2013-04-26 07:45:45 +03:00
|
|
|
"use strict";
|
2013-04-26 09:00:55 +03:00
|
|
|
define(['app', 'Config'], function () {
|
2013-04-26 07:45:45 +03:00
|
|
|
|
|
|
|
NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({
|
|
|
|
template : 'Shared/Toolbar/ButtonTemplate',
|
|
|
|
className: 'btn',
|
|
|
|
|
|
|
|
events: {
|
2013-04-26 09:00:55 +03:00
|
|
|
'click': 'onClick'
|
2013-04-26 07:45:45 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-04-26 09:00:55 +03:00
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
|
|
|
},
|
|
|
|
|
2013-04-26 07:45:45 +03:00
|
|
|
onRender: function () {
|
|
|
|
if (this.model.get('active')) {
|
|
|
|
this.$el.addClass('active');
|
|
|
|
this.invokeCallback();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-26 09:00:55 +03:00
|
|
|
onClick: function () {
|
|
|
|
|
|
|
|
NzbDrone.Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
|
|
|
|
this.invokeCallback();
|
|
|
|
},
|
|
|
|
|
2013-04-26 07:45:45 +03: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|