Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

! resend()

  • Loading branch information...
commit 1822a0f39909d238f070ce34a87e5b5e9c9227d9 1 parent 3754e5f
@floere authored
View
30 client/javascripts/picky.min.js
@@ -1,18 +1,18 @@
Array.prototype.index=function(a){for(var c=0,g=this.length;c<g;c++)if(this[c]==a)return c;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 c=0,g=this.length;c<g;c++)a(c,this[c]);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 c=PickyI18n.locale||
-"en",g=a.split(".").concat(c),f=dictionary,e=0,k=g.length;e<k;e++){f=f[g[e]];if(f==undefined){f="Translation missing: "+a+"."+c;break}}return f};function Allocation(a,c,g,f,e,k){var n=this;this.type=a;this.weight=c;this.count=g;this.combination=f;this.ids=e||[];this.entries=this.rendered=k||[];this.isType=function(r){return r==n.type}}function Allocations(a){this.allocations=[];for(var c=0,g=a.length;c<g;c++){var f=a[c];this.allocations.push(new Allocation(f[0],f[1],f[2],f[3],f[4],f[5]))}this.length=this.allocations.length;this.each=function(e){return this.allocations.each(e)}}
-function PickyData(a){var c=a.total,g=a.duration,f=a.offset,e=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=g;this.offset=f;this.allocations=e;this.renderedAmount=function(){var k=0;e.each(function(n,r){k+=r.rendered.length});return k};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var g=c.showResultsLimit||10,f=c.input,e=c.reset,k=c.button,n=c.counter,r=c.dashboard,w=c.moreSelector,s=c.results,i=c.noResults,p=new PickyAddination(this,s),q=new PickyAllocationsCloud(this,c),b=new PickyResultsRenderer(p,c),d=function(){e.fadeTo(166,1)},h=function(){q.hide();s.empty();i.hide()},m=function(j){f.val(j);e.fadeTo(166,0);x("empty");n.empty();h()},o=function(){return f.val()};this.text=o;var u=function(j){n.text(j);j>0&&j<=5&&n.fadeTo("fast",0.5).fadeTo("fast",
-1)},v=function(j){if(j.isEmpty())return"none";if(j.total>g&&j.allocations.length>1)return"support";return"ok"},x=function(j){r.attr("class","dashboard "+j)};this.insert=function(j){f.val(j);f.select()};this.fullResultsCallback=function(j){x(v(j));if(j.isEmpty()){h();u(0);i.show();d()}else if(j.total>g&&j.allocations.length>1){h();d();q.show(j);u(j.total)}else if(j.offset==0){h();u(j.total);b.render(j);s.show();d();f.focus()}else{var y=$(w).position().top;p.remove();b.render(j);$("body").animate({scrollTop:y-
-12},500)}};this.liveResultsCallback=function(j){x(v(j));u(j.total)};this.allocationChosen=function(j){j=j.data.query;f.val(j);a.allocationChosen(j)};this.addinationClicked=function(j){a.addinationClicked(o(),j)};(function(){f.keyup(function(j){if(o()==""){m();a.searchTextCleared()}else{a.searchTextEntered(o(),j);d()}});n.click(function(){o()==""||a.searchButtonClicked(o())});k.click(function(){o()==""||a.searchButtonClicked(o())});e.click(function(){m("");a.clearButtonClicked();f.focus()})})();f.focus()};var PickyBackend=function(a){var c=function(g,f,e){var k=e||{};k=$.extend({query:g},e);$.getJSON(a,k,function(n){f&&f(new PickyData(n))})};this.search=function(g,f,e,k){c(g,function(n){f&&f(k,n)},e)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),g=new PickyBackend(c);this.search=function(f,e,k,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;k=$.extend({ids:a.liveResults||0,offset:0},k);g.search(f,function(r,w){if(!r.live||r.live==latestRequestTimestamp)e&&
-e(w)},k,n)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),g=new PickyBackend(c);this.search=function(f,e,k,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;k=$.extend({ids:a.fullResults||20,offset:0},k);g.search(f,function(r,w){if(!r.full||r.full==latestRequestTimestamp)e&&e(w)},k,n)}};var PickyController=function(a){var c=new PickyView(this,a),g=a.backends,f=a.before||function(){},e=a.success||function(){},k=a.after||function(){},n=function(b){return(b=b&&b.match(/q=([^&]+)/))&&unescape(b[1]||"")};this.extractQuery=n;var r=function(){var b=window.History&&window.History.getState();return n(b&&b.url)};this.lastQuery=r;var w=function(b,d){b=e(b,d)||b;c.liveResultsCallback(b);k(b,d)},s,i=function(){var b=c.text(),d={};b=f(b,d)||b;var h=g.live;h&&h.search(b,w,d);clearInterval(s)};
-s=setInterval(i,180);clearInterval(s);var p=function(b,d){b=e(b,d)||b;c.fullResultsCallback(b);k(b,d)},q=function(b,d){var h=d||{};clearInterval(s);if(b!=r()){var m="?q="+escape(b).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}b=f(b,h)||b;(m=g.full)&&m.search(b,p,h)};this.insert=function(b,d,h){c.insert(b);h&&q(b,d)};this.clearButtonClicked=function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)};
-this.searchTextEntered=function(b,d){if($.inArray(d.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(d.keyCode==13)q(b);else{clearInterval(s);s=setInterval(i,180)}};this.searchButtonClicked=function(b){q(b)};this.allocationChosen=function(b){q(b)};this.addinationClicked=function(b,d){q(b,{offset:d.data.offset})}};var Localization={},PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
+"en",g=a.split(".").concat(c),e=dictionary,h=0,f=g.length;h<f;h++){e=e[g[h]];if(e==undefined){e="Translation missing: "+a+"."+c;break}}return e};function Allocation(a,c,g,e,h,f){var n=this;this.type=a;this.weight=c;this.count=g;this.combination=e;this.ids=h||[];this.entries=this.rendered=f||[];this.isType=function(r){return r==n.type}}function Allocations(a){this.allocations=[];for(var c=0,g=a.length;c<g;c++){var e=a[c];this.allocations.push(new Allocation(e[0],e[1],e[2],e[3],e[4],e[5]))}this.length=this.allocations.length;this.each=function(h){return this.allocations.each(h)}}
+function PickyData(a){var c=a.total,g=a.duration,e=a.offset,h=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=g;this.offset=e;this.allocations=h;this.renderedAmount=function(){var f=0;h.each(function(n,r){f+=r.rendered.length});return f};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var g=c.showResultsLimit||10,e=c.input,h=c.reset,f=c.button,n=c.counter,r=c.dashboard,w=c.moreSelector,s=c.results,j=c.noResults,p=new PickyAddination(this,s),q=new PickyAllocationsCloud(this,c),b=new PickyResultsRenderer(p,c),d=function(){h.fadeTo(166,1)},i=function(){q.hide();s.empty();j.hide()},m=function(k){e.val(k);h.fadeTo(166,0);x("empty");n.empty();i()},o=function(){return e.val()};this.text=o;var u=function(k){n.text(k);k>0&&k<=5&&n.fadeTo("fast",0.5).fadeTo("fast",
+1)},v=function(k){if(k.isEmpty())return"none";if(k.total>g&&k.allocations.length>1)return"support";return"ok"},x=function(k){r.attr("class","dashboard "+k)};this.insert=function(k){e.val(k);e.select()};this.fullResultsCallback=function(k){x(v(k));if(k.isEmpty()){i();u(0);j.show();d()}else if(k.total>g&&k.allocations.length>1){i();d();q.show(k);u(k.total)}else if(k.offset==0){i();u(k.total);b.render(k);s.show();d();e.focus()}else{var y=$(w).position().top;p.remove();b.render(k);$("body").animate({scrollTop:y-
+12},500)}};this.liveResultsCallback=function(k){x(v(k));u(k.total)};this.allocationChosen=function(k){k=k.data.query;e.val(k);a.allocationChosen(k)};this.addinationClicked=function(k){a.addinationClicked(o(),k)};(function(){e.keyup(function(k){if(o()==""){m();a.searchTextCleared()}else{a.searchTextEntered(o(),k);d()}});n.click(function(){o()==""||a.searchButtonClicked(o())});f.click(function(){o()==""||a.searchButtonClicked(o())});h.click(function(){m("");a.clearButtonClicked();e.focus()})})();e.focus()};var PickyBackend=function(a){var c=function(g,e,h){var f=h||{};f=$.extend({query:g},h);$.getJSON(a,f,function(n){e&&e(new PickyData(n))})};this.search=function(g,e,h,f){c(g,function(n){e&&e(f,n)},h)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),g=new PickyBackend(c);this.search=function(e,h,f,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;f=$.extend({ids:a.liveResults||0,offset:0},f);g.search(e,function(r,w){if(!r.live||r.live==latestRequestTimestamp)h&&
+h(w)},f,n)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),g=new PickyBackend(c);this.search=function(e,h,f,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;f=$.extend({ids:a.fullResults||20,offset:0},f);g.search(e,function(r,w){if(!r.full||r.full==latestRequestTimestamp)h&&h(w)},f,n)}};var PickyController=function(a){var c=new PickyView(this,a),g=a.backends,e=a.before||function(){},h=a.success||function(){},f=a.after||function(){},n=function(b){return(b=b&&b.match(/q=([^&]+)/))&&unescape(b[1]||"")};this.extractQuery=n;var r=function(){var b=window.History&&window.History.getState();return n(b&&b.url)};this.lastQuery=r;var w=function(b,d){b=h(b,d)||b;console.log(b.renderedAmount());b.renderedAmount()>0?c.fullResultsCallback(b):c.liveResultsCallback(b);f(b,d)},s,j=function(){var b=
+c.text(),d={};b=e(b,d)||b;var i=g.live;i&&i.search(b,w,d);clearInterval(s)};s=setInterval(j,180);clearInterval(s);var p=function(b,d){b=h(b,d)||b;c.fullResultsCallback(b);f(b,d)},q=function(b,d){var i=d||{};clearInterval(s);if(b!=r()){var m="?q="+escape(b).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}b=e(b,i)||b;(m=g.full)&&m.search(b,p,i)};this.insert=function(b,d,i){c.insert(b);i&&q(b,d)};this.clearButtonClicked=
+function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)};this.searchTextEntered=function(b,d){if($.inArray(d.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(d.keyCode==13)q(b);else{clearInterval(s);s=setInterval(j,180)}};this.searchButtonClicked=function(b){q(b)};this.allocationChosen=function(b){q(b)};this.addinationClicked=function(b,d){q(b,{offset:d.data.offset})}};var Localization={},PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
var PickyClient=function(a){Localization.qualifiers=a.qualifiers||{};Localization.explanations=a.explanations||{};Localization.choices=a.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var c=a.backends;if(c){c.live||alert("Both a full and live backend must be provided.");c.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};c=a.enclosingSelector||"#picky";a.input=$(a.inputSelector||
c+" input.query");a.reset=$(a.resetSelector||c+" div.reset");a.button=$(a.buttonSelector||c+" input.search_button");a.counter=$(a.counterSelector||c+" div.status");a.dashboard=$(a.dashboardSelector||c+" .dashboard");a.results=$(a.resultsSelector||c+" div.results");a.noResults=$(a.noResultsSelector||c+" .no_results");a.moreSelector=a.moreSelector||c+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||c+" .allocations");a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=
-a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.results=$(a.resultsSelector||c+" div.results");a.noAsterisks=a.noAsterisks||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var g=a.controller&&new a.controller(a)||new PickyController(a);var f=this.insert=function(e,k,n){g.insert(e,k||{},n||true)};this.insertFromURL=function(e){e&&e!=""?f(e):resend()};this.resend=function(){var e=g.lastQuery();e&&f(e)};window.History&&window.History.Adapter.bind(window,"statechange",
-function(){var e=window.History.getState();(e=g.extractQuery(e.url))&&f(e)})};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(g){var f=g.total,e,k=g.renderedAmount();e=g.offset+k;k=e+k;g=g.total;if(g<k)k=g;e={offset:e,start:e+1,end:k};if(e.offset<f){f=$("<div class='addination'>"+t("results.addination.more")+"</div>");f.bind("click",{offset:e.offset},a.addinationClicked);return f}else return""}};var PickyResultsRenderer=function(a,c){var g=c.results,f=c.wrapResults,e=c.noAsterisks,k=function(i){var p=i[i.length-1];i=i.slice(0,i.length-1);if(i==[])i=[i];if(!e.include(p[0]))if(p[1].match(/[^\*~]$/))p[1]+="*";i.push(p);return i},n=function(i){for(var p=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},q=[],b,d=0,h=i.length;d<h;d++){b=i[d];var m=b[0];m=p[m]||m;q.push([m,b[1]])}return q},r=function(i,p){return[i.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
-"<strong>$1</strong>"),p].join(" ")},w=function(i,p){var q=Localization.explanation_delimiters[PickyI18n.locale],b=n(k(p)),d="",h=[];b=$.map(b,function(m){var o=m[0];m=m[1];if(d==""||o==d){m=m.replace(/[\w,]+:(.+)/,"$1");h.push(m);d=o}else{var u=r(d,h.join(" "));h=[];h.push(m);d=o;return u}});b.push(r(d,h.join(" ")));b=b.join(" "+q+" ");return'<span class="explanation">'+i+" "+b+"</span>"},s=function(i,p){var q='<div class="header">';q+=w(p.type,p.combination);if(i.offset>0)q+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
-return q};this.render=function(i){i.allocations.each(function(p,q){if(q.entries.length>0){g.append(s(i,q)).append(q.entries.join(""));g.children("li").wrapAll(f)}});g.append(a.render(i))}};function AllocationRenderer(a,c){function g(b){var d={},h={},m=[],o;o=0;for(l=b.length;o<l;o++){var u=b[o][0];if(u in d){d[u]=d[u]+" "+b[o][1];m.push(o)}else{d[u]=b[o][1];h[o]=u}}for(o in h)b[o][1]=d[h[o]];for(o=m.length-1;o>=0;o--)b.remove(m[o]);return b}function f(b){return $.map(b,function(d,h){return"%"+(h+1)+"$s"}).join(" ")}function e(b){if(b.length==0)return"";var d=b=g(b);d.sort(function(y,z){return y[0]<z[0]?-1:1});for(var h=[],m=0,o=d.length;m<o;m++)h.push(d[m][0]);var u=h.length==1,v=p[h]||
-(p[h]=f(h));if($.type(v)==="string"){p[h]={format:v};v=p[h]}var x=1,j=v.format;$.each(b,function(y,z){var A=z[0],B=z[2];if(v.filter)B=v.filter(B);A=s[A]||A;if(u&&!(v&&v.ignoreSingle))return j=B+"&nbsp;("+A+")";j=j.replace(RegExp("%"+x+"\\$s","g"),B);x+=1;return x});return j}function k(b){for(var d=[],h=0,m=i.length;h<m;h++)d.push([]);d.push([]);h=0;for(m=b.length;h<m;h++){for(var o=b[h],u=o[0],v=false,x=0,j=i.length;x<j;x++)if(i[x].include(u)){d[x].push(o);v=true;break}v||d[d.length-1].push(o)}var y;
-for(b=d.length-1;b>=0;b--){y=d[b];if(y.length>0)break}y=y[y.length-1];q.include(y[0])||(y[1]+="...");return $.map(d,function(z){return e(z)})}function n(b){var d=[],h,m;for(m in b){h=b[m][0];h=w[h]||h;d[m]=h+":"+b[m][2]}return d.join(" ")}var r=PickyI18n.locale,w=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},i=c.groups||[],p=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var q=["street_number",
-"zipcode"];this.contract=g;this.rendered=e;this.groupify=k;this.querify=n;this.render=function(b){var d=b.combination,h=b.count;b=n(d);d=k(d).join(" ");d=$('<li><div class="text">'+d+'</div><div class="count">'+h+"</div></li>");d.bind("click",{query:b},a);return d}};var PickyAllocationsCloud=function(a,c){var g=c.allocations,f=c.shownAllocations,e=c.showMoreAllocations,k=c.hiddenAllocations,n=function(){g.hide()},r=new AllocationRenderer(function(i){n();a.allocationChosen(i)},c),w=function(i){var p=[];i.each(function(q,b){p.push(r.render(b))});return p},s=function(i){if(i.length==0)return g.hide();f.empty();e.hide();k.empty().hide();if(i.length>3){$.each(i.slice(0,2),function(p,q){f.append(q)});$.each(i.slice(2),function(p,q){k.append(q)});e.show()}else $.each(i,
-function(p,q){f.append(q)});return g.show()};e.click(function(){e.hide();k.show()});this.hide=n;this.show=function(i){s(w(i.allocations));g.show()}};
+a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.results=$(a.resultsSelector||c+" div.results");a.noAsterisks=a.noAsterisks||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var g=a.controller&&new a.controller(a)||new PickyController(a);var e=this.insert=function(f,n,r){g.insert(f,n||{},r||true)},h=function(){var f=g.lastQuery();f&&e(f)};this.resend=h;this.insertFromURL=function(f){f&&f!=""?e(f):h()};window.History&&window.History.Adapter.bind(window,"statechange",
+function(){var f=window.History.getState();(f=g.extractQuery(f.url))&&e(f)})};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(g){var e=g.total,h,f=g.renderedAmount();h=g.offset+f;f=h+f;g=g.total;if(g<f)f=g;h={offset:h,start:h+1,end:f};if(h.offset<e){e=$("<div class='addination'>"+t("results.addination.more")+"</div>");e.bind("click",{offset:h.offset},a.addinationClicked);return e}else return""}};var PickyResultsRenderer=function(a,c){var g=c.results,e=c.wrapResults,h=c.noAsterisks,f=function(j){var p=j[j.length-1];j=j.slice(0,j.length-1);if(j==[])j=[j];if(!h.include(p[0]))if(p[1].match(/[^\*~]$/))p[1]+="*";j.push(p);return j},n=function(j){for(var p=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},q=[],b,d=0,i=j.length;d<i;d++){b=j[d];var m=b[0];m=p[m]||m;q.push([m,b[1]])}return q},r=function(j,p){return[j.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
+"<strong>$1</strong>"),p].join(" ")},w=function(j,p){var q=Localization.explanation_delimiters[PickyI18n.locale],b=n(f(p)),d="",i=[];b=$.map(b,function(m){var o=m[0];m=m[1];if(d==""||o==d){m=m.replace(/[\w,]+:(.+)/,"$1");i.push(m);d=o}else{var u=r(d,i.join(" "));i=[];i.push(m);d=o;return u}});b.push(r(d,i.join(" ")));b=b.join(" "+q+" ");return'<span class="explanation">'+j+" "+b+"</span>"},s=function(j,p){var q='<div class="header">';q+=w(p.type,p.combination);if(j.offset>0)q+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
+return q};this.render=function(j){j.allocations.each(function(p,q){if(q.entries.length>0){g.append(s(j,q)).append(q.entries.join(""));g.children("li").wrapAll(e)}});g.append(a.render(j))}};function AllocationRenderer(a,c){function g(b){var d={},i={},m=[],o;o=0;for(l=b.length;o<l;o++){var u=b[o][0];if(u in d){d[u]=d[u]+" "+b[o][1];m.push(o)}else{d[u]=b[o][1];i[o]=u}}for(o in i)b[o][1]=d[i[o]];for(o=m.length-1;o>=0;o--)b.remove(m[o]);return b}function e(b){return $.map(b,function(d,i){return"%"+(i+1)+"$s"}).join(" ")}function h(b){if(b.length==0)return"";var d=b=g(b);d.sort(function(y,z){return y[0]<z[0]?-1:1});for(var i=[],m=0,o=d.length;m<o;m++)i.push(d[m][0]);var u=i.length==1,v=p[i]||
+(p[i]=e(i));if($.type(v)==="string"){p[i]={format:v};v=p[i]}var x=1,k=v.format;$.each(b,function(y,z){var A=z[0],B=z[2];if(v.filter)B=v.filter(B);A=s[A]||A;if(u&&!(v&&v.ignoreSingle))return k=B+"&nbsp;("+A+")";k=k.replace(RegExp("%"+x+"\\$s","g"),B);x+=1;return x});return k}function f(b){for(var d=[],i=0,m=j.length;i<m;i++)d.push([]);d.push([]);i=0;for(m=b.length;i<m;i++){for(var o=b[i],u=o[0],v=false,x=0,k=j.length;x<k;x++)if(j[x].include(u)){d[x].push(o);v=true;break}v||d[d.length-1].push(o)}var y;
+for(b=d.length-1;b>=0;b--){y=d[b];if(y.length>0)break}y=y[y.length-1];q.include(y[0])||(y[1]+="...");return $.map(d,function(z){return h(z)})}function n(b){var d=[],i,m;for(m in b){i=b[m][0];i=w[i]||i;d[m]=i+":"+b[m][2]}return d.join(" ")}var r=PickyI18n.locale,w=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},j=c.groups||[],p=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var q=["street_number",
+"zipcode"];this.contract=g;this.rendered=h;this.groupify=f;this.querify=n;this.render=function(b){var d=b.combination,i=b.count;b=n(d);d=f(d).join(" ");d=$('<li><div class="text">'+d+'</div><div class="count">'+i+"</div></li>");d.bind("click",{query:b},a);return d}};var PickyAllocationsCloud=function(a,c){var g=c.allocations,e=c.shownAllocations,h=c.showMoreAllocations,f=c.hiddenAllocations,n=function(){g.hide()},r=new AllocationRenderer(function(j){n();a.allocationChosen(j)},c),w=function(j){var p=[];j.each(function(q,b){p.push(r.render(b))});return p},s=function(j){if(j.length==0)return g.hide();e.empty();h.hide();f.empty().hide();if(j.length>3){$.each(j.slice(0,2),function(p,q){e.append(q)});$.each(j.slice(2),function(p,q){f.append(q)});h.show()}else $.each(j,
+function(p,q){e.append(q)});return g.show()};h.click(function(){h.hide();f.show()});this.hide=n;this.show=function(j){s(w(j.allocations));g.show()}};
View
BIN  client/javascripts/picky.source.js.tar
Binary file not shown
View
21 client/javascripts/source/picky.client.js
@@ -98,6 +98,17 @@ var PickyClient = function(config) {
};
var insert = this.insert;
+ // Resends the last query text.
+ //
+ // Note: Other variables apart from the text
+ // could have changed.
+ //
+ var resend = function() {
+ var lastQuery = controller.lastQuery();
+ lastQuery && insert(lastQuery);
+ };
+ this.resend = resend;
+
// Takes a query or nothing as parameter.
//
// And runs a query with it (if $.address exists).
@@ -111,16 +122,6 @@ var PickyClient = function(config) {
}
};
- // Resends the last query text.
- //
- // Note: Other variables apart from the text
- // could have changed.
- //
- this.resend = function() {
- var lastQuery = controller.lastQuery();
- lastQuery && insert(lastQuery);
- };
-
// Bind adapter to let the back/forward button start queries.
//
if (window.History) {
View
21 client/test_project/javascripts/picky.client.js
@@ -98,6 +98,17 @@ var PickyClient = function(config) {
};
var insert = this.insert;
+ // Resends the last query text.
+ //
+ // Note: Other variables apart from the text
+ // could have changed.
+ //
+ var resend = function() {
+ var lastQuery = controller.lastQuery();
+ lastQuery && insert(lastQuery);
+ };
+ this.resend = resend;
+
// Takes a query or nothing as parameter.
//
// And runs a query with it (if $.address exists).
@@ -111,16 +122,6 @@ var PickyClient = function(config) {
}
};
- // Resends the last query text.
- //
- // Note: Other variables apart from the text
- // could have changed.
- //
- this.resend = function() {
- var lastQuery = controller.lastQuery();
- lastQuery && insert(lastQuery);
- };
-
// Bind adapter to let the back/forward button start queries.
//
if (window.History) {
View
30 generators/prototypes/client/sinatra/javascripts/picky.min.js
@@ -1,18 +1,18 @@
Array.prototype.index=function(a){for(var c=0,g=this.length;c<g;c++)if(this[c]==a)return c;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 c=0,g=this.length;c<g;c++)a(c,this[c]);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 c=PickyI18n.locale||
-"en",g=a.split(".").concat(c),f=dictionary,e=0,k=g.length;e<k;e++){f=f[g[e]];if(f==undefined){f="Translation missing: "+a+"."+c;break}}return f};function Allocation(a,c,g,f,e,k){var n=this;this.type=a;this.weight=c;this.count=g;this.combination=f;this.ids=e||[];this.entries=this.rendered=k||[];this.isType=function(r){return r==n.type}}function Allocations(a){this.allocations=[];for(var c=0,g=a.length;c<g;c++){var f=a[c];this.allocations.push(new Allocation(f[0],f[1],f[2],f[3],f[4],f[5]))}this.length=this.allocations.length;this.each=function(e){return this.allocations.each(e)}}
-function PickyData(a){var c=a.total,g=a.duration,f=a.offset,e=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=g;this.offset=f;this.allocations=e;this.renderedAmount=function(){var k=0;e.each(function(n,r){k+=r.rendered.length});return k};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var g=c.showResultsLimit||10,f=c.input,e=c.reset,k=c.button,n=c.counter,r=c.dashboard,w=c.moreSelector,s=c.results,i=c.noResults,p=new PickyAddination(this,s),q=new PickyAllocationsCloud(this,c),b=new PickyResultsRenderer(p,c),d=function(){e.fadeTo(166,1)},h=function(){q.hide();s.empty();i.hide()},m=function(j){f.val(j);e.fadeTo(166,0);x("empty");n.empty();h()},o=function(){return f.val()};this.text=o;var u=function(j){n.text(j);j>0&&j<=5&&n.fadeTo("fast",0.5).fadeTo("fast",
-1)},v=function(j){if(j.isEmpty())return"none";if(j.total>g&&j.allocations.length>1)return"support";return"ok"},x=function(j){r.attr("class","dashboard "+j)};this.insert=function(j){f.val(j);f.select()};this.fullResultsCallback=function(j){x(v(j));if(j.isEmpty()){h();u(0);i.show();d()}else if(j.total>g&&j.allocations.length>1){h();d();q.show(j);u(j.total)}else if(j.offset==0){h();u(j.total);b.render(j);s.show();d();f.focus()}else{var y=$(w).position().top;p.remove();b.render(j);$("body").animate({scrollTop:y-
-12},500)}};this.liveResultsCallback=function(j){x(v(j));u(j.total)};this.allocationChosen=function(j){j=j.data.query;f.val(j);a.allocationChosen(j)};this.addinationClicked=function(j){a.addinationClicked(o(),j)};(function(){f.keyup(function(j){if(o()==""){m();a.searchTextCleared()}else{a.searchTextEntered(o(),j);d()}});n.click(function(){o()==""||a.searchButtonClicked(o())});k.click(function(){o()==""||a.searchButtonClicked(o())});e.click(function(){m("");a.clearButtonClicked();f.focus()})})();f.focus()};var PickyBackend=function(a){var c=function(g,f,e){var k=e||{};k=$.extend({query:g},e);$.getJSON(a,k,function(n){f&&f(new PickyData(n))})};this.search=function(g,f,e,k){c(g,function(n){f&&f(k,n)},e)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),g=new PickyBackend(c);this.search=function(f,e,k,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;k=$.extend({ids:a.liveResults||0,offset:0},k);g.search(f,function(r,w){if(!r.live||r.live==latestRequestTimestamp)e&&
-e(w)},k,n)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),g=new PickyBackend(c);this.search=function(f,e,k,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;k=$.extend({ids:a.fullResults||20,offset:0},k);g.search(f,function(r,w){if(!r.full||r.full==latestRequestTimestamp)e&&e(w)},k,n)}};var PickyController=function(a){var c=new PickyView(this,a),g=a.backends,f=a.before||function(){},e=a.success||function(){},k=a.after||function(){},n=function(b){return(b=b&&b.match(/q=([^&]+)/))&&unescape(b[1]||"")};this.extractQuery=n;var r=function(){var b=window.History&&window.History.getState();return n(b&&b.url)};this.lastQuery=r;var w=function(b,d){b=e(b,d)||b;c.liveResultsCallback(b);k(b,d)},s,i=function(){var b=c.text(),d={};b=f(b,d)||b;var h=g.live;h&&h.search(b,w,d);clearInterval(s)};
-s=setInterval(i,180);clearInterval(s);var p=function(b,d){b=e(b,d)||b;c.fullResultsCallback(b);k(b,d)},q=function(b,d){var h=d||{};clearInterval(s);if(b!=r()){var m="?q="+escape(b).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}b=f(b,h)||b;(m=g.full)&&m.search(b,p,h)};this.insert=function(b,d,h){c.insert(b);h&&q(b,d)};this.clearButtonClicked=function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)};
-this.searchTextEntered=function(b,d){if($.inArray(d.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(d.keyCode==13)q(b);else{clearInterval(s);s=setInterval(i,180)}};this.searchButtonClicked=function(b){q(b)};this.allocationChosen=function(b){q(b)};this.addinationClicked=function(b,d){q(b,{offset:d.data.offset})}};var Localization={},PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
+"en",g=a.split(".").concat(c),e=dictionary,h=0,f=g.length;h<f;h++){e=e[g[h]];if(e==undefined){e="Translation missing: "+a+"."+c;break}}return e};function Allocation(a,c,g,e,h,f){var n=this;this.type=a;this.weight=c;this.count=g;this.combination=e;this.ids=h||[];this.entries=this.rendered=f||[];this.isType=function(r){return r==n.type}}function Allocations(a){this.allocations=[];for(var c=0,g=a.length;c<g;c++){var e=a[c];this.allocations.push(new Allocation(e[0],e[1],e[2],e[3],e[4],e[5]))}this.length=this.allocations.length;this.each=function(h){return this.allocations.each(h)}}
+function PickyData(a){var c=a.total,g=a.duration,e=a.offset,h=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=g;this.offset=e;this.allocations=h;this.renderedAmount=function(){var f=0;h.each(function(n,r){f+=r.rendered.length});return f};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var g=c.showResultsLimit||10,e=c.input,h=c.reset,f=c.button,n=c.counter,r=c.dashboard,w=c.moreSelector,s=c.results,j=c.noResults,p=new PickyAddination(this,s),q=new PickyAllocationsCloud(this,c),b=new PickyResultsRenderer(p,c),d=function(){h.fadeTo(166,1)},i=function(){q.hide();s.empty();j.hide()},m=function(k){e.val(k);h.fadeTo(166,0);x("empty");n.empty();i()},o=function(){return e.val()};this.text=o;var u=function(k){n.text(k);k>0&&k<=5&&n.fadeTo("fast",0.5).fadeTo("fast",
+1)},v=function(k){if(k.isEmpty())return"none";if(k.total>g&&k.allocations.length>1)return"support";return"ok"},x=function(k){r.attr("class","dashboard "+k)};this.insert=function(k){e.val(k);e.select()};this.fullResultsCallback=function(k){x(v(k));if(k.isEmpty()){i();u(0);j.show();d()}else if(k.total>g&&k.allocations.length>1){i();d();q.show(k);u(k.total)}else if(k.offset==0){i();u(k.total);b.render(k);s.show();d();e.focus()}else{var y=$(w).position().top;p.remove();b.render(k);$("body").animate({scrollTop:y-
+12},500)}};this.liveResultsCallback=function(k){x(v(k));u(k.total)};this.allocationChosen=function(k){k=k.data.query;e.val(k);a.allocationChosen(k)};this.addinationClicked=function(k){a.addinationClicked(o(),k)};(function(){e.keyup(function(k){if(o()==""){m();a.searchTextCleared()}else{a.searchTextEntered(o(),k);d()}});n.click(function(){o()==""||a.searchButtonClicked(o())});f.click(function(){o()==""||a.searchButtonClicked(o())});h.click(function(){m("");a.clearButtonClicked();e.focus()})})();e.focus()};var PickyBackend=function(a){var c=function(g,e,h){var f=h||{};f=$.extend({query:g},h);$.getJSON(a,f,function(n){e&&e(new PickyData(n))})};this.search=function(g,e,h,f){c(g,function(n){e&&e(f,n)},h)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),g=new PickyBackend(c);this.search=function(e,h,f,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;f=$.extend({ids:a.liveResults||0,offset:0},f);g.search(e,function(r,w){if(!r.live||r.live==latestRequestTimestamp)h&&
+h(w)},f,n)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),g=new PickyBackend(c);this.search=function(e,h,f,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;f=$.extend({ids:a.fullResults||20,offset:0},f);g.search(e,function(r,w){if(!r.full||r.full==latestRequestTimestamp)h&&h(w)},f,n)}};var PickyController=function(a){var c=new PickyView(this,a),g=a.backends,e=a.before||function(){},h=a.success||function(){},f=a.after||function(){},n=function(b){return(b=b&&b.match(/q=([^&]+)/))&&unescape(b[1]||"")};this.extractQuery=n;var r=function(){var b=window.History&&window.History.getState();return n(b&&b.url)};this.lastQuery=r;var w=function(b,d){b=h(b,d)||b;console.log(b.renderedAmount());b.renderedAmount()>0?c.fullResultsCallback(b):c.liveResultsCallback(b);f(b,d)},s,j=function(){var b=
+c.text(),d={};b=e(b,d)||b;var i=g.live;i&&i.search(b,w,d);clearInterval(s)};s=setInterval(j,180);clearInterval(s);var p=function(b,d){b=h(b,d)||b;c.fullResultsCallback(b);f(b,d)},q=function(b,d){var i=d||{};clearInterval(s);if(b!=r()){var m="?q="+escape(b).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}b=e(b,i)||b;(m=g.full)&&m.search(b,p,i)};this.insert=function(b,d,i){c.insert(b);i&&q(b,d)};this.clearButtonClicked=
+function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)};this.searchTextEntered=function(b,d){if($.inArray(d.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(d.keyCode==13)q(b);else{clearInterval(s);s=setInterval(j,180)}};this.searchButtonClicked=function(b){q(b)};this.allocationChosen=function(b){q(b)};this.addinationClicked=function(b,d){q(b,{offset:d.data.offset})}};var Localization={},PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
var PickyClient=function(a){Localization.qualifiers=a.qualifiers||{};Localization.explanations=a.explanations||{};Localization.choices=a.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var c=a.backends;if(c){c.live||alert("Both a full and live backend must be provided.");c.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};c=a.enclosingSelector||"#picky";a.input=$(a.inputSelector||
c+" input.query");a.reset=$(a.resetSelector||c+" div.reset");a.button=$(a.buttonSelector||c+" input.search_button");a.counter=$(a.counterSelector||c+" div.status");a.dashboard=$(a.dashboardSelector||c+" .dashboard");a.results=$(a.resultsSelector||c+" div.results");a.noResults=$(a.noResultsSelector||c+" .no_results");a.moreSelector=a.moreSelector||c+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||c+" .allocations");a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=
-a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.results=$(a.resultsSelector||c+" div.results");a.noAsterisks=a.noAsterisks||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var g=a.controller&&new a.controller(a)||new PickyController(a);var f=this.insert=function(e,k,n){g.insert(e,k||{},n||true)};this.insertFromURL=function(e){e&&e!=""?f(e):resend()};this.resend=function(){var e=g.lastQuery();e&&f(e)};window.History&&window.History.Adapter.bind(window,"statechange",
-function(){var e=window.History.getState();(e=g.extractQuery(e.url))&&f(e)})};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(g){var f=g.total,e,k=g.renderedAmount();e=g.offset+k;k=e+k;g=g.total;if(g<k)k=g;e={offset:e,start:e+1,end:k};if(e.offset<f){f=$("<div class='addination'>"+t("results.addination.more")+"</div>");f.bind("click",{offset:e.offset},a.addinationClicked);return f}else return""}};var PickyResultsRenderer=function(a,c){var g=c.results,f=c.wrapResults,e=c.noAsterisks,k=function(i){var p=i[i.length-1];i=i.slice(0,i.length-1);if(i==[])i=[i];if(!e.include(p[0]))if(p[1].match(/[^\*~]$/))p[1]+="*";i.push(p);return i},n=function(i){for(var p=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},q=[],b,d=0,h=i.length;d<h;d++){b=i[d];var m=b[0];m=p[m]||m;q.push([m,b[1]])}return q},r=function(i,p){return[i.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
-"<strong>$1</strong>"),p].join(" ")},w=function(i,p){var q=Localization.explanation_delimiters[PickyI18n.locale],b=n(k(p)),d="",h=[];b=$.map(b,function(m){var o=m[0];m=m[1];if(d==""||o==d){m=m.replace(/[\w,]+:(.+)/,"$1");h.push(m);d=o}else{var u=r(d,h.join(" "));h=[];h.push(m);d=o;return u}});b.push(r(d,h.join(" ")));b=b.join(" "+q+" ");return'<span class="explanation">'+i+" "+b+"</span>"},s=function(i,p){var q='<div class="header">';q+=w(p.type,p.combination);if(i.offset>0)q+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
-return q};this.render=function(i){i.allocations.each(function(p,q){if(q.entries.length>0){g.append(s(i,q)).append(q.entries.join(""));g.children("li").wrapAll(f)}});g.append(a.render(i))}};function AllocationRenderer(a,c){function g(b){var d={},h={},m=[],o;o=0;for(l=b.length;o<l;o++){var u=b[o][0];if(u in d){d[u]=d[u]+" "+b[o][1];m.push(o)}else{d[u]=b[o][1];h[o]=u}}for(o in h)b[o][1]=d[h[o]];for(o=m.length-1;o>=0;o--)b.remove(m[o]);return b}function f(b){return $.map(b,function(d,h){return"%"+(h+1)+"$s"}).join(" ")}function e(b){if(b.length==0)return"";var d=b=g(b);d.sort(function(y,z){return y[0]<z[0]?-1:1});for(var h=[],m=0,o=d.length;m<o;m++)h.push(d[m][0]);var u=h.length==1,v=p[h]||
-(p[h]=f(h));if($.type(v)==="string"){p[h]={format:v};v=p[h]}var x=1,j=v.format;$.each(b,function(y,z){var A=z[0],B=z[2];if(v.filter)B=v.filter(B);A=s[A]||A;if(u&&!(v&&v.ignoreSingle))return j=B+"&nbsp;("+A+")";j=j.replace(RegExp("%"+x+"\\$s","g"),B);x+=1;return x});return j}function k(b){for(var d=[],h=0,m=i.length;h<m;h++)d.push([]);d.push([]);h=0;for(m=b.length;h<m;h++){for(var o=b[h],u=o[0],v=false,x=0,j=i.length;x<j;x++)if(i[x].include(u)){d[x].push(o);v=true;break}v||d[d.length-1].push(o)}var y;
-for(b=d.length-1;b>=0;b--){y=d[b];if(y.length>0)break}y=y[y.length-1];q.include(y[0])||(y[1]+="...");return $.map(d,function(z){return e(z)})}function n(b){var d=[],h,m;for(m in b){h=b[m][0];h=w[h]||h;d[m]=h+":"+b[m][2]}return d.join(" ")}var r=PickyI18n.locale,w=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},i=c.groups||[],p=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var q=["street_number",
-"zipcode"];this.contract=g;this.rendered=e;this.groupify=k;this.querify=n;this.render=function(b){var d=b.combination,h=b.count;b=n(d);d=k(d).join(" ");d=$('<li><div class="text">'+d+'</div><div class="count">'+h+"</div></li>");d.bind("click",{query:b},a);return d}};var PickyAllocationsCloud=function(a,c){var g=c.allocations,f=c.shownAllocations,e=c.showMoreAllocations,k=c.hiddenAllocations,n=function(){g.hide()},r=new AllocationRenderer(function(i){n();a.allocationChosen(i)},c),w=function(i){var p=[];i.each(function(q,b){p.push(r.render(b))});return p},s=function(i){if(i.length==0)return g.hide();f.empty();e.hide();k.empty().hide();if(i.length>3){$.each(i.slice(0,2),function(p,q){f.append(q)});$.each(i.slice(2),function(p,q){k.append(q)});e.show()}else $.each(i,
-function(p,q){f.append(q)});return g.show()};e.click(function(){e.hide();k.show()});this.hide=n;this.show=function(i){s(w(i.allocations));g.show()}};
+a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.results=$(a.resultsSelector||c+" div.results");a.noAsterisks=a.noAsterisks||[];a.wrapResults=a.wrapResults||'<ol class="results"></ol>';var g=a.controller&&new a.controller(a)||new PickyController(a);var e=this.insert=function(f,n,r){g.insert(f,n||{},r||true)},h=function(){var f=g.lastQuery();f&&e(f)};this.resend=h;this.insertFromURL=function(f){f&&f!=""?e(f):h()};window.History&&window.History.Adapter.bind(window,"statechange",
+function(){var f=window.History.getState();(f=g.extractQuery(f.url))&&e(f)})};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(g){var e=g.total,h,f=g.renderedAmount();h=g.offset+f;f=h+f;g=g.total;if(g<f)f=g;h={offset:h,start:h+1,end:f};if(h.offset<e){e=$("<div class='addination'>"+t("results.addination.more")+"</div>");e.bind("click",{offset:h.offset},a.addinationClicked);return e}else return""}};var PickyResultsRenderer=function(a,c){var g=c.results,e=c.wrapResults,h=c.noAsterisks,f=function(j){var p=j[j.length-1];j=j.slice(0,j.length-1);if(j==[])j=[j];if(!h.include(p[0]))if(p[1].match(/[^\*~]$/))p[1]+="*";j.push(p);return j},n=function(j){for(var p=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},q=[],b,d=0,i=j.length;d<i;d++){b=j[d];var m=b[0];m=p[m]||m;q.push([m,b[1]])}return q},r=function(j,p){return[j.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
+"<strong>$1</strong>"),p].join(" ")},w=function(j,p){var q=Localization.explanation_delimiters[PickyI18n.locale],b=n(f(p)),d="",i=[];b=$.map(b,function(m){var o=m[0];m=m[1];if(d==""||o==d){m=m.replace(/[\w,]+:(.+)/,"$1");i.push(m);d=o}else{var u=r(d,i.join(" "));i=[];i.push(m);d=o;return u}});b.push(r(d,i.join(" ")));b=b.join(" "+q+" ");return'<span class="explanation">'+j+" "+b+"</span>"},s=function(j,p){var q='<div class="header">';q+=w(p.type,p.combination);if(j.offset>0)q+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
+return q};this.render=function(j){j.allocations.each(function(p,q){if(q.entries.length>0){g.append(s(j,q)).append(q.entries.join(""));g.children("li").wrapAll(e)}});g.append(a.render(j))}};function AllocationRenderer(a,c){function g(b){var d={},i={},m=[],o;o=0;for(l=b.length;o<l;o++){var u=b[o][0];if(u in d){d[u]=d[u]+" "+b[o][1];m.push(o)}else{d[u]=b[o][1];i[o]=u}}for(o in i)b[o][1]=d[i[o]];for(o=m.length-1;o>=0;o--)b.remove(m[o]);return b}function e(b){return $.map(b,function(d,i){return"%"+(i+1)+"$s"}).join(" ")}function h(b){if(b.length==0)return"";var d=b=g(b);d.sort(function(y,z){return y[0]<z[0]?-1:1});for(var i=[],m=0,o=d.length;m<o;m++)i.push(d[m][0]);var u=i.length==1,v=p[i]||
+(p[i]=e(i));if($.type(v)==="string"){p[i]={format:v};v=p[i]}var x=1,k=v.format;$.each(b,function(y,z){var A=z[0],B=z[2];if(v.filter)B=v.filter(B);A=s[A]||A;if(u&&!(v&&v.ignoreSingle))return k=B+"&nbsp;("+A+")";k=k.replace(RegExp("%"+x+"\\$s","g"),B);x+=1;return x});return k}function f(b){for(var d=[],i=0,m=j.length;i<m;i++)d.push([]);d.push([]);i=0;for(m=b.length;i<m;i++){for(var o=b[i],u=o[0],v=false,x=0,k=j.length;x<k;x++)if(j[x].include(u)){d[x].push(o);v=true;break}v||d[d.length-1].push(o)}var y;
+for(b=d.length-1;b>=0;b--){y=d[b];if(y.length>0)break}y=y[y.length-1];q.include(y[0])||(y[1]+="...");return $.map(d,function(z){return h(z)})}function n(b){var d=[],i,m;for(m in b){i=b[m][0];i=w[i]||i;d[m]=i+":"+b[m][2]}return d.join(" ")}var r=PickyI18n.locale,w=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},j=c.groups||[],p=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var q=["street_number",
+"zipcode"];this.contract=g;this.rendered=h;this.groupify=f;this.querify=n;this.render=function(b){var d=b.combination,i=b.count;b=n(d);d=f(d).join(" ");d=$('<li><div class="text">'+d+'</div><div class="count">'+i+"</div></li>");d.bind("click",{query:b},a);return d}};var PickyAllocationsCloud=function(a,c){var g=c.allocations,e=c.shownAllocations,h=c.showMoreAllocations,f=c.hiddenAllocations,n=function(){g.hide()},r=new AllocationRenderer(function(j){n();a.allocationChosen(j)},c),w=function(j){var p=[];j.each(function(q,b){p.push(r.render(b))});return p},s=function(j){if(j.length==0)return g.hide();e.empty();h.hide();f.empty().hide();if(j.length>3){$.each(j.slice(0,2),function(p,q){e.append(q)});$.each(j.slice(2),function(p,q){f.append(q)});h.show()}else $.each(j,
+function(p,q){e.append(q)});return g.show()};h.click(function(){h.hide();f.show()});this.hide=n;this.show=function(j){s(w(j.allocations));g.show()}};
Please sign in to comment.
Something went wrong with that request. Please try again.