2013-04-26 07:45:45 +03:00
|
|
|
"use strict";
|
2013-06-21 04:43:58 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'app',
|
|
|
|
'Shared/Toolbar/Radio/RadioButtonView',
|
|
|
|
'Config'
|
|
|
|
], function (App, RadioButtonView, Config) {
|
|
|
|
NzbDrone.Shared.Toolbar.RadioButtonCollectionView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
className: 'btn-group',
|
|
|
|
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
attributes: {
|
|
|
|
'data-toggle': 'buttons-radio'
|
|
|
|
},
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
initialize: function (options) {
|
|
|
|
this.menu = options.menu;
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
if (this.menu.storeState) {
|
|
|
|
this.setActive();
|
|
|
|
}
|
|
|
|
},
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
setActive: function () {
|
|
|
|
var storedKey = Config.GetValue(this.menu.menuKey, this.menu.defaultAction);
|
2013-04-26 07:45:45 +03:00
|
|
|
|
2013-06-21 04:43:58 +03:00
|
|
|
this.collection.each(function (model) {
|
|
|
|
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
|
|
|
model.set('active', true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
model.set('active, false');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2013-04-26 07:45:45 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|