mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
Moved source code under src folder - massive change
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Shared/Toolbar/Button/ButtonView'
|
||||
], function (Marionette, ButtonView) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : ButtonView
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'marionette',
|
||||
'Commands/CommandController'
|
||||
], function (App, Marionette, CommandController) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
|
||||
if (!this.model.get('title')) {
|
||||
this.$el.addClass('btn-icon-only');
|
||||
}
|
||||
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
CommandController.bindToCommand({
|
||||
command: {name: command},
|
||||
element: this.$el
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
|
||||
if (this.$el.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.invokeCallback();
|
||||
this.invokeRoute();
|
||||
this.invokeCommand();
|
||||
},
|
||||
|
||||
invokeCommand: function () {
|
||||
var command = this.model.get('command');
|
||||
if (command) {
|
||||
CommandController.Execute(command);
|
||||
}
|
||||
},
|
||||
|
||||
invokeRoute: function () {
|
||||
var route = this.model.get('route');
|
||||
if (route) {
|
||||
|
||||
require(
|
||||
[
|
||||
'Router'
|
||||
], function () {
|
||||
App.Router.navigate(route, {trigger: true});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Shared/Toolbar/ButtonModel'
|
||||
], function (Backbone, ButtonModel) {
|
||||
return Backbone.Collection.extend({
|
||||
model: ButtonModel
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
'target' : '/nzbdrone/route',
|
||||
'title' : '',
|
||||
'active' : false,
|
||||
'tooltip': undefined }
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
<i class="{{icon}} x-icon"/> {{title}}
|
||||
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Shared/Toolbar/Radio/RadioButtonView',
|
||||
'Config'
|
||||
], function (Marionette, RadioButtonView, Config) {
|
||||
return Marionette.CollectionView.extend({
|
||||
className: 'btn-group',
|
||||
itemView : RadioButtonView,
|
||||
|
||||
attributes: {
|
||||
'data-toggle': 'buttons-radio'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.menu = options.menu;
|
||||
|
||||
if (this.menu.storeState) {
|
||||
this.setActive();
|
||||
}
|
||||
},
|
||||
|
||||
setActive: function () {
|
||||
var storedKey = Config.getValue(this.menu.menuKey, this.menu.defaultAction);
|
||||
|
||||
this.collection.each(function (model) {
|
||||
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
||||
model.set('active', true);
|
||||
}
|
||||
else {
|
||||
model.set('active, false');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Config'
|
||||
], function (Marionette, Config) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Shared/Toolbar/ButtonTemplate',
|
||||
className: 'btn',
|
||||
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
|
||||
initialize: function () {
|
||||
|
||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.get('active')) {
|
||||
this.$el.addClass('active');
|
||||
this.invokeCallback();
|
||||
}
|
||||
|
||||
if(!this.model.get('title')){
|
||||
this.$el.addClass('btn-icon-only');
|
||||
}
|
||||
|
||||
if (this.model.get('tooltip')) {
|
||||
this.$el.attr('title', this.model.get('tooltip'));
|
||||
this.$el.attr('data-container', 'body');
|
||||
}
|
||||
},
|
||||
|
||||
onClick: function () {
|
||||
|
||||
Config.setValue(this.model.get('menuKey'), this.model.get('key'));
|
||||
this.invokeCallback();
|
||||
},
|
||||
|
||||
invokeCallback: function () {
|
||||
|
||||
if (!this.model.ownerContext) {
|
||||
throw 'ownerContext must be set.';
|
||||
}
|
||||
|
||||
|
||||
var callback = this.model.get('callback');
|
||||
if (callback) {
|
||||
callback.call(this.model.ownerContext);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Shared/Toolbar/ButtonCollection',
|
||||
'Shared/Toolbar/ButtonModel',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView'
|
||||
], function (Marionette, ButtonCollection, ButtonModel, RadioButtonCollectionView, ButtonCollectionView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
left_1 : '.x-toolbar-left-1',
|
||||
left_2 : '.x-toolbar-left-2',
|
||||
right_1: '.x-toolbar-right-1',
|
||||
right_2: '.x-toolbar-right-2'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
|
||||
if (!options) {
|
||||
throw 'options needs to be passed';
|
||||
}
|
||||
|
||||
if (!options.context) {
|
||||
throw 'context needs to be passed';
|
||||
}
|
||||
|
||||
this.left = options.left;
|
||||
this.right = options.right;
|
||||
this.toolbarContext = options.context;
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
if (this.left) {
|
||||
_.each(this.left, this._showToolbarLeft, this);
|
||||
}
|
||||
if (this.right) {
|
||||
_.each(this.right, this._showToolbarRight, this);
|
||||
}
|
||||
},
|
||||
|
||||
_showToolbarLeft: function (element, index) {
|
||||
this._showToolbar(element, index, 'left');
|
||||
},
|
||||
|
||||
_showToolbarRight: function (element, index) {
|
||||
this._showToolbar(element, index, 'right');
|
||||
},
|
||||
|
||||
_showToolbar: function (buttonGroup, index, position) {
|
||||
|
||||
var groupCollection = new ButtonCollection();
|
||||
|
||||
_.each(buttonGroup.items, function (button) {
|
||||
|
||||
if (buttonGroup.storeState && !button.key) {
|
||||
throw 'must provide key for all buttons when storSstate is enabled';
|
||||
}
|
||||
|
||||
var model = new ButtonModel(button);
|
||||
model.set('menuKey', buttonGroup.menuKey);
|
||||
model.ownerContext = this.toolbarContext;
|
||||
groupCollection.add(model);
|
||||
|
||||
}, this);
|
||||
|
||||
var buttonGroupView;
|
||||
|
||||
switch (buttonGroup.type) {
|
||||
case 'radio':
|
||||
{
|
||||
buttonGroupView = new RadioButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
buttonGroupView = new ButtonCollectionView({
|
||||
collection: groupCollection,
|
||||
menu : buttonGroup
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this[position + '_' + (index + 1).toString()].show(buttonGroupView);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<div class="pull-left page-toolbar">
|
||||
<div class="x-toolbar-left-1"/>
|
||||
<div class="x-toolbar-left-2"/>
|
||||
</div>
|
||||
<div class="pull-right page-toolbar">
|
||||
<div class="x-toolbar-right-1"/>
|
||||
<div class="x-toolbar-right-2"/>
|
||||
</div>
|
||||
Reference in New Issue
Block a user