| 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 16 matching lines...) Expand all Loading... |
| 27 let {Filter} = require("filterClasses"); | 27 let {Filter} = require("filterClasses"); |
| 28 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); | 28 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); |
| 29 let {Synchronizer} = require("synchronizer"); | 29 let {Synchronizer} = require("synchronizer"); |
| 30 let {KeySelector} = require("keySelector"); | 30 let {KeySelector} = require("keySelector"); |
| 31 let {Notification} = require("notification"); | 31 let {Notification} = require("notification"); |
| 32 let {initAntiAdblockNotification} = require("antiadblockInit"); | 32 let {initAntiAdblockNotification} = require("antiadblockInit"); |
| 33 | 33 |
| 34 let CustomizableUI = null; | 34 let CustomizableUI = null; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Filter corresponding with "disable on site" menu item (set in fillIconMent())
. | 37 * Filter corresponding with "disable on site" menu item (set in fillIconMenu())
. |
| 38 * @type Filter | 38 * @type Filter |
| 39 */ | 39 */ |
| 40 let siteWhitelist = null; | 40 let siteWhitelist = null; |
| 41 /** | 41 /** |
| 42 * Filter corresponding with "disable on site" menu item (set in fillIconMenu())
. | 42 * Filter corresponding with "disable on site" menu item (set in fillIconMenu())
. |
| 43 * @type Filter | 43 * @type Filter |
| 44 */ | 44 */ |
| 45 let pageWhitelist = null; | 45 let pageWhitelist = null; |
| 46 | 46 |
| 47 /** | 47 /** |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 if ("abp-status-popup" in this.overlay) | 381 if ("abp-status-popup" in this.overlay) |
| 382 { | 382 { |
| 383 let menuSource = this.overlay["abp-status-popup"]; | 383 let menuSource = this.overlay["abp-status-popup"]; |
| 384 delete this.overlay["abp-status-popup"]; | 384 delete this.overlay["abp-status-popup"]; |
| 385 | 385 |
| 386 if (this.overlay.all.length) | 386 if (this.overlay.all.length) |
| 387 this.overlay.all[0].appendChild(menuSource); | 387 this.overlay.all[0].appendChild(menuSource); |
| 388 if ("abp-toolbarbutton" in this.overlay) | 388 if ("abp-toolbarbutton" in this.overlay) |
| 389 this.overlay["abp-toolbarbutton"].appendChild(fixId(menuSource.cloneNode
(true), "abp-toolbar")); | 389 this.overlay["abp-toolbarbutton"].appendChild(fixId(menuSource.cloneNode
(true), "abp-toolbar")); |
| 390 if ("abp-menuitem" in this.overlay) | |
| 391 this.overlay["abp-menuitem"].appendChild(fixId(menuSource.cloneNode(true
), "abp-menuitem")); | |
| 392 } | 390 } |
| 393 }, | 391 }, |
| 394 | 392 |
| 395 /** | 393 /** |
| 396 * Gets called once the initialization is finished and Adblock Plus elements | 394 * Gets called once the initialization is finished and Adblock Plus elements |
| 397 * can be added to the UI. | 395 * can be added to the UI. |
| 398 */ | 396 */ |
| 399 initDone: function() | 397 initDone: function() |
| 400 { | 398 { |
| 401 // The icon might be added already, make sure its state is correct | 399 // The icon might be added already, make sure its state is correct |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 554 |
| 557 // Attach event handlers | 555 // Attach event handlers |
| 558 for (let i = 0; i < eventHandlers.length; i++) | 556 for (let i = 0; i < eventHandlers.length; i++) |
| 559 { | 557 { |
| 560 let [id, event, handler] = eventHandlers[i]; | 558 let [id, event, handler] = eventHandlers[i]; |
| 561 let element = window.document.getElementById(id); | 559 let element = window.document.getElementById(id); |
| 562 if (element) | 560 if (element) |
| 563 element.addEventListener(event, handler.bind(null, window), false); | 561 element.addEventListener(event, handler.bind(null, window), false); |
| 564 } | 562 } |
| 565 window.addEventListener("popupshowing", this.onPopupShowing, false); | 563 window.addEventListener("popupshowing", this.onPopupShowing, false); |
| 564 window.addEventListener("popuphiding", this.onPopupHiding, false); |
| 566 window.addEventListener("keypress", this.onKeyPress, false); | 565 window.addEventListener("keypress", this.onKeyPress, false); |
| 567 | 566 |
| 568 addBrowserLocationListener(window, function() | 567 addBrowserLocationListener(window, function() |
| 569 { | 568 { |
| 570 this.updateIconState(window, window.document.getElementById("abp-status"))
; | 569 this.updateIconState(window, window.document.getElementById("abp-status"))
; |
| 571 this.updateIconState(window, window.document.getElementById("abp-toolbarbu
tton")); | 570 this.updateIconState(window, window.document.getElementById("abp-toolbarbu
tton")); |
| 572 }.bind(this)); | 571 }.bind(this)); |
| 573 addBrowserClickListener(window, this.onBrowserClick.bind(this, window)); | 572 addBrowserClickListener(window, this.onBrowserClick.bind(this, window)); |
| 574 | 573 |
| 575 window.document.getElementById("abp-notification-close").addEventListener("c
ommand", function(event) | 574 window.document.getElementById("abp-notification-close").addEventListener("c
ommand", function(event) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 618 } |
| 620 else | 619 else |
| 621 { | 620 { |
| 622 let clone = window.document.getElementById(id); | 621 let clone = window.document.getElementById(id); |
| 623 if (clone) | 622 if (clone) |
| 624 clone.parentNode.removeChild(clone); | 623 clone.parentNode.removeChild(clone); |
| 625 } | 624 } |
| 626 } | 625 } |
| 627 | 626 |
| 628 window.removeEventListener("popupshowing", this.onPopupShowing, false); | 627 window.removeEventListener("popupshowing", this.onPopupShowing, false); |
| 628 window.removeEventListener("popuphiding", this.onPopupHiding, false); |
| 629 window.removeEventListener("keypress", this.onKeyPress, false); | 629 window.removeEventListener("keypress", this.onKeyPress, false); |
| 630 removeBrowserLocationListeners(window); | 630 removeBrowserLocationListeners(window); |
| 631 removeBrowserClickListeners(window); | 631 removeBrowserClickListeners(window); |
| 632 }, | 632 }, |
| 633 | 633 |
| 634 /** | 634 /** |
| 635 * The overlay information to be used when adding elements to the UI. | 635 * The overlay information to be used when adding elements to the UI. |
| 636 * @type Object | 636 * @type Object |
| 637 */ | 637 */ |
| 638 overlay: null, | 638 overlay: null, |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 let {contentContextMenu} = require("appSupport"); | 1283 let {contentContextMenu} = require("appSupport"); |
| 1284 if ((typeof contentContextMenu == "string" && popup.id == contentContextMenu
) || | 1284 if ((typeof contentContextMenu == "string" && popup.id == contentContextMenu
) || |
| 1285 (contentContextMenu instanceof Array && contentContextMenu.indexOf(popup
.id) >= 0)) | 1285 (contentContextMenu instanceof Array && contentContextMenu.indexOf(popup
.id) >= 0)) |
| 1286 { | 1286 { |
| 1287 this.fillContentContextMenu(popup); | 1287 this.fillContentContextMenu(popup); |
| 1288 } | 1288 } |
| 1289 else if (popup.id == "abp-tooltip") | 1289 else if (popup.id == "abp-tooltip") |
| 1290 this.fillIconTooltip(event, popup.ownerDocument.defaultView); | 1290 this.fillIconTooltip(event, popup.ownerDocument.defaultView); |
| 1291 else | 1291 else |
| 1292 { | 1292 { |
| 1293 let match = /^(abp-(?:toolbar|status|menuitem)-)popup$/.exec(popup.id); | 1293 let match = /^(abp-(toolbar|status|menuitem)-)popup$/.exec(popup.id); |
| 1294 if (match) | 1294 if (match) |
| 1295 this.fillIconMenu(event, popup.ownerDocument.defaultView, match[1]); | 1295 { |
| 1296 let [, prefix, name] = match; |
| 1297 if (name == "toolbar" || name == "status") |
| 1298 { |
| 1299 let window = popup.ownerDocument.defaultView; |
| 1300 let browser = window.document.getElementById(prefix + "popup-browser")
; |
| 1301 browser.setAttribute("src", "chrome://adblockplus/content/ui/popup.htm
l"); |
| 1302 } |
| 1303 else |
| 1304 this.fillIconMenu(event, popup.ownerDocument.defaultView, match[1]); |
| 1305 } |
| 1296 } | 1306 } |
| 1297 }, | 1307 }, |
| 1298 | 1308 |
| 1309 /** |
| 1310 * Called when some pop-up in the application window is being hidden |
| 1311 */ |
| 1312 onPopupHiding: function(/**Event*/ event) |
| 1313 { |
| 1314 if (event.defaultPrevented) |
| 1315 return; |
| 1316 |
| 1317 let popup = event.originalTarget; |
| 1318 if (popup.id == "abp-toolbar-popup") |
| 1319 { |
| 1320 let window = popup.ownerDocument.defaultView; |
| 1321 let browser = window.document.getElementById("abp-toolbar-popup-browser"); |
| 1322 browser.setAttribute("src", "about:blank"); |
| 1323 } |
| 1324 }, |
| 1325 |
| 1299 /** | 1326 /** |
| 1300 * Handles click on toolbar and status bar icons. | 1327 * Handles click on toolbar and status bar icons. |
| 1301 */ | 1328 */ |
| 1302 onIconClick: function(/**Event*/ event) | 1329 onIconClick: function(/**Event*/ event) |
| 1303 { | 1330 { |
| 1304 if (event.eventPhase != event.AT_TARGET) | 1331 if (event.eventPhase != event.AT_TARGET) |
| 1305 return; | 1332 return; |
| 1306 | 1333 |
| 1307 let isToolbar = (event.target.localName != "statusbarpanel"); | 1334 let isToolbar = (event.target.localName != "statusbarpanel"); |
| 1308 let action = 0; | 1335 let action = 0; |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 window.document.getElementById("abp-notification-yes").onclick = buttonHan
dler.bind(null, true); | 1945 window.document.getElementById("abp-notification-yes").onclick = buttonHan
dler.bind(null, true); |
| 1919 window.document.getElementById("abp-notification-no").onclick = buttonHand
ler.bind(null, false); | 1946 window.document.getElementById("abp-notification-no").onclick = buttonHand
ler.bind(null, false); |
| 1920 } | 1947 } |
| 1921 | 1948 |
| 1922 panel.setAttribute("class", "abp-" + notification.type); | 1949 panel.setAttribute("class", "abp-" + notification.type); |
| 1923 panel.setAttribute("noautohide", notification.type === "question"); | 1950 panel.setAttribute("noautohide", notification.type === "question"); |
| 1924 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); | 1951 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); |
| 1925 } | 1952 } |
| 1926 }; | 1953 }; |
| 1927 UI.onPopupShowing = UI.onPopupShowing.bind(UI); | 1954 UI.onPopupShowing = UI.onPopupShowing.bind(UI); |
| 1955 UI.onPopupHiding = UI.onPopupHiding.bind(UI); |
| 1928 UI.onKeyPress = UI.onKeyPress.bind(UI); | 1956 UI.onKeyPress = UI.onKeyPress.bind(UI); |
| 1929 UI.onIconClick = UI.onIconClick.bind(UI); | 1957 UI.onIconClick = UI.onIconClick.bind(UI); |
| 1930 UI.init(); | 1958 UI.init(); |
| 1931 | 1959 |
| 1932 /** | 1960 /** |
| 1933 * List of event handers to be registered for each window. For each event | 1961 * List of event handers to be registered for each window. For each event |
| 1934 * handler the element ID, event and the actual event handler are listed. | 1962 * handler the element ID, event and the actual event handler are listed. |
| 1935 * @type Array | 1963 * @type Array |
| 1936 */ | 1964 */ |
| 1937 let eventHandlers = [ | 1965 let eventHandlers = [ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1950 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1978 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1951 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1979 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1952 ]; | 1980 ]; |
| 1953 | 1981 |
| 1954 onShutdown.add(function() | 1982 onShutdown.add(function() |
| 1955 { | 1983 { |
| 1956 for (let window in UI.applicationWindows) | 1984 for (let window in UI.applicationWindows) |
| 1957 if (UI.isBottombarOpen(window)) | 1985 if (UI.isBottombarOpen(window)) |
| 1958 UI.toggleBottombar(window); | 1986 UI.toggleBottombar(window); |
| 1959 }); | 1987 }); |
| OLD | NEW |