picky-generators 1.4.0 → 1.4.1
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
|
-
Array.prototype.index=function(a){for(var
|
|
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(a){for(var
|
|
3
|
-
"en",
|
|
4
|
-
function PickyData(a){var
|
|
5
|
-
this.text=r;var s=function(h){o.text(h);h>0&&h<=5&&o.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>
|
|
1
|
+
Array.prototype.index=function(a){for(var j=0,i=this.length;j<i;j++)if(this[j]==a)return j;return null};Array.prototype.include=function(a){return this.index(a)!==null};Array.prototype.remove=function(a){this.splice(a,1);return this};var PickyI18n={};$(function(){PickyI18n.locale=$("html").attr("lang").split("-")[0]||"en"});
|
|
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(a){for(var j=PickyI18n.locale||
|
|
3
|
+
"en",i=a.split(".").concat(j),b=dictionary,e=0,n=i.length;e<n;e++){b=b[i[e]];if(b==undefined){b="Translation missing: "+a+"."+j;break}}return b};function Allocation(a,j,i,b,e,n){var o=this;this.type=a;this.weight=j;this.count=i;this.combination=b;this.ids=e||[];this.entries=this.rendered=n||[];this.isType=function(q){return q==o.type}}function Allocations(a){this.allocations=[];for(var j=0,i=a.length;j<i;j++){var b=a[j];this.allocations.push(new Allocation(b[0],b[1],b[2],b[3],b[4],b[5]))}this.length=this.allocations.length;this.each=function(e){return $.each(this.allocations,e)}}
|
|
4
|
+
function PickyData(a){var j=a.total,i=a.duration,b=a.offset;a=new Allocations(a.allocations||[]);this.total=j;this.duration=i;this.offset=b;this.allocations=a;this.isEmpty=function(){return j==0}};var PickyView=function(a,j){var i=j.showResultsLimit||10,b=$("#picky input.query"),e=$("#picky div.reset"),n=$("#picky input.search_button"),o=$("#picky div.status"),q=$("#picky .dashboard"),u=$("#picky .results"),p=$("#picky .no_results"),m=new PickyAddination(this,u),d=new PickyAllocationsCloud(this,j),f=new PickyResultsRenderer(m,j),c=function(){e.fadeTo(166,1)},g=function(){d.hide();u.empty();p.hide()},k=function(h){b.val(h);e.fadeTo(166,0);v("empty");o.empty();g()},r=function(){return b.val()};
|
|
5
|
+
this.text=r;var s=function(h){o.text(h);h>0&&h<=5&&o.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(h){if(h.isEmpty())return"none";if(h.total>i&&h.allocations.length>1)return"support";return"ok"},v=function(h){q.attr("class","dashboard "+h)};this.insert=function(h){b.val(h);b.select()};this.fullResultsCallback=function(h){v(w(h));if(h.isEmpty()){g();s(0);p.show();c()}else if(h.total>i&&h.allocations.length>1){g();c();d.show(h);s(h.total)}else if(h.offset==0){g();s(h.total);f.render(h);u.show();c();
|
|
6
6
|
b.focus()}else{m.remove();f.render(h);$("body").animate({scrollTop:$("#picky div.results div.header:last").position().top-12},500)}};this.liveResultsCallback=function(h){v(w(h));s(h.total)};this.allocationChosen=function(h){h=h.data.query;b.val(h);a.allocationChosen(h)};this.addinationClicked=function(h){a.addinationClicked(r(),h)};(function(){b.keyup(function(h){if(r()==""){k();a.searchTextCleared()}else{a.searchTextEntered(r(),h);c()}});o.click(function(){r()==""||a.searchButtonClicked(r())});n.click(function(){r()==
|
|
7
|
-
""||a.searchButtonClicked(r())});e.click(function(){k("");a.clearButtonClicked();b.focus()})})();b.focus()};var PickyBackend=function(a){var
|
|
8
|
-
this.search=function(
|
|
9
|
-
f)||c;var g=
|
|
10
|
-
function(d){m(d)};this.addinationClicked=function(d,f){m(d,f.data.offset)}};var Localization={
|
|
11
|
-
|
|
7
|
+
""||a.searchButtonClicked(r())});e.click(function(){k("");a.clearButtonClicked();b.focus()})})();b.focus()};var PickyBackend=function(a){var j=function(i,b,e,n){var o=n||{};o=$.extend({query:i,offset:e},n);$.getJSON(a,o,function(q){b&&b(new PickyData(q))})};this.search=function(i,b,e,n,o){j(i,function(q){b&&b(o,q)},e,n)}},LiveBackend=function(a){var j=new PickyBackend(a);this.search=function(i,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.live=latestRequestTimestamp;j.search(i,function(q,u){if(!q.live||q.live==latestRequestTimestamp)b&&b(u)},e,n,o)}},FullBackend=function(a){var j=new PickyBackend(a);
|
|
8
|
+
this.search=function(i,b,e,n,o){o=o||{};latestRequestTimestamp=new Date;o.full=latestRequestTimestamp;j.search(i,function(q,u){if(!q.full||q.full==latestRequestTimestamp)b&&b(u)},e,n,o)}};var PickyController=function(a){var j=new PickyView(this,a),i=a.backends,b=a.before||function(){},e=a.success||function(){},n=a.after||function(){},o=function(d,f){d=e(d,f)||d;j.liveResultsCallback(d);n(d,f)},q,u=function(){var d=j.text();b({});var f=i.live;f&&f.search(d,o,0,void 0);clearInterval(q)};q=setInterval(u,180);clearInterval(q);var p=function(d,f){d=e(d,f)||d;j.fullResultsCallback(d);n(d,f)},m=function(d,f,c){c=c||{};f=f||0;clearInterval(q);$.address&&$.address.parameter("q",d);c=b(c,d,
|
|
9
|
+
f)||c;var g=i.full;g&&g.search(d,p,f,c)};this.insert=function(d,f){j.insert(d);f&&m(d)};this.clearButtonClicked=function(){clearInterval(q)};this.searchTextCleared=function(){clearInterval(q)};this.searchTextEntered=function(d,f){if($.inArray(f.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(f.keyCode==13)m(d);else{clearInterval(q);q=setInterval(u,180)}};this.searchButtonClicked=function(d){m(d)};this.allocationChosen=
|
|
10
|
+
function(d){m(d)};this.addinationClicked=function(d,f){m(d,f.data.offset)}};var Localization={},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 j=a.backends;if(j){j.live||alert("Both a full and live backend must be provided.");j.full||alert("Both a full and live backend must be provided.")}else a.backends={live:a.live&&new LiveBackend(a.live)||alert("A live backend path must be provided."),full:a.full&&
|
|
11
|
+
new FullBackend(a.full)||alert("A live backend path must be provided.")};var i=a.controller&&new a.controller(a)||new PickyController(a);var b=this.insert=function(e,n){i.insert(e,n||true)};this.insertFromURL=function(e){if(e&&e!="")b(e);else $.address&&b($.address.parameter("q"))};$.address&&$.address.externalChange(function(e){(e=e.parameters.q)&&b(e)})};var PickyAddination=function(a,j){this.remove=function(){j.find(".addination").remove()};this.render=function(i){var b=i.total,e;e=i.offset+20+0;var n=e+20;i=i.total;if(i<n)n=i;e={offset:e,start:e+1,end:n};if(e.offset<b){b=$("<div class='addination'>"+t("results.addination.more")+"</div>");b.bind("click",{offset:e.offset},a.addinationClicked);return b}else return""}};var PickyResultsRenderer=function(a,j){var i=j.wrapResults||'<ol class="results"></ol>',b=["street_number","zipcode"],e=function(p){var m=p[p.length-1];p=p.slice(0,p.length-1);if(p==[])p=[p];if(!b.include(m[0]))if(m[1].match(/[^\*~]$/))m[1]+="*";p.push(m);return p},n=function(p){for(var m=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},d=[],f,c=0,g=p.length;c<g;c++){f=p[c];var k=f[0];k=m[k]||k;d.push([k,f[1]])}return d},o=function(p,m){return[p.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,
|
|
12
12
|
"<strong>$1</strong>"),m].join(" ")},q=function(p,m){var d=Localization.explanation_delimiters[PickyI18n.locale],f=n(e(m)),c="",g=[];f=$.map(f,function(k){var r=k[0];k=k[1];if(c==""||r==c){g.push(k);c=r}else{var s=o(c,g.join(" "));g=[];g.push(k);c=r;return s}});f.push(o(c,g.join(" ")));f=f.join(" "+d+" ");return'<span class="explanation">'+p+" "+f+"</span>"},u=function(p,m){var d='<div class="header">';d+=q(m.type,m.combination);if(p.offset>0)d+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">↑</a></div>';
|
|
13
|
-
return d};this.render=function(p){var m=$("#picky div.results");p.allocations.each(function(d,f){m.append(u(p,f)).append(f.entries.join("")).append(a.render(p));m.children("li").wrapAll(
|
|
13
|
+
return d};this.render=function(p){var m=$("#picky div.results");p.allocations.each(function(d,f){m.append(u(p,f)).append(f.entries.join("")).append(a.render(p));m.children("li").wrapAll(i)})}};function AllocationRenderer(a,j){function i(c){var g={},k={},r=[],s;s=0;for(l=c.length;s<l;s++){var w=c[s][0];if(w in g){g[w]=g[w]+" "+c[s][1];r.push(s)}else{g[w]=c[s][1];k[s]=w}}for(s in k)c[s][1]=g[k[s]];for(s=r.length-1;s>=0;s--)c.remove(r[s]);return c}function b(c){return $.map(c,function(g,k){return"%"+(k+1)+"$s"}).join(" ")}function e(c){if(c.length==0)return"";var g=c=i(c);g.sort(function(x,y){return x[0]<y[0]?-1:1});for(var k=[],r=0,s=g.length;r<s;r++)k.push(g[r][0]);var w=k.length==1,v=d[k]||
|
|
14
14
|
(d[k]=b(k));if($.type(v)==="string"){d[k]={format:v};v=d[k]}var h=1,z=v.format;$.each(c,function(x,y){var A=y[0],B=y[1];if(v.filter)B=v.filter(B);A=p[A]||A;if(w&&!(v&&v.ignoreSingle))return z=B+" ("+A+")";z=z.replace(RegExp("%"+h+"\\$s","g"),B);h+=1;return h});return z}function n(c){for(var g=[],k=0,r=m.length;k<r;k++)g.push([]);g.push([]);k=0;for(r=c.length;k<r;k++){for(var s=c[k],w=s[0],v=false,h=0,z=m.length;h<z;h++)if(m[h].include(w)){g[h].push(s);v=true;break}v||g[g.length-1].push(s)}var x;
|
|
15
|
-
for(c=g.length-1;c>=0;c--){x=g[c];if(x.length>0)break}x=x[x.length-1];f.include(x[0])||(x[1]+="...");return $.map(g,function(y){return e(y)})}function o(c){var g=[],k,r;for(r in c){k=c[r][0];k=u[k]||k;g[r]=k+":"+c[r][1]}return g.join(" ")}var q=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[q]||{},p=Localization.explanations&&Localization.explanations[q]||{},m=
|
|
16
|
-
|
|
17
|
-
e.show()}else $.each(m,function(d,f){b.append(f)});return $("#search .allocations").show()};e.click(function(){e.hide();n.show()});this.hide=o;this.show=function(m){p(u(m.allocations));
|
|
15
|
+
for(c=g.length-1;c>=0;c--){x=g[c];if(x.length>0)break}x=x[x.length-1];f.include(x[0])||(x[1]+="...");return $.map(g,function(y){return e(y)})}function o(c){var g=[],k,r;for(r in c){k=c[r][0];k=u[k]||k;g[r]=k+":"+c[r][1]}return g.join(" ")}var q=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[q]||{},p=Localization.explanations&&Localization.explanations[q]||{},m=j.groups||[],d=Localization.choices&&Localization.choices[q]||{};this.explanation=this.query=this.text="";var f=["street_number",
|
|
16
|
+
"zipcode"];this.contract=i;this.rendered=e;this.groupify=n;this.querify=o;this.render=function(c){var g=c.combination,k=c.count;c=o(g);g=n(g).join(" ");g=$('<li><div class="text">'+g+'</div><div class="count">'+k+"</div></li>");g.bind("click",{query:c},a);return g}};var PickyAllocationsCloud=function(a,j){var i=$("#picky .allocations"),b=i.find(".shown"),e=i.find(".more"),n=i.find(".hidden"),o=function(){i.hide()},q=new AllocationRenderer(function(m){o();a.allocationChosen(m)},j),u=function(m){var d=[];m.each(function(f,c){d.push(q.render(c))});return d},p=function(m){if(m.length==0)return $("#search .allocations").hide();b.empty();e.hide();n.empty().hide();if(m.length>3){$.each(m.slice(0,2),function(d,f){b.append(f)});$.each(m.slice(2),function(d,f){n.append(f)});
|
|
17
|
+
e.show()}else $.each(m,function(d,f){b.append(f)});return $("#search .allocations").show()};e.click(function(){e.hide();n.show()});this.hide=o;this.show=function(m){p(u(m.allocations));i.show()}};
|
|
@@ -97,15 +97,17 @@
|
|
|
97
97
|
// Optional. Default is {}.
|
|
98
98
|
//
|
|
99
99
|
choices: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
en:{
|
|
101
|
+
'title': {
|
|
102
|
+
format: "<strong>%1$s</strong>",
|
|
103
|
+
filter: function(text) { return text.toUpperCase(); },
|
|
104
|
+
ignoreSingle: false
|
|
105
|
+
},
|
|
106
|
+
'author,title': '%1$s, who wrote %2$s',
|
|
107
|
+
'title,author': '%2$s, written by %2$s',
|
|
108
|
+
'title,subjects': '%1$s, about %2$s',
|
|
109
|
+
'author,subjects': '%1$s, who wrote about %2$s'
|
|
110
|
+
}
|
|
109
111
|
},
|
|
110
112
|
|
|
111
113
|
// This is used to explain the preceding word in the suggestion text (if it
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: picky-generators
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 1.4.
|
|
5
|
+
version: 1.4.1
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Florian Hanke
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
requirements:
|
|
33
33
|
- - ~>
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: 1.4.
|
|
35
|
+
version: 1.4.1
|
|
36
36
|
type: :runtime
|
|
37
37
|
version_requirements: *id002
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ~>
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.4.
|
|
46
|
+
version: 1.4.1
|
|
47
47
|
type: :runtime
|
|
48
48
|
version_requirements: *id003
|
|
49
49
|
description: Generators for Picky.
|