From a7f05697cc02a581bb78dbcf25f5f681846ef907 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Sat, 12 Dec 2015 15:32:53 -0600 Subject: [PATCH] Cleaned up functions --- notebook/static/notebook/js/notebook.js | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 1dc51d304..a33f23de0 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -634,6 +634,7 @@ define(function (require) { }); return result; }; + /** * Get the index of the currently selected cell. * @@ -847,20 +848,22 @@ define(function (require) { // actually will move the cell before the selection, after the selection var indices = this.get_selected_cells_indices(); var first = indices[0]; - var last = indices[indices.length-1]; + var last = indices[indices.length - 1]; - var i1 = this.get_selected_index(); - var i2 = this.get_anchor_index(); + var selected = this.get_selected_index(); + var anchored = this.get_anchor_index(); - if(first===0){ + if (first === 0){ return; } - var tomove = this.get_cell_element(first-1); + var tomove = this.get_cell_element(first - 1); var pivot = this.get_cell_element(last); + tomove.detach(); pivot.after(tomove); - this.select(i2-1); - this.select(i1-1, false); + + this.select(anchored - 1); + this.select(selected - 1, false); }; /** @@ -871,19 +874,23 @@ define(function (require) { // actually will move the cell after the selection, before the selection var indices = this.get_selected_cells_indices(); var first = indices[0]; - var last = indices[indices.length-1]; - var i1 = this.get_selected_index(); - var i2 = this.get_anchor_index(); - if(!this.is_valid_cell_index(last+1)){ + var last = indices[indices.length - 1]; + + var selected = this.get_selected_index(); + var anchored = this.get_anchor_index(); + + if(!this.is_valid_cell_index(last + 1)){ return; } - var tomove = this.get_cell_element(last+1); + var tomove = this.get_cell_element(last + 1); var pivot = this.get_cell_element(first); + tomove.detach(); pivot.before(tomove); + this.select(first); - this.select(i2+1); - this.select(i1+1, false); + this.select(anchored + 1); + this.select(selected + 1, false); }; /**