Comments (8)
I have this scheduled for tomorrow.
from developer-docs.
Great, thanks for taking care of this.
Notifications can be added almost anywhere as far as there's a container with an ID
to use as a target.
Eg.
const myNotification = {};
XPCOMUtils.defineLazyGetter(myNotification, "notificationbox", () => {
return new MozElements.NotificationBox(element => {
element.setAttribute("flex", "1");
document.getElementById("targetID").append(element);
});
});
At that point, the developer can use myNotification.notificationbox
to append his own notifications.
from developer-docs.
@Alecaddd : Could you have a look at
https://developer.thunderbird.net/add-ons/tb68/changes#less-than-notificationbox-greater-than
What happens, if the addon author wants to add a notification to a window, that does not have a notification box?
from developer-docs.
Wow! Would it then be the better "update strategy" to just rename the <notificationbox>
to <hbox>
in my code and do the above in JS? This way I do not have to search for the correct box?
Or should authors use the default notification box of messenger and composer? And the above is just for custom dialogs?
from developer-docs.
I knew that something like this should be possible - that JavaScript is something an average Add-on author would not be able to come up with so we definitely should add this to the documentation. I will try this out on my Add-on quickFilters where I currently show a notification panel in the filters dialog. The old overlay contained:
<panel id="quickFilterNotification" noautohide="true">
<notificationbox flex="1" id="quickFilterNotificationBox" >
<!-- <notification type="warning" label="Test" id="quickFiltersNotificationContent"/> -->
</notificationbox>
</panel>
and this was the main js code for displaying the notification:
util.popupAlert(
util.getBundleString('quickfilters.debug.fixFilters.result','{0} filters were fixed.').replace('{0}',countFixed),
"quickFilters", "debug-success.png", 0
);
popupAlert: function popupAlert(text, title, icon, timeOut) {
try {
let isTimeout = !(timeOut == 0);
if (!timeOut) timeOut = 4000;
let panel = document.getElementById('quickFilterNotification');
if (panel) {
panel.openPopup(null, "after_start", 0, 0, false, false);
let notificationBox = document.getElementById('quickFilterNotificationBox'),
priority = notificationBox.PRIORITY_WARNING_MEDIUM,
note = notificationBox.appendNotification( text , null , icon , priority, null, null );
notificationBox.addEventListener('alertclose', function() { alert('test'); });
if (isTimeout)
window.setTimeout(function() {try{notificationBox.removeNotification(note)}catch(e){};panel.hidePopup();}, timeOut);
}
else {
let prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
prompts.alert(window, title, text);
}
}
catch(e) {
alert(text);
}
}
from developer-docs.
@jobisoft, it really depends on the situation, but using built-in notification ensures visual consistency and style.
from developer-docs.
@RealRaven2000 Indeed, documenting this approach would be very useful for add-on developers.
It's a pretty easy implementation that depends on importing the XPCOMUtils
object
from developer-docs.
I am sorry, I forgot about this one. I added it to the documentation.
from developer-docs.
Related Issues (20)
- comm-beta build fails on fresh environment HOT 3
- Building esr versions of Thunderbird addendum
- Dead links in developer documentation about E-mail autoconfiguration HOT 2
- Explain why/if loading of customElements.js no longer necessary? HOT 1
- [Name Suggestion] Name Suggestion For Q4 2023's "K-9 -> Thunderbird For Android" Release.
- "Adapt to TB 115" page explains 3-pane window restructuring poorly HOT 1
- Better documentation of editing omni.ja
- "Adapt to TB 115" page needs to mention -moz-image-region going away HOT 1
- Missing code in "hello-world" extension tutorial HOT 3
- add link to kb article on how to open console logs
- allow change of default ImapMail folder location via GPO or Policies File HOT 1
- broken links: writing mochitest tests HOT 1
- mac build instructions do not work HOT 7
- calendar notifications not working HOT 1
- Commit message improvements
- CPG Link? HOT 1
- ics import error HOT 1
- OnProgress() -> onProgress() HOT 1
- Remove section about supported Manifest Keys and supported APIs
- Broken links HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from developer-docs.