| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 { | 406 { |
| 407 let {WindowObserver} = require("windowObserver"); | 407 let {WindowObserver} = require("windowObserver"); |
| 408 new WindowObserver(this); | 408 new WindowObserver(this); |
| 409 | 409 |
| 410 // Add toolbar icon | 410 // Add toolbar icon |
| 411 let {defaultToolbarPosition} = require("appSupport"); | 411 let {defaultToolbarPosition} = require("appSupport"); |
| 412 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) | 412 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) |
| 413 { | 413 { |
| 414 CustomizableUI.createWidget({ | 414 CustomizableUI.createWidget({ |
| 415 id: "abp-toolbarbutton", | 415 id: "abp-toolbarbutton", |
| 416 positionAttribute: "abp-iconposition", | 416 type: "custom", |
| 417 positionAttribute: "abp-iconposition", // For emulation only | |
| 417 defaultArea: defaultToolbarPosition.parent, | 418 defaultArea: defaultToolbarPosition.parent, |
| 418 defaultBefore: defaultToolbarPosition.before, | 419 defaultBefore: defaultToolbarPosition.before, // For emulation only |
| 419 defaultAfter: defaultToolbarPosition.after, | 420 defaultAfter: defaultToolbarPosition.after, // For emulation only |
| 420 removable: true, | 421 removable: true, |
| 421 onCreated: function(node) | 422 onBuild: function(document) |
| 422 { | 423 { |
|
tschuster
2014/05/15 20:12:30
We can probably make these arrow functions when I
Wladimir Palant
2014/07/11 07:15:54
Don't think so, arrow functions are for trivial fu
| |
| 423 for (let attribute of this.overlay["abp-toolbarbutton"].attributes) | 424 let node = document.importNode(this.overlay["abp-toolbarbutton"], true ); |
| 424 node.setAttribute(attribute.name, attribute.value); | 425 this.updateIconState(document.defaultView, node); |
| 425 if (!node.firstChild) | 426 return node; |
| 426 for (let child of this.overlay["abp-toolbarbutton"].children) | 427 }.bind(this), |
| 427 node.appendChild(child.cloneNode(true)); | 428 onAdded: function(node) |
| 428 if ("addClass" in defaultToolbarPosition) | 429 { |
| 429 icon.classList.add(defaultToolbarPosition.addClass); | 430 // For emulation only, this callback isn't part of the official |
| 430 | 431 // CustomizableUI API. |
| 431 this.updateIconState(node.ownerDocument.defaultView, node); | 432 this.updateIconState(node.ownerDocument.defaultView, node); |
| 432 }.bind(this), | 433 }.bind(this), |
| 433 onClick: this.onIconClick, | 434 onClick: this.onIconClick, |
| 434 onCommand: this.onIconCommand | 435 onCommand: this.onIconCommand |
|
Wladimir Palant
2013/12/02 15:14:18
These two lines don't actually do anything, they a
| |
| 435 }); | 436 }); |
| 436 onShutdown.add(CustomizableUI.destroyWidget.bind(CustomizableUI, "abp-tool barbutton")); | 437 onShutdown.add(CustomizableUI.destroyWidget.bind(CustomizableUI, "abp-tool barbutton")); |
| 437 } | 438 } |
| 438 | 439 |
| 439 // Listen for pref and filters changes | 440 // Listen for pref and filters changes |
| 440 Prefs.addListener(function(name) | 441 Prefs.addListener(function(name) |
| 441 { | 442 { |
| 442 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul tstatusbaraction") | 443 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul tstatusbaraction") |
| 443 this.updateState(); | 444 this.updateState(); |
| 444 else if (name == "showinstatusbar") | 445 else if (name == "showinstatusbar") |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 | 997 |
| 997 /** | 998 /** |
| 998 * Toggles visibility state of the toolbar icon. | 999 * Toggles visibility state of the toolbar icon. |
| 999 */ | 1000 */ |
| 1000 toggleToolbarIcon: function() | 1001 toggleToolbarIcon: function() |
| 1001 { | 1002 { |
| 1002 if (this.isToolbarIconVisible()) | 1003 if (this.isToolbarIconVisible()) |
| 1003 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); | 1004 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); |
| 1004 else | 1005 else |
| 1005 { | 1006 { |
| 1006 let {defaultToolbarPosition} = require("appSupport"); | 1007 let {defaultToolbarPosition} = require("appSupport"); |
|
tschuster
2014/05/15 20:12:30
From the rest of the code it looks like this can b
Wladimir Palant
2014/07/11 07:15:54
No, it cannot - nothing would call toggleToolbarIc
| |
| 1007 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent); | 1008 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent); |
| 1008 } | 1009 } |
| 1009 }, | 1010 }, |
| 1010 | 1011 |
| 1011 /** | 1012 /** |
| 1012 * Updates Adblock Plus icon state for all windows. | 1013 * Updates Adblock Plus icon state for all windows. |
| 1013 */ | 1014 */ |
| 1014 updateState: function() | 1015 updateState: function() |
| 1015 { | 1016 { |
| 1016 for (let window in this.applicationWindows) | 1017 for (let window in this.applicationWindows) |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1857 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1858 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1858 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1859 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1859 ]; | 1860 ]; |
| 1860 | 1861 |
| 1861 onShutdown.add(function() | 1862 onShutdown.add(function() |
| 1862 { | 1863 { |
| 1863 for (let window in UI.applicationWindows) | 1864 for (let window in UI.applicationWindows) |
| 1864 if (UI.isBottombarOpen(window)) | 1865 if (UI.isBottombarOpen(window)) |
| 1865 UI.toggleBottombar(window); | 1866 UI.toggleBottombar(window); |
| 1866 }); | 1867 }); |
| LEFT | RIGHT |