add 'more...' and 'close' button to the pager

'more...' button execute 'foo?' **On the behalf of the current cell**
	which increase it's prompt number to the curent value, and give focus back
Matthias BUSSONNIER 14 years ago
parent 01a0c126d4
commit aa24495b5b

@ -153,7 +153,10 @@ var IPython = (function (IPython) {
$('#tooltip').remove();
}
CodeCell.prototype.finish_tooltip = function (defstring,docstring) {
CodeCell.prototype.finish_tooltip = function (reply) {
defstring=reply.definition;
docstring=reply.docstring;
name=reply.name;
shortened = function(string){
if(string.length > 200){
return string.trim().substring(0,197)+'...';
@ -166,7 +169,25 @@ var IPython = (function (IPython) {
defstring_html= $('<pre/>').html(utils.fixConsole(defstring));
tooltip.append(defstring_html);
}
tooltip.append($('<pre/>').html(utils.fixConsole(shortened(docstring))));
var pre=$('<pre/>').html(utils.fixConsole(shortened(docstring)));
var more=$('<button/>').text('more...')
more.addClass('ui-button ui-state-default ui-corner-all');
more.click(function(){
var msg_id = IPython.notebook.kernel.execute(name+"?");
IPython.notebook.msg_cell_map[msg_id] = IPython.notebook.selected_cell().cell_id;
CodeCell.prototype.remove_and_cancell_tooltip(that.tooltip_timeout);
setTimeout(function(){that.code_mirror.focus();}, 50);
});
var close=$('<button/>').text('close')
close.addClass('ui-button ui-state-default ui-corner-all');
close.click(function(){
CodeCell.prototype.remove_and_cancell_tooltip(that.tooltip_timeout);
setTimeout(function(){that.code_mirror.focus();}, 50);
});
pre.append(more);
pre.append(close);
tooltip.append(pre);
var pos = this.code_mirror.cursorCoords();
tooltip.css('left',pos.x+'px');
tooltip.css('top',pos.yBot+'px');

@ -723,7 +723,7 @@ var IPython = (function (IPython) {
rep = reply.content;
if(rep.found)
{
cell.finish_tooltip(rep.definition,rep.docstring);
cell.finish_tooltip(rep);
}
} else {
//console.log("unknown reply:"+msg_type);

Loading…
Cancel
Save