picky-client 4.19.2 → 4.19.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,19 @@
1
- Array.prototype.index=function(a){for(var c=0,i=this.length;c<i;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,i=this.length;c<i;c++)a(c,this[c]);return this};Array.prototype.map=function(a){for(var c=0,i=this.length;c<i;c++)this[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||
2
- "en",i=a.split(".").concat(c),g=dictionary,j=0,k=i.length;j<k;j++){g=g[i[j]];if(g==undefined){g="Translation missing: "+a+"."+c;break}}return g};function Allocation(a,c,i,g,j,k){var p=this;this.type=a;this.weight=c;this.count=i;this.combination=g;this.ids=j||[];this.entries=this.rendered=k||[];this.isType=function(r){return r==p.type}}function Allocations(a){this.allocations=[];for(var c=0,i=a.length;c<i;c++){var g=a[c];this.allocations.push(new Allocation(g[0],g[1],g[2],g[3],g[4],g[5]))}this.length=this.allocations.length;this.remove=function(j){this.allocations.splice(j,1)};this.each=function(j){this.allocations.each(j)}}
3
- function PickyData(a){var c=a.total,i=a.duration,g=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=i;this.offset=g;this.allocations=j;this.renderedAmount=function(){var k=0;j.each(function(p,r){k+=r.rendered.length});return k};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var i=c.showResultsLimit||10,g=c.input,j=c.reset,k=c.button,p=c.counter,r=c.form,w=c.moreSelector,v=c.results,s=c.noResults,y=new PickyAddination(this,v),f=new PickyAllocationsCloud(this,c),d=new PickyResultsRenderer(y,c),h=function(){j.fadeTo(166,1)},m=function(){f.hide();v.empty();s.hide()},o=function(b){g.val(b);j.fadeTo(166,0);r.attr("class","empty");p.empty();m()};this.reset=o;var e=function(){return g.val()};this.text=e;var q=function(b){p.text(b);b>0&&b<=5&&p.fadeTo("fast",
4
- 0.5).fadeTo("fast",1)},u=function(b){if(b.isEmpty())return"none";if(b.total>i&&b.allocations.length>1)return"support";return"ok"};this.insert=function(b){g.val(b);g.select()};this.fullResultsCallback=function(b){var n=u(b);r.attr("class",n);if(b.isEmpty()){m();q(0);s.show();h()}else if(b.total>i&&b.allocations.length>1){m();h();f.show(b);q(b.total)}else if(b.offset==0){m();q(b.total);d.render(v,b);v.show();h();g.focus()}else{n=$(w).position().top;y.remove();d.render(v,b);$("body").animate({scrollTop:n-
5
- 12},500)}};this.liveResultsCallback=function(b){var n=u(b);r.attr("class",n);q(b.total)};this.allocationChosen=function(b){b=b.data.query;a.insert(b);a.allocationChosen(b)};this.addinationClicked=function(b){a.addinationClicked(e(),b)};(function(){g.keyup(function(b){if(e()==""){o();a.searchTextCleared()}else h();a.searchTextEntered(e(),b)});p.click(function(){a.searchButtonClicked(e())});k.click(function(){a.searchButtonClicked(e())});j.click(function(){o();a.clearButtonClicked();g.focus()})})();
6
- g.focus()};var PickyBackend=function(a){var c=function(i,g,j){var k=j||{};k=$.extend({query:i},j);$.getJSON(a,k,function(p){g&&g(new PickyData(p))})};this.search=function(i,g,j,k){c(i,function(p){g&&g(k,p)},j)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),i=new PickyBackend(c);this.search=function(g,j,k,p){p=p||{};latestRequestTimestamp=new Date;p.live=latestRequestTimestamp;k=$.extend({ids:a.liveResults||0,offset:0},k);i.search(g,function(r,w){if(!r.live||r.live==latestRequestTimestamp)j&&
7
- j(w)},k,p)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),i=new PickyBackend(c);this.search=function(g,j,k,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;k=$.extend({ids:a.fullResults||20,offset:0},k);i.search(g,function(r,w){if(!r.full||r.full==latestRequestTimestamp)j&&j(w)},k,p)}};var PickyController=function(a){var c=new PickyView(this,a),i=a.backends,g=a.beforeInsert||function(){},j=a.before||function(){},k=a.success||function(){},p=a.after||function(){},r=a.searchOnEmpty||false,w=a.liveRendered||false,v=a.liveSearchInterval||180,s,y=function(b){return(b=b&&b.match(/q=([^&]+)/))&&decodeURIComponent(b[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=y;var f=function(){var b=window.History&&window.History.getState();return y(b&&b.url)};this.lastFullQuery=f;var d=
8
- function(b,n,A,x){var z=j(n,x);if(z!=undefined)n=z;s=[b,n,A,x];z=n;if(z!=f()){z=!r&&z==""?"":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(!r&&n=="")c.reset();else(b=i[b])&&b.search(n,A,x)};this.resend=function(){s&&d.apply(this,s)};var h=function(b,n){b=k(b,n)||b;c.fullResultsCallback(b);p(b,n)},m=function(b,n){clearInterval(e);d("full",b,h,n||{})};a=function(b,n){b=k(b,n)||b;c.liveResultsCallback(b);
9
- p(b,n)};var o=w?h:a,e,q=function(){var b=c.text();d("live",b,o,{});clearInterval(e)};e=setInterval(q,v);clearInterval(e);var u=function(b,n,A){var x=g(b);if(x!=undefined)b=x;c.insert(b);A&&m(b,n)};this.insert=u;this.clearButtonClicked=function(){clearInterval(e)};this.searchTextCleared=function(){clearInterval(e)};this.searchTextEntered=function(b,n){if($.inArray(n.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(n.keyCode==
10
- 13)m(b);else{clearInterval(e);e=setInterval(q,v)}};this.searchButtonClicked=function(b){m(b)};this.allocationChosen=function(b){m(b)};this.addinationClicked=function(b,n){m(b,{offset:n.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var b=window.History.getState();b=y(b.url);b!=undefined&&b!=(s&&s.length>1&&s[1])&&u(b,{},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 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)};
11
- c=a.enclosingSelector||".picky";var i=a.formSelector||c+" form";a.form=$(i);a.input=$(a.inputSelector||i+" input[type=search]");a.reset=$(a.resetSelector||i+" div.reset");a.button=$(a.buttonSelector||i+" input[type=button]");a.counter=$(a.counterSelector||i+" div.status");a.results=$(a.resultsSelector||c+" div.results");a.noResults=$(a.noResultsSelector||c+" div.no_results");a.moreSelector=a.moreSelector||c+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||c+" .allocations");
12
- 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||c+" div.results");a.resultsDivider=a.resultsDivider||"";a.nonPartial=a.nonPartial||[];a.wrapResults=a.wrapResults||"<ol></ol>";var g=a.controller&&new a.controller(a)||new PickyController(a);var j=this.insert=function(k,p,r){g.insert(k,p||{},r||true)};this.resend=g.resend;this.insertFromURL=
13
- function(k){if(k)j(k);else(k=g.lastFullQuery())&&j(k)}};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(i){var g=i.total,j,k=i.renderedAmount();j=i.offset+k;k=j+k;i=i.total;if(i<k)k=i;j={offset:j,start:j+1,end:k};if(j.offset<g){g=$("<div class='addination'>"+t("results.addination.more")+"</div>");g.bind("click",{offset:j.offset},a.addinationClicked);return g}else return""}};var PickyResultsRenderer=function(a,c){var i=c.locale,g=c.explanations||{},j=c.explanation_delimiters||{},k=c.resultsDivider,p=c.wrapResults,r=c.nonPartial,w=function(d){var h=d[d.length-1];if(h===undefined)return[];d=d.slice(0,d.length-1);if(d==[])d=[d];if(!r.include(h[0]))if(h[1].match(/[^\*~]$/))h[1]+="*";d.push(h);return d};this.asteriskifyLastToken=w;var v=function(d){for(var h=g[i]||{},m=[],o,e=0,q=d.length;e<q;e++){o=d[e];var u=o[0];u=h[u]||u;m.push([u,o[1]])}return m};this.explainCategory=
14
- v;var s=function(d,h){return["<strong>"+d+"</strong>",h].join(" ")};this.strongify=s;var y=function(d,h){var m=j[i],o="",e=[],q=[];v(w(h)).each(function(u,b){var n=b[0],A=b[1];A=A.replace(/[\w,]+:(.+)/,"$1");if(o==""||n==o){e.push(A);o=n}else{var x=s(o,e.join(" "));e=[];e.push(A);o=n;q.push(x)}});q.push(s(o,e.join(" ")));q=q.join(" "+m+" ");return q='<span class="explanation">'+d+" "+q+"</span>"};this.explain=y;var f=function(d,h){var m='<div class="header">';m+=y(h.type,h.combination);if(d.offset>
15
- 0)m+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';m+="</div>";return m};this.renderHeader=f;this.render=function(d,h){h.allocations.each(function(m,o){if(o.entries.length>0){d.append(f(h,o)).append(o.entries.join(k));d.children("li").wrapAll(p)}});d.append(a.render(h))}};function AllocationRenderer(a){function c(f){var d={},h={},m={},o=[],e;e=0;for(l=f.length;e<l;e++){var q=f[e][0];if(q in d){d[q].push(f[e][1]);h[q].push(f[e][2]);o.push(e)}else{d[q]=[f[e][1]];h[q]=[f[e][2]];m[e]=q}}for(e in m){f[e][1]=d[m[e]];f[e][2]=h[m[e]]}for(e=o.length-1;e>=0;e--)f.remove(o[e]);return f}function i(f){f.map(function(d){return"%"+(d+1)+"$s"});return f.join(" ")}function g(f){if(f.length==0)return"";f=c(f);f.sort(function(u,b){return u[0]<b[0]?-1:1});for(var d=[],h=0,m=f.length;h<
16
- m;h++)d.push(f[h][0]);var o=d.length==1,e=s[d.join(",")];if(e===undefined)e=s[d]=i(d);if(typeof e==="string"){s[d]={format:e,ignoreSingle:true};e=s[d]}var q=e.format;f.each(function(u,b){var n=b[0],A=b[1],x=b[2];x.map(function(z,B){var C=A[z];if(C.charAt(C.length-1)=="*")B+="...";return B});e.filter&&x.map(function(z,B){return e.filter(B)});if(o&&!(e&&e.ignoreSingle)){n=w[n]||n;return q=x.join("&nbsp;")+"&nbsp;("+n+")"}x.map(function(z,B){return B.replace(/[\w,]+:(.+)/,"$1")});q=q.replace(RegExp("%"+
17
- (u+1)+"\\$s","g"),x.join("&nbsp;"))});return q}function j(f){for(var d=[],h=0,m=v.length;h<m;h++)d.push([]);d.push([]);h=0;for(m=f.length;h<m;h++){for(var o=f[h],e=o[0],q=false,u=0,b=v.length;u<b;u++)if(v[u].include(e)){d[u].push(o);q=true;break}q||d[d.length-1].push(o)}var n;for(f=d.length-1;f>=0;f--){n=d[f];if(n.length>0)break}n=n[n.length-1];y.include(n[0])||(n[1]=n[1].valueOf()+"*");return d}function k(f){var d=[];j(f).each(function(h,m){var o=g(m);o&&d.push(o)});return d.join(" ")}var p=a.locale,
18
- r=a.qualifiers&&a.qualifiers[p]||{},w=a.explanations&&a.explanations[p]||{},v=a.groups||[],s=a.choices&&a.choices[p]||{},y=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=c;this.makeUpMissingFormat=i;this.rendered=g;this.groupify=j;this.querify=function(f){var d=[],h,m,o;for(o in f){h=f[o][0];h=r[h]||h;m=(m=f[o][1])||"";m=m.charAt(m.length-1)=="*"?"*":"";d[o]=h+":"+f[o][2]+m}return d.join(" ")};this.suggestify=k;this.render=function(f){return k(f.combination)}};var PickyAllocationsCloud=function(a,c){var i=c.allocations,g=c.shownAllocations,j=c.showMoreAllocations,k=c.hiddenAllocations,p=c.maxSuggestions,r=function(){i.hide()},w=function(f){r();a.allocationChosen(f)},v=new AllocationRenderer(c),s=function(f){var d=[];f.each(function(h,m){var o=v.querify(m.combination),e=v.render(m);e=$('<li><div class="text">'+e+'</div><div class="count">'+m.count+"</div></li>");e.bind("click",{query:o},w);d.push(e)});return d},y=function(f){if(f.length==0)return i.hide();
19
- g.empty();j.hide();k.empty().hide();if(f.length>p){$.each(f.slice(0,p-1),function(d,h){g.append(h)});$.each(f.slice(p-1),function(d,h){k.append(h)});j.show()}else $.each(f,function(d,h){g.append(h)});return i.show()};j.click(function(){j.hide();k.show()});this.hide=r;this.show=function(f){y(s(f.allocations));i.show()}};
1
+ Array.prototype.index=function(a){for(var b=0,j=this.length;b<j;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,j=this.length;b<j;b++)a(b,this[b]);return this};Array.prototype.map=function(a){for(var b=0,j=this.length;b<j;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||
2
+ "en",j=a.split(".").concat(b),k=dictionary,l=0,i=j.length;l<i;l++){k=k[j[l]];if(k==undefined){k="Translation missing: "+a+"."+b;break}}return k};function Allocation(a,b,j,k,l,i){var o=this;this.type=a;this.weight=b;this.count=j;this.combination=k;this.ids=l||[];this.entries=this.rendered=i||[];this.isType=function(r){return r==o.type}}function Allocations(a){this.allocations=[];for(var b=0,j=a.length;b<j;b++){var k=a[b];this.allocations.push(new Allocation(k[0],k[1],k[2],k[3],k[4],k[5]))}this.length=this.allocations.length;this.remove=function(l){this.allocations.splice(l,1)};this.each=function(l){this.allocations.each(l)}}
3
+ function PickyData(a){var b=a.total,j=a.duration,k=a.offset,l=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=j;this.offset=k;this.allocations=l;this.renderedAmount=function(){var i=0;l.each(function(o,r){i+=r.rendered.length});return i};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var j=b.showResultsLimit||10,k=b.alwaysShowResults||false,l=b.alwaysShowSelection||false,i=b.input,o=b.reset,r=b.button,v=b.counter,x=b.form,u=b.moreSelector,w=b.results,g=b.noResults,d=new PickyAddination(this,w),h=new PickyAllocationsCloud(this,b),m=new PickyResultsRenderer(d,b),n=function(c){i.val(c);o.fadeTo(166,0);x.attr("class","empty");v.empty();h.hide();g.hide()};this.reset=n;var f=function(){return i.val()};this.text=f;var p=function(c){if(c.offset==0){w.empty();
4
+ m.render(w,c);w.show();i.focus()}else{var s=$(u).position().top;d.remove();m.render(w,c);$("body").animate({scrollTop:s-12},500)}},q=function(c){c>0&&c<=5&&v.fadeTo("fast",0.5).fadeTo("fast",1)},e=function(c){if(c.isEmpty())return"none";if(c.total>j&&c.allocations.length>1)return"support";return"ok"};this.insert=function(c){i.val(c);i.select()};this.fullResultsCallback=function(c){var s=e(c);x.attr("class",s);h.hide();g.hide();o.fadeTo(166,1);s=c.total;v.text(s);q(s);if(c.isEmpty()){w.empty();g.show()}else if(c.total>
5
+ j&&c.allocations.length>1){k&&p(c);h.show(c)}else{p(c);l&&h.show(c)}};this.liveResultsCallback=function(c){var s=e(c);x.attr("class",s);c=c.total;v.text(c);q(c)};this.allocationChosen=function(c){c=c.data.query;a.insert(c);a.allocationChosen(c)};this.addinationClicked=function(c){a.addinationClicked(f(),c)};(function(){i.keyup(function(c){if(f()==""){n();a.searchTextCleared()}else o.fadeTo(166,1);a.searchTextEntered(f(),c)});v.click(function(){a.searchButtonClicked(f())});r.click(function(){a.searchButtonClicked(f())});
6
+ o.click(function(){n();a.clearButtonClicked();i.focus()})})();i.focus()};var PickyBackend=function(a){var b=function(j,k,l){var i=l||{};i=$.extend({query:j},l);$.getJSON(a,i,function(o){k&&k(new PickyData(o))})};this.search=function(j,k,l,i){b(j,function(o){k&&k(i,o)},l)}},LiveBackend=function(a){var b=a.live||alert("A live backend path must be provided."),j=new PickyBackend(b);this.search=function(k,l,i,o){o=o||{};latestRequestTimestamp=new Date;o.live=latestRequestTimestamp;i=$.extend({ids:a.liveResults||0,offset:0},i);j.search(k,function(r,v){if(!r.live||r.live==latestRequestTimestamp)l&&
7
+ l(v,k)},i,o)}},FullBackend=function(a){var b=a.full||alert("A full backend path must be provided."),j=new PickyBackend(b);this.search=function(k,l,i,o){o=o||{};latestRequestTimestamp=new Date;o.full=latestRequestTimestamp;i=$.extend({ids:a.fullResults||20,offset:0},i);j.search(k,function(r,v){if(!r.full||r.full==latestRequestTimestamp)l&&l(v,k)},i,o)}};var PickyController=function(a){var b=new PickyView(this,a),j=a.backends,k=a.beforeInsert||function(e){return e},l=a.before||function(e){return e},i=a.success||function(e){return e},o=a.after||function(e){return e},r=a.searchOnEmpty||false,v=a.liveRendered||false,x=a.liveSearchInterval||180,u,w=function(e){return(e=e&&e.match(/q=([^&]+)/))&&decodeURIComponent(e[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=w;var g=function(){var e=window.History&&window.History.getState();return w(e&&
8
+ e.url)};this.lastFullQuery=g;var d=function(e,c,s,y){var z=l(c,y);if(z!=undefined)c=z;u=[e,c,s,y];z=c;if(z!=g()){z=!r&&z==""?"":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(!r&&c=="")b.reset();else(e=j[e])&&e.search(c,s,y)};this.resend=function(){u&&d.apply(this,u)};var h=function(e,c){(e=i(e,c))&&b.fullResultsCallback(e);o(e,c)},m=function(e,c){clearInterval(f);d("full",e,h,c||{})};a=function(e,
9
+ c){(e=i(e,c))&&b.liveResultsCallback(e);o(e,c)};var n=v?h:a,f,p=function(){var e=b.text();d("live",e,n,{});clearInterval(f)};f=setInterval(p,x);clearInterval(f);var q=function(e,c,s){var y=k(e);if(y!=undefined)e=y;b.insert(e);s&&m(e,c)};this.insert=q;this.clearButtonClicked=function(){clearInterval(f)};this.searchTextCleared=function(){clearInterval(f)};this.searchTextEntered=function(e,c){if($.inArray(c.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,
10
+ 79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(c.keyCode==13)m(e);else{clearInterval(f);f=setInterval(p,x)}};this.searchButtonClicked=function(e){m(e)};this.allocationChosen=function(e){m(e)};this.addinationClicked=function(e,c){m(e,{offset:c.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var e=window.History.getState();e=w(e.url);e!=undefined&&e!=(u&&u.length>1&&u[1])&&q(e,{},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)};
11
+ b=a.enclosingSelector||".picky";var j=a.formSelector||b+" form";a.form=$(j);a.input=$(a.inputSelector||j+" input[type=search]");a.reset=$(a.resetSelector||j+" div.reset");a.button=$(a.buttonSelector||j+" input[type=button]");a.counter=$(a.counterSelector||j+" div.status");a.results=$(a.resultsSelector||b+" div.results");a.noResults=$(a.noResultsSelector||b+" div.no_results");a.moreSelector=a.moreSelector||b+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||b+" .allocations");
12
+ a.shownAllocations=$(a.shownAllocations||a.allocations.find(".shown"));a.showMoreAllocations=$(a.showMoreAllocations||a.allocations.find(".more"));a.hiddenAllocations=$(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></ol>";var k=a.controller&&new a.controller(a)||new PickyController(a);var l=this.insert=function(i,
13
+ o,r){k.insert(i,o||{},r||true)};this.resend=k.resend;this.insertFromURL=function(i){if(i)l(i);else(i=k.lastFullQuery())&&l(i)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(j){var k=j.total,l,i=j.renderedAmount();l=j.offset+i;i=l+i;j=j.total;if(j<i)i=j;l={offset:l,start:l+1,end:i};if(l.offset<k){k=$("<div class='addination'>"+t("results.addination.more")+"</div>");k.bind("click",{offset:l.offset},a.addinationClicked);return k}else return""}};var PickyResultsRenderer=function(a,b){var j=b.locale,k=b.explanations||{},l=b.explanation_delimiters||{},i=b.resultsDivider,o=b.wrapResults,r=b.nonPartial,v=function(d){var h=d[d.length-1];if(h===undefined)return[];d=d.slice(0,d.length-1);if(d==[])d=[d];if(!r.include(h[0]))if(h[1].match(/[^\*~]$/))h[1]+="*";d.push(h);return d};this.asteriskifyLastToken=v;var x=function(d){for(var h=k[j]||{},m=[],n,f=0,p=d.length;f<p;f++){n=d[f];var q=n[0];q=h[q]||q;m.push([q,n[1]])}return m};this.explainCategory=
14
+ x;var u=function(d,h){return["<strong>"+d+"</strong>",h].join(" ")};this.strongify=u;var w=function(d,h){var m=l[j],n="",f=[],p=[];x(v(h)).each(function(q,e){var c=e[0],s=e[1];s=s.replace(/[\w,]+:(.+)/,"$1");if(n==""||c==n){f.push(s);n=c}else{var y=u(n,f.join(" "));f=[];f.push(s);n=c;p.push(y)}});p.push(u(n,f.join(" ")));p=p.join(" "+m+" ");return p='<span class="explanation">'+d+" "+p+"</span>"};this.explain=w;var g=function(d,h){var m='<div class="header">';m+=w(h.type,h.combination);if(d.offset>
15
+ 0)m+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';m+="</div>";return m};this.renderHeader=g;this.render=function(d,h){h.allocations.each(function(m,n){if(n.entries.length>0){d.append(g(h,n)).append(n.entries.join(i));d.children("li").wrapAll(o)}});d.append(a.render(h))}};function AllocationRenderer(a){function b(g){var d={},h={},m={},n=[],f,p;f=0;for(p=g.length;f<p;f++){var q=g[f][0];if(q in d){d[q].push(g[f][1]);h[q].push(g[f][2]);n.push(f)}else{d[q]=[g[f][1]];h[q]=[g[f][2]];m[f]=q}}for(f in m){g[f][1]=d[m[f]];g[f][2]=h[m[f]]}for(f=n.length-1;f>=0;f--)g.remove(n[f]);return g}function j(g){g.map(function(d){return"%"+(d+1)+"$s"});return g.join(" ")}function k(g){if(g.length==0)return"";g=b(g);for(var d=[],h=0,m=g.length;h<m;h++)d.push(g[h][0]);var n=d.length==1,f=
16
+ u[d.join(",")];if(f===undefined)f=u[d]=j(d);if(typeof f==="string"){u[d]={format:f,ignoreSingle:true};f=u[d]}var p=f.format;g.each(function(q,e){var c=e[0],s=e[1],y=e[2];y.map(function(z,A){var B=s[z];if(B.charAt(B.length-1)=="*")A+="...";return A});f.filter&&y.map(function(z,A){return f.filter(A)});if(n&&!(f&&f.ignoreSingle)){c=v[c]||c;return p=y.join("&nbsp;")+"&nbsp;("+c+")"}y.map(function(z,A){return A.replace(/[\w,]+:(.+)/,"$1")});p=p.replace(RegExp("%"+(q+1)+"\\$s","g"),y.join("&nbsp;"))});
17
+ return p}function l(g){for(var d=[],h=0,m=x.length;h<m;h++)d.push([]);d.push([]);h=0;for(m=g.length;h<m;h++){for(var n=g[h],f=n[0],p=false,q=0,e=x.length;q<e;q++)if(x[q].include(f)){d[q].push(n);p=true;break}p||d[d.length-1].push(n)}var c;for(g=d.length-1;g>=0;g--){c=d[g];if(c.length>0)break}c=c[c.length-1];w.include(c[0])||(c[1]=c[1].valueOf()+"*");return d}function i(g){var d=[];l(g).each(function(h,m){var n=k(m);n&&d.push(n)});return d.join(" ")}var o=a.locale,r=a.qualifiers&&a.qualifiers[o]||
18
+ {},v=a.explanations&&a.explanations[o]||{},x=a.groups||[],u=a.choices&&a.choices[o]||{},w=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=j;this.rendered=k;this.groupify=l;this.querify=function(g){var d=[],h,m,n;for(n in g){h=g[n][0];h=r[h]||h;m=(m=g[n][1])||"";m=m.charAt(m.length-1)=="*"?"*":"";d[n]=h+":"+g[n][2]+m}return d.join(" ")};this.suggestify=i;this.render=function(g){return i(g.combination)}};var PickyAllocationsCloud=function(a,b){var j=b.allocations,k=b.shownAllocations,l=b.showMoreAllocations,i=b.hiddenAllocations,o=b.maxSuggestions,r=function(){j.hide()},v=function(g){r();a.allocationChosen(g)},x=new AllocationRenderer(b),u=function(g){var d=[];g.each(function(h,m){var n=x.querify(m.combination),f=x.render(m);f=$('<li><div class="text">'+f+'</div><div class="count">'+m.count+"</div></li>");f.bind("click",{query:n},v);d.push(f)});return d},w=function(g){if(g.length==0)return j.hide();
19
+ k.empty();l.hide();i.empty().hide();if(g.length>o){$.each(g.slice(0,o-1),function(d,h){k.append(h)});$.each(g.slice(o-1),function(d,h){i.append(h)});l.show()}else $.each(g,function(d,h){k.append(h)});return j.show()};l.click(function(){l.hide();i.show()});this.hide=r;this.show=function(g){w(u(g.allocations));j.show()}};
@@ -20,6 +20,16 @@ describe Picky::TestClient do
20
20
 
21
21
  client.search('test').total.should == 1
22
22
  end
23
+ it 'sends correctly' do
24
+ response = stub :response
25
+ request = stub :request
26
+ client.stub! :request => request
27
+
28
+ request.should_receive(:get).once.with('/some/path?ids=100&query=some_query').and_return response
29
+ response.should_receive(:body).once.and_return '"some_body"'
30
+
31
+ client.search('some_query', :ids => 100).should == 'some_body'
32
+ end
23
33
  end
24
34
 
25
35
  context 'send_search' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.19.2
4
+ version: 4.19.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-20 00:00:00.000000000 Z
12
+ date: 2013-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby