Metadataplayer upgrade
authorRaphael Velt <raph.velt@gmail.com>
Wed, 15 May 2013 16:36:30 +0200
changeset 898 196ce9f8751c
parent 895 aa7ad01b8260
child 899 cdcc5249830e
Metadataplayer upgrade
web/res/js/renkan.js
web/res/metadataplayer/HtmlPlayer.js
web/res/metadataplayer/LdtPlayer-core.js
--- a/web/res/js/renkan.js	Fri May 10 14:46:57 2013 +0200
+++ b/web/res/js/renkan.js	Wed May 15 16:36:30 2013 +0200
@@ -1,10 +1,17 @@
           /* *********************************************************
-                  File generated on Wed Apr 24 10:49:26 CEST 2013
+                  File generated on Wed May 15 15:42:55 CEST 2013
           ************************************************************
                           start of      main.js
           ********************************************************* */
 
 /* 
+    _____            _               
+   |  __ \          | |              
+   | |__) |___ _ __ | | ____ _ _ __  
+   |  _  // _ \ '_ \| |/ / _` | '_ \ 
+   | | \ \  __/ | | |   < (_| | | | |
+   |_|  \_\___|_| |_|_|\_\__,_|_| |_|
+
  *  Copyright 2012-2013 Institut de recherche et d'innovation 
  *  contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
  *   
@@ -462,7 +469,8 @@
                 image: this.get("image"),
                 color: this.get("color"),
                 created_by: this.get("created_by") ? this.get("created_by").get("_id") : null,
-                size: this.get("size")
+                size: this.get("size"),
+                "clip-path": this.get("clip-path")
             };
         },
     });
@@ -679,7 +687,10 @@
     force_resize: false,
     allow_double_click: true,
         /* Allows Double Click to create a node on an empty background */
-    element_delete_delay: 5000,
+    element_delete_delay: 0,
+        /* Delay between clicking on the bin on an element and really deleting it
+           Set to 0 for delete confirm */
+    autoscale_padding: 50,
     
     /* MINI-MAP OPTIONS */
     
@@ -687,6 +698,7 @@
         /* Show a small map at the bottom right */
     minimap_width: 160,
     minimap_height: 120,
+    minimap_padding: 20,
     minimap_background_color: "#ffffff",
     minimap_border_color: "#cccccc",
     minimap_highlight_color: "#ffff00",
@@ -704,6 +716,9 @@
         /* Show circles for nodes */
     clip_node_images: true,
         /* Constraint node images to circles */
+    node_images_fill_mode: false,
+        /* Set to false for "letterboxing" (height/width of node adapted to show full image)
+           Set to true for "crop" (adapted to fill circle) */
     node_size_base: 25,
     node_stroke_width: 2,
     selected_node_stroke_width: 4,
@@ -737,7 +752,41 @@
     tooltip_top_color: "#f0f0f0",
     tooltip_bottom_color: "#d0d0d0",
     tooltip_border_color: "#808080",
-    tooltip_border_width: 1
+    tooltip_border_width: 1,
+    
+    /* NODE EDITOR OPTIONS */
+    
+    show_node_editor_uri: true,
+    show_node_editor_description: true,
+    show_node_editor_size: true,
+    show_node_editor_color: true,
+    show_node_editor_image: true,
+    show_node_editor_creator: true,
+    
+    /* NODE TOOLTIP OPTIONS */
+    
+    show_node_tooltip_uri: true,
+    show_node_tooltip_description: true,
+    show_node_tooltip_color: true,
+    show_node_tooltip_image: true,
+    show_node_tooltip_creator: true,
+    
+    /* EDGE EDITOR OPTIONS */
+    
+    show_edge_editor_uri: true,
+    show_edge_editor_color: true,
+    show_edge_editor_direction: true,
+    show_edge_editor_nodes: true,
+    show_edge_editor_creator: true,
+    
+    /* EDGE TOOLTIP OPTIONS */
+    
+    show_edge_tooltip_uri: true,
+    show_edge_tooltip_color: true,
+    show_edge_tooltip_nodes: true,
+    show_edge_tooltip_creator: true
+    
+    /* */
     
 };
 
@@ -834,7 +883,6 @@
           ********************************************************* */
 
 Rkns.Renderer = {
-    _MINIMAP_MARGIN: 20,
     _MIN_DRAG_DISTANCE: 2,
     _NODE_BUTTON_WIDTH: 40,
     _EDGE_BUTTON_INNER: 2,
@@ -846,7 +894,6 @@
     _NODE_SIZE_STEP: Math.LN2/4,
     _MIN_SCALE: 1/20,
     _MAX_SCALE: 20,
-    _AUTOSCALE_MARGIN: 50,
     _MOUSEMOVE_RATE: 80,
     _DOUBLETAP_DELAY: 800,
     _DOUBLETAP_DISTANCE: 20*20,
@@ -1079,15 +1126,14 @@
         var square = new paper.Size(this.circle_radius, this.circle_radius),
             topleft = this.paper_coords.subtract(square),
             bounds = new paper.Rectangle(topleft, square.multiply(2));
-        this.circle.fitBounds(bounds);
+        this.circle.scale(this.circle_radius / this.last_circle_radius);
         if (this.node_image) {
-            this.node_image.fitBounds(bounds);
+            this.node_image.scale(this.circle_radius / this.last_circle_radius);
         }
-    } else {
-        this.circle.position = this.paper_coords;
-        if (this.node_image) {
-            this.node_image.position = this.paper_coords;
-        }
+    }
+    this.circle.position = this.paper_coords;
+    if (this.node_image) {
+        this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
     }
     this.last_circle_radius = this.circle_radius;
     
@@ -1136,44 +1182,11 @@
     this.all_buttons.forEach(function(b) {
         b.moveTo(_pc);
     });
-    var _img = this.model.get("image");
-    if (_img && _img !== this.img) {
-        var _image = new Image(),
-            _this = this;
-        _image.onload = function() {
-            if (_this.node_image) {
-                _this.node_image.remove();
-            }
-            _this.renderer.node_layer.activate();
-            var _ratio = Math.min(2 / _image.width, 2 / _image.height );
-            if (!_this.options.show_node_circles) {
-                _this.h_ratio = Math.min(1, _image.height / _image.width);
-            }
-            var _raster = new paper.Raster(_image);
-            if (_this.options.clip_node_images) {
-                var _clip = new paper.Path.Circle([0, 0], 1);
-                _raster.scale(_ratio);
-                _this.node_image = new paper.Group(_clip, _raster);
-                _this.node_image.opacity = .99;
-                /* This is a workaround to allow clipping at group level
-                 * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).
-                */
-                _this.node_image.clipped = true;
-                _clip.__representation = _this;
-            } else {
-                _this.node_image = _raster;
-            }
-            _this.node_image.__representation = _this;
-            var square = new paper.Size(_this.circle_radius, _this.circle_radius),
-                topleft = _this.paper_coords.subtract(square),
-                bounds = new paper.Rectangle(topleft, square.multiply(2));
-            _this.node_image.fitBounds(bounds);
-            _this.redraw();
-            paper.view.draw();
-        };
-        _image.src = _img;
+    var lastImage = this.img;
+    this.img = this.model.get("image");
+    if (this.img && this.img !== lastImage) {
+        this.showImage();
     }
-    this.img = _img;
     if (this.node_image && !this.img) {
         this.node_image.remove();
         delete this.node_image;
@@ -1190,7 +1203,7 @@
     if (!_dontRedrawEdges) {
         Rkns._.each(this.project.get("edges").filter(function (ed) { return ((ed.to === this.model) || (ed.from === this.model));}), function(edge, index, list){
             var repr = this.renderer.getRepresentationByModel(edge);
-            if(repr != null && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
+            if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
                 repr.redraw();
             }
         }, this);
@@ -1198,6 +1211,131 @@
 
 };
 
+Rkns.Renderer.Node.prototype.showImage = function() {
+    if (typeof this.renderer.image_cache[this.img] === "undefined") {
+        var _image = new Image();
+        this.renderer.image_cache[this.img] = _image;
+        _image.src = this.img;
+    } else {
+        var _image = this.renderer.image_cache[this.img];
+    }
+    if (_image.width) {
+        if (this.node_image) {
+            this.node_image.remove();
+        }
+        this.renderer.node_layer.activate();
+        var width = _image.width,
+            height = _image.height,
+            clipPath = this.model.get("clip-path"),
+            hasClipPath = (typeof clipPath !== "undefined" && clipPath);
+        if (hasClipPath) {
+            var _clip = new paper.Path(),
+                instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
+                lastCoords = [0,0],
+                minX = Infinity,
+                minY = Infinity,
+                maxX = -Infinity,
+                maxY = -Infinity;
+                
+            function transformCoords(tabc, relative) {
+                var newCoords = tabc.slice(1).map(function(v, k) {
+                    var res = parseFloat(v),
+                        isY = k % 2;
+                    if (isY) {
+                        res = ( res - .5 ) * height;
+                    } else {
+                        res = ( res - .5 ) * width;
+                    }
+                    if (relative) {
+                        res += lastCoords[isY];
+                    }
+                    if (isY) {
+                        minY = Math.min(minY, res);
+                        maxY = Math.max(maxY, res);
+                    } else {
+                        minX = Math.min(minX, res);
+                        maxX = Math.max(maxX, res);
+                    }
+                    return res;
+                });
+                lastCoords = newCoords.slice(-2);
+                return newCoords;
+            }
+            
+            instructions.forEach(function(instr) {
+                var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""];
+                switch(coords[0]) {
+                    case "M":
+                        _clip.moveTo(transformCoords(coords));
+                    break;
+                    case "m":
+                        _clip.moveTo(transformCoords(coords, true));
+                    break;
+                    case "L":
+                        _clip.lineTo(transformCoords(coords));
+                    break;
+                    case "l":
+                        _clip.lineTo(transformCoords(coords, true));
+                    break;
+                    case "C":
+                        _clip.cubicCurveTo(transformCoords(coords));
+                    break;
+                    case "c":
+                        _clip.cubicCurveTo(transformCoords(coords, true));
+                    break;
+                    case "Q":
+                        _clip.quadraticCurveTo(transformCoords(coords));
+                    break;
+                    case "q":
+                        _clip.quadraticCurveTo(transformCoords(coords, true));
+                    break;
+                }
+            });
+            
+            var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2,
+                centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);
+            if (!this.options.show_node_circles) {
+                this.h_ratio = (maxY - minY) / (2 * baseRadius);
+            }
+        } else {
+            var baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2,
+                centerPoint = new paper.Point(0,0);
+            if (!this.options.show_node_circles) {
+                this.h_ratio = height / (2 * baseRadius);
+            }
+        }
+        var _raster = new paper.Raster(_image);
+        if (hasClipPath) {
+            _raster = new paper.Group(_clip, _raster);
+            _raster.opacity = .99;
+            /* This is a workaround to allow clipping at group level
+             * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).
+            */
+            _raster.clipped = true;
+            _clip.__representation = this;
+        }
+        if (this.options.clip_node_images) {
+            var _circleClip = new paper.Path.Circle(centerPoint, baseRadius);
+            _raster = new paper.Group(_circleClip, _raster);
+            _raster.opacity = .99;
+            _raster.clipped = true;
+            _circleClip.__representation = this;
+        }
+        this.image_delta = centerPoint.divide(baseRadius);
+        this.node_image = _raster;
+        this.node_image.__representation = _this;
+        this.node_image.scale(this.circle_radius / baseRadius);
+        this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
+        this.redraw();
+        this.renderer.throttledPaperDraw();
+    } else {
+        var _this = this;
+        Rkns.$(_image).on("load", function() {
+            _this.showImage();
+        });
+    }
+}
+
 Rkns.Renderer.Node.prototype.paperShift = function(_delta) {
     if (this.options.editor_mode) {
         if (!this.renkan.read_only) {
@@ -1377,9 +1515,14 @@
 };
 
 Rkns.Renderer.Edge.prototype.redraw = function() {
-    this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
-    this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
-    if (!this.from_representation || !this.to_representation) {
+    var from = this.model.get("from"),
+        to = this.model.get("to");
+    if (!from || !to) {
+        return;
+    }
+    this.from_representation = this.renderer.getRepresentationByModel(from);
+    this.to_representation = this.renderer.getRepresentationByModel(to);
+    if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
         return;
     }
     var _p0a = this.from_representation.paper_coords,
@@ -1673,24 +1816,25 @@
 Rkns.Renderer.NodeEditor.prototype.template = Rkns._.template(
     '<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Node")%></span></h2>'
     + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>'
-    + '<p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p>'
-    + '<p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p>'
-    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p>'
-    + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
-    + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div>'
-    + '<img class="Rk-Edit-ImgPreview" src="<%-node.image || node.image_placeholder%>" />'
-    + '<p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>'
-    + '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p>'    
-    + '<% if (node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
+    + '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>'
+    + '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>'
+    + '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>'
+    + '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
+    + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
+    + '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />'
+    + '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>'
+    + '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>'
+    + '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>'    
+    + '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
 );
 
 Rkns.Renderer.NodeEditor.prototype.readOnlyTemplate = Rkns._.template(
-    '<h2><span class="Rk-CloseX">&times;</span><span class="Rk-UserColor" style="background:<%-node.color%>;"></span>'
+    '<h2><span class="Rk-CloseX">&times;</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>'
     + '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>'
-    + '<% if (node.uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>'
-    + '<p><%-node.description%></p>'
-    + '<% if (node.image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>'
-    + '<% if (node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
+    + '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>'
+    + '<% if (options.show_node_tooltip_description) { %><p><%-node.description%></p><% } %>'
+    + '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>'
+    + '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(node.created_by_title, 25) %></p><% } %>'
 );
 
 Rkns.Renderer.NodeEditor.prototype.draw = function() {
@@ -1710,11 +1854,13 @@
                 image: _model.get("image") || "",
                 image_placeholder: _image_placeholder,
                 color: _model.get("color") || _created_by.get("color"),
+                clip_path: _model.get("clip-path") || false,
                 created_by_color: _created_by.get("color"),
                 created_by_title: _created_by.get("title"),
                 size: (_size > 0 ? "+" : "") + _size
             },
-            renkan: this.renkan
+            renkan: this.renkan,
+            options: this.options
         }));
     this.redraw();
     var _this = this,
