[Pkg-mozext-commits] [tabmixplus] 08/13: Update changeset 13c8fb9eb0f7, add syncfrompreference and synctopreference functions, and set _lastValue on the preference instead of the item

David Prévot taffit at moszumanska.debian.org
Mon Oct 20 02:33:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit d30751925638c5e73cbd4bc0b061ce66e02e21d9
Author: onemen <tabmix.onemen at gmail.com>
Date:   Thu Oct 16 14:35:32 2014 +0300

    Update changeset 13c8fb9eb0f7, add syncfrompreference and synctopreference functions, and set _lastValue on the preference instead of the item
---
 chrome/content/preferences/links.xul      |  7 +++----
 chrome/content/preferences/mouse.xul      |  7 +++----
 chrome/content/preferences/preferences.js | 16 ++++++++++++++++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/chrome/content/preferences/links.xul b/chrome/content/preferences/links.xul
index 31b04b2..82b6a2c 100644
--- a/chrome/content/preferences/links.xul
+++ b/chrome/content/preferences/links.xul
@@ -90,10 +90,9 @@
             <checkbox_tmp id="linkTarget" label="&linkTarget.label;" preference="pref_linkTarget" observes="obs_opentabforAllLinks"/>
             <checkbox_tmp id="forceLinkToTab" label="&speLink.label;"
                           preference="pref_opentabforLinks"
-                          onsyncfrompreference="return $('pref_opentabforLinks').value != 0"
-                          onsynctopreference="var val = this.checked ? this._lastValue || 1 : 0;
-                             this._lastValue = $('opentabforLinks').value;
-                             return val;"/>
+                          control="opentabforLinks"
+                          onsyncfrompreference="return gPrefWindow.syncfrompreference(this);"
+                          onsynctopreference="return gPrefWindow.synctopreference(this, 1);"/>
             <radiogroup id="opentabforLinks" align="start" preference="pref_opentabforLinks" class="indent">
               <radio value="1" label="&speLink.allLinks;" observes="obs_opentabforLinks"/>
               <radio value="2" label="&speLink.external;" observes="obs_opentabforLinks"/>
diff --git a/chrome/content/preferences/mouse.xul b/chrome/content/preferences/mouse.xul
index 7c5a2ce..03ef48b 100644
--- a/chrome/content/preferences/mouse.xul
+++ b/chrome/content/preferences/mouse.xul
@@ -108,10 +108,9 @@
             <caption>
                <checkbox_tmp id="enableTabsScroll" label="&tabbarscrolling.caption;"
                              preference="pref_tabbarscrolling"
-                             onsyncfrompreference="return $('pref_tabbarscrolling').value != 2"
-                             onsynctopreference="var val = this.checked ? this._lastValue || 1 : 2;
-                                this._lastValue = $('tabbarscrolling').value;
-                                return val;"/>
+                             control="tabbarscrolling"
+                             onsyncfrompreference="return gPrefWindow.syncfrompreference(this);"
+                             onsynctopreference="return gPrefWindow.synctopreference(this, 1);"/>
             </caption>
             <separator class="thin"/>
             <label value="&tabbarscrolling.holdShift.label;" observes="obs_tabbarscrolling"/>
diff --git a/chrome/content/preferences/preferences.js b/chrome/content/preferences/preferences.js
index 38d0f65..5d237ce 100644
--- a/chrome/content/preferences/preferences.js
+++ b/chrome/content/preferences/preferences.js
@@ -216,6 +216,22 @@ var gPrefWindow = {
     if (typeof gMenuPane == "object" &&
         $("pref_shortcuts").value != $("shortcut-group").value)
       gMenuPane.initializeShortcuts();
+  },
+
+  // syncfrompreference and synctopreference are for checkbox preference
+  // controlled by int preference
+  syncfrompreference: function(item) {
+    let preference = $(item.getAttribute("preference"));
+    return preference.value != parseInt(preference.getAttribute("notChecked"));
+  },
+
+  synctopreference: function(item, checkedVal) {
+    let preference = $(item.getAttribute("preference"));
+    let control = $(item.getAttribute("control"));
+    let notChecked = parseInt(preference.getAttribute("notChecked"));
+    let val = item.checked ? preference._lastValue || checkedVal : notChecked;
+    preference._lastValue = control.value;
+    return val;
   }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list