##// END OF EJS Templates
call tooltip by cell reference
Matthias BUSSONNIER -
Show More
@@ -50,9 +50,21
50 .bigtooltip {
50 .bigtooltip {
51 overflow: auto;
51 overflow: auto;
52 height: 200px;
52 height: 200px;
53 -webkit-transition-property: height;
54 -webkit-transition-duration: 1s;
55 -moz-transition-property: height;
56 -moz-transition-duration: 1s;
57 transition-property: height;
58 transition-duration: 1s;
53 }
59 }
54 /*properties of tooltip before "expand"*/
60 /*properties of tooltip before "expand"*/
55 .smalltooltip {
61 .smalltooltip {
62 -webkit-transition-property: height;
63 -webkit-transition-duration: 1s;
64 -moz-transition-property: height;
65 -moz-transition-duration: 1s;
66 transition-property: height;
67 transition-duration: 1s;
56 text-overflow: ellipsis;
68 text-overflow: ellipsis;
57 overflow: hidden;
69 overflow: hidden;
58 height: 80px;
70 height: 80px;
@@ -64,18 +76,6
64 right: 0px;
76 right: 0px;
65 }
77 }
66 .tooltip {
78 .tooltip {
67 -webkit-transition: all 0.8s ease;
68 -moz-transition: all 0.8s ease;
69 -ms-transition: all 0.8s ease;
70 -o-transition: all 0.8s ease;
71 /*transition when "expand"ing tooltip */
72
73 -webkit-transition-property: height;
74 -webkit-transition-duration: 1s;
75 -moz-transition-property: height;
76 -moz-transition-duration: 1s;
77 transition-property: height;
78 transition-duration: 1s;
79 max-width: 700px;
79 max-width: 700px;
80 border-radius: 10px 10px 10px 10px;
80 border-radius: 10px 10px 10px 10px;
81 box-shadow: 3px 3px 5px #999;
81 box-shadow: 3px 3px 5px #999;
@@ -42,6 +42,7 var IPython = (function (IPython) {
42 readOnly: this.read_only,
42 readOnly: this.read_only,
43 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
43 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
44 });
44 });
45 cm = this.code_mirror
45 input.append(input_area);
46 input.append(input_area);
46 var output = $('<div></div>').addClass('output vbox');
47 var output = $('<div></div>').addClass('output vbox');
47 cell.append(input).append(output);
48 cell.append(input).append(output);
@@ -60,7 +61,7 var IPython = (function (IPython) {
60 } else {
61 } else {
61 // Will set a timer to request tooltip in `time`
62 // Will set a timer to request tooltip in `time`
62 that.tooltip_timeout = setTimeout(function(){
63 that.tooltip_timeout = setTimeout(function(){
63 IPython.notebook.request_tool_tip(that, pre_cursor)
64 IPython.tooltip.request(that, pre_cursor)
64 },time);
65 },time);
65 }
66 }
66 };
67 };
@@ -76,7 +77,7 var IPython = (function (IPython) {
76 }
77 }
77
78
78 // note that we are comparing and setting the time to wait at each key press.
79 // note that we are comparing and setting the time to wait at each key press.
79 // a better wqy might be to generate a new function on each time change and
80 // a better way might be to generate a new function on each time change and
80 // assign it to CodeCell.prototype.request_tooltip_after_time
81 // assign it to CodeCell.prototype.request_tooltip_after_time
81 var tooltip_wait_time = this.notebook.time_before_tooltip;
82 var tooltip_wait_time = this.notebook.time_before_tooltip;
82 var tooltip_on_tab = this.notebook.tooltip_on_tab;
83 var tooltip_on_tab = this.notebook.tooltip_on_tab;
@@ -159,89 +160,8 var IPython = (function (IPython) {
159 return false;
160 return false;
160 };
161 };
161
162
162
163 CodeCell.prototype.finish_tooltip = function (reply) {
163 CodeCell.prototype.finish_tooltip = function (reply) {
164 IPython.tooltip.show(reply,this.code_mirror.cursorCoords());
164 IPython.tooltip.show(reply, this);
165 return;
166 // Extract call tip data; the priority is call, init, main.
167 defstring = reply.call_def;
168 if (defstring == null) { defstring = reply.init_definition; }
169 if (defstring == null) { defstring = reply.definition; }
170
171 docstring = reply.call_docstring;
172 if (docstring == null) { docstring = reply.init_docstring; }
173 if (docstring == null) { docstring = reply.docstring; }
174 if (docstring == null) { docstring = "<empty docstring>"; }
175
176 name=reply.name;
177
178 var that = this;
179 var tooltip = $('<div/>').attr('id', 'tooltip').addClass('tooltip');
180 // remove to have the tooltip not Limited in X and Y
181 tooltip.addClass('smalltooltip');
182 var pre=$('<pre/>').html(utils.fixConsole(docstring));
183 var expandlink=$('<a/>').attr('href',"#");
184 expandlink.addClass("ui-corner-all"); //rounded corner
185 expandlink.attr('role',"button");
186 //expandlink.addClass('ui-button');
187 //expandlink.addClass('ui-state-default');
188 var expandspan=$('<span/>').text('Expand');
189 expandspan.addClass('ui-icon');
190 expandspan.addClass('ui-icon-plus');
191 expandlink.append(expandspan);
192 expandlink.attr('id','expanbutton');
193 expandlink.click(function(){
194 tooltip.removeClass('smalltooltip');
195 tooltip.addClass('bigtooltip');
196 $('#expanbutton').remove();
197 setTimeout(function(){that.code_mirror.focus();}, 50);
198 });
199 var morelink=$('<a/>').attr('href',"#");
200 morelink.attr('role',"button");
201 morelink.addClass('ui-button');
202 //morelink.addClass("ui-corner-all"); //rounded corner
203 //morelink.addClass('ui-state-default');
204 var morespan=$('<span/>').text('Open in Pager');
205 morespan.addClass('ui-icon');
206 morespan.addClass('ui-icon-arrowstop-l-n');
207 morelink.append(morespan);
208 morelink.click(function(){
209 var msg_id = IPython.notebook.kernel.execute(name+"?");
210 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
211 IPython.tooltip.remove_and_cancel_tooltip();
212 setTimeout(function(){that.code_mirror.focus();}, 50);
213 });
214
215 var closelink=$('<a/>').attr('href',"#");
216 closelink.attr('role',"button");
217 closelink.addClass('ui-button');
218 //closelink.addClass("ui-corner-all"); //rounded corner
219 //closelink.adClass('ui-state-default'); // grey background and blue cross
220 var closespan=$('<span/>').text('Close');
221 closespan.addClass('ui-icon');
222 closespan.addClass('ui-icon-close');
223 closelink.append(closespan);
224 closelink.click(function(){
225 IPython.tooltip.remove_and_cancel_tooltip();
226 setTimeout(function(){that.code_mirror.focus();}, 50);
227 });
228 //construct the tooltip
229 tooltip.append(closelink);
230 tooltip.append(expandlink);
231 tooltip.append(morelink);
232 if(defstring){
233 defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
234 tooltip.append(defstring_html);
235 }
236 tooltip.append(pre);
237 var pos = this.code_mirror.cursorCoords();
238 tooltip.css('left',pos.x+'px');
239 tooltip.css('top',pos.yBot+'px');
240 $('body').append(tooltip);
241
242 // issues with cross-closing if multiple tooltip in less than 5sec
243 // keep it comented for now
244 // setTimeout(that.remove_and_cancel_tooltip, 5000);
245 };
165 };
246
166
247
167
@@ -46,7 +46,7 var IPython = (function (IPython) {
46 text.removeClass('smalltooltip');
46 text.removeClass('smalltooltip');
47 text.addClass('bigtooltip');
47 text.addClass('bigtooltip');
48 $('#expanbutton').addClass('hidden');
48 $('#expanbutton').addClass('hidden');
49 //setTimeout(function(){that.code_mirror.focus();}, 50);
49 that._cmfocus();
50 })
50 })
51 .append(
51 .append(
52 $('<span/>').text('Expand')
52 $('<span/>').text('Expand')
@@ -63,10 +63,10 var IPython = (function (IPython) {
63 .addClass('ui-icon-arrowstop-l-n');
63 .addClass('ui-icon-arrowstop-l-n');
64 morelink.append(morespan);
64 morelink.append(morespan);
65 morelink.click(function(){
65 morelink.click(function(){
66 var msg_id = IPython.notebook.kernel.execute(name+"?");
66 var msg_id = IPython.notebook.kernel.execute(that.name+"?");
67 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
67 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
68 that.remove_and_cancel_tooltip();
68 that.remove_and_cancel_tooltip();
69 setTimeout(function(){that.code_mirror.focus();}, 50);
69 that._cmfocus();
70 });
70 });
71
71
72 // close the tooltip
72 // close the tooltip
@@ -125,10 +125,19 var IPython = (function (IPython) {
125 }
125 }
126 }
126 }
127
127
128 Tooltip.prototype.show = function(reply,pos)
128 Tooltip.prototype.request = function(cell,text)
129 {
130 IPython.notebook.request_tool_tip(cell, text);
131 }
132
133 Tooltip.prototype.show = function(reply, codecell)
129 {
134 {
130 // move the bubble if it is not hidden
135 // move the bubble if it is not hidden
131 // otherwise fade it
136 // otherwise fade it
137 var editor = codecell.code_mirror;
138 this.name = reply.name;
139 this.code_mirror = editor;
140 var pos = editor.cursorCoords();
132 var xinit = pos.x;
141 var xinit = pos.x;
133 var xinter = xinit/1000*600;
142 var xinter = xinit/1000*600;
134 var posarrowleft = xinit - xinter;
143 var posarrowleft = xinit - xinter;
@@ -178,6 +187,12 var IPython = (function (IPython) {
178 setTimeout(function(){that.code_mirror.focus();}, 50);
187 setTimeout(function(){that.code_mirror.focus();}, 50);
179 }
188 }
180
189
190 Tooltip.prototype._cmfocus = function()
191 {
192 var cm = this.code_mirror;
193 setTimeout(function(){cm.focus();}, 50);
194 }
195
181
196
182 IPython.Tooltip = Tooltip;
197 IPython.Tooltip = Tooltip;
183
198
@@ -26,6 +26,16
26 @borderwidth : 1px;
26 @borderwidth : 1px;
27 @textColor : #000;
27 @textColor : #000;
28
28
29 // smoth height adaptation
30 .smoothheight(@t:1s) {
31 -webkit-transition-property: height;
32 -webkit-transition-duration: 1s;
33 -moz-transition-property: height;
34 -moz-transition-duration: 1s;
35 transition-property: height;
36 transition-duration: 1s;
37 }
38
29 @-moz-keyframes fadeOut {
39 @-moz-keyframes fadeOut {
30 from {opacity:1;}
40 from {opacity:1;}
31 to {opacity:0;}
41 to {opacity:0;}
@@ -83,10 +93,12
83 .bigtooltip {
93 .bigtooltip {
84 overflow: auto;
94 overflow: auto;
85 height: 200px;
95 height: 200px;
96 .smoothheight();
86 }
97 }
87
98
88 /*properties of tooltip before "expand"*/
99 /*properties of tooltip before "expand"*/
89 .smalltooltip{
100 .smalltooltip{
101 .smoothheight();
90 text-overflow: ellipsis;
102 text-overflow: ellipsis;
91 overflow: hidden;
103 overflow: hidden;
92 height:80px;
104 height:80px;
@@ -103,17 +115,6
103 }
115 }
104
116
105 .tooltip {
117 .tooltip {
106 -webkit-transition: all 0.8s ease;
107 -moz-transition: all 0.8s ease;
108 -ms-transition: all 0.8s ease;
109 -o-transition: all 0.8s ease;
110 /*transition when "expand"ing tooltip */
111 -webkit-transition-property: height;
112 -webkit-transition-duration: 1s;
113 -moz-transition-property: height;
114 -moz-transition-duration: 1s;
115 transition-property: height;
116 transition-duration: 1s;
117 max-width:700px;
118 max-width:700px;
118 border-radius: 10px 10px 10px 10px;
119 border-radius: 10px 10px 10px 10px;
119 box-shadow: 3px 3px 5px #999;
120 box-shadow: 3px 3px 5px #999;
@@ -174,5 +175,4
174 -moz-animation: fadeOut 800ms;
175 -moz-animation: fadeOut 800ms;
175 animation: fadeOut 800ms;
176 animation: fadeOut 800ms;
176 opacity : 0;
177 opacity : 0;
177
178 }
178 }
General Comments 0
You need to be logged in to leave comments. Login now