# HG changeset patch # User cavaliet # Date 1395660685 -3600 # Node ID 21840e43dcc8506d004a038fce1cb7d80729507d # Parent dda5c321379a415a19a52ecb4a6175de03c7f95f chapters to annotations filters diff -r dda5c321379a -r 21840e43dcc8 src/spel/static/spel/css/spel.css --- a/src/spel/static/spel/css/spel.css Fri Mar 21 15:21:15 2014 +0100 +++ b/src/spel/static/spel/css/spel.css Mon Mar 24 12:31:25 2014 +0100 @@ -68,6 +68,12 @@ .multiline{ white-space: normal; } +th.popinfo{ + min-width: 45px; +} +span.popinfo{ + cursor: pointer; +} .info{ padding-left: 5px; padding-right: 5px; diff -r dda5c321379a -r 21840e43dcc8 src/spel/static/spel/js/spectacle.js --- a/src/spel/static/spel/js/spectacle.js Fri Mar 21 15:21:15 2014 +0100 +++ b/src/spel/static/spel/js/spectacle.js Mon Mar 24 12:31:25 2014 +0100 @@ -276,7 +276,7 @@ } $("#btn-filter-annotations").click(); // manage when nothing is selected - if($(".annot-tag-list").children().length==0){ + if($(".annot-tag-list").children().length==0 && $(".annotation-results .info").length==0){ $(".annotation-results").html(''); } }); @@ -340,6 +340,7 @@ csrfmiddlewaretoken: csrf_token }, function( html ) { + $("#search-input").val(" "); // trick to simply enable filter annotations $(".annotation-results").removeClass("loader"); $(".annotation-results").html(html); } @@ -349,5 +350,50 @@ $(".annotation-results").html('
Erreur de chargement
'); }); }); - + + // Filter chapter to annotations + $(".chapter-results").on("click", ".filter-chapter-annot", function(){ + var $tr = $(this).parent().parent(); + // green line or not + ($(this).prop('checked')==true) ? $tr.addClass("success") : $tr.removeClass("success"); + filterAnnotationsWithChapters(); + }); + + function filterAnnotationsWithChapters(){ + // Remove all childs but the searched-term one + if($(".annot-tag-list").children().first().children().first().hasClass("glyphicon-search")){ + $(".annot-tag-list").find("li:gt(0)").remove(); + } + else{ + $(".annot-tag-list").children().remove(); + } + // We build the the array of content ids and timecodes + var id_tc = {}; + $(".chapter-results input[type=checkbox]:checked").each(function(index){ + var $tr = $(this).parent().parent(); + var iri_id = $tr.attr("data-content"); + if(!(iri_id in id_tc)){ + id_tc[iri_id] = []; + } + id_tc[iri_id].push({ start: parseInt($tr.attr("data-start")), end: parseInt($tr.attr("data-end")) }); + }); + $('.annotation-results > div.searched-annot').each(function(index){ + // annot in timecode and content ? + var show = true; + var iri_id = $(this).attr("data-content"); + if(iri_id in id_tc){ + show = true; + } + else{ + show = false; + } + show ? $(this).show() : $(this).hide(); + }); + + if($(".chapter-results input[type=checkbox]:checked").length==0){ + $('.annotation-results > div.searched-annot').show(); + } + // Update number displayed + $(".nb-annotations-found").html($('.annotation-results > div.searched-annot:visible').length); + } }); diff -r dda5c321379a -r 21840e43dcc8 src/spel/templates/partial/spel_chapters.html --- a/src/spel/templates/partial/spel_chapters.html Fri Mar 21 15:21:15 2014 +0100 +++ b/src/spel/templates/partial/spel_chapters.html Mon Mar 24 12:31:25 2014 +0100 @@ -21,15 +21,16 @@| Type | Ref texte | Titre de la vidéo | ||||
|---|---|---|---|---|---|---|
| Type | Ref texte | Titre de la vidéo | ||||
| {{ s.cutting_id }} | {{ s.tags|get_tags:"ref_text"|join:', ' }} | {% if annot_chapters %}{{ s.ct }}{% else %}{{ s.content.title }}{% endif %} | +{{ s.cutting_id|slice:":1"|upper }} | {{ s.tags|get_tags:"ref_text"|join:', ' }} | {% if annot_chapters %}{{ s.ct }}{% else %}{{ s.content.title }}{% endif %} | - + + |