picky-generators 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/prototypes/client/sinatra/javascripts/history.adapter.jquery.min.js +6 -0
- data/prototypes/client/sinatra/javascripts/history.min.js +6 -0
- data/prototypes/client/sinatra/javascripts/picky.min.js +17 -17
- data/prototypes/client/sinatra/views/search.haml +3 -6
- metadata +6 -5
- data/prototypes/client/sinatra/javascripts/jquery.address-1.3.2.min.js +0 -32
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* History.js jQuery Adapter
|
3
|
+
* @author Benjamin Arthur Lupton
|
4
|
+
* @copyright 2010-2011 Benjamin Arthur Lupton
|
5
|
+
* @license New BSD License - http://creativecommons.org/licenses/BSD/
|
6
|
+
*/(function(a,b,c){b.History=b.History||{};var d=b.History||{},e=b.history;if(typeof d.Adapter!=="undefined")throw new Error("History.js Adapter has already been loaded...");d.Adapter={bind:function(b,c,d){return a(b).bind(c,d)},trigger:function(b,c){return a(b).trigger(c)},onDomLoad:function(a){jQuery(a)}},typeof d.initHtml5!=="undefined"&&d.initHtml5(),typeof d.initHtml4!=="undefined"&&d.initHtml4()})(jQuery,window)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* History.js HTML5 Support
|
3
|
+
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
4
|
+
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
|
5
|
+
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
|
6
|
+
*/(function(a,b){a.History=a.History||{},a._History=a._History||{};var c=a.console||b,d=a.document,e=a._History,f=a.History,g=a.history;if(typeof f.initHtml5!=="undefined")throw new Error("History.js HTML5 Support has already been loaded...");f.initHtml5=function(){if(typeof f.Adapter==="undefined")return!1;f.options={hashChangeCheckerDelay:100,busyDelay:250},f.debug=function(){(f.debug.enable||!1)&&f.log.apply(f,arguments)},f.debug.enable=!1,f.log=function(){var a=typeof c!=="undefined",b=d.getElementById("log"),e="\n"+arguments[0]+"\n",f;if(a){var g=Array.prototype.slice.call(arguments),e=g.shift();typeof c.debug!=="undefined"?c.debug.apply(c,[e,g]):c.log.apply(c,[e,g])}for(f=1,n=arguments.length;f<n;++f){var h=arguments[f];if(typeof h==="object"&&typeof JSON!=="undefined")try{h=JSON.stringify(h)}catch(i){}e+="\n"+h+"\n"}b?(b.value+=e+"\n-----\n",b.scrollTop=b.scrollHeight-b.clientHeight):a||alert(e);return!0},e.getInternetExplorerMajorVersion=function(){var a=e.getInternetExplorerMajorVersion.cached=typeof e.getInternetExplorerMajorVersion.cached!=="undefined"?e.getInternetExplorerMajorVersion.cached:function(){var a,b=3,c=d.createElement("div"),e=c.getElementsByTagName("i");while(c.innerHTML="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->",e[0]);return b>4?b:a}();return a},e.isInternetExplorer=function(){var a=e.isInternetExplorer.cached=typeof e.isInternetExplorer.cached!=="undefined"?e.isInternetExplorer.cached:e.getInternetExplorerMajorVersion()!==0;return a},f.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState)},e.isEmptyObject=function(a){for(var b in a){if(!this.hasOwnProperty(b))continue;return!1}return!0},e.cloneObject=function(a){var b,c;a?(b=JSON.stringify(a),c=JSON.parse(b)):c={};return c},f.contractUrl=function(a){a=f.expandUrl(a);var b=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)b+=":"+d.location.port;b+="/",a=a.replace(b,"/");return a},f.expandUrl=function(a){a=a||"";if(!/[a-z]+\:\/\//.test(a))if(a.length===0||a.substring(0,1)==="?"){var b=d.location.href.replace(/[#\?].*/,"");a=b+a}else{var c=d.getElementsByTagName("base"),e=null,f="";if(c.length===1)e=c[0],f=e.href,f[f.length-1]!=="/"&&(f+="/"),a=f+a.replace(/^\//,"");else if(a.substring(0,1)==="."){var g=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,"");g[g.length-1]!=="/"&&(g+="/"),a=g+a}else{var h=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)h+=":"+d.location.port;h+="/",a=h+a.replace(/^\//,"")}}return a},f.expandState=function(a){a=a||{};var b={data:a.data||{},url:f.expandUrl(a.url||""),title:a.title||""};b.data.title=b.data.title||b.title,b.data.url=b.data.url||b.url;return b},f.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};d=f.expandState(d);return d},f.expandHash=function(a){var b=null;try{b=JSON.parse(a)}catch(c){var d=/(.*)\/uid=([0-9]+)$/.exec(a),g=d?d[1]||a:a,h=d?String(d[2]||""):"";h&&(b=e.getStateByUid(h)||null);if(!b&&/\//.test(a)){var i=f.expandUrl(a);b=f.createStateObject(null,null,i)}}b=b?f.expandState(b):null;return b},f.contractState=function(a){if(!a)return null;var b=null,c=e.cloneObject(a);if(c){c.data=c.data||{},delete c.data.title,delete c.data.url;if(e.isEmptyObject(c)&&!c.title)b=f.contractUrl(c.url);else{b=JSON.stringify(c);var d;if(typeof e.hashesToUids[b]!=="undefined")d=e.hashesToUids[b];else while(!0){d=String(Math.floor(Math.random()*1e3));if(typeof e.uidsToStates[d]==="undefined")break}e.hashesToUids[b]=d,e.uidsToStates[d]=c,b=f.contractUrl(c.url)+"/uid="+d}}return b},e.uidsToStates={},e.hashesToUids={},e.getStateByUid=function(a){a=String(a);var c=e.uidsToStates[a]||b;return c},e.statesByUrl={},e.duplicateStateUrls={},e.statesByHash={},e.savedStates=[],f.getState=function(){return e.getStateByIndex()},f.getStateHash=function(){return f.contractState(f.getState())},e.getStateByUrl=function(a){var c=e.statesByUrl[a]||b;return c},e.getStateByHash=function(a){var c=e.statesByHash[a]||b;return c},e.storeState=function(a){var b=f.contractState(a),c=e.getStateByUrl(a.url);if(typeof c!=="undefined"){var d=f.contractState(c);d!==b&&(e.duplicateStateUrls[a.url]=!0)}e.statesByUrl[a.url]=e.statesByHash[b]=a;return!0},e.isLastState=function(a){var b=f.contractState(a),c=f.getStateHash(),d=e.savedStates.length&&b===c;return d},e.saveState=function(a){if(e.isLastState(a))return!1;e.savedStates.push(a);return!0},e.getStateByIndex=function(a){var b=null;typeof a==="undefined"?b=e.savedStates[e.savedStates.length-1]:a<0?b=e.savedStates[e.savedStates.length+a]:b=e.savedStates[a];return b},e.stateUrlExists=function(a){var b=typeof e.statesByUrl[a]!=="undefined";return b},e.urlDuplicateExists=function(a){var b=typeof e.duplicateStateUrls[a]!=="undefined";return b},f.getHash=function(){var a=e.unescapeHash(d.location.hash);return a},e.unescapeHash=function(a){var b=e.normalizeHash(a);/[\%]/.test(b)&&(b=unescape(b));return b},e.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},f.setHash=function(a,b){if(b!==!1&&f.busy()){f.debug("History.setHash: we must wait",arguments),f.pushQueue({scope:f,callback:f.setHash,args:arguments,queue:b});return!1}var c=e.escapeHash(a);f.debug("History.setHash",this,arguments,"hash:",a,"adjustedHash:",c,"oldHash:",d.location.hash),f.busy(!0),d.location.hash=c;return a},e.escapeHash=function(a){var b=e.normalizeHash(a);/[^a-zA-Z0-9\/\-\_\%\.]/.test(b)&&(b=escape(b));return b},f.extractHashFromUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");b=e.unescapeHash(b);return b},f.isTraditionalAnchor=function(a){var b=f.extractHashFromUrl(a),c=d.getElementById(b),e=typeof c!=="undefined";return e},f.queues=[],f.busy=function(a){f.debug("History.busy: called: changing ["+(f.busy.flag||!1)+"] to ["+(a||!1)+"]",f.queues),typeof a!=="undefined"?f.busy.flag=a:typeof f.busy.flag==="undefined"&&(f.busy.flag=!1);if(!f.busy.flag){clearTimeout(f.busy.timeout);var b=function(){if(!f.busy.flag)for(var a=f.queues.length-1;a>=0;--a){var c=f.queues[a];if(c.length===0)continue;var d=c.shift();f.debug("History.busy: firing",d),f.fireQueueItem(d),f.busy.timeout=setTimeout(b,f.options.busyDelay)}};f.busy.timeout=setTimeout(b,f.options.busyDelay)}return f.busy.flag},f.fireQueueItem=function(a){return a.callback.apply(a.scope||f,a.args||[])},f.pushQueue=function(a){f.debug("History.pushQueue: called",arguments),f.queues[a.queue||0]=f.queues[a.queue||0]||[],f.queues[a.queue||0].push(a);return!0},f.queue=function(a,b){typeof a==="function"&&(a={callback:a}),typeof b!=="undefined"&&(a.queue=b),f.busy()?f.pushQueue(a):f.fireQueueItem(a);return!0},f.back=function(a){f.debug("History.back: called",arguments);if(a!==!1&&f.busy()){f.debug("History.back: we must wait",arguments),f.pushQueue({scope:f,callback:f.back,args:arguments,queue:a});return!1}f.busy(!0);if(f.emulated.hashChange&&e.isInternetExplorer()){var b=f.getHash();setTimeout(function(){var a=f.getHash();if(a===b){f.debug("History.back: trying again");return f.back(!1)}return!0},f.options.hashChangeCheckerDelay*5)}g.go(-1);return!0},f.forward=function(a){f.debug("History.forward: called",arguments);if(a!==!1&&f.busy()){f.debug("History.forward: we must wait",arguments),f.pushQueue({scope:f,callback:f.forward,args:arguments,queue:a});return!1}f.busy(!0);if(f.emulated.hashChange&&e.isInternetExplorer()){var b=f.getHash();setTimeout(function(){var a=f.getHash();if(a===b){f.debug("History.forward: trying again");return f.forward(!1)}return!0},f.options.hashChangeCheckerDelay*5)}g.go(1);return!0},f.go=function(a,b){f.debug("History.go: called",arguments);if(a>0)for(var c=1;c<=a;++c)f.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(var c=-1;c>=a;--c)f.back(b)}return!0},f.emulated.pushState||(e.onPopState=function(b){f.debug("_History.onPopState",this,arguments);var c=unescape(f.getHash());if(c){var g=f.expandHash(c);g?(f.debug("_History.onPopState: state anchor",c,g),f.replaceState(g.data,g.tite,g.url,!1)):(f.debug("_History.onPopState: traditional anchor",c),f.Adapter.trigger(a,"anchorchange"),f.busy(!1));return!1}var h=null,i={},j=null,k=null,l=null;b=b||{},typeof b.state==="undefined"&&(typeof b.originalEvent!=="undefined"&&typeof b.originalEvent.state!=="undefined"?b.state=b.originalEvent.state:typeof b.event!=="undefined"&&typeof b.event.state!=="undefined"&&(b.state=b.event.state));if(b.state===null)i=b.state;else if(typeof b.state!=="undefined"){var m=f.expandUrl(d.location.href),n=e.getStateByUrl(m),o=e.urlDuplicateExists(m);typeof n!=="undefined"&&!o?i=n.data:i=b.state}else{var m=f.expandUrl(d.location.href),n=e.getStateByUrl(m);if(n&&m==n.url)i=n.data;else throw new Error("Unknown state")}i=typeof i!=="object"||i===null?{}:i,j=i.title||"",k=i.url||d.location.href,l=f.createStateObject(i,j,k);if(e.isLastState(l)){f.debug("_History.onPopState: no change",l,e.savedStates),f.busy(!1);return!1}f.debug("_History.onPopState","newState:",l,"oldState:",e.getStateByUrl(f.expandUrl(d.location.href)),"duplicateExists:",e.urlDuplicateExists(f.expandUrl(d.location.href))),e.storeState(l),e.saveState(l),l.title&&(d.title=l.title),f.Adapter.trigger(a,"statechange"),f.busy(!1);return!0},f.Adapter.bind(a,"popstate",e.onPopState),f.pushState=function(b,c,d,h){if(f.extractHashFromUrl(d))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(h!==!1&&f.busy()){f.debug("History.pushState: we must wait",arguments),f.pushQueue({scope:f,callback:f.pushState,args:arguments,queue:h});return!1}f.busy(!0);var i=f.createStateObject(b,c,d);e.storeState(i),g.pushState(i.data,i.title,i.url),f.Adapter.trigger(a,"popstate");return!0},f.replaceState=function(b,c,d,h){if(f.extractHashFromUrl(d))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(h!==!1&&f.busy()){f.debug("History.replaceState: we must wait",arguments),f.pushQueue({scope:f,callback:f.replaceState,args:arguments,queue:h});return!1}f.busy(!0);var i=f.createStateObject(b,c,d);e.storeState(i),g.replaceState(i.data,i.title,i.url),f.Adapter.trigger(a,"popstate");return!0},navigator.vendor==="Apple Computer, Inc."&&(f.Adapter.onDomLoad(function(){f.debug("Safari Initial State Change Fix");var a=f.createStateObject({},"",d.location.href);f.pushState(a.data,a.title,a.url)}),f.Adapter.bind(a,"hashchange",function(){f.Adapter.trigger(a,"popstate")})))},f.initHtml5()})(window)
|
@@ -1,17 +1,17 @@
|
|
1
|
-
Array.prototype.index=function(
|
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(
|
3
|
-
"en",
|
4
|
-
function PickyData(
|
5
|
-
this.text=
|
6
|
-
|
7
|
-
""||
|
8
|
-
this.search=function(
|
9
|
-
f)||
|
10
|
-
function(
|
11
|
-
new FullBackend(
|
12
|
-
"<strong>$1</strong>"),
|
13
|
-
return
|
14
|
-
(
|
15
|
-
for(
|
16
|
-
"zipcode"];this.contract=
|
17
|
-
e.show()}else $.each(
|
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
|
+
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,o=g.length;e<o;e++){d=d[g[e]];if(d==undefined){d="Translation missing: "+c+"."+i;break}}return d};function Allocation(c,i,g,d,e,o){var m=this;this.type=c;this.weight=i;this.count=g;this.combination=d;this.ids=e||[];this.entries=this.rendered=o||[];this.isType=function(s){return s==m.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"),o=$("#picky input.search_button"),m=$("#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");m.empty();b()},n=function(){return d.val()};
|
5
|
+
this.text=n;var q=function(h){m.text(h);h>0&&h<=5&&m.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(n(),h)};(function(){d.keyup(function(h){if(n()==""){f();c.searchTextCleared()}else{c.searchTextEntered(n(),h);a()}});m.click(function(){n()==""||c.searchButtonClicked(n())});o.click(function(){n()==
|
7
|
+
""||c.searchButtonClicked(n())});e.click(function(){f("");c.clearButtonClicked();d.focus()})})();d.focus()};var PickyBackend=function(c){var i=function(g,d,e,o){var m=o||{};m=$.extend({query:g,offset:e},o);$.getJSON(c,m,function(s){d&&d(new PickyData(s))})};this.search=function(g,d,e,o,m){i(g,function(s){d&&d(m,s)},e,o)}},LiveBackend=function(c){var i=new PickyBackend(c);this.search=function(g,d,e,o,m){m=m||{};latestRequestTimestamp=new Date;m.live=latestRequestTimestamp;i.search(g,function(s,u){if(!s.live||s.live==latestRequestTimestamp)d&&d(u)},e,o,m)}},FullBackend=function(c){var i=new PickyBackend(c);
|
8
|
+
this.search=function(g,d,e,o,m){m=m||{};latestRequestTimestamp=new Date;m.full=latestRequestTimestamp;i.search(g,function(s,u){if(!s.full||s.full==latestRequestTimestamp)d&&d(u)},e,o,m)}};var PickyController=function(c){var i=new PickyView(this,c),g=c.backends,d=c.before||function(){},e=c.success||function(){},o=c.after||function(){},m=function(a){return(a=a&&a.match(/q=([^&]+)/))&&unescape(a[1]||"")};this.extractQuery=m;var s=function(){var a=window.History&&window.History.getState();return m(a&&a.url)};this.lastQuery=s;var u=function(a,b){a=e(a,b)||a;i.liveResultsCallback(a);o(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);o(a,b)},p=function(a,b,f){f=f||{};b=b||0;clearInterval(j);if(a!=s()){var n="?q="+a;window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,n)}f=d(f,a,b)||f;(n=g.full)&&n.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=function(a,b){if($.inArray(b.keyCode,
|
10
|
+
[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,o){g.insert(e,o||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 o=e+20;g=g.total;if(g<o)o=g;e={offset:e,start:e+1,end:o};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},o=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},m=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=o(e(k)),a="",b=[];p=$.map(p,function(f){var n=f[0];f=f[1];if(a==""||n==a){b.push(f);a=n}else{var q=m(a,b.join(" "));b=[];b.push(f);a=n;return q}});p.push(m(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);">↑</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={},n=[],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];n.push(q)}else{b[w]=a[q][1];f[q]=w}}for(q in f)a[q][1]=b[f[q]];for(q=n.length-1;q>=0;q--)a.remove(n[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=[],n=0,q=b.length;n<q;n++)f.push(b[n][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+" ("+A+")";z=z.replace(RegExp("%"+h+"\\$s","g"),B);h+=1;return h});return z}function o(a){for(var b=[],f=0,n=k.length;f<n;f++)b.push([]);b.push([]);f=0;for(n=a.length;f<n;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 m(a){var b=[],f,n;for(n in a){f=a[n][0];f=u[f]||f;b[n]=f+":"+a[n][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=o;this.querify=m;this.render=function(a){var b=a.combination,f=a.count;a=m(b);b=o(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"),o=g.find(".hidden"),m=function(){g.hide()},s=new AllocationRenderer(function(k){m();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();o.empty().hide();if(k.length>3){$.each(k.slice(0,2),function(r,p){d.append(p)});$.each(k.slice(2),function(r,p){o.append(p)});
|
17
|
+
e.show()}else $.each(k,function(r,p){d.append(p)});return $("#search .allocations").show()};e.click(function(){e.hide();o.show()});this.hide=m;this.show=function(k){j(u(k.allocations));g.show()}};
|
@@ -3,11 +3,11 @@
|
|
3
3
|
%head
|
4
4
|
%link{:href => "stylesheets/picky.css", :media => "screen", :rel => "stylesheet", :type => "text/css"}/
|
5
5
|
%link{:href => "stylesheets/application.css", :media => "screen", :rel => "stylesheet", :type => "text/css"}/
|
6
|
-
|
7
6
|
= js 'jquery-1.5.0.min'
|
8
|
-
= js '
|
9
|
-
|
7
|
+
= js 'history.min'
|
8
|
+
= js 'history.adapter.jquery.min'
|
10
9
|
= js 'picky.min'
|
10
|
+
|
11
11
|
%body
|
12
12
|
%img{:src => "images/picky.png"}/
|
13
13
|
%p
|
@@ -130,8 +130,5 @@
|
|
130
130
|
//
|
131
131
|
// Example: www.mysearch.com/?q=example
|
132
132
|
//
|
133
|
-
// If there isn't a q parameter (because it is empty), we try to
|
134
|
-
// take it from the deep linking /#/?q parameter.
|
135
|
-
//
|
136
133
|
pickyClient.insertFromURL('#{@query}');
|
137
134
|
});
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: picky-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.5.
|
5
|
+
version: 1.5.4
|
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-03-
|
13
|
+
date: 2011-03-15 00:00:00 +01:00
|
14
14
|
default_executable: picky-generate
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.5.
|
35
|
+
version: 1.5.4
|
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.5.
|
46
|
+
version: 1.5.4
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
description: Generators for Picky.
|
@@ -67,8 +67,9 @@ files:
|
|
67
67
|
- prototypes/client/sinatra/config.ru
|
68
68
|
- prototypes/client/sinatra/Gemfile
|
69
69
|
- prototypes/client/sinatra/images/picky.png
|
70
|
+
- prototypes/client/sinatra/javascripts/history.adapter.jquery.min.js
|
71
|
+
- prototypes/client/sinatra/javascripts/history.min.js
|
70
72
|
- prototypes/client/sinatra/javascripts/jquery-1.5.0.min.js
|
71
|
-
- prototypes/client/sinatra/javascripts/jquery.address-1.3.2.min.js
|
72
73
|
- prototypes/client/sinatra/javascripts/picky.min.js
|
73
74
|
- prototypes/client/sinatra/library.csv
|
74
75
|
- prototypes/client/sinatra/stylesheets/application.css
|
@@ -1,32 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery Address Plugin v1.3.2
|
3
|
-
* http://www.asual.com/jquery/address/
|
4
|
-
*
|
5
|
-
* Copyright (c) 2009-2010 Rostislav Hristov
|
6
|
-
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
-
* http://jquery.org/license
|
8
|
-
*
|
9
|
-
* Date: 2011-02-04 12:34:19 +0200 (Fri, 04 Feb 2011)
|
10
|
-
*/
|
11
|
-
(function(c){c.address=function(){var z=function(a){c(c.address).trigger(c.extend(c.Event(a),function(){for(var b={},e=c.address.parameterNames(),h=0,q=e.length;h<q;h++)b[e[h]]=c.address.parameter(e[h]);return{value:c.address.value(),path:c.address.path(),pathNames:c.address.pathNames(),parameterNames:e,parameters:b,queryString:c.address.queryString()}}.call(c.address)))},A=function(a,b,e){c(c.address).bind(a,b,e);return c.address},C=function(){return B.pushState&&d.state!==i},u=function(){return("/"+
|
12
|
-
g.pathname.replace(new RegExp(d.state),"")+g.search+(K()?"#"+K():"")).replace(ba,"/")},K=function(){var a=g.href.indexOf("#");return a!=-1?D(g.href.substr(a+1),l):""},w=function(){return C()?u():K()},va=function(){return"javascript"},r=function(a){a=a.toString();return(d.strict&&a.substr(0,1)!="/"?"/":"")+a},D=function(a,b){if(d.crawlable&&b)return(a!=""?"!":"")+a;return a.replace(/^\!/,"")},E=function(a,b){return parseInt(a.css(b),10)},ca=function(a){for(var b,e,h=0,q=a.childNodes.length;h<q;h++){if(a.childNodes[h].src)b=
|
13
|
-
String(a.childNodes[h].src);if(e=ca(a.childNodes[h]))b=e}return b},O=function(){if(!T){var a=w(),b=f!=a;if(F&&p<523){if(L!=B.length){L=B.length;if(J[L-1]!==i)f=J[L-1];M(l)}}else if(b)if(G&&p<7)g.reload();else{G&&p<8&&d.history&&x(W,50);f=a;M(l)}}},M=function(a){z(da);z(a?ea:fa);x(ga,10)},ga=function(){if(d.tracker!=="null"&&d.tracker!==null){var a=c.isFunction(d.tracker)?d.tracker:k[d.tracker],b=(g.pathname+g.search+(c.address&&!C()?c.address.value():"")).replace(/\/\//,"/").replace(/^\/$/,"");if(c.isFunction(a))a(b);
|
14
|
-
else if(c.isFunction(k.urchinTracker))k.urchinTracker(b);else if(k.pageTracker!==i&&c.isFunction(k.pageTracker._trackPageview))k.pageTracker._trackPageview(b);else k._gaq!==i&&c.isFunction(k._gaq.push)&&k._gaq.push(["_trackPageview",decodeURI(b)])}},W=function(){var a=va()+":"+l+";document.open();document.writeln('<html><head><title>"+n.title.replace("'","\\'")+"</title><script>var "+s+' = "'+encodeURIComponent(w())+(n.domain!=g.hostname?'";document.domain="'+n.domain:"")+"\";<\/script></head></html>');document.close();";
|
15
|
-
if(p<7)o.src=a;else o.contentWindow.location.replace(a)},ia=function(){if(P&&ha!=-1){var a,b=P.substr(ha+1).split("&");for(v=0;v<b.length;v++){a=b[v].split("=");if(/^(autoUpdate|crawlable|history|strict|wrap)$/.test(a[0]))d[a[0]]=isNaN(a[1])?/^(true|yes)$/i.test(a[1]):parseInt(a[1],10)!==0;if(/^(state|tracker)$/.test(a[0]))d[a[0]]=a[1]}P=null}f=w()},ka=function(){if(!ja){ja=m;ia();var a=function(){wa.call(this);xa.call(this)},b=c("body").ajaxComplete(a);a();if(d.wrap){c("body > *").wrapAll('<div style="padding:'+
|
16
|
-
(E(b,"marginTop")+E(b,"paddingTop"))+"px "+(E(b,"marginRight")+E(b,"paddingRight"))+"px "+(E(b,"marginBottom")+E(b,"paddingBottom"))+"px "+(E(b,"marginLeft")+E(b,"paddingLeft"))+'px;" />').parent().wrap('<div id="'+s+'" style="height:100%;overflow:auto;position:relative;'+(F?window.statusbar.visible&&!/chrome/i.test(X)?"":"resize:both;":"")+'" />');c("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"});F&&c('<style type="text/css" />').appendTo("head").text("#"+s+"::-webkit-resizer { background-color: #fff; }")}if(G&&
|
17
|
-
p<8){a=n.getElementsByTagName("frameset")[0];o=n.createElement((a?"":"i")+"frame");if(a){a.insertAdjacentElement("beforeEnd",o);a[a.cols?"cols":"rows"]+=",0";o.noResize=m;o.frameBorder=o.frameSpacing=0}else{o.style.display="none";o.style.width=o.style.height=0;o.tabIndex=-1;n.body.insertAdjacentElement("afterBegin",o)}x(function(){c(o).bind("load",function(){var e=o.contentWindow;f=e[s]!==i?c.address.decode(e[s]):"";if(f!=w()){M(l);g.hash=D(f,m)}});o.contentWindow[s]===i&&W()},50)}else if(F){if(p<
|
18
|
-
418){c(n.body).append('<form id="'+s+'" style="position:absolute;top:-9999px;" method="get"></form>');Y=n.getElementById(s)}if(g[s]===i)g[s]={};if(g[s][g.pathname]!==i)J=g[s][g.pathname].split(",")}x(function(){z("init");M(l)},1);if(!C())if(G&&p>7||!G&&"on"+Q in k)if(k.addEventListener)k.addEventListener(Q,O,l);else k.attachEvent&&k.attachEvent("on"+Q,O);else ya(O,50)}},wa=function(){var a,b=c("a"),e=b.size(),h=-1;x(function(){if(++h!=e){a=c(b.get(h));a.is('[rel*="address:"]')&&a.address();x(arguments.callee,
|
19
|
-
1)}},1)},za=function(){if(f!=w()){f=w();M(l)}},Aa=function(){if(k.removeEventListener)k.removeEventListener(Q,O,l);else k.detachEvent&&k.detachEvent("on"+Q,O)},xa=function(){if(d.crawlable){var a=g.pathname.replace(/\/$/,"");c("body").html().indexOf("_escaped_fragment_")!=-1&&c("a[href]:not([href^=http]), , a[href*="+document.domain+"]").each(function(){var b=c(this).attr("href").replace(/^http:/,"").replace(new RegExp(a+"/?$"),"");if(b==""||b.indexOf("_escaped_fragment_")!=-1)c(this).attr("href",
|
20
|
-
"#"+c.address.decode(b.replace(/\/(.*)\?_escaped_fragment_=(.*)$/,"!$2")))})}},la=function(a){return a.replace(/\+/g," ")},H=function(a){return ma(na(a)).replace(/%20/g,"+")},oa=function(a){return a.split("#")[0].split("?")[0]},pa=function(a){a=oa(a);var b=a.replace(ba,"/").split("/");if(a.substr(0,1)=="/"||a.length===0)b.splice(0,1);a.substr(a.length-1,1)=="/"&&b.splice(b.length-1,1);return b},R=function(a){a=a.split("?");return a.slice(1,a.length).join("?").split("#")[0]},qa=function(a,b){if(b=
|
21
|
-
R(b)){params=b.split("&");b=[];for(v=0;v<params.length;v++){var e=params[v].split("=");if(e[0]==a||c.address.decode(e[0])==a)b.push(e.slice(1).join("="))}if(b.length!==0)return b.length!=1?b:b[0]}},ra=function(a){var b=R(a);a=[];if(b&&b.indexOf("=")!=-1){b=b.split("&");for(var e=0;e<b.length;e++){var h=b[e].split("=")[0];c.inArray(h,a)==-1&&a.push(h)}}return a},U=function(a){a=a.split("#");return a.slice(1,a.length).join("#")},i,s="jQueryAddress",Q="hashchange",da="change",ea="internalChange",fa=
|
22
|
-
"externalChange",m=true,l=false,d={autoUpdate:m,crawlable:l,history:m,strict:m,wrap:l},t=c.browser,p=parseFloat(c.browser.version),sa=t.mozilla,G=t.msie,ta=t.opera,F=t.webkit||t.safari,Z=l,k=function(){try{return top.document!==i?top:window}catch(a){return window}}(),n=k.document,B=k.history,g=k.location,ya=setInterval,x=setTimeout,ma=encodeURIComponent,na=decodeURIComponent,ba=/\/{2,9}/g,X=navigator.userAgent,o,Y,P=ca(document),ha=P?P.indexOf("?"):-1,$=n.title,L=B.length,T=l,ja=l,aa=m,ua=m,V=l,J=
|
23
|
-
[],f=w();if(G){p=parseFloat(X.substr(X.indexOf("MSIE")+4));if(n.documentMode&&n.documentMode!=p)p=n.documentMode!=8?7:8;c(document).bind("propertychange",function(){if(n.title!=$&&n.title.indexOf("#"+w())!=-1)n.title=$})}if(Z=sa&&p>=1||G&&p>=6||ta&&p>=9.5||F&&p>=312){for(var v=1;v<L;v++)J.push("");J.push(f);if(ta)history.navigationMode="compatible";if(document.readyState=="complete")var Ba=setInterval(function(){if(c.address){ka();clearInterval(Ba)}},50);else{ia();c(ka)}t=u();if(d.state!==i)if(B.pushState)t.substr(0,
|
24
|
-
3)=="/#/"&&g.replace(d.state.replace(/^\/$/,"")+t.substr(2));else t!="/"&&t.replace(/^\/#/,"")!=K()&&g.replace(d.state.replace(/^\/$/,"")+"/#"+t);c(window).bind({popstate:za,unload:Aa})}else!Z&&K()!=""||F&&p<418&&K()!=""&&g.search!=""?g.replace(g.href.substr(0,g.href.indexOf("#"))):ga();return{bind:function(a,b,e){return A(a,b,e)},init:function(a){return A("init",a)},change:function(a){return A(da,a)},internalChange:function(a){return A(ea,a)},externalChange:function(a){return A(fa,a)},baseURL:function(){var a=
|
25
|
-
g.href;if(a.indexOf("#")!=-1)a=a.substr(0,a.indexOf("#"));if(/\/$/.test(a))a=a.substr(0,a.length-1);return a},autoUpdate:function(a){if(a!==i){d.autoUpdate=a;return this}return d.autoUpdate},crawlable:function(a){if(a!==i){d.crawlable=a;return this}return d.crawlable},history:function(a){if(a!==i){d.history=a;return this}return d.history},state:function(a){if(a!==i){d.state=a;return this}return d.state},strict:function(a){if(a!==i){d.strict=a;return this}return d.strict},tracker:function(a){if(a!==
|
26
|
-
i){d.tracker=a;return this}return d.tracker},wrap:function(a){if(a!==i){d.wrap=a;return this}return d.wrap},update:function(){V=m;this.value(f);V=l;return this},encode:function(a){var b=pa(a),e=ra(a),h=R(a),q=U(a),I=a.substr(0,1),N=a.substr(a.length-1),j="";c.each(b,function(y,S){j+="/"+H(S)});if(h!==""){j+="?";if(e.length===0)j+=h;else{c.each(e,function(y,S){y=qa(S,a);if(typeof y!=="string")c.each(y,function(Da,Ca){j+=H(S)+"="+H(Ca)+"&"});else j+=H(S)+"="+H(y)+"&"});j=j.substr(0,j.length-1)}}if(q!==
|
27
|
-
"")j+="#"+H(q);if(I!="/"&&j.substr(0,1)=="/")j=j.substr(1);if(I=="/"&&j.substr(0,1)!="/")j="/"+j;if(/#|&|\?/.test(N))j+=N;return j},decode:function(a){if(a!==i){var b=[],e=function(I){return na(I.toString().replace(/\+/g,"%20"))};if(typeof a=="object"&&a.length!==i){for(var h=0,q=a.length;h<q;h++)b[h]=e(a[h]);return b}else return e(a)}},title:function(a){if(a!==i){x(function(){$=n.title=a;if(ua&&o&&o.contentWindow&&o.contentWindow.document){o.contentWindow.document.title=a;ua=l}if(!aa&&sa)g.replace(g.href.indexOf("#")!=
|
28
|
-
-1?g.href:g.href+"#");aa=l},50);return this}return n.title},value:function(a){if(a!==i){a=r(a);if(d.autoUpdate)a=this.encode(a);if(a=="/")a="";if(f==a&&!V)return;aa=m;f=a;if(d.autoUpdate||V){M(m);if(C())B[d.history?"pushState":"replaceState"]({},"",d.state.replace(/\/$/,"")+(f==""?"/":f));else{T=m;J[B.length]=f;if(F)if(d.history){g[s][g.pathname]=J.toString();L=B.length+1;if(p<418){if(g.search==""){Y.action="#"+D(f,m);Y.submit()}}else if(p<523||f==""){a=n.createEvent("MouseEvents");a.initEvent("click",
|
29
|
-
m,m);var b=n.createElement("a");b.href="#"+D(f,m);b.dispatchEvent(a)}else g.hash="#"+D(f,m)}else g.replace("#"+D(f,m));else if(f!=w())if(d.history)g.hash="#"+D(this.decode(r(f)),m);else g.replace("#"+D(f,m));G&&p<8&&d.history&&x(W,50);if(F)x(function(){T=l},1);else T=l}}return this}if(!Z)return null;return this.decode(r(f))},path:function(a){if(a!==i){var b=R(r(f)),e=U(r(f));this.value(a+(b?"?"+b:"")+(e?"#"+e:""));return this}return this.decode(oa(r(f)))},pathNames:function(){return this.decode(pa(r(f)))},
|
30
|
-
queryString:function(a){if(a!==i){var b=U(r(f));this.value(this.path()+(a?"?"+a:"")+(b?"#"+b:""));return this}return this.decode(R(r(f)))},parameter:function(a,b,e){var h,q;if(b!==i){var I=this.parameterNames();q=[];b=b?ma(b):"";for(h=0;h<I.length;h++){var N=I[h],j=this.parameter(N);if(typeof j=="string")j=[j];if(N==a)j=b===null||b===""?[]:e?j.concat([b]):[b];for(var y=0;y<j.length;y++)q.push(N+"="+la(H(j[y])))}c.inArray(a,I)==-1&&b!==null&&b!==""&&q.push(a+"="+la(H(b)));this.queryString(q.join("&"));
|
31
|
-
return this}return this.decode(qa(a,r(f)))},parameterNames:function(){return this.decode(ra(r(f)))},hash:function(a){if(a!==i){this.value(r(f).split("#")[0]+(a?"#"+a:""));return this}return this.decode(U(r(f)))}}}();c.fn.address=function(z){if(!c(this).attr("address")){var A=function(C){if(c(this).is("a")){var u=z?z.call(this):/address:/.test(c(this).attr("rel"))?c(this).attr("rel").split("address:")[1].split(" ")[0]:c.address.state()!==undefined&&c.address.state()!="/"?c(this).attr("href").replace(new RegExp("^(.*"+
|
32
|
-
c.address.state()+"|\\.)"),""):c(this).attr("href").replace(/^(#\!?|\.)/,"");c.address.value(u);C.preventDefault()}};c(this).click(A).live("click",A).live("submit",function(C){if(c(this).is("form")){var u=c(this).attr("action");u=z?z.call(this):(u.indexOf("?")!=-1?u.replace(/&$/,""):u+"?")+c.address.decode(c(this).serialize());c.address.value(u);C.preventDefault()}}).attr("address",true)}return this}})(jQuery);
|