OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /** | 18 /** |
19 * @fileOverview This emulates a subset of the CustomizableUI API from Firefox 2
8. | 19 * @fileOverview This emulates a subset of the CustomizableUI API from Firefox 2
8. |
20 */ | 20 */ |
21 | 21 |
22 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); | 22 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); |
23 | 23 |
24 let {Utils} = require("utils"); | 24 let {Utils} = require("utils"); |
25 | 25 |
26 // UI module has to be referenced lazily to avoid circular references | 26 // UI module has to be referenced lazily to avoid circular references |
27 XPCOMUtils.defineLazyGetter(this, "UI", () => require("ui").UI); | 27 XPCOMUtils.defineLazyGetter(this, "UI", () => require("ui").UI); |
28 | 28 |
29 let widgets = Map(); | 29 let widgets = new Map(); |
30 | 30 |
31 function getToolbox(/**Window*/ window, /**Widget*/ widget) /**Element*/ | 31 function getToolbox(/**Window*/ window, /**Widget*/ widget) /**Element*/ |
32 { | 32 { |
33 if (!("defaultArea" in widget) || !widget.defaultArea) | 33 if (!("defaultArea" in widget) || !widget.defaultArea) |
34 return null; | 34 return null; |
35 | 35 |
36 let toolbar = UI.findElement(window, widget.defaultArea); | 36 let toolbar = UI.findElement(window, widget.defaultArea); |
37 if (!toolbar) | 37 if (!toolbar) |
38 return null; | 38 return null; |
39 | 39 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 for (let [id, widget] of widgets) | 311 for (let [id, widget] of widgets) |
312 { | 312 { |
313 let toolbox = getToolbox(window, widget); | 313 let toolbox = getToolbox(window, widget); |
314 if (toolbox) | 314 if (toolbox) |
315 toolbox.removeEventListener("aftercustomization", onToolbarCustomization
, false); | 315 toolbox.removeEventListener("aftercustomization", onToolbarCustomization
, false); |
316 | 316 |
317 removeWidget(window, widget); | 317 removeWidget(window, widget); |
318 } | 318 } |
319 } | 319 } |
320 }); | 320 }); |
OLD | NEW |