##// END OF EJS Templates
Cleanup some inappropriate javascript...
MinRK -
Show More
@@ -20,6 +20,7 b' var IPython = (function (IPython) {'
20 this.completion_cursor = null;
20 this.completion_cursor = null;
21 this.outputs = [];
21 this.outputs = [];
22 this.collapsed = false;
22 this.collapsed = false;
23 this.tooltip_timeout = null;
23 IPython.Cell.apply(this, arguments);
24 IPython.Cell.apply(this, arguments);
24 };
25 };
25
26
@@ -48,7 +49,8 b' var IPython = (function (IPython) {'
48 };
49 };
49
50
50 //TODO, try to diminish the number of parameters.
51 //TODO, try to diminish the number of parameters.
51 CodeCell.prototype.request_tooltip_after_time = function (pre_cursor,time,that){
52 CodeCell.prototype.request_tooltip_after_time = function (pre_cursor,time){
53 var that = this;
52 if (pre_cursor === "" || pre_cursor === "(" ) {
54 if (pre_cursor === "" || pre_cursor === "(" ) {
53 // don't do anything if line beggin with '(' or is empty
55 // don't do anything if line beggin with '(' or is empty
54 } else {
56 } else {
@@ -74,8 +76,7 b' var IPython = (function (IPython) {'
74 // whatever key is pressed, first, cancel the tooltip request before
76 // whatever key is pressed, first, cancel the tooltip request before
75 // they are sent, and remove tooltip if any
77 // they are sent, and remove tooltip if any
76 if(event.type === 'keydown' ){
78 if(event.type === 'keydown' ){
77 CodeCell.prototype.remove_and_cancel_tooltip(that.tooltip_timeout);
79 that.remove_and_cancel_tooltip();
78 that.tooltip_timeout=null;
79 }
80 }
80
81
81 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
82 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
@@ -87,7 +88,7 b' var IPython = (function (IPython) {'
87 // Pressing '(' , request tooltip, don't forget to reappend it
88 // Pressing '(' , request tooltip, don't forget to reappend it
88 var cursor = editor.getCursor();
89 var cursor = editor.getCursor();
89 var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'(';
90 var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'(';
90 CodeCell.prototype.request_tooltip_after_time(pre_cursor,tooltip_wait_time,that);
91 that.request_tooltip_after_time(pre_cursor,tooltip_wait_time);
91 } else if (event.keyCode === 9 && event.type == 'keydown') {
92 } else if (event.keyCode === 9 && event.type == 'keydown') {
92 // Tab completion.
93 // Tab completion.
93 var cur = editor.getCursor();
94 var cur = editor.getCursor();
@@ -98,7 +99,7 b' var IPython = (function (IPython) {'
98 // is empty. In this case, let CodeMirror handle indentation.
99 // is empty. In this case, let CodeMirror handle indentation.
99 return false;
100 return false;
100 } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) {
101 } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) {
101 CodeCell.prototype.request_tooltip_after_time(pre_cursor,0,that);
102 that.request_tooltip_after_time(pre_cursor,0);
102 } else {
103 } else {
103 pre_cursor.trim();
104 pre_cursor.trim();
104 // Autocomplete the current line.
105 // Autocomplete the current line.
@@ -145,14 +146,15 b' var IPython = (function (IPython) {'
145 return false;
146 return false;
146 };
147 };
147
148
148 CodeCell.prototype.remove_and_cancel_tooltip = function(timeout)
149 CodeCell.prototype.remove_and_cancel_tooltip = function() {
149 {
150 // note that we don't handle closing directly inside the calltip
150 // note that we don't handle closing directly inside the calltip
151 // as in the completer, because it is not focusable, so won't
151 // as in the completer, because it is not focusable, so won't
152 // get the event.
152 // get the event.
153 if(timeout != null)
153 if (this.tooltip_timeout != null){
154 { clearTimeout(timeout);}
154 clearTimeout(this.tooltip_timeout);
155 $('#tooltip').remove();
155 $('#tooltip').remove();
156 this.tooltip_timeout = null;
157 }
156 }
158 }
157
159
158 CodeCell.prototype.finish_tooltip = function (reply) {
160 CodeCell.prototype.finish_tooltip = function (reply) {
@@ -194,7 +196,7 b' var IPython = (function (IPython) {'
194 morelink.click(function(){
196 morelink.click(function(){
195 var msg_id = IPython.notebook.kernel.execute(name+"?");
197 var msg_id = IPython.notebook.kernel.execute(name+"?");
196 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.selected_cell().cell_id;
198 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.selected_cell().cell_id;
197 CodeCell.prototype.remove_and_cancel_tooltip(that.tooltip_timeout);
199 that.remove_and_cancel_tooltip();
198 setTimeout(function(){that.code_mirror.focus();}, 50);
200 setTimeout(function(){that.code_mirror.focus();}, 50);
199 });
201 });
200
202
@@ -208,7 +210,7 b' var IPython = (function (IPython) {'
208 closespan.addClass('ui-icon-close');
210 closespan.addClass('ui-icon-close');
209 closelink.append(closespan);
211 closelink.append(closespan);
210 closelink.click(function(){
212 closelink.click(function(){
211 CodeCell.prototype.remove_and_cancel_tooltip(that.tooltip_timeout);
213 that.remove_and_cancel_tooltip();
212 setTimeout(function(){that.code_mirror.focus();}, 50);
214 setTimeout(function(){that.code_mirror.focus();}, 50);
213 });
215 });
214 //construct the tooltip
216 //construct the tooltip
@@ -227,7 +229,7 b' var IPython = (function (IPython) {'
227
229
228 // issues with cross-closing if multiple tooltip in less than 5sec
230 // issues with cross-closing if multiple tooltip in less than 5sec
229 // keep it comented for now
231 // keep it comented for now
230 // setTimeout(CodeCell.prototype.remove_and_cancel_tooltip, 5000);
232 // setTimeout(that.remove_and_cancel_tooltip, 5000);
231 };
233 };
232
234
233 // As you type completer
235 // As you type completer
@@ -289,7 +291,7 b' var IPython = (function (IPython) {'
289 console.log('Ok, you really want to complete after pressing tab '+this.npressed+' times !');
291 console.log('Ok, you really want to complete after pressing tab '+this.npressed+' times !');
290 console.log('You should understand that there is no (more) completion for that !');
292 console.log('You should understand that there is no (more) completion for that !');
291 console.log("I'll show you the tooltip, will you stop bothering me ?");
293 console.log("I'll show you the tooltip, will you stop bothering me ?");
292 this.request_tooltip_after_time(matched_text+'(',0,this);
294 this.request_tooltip_after_time(matched_text+'(',0);
293 return;
295 return;
294 }
296 }
295 this.prevmatch=matched_text
297 this.prevmatch=matched_text
General Comments 0
You need to be logged in to leave comments. Login now