# HG changeset patch # User cavaliet # Date 1400689687 -7200 # Node ID 0eab4a2257a708b66331e6caee50b78eca87c8bf # Parent 89c9129268126ac9feb3134e38286cf437e4dae7 v0.5.15 management of range for mesure diff -r 89c912926812 -r 0eab4a2257a7 src/spel/__init__.py --- a/src/spel/__init__.py Mon May 19 13:14:17 2014 +0200 +++ b/src/spel/__init__.py Wed May 21 18:28:07 2014 +0200 @@ -1,4 +1,4 @@ -VERSION = (0, 5, 14, "final", 0) +VERSION = (0, 5, 15, "final", 0) VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2]))) diff -r 89c912926812 -r 0eab4a2257a7 src/spel/static/spel/css/spel.css --- a/src/spel/static/spel/css/spel.css Mon May 19 13:14:17 2014 +0200 +++ b/src/spel/static/spel/css/spel.css Wed May 21 18:28:07 2014 +0200 @@ -99,6 +99,9 @@ padding-left: 5px; padding-right: 5px; } +.select-opera{ + max-width: 100px; +} /* Player */ #LdtPlayer, #AnnotationsListContainer { float: left; diff -r 89c912926812 -r 0eab4a2257a7 src/spel/static/spel/js/opera.js --- a/src/spel/static/spel/js/opera.js Mon May 19 13:14:17 2014 +0200 +++ b/src/spel/static/spel/js/opera.js Wed May 21 18:28:07 2014 +0200 @@ -1,23 +1,31 @@ $(document).ready(function () { + function enabledFilter(){ + var filter_enabled = false; + var chbs = $(".spel-content input:checkbox"); + for (var i = chbs.length - 1; i >= 0; i--) { + filter_enabled = filter_enabled || $(chbs[i]).is(":checked"); + } + if(!filter_enabled){ + // check mesure + if((typeof $("#end-mesure").attr('disabled'))==="undefined" || $("#start-mesure").val()!="start"){ + filter_enabled = true; + } + } + if(filter_enabled){ + $("#btn-filter-chapters").removeAttr('disabled'); + } + else{ + $("#btn-filter-chapters").attr('disabled','disabled'); + } + } + // Chapter multiselect management $('.multiselect').multiselect({ buttonText: function(options, select) { return $(select).attr("data-title") + ' (' + options.length + ') '; }, - onChange: function(element, checked) { - var filter_enabled = false; - var chbs = $(".spel-content input:checkbox"); - for (var i = chbs.length - 1; i >= 0; i--) { - filter_enabled = filter_enabled || $(chbs[i]).is(":checked"); - }; - if(filter_enabled){ - $("#btn-filter-chapters").removeAttr('disabled'); - } - else{ - $("#btn-filter-chapters").attr('disabled','disabled'); - } - } + onChange: enabledFilter }); // Data 1 @@ -138,9 +146,30 @@ } return v1 - v2; }); - $("#mulsel7").multiselect('dataprovider', data7); - $("#mulsel7").multiselect('enable'); + // Init select text + $("#start-mesure").append(''); + $.each(data7, function(k,val){ + $("#start-mesure").append(''); + var v = parseInt(val.label); + if(!isNaN(v)){ + $("#end-mesure").append(''); + } + }); + $("#end-mesure").append(''); }); + // start-mesure + $("#start-mesure").on('change', function() { + var reg = /^\d+$/; + if(reg.test(this.value)){ + $("#end-mesure").removeAttr('disabled'); + } + else{ + $("#end-mesure").attr('disabled','disabled'); + } + enabledFilter(); + }); + + function buildChapterTable(html){ $(".chapter-results").removeClass("loader"); @@ -161,7 +190,7 @@ // Search chapters management $("#btn-filter-chapters").click(function(e){ - if($("#mulsel1").val()==null && $("#mulsel2").val()==null && $("#mulsel3").val()==null && $("#mulsel4").val()==null && $("#mulsel5").val()==null && $("#mulsel6").val()==null && $("#mulsel7").val()==null){ + if($("#mulsel1").val()==null && $("#mulsel2").val()==null && $("#mulsel3").val()==null && $("#mulsel4").val()==null && $("#mulsel5").val()==null && $("#mulsel6").val()==null && !((typeof $("#end-mesure").attr('disabled'))==="undefined" || $("#start-mesure").val()!="start")){ $(".chapter-results").html("
Vous devez sélectionner au moins un filtre
"); return false; } @@ -178,9 +207,8 @@ type_travail: ( ($("#mulsel4").val()==null) ? [] : $("#mulsel4").val() ).join(","), acte: ( ($("#mulsel5").val()==null) ? [] : $("#mulsel5").val() ).join(","), scene: ( ($("#mulsel6").val()==null) ? [] : $("#mulsel6").val() ).join(","), - mesure: ( ($("#mulsel7").val()==null) ? [] : $("#mulsel7").val() ).join(","), - start_text: $("#start-text").val(), - end_text: $("#end-text").val() + start_mesure: $("#start-mesure").val(), + end_mesure: ($("#end-mesure").attr('disabled')) ? "" : $("#end-mesure").val() } }) .done(function( html ) { @@ -215,7 +243,8 @@ $("#mulsel6").multiselect('deselect', "opera_scene: " + $(this).parent().text().split(" ")[1].trim()); } else if($(this).parent().hasClass("mesure")){ - $("#mulsel7").multiselect('deselect', "opera_mesure: " + $(this).parent().text().split(" ")[1].trim()); + $('#start-mesure')[0].selectedIndex = 0; + $("#end-mesure").attr('disabled','disabled'); } else if($(this).parent().hasClass("date")){ $('input[name=start_date]').val(""); @@ -254,225 +283,8 @@ // Search annotations management - - function searchAnnotations(){ - $(".annotation-results").html("Erreur de chargement
'); - }); - } - - $("#btn-search-annotations").click(function(e){ - e.preventDefault(); - if($("#search-input").val()==""){ - $(".annotation-results").html("Vous devez indiquer un terme pour la recherche.
"); - return false; - } - searchAnnotations(); - }); - - $("#btn-filter-annotations").click(function(e){ - if($("#mulsel4").val() && $("#mulsel4").val()!=""){ - var filters = $("#mulsel4").val(); - var nb_filters = filters.length; - if($('#search-input').val()!=""){ - $( ".searched-annot" ).each(function(index){ - var type_inter = $(this).attr("data-type-inter").split(", "); - var found = true; - for(var i=0;iErreur de chargement
'); - }); - }); - - // Chapter to annotations management - $(".chapter-results").on("click", ".chapter-to-annot", function(){ - // First we unselect chapter filters - $('option', $('#mulsel4')).each(function(element) { $(this).removeAttr('selected').prop('selected', false); }); - $('#mulsel4').multiselect('refresh'); - // Then we request - $(".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); - } - - // spectacle theatre text management - $(".toggle-text").click(function(e){ - if($(".theatre-text:visible").length==0){ - $(".theatre-text").show(); - $(".toggle-text .glyphicon-chevron-right").addClass("rotate-90"); - } - else{ - $(".theatre-text").hide(); - $(".toggle-text .glyphicon-chevron-right").removeClass("rotate-90"); - } - }); }); diff -r 89c912926812 -r 0eab4a2257a7 src/spel/templates/partial/spel_opera_annotations.html --- a/src/spel/templates/partial/spel_opera_annotations.html Mon May 19 13:14:17 2014 +0200 +++ b/src/spel/templates/partial/spel_opera_annotations.html Wed May 21 18:28:07 2014 +0200 @@ -14,7 +14,11 @@ {% for t in type_travail %}{{ segments|length }} segment(s) trouvé(s)
diff -r 89c912926812 -r 0eab4a2257a7 src/spel/templates/spel_opera.html --- a/src/spel/templates/spel_opera.html Mon May 19 13:14:17 2014 +0200 +++ b/src/spel/templates/spel_opera.html Wed May 21 18:28:07 2014 +0200 @@ -26,25 +26,34 @@