 Issue 4744516900749312:
  issue #1155 - Don't allow displaying icon text with Australis theme  (Closed)
    
  
    Issue 4744516900749312:
  issue #1155 - Don't allow displaying icon text with Australis theme  (Closed) 
  | Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 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 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); | |
| 9 | 8 | 
| 10 let {Prefs} = require("prefs"); | 9 let {Prefs} = require("prefs"); | 
| 11 let {WindowObserver} = require("windowObserver"); | 10 let {WindowObserver} = require("windowObserver"); | 
| 12 | 11 | 
| 13 let CustomizableUI = null; | 12 var isAustralis = false; | 
| 
Wladimir Palant
2014/07/30 09:38:55
No point keeping a global reference to Customizabl
 
saroyanm
2014/07/30 10:56:23
Done.
 | |
| 13 try | |
| 14 { | |
| 15 Cu.import("resource:///modules/CustomizableUI.jsm", null); | |
| 16 isAustralis = true; | |
| 17 } catch(e) {} | |
| 14 | 18 | 
| 15 var WindowFeature = | 19 var WindowFeature = | 
| 16 { | 20 { | 
| 17 observer: null, | 21 observer: null, | 
| 18 | 22 | 
| 19 init: function() | 23 init: function() | 
| 20 { | 24 { | 
| 21 if (!this.observer) | 25 if (!this.observer) | 
| 22 this.observer = new WindowObserver(this, "ready"); | 26 this.observer = new WindowObserver(this, "ready"); | 
| 23 }, | 27 }, | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 36 this._applyToWindow(window); | 40 this._applyToWindow(window); | 
| 37 }, | 41 }, | 
| 38 | 42 | 
| 39 removeFromWindow: function(window) | 43 removeFromWindow: function(window) | 
| 40 { | 44 { | 
| 41 if (window.location.href != this.windowUrl) | 45 if (window.location.href != this.windowUrl) | 
| 42 return; | 46 return; | 
| 43 this._removeFromWindow(window); | 47 this._removeFromWindow(window); | 
| 44 } | 48 } | 
| 45 } | 49 } | 
| 46 | |
| 47 /** | |
| 48 * Object initializing add-on options, observes add-on manager notifications | |
| 49 * about add-on options being opened. | |
| 50 * @type nsIObserver | |
| 51 */ | |
| 52 let optionsObserver = | |
| 53 { | |
| 54 init: function() | |
| 55 { | |
| 56 Services.obs.addObserver(this, "addon-options-displayed", true); | |
| 57 onShutdown.add(function() | |
| 58 { | |
| 59 Services.obs.removeObserver(this, "addon-options-displayed"); | |
| 60 }.bind(this)); | |
| 61 }, | |
| 62 | |
| 63 initOptionsDoc: function(/**Document*/ doc) | |
| 64 { | |
| 65 if (CustomizableUI) | |
| 66 doc.getElementById("abpcustomization-icondisplay").collapsed = true; | |
| 67 }, | |
| 68 | |
| 69 observe: function(subject, topic, data) | |
| 70 { | |
| 71 let {addonID} = require("info") | |
| 72 if (data != addonID) | |
| 73 return; | |
| 74 | |
| 75 this.initOptionsDoc(subject.QueryInterface(Ci.nsIDOMDocument)); | |
| 76 }, | |
| 77 | |
| 78 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer ence]) | |
| 79 }; | |
| 80 optionsObserver.init(); | |
| 81 | 50 | 
| 82 var VerticalPreferencesLayout = | 51 var VerticalPreferencesLayout = | 
| 83 { | 52 { | 
| 84 __proto__: WindowFeature, | 53 __proto__: WindowFeature, | 
| 85 windowUrl: "chrome://adblockplus/content/ui/filters.xul", | 54 windowUrl: "chrome://adblockplus/content/ui/filters.xul", | 
| 86 | 55 | 
| 87 _applyToWindow: function(window) | 56 _applyToWindow: function(window) | 
| 88 { | 57 { | 
| 89 let content = window.document.getElementById("content"); | 58 let content = window.document.getElementById("content"); | 
| 90 let splitter = window.document.getElementById("filtersSplitter"); | 59 let splitter = window.document.getElementById("filtersSplitter"); | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 __proto__: StylesheetFeature, | 124 __proto__: StylesheetFeature, | 
| 156 stylesheet: "chrome://abpcustomization/content/oneLineSubscriptions.css" | 125 stylesheet: "chrome://abpcustomization/content/oneLineSubscriptions.css" | 
| 157 }; | 126 }; | 
| 158 | 127 | 
| 159 var RemoveActionsButton = | 128 var RemoveActionsButton = | 
| 160 { | 129 { | 
| 161 __proto__: StylesheetFeature, | 130 __proto__: StylesheetFeature, | 
| 162 stylesheet: "chrome://abpcustomization/content/noActionButton.css" | 131 stylesheet: "chrome://abpcustomization/content/noActionButton.css" | 
| 163 }; | 132 }; | 
| 164 | 133 | 
| 134 var AddonPageAustralisStyles = | |
| 135 { | |
| 136 __proto__: StylesheetFeature, | |
| 137 stylesheet: "chrome://abpcustomization/content/addonPageAustralisStyles.css" | |
| 138 }; | |
| 139 | |
| 165 var ToolbarIconDisplay = | 140 var ToolbarIconDisplay = | 
| 166 { | 141 { | 
| 167 __proto__: StylesheetFeature, | 142 __proto__: StylesheetFeature, | 
| 168 get template() | 143 get template() | 
| 169 { | 144 { | 
| 170 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(C i.nsIXMLHttpRequest); | 145 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(C i.nsIXMLHttpRequest); | 
| 171 request.open("GET", "chrome://abpcustomization/content/toolbarIconDisplay.cs s", false); | 146 request.open("GET", "chrome://abpcustomization/content/toolbarIconDisplay.cs s", false); | 
| 172 request.overrideMimeType("text/plain"); | 147 request.overrideMimeType("text/plain"); | 
| 173 request.send(); | 148 request.send(); | 
| 174 let result = request.responseText; | 149 let result = request.responseText; | 
| (...skipping 28 matching lines...) Expand all Loading... | |
| 203 stylesheet: "chrome://abpcustomization/content/hideMenus.css" | 178 stylesheet: "chrome://abpcustomization/content/hideMenus.css" | 
| 204 }; | 179 }; | 
| 205 | 180 | 
| 206 let features = | 181 let features = | 
| 207 { | 182 { | 
| 208 "addon-page-styles": AddonPageStyles, | 183 "addon-page-styles": AddonPageStyles, | 
| 209 "vertical-preferences-layout": VerticalPreferencesLayout, | 184 "vertical-preferences-layout": VerticalPreferencesLayout, | 
| 210 "preferences-one-line-subscriptions": OneLineSubscriptions, | 185 "preferences-one-line-subscriptions": OneLineSubscriptions, | 
| 211 "preferences-remove-actions-button": RemoveActionsButton, | 186 "preferences-remove-actions-button": RemoveActionsButton, | 
| 212 "toolbar-icon-display": ToolbarIconDisplay, | 187 "toolbar-icon-display": ToolbarIconDisplay, | 
| 188 "addon-page-australis-styles": AddonPageAustralisStyles, | |
| 213 "green-icon": GreenIcon, | 189 "green-icon": GreenIcon, | 
| 214 "remove-menus": RemoveMenus | 190 "remove-menus": RemoveMenus | 
| 215 }; | 191 }; | 
| 216 | 192 | 
| 217 function updateFeature(name) | 193 function updateFeature(name) | 
| 218 { | 194 { | 
| 219 try | |
| 220 { | |
| 221 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", nul l); | |
| 222 } catch (e) {} | |
| 
Wladimir Palant
2014/07/30 09:38:55
Why run this for each feature? It should be best t
 
saroyanm
2014/07/30 10:56:23
Oops, too inattentive today!
 | |
| 223 | |
| 224 if (name in features) | 195 if (name in features) | 
| 225 { | 196 { | 
| 226 let enabled; | 197 let enabled; | 
| 227 if (name == "addon-page-styles") | 198 if (name == "addon-page-styles") | 
| 228 enabled = true; | 199 enabled = true; | 
| 
Wladimir Palant
2014/07/30 09:38:55
Actually, seeing this - it's probably cleaner to i
 
saroyanm
2014/07/30 10:56:23
Awesome, great idea. How could I miss that.
 | |
| 229 else if (name == "toolbar-icon-display" && CustomizableUI) | 200 else if (name == "toolbar-icon-display" && isAustralis) | 
| 230 enabled = false; | 201 enabled = false; | 
| 202 else if (name == "addon-page-australis-styles") | |
| 203 enabled = isAustralis; | |
| 231 else | 204 else | 
| 232 enabled = Prefs[name]; | 205 enabled = Prefs[name]; | 
| 233 | 206 | 
| 234 if (enabled) | 207 if (enabled) | 
| 235 features[name].init(); | 208 features[name].init(); | 
| 236 else | 209 else | 
| 237 features[name].shutdown(); | 210 features[name].shutdown(); | 
| 238 } | 211 } | 
| 239 } | 212 } | 
| 240 | 213 | 
| 241 // Initialize features and make sure to update them on changes | 214 // Initialize features and make sure to update them on changes | 
| 242 for (let feature in features) | 215 for (let feature in features) | 
| 243 updateFeature(feature); | 216 updateFeature(feature); | 
| 244 | 217 | 
| 245 Prefs.addListener(updateFeature); | 218 Prefs.addListener(updateFeature); | 
| LEFT | RIGHT |