@@ -1730,16 +1876,19 @@
         var onFieldChange = Rkns._(function() {
             Rkns._(function() {
                 if (_this.renderer.isEditable()) {
-                    var _uri = _this.editor_$.find(".Rk-Edit-URI").val(),
-                        _image = _this.editor_$.find(".Rk-Edit-Image").val();
-                    _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _image || _image_placeholder);
-                    _this.editor_$.find(".Rk-Edit-Goto").attr("href",_uri);
                     var _data = {
-                        title: _this.editor_$.find(".Rk-Edit-Title").val(),
-                        description: _this.editor_$.find(".Rk-Edit-Description").val(),
-                        uri: _uri,
-                        image: _image
+                        title: _this.editor_$.find(".Rk-Edit-Title").val()
                     };
+                    if (_this.options.show_node_editor_uri) {
+                        _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
+                    }
+                    if (_this.options.show_node_editor_image) {
+                        _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
+                        _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
+                    }
+                    if (_this.options.show_node_editor_description) {
+                        _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
+                    }
                     _model.set(_data);
                     _this.redraw();
                 } else {
@@ -1850,28 +1999,28 @@
 Rkns.Renderer.EdgeEditor.prototype.template = Rkns._.template(
     '<h2><span class="Rk-CloseX">&times;</span><%-renkan.translate("Edit Edge")%></span></h2>'
     + '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>'
-    + '<p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>'
-    + '<% if (properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">'
-    + '<% _(properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>'
+    + '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>'
+    + '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">'
+    + '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>'
     + '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>'
     + '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>'
-    + '<% }) %><% }) %></select></p><% } %>'
-    + '<div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
-    + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div>'
-    + '<p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p>'
-    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
-    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p>'
-    + '<% if (edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
+    + '<% }) %><% }) %></select></p><% } } %>'
+    + '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><ul class="Rk-Edit-ColorPicker">'
+    + '<% _(Rkns.pickerColors).each(function(c) { %><li data-color="<%=c%>" style="background: <%=c%>"></li><% }); %></ul><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>'
+    + '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>'
+    + '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
+    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p><% } %>'
+    + '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
 );
 
 Rkns.Renderer.EdgeEditor.prototype.readOnlyTemplate = Rkns._.template(
-    '<h2><span class="Rk-CloseX">&times;</span><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span>'
+    '<h2><span class="Rk-CloseX">&times;</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>'
     + '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>'
-    + '<% if (edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>'
+    + '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>'
     + '<p><%-edge.description%></p>'
-    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
-    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p>'
-    + '<% if (edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
+    + '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- Rkns.Renderer.shortenText(edge.from_title, 25) %></p>'
+    + '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- Rkns.Renderer.shortenText(edge.to_title, 25) %></p><% } %>'
+    + '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- Rkns.Renderer.shortenText(edge.created_by_title, 25) %></p><% } %>'
 );
 
 Rkns.Renderer.EdgeEditor.prototype.draw = function() {
@@ -1897,7 +2046,7 @@
                 created_by_title: _created_by.get("title")
             },
             renkan: this.renkan,
-            properties: this.options.properties
+            options: this.options,
         }));
     this.redraw();
     var _this = this,
@@ -1912,11 +2061,13 @@
         var onFieldChange = Rkns._(function() {
             Rkns._(function() {
                 if (_this.renderer.isEditable()) {
-                    _this.editor_$.find(".Rk-Edit-Goto").attr("href",_this.editor_$.find(".Rk-Edit-URI").val());
                     var _data = {
-                        title: _this.editor_$.find(".Rk-Edit-Title").val(),
-                        uri: _this.editor_$.find(".Rk-Edit-URI").val()
+                        title: _this.editor_$.find(".Rk-Edit-Title").val()
                     };
+                    if (_this.options.show_edge_editor_uri) {
+                        _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
+                    }
+                    _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri);
                     _model.set(_data);
                     paper.view.draw();
                 } else {
@@ -2056,12 +2207,18 @@
     this.renderer.is_dragging = false;
     this.renderer.removeRepresentationsOfType("editor");
     if (this.renderer.isEditable()) {
-        var delid = Rkns.Utils.getUID("delete");
-        this.renderer.delete_list.push({
-            id: delid,
-            time: new Date().valueOf() + this.options.element_delete_delay
-        });
-        this.source_representation.model.set("delete_scheduled", delid);
+        if (this.options.element_delete_delay) {
+            var delid = Rkns.Utils.getUID("delete");
+            this.renderer.delete_list.push({
+                id: delid,
+                time: new Date().valueOf() + this.options.element_delete_delay
+            });
+            this.source_representation.model.set("delete_scheduled", delid);
+        } else {
+            if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
+                this.project.removeNode(this.source_representation.model);
+            }
+        }
     }
 };
 
@@ -2183,12 +2340,18 @@
     this.renderer.is_dragging = false;
     this.renderer.removeRepresentationsOfType("editor");
     if (this.renderer.isEditable()) {
-        var delid = Rkns.Utils.getUID("delete");
-        this.renderer.delete_list.push({
-            id: delid,
-            time: new Date().valueOf() + this.options.element_delete_delay
-        });
-        this.source_representation.model.set("delete_scheduled", delid);
+        if (this.options.element_delete_delay) {
+            var delid = Rkns.Utils.getUID("delete");
+            this.renderer.delete_list.push({
+                id: delid,
+                time: new Date().valueOf() + this.options.element_delete_delay
+            });
+            this.source_representation.model.set("delete_scheduled", delid);
+        } else {
+            if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
+                this.project.removeEdge(this.source_representation.model);
+            }
+        }
     }
 };
 
@@ -2293,12 +2456,13 @@
         _lastTapX,
         _lastTapY;
     
-    this.imageCache = {};
+    this.image_cache = {};
+    this.icon_cache = {};
     
     ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
         var img = new Image();
         img.src = _renkan.options.static_url + 'img/' + imgname + '.png';
-        _this.imageCache[imgname] = img;
+        _this.icon_cache[imgname] = img;
     });
     
     var throttledMouseMove = _.throttle(function(_event, _isTouch) {
@@ -2672,7 +2836,7 @@
     var _options = this.renkan.options,
         _startRads = _startAngle * Math.PI / 180,
         _endRads = _endAngle * Math.PI / 180,
-        _img = this.imageCache[_imgname],
+        _img = this.icon_cache[_imgname],
         _span = _endRads - _startRads,
         _startdx = - Math.sin(_startRads),
         _startdy = Math.cos(_startRads),
@@ -2836,7 +3000,7 @@
             _miny = Math.min.apply(Math, _yy),
             _maxx = Math.max.apply(Math, _xx),
             _maxy = Math.max.apply(Math, _yy);
-        var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxx - _minx), (paper.view.size.height - 2 * Rkns.Renderer._AUTOSCALE_MARGIN) / (_maxy - _miny)));
+        var _scale = Math.max(Rkns.Renderer._MIN_SCALE, Math.min(Rkns.Renderer._MAX_SCALE, (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny)));
         this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
     }
     if (nodes.length === 1) {
@@ -2862,8 +3026,8 @@
         var _scale = Math.min(
             this.scale * .8 * this.renkan.options.minimap_width / paper.view.bounds.width,
             this.scale * .8 * this.renkan.options.minimap_height / paper.view.bounds.height,
-            ( this.renkan.options.minimap_width - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxx - _minx),
-            ( this.renkan.options.minimap_height - 2 * Rkns.Renderer._MINIMAP_MARGIN ) / (_maxy - _miny)
+            ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),
+            ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)
         );
         this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));
         this.minimap.scale = _scale;
