39 }], |
39 }], |
40 annotation_type: "Contributions", |
40 annotation_type: "Contributions", |
41 api_serializer: "ldt_annotate", |
41 api_serializer: "ldt_annotate", |
42 api_endpoint_template: "", |
42 api_endpoint_template: "", |
43 api_method: "PUT", |
43 api_method: "PUT", |
44 close_widget_timeout: 0 |
44 after_send_timeout: 0, |
|
45 close_after_send: false, |
45 } |
46 } |
46 |
47 |
47 IriSP.Widgets.CreateAnnotation.prototype.messages = { |
48 IriSP.Widgets.CreateAnnotation.prototype.messages = { |
48 en: { |
49 en: { |
49 from_time: "from", |
50 from_time: "from", |
136 }); |
137 }); |
137 // We have to use the map function because Mustache doesn't like our tags object |
138 // We have to use the map function because Mustache doesn't like our tags object |
138 } |
139 } |
139 this.renderTemplate(); |
140 this.renderTemplate(); |
140 this.$.find(".Ldt-CreateAnnotation-Close").click(function() { |
141 this.$.find(".Ldt-CreateAnnotation-Close").click(function() { |
141 _this.hide(); |
142 _this.close_after_send |
|
143 ? _this.hide() |
|
144 : _this.showScreen("Main"); |
142 return false; |
145 return false; |
143 }); |
146 }); |
144 this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() { |
147 this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() { |
145 _this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
148 _this.addKeyword(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
146 return false; |
149 return false; |
220 |
223 |
221 IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) { |
224 IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) { |
222 var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
225 var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
223 _rx = IriSP.Model.regexpFromTextOrArray(_keyword), |
226 _rx = IriSP.Model.regexpFromTextOrArray(_keyword), |
224 _contents = _field.val(); |
227 _contents = _field.val(); |
225 _contents = ( _rx.test(_contents) |
228 _contents = ( !!_contents.match(_rx) |
226 ? _contents.replace(_rx,"") |
229 ? _contents.replace(_rx,"") |
227 : _contents + " " + _keyword |
230 : _contents + " " + _keyword |
228 ); |
231 ); |
229 _field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,'')); |
232 _field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,'')); |
230 this.onDescriptionChange(); |
233 this.onDescriptionChange(); |
240 var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
243 var _field = this.$.find(".Ldt-CreateAnnotation-Description"), |
241 _contents = _field.val(); |
244 _contents = _field.val(); |
242 _field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
245 _field.css("border-color", !!_contents ? "#666666" : "#ff0000"); |
243 this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() { |
246 this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() { |
244 var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
247 var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); |
245 if (_rx.test(_contents)) { |
248 if (_contents.match(_rx)) { |
246 IriSP.jQuery(this).addClass("selected"); |
249 IriSP.jQuery(this).addClass("selected"); |
247 } else { |
250 } else { |
248 IriSP.jQuery(this).removeClass("selected"); |
251 IriSP.jQuery(this).removeClass("selected"); |
249 } |
252 } |
250 }); |
253 }); |
312 type: this.api_method, |
315 type: this.api_method, |
313 contentType: 'application/json', |
316 contentType: 'application/json', |
314 data: _export.serialize(), |
317 data: _export.serialize(), |
315 success: function(_data) { |
318 success: function(_data) { |
316 _this.showScreen('Saved'); |
319 _this.showScreen('Saved'); |
317 if (_this.close_widget_timeout) { |
320 if (_this.after_send_timeout) { |
318 window.setTimeout(_this.functionWrapper("hide"),_this.close_widget_timeout); |
321 window.setTimeout( |
|
322 function() { |
|
323 _this.close_after_send |
|
324 ? _this.hide() |
|
325 : _this.showScreen("Main"); |
|
326 }, |
|
327 _this.after_send_timeout |
|
328 ); |
319 } |
329 } |
320 _export.getAnnotations().removeElement(_annotation, true); |
330 _export.getAnnotations().removeElement(_annotation, true); |
321 _export.deSerialize(_data); |
331 _export.deSerialize(_data); |
322 _this.source.merge(_export); |
332 _this.source.merge(_export); |
323 if (this.pause_on_write && this.player.popcorn.media.paused) { |
333 if (this.pause_on_write && this.player.popcorn.media.paused) { |
330 _export.getAnnotations().removeElement(_annotation, true); |
340 _export.getAnnotations().removeElement(_annotation, true); |
331 _this.showScreen('Error'); |
341 _this.showScreen('Error'); |
332 window.setTimeout(function(){ |
342 window.setTimeout(function(){ |
333 _this.showScreen("Main") |
343 _this.showScreen("Main") |
334 }, |
344 }, |
335 (_this.close_widget_timeout || 5000)); |
345 (_this.after_send_timeout || 5000)); |
336 } |
346 } |
337 }); |
347 }); |
338 this.showScreen('Wait'); |
348 this.showScreen('Wait'); |
339 |
349 |
340 return false; |
350 return false; |