block the arrow when the user is annotating. popcorn-port
authorhamidouk
Mon, 02 Jan 2012 15:46:42 +0100
branchpopcorn-port
changeset 563 4816e3425933
parent 562 643614f78c44
child 564 a560a162f444
block the arrow when the user is annotating.
src/js/widgets/arrowWidget.js
src/js/widgets/createAnnotationWidget.js
--- a/src/js/widgets/arrowWidget.js	Mon Jan 02 15:27:32 2012 +0100
+++ b/src/js/widgets/arrowWidget.js	Mon Jan 02 15:46:42 2012 +0100
@@ -2,7 +2,7 @@
   IriSP.Widget.call(this, Popcorn, config, Serializer);
 
   this._oldAnnotation = null;
-  
+  this._blockArrow = false;
 };
 
 
@@ -19,9 +19,15 @@
   var templ = Mustache.to_html(IriSP.arrowWidget_template, {});
   this.selector.append(templ);
   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeUpdateHandler));
+  this._Popcorn.listen("IriSP.ArrowWidget.blockArrow", IriSP.wrap(this, this.blockArrow));
+  this._Popcorn.listen("IriSP.ArrowWidget.releaseArrow", IriSP.wrap(this, this.releaseArrow));
+  
 };
 
 IriSP.ArrowWidget.prototype.timeUpdateHandler = function(percents) {
+  if (this._blockArrow)
+    return;
+  
   var currentTime = this._Popcorn.currentTime();
   var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; // FIXME : use the others ?
 
@@ -66,4 +72,13 @@
 
     this._oldAnnotation = currentAnnotation;
   }
-}
+};
+
+/** Block the arrow for instance when the user is annotating */
+IriSP.ArrowWidget.prototype.blockArrow = function() {
+  this._blockArrow = true;
+};
+
+IriSP.ArrowWidget.prototype.releaseArrow = function() {
+  this._blockArrow = false;   
+};
--- a/src/js/widgets/createAnnotationWidget.js	Mon Jan 02 15:27:32 2012 +0100
+++ b/src/js/widgets/createAnnotationWidget.js	Mon Jan 02 15:46:42 2012 +0100
@@ -84,6 +84,9 @@
     
     this.selector.show();
     this._hidden = false;
+    
+    // block the arrow.
+    this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
   }
 };
 
@@ -133,5 +136,6 @@
   } else {
     this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
     this.selector.find(".Ldt-createAnnotation-endScreen").show();
+    this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow");
   }
 };
\ No newline at end of file