src/widgets/Annotation.js
changeset 1013 392ddcd212d7
parent 1009 ddbe31de8ad1
child 1025 5fb8d735fde0
equal deleted inserted replaced
1012:7e18d953a1f8 1013:392ddcd212d7
    26         description_: "Description:",
    26         description_: "Description:",
    27         creator_: "Created by\u00a0:",
    27         creator_: "Created by\u00a0:",
    28         excerpt_from: "Excerpt from:",
    28         excerpt_from: "Excerpt from:",
    29         untitled: "Untitled segment"
    29         untitled: "Untitled segment"
    30     }
    30     }
    31 }
    31 };
    32 
    32 
    33 IriSP.Widgets.Annotation.prototype.template =
    33 IriSP.Widgets.Annotation.prototype.template =
    34     '{{#show_arrow}}<div class="Ldt-Annotation-Arrow"></div>{{/show_arrow}}'
    34     '{{#show_arrow}}<div class="Ldt-Annotation-Arrow"></div>{{/show_arrow}}'
    35     + '<div class="Ldt-Annotation-Widget {{^show_arrow}}Ldt-Annotation-ShowTop{{/show_arrow}}">'
    35     + '<div class="Ldt-Annotation-Widget {{^show_arrow}}Ldt-Annotation-ShowTop{{/show_arrow}}">'
    36     + '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty{{#start_minimized}} Ldt-Annotation-Minimized{{/start_minimized}}">'
    36     + '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty{{#start_minimized}} Ldt-Annotation-Minimized{{/start_minimized}}">'
    56     arrow_position: .5,
    56     arrow_position: .5,
    57     site_name : "Lignes de Temps",
    57     site_name : "Lignes de Temps",
    58     search_on_tag_click: true,
    58     search_on_tag_click: true,
    59     show_social: true,
    59     show_social: true,
    60     show_annotation_type: false
    60     show_annotation_type: false
    61 }
    61 };
    62 
    62 
    63 IriSP.Widgets.Annotation.prototype.draw = function() {
    63 IriSP.Widgets.Annotation.prototype.draw = function() {
    64     
    64     
    65     var _this = this,
    65     var _this = this,
    66         currentAnnotation;
    66         currentAnnotation;
   123         highlightTitleAndDescription();
   123         highlightTitleAndDescription();
   124         if (_this.show_creator) {
   124         if (_this.show_creator) {
   125              _this.$.find(".Ldt-Annotation-Creator").text(_annotation.creator);
   125              _this.$.find(".Ldt-Annotation-Creator").text(_annotation.creator);
   126         }
   126         }
   127         if (_this.show_annotation_type) {
   127         if (_this.show_annotation_type) {
   128             _this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title)
   128             _this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title);
   129         }
   129         }
   130         _this.$.find(".Ldt-Annotation-Begin").text(_annotation.begin.toString());
   130         _this.$.find(".Ldt-Annotation-Begin").text(_annotation.begin.toString());
   131         _this.$.find(".Ldt-Annotation-End").text(_annotation.end.toString());
   131         _this.$.find(".Ldt-Annotation-End").text(_annotation.end.toString());
   132         if (_annotation.elementType === "mashedAnnotation") {
   132         if (_annotation.elementType === "mashedAnnotation") {
   133             _this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup");
   133             _this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup");
   177     this.onMdpEvent("Annotation.maximize","maximize");
   177     this.onMdpEvent("Annotation.maximize","maximize");
   178     this.onMdpEvent("Annotation.getBounds","sendBounds");
   178     this.onMdpEvent("Annotation.getBounds","sendBounds");
   179     this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize"));
   179     this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize"));
   180     this.getWidgetAnnotations().forEach(function(_a) {
   180     this.getWidgetAnnotations().forEach(function(_a) {
   181         _a.on("enter", function() {
   181         _a.on("enter", function() {
   182             drawAnnotation(_a)
   182             drawAnnotation(_a);
   183         });
   183         });
   184     });
   184     });
   185     this.source.getAnnotations().on("found", highlightTitleAndDescription);
   185     this.source.getAnnotations().on("found", highlightTitleAndDescription);
   186     this.source.getAnnotations().on("not-found", highlightTitleAndDescription);
   186     this.source.getAnnotations().on("not-found", highlightTitleAndDescription);
   187     this.source.getAnnotations().on("search-cleared", highlightTitleAndDescription);
   187     this.source.getAnnotations().on("search-cleared", highlightTitleAndDescription);
   191 	    	description: currentAnnotation.description,
   191 	    	description: currentAnnotation.description,
   192 	    	image: currentAnnotation.thumbnail,
   192 	    	image: currentAnnotation.thumbnail,
   193 	    	uri: (typeof currentAnnotation.url !== "undefined" 
   193 	    	uri: (typeof currentAnnotation.url !== "undefined" 
   194 	            ? currentAnnotation.url
   194 	            ? currentAnnotation.url
   195 	            : (document.location.href.replace(/#.*$/,'') + '#id='  + currentAnnotation.id))
   195 	            : (document.location.href.replace(/#.*$/,'') + '#id='  + currentAnnotation.id))
   196 	    }
   196 	    };
   197     });
   197     });
   198 }
   198 };
   199 
   199 
   200 IriSP.Widgets.Annotation.prototype.sendBounds = function() {
   200 IriSP.Widgets.Annotation.prototype.sendBounds = function() {
   201     this.player.trigger("Annotation.boundsChanged",this.bounds);
   201     this.player.trigger("Annotation.boundsChanged",this.bounds);
   202 }
   202 };
   203 
   203 
   204 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) {
   204 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) {
   205     this.lastAnnotation = _annotation.id;
   205     this.lastAnnotation = _annotation.id;
   206 
   206 
   207 }
   207 };
   208 
   208 
   209 IriSP.Widgets.Annotation.prototype.hide = function() {
   209 IriSP.Widgets.Annotation.prototype.hide = function() {
   210     this.$.slideUp();
   210     this.$.slideUp();
   211 }
   211 };
   212 
   212 
   213 IriSP.Widgets.Annotation.prototype.show = function() {
   213 IriSP.Widgets.Annotation.prototype.show = function() {
   214     this.$.slideDown();
   214     this.$.slideDown();
   215 }
   215 };
   216 
   216 
   217 IriSP.Widgets.Annotation.prototype.toggleSize = function() {
   217 IriSP.Widgets.Annotation.prototype.toggleSize = function() {
   218     if (this.minimized) {
   218     if (this.minimized) {
   219         this.maximize();
   219         this.maximize();
   220     } else {
   220     } else {
   221         this.minimize();
   221         this.minimize();
   222     }
   222     }
   223 }
   223 };
   224 
   224 
   225 IriSP.Widgets.Annotation.prototype.minimize = function() {
   225 IriSP.Widgets.Annotation.prototype.minimize = function() {
   226     this.minimized = true;
   226     this.minimized = true;
   227     this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized");
   227     this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized");
   228 }
   228 };
   229 
   229 
   230 IriSP.Widgets.Annotation.prototype.maximize = function() {
   230 IriSP.Widgets.Annotation.prototype.maximize = function() {
   231     this.minimized = false;
   231     this.minimized = false;
   232     this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized");
   232     this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized");
   233 }
   233 };