diff -r f4a03f8bc37a -r 458cc4576415 integration/js/taghome.js --- a/integration/js/taghome.js Fri Dec 21 15:45:10 2012 +0100 +++ b/integration/js/taghome.js Fri Jan 04 18:10:03 2013 +0100 @@ -5,12 +5,40 @@ acdata = [], labels = { content: "Séquence", - tag: "Tag" - }; + tag: "Mot-clé" + }, + replacerx; acInput.autocomplete({ source: function( request, response ) { - response($.ui.autocomplete.filter(acdata, request.term)); + var charsub = [ '[aáàâä]', '[cç]', '[eéèêë]', '[iíìîï]', '[oóòôö]' ], + terms = request.term.split(/[\s,]/), + escterms = terms.map(function(term) { + var t = term.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm, '\\$1'); + _(charsub).each(function(chars) { + var tmprx = new RegExp(chars,"gim"); + t = t.replace(tmprx, chars); + }); + return t; + }).filter(_.identity); + var searchrxs = _(escterms).map(function(term) { + return new RegExp("(^|\\s)" + term, "i") + }); + replacerx = new RegExp("(^|\\s)(" + escterms.join("|") + ")", "gi"); + var filtered = acdata + .filter(function(d) { + return _(searchrxs).reduce(function(memo, rx) { + return memo && rx.test(d.label); + }, true); + }) + .sort(function(a, b) { + if (a.type === b.type) { + return (a.label > b.label ? 1 : (a.label < b.label ? -1 : 0)); + } else { + return (a.type === "content" ? -1 : 1); + } + }); + response(filtered); }, select: function(event, ui) { document.location.href = ui.item.href; @@ -18,9 +46,12 @@ }).data("autocomplete")._renderItem = function(ul, item) { return $( "
  • " ) .data( "item.autocomplete", item ) - .append( "" + labels[item.type] + " : " + item.label + "" ) + .append( "" + labels[item.type] + " : " + item.label.replace(replacerx, '$1$2') + "" ) .appendTo( ul ); }; + acInput.on("keyup input paste", function() { + acInput.val(acInput.val().toUpperCase()); + }); $("#form_tag").submit(function() { return false; @@ -28,6 +59,33 @@ tagsInner.draggable(); + var dragtimeout; + + $(".arrow_left").data({xdelta: 6, ydelta: 0}); + $(".arrow_right").data({xdelta: -6, ydelta: 0}); + $(".arrow_top").data({xdelta: 0, ydelta: 6}); + $(".arrow_bottom").data({xdelta: 0, ydelta: -6}); + + $(".arrow") + .mousedown(function() { + var deltas = $(this).data(), + move = function() { + tagsInner.css({ + "left": deltas.xdelta + parseInt(tagsInner.css("left")), + "top": deltas.ydelta + parseInt(tagsInner.css("top")) + }); + } + window.clearInterval(dragtimeout); + dragtimeout = window.setInterval(move, 20); + move(); + }) + .on( + "mouseout mouseup", + function() { + window.clearInterval(dragtimeout); + } + ); + function resizeTags() { tagsInner.css({ "margin-left": - Math.floor(tagsInner.width()/2) + "px", @@ -47,7 +105,7 @@ }, success: function(data) { _(data.objects).each(function(content) { - var fpmatch = content.front_project.match(/projects\/([0-9a-f\-]+)/), + var fpmatch = (content.front_project || "").match(/projects\/([0-9a-f\-]+)/), fproj = fpmatch ? fpmatch[1] : ""; acdata.push({ label: content.title, @@ -96,7 +154,7 @@ var l = ordered.length, max = ordered[0].weight, min = Math.min(max - 1, ordered[l - 1].weight), - colorscale = 128 / (max - min), + colorscale = 160 / (max - min), ncols = Math.floor(.65*Math.sqrt(l)), nlines = Math.ceil(l/ncols); var cells = _(nlines * ncols) @@ -130,7 +188,7 @@ } _html += ""; if (c.tag) { - var color = Math.floor( 127 + (c.tag.weight - min) * colorscale ); + var color = Math.floor( 95 + (c.tag.weight - min) * colorscale ); _html += '