stringbundleをPure JSに
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4928 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
f28a400047
commit
2c3b4f3621
@ -222,7 +222,7 @@ var TreeStyleTabBookmarksService = {
|
||||
).replace(
|
||||
/(this\._openTabset\([^\)]+)(\))/,
|
||||
<![CDATA[$1,
|
||||
TreeStyleTabBookmarksService.stringbundle
|
||||
TreeStyleTabBookmarksService.treeBundle
|
||||
.getFormattedString(
|
||||
PlacesUtils.nodeIsBookmark(aNodes[0]) ?
|
||||
'openSelectedPlaces.bookmarks' :
|
||||
|
@ -2,17 +2,8 @@
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="res/prefs.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/boxObject.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/stringBundle.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/animationManager.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="treestyletab.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="bookmarksOverlay.js" type="application/x-javascript; version=1.7"/>
|
||||
|
||||
<page id="history-panel">
|
||||
<stringbundleset id="placesStringSet"/>
|
||||
</page>
|
||||
|
||||
<stringbundleset id="placesStringSet">
|
||||
<stringbundle id="treestyletab-stringbundle"
|
||||
src="chrome://treestyletab/locale/treestyletab.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
</overlay>
|
||||
|
@ -33,10 +33,12 @@ var TreeStyleEditableBookmarkService = {
|
||||
if (!container) return;
|
||||
|
||||
container = container.getElementsByTagName('rows')[0];
|
||||
|
||||
/* to be inserted to the container...
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(container);
|
||||
range.collapse(false);
|
||||
range.insertNode(range.createContextualFragment(<![CDATA[
|
||||
<row align="center">
|
||||
<label value=" (bookmarkProperty.parent.label) "
|
||||
<label id="treestyletab-parent-label"
|
||||
control="treestyletab-parent-menulist"/>
|
||||
<menulist id="treestyletab-parent-menulist"
|
||||
flex="1"
|
||||
@ -44,12 +46,15 @@ var TreeStyleEditableBookmarkService = {
|
||||
<menupopup id="treestyletab-parent-popup">
|
||||
<menuseparator id="treestyletab-parent-blank-item-separator"/>
|
||||
<menuitem id="treestyletab-parent-blank-item"
|
||||
label=" (bookmarkProperty.parent.blank.label) "
|
||||
value=""/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</row>
|
||||
*/
|
||||
]]>.toString().replace(/^\s*|\s*$/g, '').replace(/>\s+</g, '><')));
|
||||
range.detach();
|
||||
document.getElementById('treestyletab-parent-label').setAttribute('value', TreeStyleTabService.treeBundle.getString('bookmarkProperty.parent.label'));
|
||||
this.blankItem.setAttribute('label', TreeStyleTabService.treeBundle.getString('bookmarkProperty.parent.blank.label'));
|
||||
|
||||
|
||||
eval('gEditItemOverlay._showHideRows = '+gEditItemOverlay._showHideRows.toSource().replace(
|
||||
'this._element("keywordRow").collapsed',
|
||||
|
@ -3,12 +3,9 @@
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="res/prefs.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/boxObject.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/stringBundle.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/animationManager.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="treestyletab.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="bookmarksOverlay.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="editBookmarkOverlay.js" type="application/x-javascript; version=1.7"/>
|
||||
<stringbundleset id="placesStringSet">
|
||||
<stringbundle id="treestyletab-stringbundle"
|
||||
src="chrome://treestyletab/locale/treestyletab.properties"/>
|
||||
</stringbundleset>
|
||||
</overlay>
|
||||
|
73
content/treestyletab/res/stringBundle.js
Normal file
73
content/treestyletab/res/stringBundle.js
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
string bundle utility
|
||||
|
||||
Usage:
|
||||
// use instead of HTMLDocument.getBoxObjectFor(HTMLElement)
|
||||
var bundle = window['piro.sakura.ne.jp']
|
||||
.stringBundle
|
||||
.get('chrome://example/locale/example.properties');
|
||||
bundle.getString('key1');
|
||||
bundle.getFormattedString('key2', [val1, val2]);
|
||||
|
||||
lisence: The MIT License, Copyright (c) 2009 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/stringBundle.js
|
||||
*/
|
||||
(function() {
|
||||
const currentRevision = 1;
|
||||
|
||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||
|
||||
var loadedRevision = 'stringBundle' in window['piro.sakura.ne.jp'] ?
|
||||
window['piro.sakura.ne.jp'].stringBundle.revision :
|
||||
0 ;
|
||||
if (loadedRevision && loadedRevision > currentRevision) {
|
||||
return;
|
||||
}
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
window['piro.sakura.ne.jp'].stringBundle = {
|
||||
revision : currentRevision,
|
||||
|
||||
get : function(aURI)
|
||||
{
|
||||
if (!(aURI in this._cache)) {
|
||||
this._cache[aURI] = new StringBundle(aURI);
|
||||
}
|
||||
return this._cache[aURI];
|
||||
},
|
||||
_cache : {}
|
||||
};
|
||||
|
||||
const Service = Cc['@mozilla.org/intl/stringbundle;1']
|
||||
.getService(Ci.nsIStringBundleService);
|
||||
|
||||
function StringBundle(aURI)
|
||||
{
|
||||
this._bundle = Service.createBundle(aURI);
|
||||
}
|
||||
StringBundle.prototype = {
|
||||
getString : function(aKey) {
|
||||
try {
|
||||
return this._bundle.GetStringFromName(aKey);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getFormattedString : function(aKey, aArray) {
|
||||
try {
|
||||
return this._bundle.formatStringFromName(aKey, aArray, aArray.length);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
return '';
|
||||
},
|
||||
get strings() {
|
||||
return this._bundle.getSimpleEnumeration();
|
||||
}
|
||||
};
|
||||
})();
|
@ -48,7 +48,6 @@ var TreeStyleTabService = {
|
||||
kCOUNTER_CONTAINER : 'treestyletab-counter-container',
|
||||
kSPLITTER : 'treestyletab-splitter',
|
||||
kTABBAR_TOGGLER : 'treestyletab-tabbar-toggler',
|
||||
kSTRINGBUNDLE : 'treestyletab-stringbundle',
|
||||
|
||||
kMENUITEM_REMOVESUBTREE_SELECTION : 'multipletab-selection-item-removeTabSubTree',
|
||||
|
||||
@ -220,21 +219,16 @@ var TreeStyleTabService = {
|
||||
},
|
||||
_Comparator : null,
|
||||
|
||||
get stringbundle() {
|
||||
if (!this._stringbundle) {
|
||||
this._stringbundle = document.getElementById(this.kSTRINGBUNDLE);
|
||||
}
|
||||
return this._stringbundle;
|
||||
get treeBundle() {
|
||||
return window['piro.sakura.ne.jp']
|
||||
.stringBundle
|
||||
.get('chrome://treestyletab/locale/treestyletab.properties');
|
||||
},
|
||||
_stringbundle : null,
|
||||
|
||||
get tabbrowserBundle() {
|
||||
if (!this._tabbrowserBundle) {
|
||||
this._tabbrowserBundle = document.getElementById('treestyletab-tabbrowserBundle');
|
||||
}
|
||||
return this._tabbrowserBundle;
|
||||
return window['piro.sakura.ne.jp']
|
||||
.stringBundle
|
||||
.get('chrome://browser/locale/tabbrowser.properties');
|
||||
},
|
||||
_tabbrowserBundle : null,
|
||||
|
||||
/* API */
|
||||
|
||||
@ -1151,14 +1145,14 @@ var TreeStyleTabService = {
|
||||
|
||||
var checked = { value : false };
|
||||
var newChildTab = this.PromptService.confirmEx(window,
|
||||
this.stringbundle.getString('dropLinkOnTab.title'),
|
||||
this.stringbundle.getString('dropLinkOnTab.text'),
|
||||
this.treeBundle.getString('dropLinkOnTab.title'),
|
||||
this.treeBundle.getString('dropLinkOnTab.text'),
|
||||
(this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_0) +
|
||||
(this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_1),
|
||||
this.stringbundle.getString('dropLinkOnTab.openNewChildTab'),
|
||||
this.stringbundle.getString('dropLinkOnTab.loadInTheTab'),
|
||||
this.treeBundle.getString('dropLinkOnTab.openNewChildTab'),
|
||||
this.treeBundle.getString('dropLinkOnTab.loadInTheTab'),
|
||||
null,
|
||||
this.stringbundle.getString('dropLinkOnTab.never'),
|
||||
this.treeBundle.getString('dropLinkOnTab.never'),
|
||||
checked
|
||||
) == 0;
|
||||
|
||||
@ -1182,15 +1176,15 @@ var TreeStyleTabService = {
|
||||
|
||||
var checked = { value : false };
|
||||
var button = this.PromptService.confirmEx(window,
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.title'),
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.text'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.title'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.text'),
|
||||
(this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_0) +
|
||||
(this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_1) +
|
||||
(this.PromptService.BUTTON_TITLE_IS_STRING * this.PromptService.BUTTON_POS_2),
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.subTree'),
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.separate'),
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.replace'),
|
||||
this.stringbundle.getString('openGroupBookmarkBehavior.never'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.subTree'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.separate'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.replace'),
|
||||
this.treeBundle.getString('openGroupBookmarkBehavior.never'),
|
||||
checked
|
||||
);
|
||||
|
||||
@ -2220,7 +2214,7 @@ catch(e) {
|
||||
if ('mOverCloseButton' in aTab && aTab.mOverCloseButton) {
|
||||
if (descendant.length &&
|
||||
(collapsed || this.getTreePref('closeParentBehavior') == this.CLOSE_PARENT_BEHAVIOR_CLOSE)) {
|
||||
label = this.stringbundle.getString('tooltip.closeTree');
|
||||
label = this.treeBundle.getString('tooltip.closeTree');
|
||||
}
|
||||
}
|
||||
else if (aTab.getAttribute(this.kTWISTY_HOVER) == 'true') {
|
||||
@ -2229,8 +2223,8 @@ catch(e) {
|
||||
'tooltip.collapseSubtree' ;
|
||||
label = tree || aTab.getAttribute('label');
|
||||
label = label ?
|
||||
this.stringbundle.getFormattedString(key+'.labeled', [label]) :
|
||||
this.stringbundle.getString(key) ;
|
||||
this.treeBundle.getFormattedString(key+'.labeled', [label]) :
|
||||
this.treeBundle.getString(key) ;
|
||||
}
|
||||
else if (collapsed) {
|
||||
label = tree;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
<script src="res/prefs.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/boxObject.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/stringBundle.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/autoScroll.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/animationManager.js" type="application/x-javascript; version=1.7"/>
|
||||
<script src="res/extensions.js" type="application/x-javascript; version=1.7"/>
|
||||
@ -53,13 +54,6 @@
|
||||
multipletab-enabled="TreeStyleTabService.canCreateSubTree(MultipleTabService.getSelectedTabs())"/>
|
||||
</menupopup>
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="treestyletab-stringbundle"
|
||||
src="chrome://treestyletab/locale/treestyletab.properties"/>
|
||||
<stringbundle id="treestyletab-tabbrowserBundle"
|
||||
src="chrome://browser/locale/tabbrowser.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<popupset id="mainPopupSet">
|
||||
<menupopup id="multipletab-tabcontext-menu-template">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user