new player version
authorhamidouk
Fri, 03 Feb 2012 17:20:18 +0100
changeset 525 1b7a99b910a0
parent 523 668a7f75b256
child 526 1def9a19333d
new player version
src/ldt/ldt/static/ldt/js/LdtPlayer-release.js
--- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Fri Feb 03 16:02:04 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js	Fri Feb 03 17:20:18 2012 +0100
@@ -2558,8 +2558,11 @@
   var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template);
 	this.selector.append(annotationMarkup);
 
-  this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
-                        IriSP.wrap(this, this.handleAnnotateSignal));  
+  this._Popcorn.listen("IriSP.AnnotationsWidget.show", 
+                        IriSP.wrap(this, this.show));
+  this._Popcorn.listen("IriSP.AnnotationsWidget.hide", 
+                        IriSP.wrap(this, this.hide));
+ 
   var legal_ids = [];
   if (typeof(this._serializer.getChapitrage()) !== "undefined")
     legal_ids.push(this._serializer.getChapitrage());
@@ -2595,11 +2598,15 @@
 
 };
 
-IriSP.AnnotationsWidget.prototype.handleAnnotateSignal = function() {
+IriSP.AnnotationsWidget.prototype.hide = function() {
   if (this._hidden == false) {
     this.selector.hide();
     this._hidden = true;
-  } else {
+  }
+};
+
+IriSP.AnnotationsWidget.prototype.show = function() {
+  if (this._hidden == true) {
     this.selector.show();
     this._hidden = false;
   }
@@ -2872,15 +2879,17 @@
 /** handles clicks on the annotate button. Works only for the non-cinecast version */
 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
   
-  if (this._hidden == false) {
+  if (this._hidden == false && this._state == 'startScreen') {
     this.selector.hide();
     this._hidden = true;
     
     // free the arrow.
     this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow");
     this._Popcorn.trigger("IriSP.SliceWidget.hide");
+    this._Popcorn.trigger("IriSP.AnnotationsWidget.show");
     
   } else {
+    this._Popcorn.trigger("IriSP.AnnotationsWidget.hide");
     this.showStartScreen();
     this.selector.show();
     this._hidden = false;
@@ -2892,7 +2901,7 @@
     var duration = +this._serializer.currentMedia().meta["dc:duration"];
         
     var currentChapter = this._serializer.currentChapitre(currentTime);
-    if (typeof(currentChapter) === "undefined") {
+    if (IriSP.null_or_undefined(currentChapter)) {
       var left = this.selector.width() / 2;
       var width = this.selector.width() / 10;
     } else {
@@ -2906,13 +2915,15 @@
     this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges));
     this._Popcorn.trigger("IriSP.SliceWidget.show");
     
-    this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title);
-
-    this._currentcurrentChapter = currentChapter;
-    var beginTime = IriSP.msToTime(currentChapter.begin);
-    var endTime = IriSP.msToTime(currentChapter.end);
-    var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
-    this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
+    if (!IriSP.null_or_undefined(currentChapter)) {
+      this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title);
+
+      this._currentcurrentChapter = currentChapter;
+      var beginTime = IriSP.msToTime(currentChapter.begin);
+      var endTime = IriSP.msToTime(currentChapter.end);
+      var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
+      this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
+    }
   }
 };
 
@@ -2957,17 +2968,21 @@
 IriSP.createAnnotationWidget.prototype.showStartScreen = function() {
   this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
   this.selector.find(".Ldt-createAnnotation-startScreen").show();
-  this.selector.find(".Ldt-createAnnotation-Description").val("Type your annotation here.");  
+  this.selector.find(".Ldt-createAnnotation-Description").val("Type your annotation here.");
+
+  this._state = "startScreen";
 };
 
 IriSP.createAnnotationWidget.prototype.showWaitScreen = function() {
   this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
-  this.selector.find(".Ldt-createAnnotation-waitScreen").show();  
+  this.selector.find(".Ldt-createAnnotation-waitScreen").show();
+  this._state = "waitScreen";
 };
 
 IriSP.createAnnotationWidget.prototype.showErrorScreen = function() {
   this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
-  this.selector.find(".Ldt-createAnnotation-errorScreen").show();  
+  this.selector.find(".Ldt-createAnnotation-errorScreen").show();
+  this._state = "errorScreen";
 };
 
 /** update show the final screen with links to share the created annotation */
