TreeStyleTabCommon => TreeStyleTabUtils

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5624 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-12-25 16:51:24 +00:00
parent 16f8cc66bf
commit 641d9ffc9f
2 changed files with 56 additions and 63 deletions

View File

@ -455,16 +455,16 @@ var TreeStyleTabService = {
get currentTabbarPosition() /* PUBLIC API */ get currentTabbarPosition() /* PUBLIC API */
{ {
return this.common.currentTabbarPosition; return this.utils.currentTabbarPosition;
}, },
set currentTabbarPosition(aValue) set currentTabbarPosition(aValue)
{ {
return this.common.currentTabbarPosition = aValue; return this.utils.currentTabbarPosition = aValue;
}, },
rollbackTabbarPosition : function TSTService_rollbackTabbarPosition() /* PUBLIC API */ rollbackTabbarPosition : function TSTService_rollbackTabbarPosition() /* PUBLIC API */
{ {
return this.common.rollbackTabbarPosition(); return this.utils.rollbackTabbarPosition();
}, },
/* backward compatibility */ /* backward compatibility */
@ -2914,39 +2914,16 @@ catch(e) {
} }
}, },
/* Save/Load Prefs */
getTreePref : function TSTService_getTreePref(aPrefstring)
{
return this.getPref('extensions.treestyletab.'+aPrefstring);
},
setTreePref : function TSTService_setTreePref(aPrefstring, aNewValue)
{
return this.setPref('extensions.treestyletab.'+aPrefstring, aNewValue);
},
clearTreePref : function TSTService_clearTreePref(aPrefstring)
{
return this.clearPref('extensions.treestyletab.'+aPrefstring);
}
}; };
(function() { (function() {
var namespace = {}; var namespace = {};
Components.utils.import( Components.utils.import(
'resource://treestyletab-modules/prefs.js', 'resource://treestyletab-modules/utils.js',
namespace namespace
); );
TreeStyleTabService.__proto__ = namespace.window['piro.sakura.ne.jp'].prefs; TreeStyleTabService.__proto__ = TreeStyleTabService.utils = namespace.TreeStyleTabUtils;
TreeStyleTabService.utils.init();
Components.utils.import(
'resource://treestyletab-modules/common.jsm',
namespace
);
TreeStyleTabService.common = namespace.TreeStyleTabCommon;
TreeStyleTabService.common.init();
})(); })();
window.addEventListener('DOMContentLoaded', TreeStyleTabService, true); window.addEventListener('DOMContentLoaded', TreeStyleTabService, true);
window.addEventListener('load', TreeStyleTabService, false); window.addEventListener('load', TreeStyleTabService, false);

View File

@ -33,11 +33,11 @@
* *
* ***** END LICENSE BLOCK ******/ * ***** END LICENSE BLOCK ******/
var EXPORTED_SYMBOLS = ['TreeStyleTabCommon']; var EXPORTED_SYMBOLS = ['TreeStyleTabUtils'];
var TreeStyleTabCommon = { var TreeStyleTabUtils = {
init : function TSTCommon_init() init : function TSTUtils_init()
{ {
if (this._initialized) return; if (this._initialized) return;
@ -46,8 +46,13 @@ var TreeStyleTabCommon = {
}, },
_initialized : false, _initialized : false,
// pref listener
observe : function TSTCommon_observe(aSubject, aTopic, aData) domains : [
'extensions.treestyletab.tabbar.position'
],
observe : function TSTUtils_observe(aSubject, aTopic, aData)
{ {
switch (aTopic) switch (aTopic)
{ {
@ -57,11 +62,7 @@ var TreeStyleTabCommon = {
} }
}, },
domains : [ onPrefChange : function TSTUtils_onPrefChange(aPrefName)
'extensions.treestyletab.tabbar.position'
],
onPrefChange : function TSTCommon_onPrefChange(aPrefName)
{ {
var value = this.getPref(aPrefName); var value = this.getPref(aPrefName);
switch (aPrefName) switch (aPrefName)
@ -75,11 +76,9 @@ var TreeStyleTabCommon = {
} }
}, },
// tabbar position
// tabbar position API get currentTabbarPosition() /* PUBLIC API */
/* PUBLIC API */
get currentTabbarPosition()
{ {
return this.getPref('extensions.treestyletab.tabbar.position') || 'top'; return this.getPref('extensions.treestyletab.tabbar.position') || 'top';
}, },
@ -95,8 +94,7 @@ var TreeStyleTabCommon = {
return aValue; return aValue;
}, },
/* PUBLIC API */ rollbackTabbarPosition : function TSTUtils_rollbackTabbarPosition() /* PUBLIC API */
rollbackTabbarPosition : function TSTCommon_rollbackTabbarPosition()
{ {
if (!this._tabbarPositionHistory.length) if (!this._tabbarPositionHistory.length)
return false; return false;
@ -108,15 +106,33 @@ var TreeStyleTabCommon = {
return true; return true;
}, },
onChangeTabbarPosition : function TSTCommon_onChangeTabbarPosition(aPosition) onChangeTabbarPosition : function TSTUtils_onChangeTabbarPosition(aPosition)
{ {
if (this._inRollbackTabbarPosition) return; if (this._inRollbackTabbarPosition) return;
this._tabbarPositionHistory.push(aPosition); this._tabbarPositionHistory.push(aPosition);
}, },
_tabbarPositionHistory : [] _tabbarPositionHistory : [],
/* Save/Load Prefs */
getTreePref : function TSTUtils_getTreePref(aPrefstring)
{
return this.getPref('extensions.treestyletab.'+aPrefstring);
},
setTreePref : function TSTUtils_setTreePref(aPrefstring, aNewValue)
{
return this.setPref('extensions.treestyletab.'+aPrefstring, aNewValue);
},
clearTreePref : function TSTUtils_clearTreePref(aPrefstring)
{
return this.clearPref('extensions.treestyletab.'+aPrefstring);
}
}; };
Components.utils.import('resource://treestyletab-modules/prefs.js'); Components.utils.import('resource://treestyletab-modules/prefs.js');
TreeStyleTabCommon.__proto__ = window['piro.sakura.ne.jp'].prefs; TreeStyleTabUtils.__proto__ = window['piro.sakura.ne.jp'].prefs;