##// END OF EJS Templates
fix scrolltop
Matthias Bussonnier -
Show More
@@ -84,7 +84,7 var IPython = (function (IPython) {
84 84 // whatever key is pressed, first, cancel the tooltip request before
85 85 // they are sent, and remove tooltip if any
86 86 if(event.type === 'keydown' ) {
87 that.remove_and_cancel_tooltip();
87 IPython.tooltip.remove_and_cancel_tooltip();
88 88 };
89 89
90 90
@@ -159,16 +159,6 var IPython = (function (IPython) {
159 159 return false;
160 160 };
161 161
162 CodeCell.prototype.remove_and_cancel_tooltip = function() {
163 // note that we don't handle closing directly inside the calltip
164 // as in the completer, because it is not focusable, so won't
165 // get the event.
166 if (this.tooltip_timeout != null){
167 clearTimeout(this.tooltip_timeout);
168 $('#tooltip').addClass('hidden');
169 this.tooltip_timeout = null;
170 }
171 }
172 162
173 163 CodeCell.prototype.finish_tooltip = function (reply) {
174 164 IPython.tooltip.show(reply,this.code_mirror.cursorCoords());
@@ -218,7 +208,7 var IPython = (function (IPython) {
218 208 morelink.click(function(){
219 209 var msg_id = IPython.notebook.kernel.execute(name+"?");
220 210 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
221 that.remove_and_cancel_tooltip();
211 IPython.tooltip.remove_and_cancel_tooltip();
222 212 setTimeout(function(){that.code_mirror.focus();}, 50);
223 213 });
224 214
@@ -232,7 +222,7 var IPython = (function (IPython) {
232 222 closespan.addClass('ui-icon-close');
233 223 closelink.append(closespan);
234 224 closelink.click(function(){
235 that.remove_and_cancel_tooltip();
225 IPython.tooltip.remove_and_cancel_tooltip();
236 226 setTimeout(function(){that.code_mirror.focus();}, 50);
237 227 });
238 228 //construct the tooltip
@@ -12,12 +12,15
12 12 // Todo :
13 13 // use codemirror highlight example to
14 14 // highlight the introspection request and introspect on mouse hove ...
15 //
16 //
15 17 var IPython = (function (IPython) {
16 18
17 19 var utils = IPython.utils;
18 20
19 21 var Tooltip = function (notebook) {
20 22 this.tooltip = $('#tooltip');
23 var that = this;
21 24
22 25 // contain the button in the upper right corner
23 26 this.buttons = $('<div/>')
@@ -41,7 +44,7 var IPython = (function (IPython) {
41 44 .click(function(){
42 45 text.removeClass('smalltooltip');
43 46 text.addClass('bigtooltip');
44 $('#expanbutton').remove();
47 $('#expanbutton').addClass('hidden');
45 48 //setTimeout(function(){that.code_mirror.focus();}, 50);
46 49 })
47 50 .append(
@@ -74,7 +77,7 var IPython = (function (IPython) {
74 77 closespan.addClass('ui-icon-close');
75 78 closelink.append(closespan);
76 79 closelink.click(function(){
77 tooltip.addClass('hide');
80 that.hide();
78 81 });
79 82
80 83 //construct the tooltip
@@ -92,7 +95,17 var IPython = (function (IPython) {
92 95 this.tooltip.append(this.text);
93 96 };
94 97
95
98 // deal with all the logic of hiding the tooltip
99 // and reset it's status
100 Tooltip.prototype.hide = function()
101 {
102 this.tooltip.addClass('hide');
103 $('#expanbutton').removeClass('hidden');
104 this.text.removeClass('bigtooltip');
105 this.text.addClass('smalltooltip');
106 // keep scroll top to be sure to always see the first line
107 this.text.scrollTop(0);
108 }
96 109
97 110 //TODO, try to diminish the number of parameters.
98 111 Tooltip.prototype.request_tooltip_after_time = function (pre_cursor,time){
@@ -103,12 +116,13 var IPython = (function (IPython) {
103 116 // note that we don't handle closing directly inside the calltip
104 117 // as in the completer, because it is not focusable, so won't
105 118 // get the event.
119 this.hide();
106 120 if (this.tooltip_timeout != null){
107 121 clearTimeout(this.tooltip_timeout);
108 $('#tooltip').remove();
109 122 this.tooltip_timeout = null;
110 123 }
111 124 }
125
112 126 Tooltip.prototype.show = function(reply,pos)
113 127 {
114 128 this.tooltip.css('left',pos.x-30+'px');
@@ -133,7 +147,9 var IPython = (function (IPython) {
133 147 var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
134 148 this.text.append(defstring_html);
135 149 }
136 this.text.append(pre)
150 this.text.append(pre);
151 // keep scroll top to be sure to always see the first line
152 this.text.scrollTop(0);
137 153
138 154
139 155 }
@@ -145,60 +161,6 var IPython = (function (IPython) {
145 161 setTimeout(function(){that.code_mirror.focus();}, 50);
146 162 }
147 163
148 Tooltip.prototype.finish_tooltip = function (reply) {
149
150 var expandlink=$('<a/>').attr('href',"#");
151 expandlink.addClass("ui-corner-all"); //rounded corner
152 expandlink.attr('role',"button");
153
154 var expandspan=$('<span/>').text('Expand');
155 expandspan.addClass('ui-icon');
156 expandspan.addClass('ui-icon-plus');
157
158 expandlink.append(expandspan);
159 expandlink.attr('id','expanbutton');
160 expandlink.click(function(){
161 tooltip.removeClass('smalltooltip');
162 tooltip.addClass('bigtooltip');
163 $('#expanbutton').remove();
164 setTimeout(function(){that.code_mirror.focus();}, 50);
165 });
166
167 var morelink=$('<a/>').attr('href',"#");
168 morelink.attr('role',"button");
169 morelink.addClass('ui-button');
170 var morespan=$('<span/>').text('Open in Pager');
171 morespan.addClass('ui-icon');
172 morespan.addClass('ui-icon-arrowstop-l-n');
173 morelink.append(morespan);
174 morelink.click(function(){
175 this.showInPager();
176 });
177
178
179 var closelink=$('<a/>').attr('href',"#");
180 closelink.attr('role',"button");
181 closelink.addClass('ui-button');
182
183 var closespan=$('<span/>').text('Close');
184 closespan.addClass('ui-icon');
185 closespan.addClass('ui-icon-close');
186 closelink.append(closespan);
187 closelink.click(function(){
188 that.remove_and_cancel_tooltip();
189 setTimeout(function(){that.code_mirror.focus();}, 50);
190 });
191 //construct the tooltip
192 tooltip.append(closelink);
193 tooltip.append(expandlink);
194 tooltip.append(morelink);
195
196 var pos = this.code_mirror.cursorCoords();
197 tooltip.css('left',pos.x+'px');
198 tooltip.css('top',pos.yBot+'px');
199
200 };
201
202 164
203 165 IPython.Tooltip = Tooltip;
204 166
General Comments 0
You need to be logged in to leave comments. Login now