マルチプルタブハンドラがある場合はそちらに処理を任せるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4413 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-05-12 16:56:39 +00:00
parent d6fd326493
commit 62b8d17dec
2 changed files with 76 additions and 44 deletions

View File

@ -50,18 +50,44 @@
src="chrome://treestyletab/locale/treestyletab.properties"/> src="chrome://treestyletab/locale/treestyletab.properties"/>
</stringbundleset> </stringbundleset>
<window id="main-window"> <popupset id="mainPopupSet">
<data id="treestyletab-tabcontext-menu-template" collapsed="true"> <menupopup id="multipletab-tabcontext-menu-template">
<menuitem id="context-item-removeTabSubTree" <menuitem id="context-item-removeTabSubTree"
label="&context.removeTabSubTree.label;" label="&context.removeTabSubTree.label;"
accesskey="&context.removeTabSubTree.accesskey;" accesskey="&context.removeTabSubTree.accesskey;"
oncommand="TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);" oncommand="TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; (navigator.platform.indexOf('Mac') &lt; 0 ? event.ctrlKey : event.metaKey ))) { TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true); event.stopPropagation(); this.parentNode.hidePopup(); }"/> onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; TreeStyleTabService.isAccelKeyPressed(event))) {
TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true);
event.stopPropagation();
this.parentNode.hidePopup();
}"
multipletab-insertbefore="TreeStyleTabService.evaluateXPath(
&quot;(descendant::*[starts-with(@id, 'multipletab-context-removeAll') | starts-with(@id, 'context_closeTab')][1] | child::xul:menuitem[last()])/preceding-sibling::xul:menuseparator[1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-removeDescendantTabs" <menuitem id="context-item-removeDescendantTabs"
label="&context.removeDescendantTabs.label;" label="&context.removeDescendantTabs.label;"
accesskey="&context.removeDescendantTabs.accesskey;" accesskey="&context.removeDescendantTabs.accesskey;"
oncommand="TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true);" oncommand="TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true);"
onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; (navigator.platform.indexOf('Mac') &lt; 0 ? event.ctrlKey : event.metaKey ))) { TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab); event.stopPropagation(); this.parentNode.hidePopup(); }"/> onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; TreeStyleTabService.isAccelKeyPressed(event))) {
TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);
event.stopPropagation();
this.parentNode.hidePopup();
}"
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context-item-removeTabSubTree')][1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-bookmarkTabSubTree"
label="&context.bookmarkTabSubTree.label;"
accesskey="&context.bookmarkTabSubTree.accesskey;"
oncommand="TreeStyleTabService.bookmarkTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context_bookmarkTab')][1] | descendant::*[@command='Browser:BookmarkAllTabs']/preceding-sibling[1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<!-- simply appended items -->
<menuseparator id="context-separator-collapseExpandAll"/> <menuseparator id="context-separator-collapseExpandAll"/>
<menuitem id="context-item-collapseAllSubtree" <menuitem id="context-item-collapseAllSubtree"
@ -102,12 +128,7 @@
</menupopup> </menupopup>
</menu> </menu>
</menupopup>
<menuitem id="context-item-bookmarkTabSubTree" </popupset>
label="&context.bookmarkTabSubTree.label;"
accesskey="&context.bookmarkTabSubTree.accesskey;"
oncommand="TreeStyleTabService.bookmarkTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"/>
</data>
</window>
</overlay> </overlay>

View File

@ -508,37 +508,48 @@ TreeStyleTabBrowser.prototype = {
delete maxi; delete maxi;
delete tabs; delete tabs;
var tabContext = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu'); var tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu');
tabContext.addEventListener('popupshowing', this, false); tabContextMenu.addEventListener('popupshowing', this, false);
tabContext.addEventListener('popuphiding', this, false); tabContextMenu.addEventListener('popuphiding', this, false);
window.setTimeout(function(aSelf) { if (!('MultipleTabService' in window)) {
var suffix = '-tabbrowser-'+(b.id || 'instance-'+parseInt(Math.random() * 65000)); window.setTimeout(function(aSelf) {
[ var suffix = '-tabbrowser-'+(b.id || 'instance-'+parseInt(Math.random() * 65000));
aSelf.kMENUITEM_REMOVESUBTREE, [
aSelf.kMENUITEM_REMOVECHILDREN, aSelf.kMENUITEM_REMOVESUBTREE,
aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR, aSelf.kMENUITEM_REMOVECHILDREN,
aSelf.kMENUITEM_COLLAPSE, aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR,
aSelf.kMENUITEM_EXPAND, aSelf.kMENUITEM_COLLAPSE,
aSelf.kMENUITEM_AUTOHIDE_SEPARATOR, aSelf.kMENUITEM_EXPAND,
aSelf.kMENUITEM_AUTOHIDE, aSelf.kMENUITEM_AUTOHIDE_SEPARATOR,
aSelf.kMENUITEM_FIXED, aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_POSITION aSelf.kMENUITEM_FIXED,
].forEach(function(aID) { aSelf.kMENUITEM_POSITION,
var item = document.getElementById(aID).cloneNode(true); aSelf.kMENUITEM_BOOKMARKSUBTREE
item.setAttribute('id', item.getAttribute('id')+suffix); ].forEach(function(aID) {
tabContext.appendChild(item); let item = document.getElementById(aID).cloneNode(true);
}); item.setAttribute('id', item.getAttribute('id')+suffix);
var item = document.getElementById(aSelf.kMENUITEM_BOOKMARKSUBTREE).cloneNode(true); let refNode = void(0);
item.setAttribute('id', item.getAttribute('id')+suffix); let insertAfter = item.getAttribute('multipletab-insertafter');
var refNodes = tabContext.getElementsByAttribute('command', 'Browser:BookmarkAllTabs'); if (insertAfter) {
tabContext.insertBefore( try {
item, eval('refNode = ('+insertAfter+').nextSibling');
(refNodes && refNodes.length) ? }
(aSelf.getNextTab(refNodes[0]) || refNodes[0]) : catch(e) {
null }
); }
}, 0, this); let insertBefore = item.getAttribute('multipletab-insertbefore');
if (refNode === void(0) && insertBefore) {
try {
eval('refNode = '+insertBefore);
}
catch(e) {
}
}
tabContextMenu.insertBefore(item, refNode || null);
});
}, 0, this);
}
var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup'); var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup');
if (allTabPopup) { if (allTabPopup) {
@ -938,9 +949,9 @@ TreeStyleTabBrowser.prototype = {
this.scrollBox.removeEventListener('overflow', this, true); this.scrollBox.removeEventListener('overflow', this, true);
this.scrollBox.removeEventListener('underflow', this, true); this.scrollBox.removeEventListener('underflow', this, true);
var tabContext = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu'); var tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu');
tabContext.removeEventListener('popupshowing', this, false); tabContextMenu.removeEventListener('popupshowing', this, false);
tabContext.removeEventListener('popuphiding', this, false); tabContextMenu.removeEventListener('popuphiding', this, false);
var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup'); var allTabPopup = document.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'alltabs-popup');
if (allTabPopup) { if (allTabPopup) {