Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
authordurandn
Thu, 25 Jun 2015 11:00:41 +0200
changeset 1390 e165d0d979e9
parent 1389 a2316b574499
child 1391 2b17782e7c08
Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
src/ldt/ldt/ldt_utils/views/ldt_json.py
src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css
src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js
src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js
--- a/src/ldt/ldt/ldt_utils/views/ldt_json.py	Wed Jun 10 18:36:40 2015 +0200
+++ b/src/ldt/ldt/ldt_utils/views/ldt_json.py	Thu Jun 25 11:00:41 2015 +0200
@@ -73,7 +73,7 @@
     if one_content_str:
         one_content_bool = {'true': True, 'false': False, "0": False, "1": True}.get(one_content_str.lower())
     
-    from_display_str = request.GET.get("from_display")
+    from_display_str = request.GET.get("from_display", "")
     from_display_bool = True
     if from_display_str:
         from_display_bool = {'true': True, 'false': False, "0": False, "1": True}.get(from_display_str.lower())
--- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css	Wed Jun 10 18:36:40 2015 +0200
+++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css	Thu Jun 25 11:00:41 2015 +0200
@@ -50,10 +50,9 @@
 }
 .Ldt-AnnotationsList-CreationDate {
     color: #f7268e;
-    float: left;
     text-align: left;
     font-size: 12px;
-    margin: 2px;
+    margin: 2px 2px 0 82px;
 }
 h3.Ldt-AnnotationsList-Title {
     color: #0068c4;
--- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js	Wed Jun 10 18:36:40 2015 +0200
+++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js	Thu Jun 25 11:00:41 2015 +0200
@@ -33,6 +33,8 @@
     refresh_interval : 0,
     limit_count : 20,
     newest_first : false,
+    always_visible : false,
+    start_visible: true,
     show_audio: true,
     show_creation_date: false,
     /*
@@ -44,6 +46,11 @@
      * Set to a username if you only want to display annotations from a given user
      */
     show_only_annotation_from_user: false,
+    /*
+     * Show a text field that filter annotations by username
+     */
+    filter_by_user: false,
+    
     polemics : [{
         keyword: "++",
         background_color: "#c9ecc6"
@@ -171,7 +178,9 @@
             return (_currentTime >= _segment.begin && _currentTime <= _segment.end)
         });
         if (_current_segments.length == 0) {
-            _list = [];
+            _list = _list.filter(function(_annotation){
+                return false;
+            })
         }
         else {
             _list = _list.filter(function(_annotation){
@@ -363,9 +372,35 @@
             }
         }
     }
+    
     return _list.length;
 };
 
+IriSP.Widgets.AnnotationsList.prototype.hide = function() {
+    if (this.visible){
+        this.visible = false;
+        this.list_$.slideUp()
+    }
+}
+
+IriSP.Widgets.AnnotationsList.prototype.show = function() {
+    if(!this.visible){
+        this.visible = true;
+        this.list_$.slideDown()
+    }
+}
+
+
+IriSP.Widgets.AnnotationsList.prototype.toggle = function() {
+    if (!this.always_visible) {
+        if (this.visible) {
+            this.hide();
+        } else {
+            this.show();
+        }
+    }
+};
+
 IriSP.Widgets.AnnotationsList.prototype.draw = function() {
     
     this.jwplayers = {};
@@ -428,7 +463,11 @@
         }, this.refresh_interval);
     }
     
-    this.onMdpEvent("createAnnotationWidget.addedAnnotation");
+    this.onMdpEvent("AnnotationsList.toggle","toggle");
+    this.onMdpEvent("AnnotationsList.hide", "hide");
+    this.onMdpEvent("AnnotationsList.show", "show");
+    
+    this.onMdpEvent("createAnnotationWidget.addedAnnotation", "refresh");
     var _events = [
         "timeupdate",
         "seeked",
@@ -439,5 +478,10 @@
     }
     
     this.throttledRefresh();
-
+    
+    this.visible = true;
+    if (!this.start_visible){
+        this.hide();
+    }
+    
 };
--- a/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js	Wed Jun 10 18:36:40 2015 +0200
+++ b/src/ldt/ldt/static/ldt/metadataplayer/CreateAnnotation.js	Thu Jun 25 11:00:41 2015 +0200
@@ -254,6 +254,8 @@
     }
     
     this.onMdpEvent("CreateAnnotation.toggle","toggle");
+    this.onMdpEvent("CreateAnnotation.hide", "hide");
+    this.onMdpEvent("CreateAnnotation.show", "show");
     this.$.find("form").submit(this.functionWrapper("onSubmit"));
 };
 
@@ -263,34 +265,38 @@
 }
 
 IriSP.Widgets.CreateAnnotation.prototype.show = function() {
-    this.visible = true;
-    this.showScreen('Main');
-    this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty");
-    if (this.show_title_field) {
-        this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty");
-    }
-    if (this.show_creator_field) {
-        this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666");
-        if (!this.creator_name) {
-            this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
+    if (!this.visible){
+        this.visible = true;
+        this.showScreen('Main');
+        this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty");
+        if (this.show_title_field) {
+            this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty");
         }
-    }
-    this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
-    this.$.slideDown();
-    if (this.minimize_annotation_widget) {
-        this.player.trigger("Annotation.minimize");
+        if (this.show_creator_field) {
+            this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666");
+            if (!this.creator_name) {
+                this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
+            }
+        }
+        this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected");
+        this.$.slideDown();
+        if (this.minimize_annotation_widget) {
+            this.player.trigger("Annotation.minimize");
+        }
     }
 };
 
 IriSP.Widgets.CreateAnnotation.prototype.hide = function() {
-    if (this.recorder) {
-        this.recorder.stopRecord();
-    }
-    if (!this.always_visible) {
-        this.visible = false;
-        this.$.slideUp();
-        if (this.minimize_annotation_widget) {
-            this.player.trigger("Annotation.maximize");
+    if (this.visible){
+        if (this.recorder) {
+            this.recorder.stopRecord();
+        }
+        if (!this.always_visible) {
+            this.visible = false;
+            this.$.slideUp();
+            if (this.minimize_annotation_widget) {
+                this.player.trigger("Annotation.maximize");
+            }
         }
     }
 };