Corrections on Marker widget and scenario for remie
authordurandn
Tue, 15 Sep 2015 15:12:08 +0200
changeset 126 d23705b04d7b
parent 125 d2142a047ed2
child 127 0de175cdcb7f
Corrections on Marker widget and scenario for remie
server/src/remie/static/remie/css/markers.css
server/src/remie/static/remie/metadataplayer/Markers.css
server/src/remie/static/remie/metadataplayer/Markers.js
server/src/remie/templates/remie/iframe_markers.html
--- a/server/src/remie/static/remie/css/markers.css	Fri Sep 11 14:07:22 2015 +0200
+++ b/server/src/remie/static/remie/css/markers.css	Tue Sep 15 15:12:08 2015 +0200
@@ -173,11 +173,18 @@
     overflow: hidden;
 }
 .Ldt-Markers-Screen.Ldt-Markers-ScreenMain .Ldt-Markers-RoundButton.Ldt-Markers-Delete{
-    font-size: 80px;
-    line-height: 5px;
-    text-indent: -2px;
+    font-size: 35px;
+    line-height: 20px;
+    text-indent: 2px;
     background-color: #CD000B;
+    border-color: #4d0004;
 }
+
+.Ldt-Markers-Screen.Ldt-Markers-ScreenMain .Ldt-Markers-RoundButton.Ldt-Markers-Delete:hover{
+    background-color: #CD000B;
+    border-color: #9f9ea1;
+}
+
 .Ldt-Markers-Screen.Ldt-Markers-ScreenMain .Ldt-Markers-RoundButton.Ldt-Markers-Create, 
 .Ldt-Markers-Screen.Ldt-Markers-ScreenMain .Ldt-Markers-RoundButton.Ldt-Markers-CannotCreate {
     font-size: 45px;
--- a/server/src/remie/static/remie/metadataplayer/Markers.css	Fri Sep 11 14:07:22 2015 +0200
+++ b/server/src/remie/static/remie/metadataplayer/Markers.css	Tue Sep 15 15:12:08 2015 +0200
@@ -61,6 +61,11 @@
 	border-color: #797979 #444444 #222222 #696969;
 }
 
+.Ldt-Markers-RoundButton.Ldt-Markers-Delete{
+	line-height: 23px;
+	text-indent: 2px;
+}
+
 .Ldt-Markers-Info{
 	height: 125px;
 	width: 90%;
--- a/server/src/remie/static/remie/metadataplayer/Markers.js	Fri Sep 11 14:07:22 2015 +0200
+++ b/server/src/remie/static/remie/metadataplayer/Markers.js	Tue Sep 15 15:12:08 2015 +0200
@@ -15,6 +15,7 @@
     selected_color: "#74d600",
     ball_radius: 4,
     pause_on_write: true,
+    play_on_submit: true,
     api_serializer: "ldt_annotate",
     api_endpoint_template_create: "",
     api_endpoint_template_edit: "",
@@ -26,6 +27,7 @@
     creator_name: "",
     after_send_timeout: 0,
     markers_gap: 2000,
+    allow_empty_markers: false,
     close_after_send: false,
     custom_send_button: false,
     custom_cancel_button: false,
@@ -40,7 +42,7 @@
     +     '<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-Create">+</div>'
-    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">-</div>'
+    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</div>'
     +         '<div class="Ldt-Markers-Info"></div>'
     +     '</div>'
     +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSending">'  
@@ -142,15 +144,13 @@
         background: this.background
     });
     
-    this.$.find(".Ldt-Markers-Close").click(function() {
-        _this.showScreen("Main");
-        _this.cancelEdit();
-    });
+    this.$.find(".Ldt-Markers-Close").click(this.functionWrapper("revertToMainScreen"));
     
-    this.onMediaEvent("timeupdate", "updatePosition");
-    this.onMediaEvent("timeupdate", "updateCreateButtonState");
+    this.onMediaEvent("timeupdate", this.functionWrapper("updatePosition"));
+    this.onMediaEvent("timeupdate", this.functionWrapper("updateCreateButtonState"));
+    this.onMediaEvent("play", this.functionWrapper("clearSelectedMarker"));
     this.onMdpEvent("Markers.refresh", this.functionWrapper("drawMarkers"));
-    
+   
     this.newMarkerTimeCode = 0;
     this.selectedMarker = false;
 }
@@ -216,8 +216,8 @@
         _divHtml = Mustache.to_html(this.infoTemplate, {
             edit: true,
             marker_info: "",
-            send: this.l10n.send,
-            cancel: this.l10n.cancel,
+            send: this.custom_send_button? this.custom_send_button : this.l10n.send,
+            cancel: this.custom_cancel_button? this.custom_cancel_button :this.l10n.cancel
         })
     }
     this.$.find(".Ldt-Markers-Info").html(_divHtml);
