Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying the timeout of notifications in a firefox extension

I am using the notification function of the firefox SDK to create a firefox extensions. the problem is that after showing the notification it fades away too quickly , is there a way to modify the timeout of the notification ? this is the code i'm using :

notifications.notify({
                      title: "notification title",
                      text: " notification text ",
                      data: List[i] ,
                      onClick: function (data) {
                        tabs.open(data);

                      }
            });
like image 885
zaraki Avatar asked Dec 08 '13 17:12

zaraki


1 Answers

There is no way to control the animation. @canuckistani is half-right: Both the SDK notifications and the HTML5 notifications use the same underlying service, the nsIAlertsService. This service does not allow you to control the duration.

Desktop Firefox does not use system-level services, except for the Metro implementation (yet to be officially released and does not support add-ons anyway IIRC). Instead they use the XUL alert service implementation, which is just some XUL with some Javascript and some additional CSS.And some code to open the window.

Depending on some pref, either a hardcoded 4000ms timeout via setTimeout will be used, or a 4s CSS animation.

While not convenient, in particular not in an SDK add-on where you do not get a chrome package to open your own XUL windows from, you could copy/paste implement your own fork of the XUL window with controls for the duration, or even override the Firefox default one. I cannot recall the name right now, but I know there is or was at least one add-on doing exactly that, overriding the built-in implementation and letting the user choose a custom timeout, among other things.

like image 86
nmaier Avatar answered Oct 06 '22 06:10

nmaier