picky-generators 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/prototypes/client/sinatra/javascripts/picky.min.js +17 -17
- metadata +10 -10
@@ -1,17 +1,17 @@
|
|
1
|
-
Array.prototype.index=function(b){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(b){for(var
|
3
|
-
"en",g=b.split(".").concat(
|
4
|
-
function PickyData(b){var
|
5
|
-
this.text=
|
6
|
-
|
7
|
-
j.click(function(){
|
8
|
-
d(u)},
|
9
|
-
|
10
|
-
this.searchTextEntered=function(a,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,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(c.keyCode==13)p(a);else{clearInterval(
|
11
|
-
new PickyController(b);var
|
12
|
-
"<strong>$1</strong>"),
|
13
|
-
return
|
14
|
-
(
|
15
|
-
|
16
|
-
"
|
17
|
-
d.show()}else $.each(
|
1
|
+
Array.prototype.index=function(b){for(var e=0,g=this.length;e<g;e++)if(this[e]==b)return e;return null};Array.prototype.include=function(b){return this.index(b)!==null};Array.prototype.remove=function(b){this.splice(b,1);return this};Array.prototype.compare=function(b){return this.join("")==b.join("")};Array.prototype.each=function(b){for(var e=0,g=this.length;e<g;e++)b(e,this[e]);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(b){for(var e=PickyI18n.locale||
|
3
|
+
"en",g=b.split(".").concat(e),f=dictionary,d=0,k=g.length;d<k;d++){f=f[g[d]];if(f==undefined){f="Translation missing: "+b+"."+e;break}}return f};function Allocation(b,e,g,f,d,k){var n=this;this.type=b;this.weight=e;this.count=g;this.combination=f;this.ids=d||[];this.entries=this.rendered=k||[];this.isType=function(r){return r==n.type}}function Allocations(b){this.allocations=[];for(var e=0,g=b.length;e<g;e++){var f=b[e];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(d){return this.allocations.each(d)}}
|
4
|
+
function PickyData(b){var e=b.total,g=b.duration,f=b.offset,d=new Allocations(b.allocations||[]);this.original_hash=b;this.total=e;this.duration=g;this.offset=f;this.allocations=d;this.renderedAmount=function(){var k=0;d.each(function(n,r){k+=r.rendered.length});return k};this.isEmpty=function(){return e==0}};var PickyView=function(b,e){var g=e.showResultsLimit||10,f=$(e.inputSelector||"#picky input.query"),d=$(e.resetSelector||"#picky div.reset"),k=$(e.buttonSelector||"#picky input.search_button"),n=$(e.counterSelector||"#picky div.status"),r=$(e.dashboardSelector||"#picky .dashboard"),u=$(e.resultsSelector||"#picky div.results"),s=$(e.noResultsSelector||"#picky .no_results"),i=new PickyAddination(this,u),o=new PickyAllocationsCloud(this,e),p=new PickyResultsRenderer(i,e),a=function(){d.fadeTo(166,1)},
|
5
|
+
c=function(){o.hide();u.empty();s.hide()},h=function(j){f.val(j);d.fadeTo(166,0);v("empty");n.empty();c()},m=function(){return f.val()};this.text=m;var q=function(j){n.text(j);j>0&&j<=5&&n.fadeTo("fast",0.5).fadeTo("fast",1)},w=function(j){if(j.isEmpty())return"none";if(j.total>g&&j.allocations.length>1)return"support";return"ok"},v=function(j){r.attr("class","dashboard "+j)};this.insert=function(j){f.val(j);f.select()};this.fullResultsCallback=function(j){v(w(j));if(j.isEmpty()){c();q(0);s.show();
|
6
|
+
a()}else if(j.total>g&&j.allocations.length>1){c();a();o.show(j);q(j.total)}else if(j.offset==0){c();q(j.total);p.render(j);u.show();a();f.focus()}else{var y=$("#picky div.results div.addination:last").position().top;i.remove();p.render(j);$("body").animate({scrollTop:y-12},500)}};this.liveResultsCallback=function(j){v(w(j));q(j.total)};this.allocationChosen=function(j){j=j.data.query;f.val(j);b.allocationChosen(j)};this.addinationClicked=function(j){b.addinationClicked(m(),j)};(function(){f.keyup(function(j){if(m()==
|
7
|
+
""){h();b.searchTextCleared()}else{b.searchTextEntered(m(),j);a()}});n.click(function(){m()==""||b.searchButtonClicked(m())});k.click(function(){m()==""||b.searchButtonClicked(m())});d.click(function(){h("");b.clearButtonClicked();f.focus()})})();f.focus()};var PickyBackend=function(b){var e=function(g,f,d){var k=d||{};k=$.extend({query:g},d);$.getJSON(b,k,function(n){f&&f(new PickyData(n))})};this.search=function(g,f,d,k){e(g,function(n){f&&f(k,n)},d)}},LiveBackend=function(b){var e=b.live||alert("A live backend path must be provided."),g=new PickyBackend(e);this.search=function(f,d,k,n){n=n||{};latestRequestTimestamp=new Date;n.live=latestRequestTimestamp;k=$.extend({ids:b.liveResults||0,offset:0},k);g.search(f,function(r,u){if(!r.live||r.live==latestRequestTimestamp)d&&
|
8
|
+
d(u)},k,n)}},FullBackend=function(b){var e=b.full||alert("A full backend path must be provided."),g=new PickyBackend(e);this.search=function(f,d,k,n){n=n||{};latestRequestTimestamp=new Date;n.full=latestRequestTimestamp;k=$.extend({ids:b.fullResults||20,offset:0},k);g.search(f,function(r,u){if(!r.full||r.full==latestRequestTimestamp)d&&d(u)},k,n)}};var PickyController=function(b){var e=new PickyView(this,b),g=b.backends,f=b.before||function(){},d=b.success||function(){},k=b.after||function(){},n=function(a){return(a=a&&a.match(/q=([^&]+)/))&&unescape(a[1]||"")};this.extractQuery=n;var r=function(){var a=window.History&&window.History.getState();return n(a&&a.url)};this.lastQuery=r;var u=function(a,c){a=d(a,c)||a;e.liveResultsCallback(a);k(a,c)},s,i=function(){var a=e.text(),c={};a=f(a,c)||a;var h=g.live;h&&h.search(a,u,c);clearInterval(s)};
|
9
|
+
s=setInterval(i,180);clearInterval(s);var o=function(a,c){a=d(a,c)||a;e.fullResultsCallback(a);k(a,c)},p=function(a,c){var h=c||{};clearInterval(s);if(a!=r()){var m="?q="+escape(a).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,m)}a=f(a,h)||a;(m=g.full)&&m.search(a,o,h)};this.insert=function(a,c,h){e.insert(a);h&&p(a,c)};this.clearButtonClicked=function(){clearInterval(s)};this.searchTextCleared=function(){clearInterval(s)};
|
10
|
+
this.searchTextEntered=function(a,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,79,80,81,82,83,84,85,86,87,88,89,90])>-1)if(c.keyCode==13)p(a);else{clearInterval(s);s=setInterval(i,180)}};this.searchButtonClicked=function(a){p(a)};this.allocationChosen=function(a){p(a)};this.addinationClicked=function(a,c){p(a,{offset:c.data.offset})}};var Localization={},PickyClient=function(b){Localization.qualifiers=b.qualifiers||{};Localization.explanations=b.explanations||{};Localization.choices=b.choices||{};Localization.explanation_delimiters={de:"und",fr:"et",it:"e",en:"and",ch:"und"};var e=b.backends;if(e){e.live||alert("Both a full and live backend must be provided.");e.full||alert("Both a full and live backend must be provided.")}else b.backends={live:new LiveBackend(b),full:new FullBackend(b)};var g=b.controller&&new b.controller(b)||
|
11
|
+
new PickyController(b);var f=this.insert=function(d,k,n){g.insert(d,k||{},n||true)};this.insertFromURL=function(d){if(d&&d!="")f(d);else(d=g.lastQuery())&&f(d)};window.History&&window.History.Adapter.bind(window,"statechange",function(){var d=window.History.getState();(d=g.extractQuery(d.url))&&f(d)})};var PickyAddination=function(b,e){this.remove=function(){e.find(".addination").remove()};this.render=function(g){var f=g.total,d,k=g.renderedAmount();d=g.offset+k;k=d+k;g=g.total;if(g<k)k=g;d={offset:d,start:d+1,end:k};if(d.offset<f){f=$("<div class='addination'>"+t("results.addination.more")+"</div>");f.bind("click",{offset:d.offset},b.addinationClicked);return f}else return""}};var PickyResultsRenderer=function(b,e){var g=$(e.resultsSelector||"#picky div.results"),f=e.wrapResults||'<ol class="results"></ol>',d=["street_number","zipcode"],k=function(i){var o=i[i.length-1];i=i.slice(0,i.length-1);if(i==[])i=[i];if(!d.include(o[0]))if(o[1].match(/[^\*~]$/))o[1]+="*";i.push(o);return i},n=function(i){for(var o=Localization.explanations&&Localization.explanations[PickyI18n.locale]||{},p=[],a,c=0,h=i.length;c<h;c++){a=i[c];var m=a[0];m=o[m]||m;p.push([m,a[1]])}return p},r=function(i,
|
12
|
+
o){return[i.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0]+)/,"<strong>$1</strong>"),o].join(" ")},u=function(i,o){var p=Localization.explanation_delimiters[PickyI18n.locale],a=n(k(o)),c="",h=[];a=$.map(a,function(m){var q=m[0];m=m[1];if(c==""||q==c){m=m.replace(/[\w,]+:(.+)/,"$1");h.push(m);c=q}else{var w=r(c,h.join(" "));h=[];h.push(m);c=q;return w}});a.push(r(c,h.join(" ")));a=a.join(" "+p+" ");return'<span class="explanation">'+i+" "+a+"</span>"},s=function(i,o){var p=
|
13
|
+
'<div class="header">';p+=u(o.type,o.combination);if(i.offset>0)p+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">↑</a></div>';return p};this.render=function(i){i.allocations.each(function(o,p){if(p.entries.length>0){g.append(s(i,p)).append(p.entries.join(""));g.children("li").wrapAll(f)}});g.append(b.render(i))}};function AllocationRenderer(b,e){function g(a){var c={},h={},m=[],q;q=0;for(l=a.length;q<l;q++){var w=a[q][0];if(w in c){c[w]=c[w]+" "+a[q][1];m.push(q)}else{c[w]=a[q][1];h[q]=w}}for(q in h)a[q][1]=c[h[q]];for(q=m.length-1;q>=0;q--)a.remove(m[q]);return a}function f(a){return $.map(a,function(c,h){return"%"+(h+1)+"$s"}).join(" ")}function d(a){if(a.length==0)return"";var c=a=g(a);c.sort(function(x,z){return x[0]<z[0]?-1:1});for(var h=[],m=0,q=c.length;m<q;m++)h.push(c[m][0]);var w=h.length==1,v=o[h]||
|
14
|
+
(o[h]=f(h));if($.type(v)==="string"){o[h]={format:v};v=o[h]}var j=1,y=v.format;$.each(a,function(x,z){var A=z[0],B=z[2];if(v.filter)B=v.filter(B);A=s[A]||A;if(w&&!(v&&v.ignoreSingle))return y=B+" ("+A+")";y=y.replace(RegExp("%"+j+"\\$s","g"),B);j+=1;return j});return y}function k(a){for(var c=[],h=0,m=i.length;h<m;h++)c.push([]);c.push([]);h=0;for(m=a.length;h<m;h++){for(var q=a[h],w=q[0],v=false,j=0,y=i.length;j<y;j++)if(i[j].include(w)){c[j].push(q);v=true;break}v||c[c.length-1].push(q)}var x;
|
15
|
+
for(a=c.length-1;a>=0;a--){x=c[a];if(x.length>0)break}x=x[x.length-1];p.include(x[0])||(x[1]+="...");return $.map(c,function(z){return d(z)})}function n(a){var c=[],h,m;for(m in a){h=a[m][0];h=u[h]||h;c[m]=h+":"+a[m][2]}return c.join(" ")}var r=PickyI18n.locale,u=Localization.qualifiers&&Localization.qualifiers[r]||{},s=Localization.explanations&&Localization.explanations[r]||{},i=e.groups||[],o=Localization.choices&&Localization.choices[r]||{};this.explanation=this.query=this.text="";var p=["street_number",
|
16
|
+
"zipcode"];this.contract=g;this.rendered=d;this.groupify=k;this.querify=n;this.render=function(a){var c=a.combination,h=a.count;a=n(c);c=k(c).join(" ");c=$('<li><div class="text">'+c+'</div><div class="count">'+h+"</div></li>");c.bind("click",{query:a},b);return c}};var PickyAllocationsCloud=function(b,e){var g=$(e.allocationsSelector||"#picky .allocations"),f=g.find(".shown"),d=g.find(".more"),k=g.find(".hidden"),n=function(){g.hide()},r=new AllocationRenderer(function(i){n();b.allocationChosen(i)},e),u=function(i){var o=[];i.each(function(p,a){o.push(r.render(a))});return o},s=function(i){if(i.length==0)return $("#search .allocations").hide();f.empty();d.hide();k.empty().hide();if(i.length>3){$.each(i.slice(0,2),function(o,p){f.append(p)});$.each(i.slice(2),
|
17
|
+
function(o,p){k.append(p)});d.show()}else $.each(i,function(o,p){f.append(p)});return $("#search .allocations").show()};d.click(function(){d.hide();k.show()});this.hide=n;this.show=function(i){s(u(i.allocations));g.show()}};
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70317956669880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,29 +21,29 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70317956669880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: picky
|
27
|
-
requirement: &
|
27
|
+
requirement: &70317956668760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.
|
32
|
+
version: 4.2.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70317956668760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: picky-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &70317956666200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 4.
|
43
|
+
version: 4.2.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70317956666200
|
47
47
|
description: Generators for Picky.
|
48
48
|
email: florian.hanke+picky-generators@gmail.com
|
49
49
|
executables:
|