##// END OF EJS Templates
Merge pull request #5429 from jdfreder/tooltipcompleter...
Min RK -
r15991:4b87fde0 merge
parent child Browse files
Show More
@@ -1,391 +1,387 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7 //============================================================================
7 //============================================================================
8 // Tooltip
8 // Tooltip
9 //============================================================================
9 //============================================================================
10 //
10 //
11 // you can set the autocall time by setting `IPython.tooltip.time_before_tooltip` in ms
11 // you can set the autocall time by setting `IPython.tooltip.time_before_tooltip` in ms
12 //
12 //
13 // you can configure the differents action of pressing tab several times in a row by
13 // you can configure the differents action of pressing tab several times in a row by
14 // setting/appending different fonction in the array
14 // setting/appending different fonction in the array
15 // IPython.tooltip.tabs_functions
15 // IPython.tooltip.tabs_functions
16 //
16 //
17 // eg :
17 // eg :
18 // IPython.tooltip.tabs_functions[4] = function (){console.log('this is the action of the 4th tab pressing')}
18 // IPython.tooltip.tabs_functions[4] = function (){console.log('this is the action of the 4th tab pressing')}
19 //
19 //
20 var IPython = (function (IPython) {
20 var IPython = (function (IPython) {
21 "use strict";
21 "use strict";
22
22
23 var utils = IPython.utils;
23 var utils = IPython.utils;
24
24
25 // tooltip constructor
25 // tooltip constructor
26 var Tooltip = function () {
26 var Tooltip = function () {
27 var that = this;
27 var that = this;
28 this.time_before_tooltip = 1200;
28 this.time_before_tooltip = 1200;
29
29
30 // handle to html
30 // handle to html
31 this.tooltip = $('#tooltip');
31 this.tooltip = $('#tooltip');
32 this._hidden = true;
32 this._hidden = true;
33
33
34 // variable for consecutive call
34 // variable for consecutive call
35 this._old_cell = null;
35 this._old_cell = null;
36 this._old_request = null;
36 this._old_request = null;
37 this._consecutive_counter = 0;
37 this._consecutive_counter = 0;
38
38
39 // 'sticky ?'
39 // 'sticky ?'
40 this._sticky = false;
40 this._sticky = false;
41
41
42 // display tooltip if the docstring is empty?
42 // display tooltip if the docstring is empty?
43 this._hide_if_no_docstring = false;
43 this._hide_if_no_docstring = false;
44
44
45 // contain the button in the upper right corner
45 // contain the button in the upper right corner
46 this.buttons = $('<div/>').addClass('tooltipbuttons');
46 this.buttons = $('<div/>').addClass('tooltipbuttons');
47
47
48 // will contain the docstring
48 // will contain the docstring
49 this.text = $('<div/>').addClass('tooltiptext').addClass('smalltooltip');
49 this.text = $('<div/>').addClass('tooltiptext').addClass('smalltooltip');
50
50
51 // build the buttons menu on the upper right
51 // build the buttons menu on the upper right
52 // expand the tooltip to see more
52 // expand the tooltip to see more
53 var expandlink = $('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner
53 var expandlink = $('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner
54 .attr('role', "button").attr('id', 'expanbutton').attr('title', 'Grow the tooltip vertically (press tab 2 times)').click(function () {
54 .attr('role', "button").attr('id', 'expanbutton').attr('title', 'Grow the tooltip vertically (press tab 2 times)').click(function () {
55 that.expand();
55 that.expand();
56 }).append(
56 }).append(
57 $('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus'));
57 $('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus'));
58
58
59 // open in pager
59 // open in pager
60 var morelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)');
60 var morelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)');
61 var morespan = $('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n');
61 var morespan = $('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n');
62 morelink.append(morespan);
62 morelink.append(morespan);
63 morelink.click(function () {
63 morelink.click(function () {
64 that.showInPager(that._old_cell);
64 that.showInPager(that._old_cell);
65 });
65 });
66
66
67 // close the tooltip
67 // close the tooltip
68 var closelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button');
68 var closelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button');
69 var closespan = $('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close');
69 var closespan = $('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close');
70 closelink.append(closespan);
70 closelink.append(closespan);
71 closelink.click(function () {
71 closelink.click(function () {
72 that.remove_and_cancel_tooltip(true);
72 that.remove_and_cancel_tooltip(true);
73 });
73 });
74
74
75 this._clocklink = $('<a/>').attr('href', "#");
75 this._clocklink = $('<a/>').attr('href', "#");
76 this._clocklink.attr('role', "button");
76 this._clocklink.attr('role', "button");
77 this._clocklink.addClass('ui-button');
77 this._clocklink.addClass('ui-button');
78 this._clocklink.attr('title', 'Tootip is not dismissed while typing for 10 seconds');
78 this._clocklink.attr('title', 'Tootip is not dismissed while typing for 10 seconds');
79 var clockspan = $('<span/>').text('Close');
79 var clockspan = $('<span/>').text('Close');
80 clockspan.addClass('ui-icon');
80 clockspan.addClass('ui-icon');
81 clockspan.addClass('ui-icon-clock');
81 clockspan.addClass('ui-icon-clock');
82 this._clocklink.append(clockspan);
82 this._clocklink.append(clockspan);
83 this._clocklink.click(function () {
83 this._clocklink.click(function () {
84 that.cancel_stick();
84 that.cancel_stick();
85 });
85 });
86
86
87
87
88
88
89
89
90 //construct the tooltip
90 //construct the tooltip
91 // add in the reverse order you want them to appear
91 // add in the reverse order you want them to appear
92 this.buttons.append(closelink);
92 this.buttons.append(closelink);
93 this.buttons.append(expandlink);
93 this.buttons.append(expandlink);
94 this.buttons.append(morelink);
94 this.buttons.append(morelink);
95 this.buttons.append(this._clocklink);
95 this.buttons.append(this._clocklink);
96 this._clocklink.hide();
96 this._clocklink.hide();
97
97
98
98
99 // we need a phony element to make the small arrow
99 // we need a phony element to make the small arrow
100 // of the tooltip in css
100 // of the tooltip in css
101 // we will move the arrow later
101 // we will move the arrow later
102 this.arrow = $('<div/>').addClass('pretooltiparrow');
102 this.arrow = $('<div/>').addClass('pretooltiparrow');
103 this.tooltip.append(this.buttons);
103 this.tooltip.append(this.buttons);
104 this.tooltip.append(this.arrow);
104 this.tooltip.append(this.arrow);
105 this.tooltip.append(this.text);
105 this.tooltip.append(this.text);
106
106
107 // function that will be called if you press tab 1, 2, 3... times in a row
107 // function that will be called if you press tab 1, 2, 3... times in a row
108 this.tabs_functions = [function (cell, text) {
108 this.tabs_functions = [function (cell, text) {
109 that._request_tooltip(cell, text);
109 that._request_tooltip(cell, text);
110 }, function () {
110 }, function () {
111 that.expand();
111 that.expand();
112 }, function () {
112 }, function () {
113 that.stick();
113 that.stick();
114 }, function (cell) {
114 }, function (cell) {
115 that.cancel_stick();
115 that.cancel_stick();
116 that.showInPager(cell);
116 that.showInPager(cell);
117 }];
117 }];
118 // call after all the tabs function above have bee call to clean their effects
118 // call after all the tabs function above have bee call to clean their effects
119 // if necessary
119 // if necessary
120 this.reset_tabs_function = function (cell, text) {
120 this.reset_tabs_function = function (cell, text) {
121 this._old_cell = (cell) ? cell : null;
121 this._old_cell = (cell) ? cell : null;
122 this._old_request = (text) ? text : null;
122 this._old_request = (text) ? text : null;
123 this._consecutive_counter = 0;
123 this._consecutive_counter = 0;
124 };
124 };
125 };
125 };
126
126
127 Tooltip.prototype.is_visible = function () {
127 Tooltip.prototype.is_visible = function () {
128 return !this._hidden;
128 return !this._hidden;
129 };
129 };
130
130
131 Tooltip.prototype.showInPager = function (cell) {
131 Tooltip.prototype.showInPager = function (cell) {
132 // reexecute last call in pager by appending ? to show back in pager
132 // reexecute last call in pager by appending ? to show back in pager
133 var that = this;
133 var that = this;
134 var empty = function () {};
134 var callbacks = {'shell' : {
135 cell.kernel.execute(
135 'payload' : {
136 that.name + '?', {
136 'page' : $.proxy(cell._open_with_pager, cell)
137 'execute_reply': empty,
137 }
138 'output': empty,
138 }
139 'clear_output': empty,
139 };
140 'cell': cell
140 cell.kernel.execute(that.name + '?', callbacks, {'silent': false, 'store_history': true});
141 }, {
142 'silent': false,
143 'store_history': true
144 });
145 this.remove_and_cancel_tooltip();
141 this.remove_and_cancel_tooltip();
146 };
142 };
147
143
148 // grow the tooltip verticaly
144 // grow the tooltip verticaly
149 Tooltip.prototype.expand = function () {
145 Tooltip.prototype.expand = function () {
150 this.text.removeClass('smalltooltip');
146 this.text.removeClass('smalltooltip');
151 this.text.addClass('bigtooltip');
147 this.text.addClass('bigtooltip');
152 $('#expanbutton').hide('slow');
148 $('#expanbutton').hide('slow');
153 };
149 };
154
150
155 // deal with all the logic of hiding the tooltip
151 // deal with all the logic of hiding the tooltip
156 // and reset it's status
152 // and reset it's status
157 Tooltip.prototype._hide = function () {
153 Tooltip.prototype._hide = function () {
158 this._hidden = true;
154 this._hidden = true;
159 this.tooltip.fadeOut('fast');
155 this.tooltip.fadeOut('fast');
160 $('#expanbutton').show('slow');
156 $('#expanbutton').show('slow');
161 this.text.removeClass('bigtooltip');
157 this.text.removeClass('bigtooltip');
162 this.text.addClass('smalltooltip');
158 this.text.addClass('smalltooltip');
163 // keep scroll top to be sure to always see the first line
159 // keep scroll top to be sure to always see the first line
164 this.text.scrollTop(0);
160 this.text.scrollTop(0);
165 this.code_mirror = null;
161 this.code_mirror = null;
166 };
162 };
167
163
168 // return true on successfully removing a visible tooltip; otherwise return
164 // return true on successfully removing a visible tooltip; otherwise return
169 // false.
165 // false.
170 Tooltip.prototype.remove_and_cancel_tooltip = function (force) {
166 Tooltip.prototype.remove_and_cancel_tooltip = function (force) {
171 // note that we don't handle closing directly inside the calltip
167 // note that we don't handle closing directly inside the calltip
172 // as in the completer, because it is not focusable, so won't
168 // as in the completer, because it is not focusable, so won't
173 // get the event.
169 // get the event.
174 this.cancel_pending();
170 this.cancel_pending();
175 if (!this._hidden) {
171 if (!this._hidden) {
176 if (force || !this._sticky) {
172 if (force || !this._sticky) {
177 this.cancel_stick();
173 this.cancel_stick();
178 this._hide();
174 this._hide();
179 }
175 }
180 this.reset_tabs_function();
176 this.reset_tabs_function();
181 return true;
177 return true;
182 } else {
178 } else {
183 return false;
179 return false;
184 }
180 }
185 };
181 };
186
182
187 // cancel autocall done after '(' for example.
183 // cancel autocall done after '(' for example.
188 Tooltip.prototype.cancel_pending = function () {
184 Tooltip.prototype.cancel_pending = function () {
189 if (this._tooltip_timeout !== null) {
185 if (this._tooltip_timeout !== null) {
190 clearTimeout(this._tooltip_timeout);
186 clearTimeout(this._tooltip_timeout);
191 this._tooltip_timeout = null;
187 this._tooltip_timeout = null;
192 }
188 }
193 };
189 };
194
190
195 // will trigger tooltip after timeout
191 // will trigger tooltip after timeout
196 Tooltip.prototype.pending = function (cell, hide_if_no_docstring) {
192 Tooltip.prototype.pending = function (cell, hide_if_no_docstring) {
197 var that = this;
193 var that = this;
198 this._tooltip_timeout = setTimeout(function () {
194 this._tooltip_timeout = setTimeout(function () {
199 that.request(cell, hide_if_no_docstring);
195 that.request(cell, hide_if_no_docstring);
200 }, that.time_before_tooltip);
196 }, that.time_before_tooltip);
201 };
197 };
202
198
203 // easy access for julia monkey patching.
199 // easy access for julia monkey patching.
204 Tooltip.last_token_re = /[a-z_][0-9a-z._]*$/gi;
200 Tooltip.last_token_re = /[a-z_][0-9a-z._]*$/gi;
205
201
206 Tooltip.prototype.extract_oir_token = function(line){
202 Tooltip.prototype.extract_oir_token = function(line){
207 // use internally just to make the request to the kernel
203 // use internally just to make the request to the kernel
208 // Feel free to shorten this logic if you are better
204 // Feel free to shorten this logic if you are better
209 // than me in regEx
205 // than me in regEx
210 // basicaly you shoul be able to get xxx.xxx.xxx from
206 // basicaly you shoul be able to get xxx.xxx.xxx from
211 // something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
207 // something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
212 // remove everything between matchin bracket (need to iterate)
208 // remove everything between matchin bracket (need to iterate)
213 var matchBracket = /\([^\(\)]+\)/g;
209 var matchBracket = /\([^\(\)]+\)/g;
214 var endBracket = /\([^\(]*$/g;
210 var endBracket = /\([^\(]*$/g;
215 var oldline = line;
211 var oldline = line;
216
212
217 line = line.replace(matchBracket, "");
213 line = line.replace(matchBracket, "");
218 while (oldline != line) {
214 while (oldline != line) {
219 oldline = line;
215 oldline = line;
220 line = line.replace(matchBracket, "");
216 line = line.replace(matchBracket, "");
221 }
217 }
222 // remove everything after last open bracket
218 // remove everything after last open bracket
223 line = line.replace(endBracket, "");
219 line = line.replace(endBracket, "");
224 // reset the regex object
220 // reset the regex object
225 Tooltip.last_token_re.lastIndex = 0;
221 Tooltip.last_token_re.lastIndex = 0;
226 return Tooltip.last_token_re.exec(line);
222 return Tooltip.last_token_re.exec(line);
227 };
223 };
228
224
229 Tooltip.prototype._request_tooltip = function (cell, line) {
225 Tooltip.prototype._request_tooltip = function (cell, line) {
230 var callbacks = $.proxy(this._show, this);
226 var callbacks = $.proxy(this._show, this);
231 var oir_token = this.extract_oir_token(line);
227 var oir_token = this.extract_oir_token(line);
232 var msg_id = cell.kernel.object_info(oir_token, callbacks);
228 var msg_id = cell.kernel.object_info(oir_token, callbacks);
233 };
229 };
234
230
235 // make an imediate completion request
231 // make an imediate completion request
236 Tooltip.prototype.request = function (cell, hide_if_no_docstring) {
232 Tooltip.prototype.request = function (cell, hide_if_no_docstring) {
237 // request(codecell)
233 // request(codecell)
238 // Deal with extracting the text from the cell and counting
234 // Deal with extracting the text from the cell and counting
239 // call in a row
235 // call in a row
240 this.cancel_pending();
236 this.cancel_pending();
241 var editor = cell.code_mirror;
237 var editor = cell.code_mirror;
242 var cursor = editor.getCursor();
238 var cursor = editor.getCursor();
243 var text = editor.getRange({
239 var text = editor.getRange({
244 line: cursor.line,
240 line: cursor.line,
245 ch: 0
241 ch: 0
246 }, cursor).trim();
242 }, cursor).trim();
247
243
248 this._hide_if_no_docstring = hide_if_no_docstring;
244 this._hide_if_no_docstring = hide_if_no_docstring;
249
245
250 if(editor.somethingSelected()){
246 if(editor.somethingSelected()){
251 text = editor.getSelection();
247 text = editor.getSelection();
252 }
248 }
253
249
254 // need a permanent handel to code_mirror for future auto recall
250 // need a permanent handel to code_mirror for future auto recall
255 this.code_mirror = editor;
251 this.code_mirror = editor;
256
252
257 // now we treat the different number of keypress
253 // now we treat the different number of keypress
258 // first if same cell, same text, increment counter by 1
254 // first if same cell, same text, increment counter by 1
259 if (this._old_cell == cell && this._old_request == text && this._hidden === false) {
255 if (this._old_cell == cell && this._old_request == text && this._hidden === false) {
260 this._consecutive_counter++;
256 this._consecutive_counter++;
261 } else {
257 } else {
262 // else reset
258 // else reset
263 this.cancel_stick();
259 this.cancel_stick();
264 this.reset_tabs_function (cell, text);
260 this.reset_tabs_function (cell, text);
265 }
261 }
266
262
267 // don't do anything if line beggin with '(' or is empty
263 // don't do anything if line beggin with '(' or is empty
268 if (text === "" || text === "(") {
264 if (text === "" || text === "(") {
269 return;
265 return;
270 }
266 }
271
267
272 this.tabs_functions[this._consecutive_counter](cell, text);
268 this.tabs_functions[this._consecutive_counter](cell, text);
273
269
274 // then if we are at the end of list function, reset
270 // then if we are at the end of list function, reset
275 if (this._consecutive_counter == this.tabs_functions.length) {
271 if (this._consecutive_counter == this.tabs_functions.length) {
276 this.reset_tabs_function (cell, text);
272 this.reset_tabs_function (cell, text);
277 }
273 }
278
274
279 return;
275 return;
280 };
276 };
281
277
282 // cancel the option of having the tooltip to stick
278 // cancel the option of having the tooltip to stick
283 Tooltip.prototype.cancel_stick = function () {
279 Tooltip.prototype.cancel_stick = function () {
284 clearTimeout(this._stick_timeout);
280 clearTimeout(this._stick_timeout);
285 this._stick_timeout = null;
281 this._stick_timeout = null;
286 this._clocklink.hide('slow');
282 this._clocklink.hide('slow');
287 this._sticky = false;
283 this._sticky = false;
288 };
284 };
289
285
290 // put the tooltip in a sicky state for 10 seconds
286 // put the tooltip in a sicky state for 10 seconds
291 // it won't be removed by remove_and_cancell() unless you called with
287 // it won't be removed by remove_and_cancell() unless you called with
292 // the first parameter set to true.
288 // the first parameter set to true.
293 // remove_and_cancell_tooltip(true)
289 // remove_and_cancell_tooltip(true)
294 Tooltip.prototype.stick = function (time) {
290 Tooltip.prototype.stick = function (time) {
295 time = (time !== undefined) ? time : 10;
291 time = (time !== undefined) ? time : 10;
296 var that = this;
292 var that = this;
297 this._sticky = true;
293 this._sticky = true;
298 this._clocklink.show('slow');
294 this._clocklink.show('slow');
299 this._stick_timeout = setTimeout(function () {
295 this._stick_timeout = setTimeout(function () {
300 that._sticky = false;
296 that._sticky = false;
301 that._clocklink.hide('slow');
297 that._clocklink.hide('slow');
302 }, time * 1000);
298 }, time * 1000);
303 };
299 };
304
300
305 // should be called with the kernel reply to actually show the tooltip
301 // should be called with the kernel reply to actually show the tooltip
306 Tooltip.prototype._show = function (reply) {
302 Tooltip.prototype._show = function (reply) {
307 // move the bubble if it is not hidden
303 // move the bubble if it is not hidden
308 // otherwise fade it
304 // otherwise fade it
309 var content = reply.content;
305 var content = reply.content;
310 if (!content.found) {
306 if (!content.found) {
311 // object not found, nothing to show
307 // object not found, nothing to show
312 return;
308 return;
313 }
309 }
314 this.name = content.name;
310 this.name = content.name;
315
311
316 // do some math to have the tooltip arrow on more or less on left or right
312 // do some math to have the tooltip arrow on more or less on left or right
317 // width of the editor
313 // width of the editor
318 var w = $(this.code_mirror.getScrollerElement()).width();
314 var w = $(this.code_mirror.getScrollerElement()).width();
319 // ofset of the editor
315 // ofset of the editor
320 var o = $(this.code_mirror.getScrollerElement()).offset();
316 var o = $(this.code_mirror.getScrollerElement()).offset();
321
317
322 // whatever anchor/head order but arrow at mid x selection
318 // whatever anchor/head order but arrow at mid x selection
323 var anchor = this.code_mirror.cursorCoords(false);
319 var anchor = this.code_mirror.cursorCoords(false);
324 var head = this.code_mirror.cursorCoords(true);
320 var head = this.code_mirror.cursorCoords(true);
325 var xinit = (head.left+anchor.left)/2;
321 var xinit = (head.left+anchor.left)/2;
326 var xinter = o.left + (xinit - o.left) / w * (w - 450);
322 var xinter = o.left + (xinit - o.left) / w * (w - 450);
327 var posarrowleft = xinit - xinter;
323 var posarrowleft = xinit - xinter;
328
324
329 if (this._hidden === false) {
325 if (this._hidden === false) {
330 this.tooltip.animate({
326 this.tooltip.animate({
331 'left': xinter - 30 + 'px',
327 'left': xinter - 30 + 'px',
332 'top': (head.bottom + 10) + 'px'
328 'top': (head.bottom + 10) + 'px'
333 });
329 });
334 } else {
330 } else {
335 this.tooltip.css({
331 this.tooltip.css({
336 'left': xinter - 30 + 'px'
332 'left': xinter - 30 + 'px'
337 });
333 });
338 this.tooltip.css({
334 this.tooltip.css({
339 'top': (head.bottom + 10) + 'px'
335 'top': (head.bottom + 10) + 'px'
340 });
336 });
341 }
337 }
342 this.arrow.animate({
338 this.arrow.animate({
343 'left': posarrowleft + 'px'
339 'left': posarrowleft + 'px'
344 });
340 });
345
341
346 // build docstring
342 // build docstring
347 var defstring = content.call_def;
343 var defstring = content.call_def;
348 if (!defstring) {
344 if (!defstring) {
349 defstring = content.init_definition;
345 defstring = content.init_definition;
350 }
346 }
351 if (!defstring) {
347 if (!defstring) {
352 defstring = content.definition;
348 defstring = content.definition;
353 }
349 }
354
350
355 var docstring = content.call_docstring;
351 var docstring = content.call_docstring;
356 if (!docstring) {
352 if (!docstring) {
357 docstring = content.init_docstring;
353 docstring = content.init_docstring;
358 }
354 }
359 if (!docstring) {
355 if (!docstring) {
360 docstring = content.docstring;
356 docstring = content.docstring;
361 }
357 }
362
358
363 if (!docstring) {
359 if (!docstring) {
364 // For reals this time, no docstring
360 // For reals this time, no docstring
365 if (this._hide_if_no_docstring) {
361 if (this._hide_if_no_docstring) {
366 return;
362 return;
367 } else {
363 } else {
368 docstring = "<empty docstring>";
364 docstring = "<empty docstring>";
369 }
365 }
370 }
366 }
371
367
372 this._hidden = false;
368 this._hidden = false;
373 this.tooltip.fadeIn('fast');
369 this.tooltip.fadeIn('fast');
374 this.text.children().remove();
370 this.text.children().remove();
375
371
376 // Any HTML within the docstring is escaped by the fixConsole() method.
372 // Any HTML within the docstring is escaped by the fixConsole() method.
377 var pre = $('<pre/>').html(utils.fixConsole(docstring));
373 var pre = $('<pre/>').html(utils.fixConsole(docstring));
378 if (defstring) {
374 if (defstring) {
379 var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
375 var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
380 this.text.append(defstring_html);
376 this.text.append(defstring_html);
381 }
377 }
382 this.text.append(pre);
378 this.text.append(pre);
383 // keep scroll top to be sure to always see the first line
379 // keep scroll top to be sure to always see the first line
384 this.text.scrollTop(0);
380 this.text.scrollTop(0);
385 };
381 };
386
382
387 IPython.Tooltip = Tooltip;
383 IPython.Tooltip = Tooltip;
388
384
389 return IPython;
385 return IPython;
390
386
391 }(IPython));
387 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now