From 62b8d17dec721bbfae41f01966729d39bcbe64d9 Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 12 May 2009 16:56:39 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=9E=E3=83=AB=E3=83=81=E3=83=97=E3=83=AB?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=83=8F=E3=83=B3=E3=83=89=E3=83=A9=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AF=E3=81=9D=E3=81=A1?= =?UTF-8?q?=E3=82=89=E3=81=AB=E5=87=A6=E7=90=86=E3=82=92=E4=BB=BB=E3=81=9B?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4413 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.xul | 43 +++++++++--- content/treestyletab/treestyletabbrowser.js | 77 ++++++++++++--------- 2 files changed, 76 insertions(+), 44 deletions(-) diff --git a/content/treestyletab/treestyletab.xul b/content/treestyletab/treestyletab.xul index 21da8d4d..008ea53b 100644 --- a/content/treestyletab/treestyletab.xul +++ b/content/treestyletab/treestyletab.xul @@ -50,18 +50,44 @@ src="chrome://treestyletab/locale/treestyletab.properties"/> - - + + + + onclick="if (event.button == 1 || (event.button == 0 && TreeStyleTabService.isAccelKeyPressed(event))) { + TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true); + event.stopPropagation(); + this.parentNode.hidePopup(); + }" + multipletab-insertbefore="TreeStyleTabService.evaluateXPath( + "(descendant::*[starts-with(@id, 'multipletab-context-removeAll') | starts-with(@id, 'context_closeTab')][1] | child::xul:menuitem[last()])/preceding-sibling::xul:menuseparator[1]" + , tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/> + onclick="if (event.button == 1 || (event.button == 0 && TreeStyleTabService.isAccelKeyPressed(event))) { + TreeStyleTabService.removeTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab); + event.stopPropagation(); + this.parentNode.hidePopup(); + }" + multipletab-insertafter="TreeStyleTabService.evaluateXPath( + "descendant::*[starts-with(@id, 'context-item-removeTabSubTree')][1]" + , tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/> + + + + + - - - - + + diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 5d5b30dd..6ae7f51d 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -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) {