From 4f23a77838dcdf3c3f3c11437c08408c16391b16 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Sat, 9 Feb 2013 19:36:19 +0100 Subject: [PATCH 1/2] Method to show hide linenumber of cell mostly convenience methods to wrap codemirror one, plus doc and 1 doc fix (missing curly bracket) --- IPython/frontend/html/notebook/static/js/cell.js | 11 +++++++++++ IPython/frontend/html/notebook/static/js/toolbar.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index d49e456a623..aafc127b768 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -226,6 +226,17 @@ var IPython = (function (IPython) { } }; + /** + * Show/Hide CodeMirror LineNumber + * @method show_line_number + * + * @param value {Bool} show (true), or hide (false) the line number in CodeMirror + **/ + Cell.prototype.show_line_numbers = function (value) { + this.code_mirror.setOption('lineNumbers', value); + this.code_mirror.refresh(); + }; + /** * Toggle CodeMirror LineNumber * @method toggle_line_numbers diff --git a/IPython/frontend/html/notebook/static/js/toolbar.js b/IPython/frontend/html/notebook/static/js/toolbar.js index 8ebb5f98b75..428ffa019a5 100644 --- a/IPython/frontend/html/notebook/static/js/toolbar.js +++ b/IPython/frontend/html/notebook/static/js/toolbar.js @@ -40,7 +40,7 @@ var IPython = (function (IPython) { * { * label:'my button', * icon:'ui-icon-disk', - * callback:function(){alert('hoho'), + * callback:function(){alert('hoho')}, * id : 'my_button_id', // this is optional * }, * { From 70d3237ceb076ec1a2a4f6884d44d7ee915cfbeb Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Sat, 16 Feb 2013 11:59:26 +0100 Subject: [PATCH 2/2] use show method in toggle method --- IPython/frontend/html/notebook/static/js/cell.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index aafc127b768..0abc78f8e49 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -228,7 +228,7 @@ var IPython = (function (IPython) { /** * Show/Hide CodeMirror LineNumber - * @method show_line_number + * @method show_line_numbers * * @param value {Bool} show (true), or hide (false) the line number in CodeMirror **/ @@ -242,12 +242,8 @@ var IPython = (function (IPython) { * @method toggle_line_numbers **/ Cell.prototype.toggle_line_numbers = function () { - if (this.code_mirror.getOption('lineNumbers') == false) { - this.code_mirror.setOption('lineNumbers', true); - } else { - this.code_mirror.setOption('lineNumbers', false); - } - this.code_mirror.refresh(); + var val = this.code_mirror.getOption('lineNumbers'); + this.show_line_numbers(!val); }; /**