1- var bus = require ( './bus' ) ;
21var stringScore = require ( '../../../vendor/string_score' ) ;
32var tabBroker = require ( './tab_broker' ) ( chrome ) ;
43var tabFilter = require ( './tab_filter' ) ( stringScore ) ;
@@ -7,24 +6,6 @@ var TabSearchBox = require('./tab_search_box.jsx');
76var TabList = require ( './tab_list.jsx' ) ;
87var StatusBar = require ( './status_bar.jsx' ) ;
98
10- /**
11- * TabSwitcher is the main component of our application. It contains
12- * all the state, and all other components communicate their intent
13- * to change that state via events on the bus (which is a Node.js
14- * EventEmitter). All child components receive their data via properties.
15- *
16- * Bus events:
17- * - change:searchAllWindows(boolean) - the 'search all windows'
18- * option was toggled
19- * - change:filter(string) - the filter text was changed
20- * - change:selected(tab) - the selected tab was changed
21- * - action:activate - the user wishes to swich to the currently
22- * selected tab
23- * - select:previous - the tab above the selected one should be selected
24- * - select:next - the tab below the selected one should be selected
25- * - exit - the extension should exit, closing the window
26- */
27-
289module . exports = React . createClass ( {
2910 getInitialState : function ( ) {
3011 // TODO: move into a model
@@ -44,26 +25,29 @@ module.exports = React.createClass({
4425 } ,
4526
4627 componentDidMount : function ( ) {
47- bus . on ( 'change:filter' , this . changeFilter ) ;
48- bus . on ( 'change:selected' , this . changeSelected ) ;
49- bus . on ( 'change:searchAllWindows' , this . changeSearchAllWindows ) ;
50- bus . on ( 'select:previous' , this . moveSelection . bind ( this , - 1 ) ) ;
51- bus . on ( 'select:next' , this . moveSelection . bind ( this , 1 ) ) ;
52- bus . on ( 'action:activate' , this . activateSelection ) ;
53- bus . on ( 'exit' , this . close ) ;
5428 window . onblur = this . close ;
55-
5629 this . refreshTabs ( ) ;
5730 } ,
5831
5932 render : function ( ) {
6033 return (
6134 /* jshint ignore:start */
6235 < div >
63- < TabSearchBox filter = { this . state . filter } />
64- < TabList tabs = { this . filteredTabs ( ) } filter = { this . state . filter }
65- selectedTab = { this . getSelected ( ) } />
66- < StatusBar searchAllWindows = { this . state . searchAllWindows } />
36+ < TabSearchBox
37+ filter = { this . state . filter }
38+ exit = { this . close }
39+ changeFilter = { this . changeFilter }
40+ activateSelected = { this . activateSelected }
41+ modifySelected = { this . modifySelected } />
42+ < TabList
43+ tabs = { this . filteredTabs ( ) }
44+ filter = { this . state . filter }
45+ selectedTab = { this . getSelected ( ) }
46+ changeSelected = { this . changeSelected }
47+ activateSelected = { this . activateSelected } />
48+ < StatusBar
49+ searchAllWindows = { this . state . searchAllWindows }
50+ changeSearchAllWindows = { this . changeSearchAllWindows } />
6751 </ div >
6852 /* jshint ignore:end */
6953 ) ;
@@ -94,11 +78,11 @@ module.exports = React.createClass({
9478 return this . state . selected || this . filteredTabs ( ) [ 0 ] ;
9579 } ,
9680
97- activateSelection : function ( ) {
81+ activateSelected : function ( ) {
9882 var selected = this . getSelected ( ) ;
9983 if ( selected ) {
10084 tabBroker . switchTo ( selected ) ;
101- bus . emit ( 'exit' ) ;
85+ this . close ( ) ;
10286 }
10387 } ,
10488
@@ -110,7 +94,7 @@ module.exports = React.createClass({
11094 this . setState ( { selected : tab } ) ;
11195 } ,
11296
113- moveSelection : function ( change ) {
97+ modifySelected : function ( change ) {
11498 var filteredTabs = this . filteredTabs ( ) ;
11599 if ( ! filteredTabs . length ) return ;
116100
@@ -119,7 +103,7 @@ module.exports = React.createClass({
119103 if ( newIndex < 0 ) newIndex = 0 ;
120104 if ( newIndex >= filteredTabs . length ) newIndex = filteredTabs . length - 1 ;
121105 var newTab = filteredTabs [ newIndex ] ;
122- bus . emit ( 'change:selected' , newTab ) ;
106+ this . changeSelected ( newTab ) ;
123107 } ,
124108
125109 changeSearchAllWindows : function ( value ) {
0 commit comments