| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
| 4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 Cu.import("resource://gre/modules/Services.jsm"); | 7 Cu.import("resource://gre/modules/Services.jsm"); |
| 8 | 8 |
| 9 let {Prefs} = require("prefs"); | 9 let {Prefs} = require("prefs"); |
| 10 let {WindowObserver} = require("windowObserver"); | 10 let {WindowObserver} = require("windowObserver"); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 }, | 34 }, |
| 35 | 35 |
| 36 removeFromWindow: function(window) | 36 removeFromWindow: function(window) |
| 37 { | 37 { |
| 38 if (window.location.href != this.windowUrl) | 38 if (window.location.href != this.windowUrl) |
| 39 return; | 39 return; |
| 40 this._removeFromWindow(window); | 40 this._removeFromWindow(window); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | |
| 45 * Object initializing add-on options, observes add-on manager notifications | |
| 46 * about add-on options being opened. | |
| 47 * @type nsIObserver | |
| 48 */ | |
| 49 let optionsObserver = | |
| 50 { | |
| 51 init: function() | |
| 52 { | |
| 53 Services.obs.addObserver(this, "addon-options-displayed", true); | |
| 54 onShutdown.add(function() | |
| 55 { | |
| 56 Services.obs.removeObserver(this, "addon-options-displayed"); | |
| 57 }.bind(this)); | |
| 58 }, | |
| 59 | |
| 60 initOptionsDoc: function(/**Document*/ doc) | |
| 61 { | |
| 62 function hideElement(id, hide) | |
| 63 { | |
| 64 let element = doc.getElementById(id); | |
| 65 if (element) | |
| 66 element.collapsed = hide; | |
| 67 } | |
|
Wladimir Palant
2014/07/30 07:45:40
No point to have a generic function here, we only
saroyanm
2014/07/30 09:18:32
Will keep in mind.
| |
| 68 | |
| 69 try | |
| 70 { | |
| 71 let {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm", null); | |
| 72 if (CustomizableUI) | |
|
Wladimir Palant
2014/07/30 07:45:40
This check is pointless, if the module fails to lo
| |
| 73 hideElement("abpcustomization-icondisplay", true); | |
| 74 } catch (e) {} | |
| 75 }, | |
| 76 | |
| 77 observe: function(subject, topic, data) | |
| 78 { | |
| 79 let {addonID} = require("info") | |
| 80 if (data != addonID) | |
| 81 return; | |
| 82 | |
| 83 this.initOptionsDoc(subject.QueryInterface(Ci.nsIDOMDocument)); | |
| 84 }, | |
| 85 | |
| 86 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer ence]) | |
|
Wladimir Palant
2014/07/30 07:45:40
Please import XPCOMUtils in this file. The fact th
saroyanm
2014/07/30 09:18:32
Done.
| |
| 87 }; | |
| 88 optionsObserver.init(); | |
| 89 | |
| 44 var VerticalPreferencesLayout = | 90 var VerticalPreferencesLayout = |
| 45 { | 91 { |
| 46 __proto__: WindowFeature, | 92 __proto__: WindowFeature, |
| 47 windowUrl: "chrome://adblockplus/content/ui/filters.xul", | 93 windowUrl: "chrome://adblockplus/content/ui/filters.xul", |
| 48 | 94 |
| 49 _applyToWindow: function(window) | 95 _applyToWindow: function(window) |
| 50 { | 96 { |
| 51 let content = window.document.getElementById("content"); | 97 let content = window.document.getElementById("content"); |
| 52 let splitter = window.document.getElementById("filtersSplitter"); | 98 let splitter = window.document.getElementById("filtersSplitter"); |
| 53 if (!content || !splitter) | 99 if (!content || !splitter) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 else | 232 else |
| 187 enabled = Prefs[name]; | 233 enabled = Prefs[name]; |
| 188 | 234 |
| 189 if (enabled) | 235 if (enabled) |
| 190 features[name].init(); | 236 features[name].init(); |
| 191 else | 237 else |
| 192 features[name].shutdown(); | 238 features[name].shutdown(); |
| 193 } | 239 } |
| 194 } | 240 } |
| 195 | 241 |
| 196 | |
| 197 // Initialize features and make sure to update them on changes | 242 // Initialize features and make sure to update them on changes |
| 198 for (let feature in features) | 243 for (let feature in features) |
| 199 updateFeature(feature); | 244 updateFeature(feature); |
| 200 | 245 |
| 201 Prefs.addListener(updateFeature); | 246 Prefs.addListener(updateFeature); |
| OLD | NEW |