Commit 117a7bf1 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

Merge branch 'feature-c/2436' into 'dev'

Eviter inner/outerHTML pour les axes

Closes #2436

See merge request !55
parents 693ddd9a 15c0d92a
......@@ -28,6 +28,13 @@ function Axes (model) {
V_IDENTITY_THRESHOLD = 98.0
function createClassedSpan (className, innerText) {
var span = document.createElement('span');
span.className = className;
span.textContent = innerText;
return span;
}
Axes.prototype = {
available: function(){
......@@ -57,14 +64,14 @@ Axes.prototype = {
label: "clone consensus length",
axis: new NumericalAxis(this.m, false, true),
fct: function(clone) {return clone.getSequenceLength()},
pretty: function(len) {return '<span class="threeDigits">'+len+'</span>'}
pretty: function(len) { return createClassedSpan('threeDigits', len) }
},
"readLength" : {
doc: "average length of the reads belonging to each clone",
label: "clone average read length",
axis: new FloatAxis(this.m),
fct: function(clone) {return clone.getAverageReadLength()},
pretty: function(len) {return '<span class="widestBox">' + (len == 'undefined' ? '?' : len) + '</span>'}
pretty: function(len) { return createClassedSpan('widestBox', (len == 'undefined' ? '?' : len)) }
},
"GCContent" : {
doc: "%GC content of the consensus sequence of each clone",
......@@ -77,26 +84,26 @@ Axes.prototype = {
label: "N length",
axis: new NumericalAxis(this.m),
fct: function(clone) {return clone.getNlength()},
pretty: function(len) {return '<span class="threeDigits">'+len+'</span>'}
pretty: function(len) { return createClassedSpan('threeDigits', len) }
},
"lengthCDR3": {
doc: "CDR3 length, in nucleotides, from Cys104 and Phe118/Trp118 (excluded)",
label: "CDR3 length (nt)",
axis: new NumericalAxis(this.m),
fct: function(clone) {return clone.getSegLength('cdr3')},
pretty: function(len) {return '<span class="threeDigits">' + (len == 'undefined' ? '?' : len) + '</span>'}
pretty: function(len) { return createClassedSpan('threeDigits', (len == 'undefined' ? '?' : len)) }
},
"productivity": {
label: "productivity",
axis: new GenericAxis(),
fct: function(clone) {return clone.getProductivityName()},
pretty: function(tag) { return icon_pm(tag, "productive", "not productive").outerHTML },
pretty: function(tag) { return icon_pm(tag, "productive", "not productive") },
},
"productivity-IMGT": {
label: "productivity (as computed by IMGT/V-QUEST)",
axis: new GenericAxis(),
fct: function(clone) { return clone.getProductivityIMGT() },
pretty: function(tag) { return icon_pm(tag, "productive", "not productive").outerHTML },
pretty: function(tag) { return icon_pm(tag, "productive", "not productive") },
hide: true
},
"VIdentity-IMGT": {
......@@ -116,7 +123,7 @@ Axes.prototype = {
info.setAttribute('title', 'V-REGION identity %, as computed by IMGT/V-QUEST') // with indel or not ?
Videntity_info.appendChild(info)
} else Videntity_info.innerHTML = "&nbsp;";
return Videntity_info.outerHTML
return Videntity_info;
},
hide: true
},
......@@ -125,7 +132,7 @@ Axes.prototype = {
label: "tag",
axis: new GenericAxis(),
fct: function(clone) {return clone.getTagName()},
pretty: function(tag) {return '<span class="widestBox">'+tag+'</span>'}
pretty: function(tag) { return createClassedSpan('widestBox', tag) }
},
"coverage": {
doc: "ratio of the length of the clone consensus sequence to the median read length of the clone",
......@@ -142,17 +149,14 @@ Axes.prototype = {
label: "locus",
axis: new GenericAxis(),
fct: function(clone){return clone.germline},
pretty: function(system){
var ret = self.m.systemBox(system);
return (ret instanceof Element ? ret.outerHTML : ret);
}
pretty: function(system) { return self.m.systemBox(system) }
},
"Size" : {
doc: "ratio of the number of reads of each clone to the total number of reads in the selected locus",
label: "size",
axis: new PercentAxis(this.m),
fct : function(clone){return clone.getSizeZero()},
pretty: function(size) {return '<span class="sizeBox sixChars">'+(self.m ? self.m : self).getStrAnySize(undefined, size)+'</span>'},
pretty: function(size) { return createClassedSpan("sizeBox sixChars", (self.m ? self.m : self).getStrAnySize(undefined, size)) },
min : function(){return self.m.min_size},
max : 1,
log : true
......@@ -170,7 +174,7 @@ Axes.prototype = {
label: "number of samples sharing each clone",
axis : new NumericalAxis(this.m),
fct : function(clone){return clone.getNumberNonZeroSamples()},
pretty: function(nb) {return '<span class="twoDigits">'+nb+'</span>'},
pretty: function(nb) { return createClassedSpan('twoDigits', nb) },
min : 1,
max : function(){ return self.m.samples.number }
},
......
......@@ -492,7 +492,9 @@ List.prototype = {
//update clone axis
var span_axis = div_elem.getElementsByClassName("axisBox")[0];
span_axis.style.color = clone.getColor();
span_axis.innerHTML = this.selectedAxis.pretty ? this.selectedAxis.pretty(this.selectedAxis.fct(clone)) : this.selectedAxis.fct(clone);
var axis = this.selectedAxis;
span_axis.removeAllChildren();
span_axis.appendChild(axis.pretty ? axis.pretty(axis.fct(clone)) : document.createTextNode(axis.fct(clone)));
// span_axis.setAttribute('title', clone.getPrintableSize());
//update cluster icon
......
......@@ -627,7 +627,8 @@ Segment.prototype = {
for (var i in this.selectedAxis) {
var span = document.createElement('span');
var axis = this.selectedAxis[i];
span.innerHTML = axis.pretty ? axis.pretty(axis.fct(clone)) : axis.fct(clone);
span.removeAllChildren();
span.appendChild(axis.pretty ? axis.pretty(axis.fct(clone)) : document.createTextNode(axis.fct(clone)));
span.setAttribute('title', this.selectedAxis[i].label);
span.className = axOpts[i];
axisBox.appendChild(span);
......
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