##// END OF EJS Templates
tooltip to mac
Matthias Bussonnier -
Show More
@@ -0,0 +1,108
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
7
8 //============================================================================
9 // Tooltip
10 //============================================================================
11
12 var IPython = (function (IPython) {
13
14 var utils = IPython.utils;
15
16 var Tooltip = function (notebook) {
17 this.tooltip = $('#tooltip');
18 this.text = $('<pre/>')
19 };
20
21
22
23 //TODO, try to diminish the number of parameters.
24 Tooltip.prototype.request_tooltip_after_time = function (pre_cursor,time){
25 };
26
27
28 Tooltip.prototype.remove_and_cancel_tooltip = function() {
29 // note that we don't handle closing directly inside the calltip
30 // as in the completer, because it is not focusable, so won't
31 // get the event.
32 if (this.tooltip_timeout != null){
33 clearTimeout(this.tooltip_timeout);
34 $('#tooltip').remove();
35 this.tooltip_timeout = null;
36 }
37 }
38 Tooltip.prototype.show = function()
39 {
40 this.tooltip.removeClass('hidden');
41 }
42
43 Tooltip.prototype.showInPager = function(){
44 var msg_id = IPython.notebook.kernel.execute(name+"?");
45 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
46 that.remove_and_cancel_tooltip();
47 setTimeout(function(){that.code_mirror.focus();}, 50);
48 }
49
50 Tooltip.prototype.finish_tooltip = function (reply) {
51
52 var expandlink=$('<a/>').attr('href',"#");
53 expandlink.addClass("ui-corner-all"); //rounded corner
54 expandlink.attr('role',"button");
55
56 var expandspan=$('<span/>').text('Expand');
57 expandspan.addClass('ui-icon');
58 expandspan.addClass('ui-icon-plus');
59
60 expandlink.append(expandspan);
61 expandlink.attr('id','expanbutton');
62 expandlink.click(function(){
63 tooltip.removeClass('smalltooltip');
64 tooltip.addClass('bigtooltip');
65 $('#expanbutton').remove();
66 setTimeout(function(){that.code_mirror.focus();}, 50);
67 });
68
69 var morelink=$('<a/>').attr('href',"#");
70 morelink.attr('role',"button");
71 morelink.addClass('ui-button');
72 var morespan=$('<span/>').text('Open in Pager');
73 morespan.addClass('ui-icon');
74 morespan.addClass('ui-icon-arrowstop-l-n');
75 morelink.append(morespan);
76 morelink.click(function(){
77 this.showInPager();
78 });
79
80
81 var closelink=$('<a/>').attr('href',"#");
82 closelink.attr('role',"button");
83 closelink.addClass('ui-button');
84
85 var closespan=$('<span/>').text('Close');
86 closespan.addClass('ui-icon');
87 closespan.addClass('ui-icon-close');
88 closelink.append(closespan);
89 closelink.click(function(){
90 that.remove_and_cancel_tooltip();
91 setTimeout(function(){that.code_mirror.focus();}, 50);
92 });
93 //construct the tooltip
94 tooltip.append(closelink);
95 tooltip.append(expandlink);
96 tooltip.append(morelink);
97
98 var pos = this.code_mirror.cursorCoords();
99 tooltip.css('left',pos.x+'px');
100 tooltip.css('top',pos.yBot+'px');
101
102 };
103
104
105 IPython.Tooltip = Tooltip;
106
107 return IPython;
108 }(IPython));
General Comments 0
You need to be logged in to leave comments. Login now