@@ -2930,6 +3094,9 @@
 };
 
 Rkns.Renderer.Scene.prototype.getRepresentationByModel = function(_model) {
+    if (!_model) {
+        return undefined;
+    }
     return Rkns._(this.representations).find(function(_repr) {
         return _repr.model === _model;
     });
@@ -3180,6 +3347,14 @@
             }
             if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
                 var snippet = Rkns.$('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
+                var _svgimgs = snippet.find("image");
+                if (_svgimgs.length) {
+                    newNode.image = _svgimgs.attr("xlink:href");
+                }
+                var _svgpaths = snippet.find("path");
+                if (_svgpaths.length) {
+                    newNode.clipPath = _svgpaths.attr("d");
+                }
                 var _imgs = snippet.find("img");
                 if (_imgs.length) {
                     newNode.image = _imgs[0].src;
@@ -3208,6 +3383,7 @@
                 newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
                 newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
                 newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
+                newNode.description = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.description;
             }
     }
     if (!newNode.title) {
@@ -3237,6 +3413,7 @@
             description: newNode.description || "",
             image: newNode.image || "",
             color: newNode.color || undefined,
+            "clip-path": newNode.clipPath || undefined,
             position: {
                 x: _coords.x,
                 y: _coords.y
--- a/web/res/metadataplayer/HtmlPlayer.js	Fri May 10 14:46:57 2013 +0200
+++ b/web/res/metadataplayer/HtmlPlayer.js	Wed May 15 16:36:30 2013 +0200
@@ -10,118 +10,6 @@
 
 IriSP.Widgets.HtmlPlayer.prototype.draw = function() {
 
-    
-    if (typeof this.video === "undefined") {
-        this.video = this.media.video;
-    }
-    
-    if (this.url_transform) {
-        this.video = this.url_transform(this.video);
-    }
-        
-    var videoEl = IriSP.jQuery('<video>');
-    videoEl.attr({
-        width : this.width,
-        height : this.height || undefined
-    });
-    if(typeof this.video === "string"){
-        videoEl.attr("src",this.video);
-    } else {
-        for (var i = 0; i < this.video.length; i++) {
-            var _srcNode = IriSP.jQuery('<source>');
-            _srcNode.attr({
-                src: this.video[i].src,
-                type: this.video[i].type
-            });
-            videoEl.append(_srcNode);
-        }
-    }
-    this.$.html(videoEl);
-    if (this.autostart || this.autoplay) {
-        videoEl.attr("autoplay", true);
-    }
-    
-    var mediaEl = videoEl[0],
-        media = this.media;
-    
-    // Binding functions to Popcorn
-    media.on("setcurrenttime", function(_milliseconds) {
-        try {
-            mediaEl.currentTime = (_milliseconds / 1000);
-        } catch (err) {
-            
-        }
-    });
-    
-    media.on("setvolume", function(_vol) {
-        media.volume = _vol;
-        try {
-            mediaEl.volume = _vol;
-        } catch (err) {
-            
-        }
-    });
-    
-    media.on("setmuted", function(_muted) {
-        media.muted = _muted;
-        try {
-            mediaEl.muted = _muted;
-        } catch (err) {
-            
-        }
-    });
-    
-    media.on("setplay", function() {
-        try {
-            mediaEl.play();
-        } catch (err) {
-            
-        }
-    });
-    
-    media.on("setpause", function() {
-        try {
-            mediaEl.pause();
-        } catch (err) {
-            
-        }
-    });
-    
-    // Binding Popcorn events to media
-    function getVolume() {
-        media.muted = mediaEl.muted;
-        media.volume = mediaEl.volume;
-    }
-    
-    videoEl.on("loadedmetadata", function() {
-        getVolume();
-        media.trigger("loadedmetadata");
-        media.trigger("volumechange");
-    })
-    
-    videoEl.on("timeupdate", function() {
-        media.trigger("timeupdate", new IriSP.Model.Time(1000*mediaEl.currentTime));
-    });
-    
-    videoEl.on("volumechange", function() {
-        getVolume();
-        media.trigger("volumechange");
-    })
-    
-    videoEl.on("play", function() {
-        media.trigger("play");
-    });
-    
-    videoEl.on("pause", function() {
-        media.trigger("pause");
-    });
-    
-    videoEl.on("seeking", function() {
-        media.trigger("seeking");
-    });
-    
-    videoEl.on("seeked", function() {
-        media.trigger("seeked");
-    });
+    IriSP.htmlPlayer(this.media, this.$, this);
     
 }
\ No newline at end of file
--- a/web/res/metadataplayer/LdtPlayer-core.js	Fri May 10 14:46:57 2013 +0200
+++ b/web/res/metadataplayer/LdtPlayer-core.js	Wed May 15 16:36:30 2013 +0200
@@ -1,6 +1,18 @@
+/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
+    v2.0.3 (c) Kyle Simpson
+    MIT License
+*/
+(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function t(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function I(a){a.ready=a.finished=true;for(var c=0;c<a.finished_listeners.length;c++){a.finished_listeners[c]()}a.ready_listeners=[];a.finished_listeners=[]}function P(d,f,e,g,h){setTimeout(function(){var a,c=f.real_src,b;if("item"in i){if(!i[0]){setTimeout(arguments.callee,25);return}i=i[0]}a=document.createElement("script");if(f.type)a.type=f.type;if(f.charset)a.charset=f.charset;if(h){if(r){e.elem=a;if(E){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g()}}a.src=c}else if(h&&c.indexOf(D)==0&&d[y]){b=new XMLHttpRequest();b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};e.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{a.type="text/cache-script";t(a,e,"ready",function(){i.removeChild(a);g()});a.src=c;i.insertBefore(a,i.firstChild)}}else if(F){a.async=false;t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}else{t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}},0)}function J(){var l={},Q=r||M,n=[],p={},m;l[y]=true;l[z]=false;l[u]=false;l[A]=false;l[B]="";function R(a,c,b){var d;function f(){if(d!=null){d=null;I(b)}}if(p[c.src].finished)return;if(!a[u])p[c.src].finished=true;d=b.elem||document.createElement("script");if(c.type)d.type=c.type;if(c.charset)d.charset=c.charset;t(d,b,"finished",f);if(b.elem){b.elem=null}else if(b.text){d.onload=d.onreadystatechange=null;d.text=b.text}else{d.src=c.real_src}i.insertBefore(d,i.firstChild);if(b.text){f()}}function S(c,b,d,f){var e,g,h=function(){b.ready_cb(b,function(){R(c,b,e)})},j=function(){b.finished_cb(b,d)};b.src=N(b.src,c[B]);b.real_src=b.src+(c[A]?((/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"="):"");if(!p[b.src])p[b.src]={items:[],finished:false};g=p[b.src].items;if(c[u]||g.length==0){e=g[g.length]={ready:false,finished:false,ready_listeners:[h],finished_listeners:[j]};P(c,b,e,((f)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){e.ready_listeners[a]()}e.ready_listeners=[]}:function(){I(e)}),f)}else{e=g[0];if(e.finished){j()}else{e.finished_listeners.push(j)}}}function v(){var e,g=s(l,{}),h=[],j=0,w=false,k;function T(a,c){a.ready=true;a.exec_trigger=c;x()}function U(a,c){a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;x()}function x(){while(j<h.length){if(G(h[j])){try{h[j++]()}catch(err){}continue}else if(!h[j].finished){if(O(h[j]))continue;break}j++}if(j==h.length){w=false;k=false}}function V(){if(!k||!k.scripts){h.push(k={scripts:[],finished:true})}}e={script:function(){for(var f=0;f<arguments.length;f++){(function(a,c){var b;if(!H(a)){c=[a]}for(var d=0;d<c.length;d++){V();a=c[d];if(G(a))a=a();if(!a)continue;if(H(a)){b=[].slice.call(a);b.unshift(d,1);[].splice.apply(c,b);d--;continue}if(typeof a=="string")a={src:a};a=s(a,{ready:false,ready_cb:T,finished:false,finished_cb:U});k.finished=false;k.scripts.push(a);S(g,a,k,(Q&&w));w=true;if(g[z])e.wait()}})(arguments[f],arguments[f])}return e},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){h.push(arguments[a])}k=h[h.length-1]}else k=false;x();return e}};return{script:e.script,wait:e.wait,setOptions:function(a){s(a,g);return e}}}m={setGlobalDefaults:function(a){s(a,l);return m},setOptions:function(){return v().setOptions.apply(null,arguments)},script:function(){return v().script.apply(null,arguments)},wait:function(){return v().wait.apply(null,arguments)},queueScript:function(){n[n.length]={type:"script",args:[].slice.call(arguments)};return m},queueWait:function(){n[n.length]={type:"wait",args:[].slice.call(arguments)};return m},runQueue:function(){var a=m,c=n.length,b=c,d;for(;--b>=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);
 /* 
- * 	
- *	Copyright 2010-2012 Institut de recherche et d'innovation 
+ *
+  __  __      _            _       _              _                       
+ |  \/  | ___| |_ __ _  __| | __ _| |_ __ _ _ __ | | __ _ _   _  ___ _ __ 
+ | |\/| |/ _ \ __/ _` |/ _` |/ _` | __/ _` | '_ \| |/ _` | | | |/ _ \ '__|
+ | |  | |  __/ || (_| | (_| | (_| | || (_| | |_) | | (_| | |_| |  __/ |   
+ |_|  |_|\___|\__\__,_|\__,_|\__,_|\__\__,_| .__/|_|\__,_|\__, |\___|_|   
+                                           |_|            |___/         
+
+ *  Copyright 2010-2012 Institut de recherche et d'innovation 
  *	contributor(s) : Karim Hamidou, Samuel Huron, Raphael Velt, Thibaut Cavalie
  *	 
  *	contact@iri.centrepompidou.fr
@@ -16,210 +28,24 @@
  *	The fact that you are presently reading this means that you have had
  *	knowledge of the CeCILL-C license and that you accept its terms.
 */
-/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
-    v2.0.3 (c) Kyle Simpson
-    MIT License
-*/
-(function(o){var K=o.$LAB,y="UseLocalXHR",z="AlwaysPreserveOrder",u="AllowDuplicates",A="CacheBust",B="BasePath",C=/^[^?#]*\//.exec(location.href)[0],D=/^\w+\:\/\/\/?[^\/]+/.exec(C)[0],i=document.head||document.getElementsByTagName("head"),L=(o.opera&&Object.prototype.toString.call(o.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),q=document.createElement("script"),E=typeof q.preload=="boolean",r=E||(q.readyState&&q.readyState=="uninitialized"),F=!r&&q.async===true,M=!r&&!F&&!L;function G(a){return Object.prototype.toString.call(a)=="[object Function]"}function H(a){return Object.prototype.toString.call(a)=="[object Array]"}function N(a,c){var b=/^\w+\:\/\//;if(/^\/\/\/?/.test(a)){a=location.protocol+a}else if(!b.test(a)&&a.charAt(0)!="/"){a=(c||"")+a}return b.test(a)?a:((a.charAt(0)=="/"?D:C)+a)}function s(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function O(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function t(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function I(a){a.ready=a.finished=true;for(var c=0;c<a.finished_listeners.length;c++){a.finished_listeners[c]()}a.ready_listeners=[];a.finished_listeners=[]}function P(d,f,e,g,h){setTimeout(function(){var a,c=f.real_src,b;if("item"in i){if(!i[0]){setTimeout(arguments.callee,25);return}i=i[0]}a=document.createElement("script");if(f.type)a.type=f.type;if(f.charset)a.charset=f.charset;if(h){if(r){e.elem=a;if(E){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g()}}a.src=c}else if(h&&c.indexOf(D)==0&&d[y]){b=new XMLHttpRequest();b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};e.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{a.type="text/cache-script";t(a,e,"ready",function(){i.removeChild(a);g()});a.src=c;i.insertBefore(a,i.firstChild)}}else if(F){a.async=false;t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}else{t(a,e,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}},0)}function J(){var l={},Q=r||M,n=[],p={},m;l[y]=true;l[z]=false;l[u]=false;l[A]=false;l[B]="";function R(a,c,b){var d;function f(){if(d!=null){d=null;I(b)}}if(p[c.src].finished)return;if(!a[u])p[c.src].finished=true;d=b.elem||document.createElement("script");if(c.type)d.type=c.type;if(c.charset)d.charset=c.charset;t(d,b,"finished",f);if(b.elem){b.elem=null}else if(b.text){d.onload=d.onreadystatechange=null;d.text=b.text}else{d.src=c.real_src}i.insertBefore(d,i.firstChild);if(b.text){f()}}function S(c,b,d,f){var e,g,h=function(){b.ready_cb(b,function(){R(c,b,e)})},j=function(){b.finished_cb(b,d)};b.src=N(b.src,c[B]);b.real_src=b.src+(c[A]?((/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"="):"");if(!p[b.src])p[b.src]={items:[],finished:false};g=p[b.src].items;if(c[u]||g.length==0){e=g[g.length]={ready:false,finished:false,ready_listeners:[h],finished_listeners:[j]};P(c,b,e,((f)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){e.ready_listeners[a]()}e.ready_listeners=[]}:function(){I(e)}),f)}else{e=g[0];if(e.finished){j()}else{e.finished_listeners.push(j)}}}function v(){var e,g=s(l,{}),h=[],j=0,w=false,k;function T(a,c){a.ready=true;a.exec_trigger=c;x()}function U(a,c){a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;x()}function x(){while(j<h.length){if(G(h[j])){try{h[j++]()}catch(err){}continue}else if(!h[j].finished){if(O(h[j]))continue;break}j++}if(j==h.length){w=false;k=false}}function V(){if(!k||!k.scripts){h.push(k={scripts:[],finished:true})}}e={script:function(){for(var f=0;f<arguments.length;f++){(function(a,c){var b;if(!H(a)){c=[a]}for(var d=0;d<c.length;d++){V();a=c[d];if(G(a))a=a();if(!a)continue;if(H(a)){b=[].slice.call(a);b.unshift(d,1);[].splice.apply(c,b);d--;continue}if(typeof a=="string")a={src:a};a=s(a,{ready:false,ready_cb:T,finished:false,finished_cb:U});k.finished=false;k.scripts.push(a);S(g,a,k,(Q&&w));w=true;if(g[z])e.wait()}})(arguments[f],arguments[f])}return e},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){h.push(arguments[a])}k=h[h.length-1]}else k=false;x();return e}};return{script:e.script,wait:e.wait,setOptions:function(a){s(a,g);return e}}}m={setGlobalDefaults:function(a){s(a,l);return m},setOptions:function(){return v().setOptions.apply(null,arguments)},script:function(){return v().script.apply(null,arguments)},wait:function(){return v().wait.apply(null,arguments)},queueScript:function(){n[n.length]={type:"script",args:[].slice.call(arguments)};return m},queueWait:function(){n[n.length]={type:"wait",args:[].slice.call(arguments)};return m},runQueue:function(){var a=m,c=n.length,b=c,d;for(;--b>=0;){d=n.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){o.$LAB=K;return m},sandbox:function(){return J()}};return m}o.$LAB=J();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);/* init.js - initialization and configuration of the widgets
-*/
+/* Initialization of the namespace */
 
 if (typeof window.IriSP === "undefined") {
     window.IriSP = {};
 }
 
-/* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */
-
-IriSP.Metadataplayer = function(config) {
-    IriSP.log("IriSP.Metadataplayer constructor");
-    for (var key in IriSP.guiDefaults) {
-        if (IriSP.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) {
-            config[key] = IriSP.guiDefaults[key]
-        }
-    }
-    var _container = document.getElementById(config.container);
-    _container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>';
-    this.sourceManager = new IriSP.Model.Directory();
-    this.config = config;
-    this.__events = {};
-    this.loadLibs();
-}
-
-IriSP.Metadataplayer.prototype.toString = function() {
-    return 'Metadataplayer in #' + this.config.container;
-}
-
-IriSP.Metadataplayer.prototype.on = function(_event, _callback) {
-    if (typeof this.__events[_event] === "undefined") {
-        this.__events[_event] = [];
-    }
-    this.__events[_event].push(_callback);
-}
-
-IriSP.Metadataplayer.prototype.trigger = function(_event, _data) {
-    var _element = this;
-    IriSP._(this.__events[_event]).each(function(_callback) {
-        _callback.call(_element, _data);
-    });
-}
-
-IriSP.Metadataplayer.prototype.loadLibs = function() {
-    IriSP.log("IriSP.Metadataplayer.prototype.loadLibs");
-    var $L = $LAB
-        .script(IriSP.getLib("underscore"))
-        .script(IriSP.getLib("Mustache"))
-        .script(IriSP.getLib("jQuery"));
-    
-    if (typeof JSON == "undefined") {
-        $L.script(IriSP.getLib("json"));
-    }
-    
-    $L.wait()
-        .script(IriSP.getLib("jQueryUI"));
-
-    /* widget specific requirements */
-    for(var _i = 0; _i < this.config.widgets.length; _i++) {
-        var _t = this.config.widgets[_i].type;
-        if (typeof IriSP.widgetsRequirements[_t] !== "undefined" && typeof IriSP.widgetsRequirements[_t].requires !== "undefined" ) {
-            for (var _j = 0; _j < IriSP.widgetsRequirements[_t].requires.length; _j++) {
-                $L.script(IriSP.getLib(IriSP.widgetsRequirements[_t].requires[_j]));
-            }
-        }
-    }
-    
-    var _this = this;
-    
-    $L.wait(function() {
-        _this.onLibsLoaded();
-    });
+if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined" && parseFloat(window.jQuery().jquery) >= 1.7) {
+    IriSP.jQuery = window.jQuery;
 }
 
-IriSP.Metadataplayer.prototype.onLibsLoaded = function() {
-    IriSP.log("IriSP.Metadataplayer.prototype.onLibsLoaded");
-    if (typeof IriSP.jQuery === "undefined" && typeof window.jQuery !== "undefined") {
-        IriSP.jQuery = window.jQuery;
-    }
-    if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined") {
-        IriSP._ = window._;
-    }
-    IriSP.loadCss(IriSP.getLib("cssjQueryUI"));
-    IriSP.loadCss(this.config.css);
-    
-    this.$ = IriSP.jQuery('#' + this.config.container);
-    this.$.css({
-        "width": this.config.width,
-        "clear": "both"
-    });
-    if (typeof this.config.height !== "undefined") {
-        this.$.css("height", this.config.height);
-    }
-      
-    this.widgets = [];
-    var _this = this;
-    IriSP._(this.config.widgets).each(function(widgetconf, key) {
-        _this.widgets.push(null);
-        _this.loadWidget(widgetconf, function(widget) {
-            _this.widgets[key] = widget;
-            if (widget.isLoaded()) {
-                _this.trigger("widget-loaded");
-            }
-        });
-    });
-    this.$.find('.Ldt-Loader').detach();
-    
-    this.widgetsLoaded = false;
-    
-    this.on("widget-loaded", function() {
-        if (_this.widgetsLoaded) {
-            return;
-        }
-        var isloaded = !IriSP._(_this.widgets).any(function(w) {
-            return !(w && w.isLoaded())
-        });
-        if (isloaded) {
-            _this.widgetsLoaded = true;
-            _this.trigger("widgets-loaded");
-        }
-    });   
+if (typeof IriSP._ === "undefined" && typeof window._ !== "undefined" && parseFloat(window._.VERSION) >= 1.4) {
+    IriSP._ = window._;
 }
-
-IriSP.Metadataplayer.prototype.loadMetadata = function(_metadataInfo) {
-    if (_metadataInfo.elementType === "source") {
-        return _metadataInfo;
-    }
-    if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") {
-        _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format];
-    }
-    if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") {
-        return this.sourceManager.remoteSource(_metadataInfo);
-    } else {
-        return this.sourceManager.newLocalSource(_metadataInfo);
-    }
-}
-
-IriSP.Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) {
-    /* Creating containers if needed */
-    if (typeof _widgetConfig.container === "undefined") {
-        var _divs = this.layoutDivs(_widgetConfig.type);
-        _widgetConfig.container = _divs[0];
-    }
-    
-    var _this = this;
-    
-    if (typeof IriSP.Widgets[_widgetConfig.type] !== "undefined") {
-        IriSP._.defer(function() {
-            _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig));
-        });
-    } else {
-        /* Loading Widget CSS */
-        if (typeof IriSP.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof IriSP.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !IriSP.widgetsRequirements[_widgetConfig.type].noCss) {
-            IriSP.loadCss(IriSP.widgetsDir + '/' + _widgetConfig.type + '.css');
-        }
-        /* Loading Widget JS    */
-        $LAB.script(IriSP.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() {
-            _callback(new IriSP.Widgets[_widgetConfig.type](_this, _widgetConfig));
-        });
-    }
-}
-
-/** create a subdiv with an unique id, and a spacer div as well.
-    @param widgetName the name of the widget.
-    @return an array of the form [createdivId, spacerdivId].
-*/
-IriSP.Metadataplayer.prototype.layoutDivs = function(_name, _height) {
-    if (typeof(_name) === "undefined") {
-       _name = "";
-    }
-    var newDiv = IriSP._.uniqueId(this.config.container + "_widget_" + _name + "_"),
-        spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"),
-        divHtml = IriSP.jQuery('<div>')
-            .attr("id",newDiv)
-            .css({
-                width: this.config.width + "px",
-                position: "relative",
-                clear: "both"
-            }),
-        spacerHtml = IriSP.jQuery('<div>')
-            .attr("id",spacerDiv)
-            .css({
-                width: this.config.width + "px",
-                height: this.config.spacer_div_height + "px",
-                position: "relative",
-                clear: "both"
-            });
-    if (typeof _height !== "undefined") {
-        divHtml.css("height", _height);
-    }
-            
-    this.$.append(divHtml);
-    this.$.append(spacerHtml);
-
-    return [newDiv, spacerDiv];
-};
 /* utils.js - various utils that don't belong anywhere else */
 
 IriSP.jqEscape = function(_text) {
     return _text.replace(/(:|\.)/g,'\\$1');
-}
+};
 
 IriSP.getLib = function(lib) {
     if (IriSP.libFiles.useCdn && typeof IriSP.libFiles.cdn[lib] == "string") {
@@ -244,7 +70,7 @@
         }).appendTo('head');
         IriSP._cssCache.push(_cssFile);
     }
