5
5
*
6
6
* @version 0.1.0
7
7
* @author Benjamin Ellenberger, https://github.com/benelot
8
- * @updated 2018-02-03
8
+ * @updated 2018-02-16
9
9
*
10
10
*
11
11
*/
@@ -56,12 +56,14 @@ define([
56
56
57
57
Jupyter . notebook . get_cells ( ) . forEach ( function ( cell , idx , cells ) { // toggle visibility of cells depending on their tags
58
58
var tags = cell . metadata . tags || [ ] ;
59
- tags = tags . join ( ' ' ) ;
60
- if ( tags . search ( matchExpr ) !== - 1 ) {
61
- cell . element . find ( "div.input" ) . show ( ) ; // cell.element.style.display = '';
59
+ tags = tags . join ( ' ' ) ;
60
+ if ( filterText === ".*(?=.*).*" || filterText === "" || tags . search ( matchExpr ) !== - 1 && tags . length > 0 ) { // empty filter or match expression on non-zero tags
61
+ cell . element . show ( ) ; // cell.element.style.display = '';
62
+ //cell.element.find("div.inner_cell").show();
62
63
}
63
64
else {
64
- cell . element . find ( "div.input" ) . hide ( ) ; // cell.element.style.display = 'none';
65
+ cell . element . hide ( ) ; // cell.element.style.display = 'none';
66
+ //cell.element.find("div.inner_cell").hide();
65
67
}
66
68
} ) ;
67
69
}
@@ -72,14 +74,14 @@ define([
72
74
73
75
function load_ipython_extension ( ) {
74
76
75
- var form = $ ( '<form />' ) // insert a form into the main toolbar container
76
- . css ( 'padding' , '0 7px 4px' )
77
+ var form_tgrp = $ ( '<div />' )
78
+ . addClass ( 'btn-group' ) // insert a top form-group to make the form appear next to the buttons
77
79
. appendTo ( '#maintoolbar-container' ) ;
78
80
79
81
var frm_grp = $ ( '<div/>' )
80
82
. addClass ( 'form-group' ) // insert a form-group
81
83
. css ( 'margin-bottom' , 0 )
82
- . appendTo ( form ) ;
84
+ . appendTo ( form_tgrp ) ;
83
85
84
86
var grp = $ ( '<div/>' )
85
87
. addClass ( 'input-group' ) // insert an input-group
@@ -90,12 +92,12 @@ define([
90
92
. addClass ( 'form-control input-sm' )
91
93
. attr ( 'title' , 'Keyword for filtering cells by tags' )
92
94
. attr ( 'id' , 'filterkeyword' )
93
- . attr ( 'placeholder' , 'Filter' )
95
+ . attr ( 'placeholder' , 'Cell Tag Filter' )
94
96
. css ( 'font-weight' , 'bold' )
95
- . appendTo ( grp ) ;
96
-
97
- var btns = $ ( '<div/>' )
98
- . addClass ( 'input-group-btn' ) // insert a div to group buttons
97
+ . css ( 'width' , '70%' )
98
+ . css ( 'height' , '24px' )
99
+ . on ( 'focus' , function ( evt ) { Jupyter . notebook . keyboard_manager . disable ( ) ; } )
100
+ . on ( 'blur' , function ( evt ) { Jupyter . notebook . keyboard_manager . enable ( ) ; } )
99
101
. appendTo ( grp ) ;
100
102
101
103
$ ( '<button/>' )
@@ -107,7 +109,7 @@ define([
107
109
. attr ( 'title' , 'Use regex (JavaScript regex syntax)' )
108
110
. text ( '.*' )
109
111
. on ( 'click' , function ( evt ) { setTimeout ( filterRowsDefaultParams ) ; } )
110
- . appendTo ( btns ) ;
112
+ . appendTo ( grp ) ;
111
113
112
114
$ ( '<button/>' ) // insert case sensitive button
113
115
. attr ( 'type' , 'button' )
@@ -119,7 +121,7 @@ define([
119
121
. css ( 'font-weight' , 'bold' )
120
122
. text ( 'Aa' )
121
123
. on ( 'click' , function ( evt ) { setTimeout ( filterRowsDefaultParams ) ; } )
122
- . appendTo ( btns ) ;
124
+ . appendTo ( grp ) ;
123
125
124
126
$ ( '#filterkeyword' ) . on ( 'keyup' , filterRowsDefaultParams ) ; // trigger filtering right with typing
125
127
}
0 commit comments