middle click on tab link should close the tab
This commit is contained in:
parent
8ec27ba13c
commit
9259ecad17
@ -147,14 +147,47 @@ function getTabById(aId)
|
||||
|
||||
function onItemClick(aEvent)
|
||||
{
|
||||
var gBrowser = getOwnerTabBrowser();
|
||||
if (!gBrowser)
|
||||
return;
|
||||
|
||||
var tab = getTabById(aEvent.getData('id'));
|
||||
if (tab)
|
||||
if (!tab)
|
||||
return;
|
||||
|
||||
var button = aEvent.getData('button');
|
||||
var altKey = aEvent.getData('altKey');
|
||||
var ctrlKey = aEvent.getData('ctrlKey');
|
||||
var metaKey = aEvent.getData('metaKey');
|
||||
var shiftKey = aEvent.getData('shiftKey');
|
||||
var isMiddleClick = (
|
||||
(
|
||||
button == 1 &&
|
||||
!altKey &&
|
||||
!ctrlKey &&
|
||||
!metaKey &&
|
||||
!shiftKey
|
||||
) ||
|
||||
(
|
||||
button == 0 &&
|
||||
!altKey &&
|
||||
(ctrlKey || metaKey) &&
|
||||
!shiftKey
|
||||
)
|
||||
);
|
||||
|
||||
if (isMiddleClick)
|
||||
gBrowser.removeTab(tab);
|
||||
else if (button != 2)
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
|
||||
|
||||
function updateTree()
|
||||
{
|
||||
if (window.closed)
|
||||
return;
|
||||
|
||||
var tree = document.getElementById('tree');
|
||||
|
||||
var range = document.createRange();
|
||||
@ -162,13 +195,18 @@ function updateTree()
|
||||
range.deleteContents();
|
||||
range.detach();
|
||||
|
||||
tree.appendChild(PseudoTreeBuilder.build(getOwnerTab()));
|
||||
var contents = PseudoTreeBuilder.build(getOwnerTab());
|
||||
if (contents)
|
||||
tree.appendChild(contents);
|
||||
}
|
||||
|
||||
function checkUpdateTreeNow()
|
||||
{
|
||||
if (getOwnerTab().selected)
|
||||
window.setTimeout(onTabSelect, 0);
|
||||
window.setTimeout(function() {
|
||||
if (!window.closed)
|
||||
onTabSelect();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
var gShouldUpdate = false;
|
||||
|
@ -58,8 +58,11 @@ var PseudoTreeBuilder = {
|
||||
|
||||
var tree = this.createTabItem(aTab);
|
||||
|
||||
tree.querySelector("."+this.kTREEROW)
|
||||
.className += " "+this.kROOTITEM;
|
||||
var row = tree.querySelector("."+this.kTREEROW);
|
||||
if (!row)
|
||||
return;
|
||||
|
||||
row.className += " "+this.kROOTITEM;
|
||||
|
||||
tree.setAttribute('onclick', <![CDATA[
|
||||
var doc = event.target.ownerDocument;
|
||||
@ -74,6 +77,11 @@ var PseudoTreeBuilder = {
|
||||
var customEvent = doc.createEvent('DataContainerEvent');
|
||||
customEvent.initEvent(%EVENT_TYPE%, true, true);
|
||||
customEvent.setData('id', label.getAttribute('tab-id'));
|
||||
customEvent.setData('button', event.button);
|
||||
customEvent.setData('altKey', event.altKey);
|
||||
customEvent.setData('ctrlKey', event.ctrlKey);
|
||||
customEvent.setData('metaKey', event.metaKey);
|
||||
customEvent.setData('shiftKey', event.shiftKey);
|
||||
event.target.dispatchEvent(customEvent);
|
||||
}
|
||||
]]>.toString().replace('%EVENT_TYPE%', this.kTAB_LINK_CLICK.quote()));
|
||||
|
Loading…
Reference in New Issue
Block a user