mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-18 11:55:46 +08:00
Merge pull request #850 from captainsafia/update-var-names
Update var names in multi-selection move
This commit is contained in:
commit
c21ba90813
@ -625,6 +625,11 @@ define(function (require) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the index of the cell that the selection is currently anchored on.
|
||||
*
|
||||
* @return {integer} Index of first cell selected in selection
|
||||
*/
|
||||
Notebook.prototype.get_anchor_index = function () {
|
||||
var result = null;
|
||||
this.get_cell_elements().filter(function (index) {
|
||||
@ -634,6 +639,7 @@ define(function (require) {
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the index of the currently selected cell.
|
||||
*
|
||||
@ -847,20 +853,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 +879,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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user