src/js/widgets/annotationsWidget.js
author hamidouk
Tue, 08 Nov 2011 15:57:04 +0100
branchpopcorn-port
changeset 212 3a6e4089eef0
parent 162 2ef47ccb290f
child 238 6008172a0592
child 264 9fb001b19dd2
permissions -rw-r--r--
fixed teh segments display bug and another bug related to float positioning.
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
139
ba2b3c15bd47 fixing prototype bug.
hamidouk
parents: 130
diff changeset
     7
IriSP.AnnotationsWidget.prototype = new IriSP.Widget();
98
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() {
162
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    10
    this.selector.find(".Ldt-SaTitle").text("");
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    11
    this.selector.find(".Ldt-SaDescription").text("");
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    12
    this.selector.find(".Ldt-SaKeywordText").text("");
98
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
162
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    23
    this.selector.find(".Ldt-SaTitle").text(title);
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    24
    this.selector.find(".Ldt-SaDescription").text(description);
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    25
		var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); 
162
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    26
		this.selector.find(".Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000);
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    27
		//IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    28
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
125
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    31
IriSP.AnnotationsWidget.prototype.clearWidget = function() {
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    32
    /* retract the pane between two annotations */
162
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    33
    this.selector.find(".Ldt-SaTitle").text("");
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    34
    this.selector.find(".Ldt-SaDescription").text("");
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    35
    this.selector.find(".Ldt-SaKeywordText").html("");
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    36
    this.selector.find(".Ldt-ShowAnnotation").slideUp();
130
f25676c72044 added a semicolon.
hamidouk
parents: 125
diff changeset
    37
};
f25676c72044 added a semicolon.
hamidouk
parents: 125
diff changeset
    38
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    39
IriSP.AnnotationsWidget.prototype.draw = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    40
  var _this = this;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    41
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    42
  var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template});
162
2ef47ccb290f a couple fixes to the annotationsWidget tests.
hamidouk
parents: 146
diff changeset
    43
	this.selector.append(annotationMarkup);
139
ba2b3c15bd47 fixing prototype bug.
hamidouk
parents: 130
diff changeset
    44
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    45
  var annotations = this._serializer._data.annotations;
146
b99527037c89 fixed global variable declaration bug.
hamidouk
parents: 139
diff changeset
    46
  var i;
b99527037c89 fixed global variable declaration bug.
hamidouk
parents: 139
diff changeset
    47
  
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    48
	for (i in annotations) {    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    49
    var annotation = annotations[i];
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    50
    var begin = Math.round((+ annotation.begin) / 1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    51
    var end = Math.round((+ annotation.end) / 1000);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    52
125
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    53
    var conf = {start: begin, end: end, 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    54
                onStart: 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    55
                       function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation),
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    56
                onEnd: 
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    57
                       function() { _this.clearWidget(); },
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    58
                };
960ce0b9f9f0 added a function to clear the widget.
hamidouk
parents: 101
diff changeset
    59
    this._Popcorn = this._Popcorn.code(conf);                                             
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    60
  }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    61
};