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

Side by Side Diff: lib/ui.js

Issue 29331700: Issue 3223 - Implement context menu fallback for SeaMonkey Mail and Thunderbird (Closed)
Patch Set: Created Dec. 1, 2015, 2:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 hideElement(prefix + "contributebutton", Prefs.hideContributeButton); 1593 hideElement(prefix + "contributebutton", Prefs.hideContributeButton);
1594 }, 1594 },
1595 1595
1596 /** 1596 /**
1597 * Adds Adblock Plus menu items to the content area context menu when it shows 1597 * Adds Adblock Plus menu items to the content area context menu when it shows
1598 * up. 1598 * up.
1599 */ 1599 */
1600 fillContentContextMenu: function(/**Element*/ popup) 1600 fillContentContextMenu: function(/**Element*/ popup)
1601 { 1601 {
1602 let window = popup.ownerDocument.defaultView; 1602 let window = popup.ownerDocument.defaultView;
1603 if (!window.gContextMenuContentData || 1603 let data = window.gContextMenuContentData;
1604 typeof window.gContextMenuContentData.addonInfo != "object" || 1604 if (!data)
1605 typeof window.gContextMenuContentData.addonInfo.adblockplus != "object")
1606 { 1605 {
1607 return; 1606 // This is SeaMonkey Mail or Thunderbird, they won't get context menu data
1607 // for us. Send the notification ourselves.
1608 let event = new Event("contextmenu");
1609 Object.defineProperty(event, "target", {"get": () => popup.triggerNode});
1610 data = {
1611 event: event,
1612 addonInfo: {},
1613 get wrappedJSObject() {return this;}
1614 };
1615 Services.obs.notifyObservers(data, "content-contextmenu", null);
Wladimir Palant 2015/12/02 11:21:46 I thought a bit more about this and it's probably
1608 } 1616 }
1609 1617
1610 let items = window.gContextMenuContentData.addonInfo.adblockplus; 1618 if (typeof data.addonInfo != "object" || typeof data.addonInfo.adblockplus ! = "object")
1619 return;
1620
1621 let items = data.addonInfo.adblockplus;
1611 let clicked = null; 1622 let clicked = null;
1612 let menuItems = []; 1623 let menuItems = [];
1613 1624
1614 function menuItemTriggered(id, nodeData) 1625 function menuItemTriggered(id, nodeData)
1615 { 1626 {
1616 clicked = id; 1627 clicked = id;
1617 this.blockItem(window, id, nodeData); 1628 this.blockItem(window, id, nodeData);
1618 } 1629 }
1619 1630
1620 for (let [id, nodeData] of items) 1631 for (let [id, nodeData] of items)
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], 1898 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)],
1888 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)] 1899 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)]
1889 ]; 1900 ];
1890 1901
1891 onShutdown.add(function() 1902 onShutdown.add(function()
1892 { 1903 {
1893 for (let window of UI.applicationWindows) 1904 for (let window of UI.applicationWindows)
1894 if (UI.isBottombarOpen(window)) 1905 if (UI.isBottombarOpen(window))
1895 UI.toggleBottombar(window); 1906 UI.toggleBottombar(window);
1896 }); 1907 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld