Commit 43e053a0 authored by Marc Duez's avatar Marc Duez
Browse files

model.js : multiselect() will sort selected clones by size

parent efa5206c
......@@ -893,8 +893,20 @@ Model.prototype = {
myConsole.log("select() (clone " + list + ")");
var tmp = []
for (var i=0; i<list.length; i++){
this.clone(list[i]).select = true;
tmp[i] = {'id': list[i], 'size': this.clone(list[i]).getSize()}
}
list=[]
tmp = tmp.sort(function (a, b) {
if (a.size < b.size) return 1;
return -1;
})
for (var i=0; i<tmp.length; i++){
this.clone(tmp[i].id).select = true;
list[i]=tmp[i].id
}
this.updateElemStyle(list);
......
......@@ -200,21 +200,23 @@ Segment.prototype = {
*
* */
updateElem: function (list) {
for (var i = 0; i < list.length; i++) {
if (this.m.clone(list[i]).isSelected()) {
if (document.getElementById("seq" + list[i])) {
var spanF = document.getElementById("f" + list[i]);
this.div_elem(spanF, list[i]);
var id = list[i]
if (this.m.clone(id).isSelected()) {
if (document.getElementById("seq" + id)) {
var spanF = document.getElementById("f" + id);
this.div_elem(spanF, id);
var spanM = document.getElementById("m" + list[i]);
spanM.innerHTML = this.sequence[list[i]].toString()
var spanM = document.getElementById("m" + id);
spanM.innerHTML = this.sequence[id].toString()
} else {
this.addToSegmenter(list[i]);
this.addToSegmenter(id);
this.show();
}
} else {
if (document.getElementById("seq" + list[i])) {
var element = document.getElementById("seq" + list[i]);
if (document.getElementById("seq" + id)) {
var element = document.getElementById("seq" + id);
element.parentNode.removeChild(element);
}
}
......@@ -222,6 +224,7 @@ Segment.prototype = {
},
updateElemStyle: function (list) {
for (var i = 0; i < list.length; i++) {
if (this.m.clone(list[i]).isSelected()) {
if (document.getElementById("seq" + list[i])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment