Created
April 27, 2012 16:37
-
-
Save gregglind/2510642 to your computer and use it in GitHub Desktop.
example notifcationbox addon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const observer = require("observer-service"); | |
const tabs = require("tabs"); | |
const widgets = require("widget"); | |
const { WindowTracker, isBrowser } = require('api-utils/window-utils'); | |
var widget = widgets.Widget({ | |
id: "mozilla-link", | |
label: "Mozilla website", | |
contentURL: "http://www.mozilla.org/favicon.ico", | |
onClick: function() { | |
//tabs.activeTab.url = "http://www.mozilla.org/"; | |
appendNotification("here is my message"); | |
} | |
}); | |
console.log("The add-on is running."); | |
// notification box? | |
//https://developer.mozilla.org/en/XUL/notificationbox | |
// inspired by: https://github.com/erikvold/menuitems-jplib/blob/master/lib/menuitems.js | |
var notificationboxTracker = new WindowTracker({ | |
onTrack: function(window) { | |
if (!isBrowser(window)) return; | |
console.log("tracking",window.location); | |
var message = 'Another pop-up blocked'; | |
var nb = window.gBrowser.getNotificationBox(); | |
var buttons = [{ | |
label: 'Button', | |
accessKey: 'B', | |
popup: 'blockedPopupOptions', | |
callback: null | |
}]; | |
/*const priority = nb.PRIORITY_WARNING_MEDIUM; | |
nb.appendNotification(message, 'popup-blocked', | |
'chrome://browser/skin/Info.png', | |
priority, buttons); | |
*/ | |
var appendNoticeFromMsg = function (subject,data){ | |
console.log("OBSERVED",subject,data,"TOPIC:", this.topic); | |
nb.appendNotification(subject,'got-notice', | |
'chrome://browser/skin/Info.png', | |
nb.PRIORY_INFO_LOW, {}); | |
}; | |
observer.add("appendNotification",appendNoticeFromMsg); | |
} | |
}); | |
var appendNotification = function(msg) { | |
observer.notify("appendNotification",msg); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment