namespace.jsmを使ってみた
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6681 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
0ae27f9716
commit
0baac4cc62
@ -1,5 +1,6 @@
|
|||||||
var EXPORTED_SYMBOLS = ['window'];
|
var EXPORTED_SYMBOLS = ['window'];
|
||||||
var window = {};
|
Components.utils.import('resource://treestyletab-modules/namespace.jsm');
|
||||||
|
var window = getNamespaceFor('piro.sakura.ne.jp');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
"getBoxObjectFor()" compatibility library for Firefox 3.6 or later
|
"getBoxObjectFor()" compatibility library for Firefox 3.6 or later
|
||||||
|
46
modules/namespace.jsm
Normal file
46
modules/namespace.jsm
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Shared Namespace Library for JavaScript Code Modules
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
Components.utils.import('resource://my-modules/namespace.jsm');
|
||||||
|
var namespace = getNamespaceFor('mylibrary');
|
||||||
|
namespace.func1 = function() { ... };
|
||||||
|
namespace.func2 = function() { ... };
|
||||||
|
var EXPORTED_SYMBOLS = ['func1', 'func2'];
|
||||||
|
var func1 = namespace.func1;
|
||||||
|
var func2 = namespace.func2;
|
||||||
|
|
||||||
|
lisence: The MIT License, Copyright (c) 2010 SHIMODA "Piro" Hiroshi
|
||||||
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
|
||||||
|
original:
|
||||||
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/namespace.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
var EXPORTED_SYMBOLS = ['getNamespaceFor'];
|
||||||
|
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
|
||||||
|
const currentRevision = 1;
|
||||||
|
|
||||||
|
var hiddenWindow = Cc['@mozilla.org/appshell/appShellService;1']
|
||||||
|
.getService(Ci.nsIAppShellService)
|
||||||
|
.hiddenDOMWindow;
|
||||||
|
|
||||||
|
if (!('piro.sakura.ne.jp' in hiddenWindow))
|
||||||
|
hiddenWindow['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
|
var namespaces = hiddenWindow['piro.sakura.ne.jp'].sharedNameSpaces || {};
|
||||||
|
if (!('sharedNameSpaces' in hiddenWindow['piro.sakura.ne.jp']))
|
||||||
|
hiddenWindow['piro.sakura.ne.jp'].sharedNameSpaces = namespaces;
|
||||||
|
|
||||||
|
function getNamespaceFor(aName)
|
||||||
|
{
|
||||||
|
if (!aName)
|
||||||
|
throw new Error('you must specify the name of the namespace!');
|
||||||
|
|
||||||
|
if (!(aName in namespaces))
|
||||||
|
namespaces[aName] = {};
|
||||||
|
|
||||||
|
return namespaces[aName];
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
var EXPORTED_SYMBOLS = ['window'];
|
var EXPORTED_SYMBOLS = ['window'];
|
||||||
var window = {};
|
Components.utils.import('resource://treestyletab-modules/namespace.jsm');
|
||||||
|
var window = getNamespaceFor('piro.sakura.ne.jp');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Preferences Library
|
Preferences Library
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
var EXPORTED_SYMBOLS = ['window'];
|
var EXPORTED_SYMBOLS = ['window'];
|
||||||
var window = {};
|
Components.utils.import('resource://treestyletab-modules/namespace.jsm');
|
||||||
|
var window = getNamespaceFor('piro.sakura.ne.jp');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string bundle utility
|
string bundle utility
|
||||||
|
@ -38,17 +38,16 @@ var EXPORTED_SYMBOLS = ['TreeStyleTabUtils'];
|
|||||||
var Cc = Components.classes;
|
var Cc = Components.classes;
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
|
|
||||||
var prefs = {};
|
Components.utils.import('resource://treestyletab-modules/prefs.js');
|
||||||
Components.utils.import('resource://treestyletab-modules/prefs.js', prefs);
|
Components.utils.import('resource://treestyletab-modules/boxObject.js');
|
||||||
prefs = prefs.window['piro.sakura.ne.jp'].prefs;
|
Components.utils.import('resource://treestyletab-modules/stringBundle.js');
|
||||||
|
|
||||||
var boxObject = {};
|
Components.utils.import('resource://treestyletab-modules/namespace.jsm');
|
||||||
Components.utils.import('resource://treestyletab-modules/boxObject.js', boxObject);
|
var window = getNamespaceFor('piro.sakura.ne.jp');
|
||||||
boxObject = boxObject.window['piro.sakura.ne.jp'].boxObject;
|
|
||||||
|
|
||||||
var stringBundle = {};
|
var prefs = window['piro.sakura.ne.jp'].prefs;
|
||||||
Components.utils.import('resource://treestyletab-modules/stringBundle.js', stringBundle);
|
var boxObject = window['piro.sakura.ne.jp'].boxObject;
|
||||||
stringBundle = stringBundle.window['piro.sakura.ne.jp'].stringBundle;
|
var stringBundle = window['piro.sakura.ne.jp'].stringBundle;
|
||||||
|
|
||||||
var TreeStyleTabUtils = {
|
var TreeStyleTabUtils = {
|
||||||
tabsHash : null,
|
tabsHash : null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user