Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/ui.js

Issue 5309182173511680: Issue 2211 - Implemented subscribe.adblockplus.org subscription links (Closed)
Left Patch Set: Removed redundant URL scheme check Created April 1, 2015, 2:59 p.m.
Right Patch Set: Rebased to b7c6ed7c2137 Created July 20, 2015, 1:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return; 118 return;
119 } 119 }
120 120
121 setChecked("adblockplus-savestats", Prefs.savestats); 121 setChecked("adblockplus-savestats", Prefs.savestats);
122 addCommandHandler("adblockplus-savestats", function() 122 addCommandHandler("adblockplus-savestats", function()
123 { 123 {
124 UI.toggleSaveStats(doc.defaultView); 124 UI.toggleSaveStats(doc.defaultView);
125 this.value = Prefs.savestats; 125 this.value = Prefs.savestats;
126 }); 126 });
127 127
128 hideElement("adblockplus-shownotifications", !Prefs.notifications_showui);
129 setChecked("adblockplus-shownotifications", Prefs.notifications_ignoredcat egories.indexOf("*") == -1);
130 addCommandHandler("adblockplus-shownotifications", function()
131 {
132 Notification.toggleIgnoreCategory("*");
133 this.value = (Prefs.notifications_ignoredcategories.indexOf("*") == -1);
134 });
135
128 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription && 136 let hasAcceptableAds = FilterStorage.subscriptions.some((subscription) => subscription instanceof DownloadableSubscription &&
129 subscription.url == Prefs.subscriptions_exceptionsurl); 137 subscription.url == Prefs.subscriptions_exceptionsurl);
130 setChecked("adblockplus-acceptableAds", hasAcceptableAds); 138 setChecked("adblockplus-acceptableAds", hasAcceptableAds);
131 addCommandHandler("adblockplus-acceptableAds", function() 139 addCommandHandler("adblockplus-acceptableAds", function()
132 { 140 {
133 this.value = UI.toggleAcceptableAds(); 141 this.value = UI.toggleAcceptableAds();
134 }); 142 });
135 143
136 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled); 144 setChecked("adblockplus-sync", syncEngine && syncEngine.enabled);
137 addCommandHandler("adblockplus-sync", function() 145 addCommandHandler("adblockplus-sync", function()
(...skipping 14 matching lines...) Expand all
152 // Load subscriptions data 160 // Load subscriptions data
153 let request = new XMLHttpRequest(); 161 let request = new XMLHttpRequest();
154 request.mozBackgroundRequest = true; 162 request.mozBackgroundRequest = true;
155 request.open("GET", "chrome://adblockplus/content/ui/subscriptions.xml") ; 163 request.open("GET", "chrome://adblockplus/content/ui/subscriptions.xml") ;
156 request.addEventListener("load", function() 164 request.addEventListener("load", function()
157 { 165 {
158 if (onShutdown.done) 166 if (onShutdown.done)
159 return; 167 return;
160 168
161 let currentSubscription = FilterStorage.subscriptions.filter((subscrip tion) => subscription instanceof DownloadableSubscription && 169 let currentSubscription = FilterStorage.subscriptions.filter((subscrip tion) => subscription instanceof DownloadableSubscription &&
162 subscription.url != Prefs.subscriptions_exceptionsurl && 170 subscription.url != Prefs.subscriptions_exceptionsurl &&
163 subscription.url != Prefs.subscriptions_antiadblockurl); 171 subscription.url != Prefs.subscriptions_antiadblockurl);
164 currentSubscription = (currentSubscription.length ? currentSubscriptio n[0] : null); 172 currentSubscription = (currentSubscription.length ? currentSubscriptio n[0] : null);
165 173
166 let subscriptions =request.responseXML.getElementsByTagName("subscript ion"); 174 let subscriptions =request.responseXML.getElementsByTagName("subscript ion");
167 for (let i = 0; i < subscriptions.length; i++) 175 for (let i = 0; i < subscriptions.length; i++)
168 { 176 {
169 let item = subscriptions[i]; 177 let item = subscriptions[i];
170 let url = item.getAttribute("url"); 178 let url = item.getAttribute("url");
171 if (!url) 179 if (!url)
172 continue; 180 continue;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // The icon might be added already, make sure its state is correct 410 // The icon might be added already, make sure its state is correct
403 this.updateState(); 411 this.updateState();
404 412
405 // Listen for pref and filters changes 413 // Listen for pref and filters changes
406 Prefs.addListener(function(name) 414 Prefs.addListener(function(name)
407 { 415 {
408 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul tstatusbaraction") 416 if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaul tstatusbaraction")
409 this.updateState(); 417 this.updateState();
410 else if (name == "showinstatusbar") 418 else if (name == "showinstatusbar")
411 { 419 {
412 for (let window in this.applicationWindows) 420 for (let window of this.applicationWindows)
413 this.updateStatusbarIcon(window); 421 this.updateStatusbarIcon(window);
414 } 422 }
415 }.bind(this)); 423 }.bind(this));
416 FilterNotifier.addListener(function(action) 424 FilterNotifier.addListener(function(action)
417 { 425 {
418 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") 426 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load")
419 this.updateState(); 427 this.updateState();
420 }.bind(this)); 428 }.bind(this));
421 429
422 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 430 Notification.addShowListener(notification =>
423 notificationTimer.initWithCallback(this.showNextNotification.bind(this), 431 {
424 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT) ; 432 let window = this.currentWindow;
425 onShutdown.add(() => notificationTimer.cancel()); 433 if (!window)
434 return;
435
436 let button = window.document.getElementById("abp-toolbarbutton")
437 || window.document.getElementById("abp-status");
438 if (!button)
439 return;
440
441 this._showNotification(window, button, notification);
442 });
426 443
427 // Add "anti-adblock messages" notification 444 // Add "anti-adblock messages" notification
428 initAntiAdblockNotification(); 445 initAntiAdblockNotification();
429 446
430 let documentCreationObserver = { 447 let documentCreationObserver = {
431 observe: function(subject, topic, data) 448 observe: function(subject, topic, data)
432 { 449 {
433 if (!(subject instanceof Ci.nsIDOMWindow)) 450 if (!(subject instanceof Ci.nsIDOMWindow))
434 return; 451 return;
435 452
436 this.showNextNotification(subject.location.href); 453 Notification.showNext(subject.location.href);
437 }.bind(UI) 454 }.bind(UI)
438 }; 455 };
439 Services.obs.addObserver(documentCreationObserver, "content-document-global- created", false); 456 Services.obs.addObserver(documentCreationObserver, "content-document-global- created", false);
440 onShutdown.add(function() 457 onShutdown.add(function()
441 { 458 {
442 Services.obs.removeObserver(documentCreationObserver, "content-document-gl obal-created", false); 459 Services.obs.removeObserver(documentCreationObserver, "content-document-gl obal-created", false);
443 }); 460 });
444 461
445 // Execute first-run actions if a window is open already, otherwise it 462 // Execute first-run actions if a window is open already, otherwise it
446 // will happen in applyToWindow() when a window is opened. 463 // will happen in applyToWindow() when a window is opened.
447 this.firstRunActions(this.currentWindow); 464 this.firstRunActions(this.currentWindow);
448 }, 465 },
449 466
450 addToolbarButton: function() 467 addToolbarButton: function()
451 { 468 {
452 let {WindowObserver} = require("windowObserver"); 469 let {WindowObserver} = require("windowObserver");
453 new WindowObserver(this); 470 new WindowObserver(this);
454 471
455 let {defaultToolbarPosition} = require("appSupport"); 472 let {defaultToolbarPosition} = require("appSupport");
456 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) 473 if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition)
457 { 474 {
458 try 475 try
459 { 476 {
460 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null); 477 ({CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm", null));
461 } 478 }
462 catch (e) 479 catch (e)
463 { 480 {
464 // No built-in CustomizableUI API, use our own implementation. 481 // No built-in CustomizableUI API, use our own implementation.
465 ({CustomizableUI}) = require("customizableUI"); 482 ({CustomizableUI} = require("customizableUI"));
466 } 483 }
467 484
468 CustomizableUI.createWidget({ 485 CustomizableUI.createWidget({
469 id: "abp-toolbarbutton", 486 id: "abp-toolbarbutton",
470 type: "custom", 487 type: "custom",
471 positionAttribute: "abp-iconposition", // For emulation only 488 positionAttribute: "abp-iconposition", // For emulation only
472 defaultArea: defaultToolbarPosition.parent, 489 defaultArea: defaultToolbarPosition.parent,
473 defaultBefore: defaultToolbarPosition.before, // For emulation only 490 defaultBefore: defaultToolbarPosition.before, // For emulation only
474 defaultAfter: defaultToolbarPosition.after, // For emulation only 491 defaultAfter: defaultToolbarPosition.after, // For emulation only
475 removable: true, 492 removable: true,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 window.addEventListener("popupshowing", this.onPopupShowing, false); 588 window.addEventListener("popupshowing", this.onPopupShowing, false);
572 window.addEventListener("keypress", this.onKeyPress, false); 589 window.addEventListener("keypress", this.onKeyPress, false);
573 590
574 addBrowserLocationListener(window, function() 591 addBrowserLocationListener(window, function()
575 { 592 {
576 this.updateIconState(window, window.document.getElementById("abp-status")) ; 593 this.updateIconState(window, window.document.getElementById("abp-status")) ;
577 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton")); 594 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton"));
578 }.bind(this)); 595 }.bind(this));
579 addBrowserClickListener(window, this.onBrowserClick.bind(this, window)); 596 addBrowserClickListener(window, this.onBrowserClick.bind(this, window));
580 597
581 window.document.getElementById("abp-notification-close").addEventListener("c ommand", function(event) 598 let notificationPanel = window.document.getElementById("abp-notification");
582 { 599 notificationPanel.addEventListener("command", function(event)
583 window.document.getElementById("abp-notification").hidePopup(); 600 {
601 switch (event.target.id)
602 {
603 case "abp-notification-close":
604 notificationPanel.classList.add("abp-closing");
605 break;
606 case "abp-notification-optout":
607 Notification.toggleIgnoreCategory("*", true);
608 /* FALL THROUGH */
609 case "abp-notification-hide":
610 notificationPanel.hidePopup();
611 break;
612 }
584 }, false); 613 }, false);
585 614
586 // First-run actions? 615 // First-run actions?
587 this.firstRunActions(window); 616 this.firstRunActions(window);
588 617
589 // Some people actually switch off browser.frames.enabled and are surprised 618 // Some people actually switch off browser.frames.enabled and are surprised
590 // that things stop working... 619 // that things stop working...
591 window.QueryInterface(Ci.nsIInterfaceRequestor) 620 window.QueryInterface(Ci.nsIInterfaceRequestor)
592 .getInterface(Ci.nsIWebNavigation) 621 .getInterface(Ci.nsIWebNavigation)
593 .QueryInterface(Ci.nsIDocShell) 622 .QueryInterface(Ci.nsIDocShell)
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 } 917 }
889 }, false); 918 }, false);
890 request.send(); 919 request.send();
891 } 920 }
892 else 921 else
893 notifyUser(); 922 notifyUser();
894 }, 923 },
895 924
896 /** 925 /**
897 * Handles clicks inside the browser's content area, will intercept clicks on 926 * Handles clicks inside the browser's content area, will intercept clicks on
898 * abp: links as well as links to subscribe.adblockplus.org. This can be calle d 927 * abp: links as well as links to subscribe.adblockplus.org.
899 * either with an event object or with the link target (if it is the former th en 928 */
Wladimir Palant 2015/04/01 17:49:31 Nit: Please stick to the 80 characters line limit.
Thomas Greiner 2015/04/02 14:26:43 Done. I also added a preference to my editor to no
900 * link target will be retrieved from event target). 929 onBrowserClick: function (/**Window*/ window, /**Event*/ event)
901 */ 930 {
902 onBrowserClick: function (/**Window*/ window, /**Event*/ event, /**String*/ li nkTarget) 931 // Ignore right-clicks
Wladimir Palant 2015/04/01 17:49:31 It seems that the linkTarget parameter is no longe
Thomas Greiner 2015/04/02 14:26:43 Done.
903 { 932 if (event.button == 2)
904 let link = null; 933 return;
905 if (linkTarget) 934
906 { 935 // Search the link associated with the click
907 try 936 let link = event.target;
908 { 937 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement))
909 link = new URL(linkTarget); 938 {
910 } 939 link = link.parentNode;
911 catch(ex) 940
912 { 941 if (!link)
913 // Don't handle links with invalid URLs
914 return; 942 return;
915 }
916 }
917
918 if (event)
919 {
920 // Ignore right-clicks
921 if (event.button == 2)
922 return;
923
924 // Search the link associated with the click
925 link = event.target;
926 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement))
927 {
928 link = link.parentNode;
929
930 if (!link)
931 return;
932 }
933 } 943 }
934 944
935 let queryString = null; 945 let queryString = null;
936 if (link.protocol == "http:" || link.protocol == "https:") 946 if (link.protocol == "http:" || link.protocol == "https:")
937 { 947 {
938 if (link.host == "subscribe.adblockplus.org" || link.pathname == "/") 948 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
939 queryString = link.search.substr(1); 949 queryString = link.search.substr(1);
940 } 950 }
941 else 951 else
942 { 952 {
943 // Firefox doesn't populate the "search" property for links with 953 // Firefox doesn't populate the "search" property for links with
944 // non-standard URL schemes so we need to extract the query string 954 // non-standard URL schemes so we need to extract the query string
945 // manually 955 // manually
946 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href); 956 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
947 if (match) 957 if (match)
948 queryString = match[1]; 958 queryString = match[1];
949 } 959 }
950 960
951 if (!queryString) 961 if (!queryString)
952 return; 962 return;
953 963
954 if (event) 964 // This is our link - make sure the browser doesn't handle it
955 { 965 event.preventDefault();
956 // This is our link - make sure the browser doesn't handle it 966 event.stopPropagation();
957 event.preventDefault();
958 event.stopPropagation();
959 }
960 967
961 // Decode URL parameters 968 // Decode URL parameters
962 let title = null; 969 let title = null;
963 let url = null; 970 let url = null;
964 let mainSubscriptionTitle = null; 971 let mainSubscriptionTitle = null;
965 let mainSubscriptionURL = null; 972 let mainSubscriptionURL = null;
966 for (let param of queryString.split("&")) 973 for (let param of queryString.split("&"))
967 { 974 {
968 let parts = param.split("=", 2); 975 let parts = param.split("=", 2);
969 if (parts.length != 2 || !/\S/.test(parts[1])) 976 if (parts.length != 2 || !/\S/.test(parts[1]))
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 let {defaultToolbarPosition} = require("appSupport"); 1117 let {defaultToolbarPosition} = require("appSupport");
1111 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent); 1118 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent);
1112 } 1119 }
1113 }, 1120 },
1114 1121
1115 /** 1122 /**
1116 * Updates Adblock Plus icon state for all windows. 1123 * Updates Adblock Plus icon state for all windows.
1117 */ 1124 */
1118 updateState: function() 1125 updateState: function()
1119 { 1126 {
1120 for (let window in this.applicationWindows) 1127 for (let window of this.applicationWindows)
1121 { 1128 {
1122 this.updateIconState(window, window.document.getElementById("abp-status")) ; 1129 this.updateIconState(window, window.document.getElementById("abp-status")) ;
1123 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton")); 1130 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton"));
1124 } 1131 }
1125 }, 1132 },
1126 1133
1127 /** 1134 /**
1128 * Updates Adblock Plus icon state for a single application window. 1135 * Updates Adblock Plus icon state for a single application window.
1129 */ 1136 */
1130 updateIconState: function(/**Window*/ window, /**Element*/ icon) 1137 updateIconState: function(/**Window*/ window, /**Element*/ icon)
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 1586
1580 setChecked(prefix + "disabled", !Prefs.enabled); 1587 setChecked(prefix + "disabled", !Prefs.enabled);
1581 setChecked(prefix + "frameobjects", Prefs.frameobjects); 1588 setChecked(prefix + "frameobjects", Prefs.frameobjects);
1582 setChecked(prefix + "savestats", Prefs.savestats); 1589 setChecked(prefix + "savestats", Prefs.savestats);
1583 1590
1584 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); 1591 let {defaultToolbarPosition, statusbarPosition} = require("appSupport");
1585 let hasToolbar = defaultToolbarPosition; 1592 let hasToolbar = defaultToolbarPosition;
1586 let hasStatusBar = statusbarPosition; 1593 let hasStatusBar = statusbarPosition;
1587 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); 1594 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- ");
1588 hideElement(prefix + "showinstatusbar", !hasStatusBar); 1595 hideElement(prefix + "showinstatusbar", !hasStatusBar);
1596 hideElement(prefix + "shownotifications", !Prefs.notifications_showui);
1589 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); 1597 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar);
1590 1598
1591 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); 1599 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible());
1592 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); 1600 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar);
1601 setChecked(prefix + "shownotifications", Prefs.notifications_ignoredcategori es.indexOf("*") == -1);
1593 1602
1594 let {Sync} = require("sync"); 1603 let {Sync} = require("sync");
1595 let syncEngine = Sync.getEngine(); 1604 let syncEngine = Sync.getEngine();
1596 hideElement(prefix + "sync", !syncEngine); 1605 hideElement(prefix + "sync", !syncEngine);
1597 setChecked(prefix + "sync", syncEngine && syncEngine.enabled); 1606 setChecked(prefix + "sync", syncEngine && syncEngine.enabled);
1598 1607
1599 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ? 1608 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ?
1600 Prefs.defaulttoolbaraction : 1609 Prefs.defaulttoolbaraction :
1601 Prefs.defaultstatusbaraction); 1610 Prefs.defaultstatusbaraction);
1602 setDefault(prefix + "openbottombar", defAction == 1); 1611 setDefault(prefix + "openbottombar", defAction == 1);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 Prefs.hideContributeButton = true; 1883 Prefs.hideContributeButton = true;
1875 1884
1876 for (let id of ["abp-status-contributebutton", "abp-toolbar-contributebutton ", "abp-menuitem-contributebutton"]) 1885 for (let id of ["abp-status-contributebutton", "abp-toolbar-contributebutton ", "abp-menuitem-contributebutton"])
1877 { 1886 {
1878 let button = window.document.getElementById(id); 1887 let button = window.document.getElementById(id);
1879 if (button) 1888 if (button)
1880 button.hidden = true; 1889 button.hidden = true;
1881 } 1890 }
1882 }, 1891 },
1883 1892
1884 showNextNotification: function(url)
1885 {
1886 let window = this.currentWindow;
1887 if (!window)
1888 return;
1889
1890 let button = window.document.getElementById("abp-toolbarbutton")
1891 || window.document.getElementById("abp-status");
1892 if (!button)
1893 return;
1894
1895 let notification = Notification.getNextToShow(url);
1896 if (!notification)
1897 return;
1898
1899 this._showNotification(window, button, notification);
1900 },
1901
1902 _showNotification: function(window, button, notification) 1893 _showNotification: function(window, button, notification)
1903 { 1894 {
1904 let panel = window.document.getElementById("abp-notification"); 1895 let panel = window.document.getElementById("abp-notification");
1905 if (panel.state !== "closed") 1896 if (panel.state !== "closed")
1906 return; 1897 return;
1907 1898
1908 function insertMessage(element, text, links) 1899 function insertMessage(element, text, links)
1909 { 1900 {
1910 let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); 1901 let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text);
1911 if (!match) 1902 if (!match)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 { 1948 {
1958 event.preventDefault(); 1949 event.preventDefault();
1959 event.stopPropagation(); 1950 event.stopPropagation();
1960 panel.hidePopup(); 1951 panel.hidePopup();
1961 Notification.triggerQuestionListeners(notification.id, approved) 1952 Notification.triggerQuestionListeners(notification.id, approved)
1962 Notification.markAsShown(notification.id); 1953 Notification.markAsShown(notification.id);
1963 } 1954 }
1964 window.document.getElementById("abp-notification-yes").onclick = buttonHan dler.bind(null, true); 1955 window.document.getElementById("abp-notification-yes").onclick = buttonHan dler.bind(null, true);
1965 window.document.getElementById("abp-notification-no").onclick = buttonHand ler.bind(null, false); 1956 window.document.getElementById("abp-notification-no").onclick = buttonHand ler.bind(null, false);
1966 } 1957 }
1958 else
1959 Notification.markAsShown(notification.id);
1967 1960
1968 panel.setAttribute("class", "abp-" + notification.type); 1961 panel.setAttribute("class", "abp-" + notification.type);
1969 panel.setAttribute("noautohide", notification.type === "question"); 1962 panel.setAttribute("noautohide", notification.type === "question");
1970 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); 1963 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null);
1971 } 1964 }
1972 }; 1965 };
1973 UI.onPopupShowing = UI.onPopupShowing.bind(UI); 1966 UI.onPopupShowing = UI.onPopupShowing.bind(UI);
1974 UI.onKeyPress = UI.onKeyPress.bind(UI); 1967 UI.onKeyPress = UI.onKeyPress.bind(UI);
1975 UI.onIconClick = UI.onIconClick.bind(UI); 1968 UI.onIconClick = UI.onIconClick.bind(UI);
1976 UI.init(); 1969 UI.init();
1977 1970
1978 /** 1971 /**
1979 * List of event handers to be registered for each window. For each event 1972 * List of event handers to be registered for each window. For each event
1980 * handler the element ID, event and the actual event handler are listed. 1973 * handler the element ID, event and the actual event handler are listed.
1981 * @type Array 1974 * @type Array
1982 */ 1975 */
1983 let eventHandlers = [ 1976 let eventHandlers = [
1984 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], 1977 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)],
1985 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], 1978 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)],
1986 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], 1979 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)],
1987 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], 1980 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }],
1988 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], 1981 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }],
1989 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], 1982 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )],
1990 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], 1983 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)],
1991 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], 1984 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)],
1992 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], 1985 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)],
1993 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], 1986 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")],
1994 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], 1987 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")],
1995 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 1988 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
1996 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] 1989 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)],
1990 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)]
1997 ]; 1991 ];
1998 1992
1999 onShutdown.add(function() 1993 onShutdown.add(function()
2000 { 1994 {
2001 for (let window in UI.applicationWindows) 1995 for (let window of UI.applicationWindows)
2002 if (UI.isBottombarOpen(window)) 1996 if (UI.isBottombarOpen(window))
2003 UI.toggleBottombar(window); 1997 UI.toggleBottombar(window);
2004 }); 1998 });
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld