1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Shared/Toolbar/Radio/RadioButtonCollectionView.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
2013-06-21 04:43:58 +03:00
define(
[
'marionette',
2013-06-21 04:43:58 +03:00
'Shared/Toolbar/Radio/RadioButtonView',
'Config'
], function (Marionette, RadioButtonView, Config) {
return Marionette.CollectionView.extend({
2013-06-21 04:43:58 +03:00
className: 'btn-group',
itemView : RadioButtonView,
2013-06-21 04:43:58 +03:00
attributes: {
'data-toggle': 'buttons-radio'
},
2013-06-21 04:43:58 +03:00
initialize: function (options) {
this.menu = options.menu;
2013-06-21 04:43:58 +03:00
if (this.menu.storeState) {
this.setActive();
}
},
2013-06-21 04:43:58 +03:00
setActive: function () {
2013-08-04 04:27:12 +03:00
var storedKey = Config.getValue(this.menu.menuKey, this.menu.defaultAction);
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');
}
});
}
});
});