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: Created April 1, 2015, 11:56 a.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 */
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
903 { 932 if (event.button == 2)
904 if (event) 933 return;
905 { 934
906 // Ignore right-clicks 935 // Search the link associated with the click
907 if (event.button == 2) 936 let link = event.target;
937 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement))
938 {
939 link = link.parentNode;
940
941 if (!link)
908 return; 942 return;
909 943 }
910 // Search the link associated with the click 944
911 let link = event.target; 945 let queryString = null;
912 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) 946 if (link.protocol == "http:" || link.protocol == "https:")
913 { 947 {
914 link = link.parentNode; 948 if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
915 949 queryString = link.search.substr(1);
916 if (!link) 950 }
917 return; 951 else
918 } 952 {
919 linkTarget = link.href; 953 // Firefox doesn't populate the "search" property for links with
920 } 954 // non-standard URL schemes so we need to extract the query string
921 955 // manually
922 let match = /^(?:abp:\/*subscribe|https?:\/*subscribe\.adblockplus\.org)\/*\ ?(.*)/i.exec(linkTarget); 956 let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
Sebastian Noack 2015/04/01 12:29:49 I think we should use DOM API's (i.e. the anchor e
Thomas Greiner 2015/04/01 12:41:15 It's a different situation than on Chrome since we
Sebastian Noack 2015/04/01 12:44:20 I'm not sure what you mean. Since you already use
Thomas Greiner 2015/04/01 12:51:30 There are two ways to get a link target here. One
923 if (!match) 957 if (match)
924 return; 958 queryString = match[1];
925 959 }
926 if (event) 960
927 { 961 if (!queryString)
928 // This is our link - make sure the browser doesn't handle it 962 return;
929 event.preventDefault(); 963
930 event.stopPropagation(); 964 // This is our link - make sure the browser doesn't handle it
931 } 965 event.preventDefault();
966 event.stopPropagation();
932 967
933 // Decode URL parameters 968 // Decode URL parameters
934 let title = null; 969 let title = null;
935 let url = null; 970 let url = null;
936 let mainSubscriptionTitle = null; 971 let mainSubscriptionTitle = null;
937 let mainSubscriptionURL = null; 972 let mainSubscriptionURL = null;
938 for (let param of match[1].split("&")) 973 for (let param of queryString.split("&"))
939 { 974 {
940 let parts = param.split("=", 2); 975 let parts = param.split("=", 2);
941 if (parts.length != 2 || !/\S/.test(parts[1])) 976 if (parts.length != 2 || !/\S/.test(parts[1]))
942 continue; 977 continue;
943 switch (parts[0]) 978 switch (parts[0])
944 { 979 {
945 case "title": 980 case "title":
946 title = decodeURIComponent(parts[1]); 981 title = decodeURIComponent(parts[1]);
947 break; 982 break;
948 case "location": 983 case "location":
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 let {defaultToolbarPosition} = require("appSupport"); 1117 let {defaultToolbarPosition} = require("appSupport");
1083 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent); 1118 CustomizableUI.addWidgetToArea("abp-toolbarbutton", defaultToolbarPosition .parent);
1084 } 1119 }
1085 }, 1120 },
1086 1121
1087 /** 1122 /**
1088 * Updates Adblock Plus icon state for all windows. 1123 * Updates Adblock Plus icon state for all windows.
1089 */ 1124 */
1090 updateState: function() 1125 updateState: function()
1091 { 1126 {
1092 for (let window in this.applicationWindows) 1127 for (let window of this.applicationWindows)
1093 { 1128 {
1094 this.updateIconState(window, window.document.getElementById("abp-status")) ; 1129 this.updateIconState(window, window.document.getElementById("abp-status")) ;
1095 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton")); 1130 this.updateIconState(window, window.document.getElementById("abp-toolbarbu tton"));
1096 } 1131 }
1097 }, 1132 },
1098 1133
1099 /** 1134 /**
1100 * Updates Adblock Plus icon state for a single application window. 1135 * Updates Adblock Plus icon state for a single application window.
1101 */ 1136 */
1102 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
1551 1586
1552 setChecked(prefix + "disabled", !Prefs.enabled); 1587 setChecked(prefix + "disabled", !Prefs.enabled);
1553 setChecked(prefix + "frameobjects", Prefs.frameobjects); 1588 setChecked(prefix + "frameobjects", Prefs.frameobjects);
1554 setChecked(prefix + "savestats", Prefs.savestats); 1589 setChecked(prefix + "savestats", Prefs.savestats);
1555 1590
1556 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); 1591 let {defaultToolbarPosition, statusbarPosition} = require("appSupport");
1557 let hasToolbar = defaultToolbarPosition; 1592 let hasToolbar = defaultToolbarPosition;
1558 let hasStatusBar = statusbarPosition; 1593 let hasStatusBar = statusbarPosition;
1559 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); 1594 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- ");
1560 hideElement(prefix + "showinstatusbar", !hasStatusBar); 1595 hideElement(prefix + "showinstatusbar", !hasStatusBar);
1596 hideElement(prefix + "shownotifications", !Prefs.notifications_showui);
1561 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); 1597 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar);
1562 1598
1563 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); 1599 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible());
1564 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); 1600 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar);
1601 setChecked(prefix + "shownotifications", Prefs.notifications_ignoredcategori es.indexOf("*") == -1);
1565 1602
1566 let {Sync} = require("sync"); 1603 let {Sync} = require("sync");
1567 let syncEngine = Sync.getEngine(); 1604 let syncEngine = Sync.getEngine();
1568 hideElement(prefix + "sync", !syncEngine); 1605 hideElement(prefix + "sync", !syncEngine);
1569 setChecked(prefix + "sync", syncEngine && syncEngine.enabled); 1606 setChecked(prefix + "sync", syncEngine && syncEngine.enabled);
1570 1607
1571 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ? 1608 let defAction = (!window.document.popupNode || window.document.popupNode.id == "abp-toolbarbutton" ?
1572 Prefs.defaulttoolbaraction : 1609 Prefs.defaulttoolbaraction :
1573 Prefs.defaultstatusbaraction); 1610 Prefs.defaultstatusbaraction);
1574 setDefault(prefix + "openbottombar", defAction == 1); 1611 setDefault(prefix + "openbottombar", defAction == 1);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 Prefs.hideContributeButton = true; 1883 Prefs.hideContributeButton = true;
1847 1884
1848 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"])
1849 { 1886 {
1850 let button = window.document.getElementById(id); 1887 let button = window.document.getElementById(id);
1851 if (button) 1888 if (button)
1852 button.hidden = true; 1889 button.hidden = true;
1853 } 1890 }
1854 }, 1891 },
1855 1892
1856 showNextNotification: function(url)
1857 {
1858 let window = this.currentWindow;
1859 if (!window)
1860 return;
1861
1862 let button = window.document.getElementById("abp-toolbarbutton")
1863 || window.document.getElementById("abp-status");
1864 if (!button)
1865 return;
1866
1867 let notification = Notification.getNextToShow(url);
1868 if (!notification)
1869 return;
1870
1871 this._showNotification(window, button, notification);
1872 },
1873
1874 _showNotification: function(window, button, notification) 1893 _showNotification: function(window, button, notification)
1875 { 1894 {
1876 let panel = window.document.getElementById("abp-notification"); 1895 let panel = window.document.getElementById("abp-notification");
1877 if (panel.state !== "closed") 1896 if (panel.state !== "closed")
1878 return; 1897 return;
1879 1898
1880 function insertMessage(element, text, links) 1899 function insertMessage(element, text, links)
1881 { 1900 {
1882 let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); 1901 let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text);
1883 if (!match) 1902 if (!match)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 { 1948 {
1930 event.preventDefault(); 1949 event.preventDefault();
1931 event.stopPropagation(); 1950 event.stopPropagation();
1932 panel.hidePopup(); 1951 panel.hidePopup();
1933 Notification.triggerQuestionListeners(notification.id, approved) 1952 Notification.triggerQuestionListeners(notification.id, approved)
1934 Notification.markAsShown(notification.id); 1953 Notification.markAsShown(notification.id);
1935 } 1954 }
1936 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);
1937 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);
1938 } 1957 }
1958 else
1959 Notification.markAsShown(notification.id);
1939 1960
1940 panel.setAttribute("class", "abp-" + notification.type); 1961 panel.setAttribute("class", "abp-" + notification.type);
1941 panel.setAttribute("noautohide", notification.type === "question"); 1962 panel.setAttribute("noautohide", notification.type === "question");
1942 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); 1963 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null);
1943 } 1964 }
1944 }; 1965 };
1945 UI.onPopupShowing = UI.onPopupShowing.bind(UI); 1966 UI.onPopupShowing = UI.onPopupShowing.bind(UI);
1946 UI.onKeyPress = UI.onKeyPress.bind(UI); 1967 UI.onKeyPress = UI.onKeyPress.bind(UI);
1947 UI.onIconClick = UI.onIconClick.bind(UI); 1968 UI.onIconClick = UI.onIconClick.bind(UI);
1948 UI.init(); 1969 UI.init();
1949 1970
1950 /** 1971 /**
1951 * 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
1952 * 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.
1953 * @type Array 1974 * @type Array
1954 */ 1975 */
1955 let eventHandlers = [ 1976 let eventHandlers = [
1956 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], 1977 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)],
1957 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], 1978 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)],
1958 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], 1979 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)],
1959 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], 1980 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }],
1960 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], 1981 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }],
1961 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], 1982 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )],
1962 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], 1983 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)],
1963 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], 1984 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)],
1964 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], 1985 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)],
1965 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], 1986 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")],
1966 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], 1987 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")],
1967 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 1988 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
1968 ["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)]
1969 ]; 1991 ];
1970 1992
1971 onShutdown.add(function() 1993 onShutdown.add(function()
1972 { 1994 {
1973 for (let window in UI.applicationWindows) 1995 for (let window of UI.applicationWindows)
1974 if (UI.isBottombarOpen(window)) 1996 if (UI.isBottombarOpen(window))
1975 UI.toggleBottombar(window); 1997 UI.toggleBottombar(window);
1976 }); 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