src/js/widgets/arrowWidget.js
branchpopcorn-port
changeset 563 4816e3425933
parent 560 68e91efc5a58
child 664 c548eb0be4ef
--- 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;   
+};