Small fixes in Player
authorveltr
Fri, 07 Jun 2013 16:17:31 +0200
changeset 15 01ac2cd2756c
parent 14 f8a0d5d14372
child 16 471bbaa78d0c
Small fixes in Player
player/css/styles.css
player/js/ldt-serializer.js
player/js/player.js
--- a/player/css/styles.css	Thu May 30 19:06:05 2013 +0200
+++ b/player/css/styles.css	Fri Jun 07 16:17:31 2013 +0200
@@ -287,10 +287,11 @@
 
 .annotation {
     left: 45px; top: 800px; right: 35px;
+    transition: top 0.8s; -webkit-transition: top 0.8s;
 }
 
 .annotation-main:after {
-    content: "."; visibility: hidden; display: block; height: 1px; clear: both;
+    content: "."; visibility: hidden; display: block; height: 0; line-height: 0; clear: both;
 }
 
 /* Narrow annotations */
@@ -348,23 +349,30 @@
 
 .text-contents {
     font-family: Georgia, 'Times New Roman', serif;
-    margin: 0 45px 35px;
+    margin: 0 45px 35px; font-size: 15px;
+    
+}
+
+.text-contents p, .text-contents ul, .text-contents ol {
+/*    column-break-inside:avoid; -moz-column-break-inside:avoid; -webkit-column-break-inside:avoid; */
+    margin-bottom: 10px;
+}
+
+.text-contents h2, .text-contents h3, .text-contents h4 {
+/*    text-align: center; */
+    font-family: 'Futura-Medium'; margin-bottom: 10px; line-height: 1.1em;
+}
+
+.text-contents img {
+    float: left; margin: 0 5px 2px 0;
+}
+/*
+.column-group {
     column-count: 2; column-gap: 60px;
     -moz-column-count: 2; -moz-column-gap: 60px;
     -webkit-column-count: 2; -webkit-column-gap: 60px;
 }
-
-.text-contents p, .text-contents ul, .text-contents ol {
-    column-break-inside:avoid; -moz-column-break-inside:avoid; -webkit-column-break-inside:avoid;
-    margin-bottom: 10px; font-size: 15px;
-}
-
-.text-contents h2, .text-contents h3, .text-contents h4 {
-    font-family: 'Futura-Medium'; margin-bottom: 10px; line-height: 1.1em;
-    column-break-after:avoid; -moz-column-break-after:avoid; -webkit-column-break-after:avoid;
-    column-break-inside:avoid; -moz-column-break-inside:avoid; -webkit-column-break-inside:avoid;
-}
-
+*/
 .text-contents h2 {
     font-size: 21px;
 }
