From e3299328d2d9bdcb74ba73efb01d372f75271c30 Mon Sep 17 00:00:00 2001 From: Pierre Gerold Date: Mon, 7 Dec 2015 16:01:10 +0100 Subject: [PATCH] to_code -> cells_to_code to handle muliple selected cells --- notebook/static/notebook/js/actions.js | 4 ++-- notebook/static/notebook/js/notebook.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index b39a68902..e84837057 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -243,11 +243,11 @@ define(function(require){ env.notebook.focus_cell(); } }, - 'change-cell-to-code' : { + 'change-cell(s)-to-code' : { help : 'to code', help_index : 'ca', handler : function (env) { - env.notebook.to_code(); + env.notebook.cells_to_code(); } }, 'change-cell-to-markdown' : { diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 14c8b42aa..99e2ac8ac 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -1176,7 +1176,18 @@ define(function (require) { var len = this.ncells(); return this.insert_cell_below(type,len-1); }; - + + + Notebook.prototype.cells_to_code = function (indices) { + if (indices === undefined){ + indices = this.get_selected_cells_indices(); + } + this.untocode_backup =[]; + + for (var i=0; i