src/widgets/CreateAnnotation.js
changeset 1013 392ddcd212d7
parent 1003 a4dc93a91a95
child 1021 7253d4d06f0d
equal deleted inserted replaced
1012:7e18d953a1f8 1013:392ddcd212d7
    45     api_endpoint_template: "",
    45     api_endpoint_template: "",
    46     api_method: "POST",
    46     api_method: "POST",
    47     after_send_timeout: 0,
    47     after_send_timeout: 0,
    48     close_after_send: false,
    48     close_after_send: false,
    49     tag_prefix: "#"
    49     tag_prefix: "#"
    50 }
    50 };
    51 
    51 
    52 IriSP.Widgets.CreateAnnotation.prototype.messages = {
    52 IriSP.Widgets.CreateAnnotation.prototype.messages = {
    53     en: {
    53     en: {
    54         from_time: "from",
    54         from_time: "from",
    55         to_time: "to",
    55         to_time: "to",
    90         "polemic++": "Accord",
    90         "polemic++": "Accord",
    91         "polemic--": "Désaccord",
    91         "polemic--": "Désaccord",
    92         "polemic??": "Question",
    92         "polemic??": "Question",
    93         "polemic==": "Référence"
    93         "polemic==": "Référence"
    94     }
    94     }
    95 }
    95 };
    96 
    96 
    97 IriSP.Widgets.CreateAnnotation.prototype.template =
    97 IriSP.Widgets.CreateAnnotation.prototype.template =
    98     '{{#show_slice}}<div class="Ldt-CreateAnnotation-Slice"></div>{{/show_slice}}'
    98     '{{#show_slice}}<div class="Ldt-CreateAnnotation-Slice"></div>{{/show_slice}}'
    99     + '{{^show_slice}}{{#show_arrow}}<div class="Ldt-CreateAnnotation-Arrow"></div>{{/show_arrow}}{{/show_slice}}'
    99     + '{{^show_slice}}{{#show_arrow}}<div class="Ldt-CreateAnnotation-Arrow"></div>{{/show_arrow}}{{/show_slice}}'
   100     + '<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">'
   100     + '<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">'
   245         this.hide();
   245         this.hide();
   246     }
   246     }
   247     
   247     
   248     this.onMdpEvent("CreateAnnotation.toggle","toggle");
   248     this.onMdpEvent("CreateAnnotation.toggle","toggle");
   249     this.$.find("form").submit(this.functionWrapper("onSubmit"));
   249     this.$.find("form").submit(this.functionWrapper("onSubmit"));
   250 }
   250 };
   251 
   251 
   252 IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) {
   252 IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) {
   253     this.$.find('.Ldt-CreateAnnotation-' + _screenName).show()
   253     this.$.find('.Ldt-CreateAnnotation-' + _screenName).show()
   254         .siblings().hide();
   254         .siblings().hide();
   255 }
   255 }
   270     this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
   270     this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
   271     this.$.slideDown();
   271     this.$.slideDown();
   272     if (this.minimize_annotation_widget) {
   272     if (this.minimize_annotation_widget) {
   273         this.player.trigger("Annotation.minimize");
   273         this.player.trigger("Annotation.minimize");
   274     }
   274     }
   275 }
   275 };
   276 
   276 
   277 IriSP.Widgets.CreateAnnotation.prototype.hide = function() {
   277 IriSP.Widgets.CreateAnnotation.prototype.hide = function() {
   278     if (this.recorder) {
   278     if (this.recorder) {
   279         this.recorder.stopRecord();
   279         this.recorder.stopRecord();
   280     }
   280     }
   283         this.$.slideUp();
   283         this.$.slideUp();
   284         if (this.minimize_annotation_widget) {
   284         if (this.minimize_annotation_widget) {
   285             this.player.trigger("Annotation.maximize");
   285             this.player.trigger("Annotation.maximize");
   286         }
   286         }
   287     }
   287     }
   288 }
   288 };
   289 
   289 
   290 IriSP.Widgets.CreateAnnotation.prototype.toggle = function() {
   290 IriSP.Widgets.CreateAnnotation.prototype.toggle = function() {
   291     if (!this.always_visible) {
   291     if (!this.always_visible) {
   292         if (this.visible) {
   292         if (this.visible) {
   293             this.hide();
   293             this.hide();
   294         } else {
   294         } else {
   295             this.show();
   295             this.show();
   296         }
   296         }
   297     }
   297     }
   298 }
   298 };
   299 
   299 
   300 IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) {
   300 IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) {
   301     var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
   301     var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
   302         _rx = IriSP.Model.regexpFromTextOrArray(_keyword),
   302         _rx = IriSP.Model.regexpFromTextOrArray(_keyword),
   303         _contents = _field.val();
   303         _contents = _field.val();
   305         ? _contents.replace(_rx,"")
   305         ? _contents.replace(_rx,"")
   306         : _contents + " " + _keyword
   306         : _contents + " " + _keyword
   307     );
   307     );
   308     _field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,''));
   308     _field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,''));
   309     this.onDescriptionChange();
   309     this.onDescriptionChange();
   310 }
   310 };
   311 
   311 
   312 IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() {
   312 IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() {
   313     if (this.pause_on_write && !this.media.getPaused()) {
   313     if (this.pause_on_write && !this.media.getPaused()) {
   314         this.media.pause();
   314         this.media.pause();
   315     }
   315     }
   316 }
   316 };
   317 
   317 
   318 IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() {
   318 IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function() {
   319     var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
   319     var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
   320         _contents = _field.val();
   320         _contents = _field.val();
   321     _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
   321     _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
   332             IriSP.jQuery(this).removeClass("selected");
   332             IriSP.jQuery(this).removeClass("selected");
   333         }
   333         }
   334     });
   334     });
   335     this.pauseOnWrite();
   335     this.pauseOnWrite();
   336     return !!_contents;
   336     return !!_contents;
   337 }
   337 };
   338 
   338 
   339 IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() {
   339 IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() {
   340     var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
   340     var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
   341         _contents = _field.val();
   341         _contents = _field.val();
   342     _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
   342     _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
   345     } else {
   345     } else {
   346         _field.addClass("empty");
   346         _field.addClass("empty");
   347     }
   347     }
   348     this.pauseOnWrite();
   348     this.pauseOnWrite();
   349     return !!_contents;
   349     return !!_contents;
   350 }
   350 };
   351 
   351 
   352 
   352 
   353 IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() {
   353 IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() {
   354     var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
   354     var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
   355         _contents = _field.val();
   355         _contents = _field.val();
   359     } else {
   359     } else {
   360         _field.addClass("empty");
   360         _field.addClass("empty");
   361     }
   361     }
   362     this.pauseOnWrite();
   362     this.pauseOnWrite();
   363     return !!_contents;
   363     return !!_contents;
   364 }
   364 };
   365 
   365 
   366 /* Fonction effectuant l'envoi des annotations */
   366 /* Fonction effectuant l'envoi des annotations */
   367 IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() {
   367 IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() {
   368     /* Si les champs obligatoires sont vides, on annule l'envoi */
   368     /* Si les champs obligatoires sont vides, on annule l'envoi */
   369     if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) {
   369     if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) {
   482         }
   482         }
   483     });
   483     });
   484     this.showScreen('Wait');
   484     this.showScreen('Wait');
   485     
   485     
   486     return false;
   486     return false;
   487 }
   487 };
   488 
   488