1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-29 11:25:26 +00:00
Radarr/UI/Shared/Toolbar/Radio/RadioButtonView.js

63 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00: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-28 23:19:00 +00:00
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 () {
2013-08-04 01:27:12 +00:00
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);
}
}
});
});