picky-client 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  Array.prototype.index=function(c){for(var i=0,g=this.length;i<g;i++)if(this[i]==c)return i;return null};Array.prototype.include=function(c){return this.index(c)!==null};Array.prototype.remove=function(c){this.splice(c,1);return this};var PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
2
2
  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(c){for(var i=PickyI18n.locale||
3
- "en",g=c.split(".").concat(i),d=dictionary,e=0,m=g.length;e<m;e++){d=d[g[e]];if(d==undefined){d="Translation missing: "+c+"."+i;break}}return d};function Allocation(c,i,g,d,e,m){var n=this;this.type=c;this.weight=i;this.count=g;this.combination=d;this.ids=e||[];this.entries=this.rendered=m||[];this.isType=function(s){return s==n.type}}function Allocations(c){this.allocations=[];for(var i=0,g=c.length;i<g;i++){var d=c[i];this.allocations.push(new Allocation(d[0],d[1],d[2],d[3],d[4],d[5]))}this.length=this.allocations.length;this.each=function(e){return $.each(this.allocations,e)}}
4
- function PickyData(c){var i=c.total,g=c.duration,d=c.offset;c=new Allocations(c.allocations||[]);this.total=i;this.duration=g;this.offset=d;this.allocations=c;this.isEmpty=function(){return i==0}};var PickyView=function(c,i){var g=i.showResultsLimit||10,d=$("#picky input.query"),e=$("#picky div.reset"),m=$("#picky input.search_button"),n=$("#picky div.status"),s=$("#picky .dashboard"),u=$("#picky .results"),j=$("#picky .no_results"),k=new PickyAddination(this,u),r=new PickyAllocationsCloud(this,i),p=new PickyResultsRenderer(k,i),a=function(){e.fadeTo(166,1)},b=function(){r.hide();u.empty();j.hide()},f=function(h){d.val(h);e.fadeTo(166,0);v("empty");n.empty();b()},o=function(){return d.val()};
5
- this.text=o;var q=function(h){n.text(h);h>0&&h<=5&&n.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>g&&h.allocations.length>1)return"support";return"ok"},v=function(h){s.attr("class","dashboard "+h)};this.insert=function(h){d.val(h);d.select()};this.fullResultsCallback=function(h){v(w(h));if(h.isEmpty()){b();q(0);j.show();a()}else if(h.total>g&&h.allocations.length>1){b();a();r.show(h);q(h.total)}else if(h.offset==0){b();q(h.total);p.render(h);u.show();a();
6
- d.focus()}else{k.remove();p.render(h);$("body").animate({scrollTop:$("#picky div.results div.header:last").position().top-12},500)}};this.liveResultsCallback=function(h){v(w(h));q(h.total)};this.allocationChosen=function(h){h=h.data.query;d.val(h);c.allocationChosen(h)};this.addinationClicked=function(h){c.addinationClicked(o(),h)};(function(){d.keyup(function(h){if(o()==""){f();c.searchTextCleared()}else{c.searchTextEntered(o(),h);a()}});n.click(function(){o()==""||c.searchButtonClicked(o())});m.click(function(){o()==
7
- ""||c.searchButtonClicked(o())});e.click(function(){f("");c.clearButtonClicked();d.focus()})})();d.focus()};var PickyBackend=function(c){var i=function(g,d,e,m){var n=m||{};n=$.extend({query:g,offset:e},m);$.getJSON(c,n,function(s){d&&d(new PickyData(s))})};this.search=function(g,d,e,m,n){i(g,function(s){d&&d(n,s)},e,m)}},LiveBackend=function(c){var i=new PickyBackend(c);this.search=function(g,d,e,m,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;m=$.extend({ids:0},m);i.search(g,function(s,u){if(!s.live||s.live==latestRequestTimestamp)d&&d(u)},e,m,n)}},FullBackend=function(c){var i=
8
- new PickyBackend(c);this.search=function(g,d,e,m,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;m=$.extend({ids:20},m);i.search(g,function(s,u){if(!s.full||s.full==latestRequestTimestamp)d&&d(u)},e,m,n)}};var PickyController=function(c){var i=new PickyView(this,c),g=c.backends,d=c.before||function(){},e=c.success||function(){},m=c.after||function(){},n=function(a){return(a=a&&a.match(/q=([^&]+)/))&&unescape(a[1]||"")};this.extractQuery=n;var s=function(){var a=window.History&&window.History.getState();return n(a&&a.url)};this.lastQuery=s;var u=function(a,b){a=e(a,b)||a;i.liveResultsCallback(a);m(a,b)},j,k=function(){var a=i.text();d({});var b=g.live;b&&b.search(a,u,0,void 0);clearInterval(j)};j=setInterval(k,
9
- 180);clearInterval(j);var r=function(a,b){a=e(a,b)||a;i.fullResultsCallback(a);m(a,b)},p=function(a,b,f){f=f||{};b=b||0;clearInterval(j);if(a!=s()){var o="?q="+escape(a).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,o)}f=d(f,a,b)||f;(o=g.full)&&o.search(a,r,b,f)};this.insert=function(a,b){i.insert(a);b&&p(a)};this.clearButtonClicked=function(){clearInterval(j)};this.searchTextCleared=function(){clearInterval(j)};this.searchTextEntered=
10
- function(a,b){if($.inArray(b.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(b.keyCode==13)p(a);else{clearInterval(j);j=setInterval(k,180)}};this.searchButtonClicked=function(a){p(a)};this.allocationChosen=function(a){p(a)};this.addinationClicked=function(a,b){p(a,b.data.offset)}};var Localization={},PickyClient=function(c){Localization.qualifiers=c.qualifiers||{};Localization.explanations=c.explanations||{};Localization.choices=c.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var i=c.backends;if(i){i.live||alert("Both a full and live backend must be provided.");i.full||alert("Both a full and live backend must be provided.")}else c.backends={live:c.live&&new LiveBackend(c.live)||alert("A live backend path must be provided."),full:c.full&&
11
- new FullBackend(c.full)||alert("A live backend path must be provided.")};var g=c.controller&&new c.controller(c)||new PickyController(c);var d=this.insert=function(e,m){g.insert(e,m||true)};this.insertFromURL=function(e){if(e&&e!="")d(e);else(e=g.lastQuery())&&d(e)};window.History&&window.History.Adapter.bind(window,"statechange",function(){var e=window.History.getState();(e=g.extractQuery(e.url))&&d(e)})};var PickyAddination=function(c,i){this.remove=function(){i.find(".addination").remove()};this.render=function(g){var d=g.total,e;e=g.offset+20+0;var m=e+20;g=g.total;if(g<m)m=g;e={offset:e,start:e+1,end:m};if(e.offset<d){d=$("<div class='addination'>"+t("results.addination.more")+"</div>");d.bind("click",{offset:e.offset},c.addinationClicked);return d}else return""}};var PickyResultsRenderer=function(c,i){var g=i.wrapResults||'<ol class="results"></ol>',d=["street_number","zipcode"],e=function(j){var k=j[j.length-1];j=j.slice(0,j.length-1);if(j==[])j=[j];if(!d.include(k[0]))if(k[1].match(/[^\*~]$/))k[1]+="*";j.push(k);return j},m=function(j){for(var k=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},r=[],p,a=0,b=j.length;a<b;a++){p=j[a];var f=p[0];f=k[f]||f;r.push([f,p[1]])}return r},n=function(j,k){return[j.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
12
- "<strong>$1</strong>"),k].join(" ")},s=function(j,k){var r=Localization.explanation_delimiters[PickyI18n.locale],p=m(e(k)),a="",b=[];p=$.map(p,function(f){var o=f[0];f=f[1];if(a==""||o==a){b.push(f);a=o}else{var q=n(a,b.join(" "));b=[];b.push(f);a=o;return q}});p.push(n(a,b.join(" ")));p=p.join(" "+r+" ");return'<span class="explanation">'+j+" "+p+"</span>"},u=function(j,k){var r='<div class="header">';r+=s(k.type,k.combination);if(j.offset>0)r+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
13
- return r};this.render=function(j){var k=$("#picky div.results");j.allocations.each(function(r,p){k.append(u(j,p)).append(p.entries.join("")).append(c.render(j));k.children("li").wrapAll(g)})}};function AllocationRenderer(c,i){function g(a){var b={},f={},o=[],q;q=0;for(l=a.length;q<l;q++){var w=a[q][0];if(w in b){b[w]=b[w]+" "+a[q][1];o.push(q)}else{b[w]=a[q][1];f[q]=w}}for(q in f)a[q][1]=b[f[q]];for(q=o.length-1;q>=0;q--)a.remove(o[q]);return a}function d(a){return $.map(a,function(b,f){return"%"+(f+1)+"$s"}).join(" ")}function e(a){if(a.length==0)return"";var b=a=g(a);b.sort(function(x,y){return x[0]<y[0]?-1:1});for(var f=[],o=0,q=b.length;o<q;o++)f.push(b[o][0]);var w=f.length==1,v=r[f]||
14
- (r[f]=d(f));if($.type(v)==="string"){r[f]={format:v};v=r[f]}var h=1,z=v.format;$.each(a,function(x,y){var A=y[0],B=y[1];if(v.filter)B=v.filter(B);A=j[A]||A;if(w&&!(v&&v.ignoreSingle))return z=B+"&nbsp;("+A+")";z=z.replace(RegExp("%"+h+"\\$s","g"),B);h+=1;return h});return z}function m(a){for(var b=[],f=0,o=k.length;f<o;f++)b.push([]);b.push([]);f=0;for(o=a.length;f<o;f++){for(var q=a[f],w=q[0],v=false,h=0,z=k.length;h<z;h++)if(k[h].include(w)){b[h].push(q);v=true;break}v||b[b.length-1].push(q)}var x;
15
- for(a=b.length-1;a>=0;a--){x=b[a];if(x.length>0)break}x=x[x.length-1];p.include(x[0])||(x[1]+="...");return $.map(b,function(y){return e(y)})}function n(a){var b=[],f,o;for(o in a){f=a[o][0];f=u[f]||f;b[o]=f+":"+a[o][1]}return b.join(" ")}var s=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[s]||{},j=Localization.explanations&&Localization.explanations[s]||{},k=i.groups||[],r=Localization.choices&&Localization.choices[s]||{};this.explanation=this.query=this.text="";var p=["street_number",
16
- "zipcode"];this.contract=g;this.rendered=e;this.groupify=m;this.querify=n;this.render=function(a){var b=a.combination,f=a.count;a=n(b);b=m(b).join(" ");b=$('<li><div class="text">'+b+'</div><div class="count">'+f+"</div></li>");b.bind("click",{query:a},c);return b}};var PickyAllocationsCloud=function(c,i){var g=$("#picky .allocations"),d=g.find(".shown"),e=g.find(".more"),m=g.find(".hidden"),n=function(){g.hide()},s=new AllocationRenderer(function(k){n();c.allocationChosen(k)},i),u=function(k){var r=[];k.each(function(p,a){r.push(s.render(a))});return r},j=function(k){if(k.length==0)return $("#search .allocations").hide();d.empty();e.hide();m.empty().hide();if(k.length>3){$.each(k.slice(0,2),function(r,p){d.append(p)});$.each(k.slice(2),function(r,p){m.append(p)});
17
- e.show()}else $.each(k,function(r,p){d.append(p)});return $("#search .allocations").show()};e.click(function(){e.hide();m.show()});this.hide=n;this.show=function(k){j(u(k.allocations));g.show()}};
3
+ "en",g=c.split(".").concat(i),e=dictionary,d=0,j=g.length;d<j;d++){e=e[g[d]];if(e==undefined){e="Translation missing: "+c+"."+i;break}}return e};function Allocation(c,i,g,e,d,j){var n=this;this.type=c;this.weight=i;this.count=g;this.combination=e;this.ids=d||[];this.entries=this.rendered=j||[];this.isType=function(s){return s==n.type}}function Allocations(c){this.allocations=[];for(var i=0,g=c.length;i<g;i++){var e=c[i];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(d){return $.each(this.allocations,d)}}
4
+ function PickyData(c){var i=c.total,g=c.duration,e=c.offset,d=new Allocations(c.allocations||[]);this.original_hash=c;this.total=i;this.duration=g;this.offset=e;this.allocations=d;this.renderedAmount=function(){var j=0;d.each(function(n,s){j+=s.rendered.length});return j};this.isEmpty=function(){return i==0}};var PickyView=function(c,i){var g=i.showResultsLimit||10,e=$("#picky input.query"),d=$("#picky div.reset"),j=$("#picky input.search_button"),n=$("#picky div.status"),s=$("#picky .dashboard"),u=$("#picky .results"),k=$("#picky .no_results"),m=new PickyAddination(this,u),r=new PickyAllocationsCloud(this,i),p=new PickyResultsRenderer(m,i),a=function(){d.fadeTo(166,1)},b=function(){r.hide();u.empty();k.hide()},f=function(h){e.val(h);d.fadeTo(166,0);v("empty");n.empty();b()},o=function(){return e.val()};
5
+ this.text=o;var q=function(h){n.text(h);h>0&&h<=5&&n.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>g&&h.allocations.length>1)return"support";return"ok"},v=function(h){s.attr("class","dashboard "+h)};this.insert=function(h){e.val(h);e.select()};this.fullResultsCallback=function(h){v(w(h));if(h.isEmpty()){b();q(0);k.show();a()}else if(h.total>g&&h.allocations.length>1){b();a();r.show(h);q(h.total)}else if(h.offset==0){b();q(h.total);p.render(h);u.show();a();
6
+ e.focus()}else{m.remove();p.render(h);$("body").animate({scrollTop:$("#picky div.results div.header:last").position().top-12},500)}};this.liveResultsCallback=function(h){v(w(h));q(h.total)};this.allocationChosen=function(h){h=h.data.query;e.val(h);c.allocationChosen(h)};this.addinationClicked=function(h){c.addinationClicked(o(),h)};(function(){e.keyup(function(h){if(o()==""){f();c.searchTextCleared()}else{c.searchTextEntered(o(),h);a()}});n.click(function(){o()==""||c.searchButtonClicked(o())});j.click(function(){o()==
7
+ ""||c.searchButtonClicked(o())});d.click(function(){f("");c.clearButtonClicked();e.focus()})})();e.focus()};var PickyBackend=function(c){var i=function(g,e,d){var j=d||{};j=$.extend({query:g},d);$.getJSON(c,j,function(n){e&&e(new PickyData(n))})};this.search=function(g,e,d,j){i(g,function(n){e&&e(j,n)},d)}},LiveBackend=function(c){var i=c.live||alert("A live backend path must be provided."),g=new PickyBackend(i);this.search=function(e,d,j,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;j=$.extend({ids:c.liveResults||0,offset:0},j);g.search(e,function(s,u){if(!s.live||s.live==latestRequestTimestamp)d&&
8
+ d(u)},j,n)}},FullBackend=function(c){var i=c.full||alert("A full backend path must be provided."),g=new PickyBackend(i);this.search=function(e,d,j,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;j=$.extend({ids:c.fullResults||20,offset:0},j);g.search(e,function(s,u){if(!s.full||s.full==latestRequestTimestamp)d&&d(u)},j,n)}};var PickyController=function(c){var i=new PickyView(this,c),g=c.backends,e=c.before||function(){},d=c.success||function(){},j=c.after||function(){},n=function(a){return(a=a&&a.match(/q=([^&]+)/))&&unescape(a[1]||"")};this.extractQuery=n;var s=function(){var a=window.History&&window.History.getState();return n(a&&a.url)};this.lastQuery=s;var u=function(a,b){a=d(a,b)||a;i.liveResultsCallback(a);j(a,b)},k,m=function(){var a=i.text(),b={};b=e(b)||b;var f=g.live;f&&f.search(a,u,b);clearInterval(k)};k=
9
+ setInterval(m,180);clearInterval(k);var r=function(a,b){a=d(a,b)||a;i.fullResultsCallback(a);j(a,b)},p=function(a,b){var f=b||{};clearInterval(k);if(a!=s()){var o="?q="+escape(a).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,o)}f=e(f,a)||f;(o=g.full)&&o.search(a,r,f)};this.insert=function(a,b,f){i.insert(a);f&&p(a,b)};this.clearButtonClicked=function(){clearInterval(k)};this.searchTextCleared=function(){clearInterval(k)};
10
+ this.searchTextEntered=function(a,b){if($.inArray(b.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(b.keyCode==13)p(a);else{clearInterval(k);k=setInterval(m,180)}};this.searchButtonClicked=function(a){p(a)};this.allocationChosen=function(a){p(a)};this.addinationClicked=function(a,b){p(a,{offset:b.data.offset})}};var Localization={},PickyClient=function(c){Localization.qualifiers=c.qualifiers||{};Localization.explanations=c.explanations||{};Localization.choices=c.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var i=c.backends;if(i){i.live||alert("Both a full and live backend must be provided.");i.full||alert("Both a full and live backend must be provided.")}else c.backends={live:new LiveBackend(c),full:new FullBackend(c)};var g=c.controller&&new c.controller(c)||
11
+ new PickyController(c);var e=this.insert=function(d,j,n){g.insert(d,j||{},n||true)};this.insertFromURL=function(d){if(d&&d!="")e(d);else(d=g.lastQuery())&&e(d)};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();(d=g.extractQuery(d.url))&&e(d)})};var PickyAddination=function(c,i){this.remove=function(){i.find(".addination").remove()};this.render=function(g){var e=g.total,d,j=g.renderedAmount();d=g.offset+j;j=d+j;g=g.total;if(g<j)j=g;d={offset:d,start:d+1,end:j};if(d.offset<e){e=$("<div class='addination'>"+t("results.addination.more")+"</div>");e.bind("click",{offset:d.offset},c.addinationClicked);return e}else return""}};var PickyResultsRenderer=function(c,i){var g=i.wrapResults||'<ol class="results"></ol>',e=["street_number","zipcode"],d=function(k){var m=k[k.length-1];k=k.slice(0,k.length-1);if(k==[])k=[k];if(!e.include(m[0]))if(m[1].match(/[^\*~]$/))m[1]+="*";k.push(m);return k},j=function(k){for(var m=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},r=[],p,a=0,b=k.length;a<b;a++){p=k[a];var f=p[0];f=m[f]||f;r.push([f,p[1]])}return r},n=function(k,m){return[k.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
12
+ "<strong>$1</strong>"),m].join(" ")},s=function(k,m){var r=Localization.explanation_delimiters[PickyI18n.locale],p=j(d(m)),a="",b=[];p=$.map(p,function(f){var o=f[0];f=f[1];if(a==""||o==a){b.push(f);a=o}else{var q=n(a,b.join(" "));b=[];b.push(f);a=o;return q}});p.push(n(a,b.join(" ")));p=p.join(" "+r+" ");return'<span class="explanation">'+k+" "+p+"</span>"},u=function(k,m){var r='<div class="header">';r+=s(m.type,m.combination);if(k.offset>0)r+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">&uarr;</a></div>';
13
+ return r};this.render=function(k){var m=$("#picky div.results");k.allocations.each(function(r,p){m.append(u(k,p)).append(p.entries.join("")).append(c.render(k));m.children("li").wrapAll(g)})}};function AllocationRenderer(c,i){function g(a){var b={},f={},o=[],q;q=0;for(l=a.length;q<l;q++){var w=a[q][0];if(w in b){b[w]=b[w]+" "+a[q][1];o.push(q)}else{b[w]=a[q][1];f[q]=w}}for(q in f)a[q][1]=b[f[q]];for(q=o.length-1;q>=0;q--)a.remove(o[q]);return a}function e(a){return $.map(a,function(b,f){return"%"+(f+1)+"$s"}).join(" ")}function d(a){if(a.length==0)return"";var b=a=g(a);b.sort(function(x,y){return x[0]<y[0]?-1:1});for(var f=[],o=0,q=b.length;o<q;o++)f.push(b[o][0]);var w=f.length==1,v=r[f]||
14
+ (r[f]=e(f));if($.type(v)==="string"){r[f]={format:v};v=r[f]}var h=1,z=v.format;$.each(a,function(x,y){var A=y[0],B=y[1];if(v.filter)B=v.filter(B);A=k[A]||A;if(w&&!(v&&v.ignoreSingle))return z=B+"&nbsp;("+A+")";z=z.replace(RegExp("%"+h+"\\$s","g"),B);h+=1;return h});return z}function j(a){for(var b=[],f=0,o=m.length;f<o;f++)b.push([]);b.push([]);f=0;for(o=a.length;f<o;f++){for(var q=a[f],w=q[0],v=false,h=0,z=m.length;h<z;h++)if(m[h].include(w)){b[h].push(q);v=true;break}v||b[b.length-1].push(q)}var x;
15
+ for(a=b.length-1;a>=0;a--){x=b[a];if(x.length>0)break}x=x[x.length-1];p.include(x[0])||(x[1]+="...");return $.map(b,function(y){return d(y)})}function n(a){var b=[],f,o;for(o in a){f=a[o][0];f=u[f]||f;b[o]=f+":"+a[o][1]}return b.join(" ")}var s=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[s]||{},k=Localization.explanations&&Localization.explanations[s]||{},m=i.groups||[],r=Localization.choices&&Localization.choices[s]||{};this.explanation=this.query=this.text="";var p=["street_number",
16
+ "zipcode"];this.contract=g;this.rendered=d;this.groupify=j;this.querify=n;this.render=function(a){var b=a.combination,f=a.count;a=n(b);b=j(b).join(" ");b=$('<li><div class="text">'+b+'</div><div class="count">'+f+"</div></li>");b.bind("click",{query:a},c);return b}};var PickyAllocationsCloud=function(c,i){var g=$("#picky .allocations"),e=g.find(".shown"),d=g.find(".more"),j=g.find(".hidden"),n=function(){g.hide()},s=new AllocationRenderer(function(m){n();c.allocationChosen(m)},i),u=function(m){var r=[];m.each(function(p,a){r.push(s.render(a))});return r},k=function(m){if(m.length==0)return $("#search .allocations").hide();e.empty();d.hide();j.empty().hide();if(m.length>3){$.each(m.slice(0,2),function(r,p){e.append(p)});$.each(m.slice(2),function(r,p){j.append(p)});
17
+ d.show()}else $.each(m,function(r,p){e.append(p)});return $("#search .allocations").show()};d.click(function(){d.hide();j.show()});this.hide=n;this.show=function(m){k(u(m.allocations));g.show()}};
@@ -14,11 +14,11 @@ module Picky
14
14
  # (Note that not all ids are returned with the results. By default only maximally 20.)
