1 IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) { |
1 IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) { |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
2 IriSP.Widget.call(this, Popcorn, config, Serializer); |
3 this._hidden = true; |
3 this._hidden = true; |
4 this.keywords = IriSP.widgetsDefaults["createAnnotationWidget"].keywords; |
4 this.keywords = IriSP.widgetsDefaults["createAnnotationWidget"].keywords; |
|
5 this.cinecast_version = IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version; |
5 this.ids = {}; /* a dictionnary linking buttons ids to keywords */ |
6 this.ids = {}; /* a dictionnary linking buttons ids to keywords */ |
6 }; |
7 }; |
7 |
8 |
8 |
9 |
9 IriSP.createAnnotationWidget.prototype = new IriSP.Widget(); |
10 IriSP.createAnnotationWidget.prototype = new IriSP.Widget(); |
12 this.selector.find(".Ldt-SaTitle").text(""); |
13 this.selector.find(".Ldt-SaTitle").text(""); |
13 this.selector.find(".Ldt-SaDescription").text(""); |
14 this.selector.find(".Ldt-SaDescription").text(""); |
14 this.selector.find(".Ldt-SaKeywordText").text(""); |
15 this.selector.find(".Ldt-SaKeywordText").text(""); |
15 }; |
16 }; |
16 |
17 |
17 IriSP.createAnnotationWidget.prototype.showWidget = function() { |
|
18 this.layoutManager.slice.after("ArrowWidget") |
|
19 .before("createAnnotationWidget") |
|
20 .jQuerySelector().hide(); |
|
21 this.selector.show(); |
|
22 }; |
|
23 |
|
24 IriSP.createAnnotationWidget.prototype.hideWidget = function() { |
|
25 this.selector.hide(); |
|
26 this.layoutManager.slice.after("ArrowWidget") |
|
27 .before("createAnnotationWidget") |
|
28 .jQuerySelector().show(); |
|
29 }; |
|
30 |
|
31 IriSP.createAnnotationWidget.prototype.draw = function() { |
18 IriSP.createAnnotationWidget.prototype.draw = function() { |
32 var _this = this; |
19 var _this = this; |
33 |
20 |
34 var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template); |
21 if (this.cinecast_version) { |
|
22 var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_festivalCinecast_template); |
|
23 } else { |
|
24 var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template); |
|
25 } |
|
26 |
35 this.selector.append(annotationMarkup); |
27 this.selector.append(annotationMarkup); |
36 |
28 |
37 this.selector.hide(); |
29 this.selector.hide(); |
38 for (var i = 0; i < this.keywords.length; i++) { |
30 for (var i = 0; i < this.keywords.length; i++) { |
39 var keyword = this.keywords[i]; |
31 var keyword = this.keywords[i]; |
60 } |
52 } |
61 |
53 |
62 this.selector.find(".Ldt-createAnnotation-Description") |
54 this.selector.find(".Ldt-createAnnotation-Description") |
63 .bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges)); |
55 .bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges)); |
64 |
56 |
|
57 this.selector.find(".Ldt-createAnnotation-submitButton").click(IriSP.wrap(this, this.handleButtonClick)); |
65 this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", |
58 this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", |
66 IriSP.wrap(this, this.handleAnnotateSignal)); |
59 IriSP.wrap(this, this.handleAnnotateSignal)); |
67 }; |
60 }; |
68 |
61 |
69 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() { |
62 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() { |
70 if (this._hidden == false) { |
63 if (this._hidden == false) { |
71 this.selector.hide(); |
64 this.selector.hide(); |
72 this._hidden = true; |
65 this._hidden = true; |
|
66 /* reinit the fields */ |
|
67 |
|
68 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().show(); |
|
69 this.selector.find("Ldt-createAnnotation-Description").val(""); |
|
70 this.selector.find(".Ldt-createAnnotation-endScreen").hide(); |
73 } else { |
71 } else { |
|
72 if (this.cinecast_version) { |
|
73 var currentTime = this._Popcorn.currentTime(); |
|
74 var currentAnnotation = this._serializer.currentAnnotations(currentTime)[0]; |
|
75 var beginTime = IriSP.msToTime(currentAnnotation.begin); |
|
76 var endTime = IriSP.msToTime(currentAnnotation.end); |
|
77 |
|
78 if (typeof(currentAnnotation.content) !== "undefined") |
|
79 this.selector.find(".Ldt-createAnnotation-Title").html(currentAnnotation.content.title); |
|
80 |
|
81 var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime }); |
|
82 this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate); |
|
83 } |
|
84 |
74 this.selector.show(); |
85 this.selector.show(); |
75 this._hidden = false; |
86 this._hidden = false; |
76 } |
87 } |
77 }; |
88 }; |
78 |
89 |