-}
+};
 
 IriSP.textFieldHtml = function(_text, _regexp, _extend) {
     var list = [],
@@ -317,13 +143,13 @@
     
     return res;
     
-}
+};
 
 IriSP.log = function() {
     if (typeof console !== "undefined" && typeof IriSP.logging !== "undefined" && IriSP.logging) {
         console.log.apply(console, arguments);
     }
-}
+};
 
 IriSP.attachDndData = function(jqSel, data) {
 	jqSel.attr("draggable", "true").on("dragstart", function(_event) {
@@ -338,10 +164,12 @@
 			_event.originalEvent.dataTransfer.setData("Text", JSON.stringify(d));
 		}
 	});
-}
-/* TODO: Separate Project-specific data from Source */
+};
 
-/* model.js is where data is stored in a standard form, whatever the serializer */
+/* js is where data is stored in a standard form, whatever the serializer */
+
+//TODO: Separate Project-specific data from Source
+
 IriSP.Model = (function (ns) {
     
     function pad(n, x, b) {
@@ -372,23 +200,32 @@
         String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
         "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
         ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
-    ]
+    ];
     
-var Model = {
-    _SOURCE_STATUS_EMPTY : 0,
-    _SOURCE_STATUS_WAITING : 1,
-    _SOURCE_STATUS_READY : 2,
-    getUID : function() {
+var Model = {},
+    _SOURCE_STATUS_EMPTY = Model._SOURCE_STATUS_EMPTY = 0,
+    _SOURCE_STATUS_WAITING = Model._SOURCE_STATUS_WAITING = 1,
+    _SOURCE_STATUS_READY = Model._SOURCE_STATUS_READY = 2,
+    extendPrototype = Model.extendPrototype = function(toClass, fromClass) {
+        var fromP = fromClass.prototype,
+            toP = toClass.prototype;
+        for (var k in fromP) {
+            if (fromP.hasOwnProperty(k)) {
+                toP[k] = fromP[k];
+            }
+        }
+    },
+    getUID = Model.getUID = function() {
         return uidbase + pad(4, (++uidincrement % 0x10000), 16) + "-" + rand16(4) + "-" + rand16(6) + rand16(6);
     },
-    isLocalURL : function(url) {
+    isLocalURL = Model.isLocalURL = function(url) {
         var matches = url.match(/^(\w+:)\/\/([^/]+)/);
         if (matches) {
             return(matches[1] === document.location.protocol && matches[2] === document.location.host)
         }
         return true;
     },
-    regexpFromTextOrArray : function(_textOrArray, _testOnly, _iexact) {
+    regexpFromTextOrArray = Model.regexpFromTextOrArray = function(_textOrArray, _testOnly, _iexact) {
         var _testOnly = _testOnly || false,
             _iexact = _iexact || false;
         function escapeText(_text) {
@@ -408,7 +245,7 @@
         }
         return new RegExp( _source, _flags);
     },
-    fullTextRegexps: function(_text) {
+    fullTextRegexps = Model.fullTextRegexps = function(_text) {
         var remsrc = "[\\" + removeChars.join("\\") + "]",
             remrx = new RegExp(remsrc,"gm"),
             txt = _text.toLowerCase().replace(remrx,"")
@@ -429,7 +266,7 @@
         }
         return "(" + src + ")";
     },
-    isoToDate : function(_str) {
+    isoToDate = Model.isoToDate = function(_str) {
         // http://delete.me.uk/2005/03/iso8601.html
         var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
         var d = _str.match(new RegExp(regexp));
@@ -454,7 +291,7 @@
         _res.setTime(Number(time));
         return _res;
     },
-    dateToIso : function(_d) {
+    dateToIso = Model.dateToIso = function(_d) {
         var d = _d ? new Date(_d) : new Date();
         return d.getUTCFullYear()+'-'  
             + pad(2, d.getUTCMonth()+1)+'-'  
@@ -462,20 +299,19 @@
             + pad(2, d.getUTCHours())+':'  
             + pad(2, d.getUTCMinutes())+':'  
             + pad(2, d.getUTCSeconds())+'Z'  
-    }
-}
+    };
 
 /*
- * Model.List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID)
+ * List is a class for a list of elements (e.g. annotations, medias, etc. that each have a distinct ID)
  */
-Model.List = function(_directory) {
+var List = Model.List = function(_directory) {
     Array.call(this);
     this.directory = _directory;
     this.idIndex = [];
     this.__events = {};
     if (typeof _directory == "undefined") {
         console.trace();
-        throw "Error : new Model.List(directory): directory is undefined";
+        throw "Error : new List(directory): directory is undefined";
     }
     var _this =  this;
     this.on("clear-search", function() {
@@ -486,113 +322,113 @@
         });
         _this.trigger("search-cleared");
     })
-}
+};
 
-Model.List.prototype = new Array();
+List.prototype = new Array();
 
-Model.List.prototype.hasId = function(_id) {
+List.prototype.hasId = function(_id) {
     return ns._(this.idIndex).include(_id);
-}
+};
 
 /* On recent browsers, forEach and map are defined and do what we want.
  * Otherwise, we'll use the Underscore.js functions
  */
 if (typeof Array.prototype.forEach === "undefined") {
-    Model.List.prototype.forEach = function(_callback) {
+    List.prototype.forEach = function(_callback) {
         var _this = this;
         ns._(this).forEach(function(_value, _key) {
             _callback(_value, _key, _this);
         });
     }
-}
+};
 
 if (typeof Array.prototype.map === "undefined") {
-    Model.List.prototype.map = function(_callback) {
+    List.prototype.map = function(_callback) {
         var _this = this;
         return ns._(this).map(function(_value, _key) {
             return _callback(_value, _key, _this);
         });
     }
-}
+};
 
-Model.List.prototype.pluck = function(_key) {
+List.prototype.pluck = function(_key) {
     return this.map(function(_value) {
         return _value[_key];
     });
-}
+};
 
-/* We override Array's filter function because it doesn't return an Model.List
+/* We override Array's filter function because it doesn't return an List
  */
-Model.List.prototype.filter = function(_callback) {
+List.prototype.filter = function(_callback) {
     var _this = this,
-        _res = new Model.List(this.directory);
+        _res = new List(this.directory);
     _res.addElements(ns._(this).filter(function(_value, _key) {
         return _callback(_value, _key, _this);
     }));
     return _res;
-}
+};
 
-Model.List.prototype.slice = function(_start, _end) {
-    var _res = new Model.List(this.directory);
+List.prototype.slice = function(_start, _end) {
+    var _res = new List(this.directory);
     _res.addElements(Array.prototype.slice.call(this, _start, _end));
     return _res;
-}
+};
 
-Model.List.prototype.splice = function(_start, _end) {
-    var _res = new Model.List(this.directory);
+List.prototype.splice = function(_start, _end) {
+    var _res = new List(this.directory);
     _res.addElements(Array.prototype.splice.call(this, _start, _end));
     this.idIndex.splice(_start, _end);
     return _res;
-}
+};
 
 /* Array has a sort function, but it's not as interesting as Underscore.js's sortBy
- * and won't return a new Model.List
+ * and won't return a new List
  */
-Model.List.prototype.sortBy = function(_callback) {
+List.prototype.sortBy = function(_callback) {
     var _this = this,
-        _res = new Model.List(this.directory);
+        _res = new List(this.directory);
     _res.addElements(ns._(this).sortBy(function(_value, _key) {
         return _callback(_value, _key, _this);
     }));
     return _res;
-}
+};
 
 /* Title and Description are basic information for (almost) all element types,
  * here we can search by these criteria
  */
-Model.List.prototype.searchByTitle = function(_text, _iexact) {
+List.prototype.searchByTitle = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp = Model.regexpFromTextOrArray(_text, true, _iexact);
+        _rgxp = regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         return _rgxp.test(_element.title);
     });
-}
+};
 
-Model.List.prototype.searchByDescription = function(_text, _iexact) {
+List.prototype.searchByDescription = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp = Model.regexpFromTextOrArray(_text, true, _iexact);
+        _rgxp = regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description);
     });
-}
+};
 
-Model.List.prototype.searchByTextFields = function(_text, _iexact) {
+List.prototype.searchByTextFields = function(_text, _iexact) {
     var _iexact = _iexact || false,
-        _rgxp =  Model.regexpFromTextOrArray(_text, true, _iexact);
+        _rgxp =  regexpFromTextOrArray(_text, true, _iexact);
     return this.filter(function(_element) {
         var keywords = (_element.keywords || _element.getTagTexts() || []).join(", ");
         return _rgxp.test(_element.description) || _rgxp.test(_element.title) || _rgxp.test(keywords);
     });
-}
+};
 
-Model.List.prototype.search = function(_text) {
+List.prototype.search = function(_text) {
     if (!_text) {
         this.trigger("clear-search");
         return this;
     }
     this.searching = true;
     this.trigger("search", _text);
-    var rxsource = Model.fullTextRegexps(_text)
+    var rxsource = fullTextRegexps(_text)
         rgxp = new RegExp(rxsource,"im"),
         this.regexp = new RegExp(rxsource,"gim");
     var res = this.filter(function(_element, _k) {
@@ -605,23 +441,23 @@
     });
     this.trigger(res.length ? "found" : "not-found",res);
     return res;
-}
+};
 
-Model.List.prototype.getTitles = function() {
+List.prototype.getTitles = function() {
     return this.map(function(_el) {
         return _el.title;
     });
-}
+};
 
-Model.List.prototype.addId = function(_id) {
+List.prototype.addId = function(_id) {
     var _el = this.directory.getElement(_id)
     if (!this.hasId(_id) && typeof _el !== "undefined") {
         this.idIndex.push(_id);
         Array.prototype.push.call(this, _el);
     }
-}
+};
 
-Model.List.prototype.push = function(_el) {
+List.prototype.push = function(_el) {
     if (typeof _el === "undefined") {
         return;
     }
@@ -632,24 +468,24 @@
     } else {
         this[_index] = _el;
     }
-}
+};
 
-Model.List.prototype.addIds = function(_array) {
+List.prototype.addIds = function(_array) {
     var _l = _array.length,
         _this = this;
     ns._(_array).forEach(function(_id) {
         _this.addId(_id);
     });
-}
+};
 
-Model.List.prototype.addElements = function(_array) {
+List.prototype.addElements = function(_array) {
     var _this = this;
     ns._(_array).forEach(function(_el) {
         _this.push(_el);
     });
-}
+};
 
-Model.List.prototype.removeId = function(_id, _deleteFromDirectory) {
+List.prototype.removeId = function(_id, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
         _index = (ns._(this.idIndex).indexOf(_id));
     if (_index !== -1) {
@@ -658,61 +494,61 @@
     if (_deleteFromDirectory) {
         delete this.directory.elements[_id];
     }
-}
+};
 
-Model.List.prototype.removeElement = function(_el, _deleteFromDirectory) {
+List.prototype.removeElement = function(_el, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false;
     this.removeId(_el.id);
-}
+};
 
-Model.List.prototype.removeIds = function(_list, _deleteFromDirectory) {
+List.prototype.removeIds = function(_list, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
         _this = this;
     ns._(_list).forEach(function(_id) {
         _this.removeId(_id);
     });
-}
+};
 
-Model.List.prototype.removeElements = function(_list, _deleteFromDirectory) {
+List.prototype.removeElements = function(_list, _deleteFromDirectory) {
     var _deleteFromDirectory = _deleteFromDirectory || false,
         _this = this;
     ns._(_list).forEach(function(_el) {
         _this.removeElement(_el);
     });
-}
+};
 
-Model.List.prototype.on = function(_event, _callback) {
+List.prototype.on = function(_event, _callback) {
     if (typeof this.__events[_event] === "undefined") {
         this.__events[_event] = [];
     }
     this.__events[_event].push(_callback);
-}
+};
 
-Model.List.prototype.off = function(_event, _callback) {
+List.prototype.off = function(_event, _callback) {
     if (typeof this.__events[_event] !== "undefined") {
         this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) {
             return _fn === _callback;
         });
     }
-}
+};
 
-Model.List.prototype.trigger = function(_event, _data) {
+List.prototype.trigger = function(_event, _data) {
     var _list = this;
     ns._(this.__events[_event]).each(function(_callback) {
         _callback.call(_list, _data);
     });
-}
+};
 
 /* A simple time management object, that helps converting millisecs to seconds and strings,
  * without the clumsiness of the original Date object.
  */
 
-Model.Time = function(_milliseconds) {
+var Time = Model.Time = function(_milliseconds) {
     this.milliseconds = 0;
     this.setMilliseconds(_milliseconds);
-}
+};
 
-Model.Time.prototype.setMilliseconds = function(_milliseconds) {
+Time.prototype.setMilliseconds = function(_milliseconds) {
     var _ante = this.milliseconds;
     switch(typeof _milliseconds) {
         case "string":
@@ -730,17 +566,17 @@
     if (this.milliseconds === NaN) {
         this.milliseconds = _ante;
     }
-}
+};
 
-Model.Time.prototype.setSeconds = function(_seconds) {
+Time.prototype.setSeconds = function(_seconds) {
     this.milliseconds = 1000 * _seconds;
-}
+};
 
-Model.Time.prototype.getSeconds = function() {
+Time.prototype.getSeconds = function() {
     return this.milliseconds / 1000;
-}
+};
 
-Model.Time.prototype.getHMS = function() {
+Time.prototype.getHMS = function() {
     var _totalSeconds = Math.abs(Math.floor(this.getSeconds()));
     return {
         hours : Math.floor(_totalSeconds / 3600),
@@ -748,17 +584,17 @@
         seconds : _totalSeconds % 60,
         milliseconds: this.milliseconds % 1000
     } 
-}
+};
 
-Model.Time.prototype.add = function(_milliseconds) {
-    this.milliseconds += new Model.Time(_milliseconds).milliseconds;
-}
+Time.prototype.add = function(_milliseconds) {
+    this.milliseconds += new Time(_milliseconds).milliseconds;
+};
 
-Model.Time.prototype.valueOf = function() {
+Time.prototype.valueOf = function() {
     return this.milliseconds;
-}
+};
 
-Model.Time.prototype.toString = function(showCs) {
+Time.prototype.toString = function(showCs) {
     var _hms = this.getHMS(),
         _res = '';
     if (_hms.hours) {
@@ -769,12 +605,12 @@
         _res += "." + Math.floor(_hms.milliseconds / 100)
     }
     return _res;
-}
+};
 
-/* Model.Reference handles references between elements
+/* Reference handles references between elements
  */
 
-Model.Reference = function(_source, _idRef) {
+var Reference = Model.Reference = function(_source, _idRef) {
     this.source = _source;
     this.id = _idRef;
     if (typeof _idRef === "object") {
@@ -783,36 +619,36 @@
         this.isList = false;
     }
     this.refresh();
-}
+};
 
-Model.Reference.prototype.refresh = function() {
+Reference.prototype.refresh = function() {
     if (this.isList) {
-        this.contents = new Model.List(this.source.directory);
+        this.contents = new List(this.source.directory);
         this.contents.addIds(this.id);
     } else {
         this.contents = this.source.getElement(this.id);
     }
     
-}
+};
 
-Model.Reference.prototype.getContents = function() {
+Reference.prototype.getContents = function() {
     if (typeof this.contents === "undefined" || (this.isList && this.contents.length != this.id.length)) {
         this.refresh();
     }
     return this.contents;
-}
+};
 
-Model.Reference.prototype.isOrHasId = function(_idRef) {
+Reference.prototype.isOrHasId = function(_idRef) {
     if (this.isList) {
         return (ns._(this.id).indexOf(_idRef) !== -1)
     } else {
         return (this.id == _idRef);
     }
-}
+};
 
 /* */
 
-Model.Element = function(_id, _source) {
+var BaseElement = Model.Element = function(_id, _source) {
     this.elementType = 'element';
     this.title = "";
     this.description = "";
@@ -821,69 +657,69 @@
         return;
     }
     if (typeof _id === "undefined" || !_id) {
-        _id = Model.getUID();
+        _id = getUID();
     }
     this.id = _id;
     this.source = _source;
     if (_source !== this) {
         this.source.directory.addElement(this);
     }
-}
+};
 