@@ -251,16 +251,23 @@
 }
 
 IriSP.Widgets.Markers.prototype.onDescriptionChange = function(){
-    var _field = this.$.find(".Ldt-Markers-MarkerTextArea"),
-        _contents = _field.val();
-    _field.css("border-color", !!_contents ? "#e87d9f" : "#ff0000");
-    if (!!_contents) {
-        _field.removeClass("empty");
-    } else {
-        _field.addClass("empty");
+    // Returns false if the textarea is empty, true if there is text in it
+    if(!this.allow_empty_markers){
+        var _field = this.$.find(".Ldt-Markers-MarkerTextArea"),
+            _contents = _field.val();
+        _field.css("border-color", !!_contents ? "#e87d9f" : "#ff0000");
+        if (!!_contents) {
+            _field.removeClass("empty");
+        } else {
+            _field.addClass("empty");
+        }
+        this.pauseOnWrite();
+        return !!_contents;
     }
-    this.pauseOnWrite();
-    return !!_contents;
+    else {
+        // If the widget is configured to allow to post empty markers, it returns true
+        return true
+    }
 };
 
 IriSP.Widgets.Markers.prototype.pauseOnWrite = function(){
@@ -278,6 +285,15 @@
     if (this.$.find(".Ldt-Markers-ScreenMain").is(":hidden")){
         this.showScreen("Main");
         this.cancelEdit();
+        if (this.selectedMarker){
+            this.$.find(".Ldt-Markers-RoundButton").hide();
+            this.$.find(".Ldt-Markers-Delete").show();
+        }
+        else {
+            this.$.find(".Ldt-Markers-RoundButton").hide();
+            this.$.find(".Ldt-Markers-Create").show();
+            this.updateCreateButtonState();
+        }
     }
 }
 
@@ -304,6 +320,19 @@
     _el.appendTo(list_$);
 }
 
+IriSP.Widgets.Markers.prototype.clearSelectedMarker = function(){
+    if (this.selectedMarker){
+        var _divHtml = "";
+        
+        this.selectedMarker = false;
+        this.$.find(".Ldt-Markers-Info").html(_divHtml);
+        this.$.find(".Ldt-Markers-RoundButton").hide();
+        this.$.find(".Ldt-Markers-Create").show();
+        this.$.find(".Ldt-Markers-MarkerBall").toggleClass("selected", false);
+        this.updateCreateButtonState(this.media.getCurrentTime())
+    }
+}
+
 IriSP.Widgets.Markers.prototype.drawMarkers = function(){
     var _this = this,
         _scale = this.width / this.source.getDuration(),
@@ -364,14 +393,8 @@
                }
                else {
                    // if we click the currently selected marker, we unselect it
-                   var _divHtml = ""
                    _el.children().css("background-color", _this.hover_color);
-                   _this.selectedMarker = false;
-                   list_$.find(".Ldt-Markers-MarkerBall").toggleClass("selected", false);
-                   _this.$.find(".Ldt-Markers-Info").html(_divHtml);
-                   _this.$.find(".Ldt-Markers-RoundButton").hide();
-                   _this.$.find(".Ldt-Markers-Create").show();
-                   _this.updateCreateButtonState(_this.media.getCurrentTime())
+                   _this.clearSelectedMarker();
                }
                
                if (_this.selectedMarker) {
@@ -388,7 +411,7 @@
 IriSP.Widgets.Markers.prototype.onSubmit = function(){
     
     /* Si les champs obligatoires sont vides, on annule l'envoi */
-    if (!this.onDescriptionChange()) {
+    if (!this.allow_empty_markers && !this.onDescriptionChange()){
         return false;
     }
     
@@ -459,7 +482,7 @@
             _export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */
             _annotation.id = _data.id;
             _this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */
-            if (_this.pause_on_write && _this.media.getPaused()) {
+            if (_this.pause_on_write && _this.media.getPaused() && _this.play_on_submit) {
                 _this.media.play();
             }
             _this.markers.push(_annotation);
@@ -490,7 +513,7 @@
         success: function(_data) {
             _this.showScreen('DeleteSuccess'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation enregistrée" */
             window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 5000));
-            if (_this.pause_on_write && _this.media.getPaused()) {
+            if (_this.pause_on_write && _this.media.getPaused() && _this.play_on_submit) {
                 _this.media.play();
             }
             _this.markers.removeElement(_this.selectedMarker);
--- a/server/src/remie/templates/remie/iframe_markers.html	Fri Sep 11 14:07:22 2015 +0200
+++ b/server/src/remie/templates/remie/iframe_markers.html	Tue Sep 15 15:12:08 2015 +0200
@@ -81,6 +81,8 @@
             api_endpoint_template_delete: "{% url 'api_dispatch_list' resource_name='annotations' api_name='1.0' %}{% templatetag openvariable %}annotation_id{% templatetag closevariable %}/",
             creator_name : "{{current_user}}",
             project_id: "{{project_id}}",
+            allow_empty_markers: true,
+            play_on_submit: true,
             custom_send_button: "Sauver",
         }
       ]