OLD | NEW |
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-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 14 matching lines...) Expand all Loading... |
25 let {FilterStorage} = require("filterStorage"); | 25 let {FilterStorage} = require("filterStorage"); |
26 let {FilterNotifier} = require("filterNotifier"); | 26 let {FilterNotifier} = require("filterNotifier"); |
27 let {RequestNotifier} = require("requestNotifier"); | 27 let {RequestNotifier} = require("requestNotifier"); |
28 let {Filter} = require("filterClasses"); | 28 let {Filter} = require("filterClasses"); |
29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); | 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); |
30 let {Synchronizer} = require("synchronizer"); | 30 let {Synchronizer} = require("synchronizer"); |
31 let {KeySelector} = require("keySelector"); | 31 let {KeySelector} = require("keySelector"); |
32 let {Notification} = require("notification"); | 32 let {Notification} = require("notification"); |
33 let {initAntiAdblockNotification} = require("antiadblockInit"); | 33 let {initAntiAdblockNotification} = require("antiadblockInit"); |
34 | 34 |
35 let CustomizableUI; | 35 let CustomizableUI = null; |
36 try | |
37 { | |
38 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null)
; | |
39 } | |
40 catch (e) | |
41 { | |
42 // No built-in CustomizableUI API, use our own implementation. | |
43 ({CustomizableUI}) = require("customizableUI"); | |
44 } | |
45 | 36 |
46 /** | 37 /** |
47 * Filter corresponding with "disable on site" menu item (set in fillIconMent())
. | 38 * Filter corresponding with "disable on site" menu item (set in fillIconMent())
. |
48 * @type Filter | 39 * @type Filter |
49 */ | 40 */ |
50 let siteWhitelist = null; | 41 let siteWhitelist = null; |
51 /** | 42 /** |
52 * Filter corresponding with "disable on site" menu item (set in fillIconMenu())
. | 43 * Filter corresponding with "disable on site" menu item (set in fillIconMenu())
. |
53 * @type Filter | 44 * @type Filter |
54 */ | 45 */ |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 */ | 396 */ |
406 initDone: function() | 397 initDone: function() |
407 { | 398 { |
408 let {WindowObserver} = require("windowObserver"); | 399 let {WindowObserver} = require("windowObserver"); |
409 new WindowObserver(this); | 400 new WindowObserver(this); |
410 | 401 |
411 // Add toolbar icon | 402 // Add toolbar icon |
412 let {defaultToolbarPosition} = require("appSupport"); | 403 let {defaultToolbarPosition} = require("appSupport"); |
413 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) | 404 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) |
414 { | 405 { |
| 406 try |
| 407 { |
| 408 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm",
null); |
| 409 } |
| 410 catch (e) |
| 411 { |
| 412 // No built-in CustomizableUI API, use our own implementation. |
| 413 ({CustomizableUI}) = require("customizableUI"); |
| 414 } |
| 415 |
415 CustomizableUI.createWidget({ | 416 CustomizableUI.createWidget({ |
416 id: "abp-toolbarbutton", | 417 id: "abp-toolbarbutton", |
417 type: "custom", | 418 type: "custom", |
418 positionAttribute: "abp-iconposition", // For emulation only | 419 positionAttribute: "abp-iconposition", // For emulation only |
419 defaultArea: defaultToolbarPosition.parent, | 420 defaultArea: defaultToolbarPosition.parent, |
420 defaultBefore: defaultToolbarPosition.before, // For emulation only | 421 defaultBefore: defaultToolbarPosition.before, // For emulation only |
421 defaultAfter: defaultToolbarPosition.after, // For emulation only | 422 defaultAfter: defaultToolbarPosition.after, // For emulation only |
422 removable: true, | 423 removable: true, |
423 onBuild: function(document) | 424 onBuild: function(document) |
424 { | 425 { |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1028 } |
1028 | 1029 |
1029 return [parent, before]; | 1030 return [parent, before]; |
1030 }, | 1031 }, |
1031 | 1032 |
1032 /** | 1033 /** |
1033 * Toggles visibility state of the toolbar icon. | 1034 * Toggles visibility state of the toolbar icon. |
1034 */ | 1035 */ |
1035 toggleToolbarIcon: function() | 1036 toggleToolbarIcon: function() |
1036 { | 1037 { |
| 1038 if (!CustomizableUI) |
| 1039 return; |
1037 if (this.isToolbarIconVisible()) | 1040 if (this.isToolbarIconVisible()) |
1038 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); | 1041 CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); |
1039 else | 1042 else |
1040 { | 1043 { |
1041 let {defaultToolbarPosition} = require("appSupport"); | 1044 let {defaultToolbarPosition} = require("appSupport"); |
1042 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition
.parent); | 1045 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition
.parent); |
1043 } | 1046 } |
1044 }, | 1047 }, |
1045 | 1048 |
1046 /** | 1049 /** |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 command.doCommand(); | 1704 command.doCommand(); |
1702 } | 1705 } |
1703 } | 1706 } |
1704 }, | 1707 }, |
1705 | 1708 |
1706 /** | 1709 /** |
1707 * Checks whether the toolbar icon is currently displayed. | 1710 * Checks whether the toolbar icon is currently displayed. |
1708 */ | 1711 */ |
1709 isToolbarIconVisible: function() /**Boolean*/ | 1712 isToolbarIconVisible: function() /**Boolean*/ |
1710 { | 1713 { |
| 1714 if (!CustomizableUI) |
| 1715 return false; |
1711 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 1716 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
1712 return !!placement; | 1717 return !!placement; |
1713 }, | 1718 }, |
1714 | 1719 |
1715 /** | 1720 /** |
1716 * Stores the selected hotkeys, initialized when the user presses a key. | 1721 * Stores the selected hotkeys, initialized when the user presses a key. |
1717 */ | 1722 */ |
1718 hotkeys: null, | 1723 hotkeys: null, |
1719 | 1724 |
1720 /** | 1725 /** |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1917 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1913 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1918 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1914 ]; | 1919 ]; |
1915 | 1920 |
1916 onShutdown.add(function() | 1921 onShutdown.add(function() |
1917 { | 1922 { |
1918 for (let window in UI.applicationWindows) | 1923 for (let window in UI.applicationWindows) |
1919 if (UI.isBottombarOpen(window)) | 1924 if (UI.isBottombarOpen(window)) |
1920 UI.toggleBottombar(window); | 1925 UI.toggleBottombar(window); |
1921 }); | 1926 }); |
OLD | NEW |