# HG changeset patch # User ymh # Date 1725457015 -7200 # Node ID 3fcce374ca5e4f1448a6f10c86646e1c9c2f6c15 # Parent 8cc1dda7efc8dc2cb1bfa9e0786e9d030f8da70a update metadataplayer diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/AdaptivePlayer.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AdaptivePlayer.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -IriSP.Widgets.AdaptivePlayer = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.AdaptivePlayer.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.AdaptivePlayer.prototype.defaults = { - mime_type: 'video/mp4; codecs="avc1.42E01E"', - normal_player: "HtmlPlayer", - fallback_player: "JwpPlayer" -}; - -IriSP.Widgets.AdaptivePlayer.prototype.draw = function() { - - if (typeof this.video === "undefined") { - this.video = this.media.video; - } - - var _props = [ "autostart", "video", "height", "width", "url_transform" ], - _opts = {}, - _canPlayType = document.createElement('video').canPlayType(this.mime_type); - - _opts.type = (_canPlayType !== "no") ? this.normal_player : this.fallback_player; - - for (var i = 0; i < _props.length; i++) { - if (typeof this[_props[i]] !== "undefined") { - _opts[_props[i]] = this[_props[i]]; - } - } - - this.insertSubwidget(this.$, _opts); - -}; \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/Annotation.css --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -.Ldt-Annotation-Widget { - border-style: none solid solid; - border-width: 1px; - border-color: #b7b7b7; - padding: 0 1px 1px; - margin: 0; -} - -.Ldt-Annotation-Widget.Ldt-Annotation-ShowTop { - border-top-style: solid; - padding-top: 1px; -} - -.Ldt-Annotation-Inner { - background: url(img/pinstripe.png); - padding: 5px; - margin: 0; -} - -.Ldt-Annotation-Inner h3 { - margin: 5px 0; - font-size: 14px; - font-weight: bold; -} - -.Ldt-Annotation-Description { - max-height: 150px; - overflow: auto; -} - -.Ldt-Annotation-Cleared { - clear: both; -} - -.Ldt-Annotation-MaxMinButton { - float: right; margin: 5px 5px 0; width: 17px; height: 17px; - background: url(img/widget-control.png); background-position: 0 -51px; cursor: pointer; -} - -.Ldt-Annotation-Social { - float: right; -} - -.Ldt-Annotation-MaxMinButton:hover { - background-position: -17px -51px; -} - -.Ldt-Annotation-Minimized div.Ldt-Annotation-MaxMinButton { - background-position: 0 -34px; -} - -.Ldt-Annotation-Minimized div.Ldt-Annotation-MaxMinButton:hover { - background-position: -17px -34px; -} - -.Ldt-Annotation-Inner h3.Ldt-Annotation-MashupOrigin { - font-size: 12px; -} - -.Ldt-Annotation-Title, .Ldt-Annotation-MashupMedia { - color: #0068c4; - text-decoration: none; -} - -.Ldt-Annotation-Type { - color: #8080A0; -} - -.Ldt-Annotation-Time { - color: #ff3b77 -} - -.Ldt-Annotation-Inner p { - font-size: 12px; - line-height: 16px; -} - -.Ldt-Annotation-Label { - font-size: 12px; font-weight: bold; max-width: 90px; float: left; clear: left; -} - -.Ldt-Annotation-Labelled { - margin: 5px 0 0 90px; clear: right; -} - -.Ldt-Annotation-Tags-Block { - font-size: 12px; -} - -ul.Ldt-Annotation-Tags { - list-style: none; padding: 0; -} - -li.Ldt-Annotation-TagLabel { - display: inline-block; border: none; margin: 0 10px 5px 0; height: 23px; padding: 0 0 0 20px; - background: url(img/tag.png) left top no-repeat; - cursor: pointer; -} - -.Ldt-Annotation-TagLabel span { - display: inline-block; font-size: 12px; height: 19px; padding: 4px 5px 0 0; border: none; margin: 0; - background: url(img/tag.png) right top no-repeat; -} - -li.Ldt-Annotation-TagLabel:hover { - background-position: left -23px; -} - -.Ldt-Annotation-TagLabel:hover span { - background-position: right -23px; -} - -.Ldt-Annotation-MashupOrigin { - display: none; -} - -.Ldt-Annotation-isMashup .Ldt-Annotation-MashupOrigin { - display: block; -} - -.Ldt-Annotation-Empty .Ldt-Annotation-HiddenWhenEmpty { - display: none; -} - -.Ldt-Annotation-Minimized .Ldt-Annotation-HiddenWhenMinimized { - display: none; -} - -.Ldt-Annotation-EmptyBlock { - display: none; -} - diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/Annotation.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -// TODO: Migrate Timeupdate functions to Extract - -IriSP.Widgets.Annotation = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); - this.lastAnnotation = false; - this.minimized = this.start_minimized || false; - this.bounds = [ 0, 0 ]; -}; - -IriSP.Widgets.Annotation.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.Annotation.prototype.messages = { - fr: { - watching: "Je regarde ", - on_site: " sur ", - tags_: "Mots-clés\u00a0:", - description_: "Description\u00a0:", - creator_: "Créé par\u00a0:", - excerpt_from: "Extrait de\u00a0:", - untitled: "Segment sans titre" - }, - en: { - watching: "I'm watching ", - on_site: " on ", - tags_: "Keywords:", - description_: "Description:", - creator_: "Created by\u00a0:", - excerpt_from: "Excerpt from:", - untitled: "Untitled segment" - } -}; - -IriSP.Widgets.Annotation.prototype.template = - '{{#show_arrow}}
{{/show_arrow}}' - + '
' - + '
' - + '
' - + '{{#show_social}}
{{/show_social}}' - + '

{{#show_annotation_type}} » {{/show_annotation_type}} ' - + '( - )

' - + '

{{l10n.excerpt_from}} ' - + '( - )

' - + '
{{l10n.creator_}}
' - + '{{#show_creator}}

{{/show_creator}}' - + '{{#show_description}}
{{l10n.description_}}
' - + '

{{/show_description}}' - + '
' - + '
{{l10n.tags_}}
    ' - + '
    '; - -IriSP.Widgets.Annotation.prototype.defaults = { - annotation_type : "chap", - start_minimized: false, - show_arrow : true, - show_creator: true, - show_description: true, - arrow_position: .5, - site_name : "Lignes de Temps", - search_on_tag_click: true, - show_social: true, - show_annotation_type: false -}; - -IriSP.Widgets.Annotation.prototype.draw = function() { - - var _this = this, - currentAnnotation; - - function timeupdate(_time) { - var _list = _this.getWidgetAnnotationsAtTime(); - if (!_list.length) { - _this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty"); - if (_this.arrow) { - _this.arrow.moveToTime(_time); - } - _this.bounds = [ _time, _time ]; - _this.sendBounds(); - } - } - - function highlightTitleAndDescription() { - if (!currentAnnotation) { - return; - } - var title = currentAnnotation.title, - description = currentAnnotation.description.replace(/(^\s+|\s+$)/g,''), - rx = (currentAnnotation.found ? (_this.source.getAnnotations().regexp || false) : false); - _this.$.find(".Ldt-Annotation-Title").html(IriSP.textFieldHtml(title,rx) || "(" + _this.l10n.untitled + ")"); - if (description) { - _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock"); - _this.$.find(".Ldt-Annotation-Description").html(IriSP.textFieldHtml(description,rx)); - } else { - _this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock"); - } - } - - function drawAnnotation(_annotation) { - currentAnnotation = _annotation; - var _url = (typeof _annotation.url !== "undefined" - ? _annotation.url - : (document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id)), - _text = _this.l10n.watching + _annotation.title + (_this.site_name ? _this.l10n.on_site + _this.site_name : ''), - _tags = _annotation.getTags(), - _tagblock = _this.$.find(".Ldt-Annotation-Tags"); - _tagblock.empty(); - if (_tags.length) { - _this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock"); - _tags.forEach(function(_tag) { - var _trimmedTitle = _tag.title.replace(/(^\s+|\s+$)/g,''); - if (_trimmedTitle) { - var _el = IriSP.jQuery('
  • ').append(IriSP.jQuery('').text(_trimmedTitle)); - _el.click(function() { - if (_this.search_on_tag_click) { - _this.source.getAnnotations().search(_trimmedTitle); - } - _tag.trigger("click"); - }); - _tagblock.append(_el); - } - }); - } else { - _this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); - } - highlightTitleAndDescription(); - if (_this.show_creator) { - _this.$.find(".Ldt-Annotation-Creator").text(_annotation.creator); - } - if (_this.show_annotation_type) { - _this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title); - _this.$.find(".Ldt-Annotation-Type").attr("title", _annotation.getAnnotationType().description); - } - _this.$.find(".Ldt-Annotation-Begin").text(_annotation.begin.toString()); - _this.$.find(".Ldt-Annotation-End").text(_annotation.end.toString()); - if (_annotation.elementType === "mashedAnnotation") { - _this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-isMashup"); - _this.$.find(".Ldt-Annotation-MashupMedia").text(_annotation.getMedia().title); - _this.$.find(".Ldt-Annotation-MashupBegin").text(_annotation.annotation.begin.toString()); - _this.$.find(".Ldt-Annotation-MashupEnd").text(_annotation.annotation.end.toString()); - } else { - _this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup"); - } - if (typeof _this.socialWidget !== "undefined") { - _this.socialWidget.updateUrls(_url, _text); - } else { - setTimeout(function() { - if (typeof _this.socialWidget !== "undefined") { - _this.socialWidget.updateUrls(_url, _text); - } - },800); - } - _this.$.find(".Ldt-Annotation-Inner").removeClass("Ldt-Annotation-Empty"); - _this.bounds = [ _annotation.begin, _annotation.end ]; - if (_this.arrow) { - _this.arrow.moveToTime((1 - _this.arrow_position) * _annotation.begin + _this.arrow_position * _annotation.end); - } - _this.sendBounds(); - } - - this.renderTemplate(); - - this.$.find(".Ldt-Annotation-Title").click(function() { - if (currentAnnotation) { - _this.media.setCurrentTime(currentAnnotation.begin); - } - return false; - }); - - if (this.show_social) { - this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); - } - - if (this.show_arrow) { - this.insertSubwidget(this.$.find(".Ldt-Annotation-Arrow"), { type: "Arrow", width: this.width }, "arrow"); - } - this.onMediaEvent("timeupdate",timeupdate); - this.onMdpEvent("Annotation.hide","hide"); - this.onMdpEvent("Annotation.show","show"); - this.onMdpEvent("Annotation.minimize","minimize"); - this.onMdpEvent("Annotation.maximize","maximize"); - this.onMdpEvent("Annotation.getBounds","sendBounds"); - this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize")); - this.$.on("resize", function () { _this.width = _this.$.parent().width(); - _this.$.css({ width: _this.width }); - }); - this.getWidgetAnnotations().forEach(function(_a) { - _a.on("enter", function() { - drawAnnotation(_a); - }); - }); - this.source.getAnnotations().on("found", highlightTitleAndDescription); - this.source.getAnnotations().on("not-found", highlightTitleAndDescription); - this.source.getAnnotations().on("search-cleared", highlightTitleAndDescription); - IriSP.attachDndData(this.$.find("h3"), function() { - return { - title: currentAnnotation.title, - description: currentAnnotation.description, - image: currentAnnotation.thumbnail, - uri: (typeof currentAnnotation.url !== "undefined" - ? currentAnnotation.url - : (document.location.href.replace(/#.*$/,'') + '#id=' + currentAnnotation.id)), - text: '[' + currentAnnotation.begin.toString() + '] ' + currentAnnotation.title - }; - }); -}; - -IriSP.Widgets.Annotation.prototype.sendBounds = function() { - this.player.trigger("Annotation.boundsChanged",this.bounds); -}; - -IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) { - this.lastAnnotation = _annotation.id; - -}; - -IriSP.Widgets.Annotation.prototype.hide = function() { - this.$.slideUp(); -}; - -IriSP.Widgets.Annotation.prototype.show = function() { - this.$.slideDown(); -}; - -IriSP.Widgets.Annotation.prototype.toggleSize = function() { - if (this.minimized) { - this.maximize(); - } else { - this.minimize(); - } -}; - -IriSP.Widgets.Annotation.prototype.minimize = function() { - this.minimized = true; - this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized"); -}; - -IriSP.Widgets.Annotation.prototype.maximize = function() { - this.minimized = false; - this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized"); -}; diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.css --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ - -.Ldt-AnnotationsController{ - background: url(img/pinstripe.png); - width: 535px; - max-height: 280px; - margin: 0px; - margin-top: 4px; - border-style: solid; - border-width: 1px; - border-color: #b7b7b7; -} - -.Ldt-AnnotationsController-ButtonsContainer{ - width: 100%; - min-height: 30px; - text-align: center; -} - -.Ldt-AnnotationsController-Button{ - display: inline-block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 25px; - width: 150px; - font-size: 14px; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - margin-right: 10px; - margin-left: 10px; - margin-bottom: 5px; - margin-top: 5px; - padding: 4px; - text-align: center; - vertical-align: middle; - line-height: 30px; -} - -.Ldt-AnnotationsController-Button:hover{ - background-color: #e15581; - border-color: #222222 #e87d9f #f0adc3 #68273c; -} \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsController.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,219 +0,0 @@ -/* - * Widget that ties AnnotationList and CreateAnnotation together - * using buttons to hide/show AnnotationList and CreateAnnotation widgets. - * - */ - -IriSP.Widgets.AnnotationsController = function(player, config){ - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.AnnotationsController.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.AnnotationsController.prototype.defaults = { - // If true, displaying AnnotationList will hide CreateAnnotation and vice versa. - display_or_write: false, - toggle_widgets: false, - starts_hidden: false, - hide_without_segment: false, - hide_when_writing: true, - starting_widget: false, - always_show_widget: false, - segments_annotation_type: "chap", - custom_write_text: false, - custom_display_text: false, -}; - -IriSP.Widgets.AnnotationsController.prototype.template = - "
    " - + "
    " - + "
    {{#custom_write_text}}{{/custom_write_text}}{{custom_write_text}}{{^custom_write_text}}{{l10n.write}}{{/custom_write_text}}
    " - + "
    {{#custom_display_text}}{{/custom_display_text}}{{custom_display_text}}{{^custom_display_text}}{{l10n.display}}{{/custom_display_text}}
    " - + "
    " - + "
    " - -IriSP.Widgets.AnnotationsController.prototype.messages = { - en : { - write : "Write", - display : "Display", - }, - fr : { - write : "Ecrire", - display : "Voir" - } -}; - -IriSP.Widgets.AnnotationsController.prototype.draw = function() { - this.renderTemplate(); - var _this = this; - this.element_$ = this.$.find(".Ldt-AnnotationsController") - - this.displayButton_$ = this.$.find(".Ldt-AnnotationsController-ShowAnnotationsListButton"); - this.writeButton_$ = this.$.find(".Ldt-AnnotationsController-ShowCreateAnnotationButton"); - - this.writeButton_$.click(function(){ - if (!_this.writeButton_$.hasClass("selected")){ - _this.player.trigger("CreateAnnotation.show") - if (_this.display_or_write){ - _this.player.trigger("AnnotationsList.hide"); - } - } - else { - _this.player.trigger("CreateAnnotation.hide") - if (_this.toggle_widgets){ - _this.player.trigger("AnnotationsList.show") - } - else if (_this.display_or_write){ - _this.player.trigger("AnnotationsList.hide"); - } - } - }); - this.displayButton_$.click(function(){ - if (!_this.displayButton_$.hasClass("selected")){ - _this.player.trigger("AnnotationsList.show") - if (_this.display_or_write){ - _this.player.trigger("CreateAnnotation.hide"); - } - } - else { - _this.player.trigger("AnnotationsList.hide") - if (_this.toggle_widgets){ - _this.player.trigger("CreateAnnotation.show") - } - else if (_this.display_or_write){ - _this.player.trigger("CreateAnnotation.hide"); - } - } - - }) - - if(this.hide_without_segment){ - this.onMediaEvent("timeupdate", function(){ - _this.refresh(); - }) - this.onMediaEvent("settimerange", function(_timeRange){ - _this.refresh(_timeRange); - }) - this.segments = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) - this.currentSegment = false - } - - - this.createAnnotationEnabled = false; - this.onMdpEvent("CreateAnnotation.hide", function(){ - if (_this.hide_when_writing){ - _this.show() - } - _this.createAnnotationEnabled = false; - _this.writeButton_$.toggleClass("selected", false); - }) - this.onMdpEvent("CreateAnnotation.show", function(){ - if (_this.hide_when_writing){ - _this.hide() - } - _this.createAnnotationEnabled = true; - _this.writeButton_$.toggleClass("selected", true); - }) - this.onMdpEvent("AnnotationsList.hide", function(){ - _this.displayButton_$.toggleClass("selected", false); - }) - this.onMdpEvent("AnnotationsList.show", function(){ - _this.displayButton_$.toggleClass("selected", true); - }) - - if (this.starts_hidden) { - this.visible = true - this.hide(); - } - else{ - this.visible = false - this.show(); - } - - if (this.starting_widget && this.visible){ - if (this.starting_widget == "AnnotationsList"){ - this.player.trigger("AnnotationsList.show") - } - else if (this.starting_widget == "CreateAnnotation"){ - this.player.trigger("CreateAnnotation.show") - } - } - -}; - -IriSP.Widgets.AnnotationsController.prototype.refresh = function(_timeRange){ - _timeRange = typeof _timeRange !== 'undefined' ? _timeRange : false ; - - if(!_timeRange){ - if (this.media.getTimeRange()){ - _timeRange = this.media.getTimeRange(); - } - } - - if (this.hide_without_segment){ - if (!_timeRange && !this.media.getTimeRange()){ - _currentTime = this.media.getCurrentTime() - _currentSegments = this.segments.filter(function(_segment){ - return (_currentTime >= _segment.begin && _currentTime <= _segment.end) - }); - if(_currentSegments.length > 0){ - currentSegment = true; - } - else { - currentSegment = false; - } - } - else { - var _timeRangeBegin = _timeRange[0], - _timeRangeEnd = _timeRange[1]; - _currentSegments = this.segments.filter(function(_segment){ - return (_timeRangeBegin == _segment.begin && _timeRangeEnd == _segment.end) - }); - if(_currentSegments.length > 0){ - currentSegment = true; - } - else { - currentSegment = false; - } - } - if (!currentSegment && _currentSegments.length == 0){ - if (this.visible || this.hide_when_writing){ - this.writeButton_$.toggleClass("selected", false); - this.displayButton_$.toggleClass("selected", false); - this.player.trigger("CreateAnnotation.hide"); - this.player.trigger("AnnotationsList.hide"); - this.hide(); - } - } - else { - if (!this.visible){ - if (!this.createAnnotationEnabled){ - this.show(); - } - this.writeButton_$.toggleClass("selected", false); - this.displayButton_$.toggleClass("selected", false); - if (this.starting_widget == "AnnotationsList"){ - this.player.trigger("AnnotationsList.show") - } - if (this.starting_widget == "CreateAnnotation"){ - this.player.trigger("CreateAnnotation.show") - } - } - - } - } -} - -IriSP.Widgets.AnnotationsController.prototype.hide = function() { - if (this.visible){ - this.visible = false; - this.element_$.hide(); - } -} - -IriSP.Widgets.AnnotationsController.prototype.show = function() { - if(!this.visible){ - this.visible = true; - this.element_$.show(); - } -} diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,254 +0,0 @@ -/* AnnotationsListWidget */ - -#ui-datepicker-div -{ - display: none; -} - -.Ldt-AnnotationsListWidget { - border: none; - margin: 0; - padding: 0; - overflow: auto; -} -.Ldt-AnnotationsListWidget a { - text-decoration: none; -} - -.Ldt-AnnotationsList-Audio { - width: 1px; height: 1px; -} - -.Ldt-AnnotationsList-Filters { - display: table-cell; - width: 100%; - height: 30px; - vertical-align: middle; - text-align: center; - -} - -.Ldt-AnnotationsList-filter-text { - text-align: left; - display: inline; - margin: 4px 2px; -} - -.Ldt-AnnotationsList-filter-dropdown { - text-align: center; - display: inline; - margin: 4px 2px; -} - -.Ldt-AnnotationsList-filter-checkbox { - text-align: center; - display: inline; - margin: 4px 2px; -} - -ul.Ldt-AnnotationsList-ul, ul.Ldt-AnnotationsList-ul-toDelete { - list-style: none; - padding: 0px; - margin: 0px; -} - -li.Ldt-AnnotationsList-li { - width: 100%; - clear: both; - margin: 2px 0; - padding: 2px 0; - min-height: 3em; - position: relative; -} -.Ldt-AnnotationsList-li.selected { - background-image: url(img/pinstripe-grey.png); - z-index: 1; -} -.Ldt-AnnotationsList-ThumbContainer { - float: left; - width: 80px; - height: 50px; - text-align: center; - margin: 0px 2px 10px 2px; - box-shadow: #808080 0px 0px 2px; -} -.Ldt-AnnotationsList-Thumbnail { - border: none; - max-width: 100%; - max-height: 100%; - margin: 0 auto; -} - -.Ldt-AnnotationsList-External-Icon { - background-image: url(img/external.png); - z-index: 100; - height: 15px; - width: 15px; - position: relative; - bottom: 20px; - left: 64px; -} - -.Ldt-AnnotationsList-DeleteButton { - margin: 0px; - float: right; - font-size: 20px; - position: relative; - top: -50px; - left: -5px; - color: #787878 -} -.Ldt-AnnotationsList-DeleteButton:hover { - color: #f7268e; - cursor: pointer; -} - -.Ldt-AnnotationsList-Duration { - color: #f7268e; - float: right; - text-align: right; - font-size: 12px; - margin: 2px; -} -.Ldt-AnnotationsList-CreationDate { - color: #f7268e; - text-align: left; - font-size: 12px; - margin: 2px 2px 2px 89px; -} -h3.Ldt-AnnotationsList-Title span.Ldt-AnnotationsList-TitleContent{ - color: #0068c4; - font-size: 13px; - margin-left: 5px; - font-weight: bold; -} - -h3.Ldt-AnnotationsList-Title.Ldt-Annotation-Timecode{ - font-size: 13px; -} - -.Ldt-AnnotationsList-Title a { - color: #0068c4; -} - -.Ldt-AnnotationsList-Creator { - color: #4d90f4; - margin-left: 5px; - font-size: 13px; -} - -p.Ldt-AnnotationsList-Description { - margin: 2px 0 2px 89px; - font-size: 12px; - color: #333333; -} - -.Ldt-AnnotationsList-Description a { - color: #0068c4; -} - -.Ldt-AnnotationsList-Description a:hover { - text-decoration: underline; color: #800000; -} - -ul.Ldt-AnnotationsList-Tags { - list-style: none; - padding: 0; - margin: 2px 0 0 82px; -} - -li.Ldt-AnnotationsList-Tag-Li { - display: inline-block; border: none; margin: 0 10px 5px 0; height: 23px; padding: 0 0 0 20px; - background: url(img/tag.png) left top no-repeat; - cursor: pointer; -} - -.Ldt-AnnotationsList-Tag-Li span { - display: inline-block; font-size: 12px; height: 19px; padding: 4px 5px 0 0; border: none; margin: 0; - background: url(img/tag.png) right top no-repeat; -} - -li.Ldt-AnnotationsList-Tag-Li:hover { - background-position: left -23px; -} - -.Ldt-AnnotationsList-Tag-Li:hover span { - background-position: right -23px; -} - -.Ldt-AnnotationsList-Play { - width: 125px; height: 20px; margin: 2px 0 2px 82px; text-align: center; - padding: 3px 5px 0 20px; font-size: 12px; cursor: pointer; - background: url(img/voiceannotation.png); color: #333333; -} - -.Ldt-AnnotationsList-Play:hover { - background-position: 0 bottom; -} - -.Ldt-AnnotationsList-EditControls { - opacity: 0; - position: absolute; - bottom: 2px; - right: 8px; -} - -.Ldt-AnnotationsList-li:hover .Ldt-AnnotationsList-EditControls { - display: inline-block; - opacity: .8; - transition: opacity 1000ms ease-in-out; -} - -.Ldt-AnnotationsList-EditControls > div { - display: inline-block; - width: 16px; - height: 16px; - cursor: pointer; - margin-left: 8px; -} - -.Ldt-AnnotationsList-Delete { - background: url(img/delete.png); -} - -.Ldt-AnnotationsList-Edit { - background: url(img/edit.png); -} - -.Ldt-AnnotationsList-PublishAnnotation { - background: url(img/publish_annotation.png); -} - -.published .Ldt-AnnotationsList-PublishAnnotation { - background: url(img/published_annotation.png); -} - -.Ldt-AnnotationsList .editing { - display: none; -} - -.Ldt-AnnotationsList .editableInput { - width: 80%; -} - -.Ldt-AnnotationsList-ScreenMain{ - margin: 0px; - padding: 0px; -} - -.Ldt-AnnotationsList-ScreenDelete, .Ldt-AnnotationsList-ScreenSending, -.Ldt-AnnotationsList-ScreenError, .Ldt-AnnotationsList-ScreenSuccess{ - margin-top: 15px; - width: 100% - text-align: center; - vertical-align: middle; - font-size: 14px; - font-weight: bold; - color: #68273C; -} - -a.Ldt-AnnotationsList-Close { - position: absolute; right: 2px; - display: inline-block; width: 17px; height: 17px; margin: 4px; - background: url(img/widget-control.png); -} \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1214 +0,0 @@ -IriSP.Widgets.AnnotationsList = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); - this.lastIds = []; - var _this = this; - this.throttledRefresh = IriSP._.throttle(function(full) { - _this.refresh(full); - }, 800); - this.searchString = false; - this.lastSearch = false; - this.localSource = undefined; -}; - -IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.AnnotationsList.prototype.defaults = { - pre_draw_callback: function(){ - return this.importUsers(); - }, - /* - * URL when the annotations are to be reloaded from an LDT-like segment API - * e.g. - * http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=? - */ - ajax_url : false, - /* - * number of milliseconds before/after the current timecode when calling the - * segment API - */ - ajax_granularity : 600000, - default_thumbnail : "", - custom_external_icon : "", - /* - * URL when the annotation is not in the current project, e.g. - * http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}} - */ - foreign_url : "", - annotation_type : false, - refresh_interval : 0, - limit_count : 20, - newest_first : false, - show_title: true, - show_audio: true, - show_creator: true, - show_controls: false, - show_end_time: true, - show_publish: false, - show_twitter: false, - twitter_hashtag: '', - // Callback for Edit action. Leave undefined for default action. - on_edit: undefined, - publish_type: "PublicContribution", - // Used to publish annotations - api_endpoint_template: "", - api_serializer: "ldt_annotate", - api_method: "POST", - editable: false, - // Id that will be used as localStorage key - editable_storage: "", - widget_max_height: 680, - always_visible : false, - start_visible: true, - show_audio : true, - show_filters : false, - keyword_filter: true, - date_filter: true, - user_filter: true, - segment_filter: true, - latest_contributions_filter: false, - current_day_filter: true, - show_header : false, - custom_header : false, - annotations_count_header : true, - annotations_count_header_string: "annotations", - show_creation_date : false, - show_timecode : true, - show_end_time : true, - project_id: "", - /* - * Only annotation in the current segment will be displayed. Designed to work with the Segments Widget. - */ - allow_annotations_deletion: false, - /* - * URL to call when deleting annotation. Expects a mustache template with {{annotation_id}}, ex /api/anotations/{{annotation_id}}/ - */ - api_delete_endpoint : "", - api_delete_method: "DELETE", - api_users_endpoint: "", - api_users_method: "GET", - make_name_string_function: function(params){ - return params.username ? params.username : "Anonymous"; - }, - filter_by_segments: false, - segment_filter: true, - segments_annotation_type: "chap", - /* - * Set to a username if you only want to display annotations from a given user - */ - show_only_annotation_from_user: false, - /* - * Show a text field that filter annotations by username - */ - tags : true, - - polemics : [{ - keyword: "++", - background_color: "#c9ecc6" - },{ - keyword: "--", - background_color: "#f9c5c6" - },{ - keyword: "??", - background_color: "#cec5f9" - },{ - keyword: "==", - background_color: "#f9f4c6" - }] -}; - -IriSP.Widgets.AnnotationsList.prototype.importUsers = function(){ - if (!this.source.users_data && this.api_users_endpoint){ - this.usernames = Array(); - var _this = this, - _list = this.getWidgetAnnotations(), - usernames_list_string = ""; - - _list.forEach(function(_annotation){ - if(_this.usernames.indexOf(_annotation.creator) == -1){ - _this.usernames.push(_annotation.creator); - } - }); - this.usernames.forEach(function(_username){ - usernames_list_string+=_username+"," - }) - usernames_list_string = usernames_list_string.substring(0, usernames_list_string.length - 1); - _url = Mustache.to_html(this.api_users_endpoint, {usernames_list_string: encodeURIComponent(usernames_list_string), usernames_list_length: this.usernames.length}); - return IriSP.jQuery.ajax({ - async: false, - url: _url, - type: "GET", - success: function(_data) { - _this.source.users_data = _data.objects - }, - error: function(_xhr, _error, _thrown) { - console.log(_xhr) - console.log(_error) - console.log(_thrown) - } - }) - } -} - -IriSP.Widgets.AnnotationsList.prototype.messages = { - en: { - voice_annotation: "Voice Annotation", - now_playing: "Now playing...", - previous: "Previous", - next: "Next", - set_time: "Double-click to update to current player time", - edit_annotation: "Edit note", - delete_annotation: "Delete note", - publish_annotation: "Make note public", - import_annotations: "Paste or load notes in this field and press Import.", - confirm_delete_message: "You are about to delete {{ annotation.title }}. Are you sure you want to delete it?", - confirm_publish_message: "You are about to publish {{ annotation.title }}. Are you sure you want to make it public?", - tweet_annotation: "Tweet annotation", - external_annotation: "This annotation was submitted to another project", - everyone: "Everyone", - header: "Annotations for this content", - segment_filter: "All cuttings", - latest_contributions: "Latest contributions", - close_widget: "Close", - confirm: "Confirm", - cancel: "Cancel", - annotation_deletion_delete: "You will delete this annotation", - annotation_deletion_sending: "Your deletion request is being sent ... ", - annotation_deletion_success: "The annotation has been deleted.", - annotation_deletion_error: "There was an error contacting the server. The annotation has not been deleted." - }, - fr: { - voice_annotation: "Annotation Vocale", - now_playing: "Lecture en cours...", - previous: "Précédent", - next: "Suivant", - set_time: "Double-cliquer pour fixer au temps du lecteur", - edit_annotation: "Éditer la note", - delete_annotation: "Supprimer la note", - publish_annotation: "Rendre la note publique", - import_annotations: "Copiez ou chargez des notes dans ce champ et appuyez sur Import", - confirm_delete_message: "Vous allez supprimer {{ annotation.title }}. Êtes-vous certain(e) ?", - confirm_publish_message: "Vous allez publier {{ annotation.title }}. Êtes-vous certain(e) ?", - tweet_annotation: "Tweeter l'annotation", - external_annotation: "Cette annotation a été postée sur un autre projet", - everyone: "Tous", - header: "Annotations sur ce contenu", - segment_filter: "Tous les segments", - latest_contributions: "Dernières contributions", - close_widget: "Fermer", - confirm: "Confirmer", - cancel: "Annuler", - annotation_deletion_delete: "Vous allez supprimer cette annotation", - annotation_deletion_sending: "Votre demande de suppression est en cours d'envoi ... ", - annotation_deletion_success: "L'annotation a été supprimée.", - annotation_deletion_error: "Une erreur s'est produite en contactant le serveur. L'annotation n'a pas été supprimée." - } -}; - -IriSP.Widgets.AnnotationsList.prototype.template = - '{{#show_header}}

    ' - + '{{#custom_header}}{{custom_header}}{{/custom_header}}' - + '{{^custom_header}}{{l10n.header}}{{/custom_header}}' - + '

    {{/show_header}}' - + '
    ' - + '
    ' - + '{{#show_filters}}' - + '
    ' - + '{{#keyword_filter}}{{/keyword_filter}}' - + '{{#user_filter}}{{/user_filter}}' - + '{{#date_filter}}{{/date_filter}}' - + '{{#segment_filter}}{{/segment_filter}}' - + '{{#latest_contributions_filter}}{{/latest_contributions_filter}}' - + '
    ' - + '{{/show_filters}}' - + '{{#show_controls}}
    {{ l10n.previous }} | {{ l10n.next }}
    {{/show_controls}}' - + '{{#show_audio}}
    {{/show_audio}}' - + '
      ' - + '
    ' - + '
    ' - + '{{#allow_annotations_deletion}}' - + '
    ' - + '' - + '{{l10n.annotation_deletion_delete}}' - + '
      ' - + '{{l10n.confirm}} {{l10n.cancel}}' - + '
      ' - + '
      ' - + '' - + '{{l10n.annotation_deletion_sending}}' - + '
      ' - + '
      ' - + '' - + '{{l10n.annotation_deletion_success}}' - + '
      ' - + '
      ' - + '' - + '{{l10n.annotation_deletion_error}}' - + '
      ' - + '{{/allow_annotations_deletion}}' - + '
      '; - -IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = - '
    • ' - + '' - + '{{#allow_annotations_deletion}}' - + '
      ' - + '{{/allow_annotations_deletion}}' - + '{{#show_timecode}}
      {{begin}}{{#show_end_time}} - {{end}}{{/show_end_time}}
      {{/show_timecode}}' - + '

      ' - + '{{#show_title}}{{{htitle}}}{{/show_title}}' - + '{{#show_creator}}{{ creator }}{{/show_creator}}' - + '

      ' - + '

      {{{hdescription}}}

      ' - + '{{#created}}' - + '
      {{{created}}}
      ' - + '{{/created}}' - + '{{#tags.length}}' - + '
        ' - + '{{#tags}}' - + '{{#.}}' - + '
      • ' - + '{{.}}' - + '
      • ' - + '{{/.}}' - + '{{/tags}}' - + '
      ' - + '{{/tags.length}}' - + '{{#audio}}
      {{l10n.voice_annotation}}
      {{/audio}}' - + '
      ' - + '{{#show_twitter}}{{/show_twitter}}' - + '{{#show_publish}}
      {{/show_publish}}' - + '{{#editable}}
      ' - + '
      {{/editable}}' - + '
      ' - + '
    • '; - -// obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project -// + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id; - -IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() { - var _currentTime = this.media.getCurrentTime(), - _duration = this.media.duration; - this.lastAjaxQuery = _currentTime; - var _url = Mustache.to_html(this.ajax_url, { - media : this.source.currentMedia.id, - begin : Math.max(0, _currentTime - this.ajax_granularity), - end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity) - }); - this.currentSource = this.player.loadMetadata(IriSP._.defaults({ - "url" : _url - }, this.metadata)); -}; - -IriSP.Widgets.AnnotationsList.prototype.showScreen = function(_screenName) { - this.$.find('.Ldt-AnnotationsList-Screen' + _screenName).show() - .siblings().hide(); -} - -IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() { - var _currentTime = this.media.getCurrentTime(); - var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime); - if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) { - this.lastMashupAnnotation = _currentAnnotation.id; - var _currentMedia = _currentAnnotation.getMedia(), - _url = Mustache.to_html(this.ajax_url, { - media : _currentMedia.id, - begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity), - end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity) - }); - this.currentSource = this.player.loadMetadata(IriSP._.defaults({ - "url" : _url - }, this.metadata)); - } -}; - -/* - * Import annotations - */ -IriSP.Widgets.AnnotationsList.prototype.importAnnotations = function () { - var widget = this; - var $ = IriSP.jQuery; - var textarea = $("' - + '{{#show_creator_field}}
      {{/show_creator_field}}' - + '
      ' - + '{{#preview_mode}}{{/preview_mode}}' - + '{{^preview_mode}}{{/preview_mode}}' - + '' - + '
      00:00
      ' - + '
      ' - + '{{#show_mic_record}}
      Add voice annotation
      ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + '
      {{/show_mic_record}}' - + '{{#tags.length}}
      {{l10n.add_keywords_}}
        ' - + '{{#tags}}
      • {{title}}
      • {{/tags}}
      {{/tags.length}}' - + '{{#polemics.length}}
      {{l10n.add_polemic_keywords_}}
        ' - + '{{#polemics}}
      • {{keyword}}
      • {{/polemics}}
      {{/polemics.length}}' - + '
      ' - + '
      {{l10n.wait_while_processing}}
      ' - + '
      {{^always_visible}}{{/always_visible}}
      {{l10n.error_while_contacting}}
      ' - + '
      {{^always_visible}}{{/always_visible}}
      {{l10n.annotation_saved}}
      ' - + ''; - -IriSP.Widgets.CreateAnnotation.prototype.draw = function() { - var _this = this; - - this.begin = new IriSP.Model.Time(); - this.end = this.source.getDuration(); - - this.tag_prefix = this.tag_prefix || ""; - - if (this.tag_titles && !this.tags) { - if(!(this.tag_titles.length==1 && this.tag_titles[0]=="")){ - this.tags = IriSP._(this.tag_titles).map(function(_tag_title) { - var _tag, - _tags = _this.source.getTags().searchByTitle(_tag_title, true); - if (_tags.length) { - _tag = _tags[0]; - } else { - _tag = new IriSP.Model.Tag(false, _this.source); - _this.source.getTags().push(_tag); - _tag.title = _tag_title; - } - return _tag; - }); - } - else{ - // we forced no tags if this.tag_titles = [''] (and not false) - this.tags = true; - } - } - if (!this.tags) { - this.tags = this.source.getTags() - .sortBy(function (_tag) { - return -_tag.getAnnotations().length; - }) - .slice(0, this.max_tags) - .map(function(_tag) { - return _tag; - }); - /* We have to use the map function because Mustache doesn't like our tags object */ - } - this.record_swf = IriSP.getLib("recordMicSwf"); - this.renderTemplate(); - if (this.show_mic_record) { - this.recorder = this.$.find("embed")[0]; - - window.setAudioUrl = function(_url) { - _this.audio_url = _url; - } - } - if (this.show_slice) { - this.insertSubwidget( - this.$.find(".Ldt-CreateAnnotation-Slice"), - { - type: "Slice", - show_arrow: this.show_arrow, - annotation_type: this.slice_annotation_type, - onBoundsChanged: function(_from, _to) { - _this.setBeginEnd(_from, _to); - } - }, - "slice" - ); - } else { - if (this.show_arrow) { - this.insertSubwidget(this.$.find(".Ldt-CreateAnnotation-Arrow"), {type: "Arrow"},"arrow"); - } - this.onMediaEvent("timeupdate", function(_time) { - // Do not update timecode if description is not empty - if (_this.$.find(".Ldt-CreateAnnotation-Description").val().trim() == "") { - _this.setBeginEnd(_time, _time); - if (_this.arrow) { - _this.arrow.moveToTime(_time); - } - }; - }); - } - this.$.find(".Ldt-CreateAnnotation-Cancel").click(function() { - _this.player.trigger("CreateAnnotation.hide"); - }); - this.$.find(".Ldt-CreateAnnotation-Close").click(function() { - _this.close_after_send - ? _this.player.trigger("CreateAnnotation.hide") - : _this.showScreen("Main"); - return false; - }); - this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").click(function() { - _this.addKeyword(IriSP.jQuery(this).attr("data-text")); - return false; - }); - this.$.find(".Ldt-CreateAnnotation-PolemicLi").each(function() { - var _el = IriSP.jQuery(this), - _kw = _el.attr("data-text"), - _msg = _this.l10n["polemic" + _kw]; - if (_msg) { - _el.attr("title",_msg); - } - }); - this.$.find(".Ldt-CreateAnnotation-Description").bind("change keyup input paste", this.functionWrapper("onDescriptionChange")); - if (this.show_title_field) { - this.$.find(".Ldt-CreateAnnotation-Title").bind("change keyup input paste", this.functionWrapper("onTitleChange")); - } - if (this.show_creator_field) { - this.$.find(".Ldt-CreateAnnotation-Creator").bind("change keyup input paste", this.functionWrapper("onCreatorChange")); - } - this.$.find("[class^='Ldt-CreateAnnotation-Control-']").click(function() { - var action = this.className.replace('Ldt-CreateAnnotation-Control-', ''); - switch (action) { - case "In": - // Set In bound to current player time - this.setBegin(_this.media.getCurrentTime()); - break; - case "Out": - // Set In bound to current player time - this.setEnd(_this.media.getCurrentTime() || _this.media.duration); - break; - case "Play": - this.media.setCurrentTime(_this.begin); - this.media.play(); - break; - } - return false; - }); - - if (this.start_visible) { - this.show(); - } else { - this.$.hide(); - this.hide(); - } - - this.onMdpEvent("CreateAnnotation.toggle","toggle"); - this.onMdpEvent("CreateAnnotation.hide", "hide"); - this.onMdpEvent("CreateAnnotation.show", "show"); - this.$.find("form").submit(this.functionWrapper("onSubmit")); -}; - -IriSP.Widgets.CreateAnnotation.prototype.setBegin = function (t) { - this.begin = new IriSP.Model.Time(t || 0); - this.$.find(".Ldt-CreateAnnotation-Begin").html(this.begin.toString()); -}; - -IriSP.Widgets.CreateAnnotation.prototype.setEnd = function (t) { - this.end = new IriSP.Model.Time(t || 0); - this.$.find(".Ldt-CreateAnnotation-End").html(this.end.toString()); -}; - -IriSP.Widgets.CreateAnnotation.prototype.setBeginEnd = function (begin, end) { - this.setBegin(begin); - this.setEnd(end); -}; - -IriSP.Widgets.CreateAnnotation.prototype.showScreen = function(_screenName) { - this.$.find('.Ldt-CreateAnnotation-' + _screenName).show() - .siblings().hide(); -}; - -IriSP.Widgets.CreateAnnotation.prototype.show = function() { - if (!this.visible){ - this.visible = true; - if (this.pause_when_displaying){ - this.media.pause(); - } - this.showScreen('Main'); - this.$.find(".Ldt-CreateAnnotation-Description").val("").css("border-color", "#666666").addClass("empty"); - if (this.show_title_field) { - this.$.find(".Ldt-CreateAnnotation-Title").val("").css("border-color", "#666666").addClass("empty"); - } - if (this.show_creator_field) { - this.$.find(".Ldt-CreateAnnotation-Creator").val(this.creator_name).css("border-color", "#666666"); - if (!this.creator_name) { - this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty"); - } - } - this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").removeClass("selected"); - this.$.slideDown(); - if (this.minimize_annotation_widget) { - this.player.trigger("Annotation.minimize"); - } - } -}; - -IriSP.Widgets.CreateAnnotation.prototype.hide = function() { - if (this.visible){ - if (this.recorder) { - this.recorder.stopRecord(); - } - if (!this.always_visible) { - this.visible = false; - this.$.slideUp(); - if (this.minimize_annotation_widget) { - this.player.trigger("Annotation.maximize"); - } - } - } -}; - -IriSP.Widgets.CreateAnnotation.prototype.toggle = function() { - if (!this.always_visible) { - if (this.visible) { - this.hide(); - } else { - var t = this.media.getCurrentTime() || 0; - this.setBeginEnd(t, t); - if (this.slice_widget) { - this.slice_widget.setBounds(this.begin, this.end); - } - this.show(); - // Set focus on textarea - this.$.find(".Ldt-CreateAnnotation-Description").focus(); - } - } -}; - -IriSP.Widgets.CreateAnnotation.prototype.addKeyword = function(_keyword) { - var _field = this.$.find(".Ldt-CreateAnnotation-Description"), - _rx = IriSP.Model.regexpFromTextOrArray(_keyword), - _contents = _field.val(); - _contents = ( !!_contents.match(_rx) - ? _contents.replace(_rx,"") - : _contents + " " + _keyword - ); - _field.val(_contents.replace(/\s{2,}/g,' ').replace(/(^\s+|\s+$)/g,'')); - this.onDescriptionChange(); -}; - -IriSP.Widgets.CreateAnnotation.prototype.pauseOnWrite = function() { - if (this.pause_on_write && !this.media.getPaused()) { - this.media.pause(); - } -}; - -IriSP.Widgets.CreateAnnotation.prototype.onDescriptionChange = function(e) { - if (e !== undefined && e.keyCode == 13 && !e.shiftKey) { - // Return: submit. Use shift-Return to insert a LF - this.onSubmit(); - return true; - } - var _field = this.$.find(".Ldt-CreateAnnotation-Description"), - _contents = _field.val(); - _field.css("border-color", !!_contents ? "#666666" : "#ff0000"); - if (!!_contents) { - _field.removeClass("empty"); - } else { - _field.addClass("empty"); - } - this.$.find(".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi").each(function() { - var _rx = IriSP.Model.regexpFromTextOrArray(IriSP.jQuery(this).attr("data-text")); - if (_contents.match(_rx)) { - IriSP.jQuery(this).addClass("selected"); - } else { - IriSP.jQuery(this).removeClass("selected"); - } - }); - this.pauseOnWrite(); - return !!_contents; -}; - -IriSP.Widgets.CreateAnnotation.prototype.onTitleChange = function() { - var _field = this.$.find(".Ldt-CreateAnnotation-Title"), - _contents = _field.val(); - _field.css("border-color", !!_contents ? "#666666" : "#ff0000"); - if (!!_contents) { - _field.removeClass("empty"); - } else { - _field.addClass("empty"); - } - this.pauseOnWrite(); - return !!_contents; -}; - - -IriSP.Widgets.CreateAnnotation.prototype.onCreatorChange = function() { - var _field = this.$.find(".Ldt-CreateAnnotation-Creator"), - _contents = _field.val(); - _field.css("border-color", !!_contents ? "#666666" : "#ff0000"); - if (!!_contents) { - _field.removeClass("empty"); - } else { - _field.addClass("empty"); - } - this.pauseOnWrite(); - return !!_contents; -}; - -IriSP.Widgets.CreateAnnotation.prototype.onSubmit = function() { - /* If mandatory fields are empty, we cancel the sending */ - if (!this.onDescriptionChange() || (this.show_title_field && !this.onTitleChange()) || (this.show_creator_field && !this.onCreatorChange())) { - return false; - } - - if (this.recorder) { - this.recorder.stopRecord(); - } - - var _this = this, - _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* We create a List to send to the server that will contains the annotation */ - _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* We create a source object using a specific serializer for export */ - _local_export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers['ldt_localstorage']}), /* Source object using a specific serializer for local export */ - _annotation = new IriSP.Model.Annotation(false, _export), /* We create an annotation in the source with a generated ID (param. false) */ - _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* We get the AnnotationType in which the annotation will be added */ - _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* If it doesn't already exists, we create it */ - _url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId}); /* We make the url to send the request to, must include project id */ - - /* If we created an AnnotationType on the spot ... */ - if (!_annotationTypes.length) { - /* ... We must not send its id to the server ... */ - _annotationType.dont_send_id = true; - /* ... And we must include its title. */ - _annotationType.title = this.annotation_type; - } - - /* - * Will fill the generated annotation object's data - * WARNING: If we're on a MASHUP, these datas must refer the ORIGINAL MEDIA - * */ - _annotation.setMedia(this.source.currentMedia.id); /* Annotated media ID */ - - if (this.post_at_segment_time){ - var _currentTime = this.media.getCurrentTime() - var _segmentsAnnotations = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type) - var _currentSegments = _segmentsAnnotations.filter(function(_segment){ - return (_currentTime >= _segment.begin && _currentTime <= _segment.end) - }); - if (_currentSegments.length == 0){ - _annotation.setBegin(this.begin); /* Widget starting timecode */ - _annotation.setEnd(this.end); /* Widget end timecode */ - } - else { - _annotation.setBegin(_currentSegments[0].begin); /* Segment starting timecode */ - _annotation.setEnd(_currentSegments[0].end); /* Segment end timecode */ - } - } - else { - _annotation.setBeginEnd(this.begin, this.end); /* Widget end/start timecodes */ - } - _annotation.setAnnotationType(_annotationType.id); /* Annotation type ID */ - if (this.show_title_field) { - /* Title field, only if it's visible */ - _annotation.title = this.$.find(".Ldt-CreateAnnotation-Title").val(); - }if (this.project_id != ""){ - /* Project id, only if it's been specifiec in the config */ - _annotation.project_id = this.project_id; - } - _annotation.created = new Date(); /* Annotation creation date */ - _annotation.description = this.$.find(".Ldt-CreateAnnotation-Description").val(); /* Description field */ - - var tagIds = Array.prototype.map.call( - this.$.find(".Ldt-CreateAnnotation-TagLi.selected"), - function(el) { return IriSP.jQuery(el).attr("tag-id"); } - ); - - IriSP._(_annotation.description.match(/#[^\s#.,;]+/g)).each(function(_tt) { - var _tag, - _tag_title = _tt.replace(/^#/,''), - _tags = _this.source.getTags().searchByTitle(_tag_title, true); - if (_tags.length) { - _tag = _tags[0]; - } else { - _tag = new IriSP.Model.Tag(false, _this.source); - _this.source.getTags().push(_tag); - _tag.title = _tag_title; - } - if (tagIds.indexOf(_tag.id) === -1) { - tagIds.push(_tag.id); - } - }); - _annotation.setTags(IriSP._(tagIds).uniq()); /* Tag ids list */ - if (this.audio_url) { - _annotation.audio = { - src: "mic", - mimetype: "audio/mp3", - href: this.audio_url - }; - } - if (this.show_creator_field) { - _annotation.creator = this.$.find(".Ldt-CreateAnnotation-Creator").val(); - } else { - _annotation.creator = this.creator_name; - } - _exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */ - - if (this.editable_storage != '') { - // Append to localStorage annotations - - // FIXME: handle movie ids - _local_export.addList("annotation", _exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */ - _this.source.merge(_local_export); /* On ajoute la nouvelle annotation au recueil original */ - // Import previously saved local annotations - if (window.localStorage[this.editable_storage]) { - _local_export.deSerialize(window.localStorage[this.editable_storage]); - } - // Save everything back - window.localStorage[_this.editable_storage] = _local_export.serialize(); - _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */ - _this.player.trigger("Annotation.create", _annotation); - _this.$.find(".Ldt-CreateAnnotation-Description").val(""); - } - - if (_url !== "") { - _exportedAnnotations.push(_annotation); /* We add the annotation in the list to export */ - _export.addList("annotation",_exportedAnnotations); /* We add the list to the source object */ - var _this = this; - /* We send the AJAX request to the server ! */ - IriSP.jQuery.ajax({ - url: _url, - type: this.api_method, - contentType: 'application/json', - data: _export.serialize(), /* Source is serialized */ - success: function(_data) { - _this.showScreen('Saved'); - if (_this.after_send_timeout) { - window.setTimeout( - function() { - _this.close_after_send - ? _this.player.trigger("CreateAnnotation.hide") - : _this.player.trigger("CreateAnnotation.show"); - }, - _this.after_send_timeout - ); - } - _export.getAnnotations().removeElement(_annotation, true); /* We delete the sent annotation to avoid redundancy */ - _export.deSerialize(_data); /* Data deserialization */ - _this.source.merge(_export); /* We merge the deserialized data with the current source data */ - if (_this.pause_on_write && _this.media.getPaused()) { - _this.media.play(); - } - _this.player.trigger("AnnotationsList.refresh"); - }, - error: function(_xhr, _error, _thrown) { - IriSP.log("Error when sending annotation", _thrown); - _export.getAnnotations().removeElement(_annotation, true); - _this.showScreen('Error'); - window.setTimeout(function(){ - _this.showScreen("Main") - }, - (_this.after_send_timeout || 5000)); - } - }); - this.showScreen('Wait'); - }; - return false; -}; - diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/CurrentSegmentInfobox.css --- a/src/ldt/ldt/static/ldt/metadataplayer/CurrentSegmentInfobox.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -.Ldt-CurrentSegmentInfobox{ - background: url(img/pinstripe.png); - width: 535px; - max-height: 280px; - margin: 0px; - margin-top: 4px; - border-style: solid; - border-width: 1px; - border-color: #b7b7b7; -} - -.Ldt-CurrentSegmentInfobox-Element{ - margin: 5px; - vertical-align: top; -} - -.Ldt-CurrentSegmentInfobox-Tags-Ul{ - list-style: none; - margin: 0px; -} - -.Ldt-CurrentSegmentInfobox-Tags{ - margin: 0px; -} - -.Ldt-CurrentSegmentInfobox-Tags-Li{ - display: inline-block; - background-color: #ffffff; - margin: 2px; - padding: 2px; - border: solid 1px; - border-color: #aeaeae; -} - -.Ldt-CurrentSegmentInfobox-Title{ - color: #0068c4; - font-size: 15px; - font-weight: bold; -} - -.Ldt-CurrentSegmentInfobox-Description{ - font-size: 13px; - font-weight: bold; -} - -textarea.Ldt-CurrentSegmentInfobox-DescriptionInput.Ldt-CurrentSegmentInfobox-Description{ - display: inline-block; - width: 95%; -} - -.Ldt-CurrentSegmentInfobox-Tags{ -} - -.Ldt-CurrentSegmentInfobox-NoSegment{ - font-size: 15px; - font-weight: bold; -} - -.Ldt-CurrentSegmentInfobox-SubmitButton{ - display: inline-block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 14px; - width: 100px; - margin: 2px; - margin-top: 5px; - padding: 2px; - font-size: 11px; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - text-align: center; - vertical-align: middle; -} - -.Ldt-CurrentSegmentInfobox-CancelButton{ - display: inline-block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 14px; - width: 100px; - margin: 2px; - margin-top: 5px; - margin-right: 5px; - padding: 2px; - font-size: 11px; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - text-align: center; - vertical-align: middle; -} - -.Ldt-CurrentSegmentInfobox-CreateTagButton{ - display: block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 14px; - width: 75px; - margin: 2px; - padding: 2px; - font-size: 11px; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - text-align: center; - vertical-align: middle; -} - -.Ldt-CurrentSegmentInfobox-Tags-Li-Input{ - width: 80px; -} - -.Ldt-CurrentSegmentInfobox-EditButton{ - float: right; - display: inline-block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 18px; - width: 95px; - font-size: 14px; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - margin-right: 5px; - margin-left: 5px; - margin-bottom: 5px; - margin-top: 5px; - padding: 4px; - text-align: center; - vertical-align: middle; - line-height: 18px; -} - -.Ldt-CurrentSegmentInfobox-EditButton:hover, .Ldt-CurrentSegmentInfobox-CreateTagInput-Add:hover{ - background-color: #e15581; - border-color: #222222 #e87d9f #f0adc3 #68273c; -} - -.Ldt-CurrentSegmentInfobox-CreateTagButton:hover, .Ldt-CurrentSegmentInfobox-CancelButton:hover, -.Ldt-CurrentSegmentInfobox-SubmitButton:hover{ - background-color: #e15581; - border-color: #222222 #e87d9f #f0adc3 #68273c; -} - -.Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton{ - font-weight: bold; - color: #d93c71 -} - -.Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton:hover{ - color: #e16e93 -} - -.Ldt-CurrentSegmentInfobox-FieldsHeader{ - margin: 5px; -} - -.Ldt-CurrentSegmentInfobox-TagsHeader{ - margin-top: 10px; - margin-left: 5px; -} - -.Ldt-CurrentSegmentInfobox-CreateTagInput{ - border: 2px solid #848484; - margin: 5px 2px; - padding: 4px; -} - -.Ldt-CurrentSegmentInfobox-CreateTagInput-Add{ - margin: 5px; - padding: 4px; - display: inline-block; - background-color: #d93c71; - color: #ffffff; - cursor: pointer; - height: 14px; - width: 14px; - font-size: 14px; - font-style: bold; - border: 1px solid; - border-color: #eca3bc #631e34 #36101c #e16e93; - cursor: pointer; - padding: 4px; - text-align: center; - vertical-align: middle; - line-height: 14px; -} \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/CurrentSegmentInfobox.js --- a/src/ldt/ldt/static/ldt/metadataplayer/CurrentSegmentInfobox.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,334 +0,0 @@ -/* Widget displays info on the current segment, with possibility of config for editing description and tags */ - -IriSP.Widgets.CurrentSegmentInfobox = function(player, config){ - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.CurrentSegmentInfobox.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.CurrentSegmentInfobox.prototype.defaults = { - annotation_type: "chap", - editable_segments: false, - empty_message: false, - project_id: false, - api_serializer: "ldt_annotate", - api_method: "PUT", - api_endpoint_template: "", - new_tag_button: true, - show_headers: false, - custom_edit_text: false, - empty_description_placeholder: false, -}; - -IriSP.Widgets.CurrentSegmentInfobox.prototype.template = - '
      ' - + '
      ' - + '{{#editable_segments}}
      {{edit}}
      {{/editable_segments}}' - + '
      {{title}}
      ' - + '
      {{description}}
      ' - + '{{^description}}{{^tags.length}}{{#description_placeholder}}
      {{description_placeholder}}
      {{/description_placeholder}}{{/tags.length}}{{/description}}' - + '
      ' - + '{{#tags.length}}' - + '
        ' - + '{{#tags}}' - + '{{#.}}' - + '
      • ' - + '{{.}}' - + '
      • ' - + '{{/.}}' - + '{{/tags}}' - + '
      ' - + '{{/tags.length}}' - + '
      ' - + '
      ' - + '
      ' - -IriSP.Widgets.CurrentSegmentInfobox.prototype.editTemplate = - '
      ' - + '
      ' - + '{{#headers}}
      {{fields_header}}
      {{/headers}}' - + '' - + '' - + '
      ' - + '{{#headers}}
      {{tags_header}}
      {{/headers}}' - + '{{#new_tag_button}}' - + '
      {{new_tag}}
      ' - + '{{/new_tag_button}}' - + '{{^new_tag_button}}' - + '' - + '
      +
      ' - + '{{/new_tag_button}}' - + '
        ' - + '{{#tags}}' - + '{{#.}}' - + '
      • ' - + '' - + '
        {{delete_tag}}
        ' - + '
      • ' - + '{{/.}}' - + '{{/tags}}' - + '
      ' - + '
      ' - + '
      {{submit}}
      ' - + '
      {{cancel}}
      ' - + '
      ' - + '
      ' - -IriSP.Widgets.CurrentSegmentInfobox.prototype.messages = { - fr : { - submit : "Soumettre", - cancel : "Annuler", - edit : "Editer", - new_tag : "Nouveau tag", - delete_tag : "Supprimer", - fields_header : "Commentaire associé à ce segment", - tags_header : "Mots-clés associés à ce segment", - empty : "Le player vidéo ne lit actuellement aucun segment" - }, - en: { - submit : "Submit", - cancel : "Cancel", - edit : "Edit", - new_tag : "New tag", - delete_tag : "Delete tag", - fields_header : "Current segment content", - tags_header : "Current segment tags", - empty : "The player currently doesn't read any segment" - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.draw = function() { - var _this = this; - this.segments = this.getWidgetAnnotations(); - this.renderTemplate(); - this.currentSegment = false; - this.clearBox(); - this.refresh(); - this.onMediaEvent("timeupdate", "refresh"); - this.onMediaEvent("settimerange", function(_timeRange){ - var _segmentBegin = _timeRange[0], - _segmentEnd = _timeRange[1], - _list = _this.segments.filter(function(_segment){ - return _segment.begin.milliseconds == _segmentBegin.milliseconds && _segment.end.milliseconds == _segmentEnd.milliseconds - }); - if (_list.length >0){ - _this.$.toggleClass("editing", false); - if (_this.currentSegment.id != _list[0].id){ - _this.currentSegment = _list[0]; - _data = { - editable_segments: _this.editable_segments, - edit: _this.custom_edit_text ? _this.custom_edit_text : _this.l10n.edit, - title: _this.currentSegment.title, - description : _this.currentSegment.description, - description_placeholder : _this.empty_description_placeholder, - tags : _this.currentSegment.getTagTexts() - } - _this.$.html(Mustache.to_html(_this.template, _data)) - if(_this.editable_segments&&_this.currentSegment){ - _this.$.find(".Ldt-CurrentSegmentInfobox").click(_this.functionWrapper("enableEditMode")); - } - } - } - }); - - if(this.editable_segments&&this.currentSegment){ - this.$.find(".Ldt-CurrentSegmentInfobox").click(_this.functionWrapper("enableEditMode")); - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.enableEditMode = function() { - var _this = this; - if(this.currentSegment){ - _data = { - title: this.currentSegment.title, - description : this.currentSegment.description, - tags : this.currentSegment.getTagTexts(), - submit : this.l10n.submit, - cancel : this.l10n.cancel, - headers : this.show_headers, - tags_header : this.custom_tags_header ? this.custom_tags_header : this.l10n.tags_header, - fields_header : this.custom_fields_header ? this.custom_fields_header : this.l10n.fields_header, - new_tag : this.l10n.new_tag, - delete_tag : this.l10n.delete_tag, - new_tag_button : this.new_tag_button, - } - this.$.toggleClass("editing", true); - this.$.html(Mustache.to_html(this.editTemplate, _data)); - this.$.find(".Ldt-CurrentSegmentInfobox-CancelButton").click(this.functionWrapper("disableEditMode")); - if (this.new_tag_button){ - this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagButton").click(this.functionWrapper("insertTagInput")); - } else { - this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput").keypress(this.functionWrapper("insertTagInputKeypress")); - this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput-Add").click(this.functionWrapper("insertTagInputKeypress")); - } - this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click(this.functionWrapper("deleteTagInput")); - this.$.find(".Ldt-CurrentSegmentInfobox-SubmitButton").click(this.functionWrapper("onSubmit")) - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.disableEditMode = function() { - if(this.currentSegment){ - _data = { - editable_segments: this.editable_segments, - edit: this.custom_edit_text ? this.custom_edit_text : this.l10n.edit, - title: this.currentSegment.title, - description : this.currentSegment.description, - description_placeholder : this.empty_description_placeholder, - tags : this.currentSegment.getTagTexts() - } - this.$.toggleClass("editing", false); - this.$.html(Mustache.to_html(this.template, _data)); - this.$.find(".Ldt-CurrentSegmentInfobox").click(this.functionWrapper("enableEditMode")); - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.insertTagInput = function() { - if((!this.currentSegment.getTagTexts().length)&&(!this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").length)){ - this.$.find(".Ldt-CurrentSegmentInfobox-Tags").prepend('') - } - this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").append( - '
    • ' - +'' - +'
      '+this.l10n.delete_tag+'
      ' - +'
    • '); - this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click(this.functionWrapper("deleteTagInput")); -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.insertTagInputKeypress = function(event) { - var keycode = (event.keyCode ? event.keyCode : event.which); - if(keycode == '13' || event.type == 'click'){ - if((!this.currentSegment.getTagTexts().length)&&(!this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").length)){ - this.$.find(".Ldt-CurrentSegmentInfobox-Tags").prepend('') - } - this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Ul").append( - '
    • ' - +'' - +'
      '+this.l10n.delete_tag+'
      ' - +'
    • '); - this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-DeleteTagButton").click(this.functionWrapper("deleteTagInput")); - this.$.find(".Ldt-CurrentSegmentInfobox-CreateTagInput").val(""); - return false; - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.deleteTagInput = function(clickEvent) { - $(clickEvent.currentTarget).parent().remove(); -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.onSubmit = function() { - new_tags_titles = this.$.find(".Ldt-CurrentSegmentInfobox-Tags-Li-Input").map(function(){ - if($(this).val()){ - return $(this).val() - } - }); - new_title = this.$.find(".Ldt-CurrentSegmentInfobox-TitleInput").val() - new_description = this.$.find(".Ldt-CurrentSegmentInfobox-DescriptionInput").val() - - var _this = this, - _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* We create an Annotations List to send to the server */ - _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* We create a source object using a specific serializer for export */ - _annotation = new IriSP.Model.Annotation(this.currentSegment.id, _export); /* We create an annotation in the source with a generated ID (param. false) */ - - _annotation.setAnnotationType(this.currentSegment.getAnnotationType().id); - _annotation.setMedia(this.currentSegment.getMedia().id); - _annotation.setBegin(this.currentSegment.begin); - _annotation.setEnd(this.currentSegment.end); - _annotation.created = this.currentSegment.created; - _annotation.creator = this.currentSegment.creator; - _annotation.title = new_title /* Title field */ - _annotation.description = new_description /* Description field */ - var _tagIds = IriSP._(new_tags_titles).map(function(_title) { - var _tags = _this.source.getTags(true).searchByTitle(_title, true); - if (_tags.length) { - var _tag = _tags[0]; - } - else { - _tag = new IriSP.Model.Tag(_title.replace(/\W/g,'_'), _this.source); - _tag.title = _title; - _this.source.getTags().push(_tag); - } - return _tag.id; - }); - _annotation.setTags(_tagIds); - _annotation.project_id = this.project_id; - - _exportedAnnotations.push(_annotation); /* We add the annotation in the list to export */ - _export.addList("annotation",_exportedAnnotations); /* We add the list to the source object */ - - _url = Mustache.to_html(this.api_endpoint_template, {annotation_id: this.currentSegment.id}); - - IriSP.jQuery.ajax({ - url: _url, - type: this.api_method, - contentType: 'application/json', - data: _export.serialize(), /* Source is serialized */ - success: function(_data) { - _export.getAnnotations().removeElement(_annotation, true); /* We delete the sent annotation to avoid redundancy */ - _export.deSerialize(_data); /* Data deserialization */ - _this.source.merge(_export); /* We merge the deserialized data with the current source data */ - _this.segments.forEach(function(_segment){ - if (_segment.id == _annotation.id){ - _this.segments.removeElement(_segment) - } - }) - _this.segments.push(_annotation) - _this.currentSegment = _annotation - _data = { - editable_segments: _this.editable_segments, - edit: _this.custom_edit_text ? _this.custom_edit_text : _this.l10n.edit, - title: _this.currentSegment.title, - description : _this.currentSegment.description, - description_placeholder : _this.empty_description_placeholder, - tags : _this.currentSegment.getTagTexts() - } - _this.$.html(Mustache.to_html(_this.template, _data)) - if(_this.editable_segments&&_this.currentSegment){ - _this.$.find(".Ldt-CurrentSegmentInfobox").click(_this.functionWrapper("enableEditMode")); - } - _this.$.toggleClass("editing", false); - }, - error: function(_xhr, _error, _thrown) { - IriSP.log("Error when sending annotation", _thrown); - _export.getAnnotations().removeElement(_annotation, true); - } - }); -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.refresh = function() { - if(!this.media.getTimeRange()){ - var _currentTime = this.media.getCurrentTime(); - var _list = this.segments.filter(function(_segment){ - return (_segment.begin <= _currentTime && _segment.end >= _currentTime); - }) - - if (_list.length > 0){ - if (this.currentSegment.id != _list[0].id){ - this.currentSegment = _list[0]; - _data = { - editable_segments: this.editable_segments, - edit: this.custom_edit_text ? this.custom_edit_text : this.l10n.edit, - title: this.currentSegment.title, - description : this.currentSegment.description, - description_placeholder : this.empty_description_placeholder, - tags : this.currentSegment.getTagTexts() - } - this.$.html(Mustache.to_html(this.template, _data)) - if(this.editable_segments&&this.currentSegment){ - this.$.find(".Ldt-CurrentSegmentInfobox").click(this.functionWrapper("enableEditMode")); - } - } - } - else { - this.currentSegment = false; - this.clearBox(); - } - } -} - -IriSP.Widgets.CurrentSegmentInfobox.prototype.clearBox = function(){ - var _empty_message = this.l10n.empty - if (this.empty_message) { - _empty_message = this.empty_message - } - this.$.find(".Ldt-CurrentSegmentInfobox").html("
      "+_empty_message+"
      "); -} \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/DailymotionPlayer.js --- a/src/ldt/ldt/static/ldt/metadataplayer/DailymotionPlayer.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,150 +0,0 @@ -IriSP.Widgets.DailymotionPlayer = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.DailymotionPlayer.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.DailymotionPlayer.prototype.defaults = { - aspect_ratio: 14/9 -}; - -IriSP.Widgets.DailymotionPlayer.prototype.draw = function() { - - if (typeof this.video === "undefined") { - this.video = this.media.video; - } - - this.height = this.height || Math.floor(this.width / this.aspect_ratio); - - var _media = this.media, - videoid = null, - _this = this, - state = { - pause: true, - apiready: false, - volume: 0, - time: 0, - duration: 0 - }; - - var m = this.video.match(/www.dailymotion.com\/video\/(.+)/); - if (m) { - videoid = m[1]; - } - - var player_url = Mustache.to_html('{{ protocol }}//www.dailymotion.com/embed/video/{{ videoid }}', { - protocol: document.location.protocol.search('http') == 0 ? document.location.protocol : 'http:', - videoid: videoid - }); - var params = { - 'api': 'postMessage', - 'chromeless': 1, - 'id': 'dm_player', - 'related': 0, - 'autoplay': 1 - }; - - _this.$.html(Mustache.to_html('', { - player_url: player_url, - params: Object.keys(params).reduce(function(a,k){a.push(k+'='+encodeURIComponent(params[k]));return a;},[]).join('&'), - width: this.width, - height: this.height, - id: params.id - })); - - function setup_media_methods () { - var dest = _this.$.find("#" + params.id)[0].contentWindow; - var execute = function(c, v) { - if (v !== undefined) - c = c + "=" + v; - dest.postMessage(c, "*"); - }; - - _media.getCurrentTime = function() { - return state.time; - }; - _media.getVolume = function() { - return state.volume; - }; - _media.getPaused = function() { - return state.pause; - }; - _media.getMuted = function() { - return state.muted; - }; - _media.setCurrentTime = function(_milliseconds) { - execute("seek", _milliseconds / 1000); - }; - _media.setVolume = function(_vol) { - execute("volume", _vol * 100); - }; - _media.mute = function() { - execute("muted", 1); - }; - _media.unmute = function() { - execute("muted", 0); - }; - _media.play = function() { - execute("play"); - }; - _media.pause = function() { - execute("pause"); - }; - }; - - window.addEventListener("message", function (event) { - // Parse event.data (query-string for to object) - - // Duck-checking if event.data is a string - if (event.data.split === undefined) - return; - - var info = event.data.split("&").map( function(s) { return s.split("="); }).reduce( function(o, v) { o[v[0]] = decodeURIComponent(v[1]); return o; }, {}); - - switch (info.event) { - case "apiready": - state.apiready = true; - setup_media_methods(); - break; - //case "canplay": - // break; - case "durationchange": - if (info.duration.slice(-2) == "sc") { - state.duration = 1000 * Number(info.duration.slice(0, -2)); - _media.setDuration(state.duration); - } - break; - case "ended": - state.pause = true; - break; - case "loadedmetadata": - _media.trigger("loadedmetadata"); - break; - case "pause": - state.pause = true; - _media.trigger("pause"); - break; - case "play": - state.pause = false; - _media.trigger("play"); - break; - //case "playing": - // break; - //case "progress": - // Loading progress - // break; - case "seeked": - state.time = new IriSP.Model.Time(1000 * Number(info.time)); - _media.trigger("seeked"); - break; - case "timeupdate": - state.time = new IriSP.Model.Time(1000 * Number(info.time)); - _media.trigger("timeupdate", state.time); - break; - case "volumechange": - state.muted = (info.muted == "true"); - state.volume = Number(info.volume) / 100; - break; - } - }, false); -}; diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/EnrichedPlan.css --- a/src/ldt/ldt/static/ldt/metadataplayer/EnrichedPlan.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -.Ldt-EnrichedPlan-Slide { - border-bottom: 2px dotted #ccc; - padding-top: 4px; - cursor: pointer; -} - -.Ldt-EnrichedPlan-SlideItem { - max-height: 3000px; - transition: max-height .6s; -} - -.Ldt-EnrichedPlan-SlideItem.filtered_out { - max-height: 0px; - overflow: hidden; -} - -.Ldt-EnrichedPlan-SlideTimecode { - display: inline-block; - width: 24px; - color: #999 !important; - font-size: 9px !important; - width: 24px; - vertical-align: top; -} - -.Ldt-EnrichedPlan-SlideThumbnail { - display: inline-block; - width: 180px; - height: 100px; - padding-left: 10px; - margin: 0; - vertical-align: top; -} - -.Ldt-EnrichedPlan-SlideThumbnail img { - max-width: 180px; - max-height: 100px; - margin: auto; - border: 1px solid #ccc; -} - -.Ldt-EnrichedPlan-SlideContent { - display: inline-block; - width: calc(100% - 220px); - transition: width .4s; -} - -.Ldt-EnrichedPlan-SlideThumbnail.filtered_out + .Ldt-EnrichedPlan-SlideContent { - width: calc(100% - 40px); -} - -.Ldt-EnrichedPlan-SlideTitle { - display: inline-block; - font-size: 14px; - width: 100%; - height: 1em; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - -.Ldt-EnrichedPlan-SlideTitle1 { - text-transform: uppercase; - font-size: 13px; - font-weight: 600; -} - -.Ldt-EnrichedPlan-Note { - font-weight: normal; - font-size: 14px; - font-family: Roboto-italic; -} -.Ldt-EnrichedPlan-Note:hover { - background-color: #eee; -} - -.Ldt-EnrichedPlan-Note-Teacher { - color: #e5007e; - font-style: italic; -} -.Ldt-EnrichedPlan-Note-Own { - color: #66ccff; -} -.Ldt-EnrichedPlan-Note-Other { - color: #996633; -} - -.Ldt-EnrichedPlan-Note-Text { - line-height: 22px; - word-wrap: break-word; -} - -.Ldt-EnrichedPlan-Note-Author { - text-transform: uppercase; - font-size: 10px; -} - -.Ldt-EnrichedPlan-Content { - margin-top: 37px; -} - -.Ldt-EnrichedPlan-Controls { - height: 36px; - padding: 9px 0px 6px 0px; - border-bottom: 1px solid #000; - overflow-y: hidden; - overflow-x: hidden; - position: absolute; - top: 0px; - left: 0px; - right: 0px; - z-index: 1; - background-color: #fff; -} - -.Ldt-EnrichedPlan-Control-Label { - display: inline-block; - text-transform: uppercase; - line-height: 10px; - font-family: Roboto; - font-size: 10px; - font-weight: 100; - width: 80px; - position: relative; -} -.Ldt-EnrichedPlan-Controls .Ldt-EnrichedPlan-Search-Input { - float: right; - font-family: Roboto; - font-size: 16px; - width: calc(100% - 340px); -} - -.Ldt-EnrichedPlan-Note.non_matching { - display: none; -} - -.Ldt-EnrichedPlan-Control- { - font-style: normal; -} - /**********************************************************/ -/* Base for label styling */ -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked), -.Ldt-EnrichedPlan-Control-Checkbox:checked { - position: absolute; - left: -9999px; -} -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked) + label, -.Ldt-EnrichedPlan-Control-Checkbox:checked + label { - position: relative; - padding-left: 20px; - cursor: pointer; -} - -/* checkbox aspect */ -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked) + label:before, -.Ldt-EnrichedPlan-Control-Checkbox:checked + label:before { - content: ''; - position: absolute; - left:0; top: 2px; - width: 13px; height: 13px; - border: 1px solid #aaa; -} -/* checked mark aspect */ -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked) + label:after, -.Ldt-EnrichedPlan-Control-Checkbox:checked + label:after { - content: '\2a2f'; - font-style: normal; - position: absolute; - top: 3px; left: -1px; - font-size: 20px; - transition: all .2s; -} -/* checked mark aspect changes */ -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked) + label:after { - opacity: 0; -} -.Ldt-EnrichedPlan-Control-Checkbox:checked + label:after { - opacity: 1; -} -/* disabled checkbox */ -.Ldt-EnrichedPlan-Control-Checkbox:disabled:not(:checked) + label:before, -.Ldt-EnrichedPlan-Control-Checkbox:disabled:checked + label:before { - box-shadow: none; - border-color: #bbb; - background-color: #ddd; -} -.Ldt-EnrichedPlan-Control-Checkbox:disabled:checked + label:after { - color: #999; -} -.Ldt-EnrichedPlan-Control-Checkbox:disabled + label { - color: #aaa; -} -/* accessibility */ -.Ldt-EnrichedPlan-Control-Checkbox:checked:focus + label:before, -.Ldt-EnrichedPlan-Control-Checkbox:not(:checked):focus + label:before { - border: 1px dotted blue; -} - -/* hover style just for information */ -label:hover:before { - border: 1px solid #4778d9!important; -} - -/* hover style just for information */ -label:hover:before { - background-color: #ededed; -} diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/EnrichedPlan.js --- a/src/ldt/ldt/static/ldt/metadataplayer/EnrichedPlan.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/* TODO -- add callbacks - */ - -IriSP.Widgets.EnrichedPlan = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); -} - -IriSP.Widgets.EnrichedPlan.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.EnrichedPlan.prototype.defaults = { - // Main type for slide segmentation - annotation_type: "Slides", - // If no annotation type list is specified, use all other types - annotation_types: [], - show_controls: true, - show_slides: true, - show_teacher_notes: true, - show_other_notes: true, - show_own_notes: true -} - -IriSP.Widgets.EnrichedPlan.prototype.template = - '
      ' - + '{{#show_controls}}
      ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + ' ' - + '
      {{/show_controls}}' - + '
      ' - + '
      '; - -IriSP.Widgets.EnrichedPlan.prototype.slideTemplate = - '
      ' - + '
      {{ begin }}
      ' - + '
      ' - + '
      ' - + '
      {{ atitle }}
      ' - + '
      {{{ notes }}}
      ' - + '
      ' - + '
      '; - -IriSP.Widgets.EnrichedPlan.prototype.annotationTemplate = '
      {{{ text }}} {{ author }}
      '; - -IriSP.Widgets.EnrichedPlan.prototype.draw = function() { - var _this = this; - // Generate a unique prefix, so that ids of input fields - // (necessary for label association) are unique too. - _this.prefix = "TODO"; - // slides content: title, level (for toc) - var _slides = this.getWidgetAnnotations().sortBy(function(_annotation) { - return _annotation.begin; - }); - // All other annotations - var _annotations = this.media.getAnnotations().filter( function (a) { - return a.getAnnotationType().title != _this.annotation_type; - }).sortBy(function(_annotation) { - return _annotation.begin; - }); - - // Reference annotations in each slide: assume that end time is - // correctly set. - _slides.forEach( function (slide) { - slide.annotations = _annotations.filter( function (a) { - return a.begin >= slide.begin && a.begin <= slide.end; - }); - }); - - _this.renderTemplate(); - var container = _this.$.find('.Ldt-EnrichedPlan-Container'); - var content = _this.$.find('.Ldt-EnrichedPlan-Content'); - - // Returns the note category: Own, Other, Teacher - function note_category(a) { - return a.title.indexOf('Anonyme') < 0 ? "Own" : "Other"; - }; - - _slides.forEach(function(slide) { - var _html = Mustache.to_html(_this.slideTemplate, { - id : slide.id, - atitle : IriSP.textFieldHtml(slide.title), - level: slide.content.level || 1, - begin : slide.begin.toString(), - begintc: slide.begin.milliseconds, - thumbnail: slide.thumbnail, - show_slides: _this.show_slides, - notes: slide.annotations.map( function (a) { - return Mustache.to_html(_this.annotationTemplate, { - id: a.id, - text: IriSP.textFieldHtml(a.description || a.title), - author: a.creator, - begin: a.begin.toString(), - begintc: a.begin.milliseconds, - atitle: a.title.slice(0, 20), - // FIXME: Temporary hack waiting for a proper metadata definition - category: "Ldt-EnrichedPlan-Note-" + note_category(a), - filtered: ( (note_category(a) == 'Own' && ! _this.show_own_notes) - || (note_category(a) == 'Other' && ! _this.show_other_notes) - || (note_category(a) == 'Teacher' && ! _this.show_teacher_notes) ) ? 'filtered_out' : '' - }); - }).join("\n") - }); - var _el = IriSP.jQuery(_html); - content.append(_el); - }); - - container.on("click", "[data-timecode]", function () { - _this.media.setCurrentTime(Number(this.dataset.timecode)); - }); - - container.on("click", ".Ldt-EnrichedPlan-Control-Checkbox", function () { - var classname = _.first(_.filter(this.classList, function (s) { return s != "Ldt-EnrichedPlan-Control-Checkbox"; })); - if (classname !== undefined) { - if ($(this).is(':checked')) { - content.find(".Ldt-EnrichedPlan-Slide ." + classname).removeClass("filtered_out"); - } else { - content.find(".Ldt-EnrichedPlan-Slide ." + classname).addClass("filtered_out"); - } - } - - }); - - container.find(".Ldt-EnrichedPlan-Search-Input").on("search", function () { - var q = $(this).val().toLocaleLowerCase(); - if (q === "") { - // Show all - content.find(".Ldt-EnrichedPlan-Note").removeClass("non_matching"); - } else { - $(".Ldt-EnrichedPlan-Note").each( function () { - var node = $(this); - if (node.text().toLocaleLowerCase().indexOf(q) > -1) { - node.removeClass("non_matching"); - } else { - node.addClass("non_matching"); - } - }); - } - }); -}; diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/HelloWorld.css --- a/src/ldt/ldt/static/ldt/metadataplayer/HelloWorld.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -.Ldt-HelloWorld p { - text-align: center; font-size: 12px; margin: 2px 0; -} diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/HelloWorld.js --- a/src/ldt/ldt/static/ldt/metadataplayer/HelloWorld.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* Shows an example of a widget, with : - * - Use of source data - * - Use of templating - * - Use of internationalization - */ - -IriSP.Widgets.HelloWorld = function(player, config) { - console.log("Calling IriSP.Widget's constructor from IriSP.HelloWorldWidget"); - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.HelloWorld.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.HelloWorld.prototype.defaults = { - text: "world" -}; - -IriSP.Widgets.HelloWorld.prototype.template = - '

      {{l10n.Hello}} {{text}}

      Looks like we have {{source.contents.annotation.length}} annotations in this feed

      '; - -IriSP.Widgets.HelloWorld.prototype.messages = { - "fr": { - "Hello" : "Bonjour," - }, - "en" : { - "Hello" : "Hello," - } -}; - -IriSP.Widgets.HelloWorld.prototype.draw = function() { - this.renderTemplate(); - console.log("HelloWorldWidget was drawn"); -}; \ No newline at end of file diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/Highlighter.css --- a/src/ldt/ldt/static/ldt/metadataplayer/Highlighter.css Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -.currentAnnotation { - border: solid 3px red; -} diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/Highlighter.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Highlighter.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -IriSP.Widgets.Highlighter = function(player, config) { - var _this = this; - IriSP.Widgets.Widget.call(this, player, config); - this.throttledRefresh = IriSP._.throttle(function() { - console.log("highlighter Refresh"); - _this.update(); - }, 800); -}; - -/** - * Highlighter widget - * This widgets highlights the current annotations by setting the - * .activeAnnotation class on appropriate .Ldt-Highlighter-Annotation - * elements. These elements *must* have data-begin and data-end properties specifying their bounds (in ms) (and data-media specifying the media-id) - */ -IriSP.Widgets.Highlighter.prototype = new IriSP.Widgets.Widget(); - -IriSP.Widgets.Highlighter.prototype.defaults = { -} - -IriSP.Widgets.Highlighter.prototype.update = function() { - var _this = this; - var _currentTime = _this.media.getCurrentTime(); - _this.$.find(".Ldt-Highlighter-Annotation", document).toggleClass("currentAnnotation", function () { - return (this.dataset.media === _this.media.id && this.dataset.begin <= _currentTime && _currentTime < this.dataset.end); - }); - console.log(_this.$.find(".currentAnnotation")); - return false; -}; - -IriSP.Widgets.Highlighter.prototype.draw = function() { - var _this = this; - - var _events = [ - "timeupdate", - "seeked", - "loadedmetadata" - ]; - for (var _i = 0; _i < _events.length; _i++) { - _this.onMediaEvent(_events[_i], _this.throttledRefresh); - } - _this.throttledRefresh(); -}; diff -r 8cc1dda7efc8 -r 3fcce374ca5e src/ldt/ldt/static/ldt/metadataplayer/HtmlMashupPlayer.js --- a/src/ldt/ldt/static/ldt/metadataplayer/HtmlMashupPlayer.js Mon Sep 02 15:00:08 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,345 +0,0 @@ -IriSP.Widgets.HtmlMashupPlayer = function(player, config) { - IriSP.Widgets.Widget.call(this, player, config); -}; - -IriSP.Widgets.HtmlMashupPlayer.prototype = new IriSP.Widgets.Widget(); - - -IriSP.Widgets.HtmlMashupPlayer.prototype.defaults = { - aspect_ratio: 14/9, - background: "#333333" -}; - -IriSP.Widgets.HtmlMashupPlayer.prototype.draw = function() { - - if (!this.height && this.aspect_ratio) { - this.height = this.width / this.aspect_ratio; - this.$.css("height", this.height); - } - - if (this.background) { - this.$.css("background", this.background); - } - - var mashup = this.media, - sel = this.$, - width = this.width, - height = this.height, - url_transform = this.url_transform; - - mashup.currentMedia = null; - mashup.currentAnnotation = null; - mashup.seeking = false; - var mashupSegmentBegin, - mashupSegmentEnd, - mashupTimecode = 0, - // seekdiv = $(".video-wait"), - mashupTimedelta; - -/* - function showSeek() { - if (currentMedia.seeking) { - seekdiv.show(); - } - } -*/ - - function changeCurrentAnnotation() { - if (mashupTimecode >= mashup.duration) { - if (!mashup.paused) { - mashup.paused = true; - mashup.trigger("pause"); - } - mashupTimecode = 0; - } - var _annotation = mashup.getAnnotationAtTime( mashupTimecode ); - if (typeof _annotation === "undefined") { - if (mashup.currentMedia) { - mashup.currentMedia.pause(); - if (!mashup.paused) { - mashup.paused = true; - mashup.trigger("pause"); - } - } - return; - } - mashup.currentAnnotation = _annotation; - mashupSegmentBegin = mashup.currentAnnotation.annotation.begin.milliseconds; - mashupSegmentEnd = mashup.currentAnnotation.annotation.end.milliseconds; - mashupTimedelta = mashupSegmentBegin - mashup.currentAnnotation.begin.milliseconds; - mashup.currentMedia = mashup.currentAnnotation.getMedia(); - mashup.getMedias().forEach(function(_media) { - if (_media !== mashup.currentMedia) { - _media.hide(); - _media.pause(); - } else { - _media.show(); - } - }); - - mashup.currentMedia.setCurrentTime( mashupTimecode + mashupTimedelta); - mashup.currentMedia.seeking = true; - - if (!mashup.paused) { - mashup.currentMedia.play(); - mashup.seeking = true; -// setTimeout(showSeek,200); - } - mashup.trigger("timeupdate", new IriSP.Model.Time(mashupTimecode)); - - } - - mashup.getMedias().forEach(addMedia); - changeCurrentAnnotation(); - mashup.trigger("loadedmetadata"); - - function addMedia(media) { - if (media.has_player) { - return; - } - media.has_player = true; - var videourl = media.video; - if (typeof url_transform === "function") { - videourl = url_transform(media.video); - } - var videoid = "video_" + media.id, - videoElement; - - media.show = function() { - - if (document.getElementById(videoid)) { - return; - } - - media.loaded = false; - media.paused = true; - var videoSelector = $('