Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ correctly ellipsify

  • Loading branch information...
commit 510faf773ab613e97bdd582bdbd2a30b6499d4e1 1 parent 6251fb6
@floere authored
View
26 client/javascripts/picky.min.js
@@ -1,19 +1,19 @@
Array.prototype.index=function(a){for(var b=0,k=this.length;b<k;b++)if(this[b]==a)return b;return null};Array.prototype.include=function(a){return this.index(a)!==null};Array.prototype.remove=function(a){this.splice(a,1);return this};Array.prototype.compare=function(a){return this.join("")==a.join("")};Array.prototype.each=function(a){for(var b=0,k=this.length;b<k;b++)a(b,this[b]);return this};Array.prototype.map=function(a){for(var b=0,k=this.length;b<k;b++)this[b]=a(b,this[b]);return this};var dictionary={common:{join:{de:"und",fr:"et",it:"e",en:"and",ch:"und"},"with":{de:"mit",fr:"avec",it:"con",en:"with",ch:"mit"},of:{de:"von",fr:"de",it:"di",en:"of",ch:"vo"},to:{de:"bis",fr:"\u00e0",it:"alla",en:"to",ch:"bis"}},results:{addination:{more:{de:"Weitere Resultate",fr:"Autres r\u00e9sultats",it:"Altri risultati",en:"More results",ch:"Mee Resultaat"}},header:{de:"Ergebnisse",fr:"R\u00e9sultats",it:"Risultati",en:"Results",ch:"Erg\u00e4bnis"}}},t=function(a){for(var b=PickyI18n.locale||
"en",k=a.split(".").concat(b),i=dictionary,j=0,n=k.length;j<n;j++){i=i[k[j]];if(i==undefined){i="Translation missing: "+a+"."+b;break}}return i};function Allocation(a,b,k,i,j,n){var p=this;this.type=a;this.weight=b;this.count=k;this.combination=i;this.ids=j||[];this.entries=this.rendered=n||[];this.isType=function(u){return u==p.type}}function Allocations(a){this.allocations=[];for(var b=0,k=a.length;b<k;b++){var i=a[b];this.allocations.push(new Allocation(i[0],i[1],i[2],i[3],i[4],i[5]))}this.length=this.allocations.length;this.remove=function(j){this.allocations.splice(j,1)};this.each=function(j){this.allocations.each(j)}}
-function PickyData(a){var b=a.total,k=a.duration,i=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=k;this.offset=i;this.allocations=j;this.renderedAmount=function(){var n=0;j.each(function(p,u){n+=u.rendered.length});return n};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var k=b.showResultsLimit||10,i=b.input,j=b.reset,n=b.button,p=b.counter,u=b.dashboard,x=b.moreSelector,s=b.results,w=b.noResults,y=new PickyAddination(this,s),e=new PickyAllocationsCloud(this,b),c=new PickyResultsRenderer(y,b),g=function(){j.fadeTo(166,1)},o=function(){e.hide();s.empty();w.hide()},m=function(f){i.val(f);j.fadeTo(166,0);q("empty");p.empty();o()};this.reset=m;var h=function(){return i.val()};this.text=h;var r=function(f){p.text(f);f>0&&f<=5&&p.fadeTo("fast",
-0.5).fadeTo("fast",1)},d=function(f){if(f.isEmpty())return"none";if(f.total>k&&f.allocations.length>1)return"support";return"ok"},q=function(f){u.attr("class","dashboard "+f)};this.insert=function(f){i.val(f);i.select()};this.fullResultsCallback=function(f){q(d(f));if(f.isEmpty()){o();r(0);w.show();g()}else if(f.total>k&&f.allocations.length>1){o();g();e.show(f);r(f.total)}else if(f.offset==0){o();r(f.total);c.render(s,f);s.show();g();i.focus()}else{var v=$(x).position().top;y.remove();c.render(s,
-f);$("body").animate({scrollTop:v-12},500)}};this.liveResultsCallback=function(f){q(d(f));r(f.total)};this.allocationChosen=function(f){f=f.data.query;a.insert(f);a.allocationChosen(f)};this.addinationClicked=function(f){a.addinationClicked(h(),f)};(function(){i.keyup(function(f){if(h()==""){m();a.searchTextCleared()}else g();a.searchTextEntered(h(),f)});p.click(function(){a.searchButtonClicked(h())});n.click(function(){a.searchButtonClicked(h())});j.click(function(){m("");a.clearButtonClicked();
+function PickyData(a){var b=a.total,k=a.duration,i=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=k;this.offset=i;this.allocations=j;this.renderedAmount=function(){var n=0;j.each(function(p,u){n+=u.rendered.length});return n};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var k=b.showResultsLimit||10,i=b.input,j=b.reset,n=b.button,p=b.counter,u=b.dashboard,x=b.moreSelector,s=b.results,v=b.noResults,z=new PickyAddination(this,s),e=new PickyAllocationsCloud(this,b),c=new PickyResultsRenderer(z,b),g=function(){j.fadeTo(166,1)},o=function(){e.hide();s.empty();v.hide()},m=function(f){i.val(f);j.fadeTo(166,0);q("empty");p.empty();o()};this.reset=m;var h=function(){return i.val()};this.text=h;var r=function(f){p.text(f);f>0&&f<=5&&p.fadeTo("fast",
+0.5).fadeTo("fast",1)},d=function(f){if(f.isEmpty())return"none";if(f.total>k&&f.allocations.length>1)return"support";return"ok"},q=function(f){u.attr("class","dashboard "+f)};this.insert=function(f){i.val(f);i.select()};this.fullResultsCallback=function(f){q(d(f));if(f.isEmpty()){o();r(0);v.show();g()}else if(f.total>k&&f.allocations.length>1){o();g();e.show(f);r(f.total)}else if(f.offset==0){o();r(f.total);c.render(s,f);s.show();g();i.focus()}else{var y=$(x).position().top;z.remove();c.render(s,
+f);$("body").animate({scrollTop:y-12},500)}};this.liveResultsCallback=function(f){q(d(f));r(f.total)};this.allocationChosen=function(f){f=f.data.query;a.insert(f);a.allocationChosen(f)};this.addinationClicked=function(f){a.addinationClicked(h(),f)};(function(){i.keyup(function(f){if(h()==""){m();a.searchTextCleared()}else g();a.searchTextEntered(h(),f)});p.click(function(){a.searchButtonClicked(h())});n.click(function(){a.searchButtonClicked(h())});j.click(function(){m("");a.clearButtonClicked();
i.focus()})})();i.focus()};var PickyBackend=function(a){var b=function(k,i,j){var n=j||{};n=$.extend({query:k},j);$.getJSON(a,n,function(p){i&&i(new PickyData(p))})};this.search=function(k,i,j,n){b(k,function(p){i&&i(n,p)},j)}},LiveBackend=function(a){var b=a.live||alert("A live backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.live=latestRequestTimestamp;n=$.extend({ids:a.liveResults||0,offset:0},n);k.search(i,function(u,x){if(!u.live||u.live==latestRequestTimestamp)j&&
-j(x)},n,p)}},FullBackend=function(a){var b=a.full||alert("A full backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;n=$.extend({ids:a.fullResults||20,offset:0},n);k.search(i,function(u,x){if(!u.full||u.full==latestRequestTimestamp)j&&j(x)},n,p)}};var PickyController=function(a){var b=new PickyView(this,a),k=a.backends,i=a.beforeInsert||function(){},j=a.before||function(){},n=a.success||function(){},p=a.after||function(){},u=a.liveRendered||false,x=a.liveSearchInterval||180,s,w=function(d){return(d=d&&d.match(/q=([^&]+)/))&&decodeURIComponent(d[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=w;var y=function(){var d=window.History&&window.History.getState();return w(d&&d.url)};this.lastFullQuery=y;var e=function(d,q,f,v){var z=
-j(q,v);if(z!=undefined)q=z;s=[d,q,f,v];z=q;if(z!=y()){z=z==""?"":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(q=="")b.reset();else(d=k[d])&&d.search(q,f,v)};this.resend=function(){s&&e.apply(this,s)};var c=function(d,q){d=n(d,q)||d;b.fullResultsCallback(d);p(d,q)},g=function(d,q){clearInterval(m);e("full",d,c,q||{})};a=function(d,q){d=n(d,q)||d;b.liveResultsCallback(d);p(d,q)};var o=u?c:a,m,h=function(){var d=
-b.text();e("live",d,o,{});clearInterval(m)};m=setInterval(h,x);clearInterval(m);var r=function(d,q,f){var v=i(d);if(v!=undefined)d=v;b.insert(d);f&&g(d,q)};this.insert=r;this.clearButtonClicked=function(){clearInterval(m)};this.searchTextCleared=function(){clearInterval(m)};this.searchTextEntered=function(d,q){if($.inArray(q.keyCode,[0,8,13,32,46,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(q.keyCode==13)g(d);else{clearInterval(m);
-m=setInterval(h,x)}};this.searchButtonClicked=function(d){g(d)};this.allocationChosen=function(d){g(d)};this.addinationClicked=function(d,q){g(d,{offset:q.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();d=w(d.url);d!=undefined&&d!=(s&&s.length>1&&s[1])&&r(d,{},true)})};var PickyI18n={},PickyClient=function(a){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en";a.locale=a.locale||PickyI18n.locale;a.qualifiers=a.qualifiers||{};a.explanations=a.explanations||{};a.choices=a.choices||{};a.explanation_delimiters={ch:"und",de:"und",en:"and",fr:"et",it:"e"};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};
+j(x)},n,p)}},FullBackend=function(a){var b=a.full||alert("A full backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;n=$.extend({ids:a.fullResults||20,offset:0},n);k.search(i,function(u,x){if(!u.full||u.full==latestRequestTimestamp)j&&j(x)},n,p)}};var PickyController=function(a){var b=new PickyView(this,a),k=a.backends,i=a.beforeInsert||function(){},j=a.before||function(){},n=a.success||function(){},p=a.after||function(){},u=a.liveRendered||false,x=a.liveSearchInterval||180,s,v=function(d){return(d=d&&d.match(/q=([^&]+)/))&&decodeURIComponent(d[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=v;var z=function(){var d=window.History&&window.History.getState();return v(d&&d.url)};this.lastFullQuery=z;var e=function(d,q,f,y){var w=
+j(q,y);if(w!=undefined)q=w;s=[d,q,f,y];w=q;if(w!=z()){w=w==""?"":"?q="+escape(w).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,w)}if(q=="")b.reset();else(d=k[d])&&d.search(q,f,y)};this.resend=function(){s&&e.apply(this,s)};var c=function(d,q){d=n(d,q)||d;b.fullResultsCallback(d);p(d,q)},g=function(d,q){clearInterval(m);e("full",d,c,q||{})};a=function(d,q){d=n(d,q)||d;b.liveResultsCallback(d);p(d,q)};var o=u?c:a,m,h=function(){var d=
+b.text();e("live",d,o,{});clearInterval(m)};m=setInterval(h,x);clearInterval(m);var r=function(d,q,f){var y=i(d);if(y!=undefined)d=y;b.insert(d);f&&g(d,q)};this.insert=r;this.clearButtonClicked=function(){clearInterval(m)};this.searchTextCleared=function(){clearInterval(m)};this.searchTextEntered=function(d,q){if($.inArray(q.keyCode,[0,8,13,32,46,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(q.keyCode==13)g(d);else{clearInterval(m);
+m=setInterval(h,x)}};this.searchButtonClicked=function(d){g(d)};this.allocationChosen=function(d){g(d)};this.addinationClicked=function(d,q){g(d,{offset:q.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();d=v(d.url);d!=undefined&&d!=(s&&s.length>1&&s[1])&&r(d,{},true)})};var PickyI18n={},PickyClient=function(a){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en";a.locale=a.locale||PickyI18n.locale;a.qualifiers=a.qualifiers||{};a.explanations=a.explanations||{};a.choices=a.choices||{};a.explanation_delimiters={ch:"und",de:"und",en:"and",fr:"et",it:"e"};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};
b=a.enclosingSelector||"#picky";a.input=$(a.inputSelector||b+" input.query");a.reset=$(a.resetSelector||b+" div.reset");a.button=$(a.buttonSelector||b+" input.search_button");a.counter=$(a.counterSelector||b+" div.status");a.dashboard=$(a.dashboardSelector||b+" .dashboard");a.results=$(a.resultsSelector||b+" div.results");a.noResults=$(a.noResultsSelector||b+" .no_results");a.moreSelector=a.moreSelector||b+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||b+" .allocations");
a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.maxSuggestions=a.maxSuggestions||3;a.results=$(a.resultsSelector||b+" div.results");a.resultsDivider=a.resultsDivider||"";a.nonPartial=a.nonPartial||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var k=a.controller&&new a.controller(a)||new PickyController(a);var i=this.insert=function(j,n,p){k.insert(j,n||{},p||true)};this.resend=k.resend;
this.insertFromURL=function(j){if(j)i(j);else(j=k.lastFullQuery())&&i(j)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(k){var i=k.total,j,n=k.renderedAmount();j=k.offset+n;n=j+n;k=k.total;if(k<n)n=k;j={offset:j,start:j+1,end:n};if(j.offset<i){i=$("<div class='addination'>"+t("results.addination.more")+"</div>");i.bind("click",{offset:j.offset},a.addinationClicked);return i}else return""}};var PickyResultsRenderer=function(a,b){var k=b.locale,i=b.explanations||{},j=b.explanation_delimiters||{},n=b.resultsDivider,p=b.wrapResults,u=b.nonPartial,x=function(c){var g=c[c.length-1];if(g===undefined)return[];c=c.slice(0,c.length-1);if(c==[])c=[c];if(!u.include(g[0]))if(g[1].match(/[^\*~]$/))g[1]+="*";c.push(g);return c};this.asteriskifyLastToken=x;var s=function(c){for(var g=i[k]||{},o=[],m,h=0,r=c.length;h<r;h++){m=c[h];var d=m[0];d=g[d]||d;o.push([d,m[1]])}return o};this.explainCategory=
-s;var w=function(c,g){return[c.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0\,]+)/,"<strong>$1</strong>"),g].join(" ")};this.strongify=w;var y=function(c,g){var o=j[k],m="",h=[],r=[];s(x(g)).each(function(d,q){var f=q[0],v=q[1];v=v.replace(/[\w,]+:(.+)/,"$1");if(m==""||f==m){h.push(v);m=f}else{var z=w(m,h.join(" "));h=[];h.push(v);m=f;r.push(z)}});r.push(w(m,h.join(" ")));r=r.join(" "+o+" ");return r='<span class="explanation">'+c+" "+r+"</span>"};this.explain=y;var e=function(c,
-g){var o='<div class="header">';o+=y(g.type,g.combination);if(c.offset>0)o+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';o+="</div>";return o};this.renderHeader=e;this.render=function(c,g){g.allocations.each(function(o,m){if(m.entries.length>0){c.append(e(g,m)).append(m.entries.join(n));c.children("li").wrapAll(p)}});c.append(a.render(g))}};function AllocationRenderer(a){function b(e){var c={},g={},o={},m=[],h;h=0;for(l=e.length;h<l;h++){var r=e[h][0];if(r in c){c[r].push(e[h][1]);g[r].push(e[h][2]);m.push(h)}else{c[r]=[e[h][1]];g[r]=[e[h][2]];o[h]=r}}for(h in o){e[h][1]=c[o[h]];e[h][2]=g[o[h]]}for(h=m.length-1;h>=0;h--)e.remove(m[h]);return e}function k(e){e.map(function(c){return"%"+(c+1)+"$s"});return e.join(" ")}function i(e){if(e.length==0)return"";e=b(e);e.sort(function(d,q){return d[0]<q[0]?-1:1});for(var c=[],g=0,o=e.length;g<
-o;g++)c.push(e[g][0]);var m=c.length==1,h=w[c.join(",")];if(h===undefined)h=w[c]=k(c);if(typeof h==="string"){w[c]={format:h,ignoreSingle:true};h=w[c]}var r=h.format;e.each(function(d,q){var f=q[0],v=q[2];h.filter&&v.map(function(z,A){return h.filter(A)});if(m&&!(h&&h.ignoreSingle)){f=x[f]||f;return r=v.join("&nbsp;")+"&nbsp;("+f+")"}v.map(function(z,A){return A.replace(/[\w,]+:(.+)/,"$1")});r=r.replace(RegExp("%"+(d+1)+"\\$s","g"),v.join("&nbsp;"))});return r}function j(e){for(var c=[],g=0,o=s.length;g<
-o;g++)c.push([]);c.push([]);g=0;for(o=e.length;g<o;g++){for(var m=e[g],h=m[0],r=false,d=0,q=s.length;d<q;d++)if(s[d].include(h)){c[d].push(m);r=true;break}r||c[c.length-1].push(m)}var f;for(e=c.length-1;e>=0;e--){f=c[e];if(f.length>0)break}f=f[f.length-1];y.include(f[0])||(f[1]=f[1].valueOf()+"...");return c}function n(e){var c=[];j(e).each(function(g,o){var m=i(o);m&&c.push(m)});return c.join(" ")}var p=a.locale,u=a.qualifiers&&a.qualifiers[p]||{},x=a.explanations&&a.explanations[p]||{},s=a.groups||
-[],w=a.choices&&a.choices[p]||{},y=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=k;this.rendered=i;this.groupify=j;this.querify=function(e){var c=[],g,o,m;for(m in e){g=e[m][0];g=u[g]||g;o=(o=e[m][1])||"";o=o.charAt(o.length-1)=="*"?"*":"";c[m]=g+":"+e[m][2]+o}return c.join(" ")};this.suggestify=n;this.render=function(e){return n(e.combination)}};var PickyAllocationsCloud=function(a,b){var k=b.allocations,i=b.shownAllocations,j=b.showMoreAllocations,n=b.hiddenAllocations,p=b.maxSuggestions,u=function(){k.hide()},x=function(e){u();a.allocationChosen(e)},s=new AllocationRenderer(b),w=function(e){var c=[];e.each(function(g,o){var m=s.querify(o.combination),h=s.render(o);h=$('<li><div class="text">'+h+'</div><div class="count">'+o.count+"</div></li>");h.bind("click",{query:m},x);c.push(h)});return c},y=function(e){if(e.length==0)return k.hide();
-i.empty();j.hide();n.empty().hide();if(e.length>p){$.each(e.slice(0,p-1),function(c,g){i.append(g)});$.each(e.slice(p-1),function(c,g){n.append(g)});j.show()}else $.each(e,function(c,g){i.append(g)});return k.show()};j.click(function(){j.hide();n.show()});this.hide=u;this.show=function(e){y(w(e.allocations));k.show()}};
+s;var v=function(c,g){return[c.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0\,]+)/,"<strong>$1</strong>"),g].join(" ")};this.strongify=v;var z=function(c,g){var o=j[k],m="",h=[],r=[];s(x(g)).each(function(d,q){var f=q[0],y=q[1];y=y.replace(/[\w,]+:(.+)/,"$1");if(m==""||f==m){h.push(y);m=f}else{var w=v(m,h.join(" "));h=[];h.push(y);m=f;r.push(w)}});r.push(v(m,h.join(" ")));r=r.join(" "+o+" ");return r='<span class="explanation">'+c+" "+r+"</span>"};this.explain=z;var e=function(c,
+g){var o='<div class="header">';o+=z(g.type,g.combination);if(c.offset>0)o+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';o+="</div>";return o};this.renderHeader=e;this.render=function(c,g){g.allocations.each(function(o,m){if(m.entries.length>0){c.append(e(g,m)).append(m.entries.join(n));c.children("li").wrapAll(p)}});c.append(a.render(g))}};function AllocationRenderer(a){function b(e){var c={},g={},o={},m=[],h;h=0;for(l=e.length;h<l;h++){var r=e[h][0];if(r in c){c[r].push(e[h][1]);g[r].push(e[h][2]);m.push(h)}else{c[r]=[e[h][1]];g[r]=[e[h][2]];o[h]=r}}for(h in o){e[h][1]=c[o[h]];e[h][2]=g[o[h]]}for(h=m.length-1;h>=0;h--)e.remove(m[h]);return e}function k(e){e.map(function(c){return"%"+(c+1)+"$s"});return e.join(" ")}function i(e){if(e.length==0)return"";e=b(e);e.sort(function(d,q){return d[0]<q[0]?-1:1});for(var c=[],g=0,o=e.length;g<
+o;g++)c.push(e[g][0]);var m=c.length==1,h=v[c.join(",")];if(h===undefined)h=v[c]=k(c);if(typeof h==="string"){v[c]={format:h,ignoreSingle:true};h=v[c]}var r=h.format;e.each(function(d,q){var f=q[0],y=q[1],w=q[2];w.map(function(B,A){var C=y[B];if(C.charAt(C.length-1)=="*")A+="...";return A});h.filter&&w.map(function(B,A){return h.filter(A)});if(m&&!(h&&h.ignoreSingle)){f=x[f]||f;return r=w.join("&nbsp;")+"&nbsp;("+f+")"}w.map(function(B,A){return A.replace(/[\w,]+:(.+)/,"$1")});r=r.replace(RegExp("%"+
+(d+1)+"\\$s","g"),w.join("&nbsp;"))});return r}function j(e){for(var c=[],g=0,o=s.length;g<o;g++)c.push([]);c.push([]);g=0;for(o=e.length;g<o;g++){for(var m=e[g],h=m[0],r=false,d=0,q=s.length;d<q;d++)if(s[d].include(h)){c[d].push(m);r=true;break}r||c[c.length-1].push(m)}var f;for(e=c.length-1;e>=0;e--){f=c[e];if(f.length>0)break}f=f[f.length-1];z.include(f[0])||(f[1]=f[1].valueOf()+"*");return c}function n(e){var c=[];j(e).each(function(g,o){var m=i(o);m&&c.push(m)});return c.join(" ")}var p=a.locale,
+u=a.qualifiers&&a.qualifiers[p]||{},x=a.explanations&&a.explanations[p]||{},s=a.groups||[],v=a.choices&&a.choices[p]||{},z=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=k;this.rendered=i;this.groupify=j;this.querify=function(e){var c=[],g,o,m;for(m in e){g=e[m][0];g=u[g]||g;o=(o=e[m][1])||"";o=o.charAt(o.length-1)=="*"?"*":"";c[m]=g+":"+e[m][2]+o}return c.join(" ")};this.suggestify=n;this.render=function(e){return n(e.combination)}};var PickyAllocationsCloud=function(a,b){var k=b.allocations,i=b.shownAllocations,j=b.showMoreAllocations,n=b.hiddenAllocations,p=b.maxSuggestions,u=function(){k.hide()},x=function(e){u();a.allocationChosen(e)},s=new AllocationRenderer(b),v=function(e){var c=[];e.each(function(g,o){var m=s.querify(o.combination),h=s.render(o);h=$('<li><div class="text">'+h+'</div><div class="count">'+o.count+"</div></li>");h.bind("click",{query:m},x);c.push(h)});return c},z=function(e){if(e.length==0)return k.hide();
+i.empty();j.hide();n.empty().hide();if(e.length>p){$.each(e.slice(0,p-1),function(c,g){i.append(g)});$.each(e.slice(p-1),function(c,g){n.append(g)});j.show()}else $.each(e,function(c,g){i.append(g)});return k.show()};j.click(function(){j.hide();n.show()});this.hide=u;this.show=function(e){z(v(e.allocations));k.show()}};
View
BIN  client/javascripts/picky.source.js.tar
Binary file not shown
View
15 client/javascripts/source/picky.allocation_renderer.js
@@ -126,9 +126,18 @@ function AllocationRenderer(config) {
// Replace each word into the formatting string.
//
zipped.each(function(i, original_token) {
- var category = original_token[0];
- var words = original_token[2];
+ var category = original_token[0];
+ var originals = original_token[1];
+ var words = original_token[2];
+ // Add ellipses.
+ //
+ words.map(function(i, word) {
+ var original = originals[i];
+ if (original.charAt(original.length - 1) == "*") { word += "..."; }
+ return word;
+ });
+
if (formatting.filter) {
words.map(function(i, word) {
return formatting.filter(word);
@@ -211,7 +220,7 @@ function AllocationRenderer(config) {
// And append "ellipses".
//
- if (!nonPartial.include(last_part[0])) { last_part[1] = last_part[1].valueOf() + '...'; }
+ if (!nonPartial.include(last_part[0])) { last_part[1] = last_part[1].valueOf() + '*'; }
return groups;
};
View
26 client/javascripts/spec/picky.allocation_renderer.spec.js
@@ -141,7 +141,7 @@ describe(
return renderer.groupify([
['cat1', 'Orig1', 'parsed1']
]).compare([
- ['cat1', 'Orig1...', 'parsed1']
+ ['cat1', 'Orig1*', 'parsed1']
]);
});
it("is correct", function() {
@@ -151,8 +151,8 @@ describe(
]).compare([
[],
[
- ['cat1', 'Orig1', 'parsed1'], // Both in the second group.
- ['cat2', 'Orig2...', 'parsed2']
+ ['cat1', 'Orig1', 'parsed1'], // Both in the second group.
+ ['cat2', 'Orig2*', 'parsed2']
]
]);
});
@@ -164,9 +164,9 @@ describe(
]).compare([
[],
[
- ['cat1', 'Orig1', 'parsed1'], // All in the second group.
- ['cat2', 'Orig2', 'parsed2'],
- ['cat1', 'Orig3...', 'parsed3']
+ ['cat1', 'Orig1', 'parsed1'], // All in the second group.
+ ['cat2', 'Orig2', 'parsed2'],
+ ['cat1', 'Orig3*', 'parsed3']
]
]);
});
@@ -180,8 +180,8 @@ describe(
['invisible', 'Invisible2', 'invisible2']
],
[
- ['cat1', 'Orig1', 'parsed1'],
- ['cat1', 'Orig2...', 'parsed2']
+ ['cat1', 'Orig1', 'parsed1'],
+ ['cat1', 'Orig2*', 'parsed2']
]
]);
});
@@ -214,29 +214,29 @@ describe(
it("is correct", function() {
return renderer.suggestify([
['cat1', 'Orig1', 'parsed1']
- ]) == "parsed1";
+ ]) == "parsed1...";
});
it("is correct", function() {
return renderer.suggestify([
['cat1', 'Orig1', 'parsed1'],
['cat2', 'Orig2', 'parsed2']
- ]) == "parsed1 parsed2";
+ ]) == "parsed1 parsed2...";
});
it("is correct", function() {
return renderer.suggestify([
['cat1', 'Orig1 Orig3', 'parsed1 parsed3'],
['cat2', 'Orig2', 'parsed2']
- ]) == "parsed1 parsed3 parsed2";
+ ]) == "parsed1 parsed3 parsed2...";
});
it("is correct", function() {
return renderer.suggestify([
['title', 'Orig1', 'parsed1']
- ]) == "PARSED1&nbsp;(title)";
+ ]) == "PARSED1...&nbsp;(title)";
});
it("is correct", function() {
return renderer.suggestify([
['author', 'Orig1', 'parsed1']
- ]) == "<em>parsed1</em>";
+ ]) == "<em>parsed1...</em>";
});
});
}
View
15 client/test_project/javascripts/picky.allocation_renderer.js
@@ -126,9 +126,18 @@ function AllocationRenderer(config) {
// Replace each word into the formatting string.
//
zipped.each(function(i, original_token) {
- var category = original_token[0];
- var words = original_token[2];
+ var category = original_token[0];
+ var originals = original_token[1];
+ var words = original_token[2];
+ // Add ellipses.
+ //
+ words.map(function(i, word) {
+ var original = originals[i];
+ if (original.charAt(original.length - 1) == "*") { word += "..."; }
+ return word;
+ });
+
if (formatting.filter) {
words.map(function(i, word) {
return formatting.filter(word);
@@ -211,7 +220,7 @@ function AllocationRenderer(config) {
// And append "ellipses".
//
- if (!nonPartial.include(last_part[0])) { last_part[1] = last_part[1].valueOf() + '...'; }
+ if (!nonPartial.include(last_part[0])) { last_part[1] = last_part[1].valueOf() + '*'; }
return groups;
};
View
26 generators/prototypes/client/sinatra/javascripts/picky.min.js
@@ -1,19 +1,19 @@
Array.prototype.index=function(a){for(var b=0,k=this.length;b<k;b++)if(this[b]==a)return b;return null};Array.prototype.include=function(a){return this.index(a)!==null};Array.prototype.remove=function(a){this.splice(a,1);return this};Array.prototype.compare=function(a){return this.join("")==a.join("")};Array.prototype.each=function(a){for(var b=0,k=this.length;b<k;b++)a(b,this[b]);return this};Array.prototype.map=function(a){for(var b=0,k=this.length;b<k;b++)this[b]=a(b,this[b]);return this};var dictionary={common:{join:{de:"und",fr:"et",it:"e",en:"and",ch:"und"},"with":{de:"mit",fr:"avec",it:"con",en:"with",ch:"mit"},of:{de:"von",fr:"de",it:"di",en:"of",ch:"vo"},to:{de:"bis",fr:"\u00e0",it:"alla",en:"to",ch:"bis"}},results:{addination:{more:{de:"Weitere Resultate",fr:"Autres r\u00e9sultats",it:"Altri risultati",en:"More results",ch:"Mee Resultaat"}},header:{de:"Ergebnisse",fr:"R\u00e9sultats",it:"Risultati",en:"Results",ch:"Erg\u00e4bnis"}}},t=function(a){for(var b=PickyI18n.locale||
"en",k=a.split(".").concat(b),i=dictionary,j=0,n=k.length;j<n;j++){i=i[k[j]];if(i==undefined){i="Translation missing: "+a+"."+b;break}}return i};function Allocation(a,b,k,i,j,n){var p=this;this.type=a;this.weight=b;this.count=k;this.combination=i;this.ids=j||[];this.entries=this.rendered=n||[];this.isType=function(u){return u==p.type}}function Allocations(a){this.allocations=[];for(var b=0,k=a.length;b<k;b++){var i=a[b];this.allocations.push(new Allocation(i[0],i[1],i[2],i[3],i[4],i[5]))}this.length=this.allocations.length;this.remove=function(j){this.allocations.splice(j,1)};this.each=function(j){this.allocations.each(j)}}
-function PickyData(a){var b=a.total,k=a.duration,i=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=k;this.offset=i;this.allocations=j;this.renderedAmount=function(){var n=0;j.each(function(p,u){n+=u.rendered.length});return n};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var k=b.showResultsLimit||10,i=b.input,j=b.reset,n=b.button,p=b.counter,u=b.dashboard,x=b.moreSelector,s=b.results,w=b.noResults,y=new PickyAddination(this,s),e=new PickyAllocationsCloud(this,b),c=new PickyResultsRenderer(y,b),g=function(){j.fadeTo(166,1)},o=function(){e.hide();s.empty();w.hide()},m=function(f){i.val(f);j.fadeTo(166,0);q("empty");p.empty();o()};this.reset=m;var h=function(){return i.val()};this.text=h;var r=function(f){p.text(f);f>0&&f<=5&&p.fadeTo("fast",
-0.5).fadeTo("fast",1)},d=function(f){if(f.isEmpty())return"none";if(f.total>k&&f.allocations.length>1)return"support";return"ok"},q=function(f){u.attr("class","dashboard "+f)};this.insert=function(f){i.val(f);i.select()};this.fullResultsCallback=function(f){q(d(f));if(f.isEmpty()){o();r(0);w.show();g()}else if(f.total>k&&f.allocations.length>1){o();g();e.show(f);r(f.total)}else if(f.offset==0){o();r(f.total);c.render(s,f);s.show();g();i.focus()}else{var v=$(x).position().top;y.remove();c.render(s,
-f);$("body").animate({scrollTop:v-12},500)}};this.liveResultsCallback=function(f){q(d(f));r(f.total)};this.allocationChosen=function(f){f=f.data.query;a.insert(f);a.allocationChosen(f)};this.addinationClicked=function(f){a.addinationClicked(h(),f)};(function(){i.keyup(function(f){if(h()==""){m();a.searchTextCleared()}else g();a.searchTextEntered(h(),f)});p.click(function(){a.searchButtonClicked(h())});n.click(function(){a.searchButtonClicked(h())});j.click(function(){m("");a.clearButtonClicked();
+function PickyData(a){var b=a.total,k=a.duration,i=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=k;this.offset=i;this.allocations=j;this.renderedAmount=function(){var n=0;j.each(function(p,u){n+=u.rendered.length});return n};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var k=b.showResultsLimit||10,i=b.input,j=b.reset,n=b.button,p=b.counter,u=b.dashboard,x=b.moreSelector,s=b.results,v=b.noResults,z=new PickyAddination(this,s),e=new PickyAllocationsCloud(this,b),c=new PickyResultsRenderer(z,b),g=function(){j.fadeTo(166,1)},o=function(){e.hide();s.empty();v.hide()},m=function(f){i.val(f);j.fadeTo(166,0);q("empty");p.empty();o()};this.reset=m;var h=function(){return i.val()};this.text=h;var r=function(f){p.text(f);f>0&&f<=5&&p.fadeTo("fast",
+0.5).fadeTo("fast",1)},d=function(f){if(f.isEmpty())return"none";if(f.total>k&&f.allocations.length>1)return"support";return"ok"},q=function(f){u.attr("class","dashboard "+f)};this.insert=function(f){i.val(f);i.select()};this.fullResultsCallback=function(f){q(d(f));if(f.isEmpty()){o();r(0);v.show();g()}else if(f.total>k&&f.allocations.length>1){o();g();e.show(f);r(f.total)}else if(f.offset==0){o();r(f.total);c.render(s,f);s.show();g();i.focus()}else{var y=$(x).position().top;z.remove();c.render(s,
+f);$("body").animate({scrollTop:y-12},500)}};this.liveResultsCallback=function(f){q(d(f));r(f.total)};this.allocationChosen=function(f){f=f.data.query;a.insert(f);a.allocationChosen(f)};this.addinationClicked=function(f){a.addinationClicked(h(),f)};(function(){i.keyup(function(f){if(h()==""){m();a.searchTextCleared()}else g();a.searchTextEntered(h(),f)});p.click(function(){a.searchButtonClicked(h())});n.click(function(){a.searchButtonClicked(h())});j.click(function(){m("");a.clearButtonClicked();
i.focus()})})();i.focus()};var PickyBackend=function(a){var b=function(k,i,j){var n=j||{};n=$.extend({query:k},j);$.getJSON(a,n,function(p){i&&i(new PickyData(p))})};this.search=function(k,i,j,n){b(k,function(p){i&&i(n,p)},j)}},LiveBackend=function(a){var b=a.live||alert("A live backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.live=latestRequestTimestamp;n=$.extend({ids:a.liveResults||0,offset:0},n);k.search(i,function(u,x){if(!u.live||u.live==latestRequestTimestamp)j&&
-j(x)},n,p)}},FullBackend=function(a){var b=a.full||alert("A full backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;n=$.extend({ids:a.fullResults||20,offset:0},n);k.search(i,function(u,x){if(!u.full||u.full==latestRequestTimestamp)j&&j(x)},n,p)}};var PickyController=function(a){var b=new PickyView(this,a),k=a.backends,i=a.beforeInsert||function(){},j=a.before||function(){},n=a.success||function(){},p=a.after||function(){},u=a.liveRendered||false,x=a.liveSearchInterval||180,s,w=function(d){return(d=d&&d.match(/q=([^&]+)/))&&decodeURIComponent(d[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=w;var y=function(){var d=window.History&&window.History.getState();return w(d&&d.url)};this.lastFullQuery=y;var e=function(d,q,f,v){var z=
-j(q,v);if(z!=undefined)q=z;s=[d,q,f,v];z=q;if(z!=y()){z=z==""?"":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(q=="")b.reset();else(d=k[d])&&d.search(q,f,v)};this.resend=function(){s&&e.apply(this,s)};var c=function(d,q){d=n(d,q)||d;b.fullResultsCallback(d);p(d,q)},g=function(d,q){clearInterval(m);e("full",d,c,q||{})};a=function(d,q){d=n(d,q)||d;b.liveResultsCallback(d);p(d,q)};var o=u?c:a,m,h=function(){var d=
-b.text();e("live",d,o,{});clearInterval(m)};m=setInterval(h,x);clearInterval(m);var r=function(d,q,f){var v=i(d);if(v!=undefined)d=v;b.insert(d);f&&g(d,q)};this.insert=r;this.clearButtonClicked=function(){clearInterval(m)};this.searchTextCleared=function(){clearInterval(m)};this.searchTextEntered=function(d,q){if($.inArray(q.keyCode,[0,8,13,32,46,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(q.keyCode==13)g(d);else{clearInterval(m);
-m=setInterval(h,x)}};this.searchButtonClicked=function(d){g(d)};this.allocationChosen=function(d){g(d)};this.addinationClicked=function(d,q){g(d,{offset:q.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();d=w(d.url);d!=undefined&&d!=(s&&s.length>1&&s[1])&&r(d,{},true)})};var PickyI18n={},PickyClient=function(a){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en";a.locale=a.locale||PickyI18n.locale;a.qualifiers=a.qualifiers||{};a.explanations=a.explanations||{};a.choices=a.choices||{};a.explanation_delimiters={ch:"und",de:"und",en:"and",fr:"et",it:"e"};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};
+j(x)},n,p)}},FullBackend=function(a){var b=a.full||alert("A full backend path must be provided."),k=new PickyBackend(b);this.search=function(i,j,n,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;n=$.extend({ids:a.fullResults||20,offset:0},n);k.search(i,function(u,x){if(!u.full||u.full==latestRequestTimestamp)j&&j(x)},n,p)}};var PickyController=function(a){var b=new PickyView(this,a),k=a.backends,i=a.beforeInsert||function(){},j=a.before||function(){},n=a.success||function(){},p=a.after||function(){},u=a.liveRendered||false,x=a.liveSearchInterval||180,s,v=function(d){return(d=d&&d.match(/q=([^&]+)/))&&decodeURIComponent(d[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=v;var z=function(){var d=window.History&&window.History.getState();return v(d&&d.url)};this.lastFullQuery=z;var e=function(d,q,f,y){var w=
+j(q,y);if(w!=undefined)q=w;s=[d,q,f,y];w=q;if(w!=z()){w=w==""?"":"?q="+escape(w).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,w)}if(q=="")b.reset();else(d=k[d])&&d.search(q,f,y)};this.resend=function(){s&&e.apply(this,s)};var c=function(d,q){d=n(d,q)||d;b.fullResultsCallback(d);p(d,q)},g=function(d,q){clearInterval(m);e("full",d,c,q||{})};a=function(d,q){d=n(d,q)||d;b.liveResultsCallback(d);p(d,q)};var o=u?c:a,m,h=function(){var d=
+b.text();e("live",d,o,{});clearInterval(m)};m=setInterval(h,x);clearInterval(m);var r=function(d,q,f){var y=i(d);if(y!=undefined)d=y;b.insert(d);f&&g(d,q)};this.insert=r;this.clearButtonClicked=function(){clearInterval(m)};this.searchTextCleared=function(){clearInterval(m)};this.searchTextEntered=function(d,q){if($.inArray(q.keyCode,[0,8,13,32,46,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(q.keyCode==13)g(d);else{clearInterval(m);
+m=setInterval(h,x)}};this.searchButtonClicked=function(d){g(d)};this.allocationChosen=function(d){g(d)};this.addinationClicked=function(d,q){g(d,{offset:q.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();d=v(d.url);d!=undefined&&d!=(s&&s.length>1&&s[1])&&r(d,{},true)})};var PickyI18n={},PickyClient=function(a){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en";a.locale=a.locale||PickyI18n.locale;a.qualifiers=a.qualifiers||{};a.explanations=a.explanations||{};a.choices=a.choices||{};a.explanation_delimiters={ch:"und",de:"und",en:"and",fr:"et",it:"e"};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};
b=a.enclosingSelector||"#picky";a.input=$(a.inputSelector||b+" input.query");a.reset=$(a.resetSelector||b+" div.reset");a.button=$(a.buttonSelector||b+" input.search_button");a.counter=$(a.counterSelector||b+" div.status");a.dashboard=$(a.dashboardSelector||b+" .dashboard");a.results=$(a.resultsSelector||b+" div.results");a.noResults=$(a.noResultsSelector||b+" .no_results");a.moreSelector=a.moreSelector||b+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||b+" .allocations");
a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.maxSuggestions=a.maxSuggestions||3;a.results=$(a.resultsSelector||b+" div.results");a.resultsDivider=a.resultsDivider||"";a.nonPartial=a.nonPartial||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var k=a.controller&&new a.controller(a)||new PickyController(a);var i=this.insert=function(j,n,p){k.insert(j,n||{},p||true)};this.resend=k.resend;
this.insertFromURL=function(j){if(j)i(j);else(j=k.lastFullQuery())&&i(j)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(k){var i=k.total,j,n=k.renderedAmount();j=k.offset+n;n=j+n;k=k.total;if(k<n)n=k;j={offset:j,start:j+1,end:n};if(j.offset<i){i=$("<div class='addination'>"+t("results.addination.more")+"</div>");i.bind("click",{offset:j.offset},a.addinationClicked);return i}else return""}};var PickyResultsRenderer=function(a,b){var k=b.locale,i=b.explanations||{},j=b.explanation_delimiters||{},n=b.resultsDivider,p=b.wrapResults,u=b.nonPartial,x=function(c){var g=c[c.length-1];if(g===undefined)return[];c=c.slice(0,c.length-1);if(c==[])c=[c];if(!u.include(g[0]))if(g[1].match(/[^\*~]$/))g[1]+="*";c.push(g);return c};this.asteriskifyLastToken=x;var s=function(c){for(var g=i[k]||{},o=[],m,h=0,r=c.length;h<r;h++){m=c[h];var d=m[0];d=g[d]||d;o.push([d,m[1]])}return o};this.explainCategory=
-s;var w=function(c,g){return[c.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0\,]+)/,"<strong>$1</strong>"),g].join(" ")};this.strongify=w;var y=function(c,g){var o=j[k],m="",h=[],r=[];s(x(g)).each(function(d,q){var f=q[0],v=q[1];v=v.replace(/[\w,]+:(.+)/,"$1");if(m==""||f==m){h.push(v);m=f}else{var z=w(m,h.join(" "));h=[];h.push(v);m=f;r.push(z)}});r.push(w(m,h.join(" ")));r=r.join(" "+o+" ");return r='<span class="explanation">'+c+" "+r+"</span>"};this.explain=y;var e=function(c,
-g){var o='<div class="header">';o+=y(g.type,g.combination);if(c.offset>0)o+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';o+="</div>";return o};this.renderHeader=e;this.render=function(c,g){g.allocations.each(function(o,m){if(m.entries.length>0){c.append(e(g,m)).append(m.entries.join(n));c.children("li").wrapAll(p)}});c.append(a.render(g))}};function AllocationRenderer(a){function b(e){var c={},g={},o={},m=[],h;h=0;for(l=e.length;h<l;h++){var r=e[h][0];if(r in c){c[r].push(e[h][1]);g[r].push(e[h][2]);m.push(h)}else{c[r]=[e[h][1]];g[r]=[e[h][2]];o[h]=r}}for(h in o){e[h][1]=c[o[h]];e[h][2]=g[o[h]]}for(h=m.length-1;h>=0;h--)e.remove(m[h]);return e}function k(e){e.map(function(c){return"%"+(c+1)+"$s"});return e.join(" ")}function i(e){if(e.length==0)return"";e=b(e);e.sort(function(d,q){return d[0]<q[0]?-1:1});for(var c=[],g=0,o=e.length;g<
-o;g++)c.push(e[g][0]);var m=c.length==1,h=w[c.join(",")];if(h===undefined)h=w[c]=k(c);if(typeof h==="string"){w[c]={format:h,ignoreSingle:true};h=w[c]}var r=h.format;e.each(function(d,q){var f=q[0],v=q[2];h.filter&&v.map(function(z,A){return h.filter(A)});if(m&&!(h&&h.ignoreSingle)){f=x[f]||f;return r=v.join("&nbsp;")+"&nbsp;("+f+")"}v.map(function(z,A){return A.replace(/[\w,]+:(.+)/,"$1")});r=r.replace(RegExp("%"+(d+1)+"\\$s","g"),v.join("&nbsp;"))});return r}function j(e){for(var c=[],g=0,o=s.length;g<
-o;g++)c.push([]);c.push([]);g=0;for(o=e.length;g<o;g++){for(var m=e[g],h=m[0],r=false,d=0,q=s.length;d<q;d++)if(s[d].include(h)){c[d].push(m);r=true;break}r||c[c.length-1].push(m)}var f;for(e=c.length-1;e>=0;e--){f=c[e];if(f.length>0)break}f=f[f.length-1];y.include(f[0])||(f[1]=f[1].valueOf()+"...");return c}function n(e){var c=[];j(e).each(function(g,o){var m=i(o);m&&c.push(m)});return c.join(" ")}var p=a.locale,u=a.qualifiers&&a.qualifiers[p]||{},x=a.explanations&&a.explanations[p]||{},s=a.groups||
-[],w=a.choices&&a.choices[p]||{},y=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=k;this.rendered=i;this.groupify=j;this.querify=function(e){var c=[],g,o,m;for(m in e){g=e[m][0];g=u[g]||g;o=(o=e[m][1])||"";o=o.charAt(o.length-1)=="*"?"*":"";c[m]=g+":"+e[m][2]+o}return c.join(" ")};this.suggestify=n;this.render=function(e){return n(e.combination)}};var PickyAllocationsCloud=function(a,b){var k=b.allocations,i=b.shownAllocations,j=b.showMoreAllocations,n=b.hiddenAllocations,p=b.maxSuggestions,u=function(){k.hide()},x=function(e){u();a.allocationChosen(e)},s=new AllocationRenderer(b),w=function(e){var c=[];e.each(function(g,o){var m=s.querify(o.combination),h=s.render(o);h=$('<li><div class="text">'+h+'</div><div class="count">'+o.count+"</div></li>");h.bind("click",{query:m},x);c.push(h)});return c},y=function(e){if(e.length==0)return k.hide();
-i.empty();j.hide();n.empty().hide();if(e.length>p){$.each(e.slice(0,p-1),function(c,g){i.append(g)});$.each(e.slice(p-1),function(c,g){n.append(g)});j.show()}else $.each(e,function(c,g){i.append(g)});return k.show()};j.click(function(){j.hide();n.show()});this.hide=u;this.show=function(e){y(w(e.allocations));k.show()}};
+s;var v=function(c,g){return[c.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0\,]+)/,"<strong>$1</strong>"),g].join(" ")};this.strongify=v;var z=function(c,g){var o=j[k],m="",h=[],r=[];s(x(g)).each(function(d,q){var f=q[0],y=q[1];y=y.replace(/[\w,]+:(.+)/,"$1");if(m==""||f==m){h.push(y);m=f}else{var w=v(m,h.join(" "));h=[];h.push(y);m=f;r.push(w)}});r.push(v(m,h.join(" ")));r=r.join(" "+o+" ");return r='<span class="explanation">'+c+" "+r+"</span>"};this.explain=z;var e=function(c,
+g){var o='<div class="header">';o+=z(g.type,g.combination);if(c.offset>0)o+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';o+="</div>";return o};this.renderHeader=e;this.render=function(c,g){g.allocations.each(function(o,m){if(m.entries.length>0){c.append(e(g,m)).append(m.entries.join(n));c.children("li").wrapAll(p)}});c.append(a.render(g))}};function AllocationRenderer(a){function b(e){var c={},g={},o={},m=[],h;h=0;for(l=e.length;h<l;h++){var r=e[h][0];if(r in c){c[r].push(e[h][1]);g[r].push(e[h][2]);m.push(h)}else{c[r]=[e[h][1]];g[r]=[e[h][2]];o[h]=r}}for(h in o){e[h][1]=c[o[h]];e[h][2]=g[o[h]]}for(h=m.length-1;h>=0;h--)e.remove(m[h]);return e}function k(e){e.map(function(c){return"%"+(c+1)+"$s"});return e.join(" ")}function i(e){if(e.length==0)return"";e=b(e);e.sort(function(d,q){return d[0]<q[0]?-1:1});for(var c=[],g=0,o=e.length;g<
+o;g++)c.push(e[g][0]);var m=c.length==1,h=v[c.join(",")];if(h===undefined)h=v[c]=k(c);if(typeof h==="string"){v[c]={format:h,ignoreSingle:true};h=v[c]}var r=h.format;e.each(function(d,q){var f=q[0],y=q[1],w=q[2];w.map(function(B,A){var C=y[B];if(C.charAt(C.length-1)=="*")A+="...";return A});h.filter&&w.map(function(B,A){return h.filter(A)});if(m&&!(h&&h.ignoreSingle)){f=x[f]||f;return r=w.join("&nbsp;")+"&nbsp;("+f+")"}w.map(function(B,A){return A.replace(/[\w,]+:(.+)/,"$1")});r=r.replace(RegExp("%"+
+(d+1)+"\\$s","g"),w.join("&nbsp;"))});return r}function j(e){for(var c=[],g=0,o=s.length;g<o;g++)c.push([]);c.push([]);g=0;for(o=e.length;g<o;g++){for(var m=e[g],h=m[0],r=false,d=0,q=s.length;d<q;d++)if(s[d].include(h)){c[d].push(m);r=true;break}r||c[c.length-1].push(m)}var f;for(e=c.length-1;e>=0;e--){f=c[e];if(f.length>0)break}f=f[f.length-1];z.include(f[0])||(f[1]=f[1].valueOf()+"*");return c}function n(e){var c=[];j(e).each(function(g,o){var m=i(o);m&&c.push(m)});return c.join(" ")}var p=a.locale,
+u=a.qualifiers&&a.qualifiers[p]||{},x=a.explanations&&a.explanations[p]||{},s=a.groups||[],v=a.choices&&a.choices[p]||{},z=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=k;this.rendered=i;this.groupify=j;this.querify=function(e){var c=[],g,o,m;for(m in e){g=e[m][0];g=u[g]||g;o=(o=e[m][1])||"";o=o.charAt(o.length-1)=="*"?"*":"";c[m]=g+":"+e[m][2]+o}return c.join(" ")};this.suggestify=n;this.render=function(e){return n(e.combination)}};var PickyAllocationsCloud=function(a,b){var k=b.allocations,i=b.shownAllocations,j=b.showMoreAllocations,n=b.hiddenAllocations,p=b.maxSuggestions,u=function(){k.hide()},x=function(e){u();a.allocationChosen(e)},s=new AllocationRenderer(b),v=function(e){var c=[];e.each(function(g,o){var m=s.querify(o.combination),h=s.render(o);h=$('<li><div class="text">'+h+'</div><div class="count">'+o.count+"</div></li>");h.bind("click",{query:m},x);c.push(h)});return c},z=function(e){if(e.length==0)return k.hide();
+i.empty();j.hide();n.empty().hide();if(e.length>p){$.each(e.slice(0,p-1),function(c,g){i.append(g)});$.each(e.slice(p-1),function(c,g){n.append(g)});j.show()}else $.each(e,function(c,g){i.append(g)});return k.show()};j.click(function(){j.hide();n.show()});this.hide=u;this.show=function(e){z(v(e.allocations));k.show()}};
Please sign in to comment.
Something went wrong with that request. Please try again.