##// END OF EJS Templates
fix scrolltop
Matthias Bussonnier -
Show More
@@ -84,7 +84,7 b' var IPython = (function (IPython) {'
84 // whatever key is pressed, first, cancel the tooltip request before
84 // whatever key is pressed, first, cancel the tooltip request before
85 // they are sent, and remove tooltip if any
85 // they are sent, and remove tooltip if any
86 if(event.type === 'keydown' ) {
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 b' var IPython = (function (IPython) {'
159 return false;
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 CodeCell.prototype.finish_tooltip = function (reply) {
163 CodeCell.prototype.finish_tooltip = function (reply) {
174 IPython.tooltip.show(reply,this.code_mirror.cursorCoords());
164 IPython.tooltip.show(reply,this.code_mirror.cursorCoords());
@@ -218,7 +208,7 b' var IPython = (function (IPython) {'
218 morelink.click(function(){
208 morelink.click(function(){
219 var msg_id = IPython.notebook.kernel.execute(name+"?");
209 var msg_id = IPython.notebook.kernel.execute(name+"?");
220 IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.get_selected_cell().cell_id;
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 setTimeout(function(){that.code_mirror.focus();}, 50);
212 setTimeout(function(){that.code_mirror.focus();}, 50);
223 });
213 });
224
214
@@ -232,7 +222,7 b' var IPython = (function (IPython) {'
232 closespan.addClass('ui-icon-close');
222 closespan.addClass('ui-icon-close');
233 closelink.append(closespan);
223 closelink.append(closespan);
234 closelink.click(function(){
224 closelink.click(function(){
235 that.remove_and_cancel_tooltip();
225 IPython.tooltip.remove_and_cancel_tooltip();
236 setTimeout(function(){that.code_mirror.focus();}, 50);
226 setTimeout(function(){that.code_mirror.focus();}, 50);
237 });
227 });
238 //construct the tooltip
228 //construct the tooltip
@@ -12,12 +12,15 b''
12 // Todo :
12 // Todo :
13 // use codemirror highlight example to
13 // use codemirror highlight example to
14 // highlight the introspection request and introspect on mouse hove ...
14 // highlight the introspection request and introspect on mouse hove ...
15 //
16 //
15 var IPython = (function (IPython) {
17 var IPython = (function (IPython) {
16
18
17 var utils = IPython.utils;
19 var utils = IPython.utils;
18
20
19 var Tooltip = function (notebook) {
21 var Tooltip = function (notebook) {
20 this.tooltip = $('#tooltip');
22 this.tooltip = $('#tooltip');
23 var that = this;
21
24
22 // contain the button in the upper right corner
25 // contain the button in the upper right corner
23 this.buttons = $('<div/>')
26 this.buttons = $('<div/>')
@@ -41,7 +44,7 b' var IPython = (function (IPython) {'
41 .click(function(){
44 .click(function(){
42 text.removeClass('smalltooltip');
45 text.removeClass('smalltooltip');
43 text.addClass('bigtooltip');
46 text.addClass('bigtooltip');
44 $('#expanbutton').remove();
47 $('#expanbutton').addClass('hidden');
45 //setTimeout(function(){that.code_mirror.focus();}, 50);
48 //setTimeout(function(){that.code_mirror.focus();}, 50);
46 })
49 })
47 .append(
50 .append(
@@ -74,7 +77,7 b' var IPython = (function (IPython) {'
74 closespan.addClass('ui-icon-close');
77 closespan.addClass('ui-icon-close');
75 closelink.append(closespan);
78 closelink.append(closespan);
76 closelink.click(function(){
79 closelink.click(function(){
77 tooltip.addClass('hide');
80 that.hide();
78 });
81 });
79
82
80 //construct the tooltip
83 //construct the tooltip
@@ -92,7 +95,17 b' var IPython = (function (IPython) {'
92 this.tooltip.append(this.text);
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 //TODO, try to diminish the number of parameters.
110 //TODO, try to diminish the number of parameters.
98 Tooltip.prototype.request_tooltip_after_time = function (pre_cursor,time){
111 Tooltip.prototype.request_tooltip_after_time = function (pre_cursor,time){
@@ -103,12 +116,13 b' var IPython = (function (IPython) {'
103 // note that we don't handle closing directly inside the calltip
116 // note that we don't handle closing directly inside the calltip
104 // as in the completer, because it is not focusable, so won't
117 // as in the completer, because it is not focusable, so won't
105 // get the event.
118 // get the event.
119 this.hide();
106 if (this.tooltip_timeout != null){
120 if (this.tooltip_timeout != null){
107 clearTimeout(this.tooltip_timeout);
121 clearTimeout(this.tooltip_timeout);
108 $('#tooltip').remove();
109 this.tooltip_timeout = null;
122 this.tooltip_timeout = null;
110 }
123 }
111 }
124 }
125
112 Tooltip.prototype.show = function(reply,pos)
126 Tooltip.prototype.show = function(reply,pos)
113 {
127 {
114 this.tooltip.css('left',pos.x-30+'px');
128 this.tooltip.css('left',pos.x-30+'px');
@@ -133,7 +147,9 b' var IPython = (function (IPython) {'
133 var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
147 var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
134 this.text.append(defstring_html);
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 b' var IPython = (function (IPython) {'
145 setTimeout(function(){that.code_mirror.focus();}, 50);
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 IPython.Tooltip = Tooltip;
165 IPython.Tooltip = Tooltip;
204
166
General Comments 0
You need to be logged in to leave comments. Login now