-Model.Element.prototype.toString = function() {
+BaseElement.prototype.toString = function() {
     return this.elementType + (this.elementType !== 'element' ? ', id=' + this.id + ', title="' + this.title + '"' : '');
-}
+};
 
-Model.Element.prototype.setReference = function(_elementType, _idRef) {
-    this[_elementType] = new Model.Reference(this.source, _idRef);
-}
+BaseElement.prototype.setReference = function(_elementType, _idRef) {
+    this[_elementType] = new Reference(this.source, _idRef);
+};
 
-Model.Element.prototype.getReference = function(_elementType) {
+BaseElement.prototype.getReference = function(_elementType) {
     if (typeof this[_elementType] !== "undefined") {
         return this[_elementType].getContents();
     }
-}
+};
 
-Model.Element.prototype.getRelated = function(_elementType, _global) {
+BaseElement.prototype.getRelated = function(_elementType, _global) {
     _global = (typeof _global !== "undefined" && _global);
     var _this = this;
     return this.source.getList(_elementType, _global).filter(function(_el) {
         var _ref = _el[_this.elementType];
         return _ref && _ref.isOrHasId(_this.id);
     });
-}
+};
 
-Model.Element.prototype.on = function(_event, _callback) {
+BaseElement.prototype.on = function(_event, _callback) {
     if (typeof this.__events[_event] === "undefined") {
         this.__events[_event] = [];
     }
     this.__events[_event].push(_callback);
-}
+};
 
-Model.Element.prototype.off = function(_event, _callback) {
+BaseElement.prototype.off = function(_event, _callback) {
     if (typeof this.__events[_event] !== "undefined") {
         this.__events[_event] = ns._(this.__events[_event]).reject(function(_fn) {
             return _fn === _callback;
         });
     }
-}
+};
 
-Model.Element.prototype.trigger = function(_event, _data) {
+BaseElement.prototype.trigger = function(_event, _data) {
     var _element = this;
     ns._(this.__events[_event]).each(function(_callback) {
         _callback.call(_element, _data);
     });
-}
+};
 
 /* */
 
-Model.Playable = function(_id, _source) {
-    Model.Element.call(this, _id, _source);
+var Playable = Model.Playable = function(_id, _source) {
+    BaseElement.call(this, _id, _source);
     if (typeof _source === "undefined") {
         return;
     }
     this.elementType = 'playable';
-    this.currentTime = new Model.Time();
+    this.currentTime = new Time();
     this.volume = .5;
     this.paused = true;
     this.muted = false;
@@ -914,188 +750,188 @@
     });
     this.on("loadedmetadata", function() {
         _this.loadedMetadata = true;
-    })
-}
+    });
+};
 
-Model.Playable.prototype = new Model.Element();
+extendPrototype(Playable, BaseElement);
 
-Model.Playable.prototype.getCurrentTime = function() { 
+Playable.prototype.getCurrentTime = function() { 
     return this.currentTime;
-}
+};
 
-Model.Playable.prototype.getVolume = function() {
+Playable.prototype.getVolume = function() {
     return this.volume;
-}
+};
 
-Model.Playable.prototype.getPaused = function() {
+Playable.prototype.getPaused = function() {
     return this.paused;
-}
+};
 
-Model.Playable.prototype.getMuted = function() {
+Playable.prototype.getMuted = function() {
     return this.muted;
-}
+};
 
-Model.Playable.prototype.setCurrentTime = function(_time) {
+Playable.prototype.setCurrentTime = function(_time) {
     this.trigger("setcurrenttime",_time);
-}
+};
 
-Model.Playable.prototype.setVolume = function(_vol) {
+Playable.prototype.setVolume = function(_vol) {
     this.trigger("setvolume",_vol);
-}
+};
 
-Model.Playable.prototype.setMuted = function(_muted) {
+Playable.prototype.setMuted = function(_muted) {
     this.trigger("setmuted",_muted);
-}
+};
 
-Model.Playable.prototype.play = function() {
+Playable.prototype.play = function() {
     this.trigger("setplay");
-}
+};
 
-Model.Playable.prototype.pause = function() {
+Playable.prototype.pause = function() {
     this.trigger("setpause");
-}
+};
 
-Model.Playable.prototype.show = function() {}
+Playable.prototype.show = function() {};
 
-Model.Playable.prototype.hide = function() {}
+Playable.prototype.hide = function() {};
 
 /* */
 
-Model.Media = function(_id, _source) {
-    Model.Playable.call(this, _id, _source);
+var Media = Model.Media = function(_id, _source) {
+    Playable.call(this, _id, _source);
     this.elementType = 'media';
-    this.duration = new Model.Time();
+    this.duration = new Time();
     this.video = '';
     var _this = this;
-}
+};
 
-Model.Media.prototype = new Model.Playable();
+extendPrototype(Media, Playable);
 
 /* Default functions to be overriden by players */
     
-Model.Media.prototype.setDuration = function(_durationMs) {
+Media.prototype.setDuration = function(_durationMs) {
     this.duration.setMilliseconds(_durationMs);
-}
+};
 
-Model.Media.prototype.getAnnotations = function() {
+Media.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
-}
+};
 
-Model.Media.prototype.getAnnotationsByTypeTitle = function(_title) {
+Media.prototype.getAnnotationsByTypeTitle = function(_title) {
     var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id");
     if (_annTypes.length) {
         return this.getAnnotations().filter(function(_annotation) {
             return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
         });
     } else {
-        return new Model.List(this.source.directory)
+        return new List(this.source.directory)
     }
-}
+};
 
 /* */
 
-Model.Tag = function(_id, _source) {
-    Model.Element.call(this, _id, _source);
+var Tag = Model.Tag = function(_id, _source) {
+    BaseElement.call(this, _id, _source);
     this.elementType = 'tag';
-}
+};
 
-Model.Tag.prototype = new Model.Element();
+extendPrototype(Tag, BaseElement);
 
-Model.Tag.prototype.getAnnotations = function() {
+Tag.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
-}
+};
 
 /* */
-Model.AnnotationType = function(_id, _source) {
-    Model.Element.call(this, _id, _source);
+var AnnotationType = Model.AnnotationType = function(_id, _source) {
+    BaseElement.call(this, _id, _source);
     this.elementType = 'annotationType';
-}
+};
 
-Model.AnnotationType.prototype = new Model.Element();
+extendPrototype(AnnotationType, BaseElement);
 
-Model.AnnotationType.prototype.getAnnotations = function() {
+AnnotationType.prototype.getAnnotations = function() {
     return this.getRelated("annotation");
-}
+};
 
 /* Annotation
  * */
 
-Model.Annotation = function(_id, _source) {
-    Model.Element.call(this, _id, _source);
+var Annotation = Model.Annotation = function(_id, _source) {
+    BaseElement.call(this, _id, _source);
     this.elementType = 'annotation';
-    this.begin = new Model.Time();
-    this.end = new Model.Time();
-    this.tag = new Model.Reference(_source, []);
+    this.begin = new Time();
+    this.end = new Time();
+    this.tag = new Reference(_source, []);
     this.playing = false;
     var _this = this;
     this.on("click", function() {
         _this.getMedia().setCurrentTime(_this.begin);
     });
-}
+};
 
-Model.Annotation.prototype = new Model.Element();
+extendPrototype(Annotation, BaseElement);
 
-Model.Annotation.prototype.setBegin = function(_beginMs) {
+Annotation.prototype.setBegin = function(_beginMs) {
     this.begin.setMilliseconds(Math.max(0,_beginMs));
     this.trigger("change-begin");
     if (this.end < this.begin) {
         this.setEnd(this.begin);
     }
-}
+};
 
-Model.Annotation.prototype.setEnd = function(_endMs) {
+Annotation.prototype.setEnd = function(_endMs) {
     this.end.setMilliseconds(Math.min(_endMs, this.getMedia().duration.milliseconds));
     this.trigger("change-end");
     if (this.end < this.begin) {
         this.setBegin(this.end);
     }
-}
+};
 
-Model.Annotation.prototype.setDuration = function(_durMs) {
+Annotation.prototype.setDuration = function(_durMs) {
     this.setEnd(_durMs + this.begin.milliseconds);
-}
+};
 
-Model.Annotation.prototype.setMedia = function(_idRef) {
+Annotation.prototype.setMedia = function(_idRef) {
     this.setReference("media", _idRef);
-}
+};
 
-Model.Annotation.prototype.getMedia = function() {
+Annotation.prototype.getMedia = function() {
     return this.getReference("media");
-}
+};
 
-Model.Annotation.prototype.setAnnotationType = function(_idRef) {
+Annotation.prototype.setAnnotationType = function(_idRef) {
     this.setReference("annotationType", _idRef);
-}
+};
 
-Model.Annotation.prototype.getAnnotationType = function() {
+Annotation.prototype.getAnnotationType = function() {
     return this.getReference("annotationType");
-}
+};
 
-Model.Annotation.prototype.setTags = function(_idRefs) {
+Annotation.prototype.setTags = function(_idRefs) {
     this.setReference("tag", _idRefs);
-}
+};
 
-Model.Annotation.prototype.getTags = function() {
+Annotation.prototype.getTags = function() {
     return this.getReference("tag");
-}
+};
 
-Model.Annotation.prototype.getTagTexts = function() {
+Annotation.prototype.getTagTexts = function() {
     return this.getTags().getTitles();
-}
+};
 
-Model.Annotation.prototype.getDuration = function() {
-    return new Model.Time(this.end.milliseconds - this.begin.milliseconds)
-}
+Annotation.prototype.getDuration = function() {
+    return new Time(this.end.milliseconds - this.begin.milliseconds)
+};
 
 /* */
 
-Model.MashedAnnotation = function(_mashup, _annotation) {
-    Model.Element.call(this, _mashup.id + "_" + _annotation.id, _annotation.source);
+var MashedAnnotation = Model.MashedAnnotation = function(_mashup, _annotation) {
+    BaseElement.call(this, _mashup.id + "_" + _annotation.id, _annotation.source);
     this.elementType = 'mashedAnnotation';
     this.annotation = _annotation;
-    this.begin = new Model.Time();
-    this.end = new Model.Time();
-    this.duration = new Model.Time();
+    this.begin = new Time();
+    this.end = new Time();
+    this.duration = new Time();
     this.title = this.annotation.title;
     this.description = this.annotation.description;
     this.color = this.annotation.color;
@@ -1109,43 +945,43 @@
     this.on("leave", function() {
         _this.annotation.trigger("leave");
     });
-}
+};
 
-Model.MashedAnnotation.prototype = new Model.Element(null);
+extendPrototype(MashedAnnotation, BaseElement);
 
-Model.MashedAnnotation.prototype.getMedia = function() {
+MashedAnnotation.prototype.getMedia = function() {
     return this.annotation.getReference("media");
-}
+};
 
-Model.MashedAnnotation.prototype.getAnnotationType = function() {
+MashedAnnotation.prototype.getAnnotationType = function() {
     return this.annotation.getReference("annotationType");
-}
+};
 
-Model.MashedAnnotation.prototype.getTags = function() {
+MashedAnnotation.prototype.getTags = function() {
     return this.annotation.getReference("tag");
-}
+};
 
-Model.MashedAnnotation.prototype.getTagTexts = function() {
+MashedAnnotation.prototype.getTagTexts = function() {
     return this.annotation.getTags().getTitles();
-}
+};
 
-Model.MashedAnnotation.prototype.getDuration = function() {
+MashedAnnotation.prototype.getDuration = function() {
     return this.annotation.getDuration();
-}
+};
 
-Model.MashedAnnotation.prototype.setBegin = function(_begin) {
+MashedAnnotation.prototype.setBegin = function(_begin) {
     this.begin.setMilliseconds(_begin);
     this.duration.setMilliseconds(this.annotation.getDuration());
     this.end.setMilliseconds(_begin + this.duration);
-}
+};
 
 /* */
 
-Model.Mashup = function(_id, _source) {
-    Model.Playable.call(this, _id, _source);
+var Mashup = Model.Mashup = function(_id, _source) {
+    Playable.call(this, _id, _source);
     this.elementType = 'mashup';
-    this.duration = new Model.Time();
-    this.segments = new Model.List(_source.directory);
+    this.duration = new Time();
+    this.segments = new List(_source.directory);
     this.loaded = false;
     var _this = this;
     this._updateTimes = function() {
@@ -1154,21 +990,21 @@
     }
     this.on("add", this._updateTimes);
     this.on("remove", this._updateTimes);
-}
+};
 
-Model.Mashup.prototype = new Model.Playable();
+extendPrototype(Mashup, Playable);
 
-Model.Mashup.prototype.updateTimes = function() {
+Mashup.prototype.updateTimes = function() {
     var _time = 0;
     this.segments.forEach(function(_segment) {
         _segment.setBegin(_time);
         _time = _segment.end;
     });
     this.duration.setMilliseconds(_time);
-}
+};
 
