##// END OF EJS Templates
Improve tooltip tringgering,make it configurable...
Matthias BUSSONNIER -
Show More
@@ -115,6 +115,10 b' span.section_row_buttons a {'
115 float: right;
115 float: right;
116 }
116 }
117
117
118 #tooltipontab_span {
119 float: right;
120 }
121
118 .checkbox_label {
122 .checkbox_label {
119 font-size: 85%;
123 font-size: 85%;
120 float: right;
124 float: right;
@@ -85,7 +85,6 b' var IPython = (function (IPython) {'
85 }
85 }
86 };
86 };
87
87
88
89 // Subclasses must implement create_element.
88 // Subclasses must implement create_element.
90 Cell.prototype.create_element = function () {};
89 Cell.prototype.create_element = function () {};
91
90
@@ -65,7 +65,8 b' var IPython = (function (IPython) {'
65 // value is used to determine if CodeMirror should ignore the event:
65 // value is used to determine if CodeMirror should ignore the event:
66 // true = ignore, false = don't ignore.
66 // true = ignore, false = don't ignore.
67 tooltip_wait_time = 2000;
67 tooltip_wait_time = 2000;
68 tooltip_on_tab = true;
68
69 tooltip_on_tab = this.notebook.tooltip_on_tab;
69 var that = this;
70 var that = this;
70
71
71 // whatever key is pressed, first, cancel the tooltip request before
72 // whatever key is pressed, first, cancel the tooltip request before
@@ -79,9 +80,9 b' var IPython = (function (IPython) {'
79 // Always ignore shift-enter in CodeMirror as we handle it.
80 // Always ignore shift-enter in CodeMirror as we handle it.
80 return true;
81 return true;
81 }else if (event.keyCode === 53 && event.type === 'keydown' && tooltip_wait_time >= 0) {
82 }else if (event.keyCode === 53 && event.type === 'keydown' && tooltip_wait_time >= 0) {
82 // Pressing '(' , request tooltip
83 // Pressing '(' , request tooltip, don't forget to reappend it
83 var cursor = editor.getCursor();
84 var cursor = editor.getCursor();
84 var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim();
85 var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'(';
85 CodeCell.prototype.request_tooltip_after_time(pre_cursor,tooltip_wait_time,that);
86 CodeCell.prototype.request_tooltip_after_time(pre_cursor,tooltip_wait_time,that);
86 } else if (event.keyCode === 9 && event.type == 'keydown') {
87 } else if (event.keyCode === 9 && event.type == 'keydown') {
87 // Tab completion.
88 // Tab completion.
@@ -92,7 +93,7 b' var IPython = (function (IPython) {'
92 // Don't autocomplete if the part of the line before the cursor
93 // Don't autocomplete if the part of the line before the cursor
93 // is empty. In this case, let CodeMirror handle indentation.
94 // is empty. In this case, let CodeMirror handle indentation.
94 return false;
95 return false;
95 } else if (pre_cursor.substr(-1) === "(" && tooltip_on_tab ) {
96 } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) {
96 CodeCell.prototype.request_tooltip_after_time(pre_cursor,0,that);
97 CodeCell.prototype.request_tooltip_after_time(pre_cursor,0,that);
97 } else {
98 } else {
98 pre_cursor.trim();
99 pre_cursor.trim();
@@ -67,6 +67,7 b' var IPython = (function (IPython) {'
67 this.notebook_section = new IPython.NotebookSection('div#notebook_section');
67 this.notebook_section = new IPython.NotebookSection('div#notebook_section');
68 if (! IPython.read_only){
68 if (! IPython.read_only){
69 this.cell_section = new IPython.CellSection('div#cell_section');
69 this.cell_section = new IPython.CellSection('div#cell_section');
70 this.config_section = new IPython.ConfigSection('div#config_section');
70 this.kernel_section = new IPython.KernelSection('div#kernel_section');
71 this.kernel_section = new IPython.KernelSection('div#kernel_section');
71 }
72 }
72 this.help_section = new IPython.HelpSection('div#help_section');
73 this.help_section = new IPython.HelpSection('div#help_section');
@@ -27,6 +27,7 b' var IPython = (function (IPython) {'
27 this.style();
27 this.style();
28 this.create_elements();
28 this.create_elements();
29 this.bind_events();
29 this.bind_events();
30 this.set_tooltipontab(true);
30 };
31 };
31
32
32
33
@@ -621,6 +622,11 b' var IPython = (function (IPython) {'
621 };
622 };
622
623
623
624
625 Notebook.prototype.set_tooltipontab = function (state) {
626 console.log("change tooltip on tab to : "+state);
627 this.tooltip_on_tab = state;
628 };
629
624 Notebook.prototype.set_autoindent = function (state) {
630 Notebook.prototype.set_autoindent = function (state) {
625 var cells = this.cells();
631 var cells = this.cells();
626 len = cells.length;
632 len = cells.length;
@@ -883,10 +889,22 b' var IPython = (function (IPython) {'
883
889
884
890
885 Notebook.prototype.request_tool_tip = function (cell,func) {
891 Notebook.prototype.request_tool_tip = function (cell,func) {
886 //remove ending '(' if any
892 // Feel free to shorten this logic if you are better
887 //there should be a way to do it in the regexp
893 // than me in regEx
888 if(func.substr(-1) === '('){func=func.substr(0, func.length-1);}
894 // basicaly you shoul be able to get xxx.xxx.xxx from
889 // regexp to select last part of expression
895 // something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
896 // remove everything between matchin bracket (need to iterate)
897 matchBracket = /\([^\(\)]+\)/g;
898 oldfunc = func;
899 func = func.replace(matchBracket,"");
900 while( oldfunc != func )
901 {
902 oldfunc = func;
903 func = func.replace(matchBracket,"");
904 }
905 // remove everythin after last open bracket
906 endBracket = /\([^\(]*$/g;
907 func = func.replace(endBracket,"");
890 var re = /[a-zA-Z._]+$/g;
908 var re = /[a-zA-Z._]+$/g;
891 var msg_id = this.kernel.object_info_request(re.exec(func));
909 var msg_id = this.kernel.object_info_request(re.exec(func));
892 this.msg_cell_map[msg_id] = cell.cell_id;
910 this.msg_cell_map[msg_id] = cell.cell_id;
@@ -51,6 +51,7 b' $(document).ready(function () {'
51 IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only
51 IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only
52 $('button#new_notebook').addClass('hidden');
52 $('button#new_notebook').addClass('hidden');
53 $('div#cell_section').addClass('hidden');
53 $('div#cell_section').addClass('hidden');
54 $('div#config_section').addClass('hidden');
54 $('div#kernel_section').addClass('hidden');
55 $('div#kernel_section').addClass('hidden');
55 $('span#login_widget').removeClass('hidden');
56 $('span#login_widget').removeClass('hidden');
56 // left panel starts collapsed, but the collapse must happen after
57 // left panel starts collapsed, but the collapse must happen after
@@ -121,13 +121,39 b' var IPython = (function (IPython) {'
121 });
121 });
122 };
122 };
123
123
124 // ConfigSection
125
126 var ConfigSection = function () {
127 PanelSection.apply(this, arguments);
128 };
129
130 ConfigSection.prototype = new PanelSection();
131
132 ConfigSection.prototype.style = function () {
133 PanelSection.prototype.style.apply(this);
134 this.content.addClass('ui-helper-clearfix');
135 this.content.find('div.section_row').addClass('ui-helper-clearfix');
136
137 this.content.find('#tooltipontab').attr('title', 'Show tooltip if yuo press <Tab> after "(" or a white space');
138 this.content.find('#tooltipontab_label').attr('title', 'Show Tooltip when pressing Tab');
139
140 };
141
142
143 ConfigSection.prototype.bind_events = function () {
144 PanelSection.prototype.bind_events.apply(this);
145 this.content.find('#tooltipontab').change(function () {
146 var state = $('#tooltipontab').prop('checked');
147 IPython.notebook.set_tooltipontab(state);
148 });
149 };
150
124 // CellSection
151 // CellSection
125
152
126 var CellSection = function () {
153 var CellSection = function () {
127 PanelSection.apply(this, arguments);
154 PanelSection.apply(this, arguments);
128 };
155 };
129
156
130
131 CellSection.prototype = new PanelSection();
157 CellSection.prototype = new PanelSection();
132
158
133
159
@@ -201,6 +227,10 b' var IPython = (function (IPython) {'
201 var state = $('#autoindent').prop('checked');
227 var state = $('#autoindent').prop('checked');
202 IPython.notebook.set_autoindent(state);
228 IPython.notebook.set_autoindent(state);
203 });
229 });
230 this.content.find('#tooltipontab').change(function () {
231 var state = $('#tooltipontab').prop('checked');
232 IPython.notebook.set_tooltipontab(state);
233 });
204 };
234 };
205
235
206
236
@@ -280,6 +310,7 b' var IPython = (function (IPython) {'
280 IPython.PanelSection = PanelSection;
310 IPython.PanelSection = PanelSection;
281 IPython.NotebookSection = NotebookSection;
311 IPython.NotebookSection = NotebookSection;
282 IPython.CellSection = CellSection;
312 IPython.CellSection = CellSection;
313 IPython.ConfigSection = ConfigSection;
283 IPython.KernelSection = KernelSection;
314 IPython.KernelSection = KernelSection;
284 IPython.HelpSection = HelpSection;
315 IPython.HelpSection = HelpSection;
285
316
@@ -251,6 +251,20 b''
251 </div>
251 </div>
252 </div>
252 </div>
253
253
254 <div id="config_section">
255 <div class="section_header">
256 <h3>Config</h3>
257 </div>
258 <div class="section_content">
259 <div class="section_row">
260 <span id="tooltipontab_span">
261 <input type="checkbox" id="tooltipontab" checked="true"></input>
262 </span>
263 <span class="checkbox_label" id="tooltipontab_label">Tooltip on tab:</span>
264 </div>
265 </div>
266 </div>
267
254 </div>
268 </div>
255 <div id="left_panel_splitter"></div>
269 <div id="left_panel_splitter"></div>
256 <div id="notebook_panel">
270 <div id="notebook_panel">
General Comments 0
You need to be logged in to leave comments. Login now