-
Notifications
You must be signed in to change notification settings - Fork 3
Config.define()
h1mesuke edited this page Sep 14, 2010
·
36 revisions
define: function(name, buildFunc, opts) {
Defines a config dialog with the given name.
ダイアログを定義する。
Config.define('dialog_name', function() { with (this.builder) {
dialog(
"Title",
{ width: 500, height: 400 },
section(...),
section(...),
null
);
}}, {
aftersave: function() {...},
});
Config.define()
において指定可能なオプションの一覧
Following 6 callbacks are available.
コールバックは以下の6種類です。
- beforeopen
- afteropen
- beforesave
- aftersave
- beforeclose
- afterclose
それぞれ、その名前通りのタイミングで呼び出されます。
If a callback function of before(open|close|save)
returns false
, (opening|closing) the dialog or saving the settings is canceled.
beforeopen
, beforeclose
, beforesave
コールバックに関しては、コールバック関数が false
を返すことでダイアログの表示/クローズ、あるいは設定の保存がキャンセルされます。
設定例▼
Config.define('dialog_name', function() { with (this.builder) {
dialog(
"Title",
{ width: 500, height: 400 },
section(...),
section(...),
null
);
}}, {
aftersave: function() {
var msg = "Seved settings are:\n\n";
for (var id in this.settings) {
msg = msg + id + " = " + this.settings[id] + "\n";
}
alert(msg);
},
});
GM_setValue()
.
GM_setValue()
で設定を保存するときに使う名前
GM_config から移行する場合は既存の設定を継承するためにこの値を 'GM_config'
に設定します。それ以外の場合は設定する必要はありません。
なお、移行に際しては実際に 'GM_config'
という名前で既存の設定が保存されているか、about:config で確認して下さい。