-Model.Mashup.prototype.addAnnotation = function(_annotation, _defer) {
-    var _mashedAnnotation = new Model.MashedAnnotation(this, _annotation),
+Mashup.prototype.addAnnotation = function(_annotation, _defer) {
+    var _mashedAnnotation = new MashedAnnotation(this, _annotation),
         _defer = _defer || false;
     this.segments.push(_mashedAnnotation);
     _annotation.on("change-begin", this._updateTimes);
@@ -1176,33 +1012,33 @@
     if (!_defer) {
         this.trigger("add");
     }
-}
+};
 
-Model.Mashup.prototype.addAnnotationById = function(_elId, _defer) {
+Mashup.prototype.addAnnotationById = function(_elId, _defer) {
     var _annotation = this.source.getElement(_elId),
         _defer = _defer || false;
     if (typeof _annotation !== "undefined") {
         this.addAnnotation(_annotation, _defer);
     }
-}
+};
 
-Model.Mashup.prototype.addAnnotations = function(_segments) {
+Mashup.prototype.addAnnotations = function(_segments) {
     var _this = this;
     ns._(_segments).forEach(function(_segment) {
         _this.addAnnotation(_segment, true);
     });
     this.trigger("add");
-}
+};
 
-Model.Mashup.prototype.addAnnotationsById = function(_segments) {
+Mashup.prototype.addAnnotationsById = function(_segments) {
     var _this = this;
     ns._(_segments).forEach(function(_segment) {
         _this.addAnnotationById(_segment, true);
     });
     this.trigger("add");
-}
+};
 
-Model.Mashup.prototype.removeAnnotation = function(_annotation, _defer) {
+Mashup.prototype.removeAnnotation = function(_annotation, _defer) {
     var _defer = _defer || false;
     _annotation.off("change-begin", this._updateTimes);
     _annotation.off("change-end", this._updateTimes);
@@ -1210,9 +1046,9 @@
     if (!_defer) {
         this.trigger("remove");
     }
-}
+};
 
-Model.Mashup.prototype.removeAnnotationById = function(_annId, _defer) {
+Mashup.prototype.removeAnnotationById = function(_annId, _defer) {
     var _defer = _defer || false;
     var _annotation = this.source.getElement(_annId);
 
@@ -1222,72 +1058,72 @@
     if (!_defer) {
         this.trigger("remove");
     }
-}
+};
 
-Model.Mashup.prototype.setAnnotations = function(_segments) {
+Mashup.prototype.setAnnotations = function(_segments) {
     while (this.segments.length) {
         this.removeAnnotation(this.segments[0].annotation, true);
     }
     this.addAnnotations(_segments);
-}
+};
 
-Model.Mashup.prototype.setAnnotationsById = function(_segments) {
+Mashup.prototype.setAnnotationsById = function(_segments) {
     while (this.segments.length) {
         this.removeAnnotation(this.segments[0].annotation, true);
     }
     this.addAnnotationsById(_segments);
-}
+};
 
-Model.Mashup.prototype.hasAnnotation = function(_annotation) {
+Mashup.prototype.hasAnnotation = function(_annotation) {
     return !!ns._(this.segments).find(function(_s) {
         return _s.annotation === _annotation
     });
-}
+};
 
-Model.Mashup.prototype.getAnnotation = function(_annotation) {
+Mashup.prototype.getAnnotation = function(_annotation) {
     return ns._(this.segments).find(function(_s) {
         return _s.annotation === _annotation
     });
-}
+};
 
-Model.Mashup.prototype.getAnnotationById = function(_id) {
+Mashup.prototype.getAnnotationById = function(_id) {
     return ns._(this.segments).find(function(_s) {
         return _s.annotation.id === _id
     });
-}
+};
 
-Model.Mashup.prototype.getAnnotations = function() {
+Mashup.prototype.getAnnotations = function() {
     return this.segments;
-}
+};
 
-Model.Mashup.prototype.getOriginalAnnotations = function() {
-    var annotations = new Model.List(this.source.directory);
+Mashup.prototype.getOriginalAnnotations = function() {
+    var annotations = new List(this.source.directory);
     this.segments.forEach(function(_s) {
         annotations.push(_s.annotation);
     });
     return annotations;
-}
+};
 
-Model.Mashup.prototype.getMedias = function() {
-    var medias = new Model.List(this.source.directory);
+Mashup.prototype.getMedias = function() {
+    var medias = new List(this.source.directory);
     this.segments.forEach(function(_annotation) {
         medias.push(_annotation.getMedia())
     })
     return medias;
-}
+};
 
-Model.Mashup.prototype.getAnnotationsByTypeTitle = function(_title) {
+Mashup.prototype.getAnnotationsByTypeTitle = function(_title) {
     var _annTypes = this.source.getAnnotationTypes().searchByTitle(_title).pluck("id");
     if (_annTypes.length) {
         return this.getAnnotations().filter(function(_annotation) {
             return ns._(_annTypes).indexOf(_annotation.getAnnotationType().id) !== -1;
         });
     } else {
-        return new Model.List(this.source.directory)
+        return new List(this.source.directory)
     }
-}
+};
 
-Model.Mashup.prototype.getAnnotationAtTime = function(_time) {
+Mashup.prototype.getAnnotationAtTime = function(_time) {
     var _list = this.segments.filter(function(_annotation) {
         return _annotation.begin <= _time && _annotation.end > _time;
     });
@@ -1296,22 +1132,22 @@
     } else {
         return undefined;
     }
-}
+};
 
-Model.Mashup.prototype.getMediaAtTime = function(_time) {
+Mashup.prototype.getMediaAtTime = function(_time) {
     var _annotation = this.getAnnotationAtTime(_time);
     if (typeof _annotation !== "undefined") {
         return _annotation.getMedia();
     } else {
         return undefined;
     }
-}
+};
 
 /* */
 
-Model.Source = function(_config) {
-    Model.Element.call(this, false, this);
-    this.status = Model._SOURCE_STATUS_EMPTY;
+var Source = Model.Source = function(_config) {
+    BaseElement.call(this, false, this);
+    this.status = _SOURCE_STATUS_EMPTY;
     this.elementType = "source";
     if (typeof _config !== "undefined") {
         var _this = this;
@@ -1322,117 +1158,117 @@
         this.contents = {};
         this.get();
     }
-}
+};
 
-Model.Source.prototype = new Model.Element();
+extendPrototype(Source, BaseElement);
 
-Model.Source.prototype.addList = function(_listId, _contents) {
+Source.prototype.addList = function(_listId, _contents) {
     if (typeof this.contents[_listId] === "undefined") {
-        this.contents[_listId] = new Model.List(this.directory);
+        this.contents[_listId] = new List(this.directory);
     }
     this.contents[_listId].addElements(_contents);
-}
+};
 
-Model.Source.prototype.getList = function(_listId, _global) {
+Source.prototype.getList = function(_listId, _global) {
     _global = (typeof _global !== "undefined" && _global);
     if (_global) {
         return this.directory.getGlobalList().filter(function(_e) {
             return (_e.elementType === _listId);
         });
     } else {
-        return this.contents[_listId] || new IriSP.Model.List(this.directory);
+        return this.contents[_listId] || new IriSP.List(this.directory);
     }
-}
+};
 
-Model.Source.prototype.forEach = function(_callback) {
+Source.prototype.forEach = function(_callback) {
     var _this = this;
     ns._(this.contents).forEach(function(_value, _key) {
         _callback.call(_this, _value, _key);
     })
-}
+};
 
-Model.Source.prototype.getElement = function(_elId) {
+Source.prototype.getElement = function(_elId) {
     return this.directory.getElement(_elId);
-}
+};
 
-Model.Source.prototype.get = function() {
-    this.status = Model._SOURCE_STATUS_WAITING;
+Source.prototype.get = function() {
+    this.status = _SOURCE_STATUS_WAITING;
     this.handleCallbacks();
-}
+};
 
 /* We defer the callbacks calls so they execute after the queue is cleared */
-Model.Source.prototype.deferCallback = function(_callback) {
+Source.prototype.deferCallback = function(_callback) {
     var _this = this;
     ns._.defer(function() {
         _callback.call(_this);
     });
-}
+};
 
-Model.Source.prototype.handleCallbacks = function() {
-    this.status = Model._SOURCE_STATUS_READY;
+Source.prototype.handleCallbacks = function() {
+    this.status = _SOURCE_STATUS_READY;
     while (this.callbackQueue.length) {
         this.deferCallback(this.callbackQueue.splice(0,1)[0]);
     }
-}
-Model.Source.prototype.onLoad = function(_callback) {
-    if (this.status === Model._SOURCE_STATUS_READY) {
+};
+Source.prototype.onLoad = function(_callback) {
+    if (this.status === _SOURCE_STATUS_READY) {
         this.deferCallback(_callback);
     } else {
         this.callbackQueue.push(_callback);
     }
-}
+};
 
-Model.Source.prototype.serialize = function() {
+Source.prototype.serialize = function() {
     return this.serializer.serialize(this);
-}
+};
 
-Model.Source.prototype.deSerialize = function(_data) {
+Source.prototype.deSerialize = function(_data) {
     this.serializer.deSerialize(_data, this);
-}
+};
 
-Model.Source.prototype.getAnnotations = function(_global) {
+Source.prototype.getAnnotations = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("annotation", _global);
-}
+};
 
-Model.Source.prototype.getMedias = function(_global) {
+Source.prototype.getMedias = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("media", _global);
-}
+};
 
-Model.Source.prototype.getTags = function(_global) {
+Source.prototype.getTags = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("tag", _global);
-}
+};
 
-Model.Source.prototype.getMashups = function(_global) {
+Source.prototype.getMashups = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("mashup", _global);
-}
+};
 
-Model.Source.prototype.getAnnotationTypes = function(_global) {
+Source.prototype.getAnnotationTypes = function(_global) {
     _global = (typeof _global !== "undefined" && _global);
     return this.getList("annotationType", _global);
-}
+};
 
-Model.Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) {
+Source.prototype.getAnnotationsByTypeTitle = function(_title, _global) {
     _global = (typeof _global !== "undefined" && _global);
-    var _res = new Model.List(this.directory),
+    var _res = new List(this.directory),
         _annTypes = this.getAnnotationTypes(_global).searchByTitle(_title);
     _annTypes.forEach(function(_annType) {
         _res.addElements(_annType.getAnnotations(_global));
     })
     return _res;
-}
+};
 
-Model.Source.prototype.getDuration = function() {
+Source.prototype.getDuration = function() {
     var _m = this.currentMedia;
     if (typeof _m !== "undefined") {
         return this.currentMedia.duration;
     }
-}
+};
 
-Model.Source.prototype.getCurrentMedia = function(_opts) {
+Source.prototype.getCurrentMedia = function(_opts) {
     if (typeof this.currentMedia === "undefined") {
         if (_opts.is_mashup) {
             var _mashups = this.getMashups();
@@ -1447,28 +1283,28 @@
         }
     }
     return this.currentMedia;
-}
+};
 
-Model.Source.prototype.merge = function(_source) {
+Source.prototype.merge = function(_source) {
     var _this = this;
     _source.forEach(function(_value, _key) {
         _this.getList(_key).addElements(_value);
     });
-}
+};
 
 /* */
 
-Model.RemoteSource = function(_config) {
-    Model.Source.call(this, _config);
-}
+var RemoteSource = Model.RemoteSource = function(_config) {
+    Source.call(this, _config);
+};
 
-Model.RemoteSource.prototype = new Model.Source();
+extendPrototype(RemoteSource, Source);
 
-Model.RemoteSource.prototype.get = function() {
-    this.status = Model._SOURCE_STATUS_WAITING;
+RemoteSource.prototype.get = function() {
+    this.status = _SOURCE_STATUS_WAITING;
     var _this = this,
         urlparams = this.url_params || {},
-        dataType = (Model.isLocalURL(this.url) ? "json" : "jsonp");
+        dataType = (isLocalURL(this.url) ? "json" : "jsonp");
     urlparams.format = dataType;
     ns.jQuery.ajax({
         url: this.url,
@@ -1480,361 +1316,178 @@
             _this.handleCallbacks();
         }
     });
-}
+};
 
 /* */
 
-Model.Directory = function() {
+var Directory = Model.Directory = function() {
     this.remoteSources = {};
     this.elements = {};
-}
+};
 
-Model.Directory.prototype.remoteSource = function(_properties) {
+Directory.prototype.remoteSource = function(_properties) {
     if (typeof _properties !== "object" || typeof _properties.url === "undefined") {
-        throw "Error : Model.Directory.remoteSource(configuration): configuration.url is undefined";
+        throw "Error : Directory.remoteSource(configuration): configuration.url is undefined";
     }
     var _config = ns._({ directory: this }).extend(_properties);
     _config.url_params = _config.url_params || {};
     var _hash = _config.url + "?" + ns.jQuery.param(_config.url_params);
     if (typeof this.remoteSources[_hash] === "undefined") {
-        this.remoteSources[_hash] = new Model.RemoteSource(_config);
+        this.remoteSources[_hash] = new RemoteSource(_config);
     }
     return this.remoteSources[_hash];
-}
+};
 
-Model.Directory.prototype.newLocalSource = function(_properties) {
+Directory.prototype.newLocalSource = function(_properties) {
     var _config = ns._({ directory: this }).extend(_properties),
-        _res = new Model.Source(_config);
+        _res = new Source(_config);
     return _res;
-}
+};
 
-Model.Directory.prototype.getElement = function(_id) {
+Directory.prototype.getElement = function(_id) {
     return this.elements[_id];
-}
+};
 
-Model.Directory.prototype.addElement = function(_element) {
+Directory.prototype.addElement = function(_element) {
     this.elements[_element.id] = _element;
-}
+};
 
-Model.Directory.prototype.getGlobalList = function() {
-    var _res = new Model.List(this);
+Directory.prototype.getGlobalList = function() {
+    var _res = new List(this);
     _res.addIds(ns._(this.elements).keys());
     return _res;
-}
-
+};
 return Model;
 
 })(IriSP);
 
-/* END model.js */
-
-IriSP.language = 'en';
+/* END js */
 
-IriSP.libFiles = {
-    defaultDir : "js/libs/",
-    inDefaultDir : {
-        underscore : "underscore-min.js",
-        Mustache : "mustache.js",
-        jQuery : "jquery.min.js",
-        jQueryUI : "jquery-ui.min.js",
-        swfObject : "swfobject.js",
-        cssjQueryUI : "jquery-ui.css",
-        popcorn : "popcorn-complete.min.js",
-        jwplayer : "jwplayer.js",
-        raphael : "raphael-min.js",
-        tracemanager : "tracemanager.js",
-        jwPlayerSWF : "player.swf",
-        json : "json2.js",
-        zeroClipboardJs: "ZeroClipboard.js",
-        zeroClipboardSwf: "ZeroClipboard.swf",
-        backbone: "backbone.js",
-        backboneRelational: "backbone-relational.js",
-        paper: "paper.js",
-        jqueryMousewheel: "jquery.mousewheel.min.js",
-        renkanPublish: "renkan.js",
-        processing: "processing-1.3.6.min.js",
-        recordMicSwf: "record_mic.swf"
-    },
-    locations : {
-        // use to define locations outside default_dir
-    },
-    cdn : {
-        jQuery : "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js",
-        jQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.min.js",
-        swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
-        cssjQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/themes/ui-lightness/jquery-ui.css",
-        underscore : "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js",
-        Mustache : "http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.5.0-dev/mustache.min.js",
-        raphael : "http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js",
-        json : "http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js",
-        popcorn: "http://cdn.popcornjs.org/code/dist/popcorn-complete.min.js"
-    },
-    useCdn : false
-}
-
-IriSP.widgetsDir = 'widgets';
+/* HTML player, to be reused in a widget, or elsewhere */
 
