49 this.showStartScreen(); |
49 this.showStartScreen(); |
50 } |
50 } |
51 |
51 |
52 // Add onclick event to both polemic and keywords buttons |
52 // Add onclick event to both polemic and keywords buttons |
53 |
53 |
54 this.selector.find(".Ldt-createAnnotation-keywords button, .Ldt-createAnnotation-polemics button").click(function() { |
54 this.selector.find(".Ldt-createAnnotation-btnblock button").click(function() { |
55 _this.addKeyword(IriSP.jQuery(this).text()); |
55 _this.addKeyword(IriSP.jQuery(this).text()); |
56 }); |
56 }); |
57 |
57 |
58 // js_mod is a custom event because there's no simple way to test for a js |
58 // js_mod is a custom event because there's no simple way to test for a js |
59 // change in a textfield. |
59 // change in a textfield. |
193 |
193 |
194 /** watch for changes in the textfield and change the buttons accordingly */ |
194 /** watch for changes in the textfield and change the buttons accordingly */ |
195 IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) { |
195 IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) { |
196 var contents = this.selector.find(".Ldt-createAnnotation-Description").val(); |
196 var contents = this.selector.find(".Ldt-createAnnotation-Description").val(); |
197 |
197 |
198 this.selector.find(".Ldt-createAnnotation-keywords button").each(function() { |
198 this.selector.find(".Ldt-createAnnotation-btnblock button").each(function() { |
199 var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text()); |
199 var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text()); |
200 if (_rx.test(contents)) { |
200 if (_rx.test(contents)) { |
201 IriSP.jQuery(this).removeClass("Ldt-createAnnotation-absent-keyword") |
201 IriSP.jQuery(this).parent().addClass("Ldt-createAnnotation-active-button"); |
202 .addClass("Ldt-createAnnotation-present-keyword"); |
|
203 } else { |
202 } else { |
204 IriSP.jQuery(this).addClass("Ldt-createAnnotation-absent-keyword") |
203 IriSP.jQuery(this).parent().removeClass("Ldt-createAnnotation-active-button"); |
205 .removeClass("Ldt-createAnnotation-present-keyword"); |
|
206 } |
204 } |
207 }); |
205 }); |
208 |
206 |
209 this.selector.find(".Ldt-createAnnotation-polemics button").each(function() { |
|
210 var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text()); |
|
211 if (_rx.test(contents)) { |
|
212 IriSP.jQuery(this).addClass("Ldt-createAnnotation-polemic-active"); |
|
213 } else { |
|
214 IriSP.jQuery(this).removeClass("Ldt-createAnnotation-polemic-active"); |
|
215 } |
|
216 }); |
|
217 if (this.polemic_mode) { |
|
218 /* Also go through the polemics to highlight the buttons */ |
|
219 for (var polemic in this.polemics) { |
|
220 /* Add the active class to the button */ |
|
221 var classname = "Ldt-createAnnotation-polemic-" + this.polemics[polemic]; |
|
222 if (contents.indexOf(polemic) != -1) { |
|
223 this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active"); |
|
224 } else { |
|
225 if (this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active")) |
|
226 this.selector.find("." + classname).removeClass("Ldt-createAnnotation-polemic-active") |
|
227 } |
|
228 } |
|
229 } |
|
230 }; |
207 }; |
231 |
208 |
232 IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
209 IriSP.createAnnotationWidget.prototype.showStartScreen = function() { |
233 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
210 this.selector.find(".Ldt-createAnnotation-screen").hide(); |
234 this.selector.find(".Ldt-createAnnotation-startScreen").show(); |
211 this.selector.find(".Ldt-createAnnotation-startScreen").show(); |
235 |
212 |
236 var jqTextfield = this.selector.find(".Ldt-createAnnotation-Description"); // handle on the textfield. used for the closure |
213 var jqTextfield = this.selector.find(".Ldt-createAnnotation-Description"); // handle on the textfield. used for the closure |
237 |
214 |
238 /* test if the browser supports the placeholder attribute */ |
215 /* test if the browser supports the placeholder attribute */ |
247 |
224 |
248 this._state = "startScreen"; |
225 this._state = "startScreen"; |
249 }; |
226 }; |
250 |
227 |
251 IriSP.createAnnotationWidget.prototype.showWaitScreen = function() { |
228 IriSP.createAnnotationWidget.prototype.showWaitScreen = function() { |
252 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
229 this.selector.find(".Ldt-createAnnotation-screen").hide(); |
253 this.selector.find(".Ldt-createAnnotation-waitScreen").show(); |
230 this.selector.find(".Ldt-createAnnotation-waitScreen").show(); |
254 this._state = "waitScreen"; |
231 this._state = "waitScreen"; |
255 }; |
232 }; |
256 |
233 |
257 IriSP.createAnnotationWidget.prototype.showErrorScreen = function() { |
234 IriSP.createAnnotationWidget.prototype.showErrorScreen = function() { |
258 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
235 this.selector.find(".Ldt-createAnnotation-screen").hide(); |
259 this.selector.find(".Ldt-createAnnotation-errorScreen").show(); |
236 this.selector.find(".Ldt-createAnnotation-errorScreen").show(); |
260 this._state = "errorScreen"; |
237 this._state = "errorScreen"; |
261 }; |
238 }; |
262 |
239 |
263 /** update show the final screen with links to share the created annotation */ |
240 /** update show the final screen with links to share the created annotation */ |
264 IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) { |
241 IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) { |
265 this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); |
242 this.selector.find(".Ldt-createAnnotation-screen").hide(); |
266 |
243 |
267 if (this.cinecast_version) { |
244 if (this.cinecast_version) { |
268 this.selector.find(".Ldt-createAnnotation-Title").parent().show(); |
245 this.selector.find(".Ldt-createAnnotation-Title").parent().show(); |
269 } |
246 } |
270 |
247 |