2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-04-26 06:00:55 +00:00
|
|
|
define(['app', 'Config'], function () {
|
2013-04-26 04:45:45 +00:00
|
|
|
|
|
|
|
NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({
|
|
|
|
template : 'Shared/Toolbar/ButtonTemplate',
|
|
|
|
className: 'btn',
|
|
|
|
|
|
|
|
events: {
|
2013-04-26 06:00:55 +00:00
|
|
|
'click': 'onClick'
|
2013-04-26 04:45:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-04-26 06:00:55 +00:00
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
|
|
|
},
|
|
|
|
|
2013-04-26 04:45:45 +00:00
|
|
|
onRender: function () {
|
|
|
|
if (this.model.get('active')) {
|
|
|
|
this.$el.addClass('active');
|
|
|
|
this.invokeCallback();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-26 06:00:55 +00:00
|
|
|
onClick: function () {
|
|
|
|
|
|
|
|
NzbDrone.Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
|
|
|
this.invokeCallback();
|
|
|
|
},
|
|
|
|
|
2013-04-26 04:45:45 +00:00
|
|
|
invokeCallback: function () {
|
|
|
|
|
|
|
|
if (!this.model.ownerContext) {
|
|
|
|
throw 'ownerContext must be set.';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var callback = this.model.get('callback');
|
|
|
|
if (callback) {
|
|
|
|
callback.call(this.model.ownerContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|