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 |
|
6 this.polemic_mode = IriSP.widgetsDefaults["createAnnotationWidget"].polemic_mode; |
|
7 this.polemics = IriSP.widgetsDefaults["createAnnotationWidget"].polemics; |
|
8 |
5 this.cinecast_version = IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version; |
9 this.cinecast_version = IriSP.widgetsDefaults["createAnnotationWidget"].cinecast_version; |
6 this.ids = {}; /* a dictionnary linking buttons ids to keywords */ |
10 this.ids = {}; /* a dictionnary linking buttons ids to keywords */ |
7 |
11 |
8 /* variables to save the current position of the slicer */ |
12 /* variables to save the current position of the slicer */ |
9 if (this.cinecast_version) { |
13 if (this.cinecast_version) { |
22 }; |
26 }; |
23 |
27 |
24 IriSP.createAnnotationWidget.prototype.draw = function() { |
28 IriSP.createAnnotationWidget.prototype.draw = function() { |
25 var _this = this; |
29 var _this = this; |
26 |
30 |
27 var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template); |
31 var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template, |
|
32 {cinecast_version: this.cinecast_version, |
|
33 polemic_mode: this.polemic_mode}); |
28 |
34 |
29 this.selector.append(annotationMarkup); |
35 this.selector.append(annotationMarkup); |
30 |
36 |
31 if (!this.cinecast_version) |
37 if (!this.cinecast_version) |
32 this.selector.hide(); |
38 this.selector.hide(); |
56 _this.selector.find(".Ldt-createAnnotation-Description").val(newVal); |
62 _this.selector.find(".Ldt-createAnnotation-Description").val(newVal); |
57 // we use a custom event because there's no simple way to test for a js |
63 // we use a custom event because there's no simple way to test for a js |
58 // change in a textfield. |
64 // change in a textfield. |
59 _this.selector.find(".Ldt-createAnnotation-Description").trigger("js_mod"); |
65 _this.selector.find(".Ldt-createAnnotation-Description").trigger("js_mod"); |
60 // also call our update function. |
66 // also call our update function. |
61 _this.handleTextChanges(); |
67 //_this.handleTextChanges(); |
62 } |
68 } |
63 }(keyword)); |
69 }(keyword)); |
64 } |
70 } |
|
71 |
|
72 // add the polemic buttons. |
|
73 if(this.polemic_mode) |
|
74 for (var polemic in this.polemics) { |
|
75 |
|
76 var classname = IriSP.templToHTML("Ldt-createAnnotation-polemic-{{classname}}", {classname : this.polemics[polemic]}); |
|
77 |
|
78 var templ = IriSP.templToHTML("<button class='{{classname}}'>{{polemic}}</button>", |
|
79 {classname: classname, polemic: polemic}); |
|
80 |
|
81 this.selector.find(".Ldt-createAnnotation-polemics").append(templ); |
|
82 this.selector.find("." + classname).click(function(polemic) { return function() { |
|
83 var contents = _this.selector.find(".Ldt-createAnnotation-Description").val(); |
|
84 if (contents.indexOf(polemic) != -1) { |
|
85 var newVal = contents.replace(" " + polemic, ""); |
|
86 if (newVal == contents) |
|
87 newVal = contents.replace(polemic, ""); |
|
88 } else { |
|
89 if (contents === "") |
|
90 var newVal = polemic; |
|
91 else |
|
92 var newVal = contents + " " + polemic; |
|
93 } |
|
94 |
|
95 _this.selector.find(".Ldt-createAnnotation-Description").val(newVal); |
|
96 // we use a custom event because there's no simple way to test for a js |
|
97 // change in a textfield. |
|
98 _this.selector.find(".Ldt-createAnnotation-Description").trigger("js_mod"); |
|
99 // also call our update function. |
|
100 _this.handleTextChanges(); |
|
101 } |
|
102 }(polemic)); |
|
103 } |
65 |
104 |
66 this.selector.find(".Ldt-createAnnotation-Description") |
105 this.selector.find(".Ldt-createAnnotation-Description") |
67 .bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges)); |
106 .bind("propertychange keyup input paste", IriSP.wrap(this, this.handleTextChanges)); |
68 |
107 |
69 /* the cinecast version of the player is supposed to pause when the user clicks on the button */ |
108 /* the cinecast version of the player is supposed to pause when the user clicks on the button */ |