33 "jQuery" ,
44 "hr/hr" ,
55 "utils/dragdrop" ,
6- "utils/keyboard"
7- ] , function ( _ , $ , hr , DragDrop , Keyboard ) {
6+ "utils/keyboard" ,
7+ "utils/contextmenu"
8+ ] , function ( _ , $ , hr , DragDrop , Keyboard , ContextMenu ) {
89 // Tab header
910 var TabView = hr . View . extend ( {
1011 className : "component-tab" ,
@@ -16,7 +17,7 @@ define([
1617 events : {
1718 "click" : "open" ,
1819 "click .close" : "close" ,
19- "dblclick" : "createSection " ,
20+ "dblclick" : "split " ,
2021 "dragstart" : "dragStart"
2122 } ,
2223 states : {
@@ -28,11 +29,47 @@ define([
2829 initialize : function ( ) {
2930 TabView . __super__ . initialize . apply ( this , arguments ) ;
3031
32+ var that = this ;
33+
3134 this . $el . attr ( "draggable" , true ) ;
3235 this . tabid = this . options . tabid ;
3336 this . tabs = this . parent ;
3437 this . section = this . options . section || 0 ;
3538
39+ // Context menu
40+ ContextMenu . add ( this . $el , [
41+ {
42+ 'type' : "action" ,
43+ 'text' : "New Tab" ,
44+ 'action' : function ( ) {
45+ that . tabs . openDefaultNew ( ) ;
46+ }
47+ } ,
48+ { 'type' : "divider" } ,
49+ {
50+ 'type' : "action" ,
51+ 'text' : "Close" ,
52+ 'action' : function ( ) {
53+ that . close ( ) ;
54+ }
55+ } ,
56+ {
57+ 'type' : "action" ,
58+ 'text' : "Close Other Tabs" ,
59+ 'action' : function ( ) {
60+ that . closeOthers ( ) ;
61+ }
62+ } ,
63+ { 'type' : "divider" } ,
64+ {
65+ 'type' : "action" ,
66+ 'text' : "New Group" ,
67+ 'action' : function ( ) {
68+ that . split ( ) ;
69+ }
70+ }
71+ ] ) ;
72+
3673 return this ;
3774 } ,
3875
@@ -76,7 +113,7 @@ define([
76113 } ,
77114
78115 // Create section
79- createSection : function ( e ) {
116+ split : function ( e ) {
80117 if ( e ) e . stopPropagation ( ) ;
81118 this . setSection ( _ . uniqueId ( "section" ) ) ;
82119 } ,
@@ -100,6 +137,11 @@ define([
100137 e . stopPropagation ( ) ;
101138 }
102139 this . tabs . close ( this . tabid , force ) ;
140+ } ,
141+
142+ // (event) close others tabs
143+ closeOthers : function ( e ) {
144+ this . tabs . closeOthers ( this . tabid ) ;
103145 }
104146 } ) ;
105147
@@ -436,6 +478,16 @@ define([
436478 return this ;
437479 } ,
438480
481+ // Close others tabs
482+ closeOthers : function ( tabid ) {
483+ _ . each ( this . tabs , function ( tab , oTabId ) {
484+ if ( oTabId == tabid ) return ;
485+ this . close ( oTabId ) ;
486+ } , this ) ;
487+
488+ return this ;
489+ } ,
490+
439491 // Open default new tab
440492 openDefaultNew : function ( e ) {
441493 this . trigger ( "tabs:opennew" ) ;
0 commit comments