1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-25 02:30:20 +02:00
Sonarr/UI/Shared/Toolbar/Radio/RadioButtonView.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'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();
}
2013-06-29 02:19:00 +03:00
if(!this.model.get('title')){
this.$el.addClass('btn-icon-only');
}
},
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);
}
}
});
});