diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index 9585d45..0a34701 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -115,6 +115,10 @@ span.section_row_buttons a { float: right; } +#tooltipontab_span { + float: right; +} + .checkbox_label { font-size: 85%; float: right; diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index 2d86c62..b186bd8 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -85,7 +85,6 @@ var IPython = (function (IPython) { } }; - // Subclasses must implement create_element. Cell.prototype.create_element = function () {}; diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 6170df5..1d4f177 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -65,7 +65,8 @@ var IPython = (function (IPython) { // value is used to determine if CodeMirror should ignore the event: // true = ignore, false = don't ignore. tooltip_wait_time = 2000; - tooltip_on_tab = true; + + tooltip_on_tab = this.notebook.tooltip_on_tab; var that = this; // whatever key is pressed, first, cancel the tooltip request before @@ -79,9 +80,9 @@ var IPython = (function (IPython) { // Always ignore shift-enter in CodeMirror as we handle it. return true; }else if (event.keyCode === 53 && event.type === 'keydown' && tooltip_wait_time >= 0) { - // Pressing '(' , request tooltip + // Pressing '(' , request tooltip, don't forget to reappend it var cursor = editor.getCursor(); - var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim(); + var pre_cursor = editor.getRange({line:cursor.line,ch:0},cursor).trim()+'('; CodeCell.prototype.request_tooltip_after_time(pre_cursor,tooltip_wait_time,that); } else if (event.keyCode === 9 && event.type == 'keydown') { // Tab completion. @@ -92,7 +93,7 @@ var IPython = (function (IPython) { // Don't autocomplete if the part of the line before the cursor // is empty. In this case, let CodeMirror handle indentation. return false; - } else if (pre_cursor.substr(-1) === "(" && tooltip_on_tab ) { + } else if ((pre_cursor.substr(-1) === "("|| pre_cursor.substr(-1) === " ") && tooltip_on_tab ) { CodeCell.prototype.request_tooltip_after_time(pre_cursor,0,that); } else { pre_cursor.trim(); diff --git a/IPython/frontend/html/notebook/static/js/leftpanel.js b/IPython/frontend/html/notebook/static/js/leftpanel.js index 380510a..5eb02e1 100644 --- a/IPython/frontend/html/notebook/static/js/leftpanel.js +++ b/IPython/frontend/html/notebook/static/js/leftpanel.js @@ -67,6 +67,7 @@ var IPython = (function (IPython) { this.notebook_section = new IPython.NotebookSection('div#notebook_section'); if (! IPython.read_only){ this.cell_section = new IPython.CellSection('div#cell_section'); + this.config_section = new IPython.ConfigSection('div#config_section'); this.kernel_section = new IPython.KernelSection('div#kernel_section'); } this.help_section = new IPython.HelpSection('div#help_section'); diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index 1c5d079..b6c36e1 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -27,6 +27,7 @@ var IPython = (function (IPython) { this.style(); this.create_elements(); this.bind_events(); + this.set_tooltipontab(true); }; @@ -621,6 +622,11 @@ var IPython = (function (IPython) { }; + Notebook.prototype.set_tooltipontab = function (state) { + console.log("change tooltip on tab to : "+state); + this.tooltip_on_tab = state; + }; + Notebook.prototype.set_autoindent = function (state) { var cells = this.cells(); len = cells.length; @@ -883,10 +889,22 @@ var IPython = (function (IPython) { Notebook.prototype.request_tool_tip = function (cell,func) { - //remove ending '(' if any - //there should be a way to do it in the regexp - if(func.substr(-1) === '('){func=func.substr(0, func.length-1);} - // regexp to select last part of expression + // Feel free to shorten this logic if you are better + // than me in regEx + // basicaly you shoul be able to get xxx.xxx.xxx from + // something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2, + // remove everything between matchin bracket (need to iterate) + matchBracket = /\([^\(\)]+\)/g; + oldfunc = func; + func = func.replace(matchBracket,""); + while( oldfunc != func ) + { + oldfunc = func; + func = func.replace(matchBracket,""); + } + // remove everythin after last open bracket + endBracket = /\([^\(]*$/g; + func = func.replace(endBracket,""); var re = /[a-zA-Z._]+$/g; var msg_id = this.kernel.object_info_request(re.exec(func)); this.msg_cell_map[msg_id] = cell.cell_id; diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index 11c0db6..78e4c05 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -51,6 +51,7 @@ $(document).ready(function () { IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only $('button#new_notebook').addClass('hidden'); $('div#cell_section').addClass('hidden'); + $('div#config_section').addClass('hidden'); $('div#kernel_section').addClass('hidden'); $('span#login_widget').removeClass('hidden'); // left panel starts collapsed, but the collapse must happen after diff --git a/IPython/frontend/html/notebook/static/js/panelsection.js b/IPython/frontend/html/notebook/static/js/panelsection.js index e7cfcab..da09efd 100644 --- a/IPython/frontend/html/notebook/static/js/panelsection.js +++ b/IPython/frontend/html/notebook/static/js/panelsection.js @@ -121,13 +121,39 @@ var IPython = (function (IPython) { }); }; + // ConfigSection + + var ConfigSection = function () { + PanelSection.apply(this, arguments); + }; + + ConfigSection.prototype = new PanelSection(); + + ConfigSection.prototype.style = function () { + PanelSection.prototype.style.apply(this); + this.content.addClass('ui-helper-clearfix'); + this.content.find('div.section_row').addClass('ui-helper-clearfix'); + + this.content.find('#tooltipontab').attr('title', 'Show tooltip if yuo press after "(" or a white space'); + this.content.find('#tooltipontab_label').attr('title', 'Show Tooltip when pressing Tab'); + + }; + + + ConfigSection.prototype.bind_events = function () { + PanelSection.prototype.bind_events.apply(this); + this.content.find('#tooltipontab').change(function () { + var state = $('#tooltipontab').prop('checked'); + IPython.notebook.set_tooltipontab(state); + }); + }; + // CellSection var CellSection = function () { PanelSection.apply(this, arguments); }; - CellSection.prototype = new PanelSection(); @@ -201,6 +227,10 @@ var IPython = (function (IPython) { var state = $('#autoindent').prop('checked'); IPython.notebook.set_autoindent(state); }); + this.content.find('#tooltipontab').change(function () { + var state = $('#tooltipontab').prop('checked'); + IPython.notebook.set_tooltipontab(state); + }); }; @@ -280,6 +310,7 @@ var IPython = (function (IPython) { IPython.PanelSection = PanelSection; IPython.NotebookSection = NotebookSection; IPython.CellSection = CellSection; + IPython.ConfigSection = ConfigSection; IPython.KernelSection = KernelSection; IPython.HelpSection = HelpSection; diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index e2fdc3b..299a76f 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -251,6 +251,20 @@ +
+
+

Config

+
+
+
+ + + + Tooltip on tab: +
+
+
+