Skip to content

Commit 7ccf7ec

Browse files
committed
Add dblclick to open new file (like sublime text)
1 parent aa12e49 commit 7ccf7ec

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

client/views/components/tabs.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ define([
7676
},
7777

7878
// Create section
79-
createSection: function(section) {
79+
createSection: function(e) {
80+
if (e) e.stopPropagation();
8081
this.setSection(_.uniqueId("section"));
8182
},
8283

@@ -198,6 +199,9 @@ define([
198199
// Complete tabs system
199200
var TabsView = hr.View.extend({
200201
className: "component-tabs",
202+
events: {
203+
"dblclick .tabs-header": "openDefaultNew"
204+
},
201205

202206
// Constructor
203207
initialize: function(options) {
@@ -431,6 +435,11 @@ define([
431435
this.render();
432436
return this;
433437
},
438+
439+
// Open default new tab
440+
openDefaultNew: function() {
441+
this.trigger("tabs:opennew");
442+
}
434443
}, {
435444
Panel: TabPanelView
436445
});

client/views/layouts/body.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ define([
1919
var that = this;
2020

2121
this.tabs = new TabsView();
22-
this.tabs.on("tabs:default", function() {
22+
23+
// Default tab and dbl click to open new
24+
this.tabs.on("tabs:default tabs:opennew", function() {
2325
files.openNew();
2426
}, this);
2527

0 commit comments

Comments
 (0)