picky-generators 4.23.2 → 4.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/prototypes/shared/client/javascripts/picky.min.js +20 -20
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dcb35e721ce75ecef022566c3144b5f6eb7b0aa
|
4
|
+
data.tar.gz: 1b012e867bb1711bffefac48131cca355fcf789b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58a1cc148c6d1e09ea9ff9c2d88e7e0f5cde2b4bb0b28e978064e7b989867e8e062c4d1bf0effee95b6b67b6288494dfbc95ad25991319cc2caa295c75b930e
|
7
|
+
data.tar.gz: 0786d03fe5b1d77d436c5b45abd8500cf891c69e2a34004b210b8bf8eb0d191cf407c14f2de621b3a6b95f59575222b209e8a349ce163b7e93cb2020f7e36e5c
|
@@ -1,20 +1,20 @@
|
|
1
|
-
Array.prototype.index=function(a){for(var
|
2
|
-
"en",
|
3
|
-
function PickyData(a){var
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
a.full||alert("A full backend path must be provided."),
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
a.form=$(
|
12
|
-
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||
|
13
|
-
function(
|
14
|
-
o,
|
15
|
-
o=
|
16
|
-
o)).append(o.entries.join(
|
17
|
-
|
18
|
-
return
|
19
|
-
{},
|
20
|
-
|
1
|
+
Array.prototype.index=function(a){for(var b=0,h=this.length;b<h;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,h=this.length;b<h;b++)a(b,this[b]);return this};Array.prototype.map=function(a){for(var b=0,h=this.length;b<h;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",h=a.split(".").concat(b),j=dictionary,k=0,i=h.length;k<i;k++){j=j[h[k]];if(j==undefined){j="Translation missing: "+a+"."+b;break}}return j};function Allocation(a,b,h,j,k,i){var n=this;this.type=a;this.weight=b;this.count=h;this.combination=j;this.ids=k||[];this.entries=this.rendered=i||[];this.isType=function(s){return s==n.type}}function Allocations(a){this.allocations=[];for(var b=0,h=a.length;b<h;b++){var j=a[b];this.allocations.push(new Allocation(j[0],j[1],j[2],j[3],j[4],j[5]))}this.length=this.allocations.length;this.remove=function(k){this.allocations.splice(k,1)};this.each=function(k){this.allocations.each(k)}}
|
3
|
+
function PickyData(a){var b=a.total,h=a.duration,j=a.offset,k=new Allocations(a.allocations||[]);this.original_hash=a;this.total=b;this.duration=h;this.offset=j;this.allocations=k;this.renderedAmount=function(){var i=0;k.each(function(n,s){i+=s.rendered.length});return i};this.isEmpty=function(){return b==0}};var PickyView=function(a,b){var h=b.showResultsLimit||10,j=b.alwaysShowResults||false,k=b.alwaysShowSelection||false,i=b.input,n=b.reset,s=b.button,v=b.counter,x=b.form,A=b.moreSelector,w=b.results,f=b.noResults,l=new PickyAddination(this,w),m=new PickyAllocationsCloud(this,b),q=new PickyResultsRenderer(l,b),g=function(e){i.val(e);n.fadeTo(166,0);x.attr("class","empty");v.empty();m.hide();f.hide()};this.reset=g;var d=function(){return i.val()};this.text=d;var p=function(e){if(e.offset==0){w.empty();
|
4
|
+
q.render(w,e);w.show();i.focus()}else{var c=$(A).position().top;l.remove();q.render(w,e);$("body").animate({scrollTop:c-12},500)}},o=function(e){e>0&&e<=5&&v.fadeTo("fast",0.5).fadeTo("fast",1)},u=function(e){if(e.isEmpty())return"none";if(e.total>h&&e.allocations.length>1)return"support";return"ok"};this.insert=function(e){i.val(e);i.select()};this.fullResultsCallback=function(e){var c=u(e);x.attr("class",c);m.hide();f.hide();n.fadeTo(166,1);c=e.total;v.text(c);o(c);if(e.isEmpty()){w.empty();f.show()}else if(e.total>
|
5
|
+
h&&e.allocations.length>1){j&&p(e);m.show(e)}else{p(e);k&&m.show(e)}};this.liveResultsCallback=function(e){var c=u(e);x.attr("class",c);e=e.total;v.text(e);o(e)};this.allocationChosen=function(e){e=e.data.query;a.insert(e);a.allocationChosen(e)};this.addinationClicked=function(e){a.addinationClicked(d(),e)};(function(){i.keyup(function(e){if(d()==""){g();a.searchTextCleared()}else n.fadeTo(166,1);a.searchTextEntered(d(),e)});v.click(function(){a.searchButtonClicked(d())});s.click(function(){a.searchButtonClicked(d())});
|
6
|
+
n.click(function(){g();a.clearButtonClicked();i.focus()})})();i.focus()};var PickyBackend=function(a){var b=function(h,j,k){var i=k||{};i=$.extend({query:h},k);$.getJSON(a,i,function(n){j&&j(new PickyData(n))})};this.search=function(h,j,k,i){b(h,function(n){j&&j(i,n)},k)}},LiveBackend=function(a){var b=a.live||alert("A live backend path must be provided."),h=new PickyBackend(b);this.search=function(j,k,i,n){n=n||{};var s=new Date;n.live=s;i=$.extend({ids:a.liveResults||0,offset:0},i);h.search(j,function(v,x){if(!v.live||v.live==s)k&&k(x,j)},i,n)}},FullBackend=function(a){var b=
|
7
|
+
a.full||alert("A full backend path must be provided."),h=new PickyBackend(b);this.search=function(j,k,i,n){n=n||{};var s=new Date;n.full=s;i=$.extend({ids:a.fullResults||20,offset:0},i);h.search(j,function(v,x){if(!v.full||v.full==s)k&&k(x,j)},i,n)}};var PickyController=function(a){var b=new PickyView(this,a),h=a.backends,j=a.beforeInsert||function(c){return c},k=a.beforeParams||function(c){return c},i=a.before||function(c){return c},n=a.success||function(c){return c},s=a.after||function(c){return c},v=a.searchOnEmpty||false,x=a.liveRendered||false,A=a.liveSearchInterval||180,w,f=function(c){return(c=c&&c.match(/q=([^&]+)/))&&decodeURIComponent(c[1].replace(/\+/g," "))||""};this.extractQuery=f;var l=function(){var c=window.History&&window.History.getState();
|
8
|
+
return f(c&&c.url)};this.lastFullQuery=l;var m=function(c,r,B,y){if(!v&&r=="")b.reset();else{y=k(y);var z=i(r,y);if(z!=undefined)r=z;w=[c,r,B,y];z=r;if(z!=l()){z=!v&&z==""?"/":"?q="+encodeURIComponent(z);window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}(c=h[c])&&c.search(r,B,y)}};this.resend=function(){w&&m.apply(this,w)};var q=function(c,r){(c=n(c,r))&&b.fullResultsCallback(c);s(c,r)},g=function(c,r){clearInterval(p);m("full",c,q,r||{})};
|
9
|
+
a=function(c,r){(c=n(c,r))&&b.liveResultsCallback(c);s(c,r)};var d=x?q:a,p,o=function(){var c=b.text();m("live",c,d,{});clearInterval(p)};p=setInterval(o,A);clearInterval(p);var u=function(c,r,B){var y=j(c);if(y!=undefined)c=y;b.insert(c);B&&g(c,r)};this.insert=u;this.clearButtonClicked=function(){clearInterval(p)};this.searchTextCleared=function(){clearInterval(p)};var e=[1,2,3,4,5,6,7,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];this.searchTextEntered=function(c,r){if($.inArray(r.keyCode,
|
10
|
+
e)<0)if(r.keyCode==13)g(c);else{clearInterval(p);p=setInterval(o,A)}};this.searchButtonClicked=function(c){g(c)};this.allocationChosen=function(c){g(c)};this.addinationClicked=function(c,r){g(c,{offset:r.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var c=window.History.getState();c=f(c.url);c!=undefined&&c!=(w&&w.length>1&&w[1])&&u(c,{},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||{};var b=a.backends;if(b){b.live||alert("Both a full and live backend must be provided.");b.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};b=a.enclosingSelector||".picky";var h=a.formSelector||b+" form";
|
11
|
+
a.form=$(h);a.input=$(a.inputSelector||h+" input[type=search]");a.reset=$(a.resetSelector||h+" div.reset");a.button=$(a.buttonSelector||h+" input[type=button]");a.counter=$(a.counterSelector||h+" 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");a.shownAllocations=$(a.shownAllocations||a.allocations.find(".shown"));
|
12
|
+
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 j=a.controller&&new a.controller(a)||new PickyController(a);var k=this.insert=function(i,n,s){j.insert(i,n||{},s||true)};this.resend=j.resend;this.insertFromURL=
|
13
|
+
function(i){if(i)k(i);else(i=j.lastFullQuery())&&k(i)}};var PickyAddination=function(a,b){this.remove=function(){b.find(".addination").remove()};this.render=function(h){var j=h.total,k,i=h.renderedAmount();k=h.offset+i;i=k+i;h=h.total;if(h<i)i=h;k={offset:k,start:k+1,end:i};if(k.offset<j){j=$("<div class='addination'>"+t("results.addination.more")+"</div>");j.bind("click",{offset:k.offset},a.addinationClicked);return j}else return""}};var PickyResultsRenderer=function(a,b){var h=b.locale,j=b.explanations||{},k=b.explanationDelimiter||{ch:"und",de:"und",en:"and",fr:"et",it:"e"},i=b.explanationTokenDelimiter||{},n=b.explanationTokenCallback,s=b.resultsDivider,v=b.wrapResults,x=b.nonPartial,A=function(g){var d=g[g.length-1];if(d===undefined)return[];g=g.slice(0,g.length-1);if(g==[])g=[g];if(!x.include(d[0]))if(d[1].match(/[^\*~]$/))d[1]+="*";g.push(d);return g};this.asteriskifyLastToken=A;var w=function(g){for(var d=j[h]||{},p=[],
|
14
|
+
o,u=0,e=g.length;u<e;u++){o=g[u];var c=o[0];p.push([c,d[c]||c,o[1]])}return p};this.explainCategory=w;var f=function(g,d){return["<strong>"+g+"</strong>",d].join(" ")};this.strongify=f;var l=function(g,d,p){var o=n&&n(g,p);return o?o:f(d,p.join((i[h]||{})[g]||" "))},m=function(g,d){var p=k[h]||"&",o="",u=[],e=[];w(A(d)).each(function(c,r){var B=r[0],y=r[1],z=r[2];z=z.replace(/[\w,]+:(.+)/,"$1");if(o==""||B==o){u.push(z);o=B;lastExplainedCategory=y}else{var C=l(o,lastExplainedCategory,u);u=[];u.push(z);
|
15
|
+
o=B;lastExplainedCategory=y;e.push(C)}});e.push(l(o,lastExplainedCategory,u));e=e.join(" "+p+" ");return e='<span class="explanation">'+g+" "+e+"</span>"};this.explain=m;var q=function(g,d){var p='<div class="header">';p+=m(d.type,d.combination);if(g.offset>0)p+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">↑</a></div>';p+="</div>";return p};this.renderHeader=q;this.render=function(g,d){d.allocations.each(function(p,o){if(o.entries.length>0){g.append(q(d,
|
16
|
+
o)).append(o.entries.join(s));g.children("li").wrapAll(v)}});g.append(a.render(d))}};function AllocationRenderer(a){function b(f){var l={},m={},q={},g=[],d,p;d=0;for(p=f.length;d<p;d++){var o=f[d][0];if(o in l){l[o].push(f[d][1]);m[o].push(f[d][2]);g.push(d)}else{l[o]=[f[d][1]];m[o]=[f[d][2]];q[d]=o}}for(d in q){f[d][1]=l[q[d]];f[d][2]=m[q[d]]}for(d=g.length-1;d>=0;d--)f.remove(g[d]);return f}function h(f){f.map(function(l){return"%"+(l+1)+"$s"});return f.join(" ")}function j(f){if(f.length==0)return"";f=b(f);for(var l=[],m=0,q=f.length;m<q;m++)l.push(f[m][0]);var g=l.length==1,d=
|
17
|
+
A[l.join(",")];if(d===undefined)d=A[l]=h(l);if(typeof d==="string"){A[l]={format:d,ignoreSingle:true};d=A[l]}var p=d.format;f.each(function(o,u){var e=u[0],c=u[1],r=u[2];r.map(function(B,y){var z=c[B];if(z.charAt(z.length-1)=="*")y+="...";return y});d.filter&&r.map(function(B,y){return d.filter(y)});if(g&&!(d&&d.ignoreSingle)){e=v[e]||e;return p=r.join(" ")+" ("+e+")"}r.map(function(B,y){return y.replace(/[\w,]+:(.+)/,"$1")});p=p.replace(RegExp("%"+(o+1)+"\\$s","g"),r.join(" "))});
|
18
|
+
return p}function k(f){for(var l=[],m=0,q=x.length;m<q;m++)l.push([]);l.push([]);m=0;for(q=f.length;m<q;m++){for(var g=f[m],d=g[0],p=false,o=0,u=x.length;o<u;o++)if(x[o].include(d)){l[o].push(g);p=true;break}p||l[l.length-1].push(g)}var e;for(f=l.length-1;f>=0;f--){e=l[f];if(e.length>0)break}e=e[e.length-1];w.include(e[0])||(e[1]=e[1].valueOf()+"*");return l}function i(f){var l=[];k(f).each(function(m,q){var g=j(q);g&&l.push(g)});return l.join(" ")}var n=a.locale,s=a.qualifiers&&a.qualifiers[n]||
|
19
|
+
{},v=a.explanations&&a.explanations[n]||{},x=a.groups||[],A=a.choices&&a.choices[n]||{},w=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=b;this.makeUpMissingFormat=h;this.rendered=j;this.groupify=k;this.querify=function(f){var l=[],m,q,g;for(g in f){m=f[g][0];m=s[m]||m;q=(q=f[g][1])||"";q=q.charAt(q.length-1)=="*"?"*":"";l[g]=m+":"+f[g][2]+q}return l.join(" ")};this.suggestify=i;this.render=function(f){return i(f.combination)}};var PickyAllocationsCloud=function(a,b){var h=b.allocations,j=b.shownAllocations,k=b.showMoreAllocations,i=b.hiddenAllocations,n=b.maxSuggestions,s=function(){h.hide()},v=function(f){s();a.allocationChosen(f)},x=new AllocationRenderer(b),A=function(f){var l=[];f.each(function(m,q){var g=x.querify(q.combination),d=x.render(q);d=$('<li><div class="text">'+d+'</div><div class="count">'+q.count+"</div></li>");d.bind("click",{query:g},v);l.push(d)});return l},w=function(f){if(f.length==0)return h.hide();
|
20
|
+
j.empty();k.hide();i.empty().hide();if(f.length>n){$.each(f.slice(0,n-1),function(l,m){j.append(m)});$.each(f.slice(n-1),function(l,m){i.append(m)});k.show()}else $.each(f,function(l,m){j.append(m)});return h.show()};k.click(function(){k.hide();i.show()});this.hide=s;this.show=function(f){w(A(f.allocations));h.show()}};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.24.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.24.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: picky-client
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.
|
47
|
+
version: 4.24.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.
|
54
|
+
version: 4.24.0
|
55
55
|
description: Generators for Picky.
|
56
56
|
email: florian.hanke+picky-generators@gmail.com
|
57
57
|
executables:
|