-IriSP.widgetsRequirements = {
-    PopcornPlayer: {
-        noCss: true,
-        requires: [ "popcorn" ]
-    },
-    HtmlPlayer: {
-        noCss: true
-    },
-    JwpPlayer: {
-        noCss: true,
-        requires: [ "jwplayer" ]
-    },
-    DailymotionPlayer: {
-        noCss: true,
-        requires: [ "swfObject" ]
-    },
-    AdaptivePlayer: {
-        noCss: true
-    },
-    AutoPlayer: {
-        noCss: true
-    },
-    AnnotationsList: {
-        requires: [ "jwplayer" ]
-    },
-    Sparkline: {
-        noCss: true,
-        requires: [ "raphael" ]
-    },
-    Arrow: {
-        noCss: true,
-        requires: [ "raphael" ]
-    },
-    Mediafragment: {
-        noCss: true
-    },
-    Trace : {
-        noCss: true,
-        requires: [ "tracemanager" ]
-    },
-    Slideshare: {
-        requires: [ "swfObject" ]
-    },
-    Social: {
-        requires: [ "zeroClipboardJs" ]
-    },
-    Renkan: {
-        requires: [ "backbone", "backboneRelational", "paper", "jqueryMousewheel", "renkanPublish" ]
-    },
-    KnowledgeConcierge: {
-        requires: [ "processing" ]
-    },
-    MultiSegments: {
-        noCss: true
+IriSP.htmlPlayer = function(media, jqselector, options) {
+    
+    var opts = options || {},
+        videoURL = opts.video || media.video;
+    
+    if (typeof opts.url_transform === "function") {
+        videoURL = opts.url_transform(videoURL);
     }
-}
-
-IriSP.guiDefaults = {
-    width : 640,            
-    container : 'LdtPlayer',
-    spacer_div_height : 0
-}
-/* Definition of an ancestor for the Widget classes */
-
-if (typeof IriSP.Widgets === "undefined") {
-    IriSP.Widgets = {}
-}
-
-/**
- * @class IriSP.Widget is an "abstract" class. It's mostly used to define some properties common to every widget.
- *
- *  Note that widget constructors are never called directly by the user. Instead, the widgets are instantiated by functions
- *  defined in init.js
- *
- * @constructor
- * @param player - a reference to the player widget
- * @param config - configuration options for the widget
- */
-
-
-IriSP.Widgets.Widget = function(player, config) {
+        
+    var videoEl = IriSP.jQuery('<video>');
+    
+    videoEl.attr({
+        width : opts.width || undefined,
+        height : opts.height || undefined
+    });
     
-    if( typeof player === "undefined") {
-        /* Probably an abstract call of the class when
-         * individual widgets set their prototype */
-        return;
+    if(typeof videoURL === "string"){
+        videoEl.attr("src",videoURL);
+    } else {
+        for (var i = 0; i < videoURL.length; i++) {
+            var _srcNode = IriSP.jQuery('<source>');
+            _srcNode.attr({
+                src: videoURL[i].src,
+                type: videoURL[i].type
+            });
+            videoEl.append(_srcNode);
+        }
+    }
+    
+    jqselector.html(videoEl);
+    
+    if (opts.autostart || opts.autoplay) {
+        videoEl.attr("autoplay", true);
     }
     
-    this.__subwidgets = [];
+    var mediaEl = videoEl[0];
     
-    /* Setting all the configuration options */
-    var _type = config.type,
-        _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults),
-        _this = this;
+    // Binding HTML video functions to media events
+    media.on("setcurrenttime", function(_milliseconds) {
+        try {
+            mediaEl.currentTime = (_milliseconds / 1000);
+        } catch (err) {
+            
+        }
+    });
     
-    IriSP._(_config).forEach(function(_value, _key) {
-       _this[_key] = _value;
+    media.on("setvolume", function(_vol) {
+        media.volume = _vol;
+        try {
+            mediaEl.volume = _vol;
+        } catch (err) {
+            
+        }
     });
     
-    this.$ = IriSP.jQuery('#' + this.container);
+    media.on("setmuted", function(_muted) {
+        media.muted = _muted;
+        try {
+            mediaEl.muted = _muted;
+        } catch (err) {
+            
+        }
+    });
     
-    if (typeof this.width === "undefined") {
-        this.width = this.$.width();
-    } else {
-        this.$.css("width", this.width);
-    }
+    media.on("setplay", function() {
+        try {
+            mediaEl.play();
+        } catch (err) {
+            
+        }
+    });
     
-    if (typeof this.height !== "undefined") {
-        this.$.css("height", this.height);
+    media.on("setpause", function() {
+        try {
+            mediaEl.pause();
+        } catch (err) {
+            
+        }
+    });
+    
+    // Binding DOM events to media
+    function getVolume() {
+        media.muted = mediaEl.muted;
+        media.volume = mediaEl.volume;
     }
     
-    /* Setting this.player at the end in case it's been overriden
-     * by a configuration option of the same name :-(
-     */
-    this.player = player;
-    
-    /* Adding classes and html attributes */
-    this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
+    videoEl.on("loadedmetadata", function() {
+        getVolume();
+        media.trigger("loadedmetadata");
+        media.trigger("volumechange");
+    })
     
-    this.l10n = (
-        typeof this.messages[IriSP.language] !== "undefined"
-        ? this.messages[IriSP.language]
-        : (
-            IriSP.language.length > 2 && typeof this.messages[IriSP.language.substr(0,2)] !== "undefined"
-            ? this.messages[IriSP.language.substr(0,2)]
-            : this.messages["en"]
-        )
-    );
+    videoEl.on("timeupdate", function() {
+        media.trigger("timeupdate", new IriSP.Model.Time(1000*mediaEl.currentTime));
+    });
     
-    /* Loading Metadata if required */
+    videoEl.on("volumechange", function() {
+        getVolume();
+        media.trigger("volumechange");
+    })
     
-    if (this.metadata) {
-        /* Getting metadata */
-        this.source = player.loadMetadata(this.metadata);
-        
-        /* Call draw when loaded */
-        this.source.onLoad(function() {
-            if (_this.media_id) {
-                _this.media = this.getElement(_this.media_id);
-            } else {
-                var _mediaopts = {
-                    is_mashup: _this.is_mashup || false
-                }
-                _this.media = this.getCurrentMedia(_mediaopts);
-            }
-            
-            _this.draw();
-            player.trigger("widget-loaded");
-        });
-    } else {
-        this.draw();
-    }
+    videoEl.on("play", function() {
+        media.trigger("play");
+    });
+    
+    videoEl.on("pause", function() {
+        media.trigger("pause");
+    });
+    
+    videoEl.on("seeking", function() {
+        media.trigger("seeking");
+    });
+    
+    videoEl.on("seeked", function() {
+        media.trigger("seeked");
+    });
     
     
 };
-
-IriSP.Widgets.Widget.prototype.defaults = {}
-
-IriSP.Widgets.Widget.prototype.template = '';
-
-IriSP.Widgets.Widget.prototype.messages = {"en":{}};
-
-IriSP.Widgets.Widget.prototype.templateToHtml = function(_template) {
-    return Mustache.to_html(_template, this);
-}
-
-IriSP.Widgets.Widget.prototype.renderTemplate = function() {
-    this.$.append(this.templateToHtml(this.template));
-}
-
-IriSP.Widgets.Widget.prototype.functionWrapper = function(_name) {
-    var _this = this,
-        _function = this[_name];
-    if (typeof _function !== "undefined") {
-        return function() {
-            return _function.apply(_this, Array.prototype.slice.call(arguments, 0));
-        }
-    } else {
-        console.log("Error, Unknown function IriSP.Widgets." + this.type + "." + _name)
-    }
-}
-
-IriSP.Widgets.Widget.prototype.getFunctionOrName = function(_functionOrName) {
-    switch (typeof _functionOrName) {
-        case "function":
-            return _functionOrName;
-        case "string":
-            return this.functionWrapper(_functionOrName);
-        default:
-            return undefined;
-    }
-}
-
-IriSP.Widgets.Widget.prototype.onMdpEvent = function(_eventName, _functionOrName) {
-    this.player.on(_eventName, this.getFunctionOrName(_functionOrName));
-}
-
-IriSP.Widgets.Widget.prototype.onMediaEvent = function(_eventName, _functionOrName) {
-    this.media.on(_eventName, this.getFunctionOrName(_functionOrName));
-}
-
-IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() {
-    if (typeof this.annotation_type === "undefined") {
-        return this.media.getAnnotations();
-    }
-    if (this.annotation_type.elementType === "annotationType") {
-        return this.annotation_type.getAnnotations();
-    }
-    return this.media.getAnnotationsByTypeTitle(this.annotation_type);
-}
-
-IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() {
-    var _time = this.media.getCurrentTime();
-    return this.getWidgetAnnotations().filter(function(_annotation) {
-        return _annotation.begin <= _time && _annotation.end > _time;
-    });
-}
-
-IriSP.Widgets.Widget.prototype.isLoaded = function() {
-    var isloaded = !IriSP._(this.__subwidgets).any(function(w) {
-        return !(w && w.isLoaded());
-    });
-    return isloaded;
-}
-
-IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) {
-    var _id = _selector.attr("id"),
-        _this = this,
-        _type = _widgetoptions.type,
-        $L = $LAB,
-        key = this.__subwidgets.length;
-    this.__subwidgets.push(null);
-    if (typeof _id == "undefined") {
-        _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type);
-        _selector.attr("id", _id);
-    }
-    _widgetoptions.container = _id;
-    if (typeof IriSP.widgetsRequirements[_type] !== "undefined" && typeof IriSP.widgetsRequirements[_type].requires !== "undefined" ) {
-        for (var _j = 0; _j < IriSP.widgetsRequirements[_type].requires.length; _j++) {
-            $L.script(IriSP.getLib(IriSP.widgetsRequirements[_type].requires[_j]));
-        }
-    }
-    $L.wait(function() {
-        _this.player.loadWidget(_widgetoptions, function(_widget) {
-            if (_propname) {
-                _this[_propname] = _widget;
-            }
-            _this.__subwidgets[key] = _widget;
-        });
-    });
-}
-
-/**
- * This method responsible of drawing a widget on screen.
- */
-IriSP.Widgets.Widget.prototype.draw = function() {
-    /* implemented by "sub-classes" */
-};/* LDT Platform Serializer */
+/* LDT Platform Serializer */
 
 if (typeof IriSP.serializers === "undefined") {
-    IriSP.serializers = {}
+    IriSP.serializers = {};
 }
 
 IriSP.serializers.ldt = {
@@ -2114,12 +1767,12 @@
             _source.currentMedia = _source.getElement(_data.meta.main_media["id-ref"]);
         }
     }
-}
+};
 
-/* Used when Putting annotations on the platform */
+/* End of LDT Platform Serializer *//* ldt_annotate serializer: Used when Putting annotations on the platform */
 
 if (typeof IriSP.serializers === "undefined") {
-    IriSP.serializers = {}
+    IriSP.serializers = {};
 }
 
 IriSP.serializers.ldt_annotate = {
@@ -2190,4 +1843,527 @@
         _source.addList('annotation', new IriSP.Model.List(_source.directory));
         this.deserializeAnnotation(_data, _source);
     }
