diff --git a/webext/js/folderChange.js b/webext/js/folderChange.js index 5c3ff0e..7d2a079 100644 --- a/webext/js/folderChange.js +++ b/webext/js/folderChange.js @@ -81,25 +81,6 @@ var folderChange = class extends ExtensionCommon.ExtensionAPI { }; }, }).api(), - - // An event. Most of this is boilerplate you don't need to worry about, just copy it. - onToolbarClick: new ExtensionCommon.EventManager({ - context, - name: "folderChange.onToolbarClick", - // In this function we add listeners for any events we want to listen to, and return a - // function that removes those listeners. To have the event fire in your extension, - // call fire.async. - register(fire) { - function callback(event, id, x, y) { - return fire.async(id, x, y); - } - - windowListener.add(callback); - return function () { - windowListener.remove(callback); - }; - }, - }).api(), }, }; } @@ -430,61 +411,3 @@ var SysTrayX = { this.callback = undefined; }, }; - -// This object is just what we're using to listen for toolbar clicks. The implementation isn't -// what this example is about, but you might be interested as it's a common pattern. We count the -// number of callbacks waiting for events so that we're only listening if we need to be. -var windowListener = new (class extends ExtensionCommon.EventEmitter { - constructor() { - super(); - this.callbackCount = 0; - } - - handleEvent(event) { - let toolbar = event.target.closest("toolbar"); - windowListener.emit( - "toolbar-clicked", - toolbar.id, - event.clientX, - event.clientY - ); - } - - add(callback) { - this.on("toolbar-clicked", callback); - this.callbackCount++; - - if (this.callbackCount == 1) { - ExtensionSupport.registerWindowListener("changeFolderListener", { - chromeURLs: [ - "chrome://messenger/content/messenger.xhtml", - "chrome://messenger/content/messenger.xul", - ], - onLoadWindow: function (window) { - let toolbox = window.document.getElementById("mail-toolbox"); - toolbox.addEventListener("click", windowListener.handleEvent); - }, - }); - } - } - - remove(callback) { - this.off("toolbar-clicked", callback); - this.callbackCount--; - - if (this.callbackCount == 0) { - for (let window of ExtensionSupport.openWindows) { - if ( - [ - "chrome://messenger/content/messenger.xhtml", - "chrome://messenger/content/messenger.xul", - ].includes(window.location.href) - ) { - let toolbox = window.document.getElementById("mail-toolbox"); - toolbox.removeEventListener("click", this.handleEvent); - } - } - ExtensionSupport.unregisterWindowListener("changeFolderListener"); - } - } -})(); diff --git a/webext/schema_folderchange.json b/webext/schema_folderchange.json index 9a948d5..94d8cf3 100644 --- a/webext/schema_folderchange.json +++ b/webext/schema_folderchange.json @@ -65,30 +65,6 @@ "type": "integer" } ] - }, - { - "name": "onToolbarClick", - "type": "function", - "description": "Fires when the user clicks anywhere on the toolbar in the main window.", - "parameters": [ - { - "name": "toolbarId", - "type": "string", - "description": "The ID of the toolbar the user clicked." - }, - { - "type": "integer", - "name": "x", - "minimum": 0, - "description": "The X position of the mouse when the user clicked." - }, - { - "type": "integer", - "name": "y", - "minimum": 0, - "description": "The Y position of the mouse when the user clicked." - } - ] } ] }