diff -r 77658c018e83 -r 5ef7182907c5 src/widgets/Markers.js --- 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 @@ + '' + '
' + '
' - + '
+
' + + '
+
' + '
+
' - + '
' + + '{{^preview_mode}}
{{/preview_mode}}' + + '{{#preview_mode}}
{{/preview_mode}}' + '
' + '
' + '
' @@ -86,7 +88,8 @@ '{{#edit}}
' + '' + '
' + - '
{{send}}
' + + '{{^preview_mode}}
{{send}}
{{/preview_mode}}' + + '{{#preview_mode}}
{{send}}
{{/preview_mode}}' + '
{{cancel}}
' + '
' + '
{{/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 {