src/js/widgets/annotationsWidget.js
author hamidouk
Mon, 24 Oct 2011 17:26:36 +0200
branchpopcorn-port
changeset 130 f25676c72044
parent 125 960ce0b9f9f0
child 139 ba2b3c15bd47
permissions -rw-r--r--
added a semicolon.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     1
IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     3
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     4
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     5
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     6
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     7
IriSP.AnnotationsWidget.prototype = new IriSP.Widget;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     8
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
     9
IriSP.AnnotationsWidget.prototype.clear = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    10
    IriSP.jQuery("#Ldt-SaTitle").text("");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    11
    IriSP.jQuery("#Ldt-SaDescription").text("");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    12
    IriSP.jQuery("#Ldt-SaKeywordText").text("");
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    13
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    14
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    15
IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    16
    var title = annotation.content.title;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    17
    var description = annotation.content.description;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    18
    var keywords =  "" // FIXME;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    19
    var begin = +annotation.begin;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    20
    var end = +annotation.end;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    21
    var duration = +this._serializer.currentMedia().meta["dc:duration"];
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    22
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    23
    IriSP.jQuery("#Ldt-SaTitle").text(title);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    24
    IriSP.jQuery("#Ldt-SaDescription").text(description);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    25
    IriSP.jQuery("#Ldt-SaKeywordText").text("Mots clefs : "+ keywords);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    26
		var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); 
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    27
		IriSP.jQuery("#Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    28
		//IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    29
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    30
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    31
125
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    32
IriSP.AnnotationsWidget.prototype.clearWidget = function() {
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    33
    /* retract the pane between two annotations */
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    34
    IriSP.jQuery("#Ldt-SaTitle").text("");
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    35
    IriSP.jQuery("#Ldt-SaDescription").text("");
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    36
    IriSP.jQuery("#Ldt-SaKeywordText").html("");
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    37
    IriSP.jQuery('#Ldt-ShowAnnotation').slideUp();
130
f25676c72044 added a semicolon.
hamidouk
parents: 125
diff changeset
    38
};
f25676c72044 added a semicolon.
hamidouk
parents: 125
diff changeset
    39
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    40
IriSP.AnnotationsWidget.prototype.draw = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    41
  var _this = this;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    42
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    43
  var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template});
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    44
	IriSP.jQuery("#Ldt-Ligne").append(annotationMarkup);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    45
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    46
  var annotations = this._serializer._data.annotations;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    47
	for (i in annotations) {    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    48
    var annotation = annotations[i];
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    49
    var begin = Math.round((+ annotation.begin) / 1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    50
    var end = Math.round((+ annotation.end) / 1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    51
125
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    52
    var conf = {start: begin, end: end, 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    53
                onStart: 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    54
                       function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation),
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    55
                onEnd: 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    56
                       function() { _this.clearWidget(); },
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    57
                };
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    58
    this._Popcorn = this._Popcorn.code(conf);                                             
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    59
  }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    60
};