src/widgets/Markers.js
changeset 1066 5ef7182907c5
parent 1059 8158421193e3
child 1067 539c9bee5372
--- a/src/widgets/Markers.js	Thu Sep 24 15:51:32 2015 +0200
+++ b/src/widgets/Markers.js	Fri Sep 25 10:44:54 2015 +0200
@@ -31,6 +31,7 @@
     close_after_send: false,
     custom_send_button: false,
     custom_cancel_button: false,
+    preview_mode: false,
 };
 
 IriSP.Widgets.Markers.prototype.template = 
@@ -40,9 +41,10 @@
     + '</div>'
     + '<div class="Ldt-Markers-Inputs">'
     +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenMain">'
-    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-CannotCreate" title="{{l10n.cannot_create}}">+</div>'
+    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-CannotCreate" title="{{#preview_mode}}{{l10n.preview_mode_submit}}{{/preview_mode}}{{^preview_mode}}{{l10n.cannot_create}}{{/preview_mode}}">+</div>'
     +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Create">+</div>'
-    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</div>'
+    +         '{{^preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</div>{{/preview_mode}}'
+    +         '{{#preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-PreviewDelete" title="{{l10n.preview_mode_delete}}">&#10006;</div>{{/preview_mode}}'
     +         '<div class="Ldt-Markers-Info"></div>'
     +     '</div>'
     +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSending">'  
@@ -86,7 +88,8 @@
     '{{#edit}}<div class="Ldt-Markers-MarkerEdit">' + 
         '<textarea class="Ldt-Markers-MarkerTextArea" cols="60" rows="4">{{marker_info}}</textarea>' +
         '<div class="Ldt-Markers-Buttons">' +
-            '<div class="Ldt-Markers-MarkerSend">{{send}}</div>' +
+            '{{^preview_mode}}<div class="Ldt-Markers-MarkerSend">{{send}}</div>{{/preview_mode}}' +
+            '{{#preview_mode}}<div class="Ldt-Markers-MarkerPreviewSend" title="{{preview_mode_text}}">{{send}}</div>{{/preview_mode}}' +
             '<div class="Ldt-Markers-MarkerCancel">{{cancel}}</div>' +
         '</div>' +
     '</div>{{/edit}}'
@@ -96,6 +99,8 @@
         send : "Send",
         submit_delete: "Delete",
         cancel : "Cancel",
+        preview_mode_submit: "You cannot submit a marker in preview mode.",
+        preview_mode_delete: "You cannot delete a marker in preview mode",
         wait_while_processing: "Please wait while your annotation is being processed...",
         delete_text: "The selected marker will be deleted. Continue?",
         error_while_contacting: "An error happened while contacting the server. Your annotation has not been saved.",
@@ -108,6 +113,8 @@
         send : "Envoyer",
         submit_delete: "Supprimer",
         cancel : "Annuler",
+        preview_mode_submit: "Vous ne pouvez pas créer ou éditer de marqueur en mode aperçu",
+        preview_mode_delete: "Vous ne pouvez pas supprimer de marqueur en mode aperçu",
         wait_while_processing: "Veuillez patienter pendant le traitement de votre annotation...",
         delete_text: "Le marqueur sélectionné sera supprimé. Continuer?",
         error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée.",
@@ -165,17 +172,17 @@
 
 IriSP.Widgets.Markers.prototype.updateCreateButtonState = function(_time){
     _this = this
-    var can_create = this.markers.every(function(_marker){   
+    var can_create = this.preview_mode? false : this.markers.every(function(_marker){   
         return ((_time < (_marker.begin-_this.markers_gap))||(_time > (_marker.begin+_this.markers_gap)))
     });
     if (can_create){
-        if ((this.$.find(".Ldt-Markers-Create").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden"))){
+        if ((this.$.find(".Ldt-Markers-Create").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden")||this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))){
             this.$.find(".Ldt-Markers-RoundButton").hide();
             this.$.find(".Ldt-Markers-Create").show();
         }
     }
     else {
-        if ((this.$.find(".Ldt-Markers-CannotCreate").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden"))){
+        if ((this.$.find(".Ldt-Markers-CannotCreate").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden")||this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))){
             this.$.find(".Ldt-Markers-RoundButton").hide();
             this.$.find(".Ldt-Markers-CannotCreate").show();
         }
@@ -207,6 +214,8 @@
     if (this.selectedMarker){
         _divHtml = Mustache.to_html(this.infoTemplate, {
             edit: true,
+            preview_mode: this.preview_mode,
+            preview_mode_text: this.l10n.preview_mode_submit,
             marker_info: this.selectedMarker.description,
             send: this.custom_send_button? this.custom_send_button : this.l10n.send,
             cancel: this.custom_cancel_button? this.custom_cancel_button :this.l10n.cancel
@@ -216,6 +225,8 @@
         _divHtml = Mustache.to_html(this.infoTemplate, {
             edit: true,
             marker_info: "",
+            preview_mode: this.preview_mode,
+            preview_mode_text: this.l10n.preview_mode_submit,
             send: this.custom_send_button? this.custom_send_button : this.l10n.send,
             cancel: this.custom_cancel_button? this.custom_cancel_button :this.l10n.cancel
         })
@@ -225,7 +236,12 @@
     this.$.find(".Ldt-Markers-MarkerCancel").click(this.functionWrapper("cancelEdit"));
     this.$.find(".Ldt-Markers-MarkerTextArea").bind("change keyup input paste", this.functionWrapper("onDescriptionChange"));
     this.$.find(".Ldt-Markers-RoundButton").hide();
-    this.$.find(".Ldt-Markers-Delete").show();
+    if (this.preview_mode){
+        this.$.find(".Ldt-Markers-PreviewDelete").show(); 
+    }
+    else {
+        this.$.find(".Ldt-Markers-Delete").show();
+    }
     this.editing = true;
 }
 
@@ -237,7 +253,9 @@
             marker_info: this.selectedMarker.description,
         })
         this.$.find(".Ldt-Markers-Info").html(_divHtml);
-        this.$.find(".Ldt-Markers-MarkerDescription").click(this.functionWrapper("startEdit"));
+        if (!this.preview_mode){
+            this.$.find(".Ldt-Markers-MarkerDescription").click(this.functionWrapper("startEdit"));
+        }
     }
     else {
         // Clic sur "cancel" pendant la création d'un marqueur = retour à l'état initial
@@ -287,7 +305,12 @@
         this.cancelEdit();
         if (this.selectedMarker){
             this.$.find(".Ldt-Markers-RoundButton").hide();
-            this.$.find(".Ldt-Markers-Delete").show();
+            if (this.preview_mode){
+                this.$.find(".Ldt-Markers-PreviewDelete").show(); 
+            }
+            else {
+                this.$.find(".Ldt-Markers-Delete").show();
+            }
         }
         else {
             this.$.find(".Ldt-Markers-RoundButton").hide();
@@ -386,9 +409,16 @@
                   })
                   
                   _this.$.find(".Ldt-Markers-Info").html(_divHtml);
-                  _this.$.find(".Ldt-Markers-MarkerDescription").click(_this.functionWrapper("startEdit"));
+                  if (!_this.preview_mode){
+                      _this.$.find(".Ldt-Markers-MarkerDescription").click(_this.functionWrapper("startEdit"));
+                  }
                   _this.$.find(".Ldt-Markers-RoundButton").hide();
-                  _this.$.find(".Ldt-Markers-Delete").show();
+                  if (_this.preview_mode){
+                      _this.$.find(".Ldt-Markers-PreviewDelete").show(); 
+                  }
+                  else {
+                      _this.$.find(".Ldt-Markers-Delete").show();
+                  }
 
                }
                else {