Merge with e4f0c105090d38f4b60699716dd20166e38e40da
authorrougeronj
Thu, 22 Jan 2015 09:29:49 +0100
changeset 112 3e075a48e19e
parent 111 a7b72620d227 (diff)
parent 110 e4f0c105090d (current diff)
child 113 7531e4180915
Merge with e4f0c105090d38f4b60699716dd20166e38e40da
client/annotviz/app/js/annotsroll.js
--- a/client/annotviz/app/js/annotsroll.js	Thu Jan 22 08:28:11 2015 +0100
+++ b/client/annotviz/app/js/annotsroll.js	Thu Jan 22 09:29:49 2015 +0100
@@ -21,7 +21,8 @@
 var defaultOptions = {
     externalRefresh: false,
     defaultColor: DEFAULT_ANNOT_COLOR,
-    annotStyles: defaultAnnotStyles
+    annotStyles: defaultAnnotStyles,
+    ignoreAnnots:false
 };
 
 function AnnotsRoll(options) {
@@ -41,20 +42,23 @@
     this.widthRoll = opts.widthRoll;
     this.pixelsPerSecond = opts.pixelsPerSecond;
     this.annotColors = opts.annotColors;
-    this.startTs = options.startTs || Date.now();
+    this.startTs = opts.startTs || Date.now();
+    this.ignoreAnnots = opts.ignoreAnnots;
 
     var yInit = opts.yInit;
     var annotStyles = _(opts.annotStyles).defaults(defaultAnnotStyles).value();
     for(var style in annotStyles) {
     	if (annotStyles[style].wordWrap === true){
-    		annotStyles[style].wordWrapWidth = this.widthRoll;
+    		annotStyles[style].wordWrapWidth = this.widthRoll; 
     	}
     }
     var started = false;
     var ws = opts.ws;
     var externalRefresh = opts.externalRefresh;
     var stageView = opts.stageView;
-
+    var waitInterval;
+    var wait = 0;
+    
     stageView.registerComponent(this);
 
     var isHidden = function(child) {
@@ -73,7 +77,7 @@
             text     = data.content.text,
             user     = data.content.user,
             ts       = Date.parse(data.ts),
-            color    = data.content.color || this.getColor(ts, data.content.category.code);
+            color    = this.getColor(ts, data.content.category.code);
 
         this.addAnnot(category, text, user, color, ts);
     };
@@ -107,36 +111,44 @@
 
         var colorHex = parseInt(color.replace(/^#/, ''), 16);
 
-        var graphics = new PIXI.Graphics()
-            .beginFill(colorHex)
-            .drawRect(x, y, 10, 3)
-            .endFill();
-
-        this.container.addChild(graphics);
-
-        var textHeight = 0;
-        var catLabel = new PIXI.Text(
-            category,
-            _(annotStyles.label).extend({fill: color}).value()
-        );
-        catLabel.x = x + 20;
-        catLabel.y = y - 23;
-        this.container.addChild(catLabel);
-        textHeight += (catLabel.height - 23 + 2);
-
-        if(text) {
-            var catText = new PIXI.Text(text, annotStyles.text);
-            catText.x = x + 20;
-            catText.y = y + 2;
-            this.container.addChild(catText);
-            textHeight += (catText.height + 2);
+        if (wait === 0){
+	        var graphics = new PIXI.Graphics()
+	            .beginFill(colorHex)
+	            .drawRect(x, y, 10, 3)
+	            .endFill();
+	
+	        this.container.addChild(graphics);
+	
+	        var textHeight = 0;
+	        var catLabel = new PIXI.Text(
+	            category,
+	            _(annotStyles.label).extend({fill: color}).value()
+	        );
+	        catLabel.x = x + 20;
+	        catLabel.y = y - 23;
+	        this.container.addChild(catLabel);
+	        textHeight += (catLabel.height - 23 + 2);
+	
+	        if(text) {
+	            var catText = new PIXI.Text(text, annotStyles.text);
+	            catText.x = x + 20;
+	            catText.y = y;
+	            this.container.addChild(catText);
+	            textHeight += (catText.height + 2);
+	        }
+	
+	        var catUser = new PIXI.Text(user, annotStyles.user);
+	        catUser.x = x + 20;
+	        catUser.y = y + textHeight;
+	        this.container.addChild(catUser);
+	        textHeight += (catUser.height + 8);
+	        
+	        if (this.ignoreAnnots === true){
+		        wait = textHeight / this.pixelsPerSecond;
+		        waitInterval = setInterval(function() {_this.refreshWait();}, 1000);
+	        }
         }
 
-        var catUser = new PIXI.Text(user, annotStyles.user);
-        catUser.x = x + 20;
-        catUser.y = y + 2 + textHeight;
-        this.container.addChild(catUser);
-
         this.addAnnotLine(colorHex, y);
     };
 
@@ -160,6 +172,14 @@
         var diff = (this.startTs - Date.now())/1000;
         this.moveTo(diff);
     };
+    
+    this.refreshWait = function(){
+    	wait -= 1;
+    	if (wait < 0){
+    		wait = 0;
+    		clearInterval(waitInterval);
+    	}
+    };
 
     this.removePassedObjets = function(){
         var childrenToRemove = [];
@@ -179,6 +199,7 @@
         });
 
     };
+    
 
     this.start = function() {
         if(!started) {