diff --git a/deluge/ui/web/js/Deluge.OptionsManager.js b/deluge/ui/web/js/Deluge.OptionsManager.js index 091042413..48bf70a36 100644 --- a/deluge/ui/web/js/Deluge.OptionsManager.js +++ b/deluge/ui/web/js/Deluge.OptionsManager.js @@ -101,12 +101,17 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @returns {Object} the options value. */ get: function() { + if (arguments.length == 1) { + var option = arguments[0]; + return (this.isDirty(option)) ? this.changed[option] : this.options[option]; + } else { var options = {}; Ext.each(arguments, function(option) { if (!this.has(option)) return; options[option] = (this.isDirty(option)) ? this.changed[option] : this.options[option]; }, this); return options; + } }, /** @@ -190,16 +195,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { this.update(key, option[key]); } } else { - var oldValue = this.get(option); - if (oldValue == value) return; - var defaultValue = this.getDefault(option); - if (defaultValue == value) { - if (this.isDirty(option)) delete this.changed[option]; - this.fireEvent('changed', option, value, oldValue); - return; - } - if (Ext.type(defaultValue) != Ext.type(value)) { switch (Ext.type(defaultValue)) { case 'string': @@ -212,6 +208,15 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { value = Boolean(value); break; } + } + + var oldValue = this.get(option); + if (oldValue == value) return; + + if (defaultValue == value) { + if (this.isDirty(option)) delete this.changed[option]; + this.fireEvent('changed', option, value, oldValue); + return; } this.changed[option] = value; diff --git a/deluge/ui/web/js/Deluge.Preferences.js b/deluge/ui/web/js/Deluge.Preferences.js index bca22e2f8..19ad08130 100644 --- a/deluge/ui/web/js/Deluge.Preferences.js +++ b/deluge/ui/web/js/Deluge.Preferences.js @@ -97,20 +97,26 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, { onApply: function(e) { var changed = this.optionsManager.getDirty(); - Deluge.Client.core.set_config(changed, { - success: this.onSetConfig, - scope: this - }); + if (!Ext.isObjectEmpty(changed)) { + Deluge.Client.core.set_config(changed, { + success: this.onSetConfig, + scope: this + }); + } + + for (var page in this.pages) { + if (this.pages[page].onApply) this.pages[page].onApply(); + } }, onClose: function() { this.hide(); }, - onOk: function() { + onOk: function() { Deluge.Client.core.set_config(this.optionsManager.getDirty()); - this.hide(); - }, + this.hide(); + }, addPage: function(page) { var store = this.categoriesGrid.getStore(); diff --git a/deluge/ui/web/js/Deluge.js b/deluge/ui/web/js/Deluge.js index c6b6e2b2e..d948a7aec 100644 --- a/deluge/ui/web/js/Deluge.js +++ b/deluge/ui/web/js/Deluge.js @@ -45,6 +45,11 @@ Ext.namespace('Ext.deluge'); }); Ext.apply(Ext, { + isObjectEmpty: function(obj) { + for(var i in obj) { return false; } + return true; + }, + keys: function(obj) { var keys = []; for (i in obj) if (obj.hasOwnProperty(i))