toolbar now saves its state for radio buttons.

pull/4/head
kay.one 12 years ago
parent 76c383dfdd
commit cf9f8b3f8a

@ -9,7 +9,6 @@ define(['app'], function () {
if (value !== undefined) { if (value !== undefined) {
NzbDrone.Config.SetValue(key, value); NzbDrone.Config.SetValue(key, value);
} }
else { else {
return NzbDrone.Config.GetValue(key, 1); return NzbDrone.Config.GetValue(key, 1);
} }
@ -40,6 +39,8 @@ define(['app'], function () {
cookie = {}; cookie = {};
} }
console.log('Config: [{0}] => [{1}] '.format(key, value));
cookie[key] = value; cookie[key] = value;
NzbDrone.Config.SetCookie(cookie); NzbDrone.Config.SetCookie(cookie);
}; };

@ -111,6 +111,9 @@
<script src="/templates.js"></script> <script src="/templates.js"></script>
<script src="/Instrumentation/StringFormat.js"></script>
<script src="/Mixins/backbone.marionette.templates.js"></script> <script src="/Mixins/backbone.marionette.templates.js"></script>
<script src="/Mixins/backbone.ajax.js"></script> <script src="/Mixins/backbone.ajax.js"></script>
<script src="/Mixins/tablesorter.extensions.js"></script> <script src="/Mixins/tablesorter.extensions.js"></script>

@ -0,0 +1,11 @@
"use strict";
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
if (typeof args[number] !== 'undefined') {
return args[number];
} else {
return match;
}
});
};

@ -40,7 +40,6 @@ define(['app'], function () {
}, },
initialize: function () { initialize: function () {
console.log('menu');
this.setElement($('#main-menu-region')); this.setElement($('#main-menu-region'));
} }
}); });

@ -1,15 +1,20 @@
"use strict"; "use strict";
define(['app'], function () { define(['app', 'Config'], function () {
NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({ NzbDrone.Shared.Toolbar.RadioButtonView = Backbone.Marionette.ItemView.extend({
template : 'Shared/Toolbar/ButtonTemplate', template : 'Shared/Toolbar/ButtonTemplate',
className: 'btn', className: 'btn',
events: { events: {
'click': 'invokeCallback' 'click': 'onClick'
}, },
initialize: function () {
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
},
onRender: function () { onRender: function () {
if (this.model.get('active')) { if (this.model.get('active')) {
this.$el.addClass('active'); this.$el.addClass('active');
@ -17,6 +22,12 @@ define(['app'], function () {
} }
}, },
onClick: function () {
NzbDrone.Config.SetValue(this.model.get('menuKey'), this.model.get('key'));
this.invokeCallback();
},
invokeCallback: function () { invokeCallback: function () {
if (!this.model.ownerContext) { if (!this.model.ownerContext) {

Loading…
Cancel
Save