修改firefox扩展中的通知超时 [英] Modifying the timeout of notifications in a firefox extension

查看:112
本文介绍了修改firefox扩展中的通知超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用firefox SDK的通知功能来创建一个Firefox扩展。问题是,显示通知后,它消失得太快,有没有办法修改通知的超时?这是我使用的代码:

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

}
});


解决方案

没有办法控制动画。 @canuckistani是一半权利:SDK 通知和HTML5通知使用相同的基础服务, nsIAlertsService 。此服务不允许您控制持续时间。

桌面Firefox不使用系统级服务,除了Metro实施(尚未正式发布且不无论如何支持附加组件IIRC)。相反,他们使用XUL警报服务实施,这只是一些XUL与一些Javascript和一些额外的CSS

根据一些pref,通过 setTimeout <硬件编码的4000ms超时> code>将被使用,或者是一个4s的CSS动画。

尽管不方便,特别是在没有获得chrome的SDK插件中包打开你自己的XUL窗口,你可以复制/粘贴XUL窗口的控制持续时间自己的叉子,甚至可以覆盖Firefox的默认窗口。
现在我不记得名字了,但是我知道至少有一个插件正在做这件事,覆盖了内置的实现,并让用户选择一个自定义超时等等。 p>

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);

                      }
            });

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.

这篇关于修改firefox扩展中的通知超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