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

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"/>
</stringbundleset>
<window id="main-window">
<data id="treestyletab-tabcontext-menu-template" collapsed="true">
<popupset id="mainPopupSet">
<menupopup id="multipletab-tabcontext-menu-template">
<menuitem id="context-item-removeTabSubTree"
label="&context.removeTabSubTree.label;"
accesskey="&context.removeTabSubTree.accesskey;"
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"
label="&context.removeDescendantTabs.label;"
accesskey="&context.removeDescendantTabs.accesskey;"
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"/>
<menuitem id="context-item-collapseAllSubtree"
@ -102,12 +128,7 @@
</menupopup>
</menu>
<menuitem id="context-item-bookmarkTabSubTree"
label="&context.bookmarkTabSubTree.label;"
accesskey="&context.bookmarkTabSubTree.accesskey;"
oncommand="TreeStyleTabService.bookmarkTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"/>
</data>
</window>
</menupopup>
</popupset>
</overlay>

View File

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