changeset 612:80582bdf9d12 multiple-tests-concatenation

discrete interface: long labels will wrap instead of overlapping. Closed #1666
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 13 Mar 2016 14:09:22 +0000
parents fef9f13bec0a
children 19c17f5fa999
files interfaces/discrete.js
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/interfaces/discrete.js	Sun Mar 13 02:12:30 2016 +0000
+++ b/interfaces/discrete.js	Sun Mar 13 14:09:22 2016 +0000
@@ -75,7 +75,7 @@
 	sliderBox.appendChild(scaleHolder);
 	var scaleText = document.createElement('div');
 	scaleText.id = "scale-text-holder";
-	scaleText.style.height = "25px";
+	scaleText.style.height = "70px";
 	scaleText.style.width = "100%";
 	scaleHolder.appendChild(scaleText);
 	var scaleCanvas = document.createElement('canvas');
@@ -507,6 +507,10 @@
 	textHolder.innerHTML = null;
 	ctx.fillStyle = "#000000";
 	ctx.setLineDash([1,4]);
+
+  var scaleTextWidthPercent = 100/scales.length - 2;
+  var scaleTextMaxHeight = 0;
+  var scaleTextDivs = [];
 	for (var scale of scales)
 	{
 		var posPercent = scale.position / 100.0;
@@ -524,9 +528,20 @@
 		text.appendChild(textC);
 		text.className = "scale-text";
 		textHolder.appendChild(text);
-		text.style.width = $(text.children[0]).width()+'px';
+    console.log('here')
+		// text.style.width = $(text.children[0]).width()+'px';
+    text.style.width = scaleTextWidthPercent+"%";
 		text.style.left = (posPix+150-($(text).width()/2)) +'px';
+    scaleTextMaxHeight = text.offsetHeight > scaleTextMaxHeight ? text.offsetHeight : scaleTextMaxHeight;
+    scaleTextDivs[scaleTextDivs.length] = text;
 	}
+  var newHeight = scaleTextMaxHeight+"px";
+  for(var scaleTextDiv of scaleTextDivs){
+    scaleTextDiv.style.height = newHeight;
+  }
+  textHolder.style.height = newHeight;
+  var sliderHolder = document.getElementById("slider-holder");
+  sliderHolder.style.marginTop = newHeight;
 }
 
 function buttonSubmitClick() // TODO: Only when all songs have been played!