Merge pull request #107 from elisee/middleclick-closes-tab

Close tab on middle-click (fixes #106)
This commit is contained in:
Thomas Wilburn 2013-12-20 22:21:35 -08:00
commit 9abc53b958
2 changed files with 11 additions and 0 deletions

View file

@ -59,6 +59,7 @@ define([
document.body.on("click", function(e) {
//cancel on inputs, selectboxes
if (["input", "select"].indexOf(e.target.tagName.toLowerCase()) >= 0) return;
if (e.button != 0) return;
//delegate all items with a command attribute
if (e.target.hasAttribute("command")) {
var command = e.target.getAttribute("command");

View file

@ -312,6 +312,15 @@ define([
renderTabs();
});
};
var enableTabMiddleClick = function() {
var tabContainer = document.find(".tabs");
tabContainer.on("click", function(e) {
if (!e.target.matches(".tab")) return;
if (e.button != 1) return;
command.fire("session:close-tab", e.target.getAttribute("argument"));
});
};
var init = function() {
cfg.modes.forEach(function(mode) {
@ -323,6 +332,7 @@ define([
addTab("");
renderTabs();
enableTabDragDrop();
enableTabMiddleClick();
reset();
};