-}
\ No newline at end of file
+};
+
+/* End ldt_annotate serializer *//* Start of defaults.js */
+
+IriSP.language = 'en';
+
+IriSP.libFiles = {
+    defaultDir : "js/libs/",
+    inDefaultDir : {
+        underscore : "underscore-min.js",
+        Mustache : "mustache.js",
+        jQuery : "jquery.min.js",
+        jQueryUI : "jquery-ui.min.js",
+        swfObject : "swfobject.js",
+        cssjQueryUI : "jquery-ui.css",
+        popcorn : "popcorn-complete.min.js",
+        jwplayer : "jwplayer.js",
+        raphael : "raphael-min.js",
+        tracemanager : "tracemanager.js",
+        jwPlayerSWF : "player.swf",
+        json : "json2.js",
+        zeroClipboardJs: "ZeroClipboard.js",
+        zeroClipboardSwf: "ZeroClipboard.swf",
+        backbone: "backbone.js",
+        backboneRelational: "backbone-relational.js",
+        paper: "paper.js",
+        jqueryMousewheel: "jquery.mousewheel.min.js",
+        renkanPublish: "renkan.js",
+        processing: "processing-1.3.6.min.js",
+        recordMicSwf: "record_mic.swf"
+    },
+    locations : {
+        // use to define locations outside default_dir
+    },
+    cdn : {
+        jQuery : "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js",
+        jQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.min.js",
+        swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
+        cssjQueryUI : "http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/themes/ui-lightness/jquery-ui.css",
+        underscore : "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js",
+        Mustache : "http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.5.0-dev/mustache.min.js",
+        raphael : "http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js",
+        json : "http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js",
+        popcorn: "http://cdn.popcornjs.org/code/dist/popcorn-complete.min.js"
+    },
+    useCdn : false
+};
+
+IriSP.widgetsDir = 'widgets';
+
+IriSP.widgetsRequirements = {
+    PopcornPlayer: {
+        noCss: true,
+        requires: [ "popcorn" ]
+    },
+    HtmlPlayer: {
+        noCss: true
+    },
+    JwpPlayer: {
+        noCss: true,
+        requires: [ "jwplayer" ]
+    },
+    DailymotionPlayer: {
+        noCss: true,
+        requires: [ "swfObject" ]
+    },
+    AdaptivePlayer: {
+        noCss: true
+    },
+    AutoPlayer: {
+        noCss: true
+    },
+    AnnotationsList: {
+        requires: [ "jwplayer" ]
+    },
+    Sparkline: {
+        noCss: true,
+        requires: [ "raphael" ]
+    },
+    Arrow: {
+        noCss: true,
+        requires: [ "raphael" ]
+    },
+    Mediafragment: {
+        noCss: true
+    },
+    Trace : {
+        noCss: true,
+        requires: [ "tracemanager" ]
+    },
+    Slideshare: {
+        requires: [ "swfObject" ]
+    },
+    Social: {
+        requires: [ "zeroClipboardJs" ]
+    },
+    Renkan: {
+        requires: [ "backbone", "backboneRelational", "paper", "jqueryMousewheel", "renkanPublish" ]
+    },
+    KnowledgeConcierge: {
+        requires: [ "processing" ]
+    },
+    MultiSegments: {
+        noCss: true
+    }
+};
+
+IriSP.guiDefaults = {
+    width : 640,            
+    container : 'LdtPlayer',
+    spacer_div_height : 0
+};
+
+/* End of defaults.js */
+/* widgets-container/metadataplayer.js - initialization and configuration of the widgets
+*/
+
+/* The Metadataplayer Object, single point of entry, replaces IriSP.init_player */
+
+(function(ns) {
+
+var formerJQuery, formerUnderscore, former$;
+
+var Metadataplayer = ns.Metadataplayer = function(config) {
+    ns.log("IriSP.Metadataplayer constructor");
+    for (var key in ns.guiDefaults) {
+        if (ns.guiDefaults.hasOwnProperty(key) && !config.hasOwnProperty(key)) {
+            config[key] = ns.guiDefaults[key]
+        }
+    }
+    var _container = document.getElementById(config.container);
+    _container.innerHTML = '<h3 class="Ldt-Loader">Loading... Chargement...</h3>';
+    this.sourceManager = new ns.Model.Directory();
+    this.config = config;
+    this.__events = {};
+    this.loadLibs();
+};
+
+Metadataplayer.prototype.toString = function() {
+    return 'Metadataplayer in #' + this.config.container;
+};
+
+Metadataplayer.prototype.on = function(_event, _callback) {
+    if (typeof this.__events[_event] === "undefined") {
+        this.__events[_event] = [];
+    }
+    this.__events[_event].push(_callback);
+};
+
+Metadataplayer.prototype.trigger = function(_event, _data) {
+    var _element = this;
+    ns._(this.__events[_event]).each(function(_callback) {
+        _callback.call(_element, _data);
+    });
+};
+
+Metadataplayer.prototype.loadLibs = function() {
+    ns.log("IriSP.Metadataplayer.prototype.loadLibs");
+    var $L = $LAB
+        .script(ns.getLib("Mustache"));
+    
+    formerJQuery = !!window.jQuery;
+    former$ = !!window.$;
+    formerUnderscore = !!window._;
+    
+    if (typeof ns.jQuery === "undefined") {
+        $L.script(ns.getLib("jQuery"));
+    }
+    
+    if (typeof ns._ === "undefined") {
+        $L.script(ns.getLib("underscore"));
+    }
+    
+    if (typeof window.JSON == "undefined") {
+        $L.script(ns.getLib("json"));
+    }
+    
+    $L.wait()
+        .script(ns.getLib("jQueryUI"));
+
+    /* widget specific requirements */
+    for(var _i = 0; _i < this.config.widgets.length; _i++) {
+        var _t = this.config.widgets[_i].type;
+        if (typeof ns.widgetsRequirements[_t] !== "undefined" && typeof ns.widgetsRequirements[_t].requires !== "undefined" ) {
+            for (var _j = 0; _j < ns.widgetsRequirements[_t].requires.length; _j++) {
+                $L.script(ns.getLib(ns.widgetsRequirements[_t].requires[_j]));
+            }
+        }
+    }
+    
+    var _this = this;
+    
+    $L.wait(function() {
+        _this.onLibsLoaded();
+    });
+};
+
+Metadataplayer.prototype.onLibsLoaded = function() {
+    ns.log("IriSP.Metadataplayer.prototype.onLibsLoaded");
+    if (typeof ns.jQuery === "undefined" && typeof window.jQuery !== "undefined") {
+        ns.jQuery = window.jQuery;
+        if (former$ || formerJQuery) {
+            window.jQuery.noConflict(formerJQuery);
+        }
+    }
+    if (typeof ns._ === "undefined" && typeof window._ !== "undefined") {
+        ns._ = window._;
+        if (formerUnderscore) {
+            _.noConflict();
+        }
+    }
+    ns.loadCss(ns.getLib("cssjQueryUI"));
+    ns.loadCss(this.config.css);
+    
+    this.$ = ns.jQuery('#' + this.config.container);
+    this.$.css({
+        "width": this.config.width,
+        "clear": "both"
+    });
+    if (typeof this.config.height !== "undefined") {
+        this.$.css("height", this.config.height);
+    }
+      
+    this.widgets = [];
+    var _this = this;
+    ns._(this.config.widgets).each(function(widgetconf, key) {
+        _this.widgets.push(null);
+        _this.loadWidget(widgetconf, function(widget) {
+            _this.widgets[key] = widget;
+            if (widget.isLoaded()) {
+                _this.trigger("widget-loaded");
+            }
+        });
+    });
+    this.$.find('.Ldt-Loader').detach();
+    
+    this.widgetsLoaded = false;
+    
+    this.on("widget-loaded", function() {
+        if (_this.widgetsLoaded) {
+            return;
+        }
+        var isloaded = !ns._(_this.widgets).any(function(w) {
+            return !(w && w.isLoaded())
+        });
+        if (isloaded) {
+            _this.widgetsLoaded = true;
+            _this.trigger("widgets-loaded");
+        }
+    });   
+};
+
+Metadataplayer.prototype.loadMetadata = function(_metadataInfo) {
+    if (_metadataInfo.elementType === "source") {
+        return _metadataInfo;
+    }
+    if (typeof _metadataInfo.serializer === "undefined" && typeof _metadataInfo.format !== "undefined") {
+        _metadataInfo.serializer = ns.serializers[_metadataInfo.format];
+    }
+    if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") {
+        return this.sourceManager.remoteSource(_metadataInfo);
+    } else {
+        return this.sourceManager.newLocalSource(_metadataInfo);
+    }
+};
+
+Metadataplayer.prototype.loadWidget = function(_widgetConfig, _callback) {
+    /* Creating containers if needed */
+    if (typeof _widgetConfig.container === "undefined") {
+        var _divs = this.layoutDivs(_widgetConfig.type);
+        _widgetConfig.container = _divs[0];
+    }
+    
+    var _this = this;
+    
+    if (typeof ns.Widgets[_widgetConfig.type] !== "undefined") {
+        ns._.defer(function() {
+            _callback(new ns.Widgets[_widgetConfig.type](_this, _widgetConfig));
+        });
+    } else {
+        /* Loading Widget CSS */
+        if (typeof ns.widgetsRequirements[_widgetConfig.type] === "undefined" || typeof ns.widgetsRequirements[_widgetConfig.type].noCss === "undefined" || !ns.widgetsRequirements[_widgetConfig.type].noCss) {
+            ns.loadCss(ns.widgetsDir + '/' + _widgetConfig.type + '.css');
+        }
+        /* Loading Widget JS    */
+        $LAB.script(ns.widgetsDir + '/' + _widgetConfig.type + '.js').wait(function() {
+            _callback(new ns.Widgets[_widgetConfig.type](_this, _widgetConfig));
+        });
+    }
+};
+
+/** create a subdiv with an unique id, and a spacer div as well.
+    @param widgetName the name of the widget.
+    @return an array of the form [createdivId, spacerdivId].
+*/
+Metadataplayer.prototype.layoutDivs = function(_name, _height) {
+    if (typeof(_name) === "undefined") {
+       _name = "";
+    }
+    var newDiv = ns._.uniqueId(this.config.container + "_widget_" + _name + "_"),
+        spacerDiv = ns._.uniqueId("LdtPlayer_spacer_"),
+        divHtml = ns.jQuery('<div>')
+            .attr("id",newDiv)
+            .css({
+                width: this.config.width + "px",
+                position: "relative",
+                clear: "both"
+            }),
+        spacerHtml = ns.jQuery('<div>')
+            .attr("id",spacerDiv)
+            .css({
+                width: this.config.width + "px",
+                height: this.config.spacer_div_height + "px",
+                position: "relative",
+                clear: "both"
+            });
+    if (typeof _height !== "undefined") {
+        divHtml.css("height", _height);
+    }
+            
+    this.$.append(divHtml);
+    this.$.append(spacerHtml);
+
+    return [newDiv, spacerDiv];
+};
+
+})(IriSP);
+
+/* End of widgets-container/metadataplayer.js *//* widgetsDefinition of an ancestor for the Widget classes */
+
+if (typeof IriSP.Widgets === "undefined") {
+    IriSP.Widgets = {};
+}
+
+/**
+ * @class IriSP.Widget is an "abstract" class. It's mostly used to define some properties common to every widget.
+ *
+ *  Note that widget constructors are never called directly by the user. Instead, the widgets are instantiated by functions
+ *  defined in init.js
+ *
+ * @constructor
+ * @param player - a reference to the player widget
+ * @param config - configuration options for the widget
+ */
+
+
+IriSP.Widgets.Widget = function(player, config) {
+    
+    if( typeof player === "undefined") {
+        /* Probably an abstract call of the class when
+         * individual widgets set their prototype */
+        return;
+    }
+    
+    this.__subwidgets = [];
+    
+    /* Setting all the configuration options */
+    var _type = config.type,
+        _config = IriSP._.defaults({}, config, player.config.default_options, this.defaults),
+        _this = this;
+    
+    IriSP._(_config).forEach(function(_value, _key) {
+       _this[_key] = _value;
+    });
+    
+    this.$ = IriSP.jQuery('#' + this.container);
+    
+    if (typeof this.width === "undefined") {
+        this.width = this.$.width();
+    } else {
+        this.$.css("width", this.width);
+    }
+    
+    if (typeof this.height !== "undefined") {
+        this.$.css("height", this.height);
+    }
+    
+    /* Setting this.player at the end in case it's been overriden
+     * by a configuration option of the same name :-(
+     */
+    this.player = player;
+    
+    /* Adding classes and html attributes */
+    this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
+    
+    this.l10n = (
+        typeof this.messages[IriSP.language] !== "undefined"
+        ? this.messages[IriSP.language]
+        : (
+            IriSP.language.length > 2 && typeof this.messages[IriSP.language.substr(0,2)] !== "undefined"
+            ? this.messages[IriSP.language.substr(0,2)]
+            : this.messages["en"]
+        )
+    );
+    
+    /* Loading Metadata if required */
+    
+    if (this.metadata) {
+        /* Getting metadata */
+        this.source = player.loadMetadata(this.metadata);
+        
+        /* Call draw when loaded */
+        this.source.onLoad(function() {
+            if (_this.media_id) {
+                _this.media = this.getElement(_this.media_id);
+            } else {
+                var _mediaopts = {
+                    is_mashup: _this.is_mashup || false
+                }
+                _this.media = this.getCurrentMedia(_mediaopts);
+            }
+            
+            _this.draw();
+            player.trigger("widget-loaded");
+        });
+    } else {
+        this.draw();
+    }
+    
+    
+};
+
+IriSP.Widgets.Widget.prototype.defaults = {};
+
+IriSP.Widgets.Widget.prototype.template = '';
+
+IriSP.Widgets.Widget.prototype.messages = {"en":{}};
+
+IriSP.Widgets.Widget.prototype.templateToHtml = function(_template) {
+    return Mustache.to_html(_template, this);
+};
+
+IriSP.Widgets.Widget.prototype.renderTemplate = function() {
+    this.$.append(this.templateToHtml(this.template));
+};
+
+IriSP.Widgets.Widget.prototype.functionWrapper = function(_name) {
+    var _this = this,
+        _function = this[_name];
+    if (typeof _function !== "undefined") {
+        return function() {
+            return _function.apply(_this, Array.prototype.slice.call(arguments, 0));
+        }
+    } else {
+        console.log("Error, Unknown function IriSP.Widgets." + this.type + "." + _name)
+    }
+};
+
+IriSP.Widgets.Widget.prototype.getFunctionOrName = function(_functionOrName) {
+    switch (typeof _functionOrName) {
+        case "function":
+            return _functionOrName;
+        case "string":
+            return this.functionWrapper(_functionOrName);
+        default:
+            return undefined;
+    }
+};
+
+IriSP.Widgets.Widget.prototype.onMdpEvent = function(_eventName, _functionOrName) {
+    this.player.on(_eventName, this.getFunctionOrName(_functionOrName));
+};
+
+IriSP.Widgets.Widget.prototype.onMediaEvent = function(_eventName, _functionOrName) {
+    this.media.on(_eventName, this.getFunctionOrName(_functionOrName));
+};
+
+IriSP.Widgets.Widget.prototype.getWidgetAnnotations = function() {
+    if (typeof this.annotation_type === "undefined") {
+        return this.media.getAnnotations();
+    }
+    if (this.annotation_type.elementType === "annotationType") {
+        return this.annotation_type.getAnnotations();
+    }
+    return this.media.getAnnotationsByTypeTitle(this.annotation_type);
+};
+
+IriSP.Widgets.Widget.prototype.getWidgetAnnotationsAtTime = function() {
+    var _time = this.media.getCurrentTime();
+    return this.getWidgetAnnotations().filter(function(_annotation) {
+        return _annotation.begin <= _time && _annotation.end > _time;
+    });
+};
+
+IriSP.Widgets.Widget.prototype.isLoaded = function() {
+    var isloaded = !IriSP._(this.__subwidgets).any(function(w) {
+        return !(w && w.isLoaded());
+    });
+    return isloaded;
+};
+
+IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _widgetoptions, _propname) {
+    var _id = _selector.attr("id"),
+        _this = this,
+        _type = _widgetoptions.type,
+        $L = $LAB,
+        key = this.__subwidgets.length;
+    this.__subwidgets.push(null);
+    if (typeof _id == "undefined") {
+        _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type);
+        _selector.attr("id", _id);
+    }
+    _widgetoptions.container = _id;
+    if (typeof IriSP.widgetsRequirements[_type] !== "undefined" && typeof IriSP.widgetsRequirements[_type].requires !== "undefined" ) {
+        for (var _j = 0; _j < IriSP.widgetsRequirements[_type].requires.length; _j++) {
+            $L.script(IriSP.getLib(IriSP.widgetsRequirements[_type].requires[_j]));
+        }
+    }
+    $L.wait(function() {
+        _this.player.loadWidget(_widgetoptions, function(_widget) {
+            if (_propname) {
+                _this[_propname] = _widget;
+            }
+            _this.__subwidgets[key] = _widget;
+        });
+    });
+};
+
+/**
+ * This method responsible of drawing a widget on screen.
+ */
+IriSP.Widgets.Widget.prototype.draw = function() {
+    /* implemented by "sub-classes" */
+};
\ No newline at end of file