@@ -2988,6 +3003,7 @@
   this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus);
           
   this.selector.find(".Ldt-createAnnotation-endScreen").show();
+  this._state = "endScreen";
 };
 
 /** handle clicks on "send annotation" button */
@@ -3022,11 +3038,12 @@
                             _this._Popcorn.play();
                       }
 
-                      _this.showEndScreen(annotation);
-                      if (_this.cinecast_version) {
-                        window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000);
+                      if (_this._state == "waitScreen") {
+                        _this.showEndScreen(annotation);
+                        if (_this.cinecast_version) {
+                          window.setTimeout(IriSP.wrap(_this, function() { this.showStartScreen(); }), 5000);
+                        }
                       }
-                      
                       // hide the slicer widget
                       if (!_this.cinecast_version) {                      
                         _this._Popcorn.trigger("IriSP.SliceWidget.hide");
@@ -4094,27 +4111,44 @@
 
   var left = this.selector.offset().left;
   var top = this.selector.offset().top;
-  console.log("width %d, offset : %d", this.selector.width(), this.selector.offset().left);
-  // contain the handles correctly - we cannot set
-  // containment: parent because it wouldn't allow to select the 
-  // whole slice, so we have to compute a box in which the slice is
-  // allowed to move.
-  var containment = [left - 8, top, this.selector.width() + left, top];
-  console.log(containment);
-  //if (browser.
-  // var containment = [left - 16, top, this.selector.width() + left - 8, top];
-  this.leftHandle.draggable({axis: "x",
-  drag: IriSP.wrap(this, this.leftHandleDragged),  
-  containment: containment
-  });
-
-  containment = [left, top, this.selector.width() + left, top];
-  // containment = [left, top, this.selector.width() + left - 8, top];
-  this.rightHandle.draggable({axis: "x",
-  drag: IriSP.wrap(this, this.rightHandleDragged),    
-  containment: containment
-  });
-
+
+  // a bug in firefox makes it use the wrong format
+  if (!IriSP.jQuery.browser.mozilla) {
+    // contain the handles correctly - we cannot set
+    // containment: parent because it wouldn't allow to select the 
+    // whole slice, so we have to compute a box in which the slice is
+    // allowed to move.
+    var containment = [left - 8, top, this.selector.width() + left, top];
+
+    // var containment = [left - 16, top, this.selector.width() + left - 8, top];
+    this.leftHandle.draggable({axis: "x",
+    drag: IriSP.wrap(this, this.leftHandleDragged),  
+    containment: containment
+    });
+
+    containment = [left, top, this.selector.width() + left, top];
+    // containment = [left, top, this.selector.width() + left - 8, top];
+    this.rightHandle.draggable({axis: "x",
+    drag: IriSP.wrap(this, this.rightHandleDragged),    
+    containment: containment
+    });
+  
+  } else { // firefox
+    // we need to define a containment specific to firefox.
+    
+    var containment = [left - 16, top, this.selector.width() + left - 8, top];
+    this.leftHandle.draggable({axis: "x",
+    drag: IriSP.wrap(this, this.leftHandleDragged),  
+    containment: containment
+    });
+
+    containment = [left, top, this.selector.width() + left - 8, top];
+    this.rightHandle.draggable({axis: "x",
+    drag: IriSP.wrap(this, this.rightHandleDragged),    
+    containment: containment
+    });
+  }
+  
   this.leftHandle.css("position", "absolute");
   this.rightHandle.css("position", "absolute");