Author: damoxc

Revision: 5681

Log:
        add an isObjectEmpty method to Ext to test to see if an object == {}
fix a couple of bugs in the options manager
only call core.set_config if there are changed options
call all the pages onApply method if they have one

Diff:
Modified: trunk/deluge/ui/web/js/Deluge.OptionsManager.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.OptionsManager.js     2009-08-19 23:16:19 UTC 
(rev 5680)
+++ trunk/deluge/ui/web/js/Deluge.OptionsManager.js     2009-08-19 23:17:50 UTC 
(rev 5681)
@@ -101,12 +101,17 @@
         * @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 @@
                                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 @@
                                                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;

Modified: trunk/deluge/ui/web/js/Deluge.Preferences.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Preferences.js        2009-08-19 23:16:19 UTC 
(rev 5680)
+++ trunk/deluge/ui/web/js/Deluge.Preferences.js        2009-08-19 23:17:50 UTC 
(rev 5681)
@@ -97,20 +97,26 @@
        
        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();

Modified: trunk/deluge/ui/web/js/Deluge.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.js    2009-08-19 23:16:19 UTC (rev 5680)
+++ trunk/deluge/ui/web/js/Deluge.js    2009-08-19 23:17:50 UTC (rev 5681)
@@ -45,6 +45,11 @@
        });
        
        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))



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to