Firefox Addon SDK:向用户显示选项的方法? [英] Firefox Addon SDK: Ways to display options to user?

查看:124
本文介绍了Firefox Addon SDK:向用户显示选项的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Firefox的插件开发相当新颖。我选择了用于将我的Chrome扩展程序移植到Firefox的addon sdk。



对于向用户显示选项页面/选项面板/选项窗口,您会有什么建议?



从我的addon目录加载options.html文件工作得很好(addTab(data.url(options.html));),但是我不能只要爱知道,就附加页面模块。因此,我不能与main.js通信来保存我的选项,对吗?

用户还应该如何访问它?
在Chrome中这很容易。右击你的图标 - >选项,它打开了你。
有没有办法为firefox创建一个simliar行为?



对此有何建议?

解决方案

从附加SDK 1.4开始,你有 simple-prefs 模块。它会自动为您的插件生成内联选项 - 这些选项直接显示在附加组件管理器的扩展页面上。这应该是显示选项的首选方式。缺点:以编程方式打开选项并不重要,即使是传统的附加组件也是如此。而且SDK似乎不支持复杂的控件(内嵌选项可能的文档),只有最基本的。

如果您想要自己推出,您可能需要将选项按钮集成到下拉式面板。您还应该能够通过 <$ c

$ p $ var $ page-mod package
, pageMod = require(page-mod);
pageMod.PageMod({
include:data.url(options.html),
...
});

var tabs = require(tabs);
tabs.open(data.url(options.html));

缺点:使用标准化的方式显示附加选项(通过附加组件管理器)这是不可能的,SDK不支持任何内联选项。


I'm quite new to addon development with firefox. I picked the addon sdk for porting my chrome extension to firefox.

What would you suggest to display a options page / options panel / options window to a user?

Loading a options.html file from my addon directory works quite fine (addTab(data.url("options.html"));), but i can't attach page-mods to it, as far as a i know. Therefore i can't communicate with the main.js to save my options, right?

Also how should the user access it? In chrome this is quite easy. Rightclick your icon -> options and it opens up for you. Are there ways to create a simliar behaviour for firefox?

Any suggestions on that?

解决方案

Starting with the Add-on SDK 1.4 you have the simple-prefs module. It will automatically generate inline options for your add-on - these are displayed directly on your extension's page in the Add-ons Manager. That should be the preferred way to display options. The downside: opening the options programmatically is non-trivial, even for classic add-ons. And the SDK doesn't seem to support complicated controls (documentation of what's possible with inline options), only the most basic ones.

If you want to roll your own, you probably want to integrate an "Options" button into a drop-down panel. You should also be able to attach a content script to it via page-mod package, something like this should work:

var pageMod = require("page-mod");
pageMod.PageMod({
  include: data.url("options.html"),
  ...
});

var tabs = require("tabs");
tabs.open(data.url("options.html"));

Downside here: using the standardized way to display add-on options (via Add-ons Manager) won't be possible, the SDK doesn't support anything but inline options.

这篇关于Firefox Addon SDK:向用户显示选项的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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