# HG changeset patch # User veltr # Date 1353512006 -3600 # Node ID d600fa967511403d9f6c861b7dbf75c1aeaa6837 # Parent 61da23337d76fa181c0c0e2e071ad9ede6a0a983 New Search in Metadataplayer diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html --- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/embed_player.html Wed Nov 21 16:33:26 2012 +0100 @@ -22,7 +22,7 @@ IriSP.widgetsDir = "{{WEB_URL}}{{LDT_MEDIA_PREFIX}}metadataplayer"; var _metadata = { - url: metadatas[metadata_key].url + '?callback=?', + url: metadatas[metadata_key].url, format: 'ldt' }; var _config = { diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/Annotation.css --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.css Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.css Wed Nov 21 16:33:26 2012 +0100 @@ -6,6 +6,10 @@ margin: 0; } +.Ldt-Annotation-Highlight { + background: #ffa0fc; +} + .Ldt-Annotation-Widget.Ldt-Annotation-ShowTop { border-top-style: solid; padding-top: 1px; @@ -15,6 +19,8 @@ background: url(img/pinstripe.png); padding: 5px; margin: 0; + max-height: 300px; + overflow: auto; } .Ldt-Annotation-Inner h3 { @@ -66,6 +72,7 @@ .Ldt-Annotation-Inner p { font-size: 12px; + line-height: 16px; } .Ldt-Annotation-Label { diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/Annotation.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Annotation.js Wed Nov 21 16:33:26 2012 +0100 @@ -56,7 +56,8 @@ IriSP.Widgets.Annotation.prototype.draw = function() { - var _this = this; + var _this = this, + currentAnnotation; function timeupdate(_time) { var _list = _this.getWidgetAnnotationsAtTime(); @@ -70,7 +71,29 @@ } } + function highlightTitleAndDescription() { + if (!currentAnnotation) { + return; + } + var title = currentAnnotation.title, + description = currentAnnotation.description.replace(/(^\s+|\s+$)/g,''); + if (currentAnnotation.found) { + var rgxp = _this.source.getAnnotations().regexp || /^$/, + repl = '$1'; + title = title.replace(rgxp,repl); + description = description.replace(rgxp,repl); + } + _this.$.find(".Ldt-Annotation-Title").html(title || "(" + _this.l10n.untitled + ")"); + if (description) { + _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock"); + _this.$.find(".Ldt-Annotation-Description").html(description); + } 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)), @@ -85,7 +108,7 @@ var _el = IriSP.jQuery('
  • ').append(IriSP.jQuery('').text(_trimmedTitle)); _el.click(function() { if (_this.search_on_tag_click) { - _this.player.trigger("search.triggeredSearch",_trimmedTitle); + _this.source.getAnnotations().search(_trimmedTitle); } _tag.trigger("click"); }); @@ -95,14 +118,7 @@ } else { _this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock"); } - _this.$.find(".Ldt-Annotation-Title").text(_annotation.title || "(" + _this.l10n.untitled + ")"); - var _desc = _annotation.description.replace(/(^\s+|\s+$)/g,''); - if (_desc) { - _this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock"); - _this.$.find(".Ldt-Annotation-Description").html(_desc); - } else { - _this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock"); - } + highlightTitleAndDescription(); if (_this.show_annotation_type) { _this.$.find(".Ldt-Annotation-Type").text(_annotation.getAnnotationType().title) } @@ -135,7 +151,7 @@ this.renderTemplate(); - if (_this.show_social) { + if (this.show_social) { this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), { type: "Social" }, "socialWidget"); } @@ -152,6 +168,9 @@ drawAnnotation(_a) }); }); + this.source.getAnnotations().on("found", highlightTitleAndDescription); + this.source.getAnnotations().on("not-found", highlightTitleAndDescription); + this.source.getAnnotations().on("search-cleared", highlightTitleAndDescription); } IriSP.Widgets.Annotation.prototype.sendBounds = function() { diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.css Wed Nov 21 16:33:26 2012 +0100 @@ -29,8 +29,7 @@ background-image: url(img/pinstripe-grey.png); } .Ldt-AnnotationsList-highlight { - background: #F7268E; - color: #ffffff; + background: #FFA0FC; } .Ldt-AnnotationsList-ThumbContainer { float: left; diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js --- a/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js Wed Nov 21 16:33:26 2012 +0100 @@ -1,11 +1,12 @@ IriSP.Widgets.AnnotationsList = function(player, config) { IriSP.Widgets.Widget.call(this, player, config); - this.searchString = false; this.lastIds = []; var _this = this; this.throttledRefresh = IriSP._.throttle(function() { _this.refresh(false); - }, 1500); + }, 800); + this.searchString = false; + this.lastSearch = false; }; IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); @@ -87,18 +88,6 @@ + '{{#audio}}
    {{l10n.voice_annotation}}
    {{/audio}}' + ''; -IriSP.Widgets.AnnotationsList.prototype.onSearch = function(searchString) { - this.searchString = typeof searchString !== "undefined" ? searchString : ''; - var _n = this.refresh(true); - if (this.searchString) { - if (_n) { - this.player.trigger("search.matchFound"); - } else { - this.player.trigger("search.noMatchFound"); - } - } -} - //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() { @@ -150,9 +139,9 @@ }); } } - if (this.searchString) { - _list = _list.searchByTextFields(this.searchString); - } + _list = _list.filter(function(_annotation) { + return _annotation.found !== false; + }); if (this.limit_count) { /* Get the n annotations closest to current timecode */ _list = _list.sortBy(function(_annotation) { @@ -171,8 +160,9 @@ var _ids = _list.idIndex; - if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds)) { + if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) { /* This part only gets executed if the list needs updating */ + this.lastSearch = this.searchString; this.lastIds = _ids; this.list_$.html(""); _list.forEach(function(_annotation) { @@ -258,7 +248,7 @@ }); this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() { - _this.player.trigger("search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); + _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,'')); }); this.$.find(".Ldt-AnnotationsList-Play").click(function() { @@ -274,11 +264,10 @@ _this.jw_paused_media = true; }); - if(this.searchString) { - var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString); + if (this.source.getAnnotations().searching) { this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() { var _$ = IriSP.jQuery(this); - _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_searchRe, '$1')) + _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_this.source.getAnnotations().regexp, '$1')) }) } } @@ -328,9 +317,29 @@ this.list_$ = this.$.find(".Ldt-AnnotationsList-ul"); - this.onMdpEvent("search", "onSearch"); - this.onMdpEvent("search.closed", "onSearch"); - this.onMdpEvent("search.cleared", "onSearch"); + this.source.getAnnotations().on("search", function(_text) { + _this.searchString = _text; + if (_this.source !== _this.currentSource) { + _this.currentSource.getAnnotations().search(_text); + _this.throttledRefresh(); + } + }); + this.source.getAnnotations().on("found", function() { + _this.throttledRefresh(); + }); + this.source.getAnnotations().on("not-found", function() { + _this.throttledRefresh(); + }); + this.source.getAnnotations().on("clear-search", function() { + _this.searchString = false; + if (_this.source !== _this.currentSource) { + _this.currentSource.getAnnotations().trigger("clear-search"); + } + }); + this.source.getAnnotations().on("search-cleared", function() { + _this.throttledRefresh(); + }); + this.onMdpEvent("AnnotationsList.refresh", function() { if (_this.ajax_url) { if (_this.mashupMode) { diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/Controller.js --- a/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/Controller.js Wed Nov 21 16:33:26 2012 +0100 @@ -92,10 +92,6 @@ this.onMediaEvent("volumechange","volumeUpdater"); this.onMediaEvent("timeupdate","timeDisplayUpdater"); this.onMediaEvent("loadedmetadata","volumeUpdater"); - this.onMdpEvent("search.matchFound","searchMatch"); - this.onMdpEvent("search.noMatchFound","searchNoMatch"); - this.onMdpEvent("search.triggeredSearch","triggeredSearch"); - this.onMdpEvent("search.cleared","hideSearchBlock"); // handle clicks this.$playButton.click(this.functionWrapper("playHandler")); @@ -157,6 +153,21 @@ }); this.timeDisplayUpdater(new IriSP.Model.Time(0)); + + var annotations = this.source.getAnnotations(); + annotations.on("search", function(_text) { + _this.$searchInput.val(_text); + _this.showSearchBlock(); + }); + annotations.on("found", function(_text) { + _this.$searchInput.css('background-color','#e1ffe1'); + }); + annotations.on("not-found", function(_text) { + _this.$searchInput.css('background-color', "#d62e3a"); + }); + annotations.on("search-cleared", function() { + _this.hideSearchBlock(); + }); }; @@ -222,23 +233,11 @@ IriSP.Widgets.Controller.prototype.showSearchBlock = function() { this.$searchBlock.animate({ width:"160px" }, 200); this.$searchInput.css('background-color','#fff'); - this.$searchInput.focus(); - - // we need this variable because some widgets can find a match in - // their data while at the same time others don't. As we want the - // search field to become green when there's a match, we need a - // variable to remember that we had one. - this._positiveMatch = false; - - // tell the world the field is open - this.player.trigger("search.open"); }; IriSP.Widgets.Controller.prototype.hideSearchBlock = function() { this.$searchBlock.animate( { width: 0 }, 200); - this._positiveMatch = false; - this.player.trigger("search.closed"); }; /** react to clicks on the search button */ @@ -247,7 +246,7 @@ this.showSearchBlock(); var _val = this.$searchInput.val(); if (_val) { - this.player.trigger("search", _val); // trigger the search to make it more natural. + this.source.getAnnotations().search(_val); } } else { this.hideSearchBlock(); @@ -267,37 +266,12 @@ // do nothing if the search field is empty, instead of highlighting everything. if (_val !== this.lastSearchValue) { if (_val) { - this.player.trigger("search", _val); + this.source.getAnnotations().search(_val); } else { - this.player.trigger("search.cleared"); + this.source.getAnnotations().trigger("clear-search"); this.$searchInput.css('background-color',''); } } this.lastSearchValue = _val; }; -/** - handler for the IriSP.search.found message, which is sent by some views when they - highlight a match. -*/ -IriSP.Widgets.Controller.prototype.searchMatch = function() { - this._positiveMatch = true; - this.$searchInput.css('background-color','#e1ffe1'); -}; - -/** the same, except that no value could be found */ -IriSP.Widgets.Controller.prototype.searchNoMatch = function() { - if (this._positiveMatch !== true) { - this.$searchInput.css('background-color', "#d62e3a"); - } -}; - -/** react to an IriSP.Player.triggeredSearch - that is, when - a widget ask the.Player to do a search on his behalf */ -IriSP.Widgets.Controller.prototype.triggeredSearch = function(searchString) { - this.showSearchBlock(); - this.$searchInput.attr('value', searchString); - this.player.trigger("search", searchString); // trigger the search to make it more natural. -}; - - diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.css --- a/src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.css Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.css Wed Nov 21 16:33:26 2012 +0100 @@ -10,6 +10,27 @@ display: none; } +.Ldt-Kc-Related h2 { + border: none; + color: #330099; + font-size: 18px; + margin: 8px 0 2px; + padding: 0 5px; +} + +h3.Ldt-Kc-For-Keywords { + border-bottom: 1px solid #666666; + color: #000000; + font-size: 12px; + margin: 2px 0 5px; + padding: 0 5px 5px; + text-align: right; +} + +.Ldt-Kc-Keywords { + color: #d000c0; font-weight: bold; +} + .Ldt-Kc-Related-Item { width: 235px; float: left; margin: 4px 0; padding: 4px 0; } diff -r 61da23337d76 -r d600fa967511 src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.js --- a/src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.js Fri Nov 16 18:37:23 2012 +0100 +++ b/src/ldt/ldt/static/ldt/metadataplayer/KnowledgeConcierge.js Wed Nov 21 16:33:26 2012 +0100 @@ -13,17 +13,19 @@ related_api_endpoint: "", use_word_boundaries: false, related_data_type: 'json', // SET TO "jsonp" FOR CROSS-DOMAIN OPERATION - related_count: 8 + related_count: 8, } IriSP.Widgets.KnowledgeConcierge.prototype.messages = { "fr": { related_videos: "Vidéos liées", - duration_: "Durée :" + duration_: "Durée :", + for_keywords_: "pour le(s) mots-clé(s) :" }, "en": { related_videos: "Related Videos", - duration_: "Duration:" + duration_: "Duration:", + for_keywords_: "for keyword(s):" } } @@ -31,6 +33,7 @@ '
    ' + '
    ' + ''; IriSP.Widgets.KnowledgeConcierge.prototype.draw = function() { @@ -54,6 +57,7 @@ _selectedText = "", currentNodesList = "", relatedCache = {}, + relatedRequests = {}, relatedTemplate = '