@@ -419,7 +427,7 @@
 /* Audio annotation */
 
 .audio-annotation .media-description {
-    margin: 25px 0 0; font-size: 15px; font-weight: bold;
+    margin: 25px 0 0; font-size: 15px;
 }
 
 .audio-annotation .annotation-main {
--- a/player/js/ldt-serializer.js	Thu May 30 19:06:05 2013 +0200
+++ b/player/js/ldt-serializer.js	Fri Jun 07 16:17:31 2013 +0200
@@ -58,7 +58,22 @@
                         "id-ref": _data.id
                     },
                     items: _source.getAnnotationTypes().filter(function(_at) {
-                        return _at.media === _data;
+                        switch (typeof _at.media) {
+                            case "object":
+                                return (_at.media === _data);
+                            case "string":
+                                return (_at.media === _data.id);
+                            default:
+                                var _ann = _at.getAnnotations();
+                                if (_ann) {
+                                    for (var i = 0; i < _ann.length; i++) {
+                                        if (_ann[i].getMedia() === _data) {
+                                            return true;
+                                        }
+                                    }
+                                }
+                        }
+                        return false;
                     }).map(function(_at) {
                         return {
                             "id-ref": _at.id
@@ -78,6 +93,9 @@
                 return _res;        
             },
             serializer : function(_data, _source, _dest) {
+                if (_source.regenerateTags && !_data.regenerated) {
+                    return;
+                }
                 var _res = {
                     id : _data.id,
                     meta : {
@@ -179,12 +197,20 @@
                         "dc:creator" : _data.creator || _source.creator,
                         "dc:contributor" : _data.contributor || _source.contributor || _data.creator || _source.creator,
 //                        project : _source.projectId
-                    },
-                    tags : IriSP._(_data.tag.id).map(function(_id) {
+                    }
+                }
+                if (_source.regenerateTags) {
+                    _res.tags = IriSP._(_data.keywords).map(function(_kw) {
+                        return {
+                            "id-ref": _source.__keywords[_kw.toLowerCase()].id
+                        } 
+                    });
+                } else {
+                    _res.tags = IriSP._(_data.tag.id).map(function(_id) {
                        return {
                            "id-ref" : _id
                        } 
-                    })
+                    });
                 }
                 _res.content.title = _data.title || _res.content.title || "";
                 _dest.annotations.push(_res);
@@ -248,6 +274,24 @@
                 annotations: []
             },
             _this = this;
+        if (_source.regenerateTags) {
+            _source.__keywords = {};
+            _source.getAnnotations().forEach(function(a) {
+                IriSP._(a.keywords).each(function(kw) {
+                    var lkw = kw.toLowerCase();
+                    if (typeof _source.__keywords[lkw] === "undefined") {
+                        _source.__keywords[lkw] = {
+                            id: IriSP.Model.getUID(),
+                            title: kw,
+                            regenerated: true
+                        }
+                    }
+                });
+            });
+            IriSP._(_source.__keywords).each(function(kw) {
+                _this.types.tag.serializer(kw, _source, _res);
+            })
+        }
         _source.forEach(function(_list, _typename) {
             if (typeof _this.types[_typename] !== "undefined") {
                 _list.forEach(function(_el) {
@@ -287,6 +331,9 @@
             _source.projectId = _data.meta.id;
             _source.title = _data.meta["dc:title"] || _data.meta.title || "";
             _source.description = _data.meta["dc:description"] || _data.meta.description || "";
+            _source.creator = _data.meta["dc:creator"] || _data.meta.creator || "";
+            _source.contributor = _data.meta["dc:contributor"] || _data.meta.contributor || _source.creator;
+            _source.created = IriSP.Model.isoToDate(_data.meta["dc:created"] || _data.meta.created);
         }
         
         if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") {
--- a/player/js/player.js	Thu May 30 19:06:05 2013 +0200
+++ b/player/js/player.js	Fri Jun 07 16:17:31 2013 +0200
@@ -272,15 +272,10 @@
         annotationDiv.find(".annotation-title").text(annotationinfo.annotation.title);
         
                 
-        var positionDiv = function(anim) {
-            var css = {
+        var positionDiv = function() {
+            annotationDiv.css({
                 top: Math.floor(($(".main-video").height() - annotationDiv.height())/2)+"px"
-            };
-            if (anim) {
-                annotationDiv.animate(css, 800);
-            } else {
-                annotationDiv.css(css);
-            }
+            });
         }
         
         switch (annotationinfo.type) {
@@ -299,7 +294,6 @@
                     var w = imgel.width(),
                         h = imgel.height();
                     annotationDiv.find(".annotation-main").css("height","");
-                    annotationDiv.find(".slideshow-description").css("margin-left",w);
                     var h2 = annotationDiv.find(".annotation-main").height();
                     if (h < h2) {
                         imgel.css("margin-top",Math.floor((h2-h)/2)+"px");
@@ -438,7 +432,7 @@
                         },
                         success: function(data) {
                             annotationDiv.find(".media-frame").html(data.html);
-                            positionDiv(true);
+                            positionDiv();
                         }
                     });
                     return;
@@ -456,7 +450,7 @@
                         },
                         success: function(data) {
                             annotationDiv.find(".media-frame").html(data.html);
-                            positionDiv(true);
+                            positionDiv();
                         }
                     });
                     return;
@@ -476,7 +470,7 @@
                         },
                         success: function(data) {
                             annotationDiv.find(".media-frame").html(data.html);
-                            positionDiv(true);
+                            positionDiv();
                         }
                     });
                     return;
@@ -500,7 +494,7 @@
                 }));
                 
                 media.on("loadedmetadata", function() {
-                    positionDiv(true);
+                    positionDiv();
                 });
                 
                 annotationDiv.find(".media-frame").html(media);
@@ -515,6 +509,26 @@
                 switch (annotationinfo.annotation.content.markup) {
                     case "html":
                         annotationDiv.find(".text-contents").html(text);
+/*
+                        var ps = annotationDiv.find(".text-contents>p"),
+                            groups = [],
+                            last, group;
+                        ps.each(function(i, e) {
+                            if (last && group && last.nextElementSibling === e) {
+                                group.contents.push(e);
+                            } else {
+                                group = {
+                                    master: e,
+                                    contents: [e.cloneNode(true)]
+                                }
+                                groups.push(group);
+                            }
+                            last = e;
+                        });
+                        groups.forEach(function(g) {
+                            $(g.master).replaceWith($('<div class="column-group">').append(g.contents));
+                        });
+*/
                     break;
                     default:
                         annotationDiv.find(".text-contents").html(