15
15
  #
16
16
  # === Parameters
17
- # * limit: The amount of ids to return. Default is 20.
17
+ # * limit: The amount of ids to return. Default is all of them.
18
18
  #
19
- def ids limit = 20
19
+ def ids limit = nil
20
20
  ids = []
21
- allocations.each { |allocation| allocation[4].each { |id| break if ids.size > limit; ids << id } }
21
+ allocations.each { |allocation| allocation[4].each { |id| break if limit && ids.size > limit; ids << id } }
22
22
  ids
23
23
  end
24
24
 
@@ -53,13 +53,13 @@ module Picky
53
53
  #
54
54
  # === Parameters
55
55
  # * model_class: The model to use for the results. Will call #find on the given class.
56
- # * amount: Amount of results to populate. Default 20.
57
56
  #
58
57
  # === Options
59
- # * options are directly passed through to the ModelClass.find(ids, options) method. Default is {}.
58
+ # * up_to: Amount of results to populate. All of them by default.
59
+ # * The rest of the options are directly passed through to the ModelClass.find(ids, options) method. Default is {}.
60
60
  #
61
- def populate_with model_class, amount = 20, options = {}, &block
62
- the_ids = ids amount
61
+ def populate_with model_class, options = {}, &block
62
+ the_ids = ids options.delete(:up_to)
63
63
 
64
64
  objects = model_class.find the_ids, options
65
65
 
@@ -139,8 +139,8 @@ describe Picky::Convenience do
139
139
  end
140
140
 
141
141
  describe 'ids' do
142
- it 'should return the top default ids' do
143
- @convenience.ids.should == (1..21).to_a
142
+ it 'returns by default all ids' do
143
+ @convenience.ids.should == (1..23).to_a
144
144
  end
145
145
  it 'should return the top limit entries' do
146
146
  @convenience.ids(7).should == (1..8).to_a
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: picky-client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.3.0
5
+ version: 2.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Florian Hanke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-17 00:00:00 +10:00
13
+ date: 2011-04-20 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency