picky-client 4.8.1 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/javascripts/history.min.js +2 -6
- data/javascripts/picky.min.js +19 -19
- data/lib/picky-client/helper.rb +8 -12
- metadata +2 -2
data/javascripts/history.min.js
CHANGED
@@ -1,6 +1,2 @@
|
|
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
|
+
// 1.7.1-r2 https://github.com/balupton/history.js/blob/master/scripts/bundled/html4%2Bhtml5/jquery.history.js
|
2
|
+
window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(),function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()}(window),function(a,b){"use strict";var c=a.document,d=a.setTimeout||d,e=a.clearTimeout||e,f=a.setInterval||f,g=a.History=a.History||{};if(typeof g.initHtml4!="undefined")throw new Error("History.js HTML4 Support has already been loaded...");g.initHtml4=function(){if(typeof g.initHtml4.initialized!="undefined")return!1;g.initHtml4.initialized=!0,g.enabled=!0,g.savedHashes=[],g.isLastHash=function(a){var b=g.getHashByIndex(),c;return c=a===b,c},g.saveHash=function(a){return g.isLastHash(a)?!1:(g.savedHashes.push(a),!0)},g.getHashByIndex=function(a){var b=null;return typeof a=="undefined"?b=g.savedHashes[g.savedHashes.length-1]:a<0?b=g.savedHashes[g.savedHashes.length+a]:b=g.savedHashes[a],b},g.discardedHashes={},g.discardedStates={},g.discardState=function(a,b,c){var d=g.getHashByState(a),e;return e={discardedState:a,backState:c,forwardState:b},g.discardedStates[d]=e,!0},g.discardHash=function(a,b,c){var d={discardedHash:a,backState:c,forwardState:b};return g.discardedHashes[a]=d,!0},g.discardedState=function(a){var b=g.getHashByState(a),c;return c=g.discardedStates[b]||!1,c},g.discardedHash=function(a){var b=g.discardedHashes[a]||!1;return b},g.recycleState=function(a){var b=g.getHashByState(a);return g.discardedState(a)&&delete g.discardedStates[b],!0},g.emulated.hashChange&&(g.hashChangeInit=function(){g.checkerFunction=null;var b="",d,e,h,i;return g.isInternetExplorer()?(d="historyjs-iframe",e=c.createElement("iframe"),e.setAttribute("id",d),e.style.display="none",c.body.appendChild(e),e.contentWindow.document.open(),e.contentWindow.document.close(),h="",i=!1,g.checkerFunction=function(){if(i)return!1;i=!0;var c=g.getHash()||"",d=g.unescapeHash(e.contentWindow.document.location.hash)||"";return c!==b?(b=c,d!==c&&(h=d=c,e.contentWindow.document.open(),e.contentWindow.document.close(),e.contentWindow.document.location.hash=g.escapeHash(c)),g.Adapter.trigger(a,"hashchange")):d!==h&&(h=d,g.setHash(d,!1)),i=!1,!0}):g.checkerFunction=function(){var c=g.getHash();return c!==b&&(b=c,g.Adapter.trigger(a,"hashchange")),!0},g.intervalList.push(f(g.checkerFunction,g.options.hashChangeInterval)),!0},g.Adapter.onDomLoad(g.hashChangeInit)),g.emulated.pushState&&(g.onHashChange=function(b){var d=b&&b.newURL||c.location.href,e=g.getHashByUrl(d),f=null,h=null,i=null,j;return g.isLastHash(e)?(g.busy(!1),!1):(g.doubleCheckComplete(),g.saveHash(e),e&&g.isTraditionalAnchor(e)?(g.Adapter.trigger(a,"anchorchange"),g.busy(!1),!1):(f=g.extractState(g.getFullUrl(e||c.location.href,!1),!0),g.isLastSavedState(f)?(g.busy(!1),!1):(h=g.getHashByState(f),j=g.discardedState(f),j?(g.getHashByIndex(-2)===g.getHashByState(j.forwardState)?g.back(!1):g.forward(!1),!1):(g.pushState(f.data,f.title,f.url,!1),!0))))},g.Adapter.bind(a,"hashchange",g.onHashChange),g.pushState=function(b,d,e,f){if(g.getHashByUrl(e))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(f!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.pushState,args:arguments,queue:f}),!1;g.busy(!0);var h=g.createStateObject(b,d,e),i=g.getHashByState(h),j=g.getState(!1),k=g.getHashByState(j),l=g.getHash();return g.storeState(h),g.expectedStateId=h.id,g.recycleState(h),g.setTitle(h),i===k?(g.busy(!1),!1):i!==l&&i!==g.getShortUrl(c.location.href)?(g.setHash(i,!1),!1):(g.saveState(h),g.Adapter.trigger(a,"statechange"),g.busy(!1),!0)},g.replaceState=function(a,b,c,d){if(g.getHashByUrl(c))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(d!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.replaceState,args:arguments,queue:d}),!1;g.busy(!0);var e=g.createStateObject(a,b,c),f=g.getState(!1),h=g.getStateByIndex(-2);return g.discardState(f,e,h),g.pushState(e.data,e.title,e.url,!1),!0}),g.emulated.pushState&&g.getHash()&&!g.emulated.hashChange&&g.Adapter.onDomLoad(function(){g.Adapter.trigger(a,"hashchange")})},typeof g.init!="undefined"&&g.init()}(window),function(a,b){"use strict";var c=a.console||b,d=a.document,e=a.navigator,f=a.sessionStorage||!1,g=a.setTimeout,h=a.clearTimeout,i=a.setInterval,j=a.clearInterval,k=a.JSON,l=a.alert,m=a.History=a.History||{},n=a.history;k.stringify=k.stringify||k.encode,k.parse=k.parse||k.decode;if(typeof m.init!="undefined")throw new Error("History.js Core has already been loaded...");m.init=function(){return typeof m.Adapter=="undefined"?!1:(typeof m.initCore!="undefined"&&m.initCore(),typeof m.initHtml4!="undefined"&&m.initHtml4(),!0)},m.initCore=function(){if(typeof m.initCore.initialized!="undefined")return!1;m.initCore.initialized=!0,m.options=m.options||{},m.options.hashChangeInterval=m.options.hashChangeInterval||100,m.options.safariPollInterval=m.options.safariPollInterval||500,m.options.doubleCheckInterval=m.options.doubleCheckInterval||500,m.options.storeInterval=m.options.storeInterval||1e3,m.options.busyDelay=m.options.busyDelay||250,m.options.debug=m.options.debug||!1,m.options.initialTitle=m.options.initialTitle||d.title,m.intervalList=[],m.clearAllIntervals=function(){var a,b=m.intervalList;if(typeof b!="undefined"&&b!==null){for(a=0;a<b.length;a++)j(b[a]);m.intervalList=null}},m.debug=function(){(m.options.debug||!1)&&m.log.apply(m,arguments)},m.log=function(){var a=typeof c!="undefined"&&typeof c.log!="undefined"&&typeof c.log.apply!="undefined",b=d.getElementById("log"),e,f,g,h,i;a?(h=Array.prototype.slice.call(arguments),e=h.shift(),typeof c.debug!="undefined"?c.debug.apply(c,[e,h]):c.log.apply(c,[e,h])):e="\n"+arguments[0]+"\n";for(f=1,g=arguments.length;f<g;++f){i=arguments[f];if(typeof i=="object"&&typeof k!="undefined")try{i=k.stringify(i)}catch(j){}e+="\n"+i+"\n"}return b?(b.value+=e+"\n-----\n",b.scrollTop=b.scrollHeight-b.clientHeight):a||l(e),!0},m.getInternetExplorerMajorVersion=function(){var a=m.getInternetExplorerMajorVersion.cached=typeof m.getInternetExplorerMajorVersion.cached!="undefined"?m.getInternetExplorerMajorVersion.cached:function(){var a=3,b=d.createElement("div"),c=b.getElementsByTagName("i");while((b.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->")&&c[0]);return a>4?a:!1}();return a},m.isInternetExplorer=function(){var a=m.isInternetExplorer.cached=typeof m.isInternetExplorer.cached!="undefined"?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion());return a},m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)a+=":"+d.location.port;return a+="/",a},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return a.length===1&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){var a=m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl();return a},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||d.location.href,c;return c=b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"}),c},m.getBasePageUrl=function(){var a=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/";return a},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=typeof b=="undefined"?!0:b,/[a-z]+\:\/\//.test(a)||(d==="/"?c=m.getRootUrl()+a.replace(/^\/+/,""):d==="#"?c=m.getPageUrl().replace(/#.*/,"")+a:d==="?"?c=m.getPageUrl().replace(/[\?#].*/,"")+a:b?c=m.getBaseUrl()+a.replace(/^(\.\/)+/,""):c=m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),b},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){typeof a=="undefined"&&(a=!0),typeof b=="undefined"&&(b=!0);var c=m.getLastSavedState();return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b=m.extractId(a.url),c;if(!b){c=m.getStateString(a);if(typeof m.stateToId[c]!="undefined")b=m.stateToId[c];else if(typeof m.store.stateToId[c]!="undefined")b=m.store.stateToId[c];else{for(;;){b=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof m.idToState[b]=="undefined"&&typeof m.store.idToState[b]=="undefined")break}m.stateToId[c]=b,m.idToState[b]=a}}return b},m.normalizeState=function(a){var b,c;if(!a||typeof a!="object")a={};if(typeof a.normalized!="undefined")return a;if(!a.data||typeof a.data!="object")a.data={};b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(m.unescapeString(a.url||d.location.href)),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data);if(b.title||c)b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id;return b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d),d},m.getStateById=function(a){a=String(a);var c=m.idToState[a]||m.store.idToState[a]||b;return c},m.getStateString=function(a){var b,c,d;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},d=k.stringify(c),d},m.getStateId=function(a){var b,c;return b=m.normalizeState(a),c=b.id,c},m.getHashByState=function(a){var b,c;return b=m.normalizeState(a),c=b.hash,c},m.extractId=function(a){var b,c,d;return c=/(.*)\&_suid=([0-9]+)$/.exec(a),d=c?c[1]||a:a,b=c?String(c[2]||""):"",b||!1},m.isTraditionalAnchor=function(a){var b=!/[\/\?\.]/.test(a);return b},m.extractState=function(a,b){var c=null,d,e;return b=b||!1,d=m.extractId(a),d&&(c=m.getStateById(d)),c||(e=m.getFullUrl(a),d=m.getIdByUrl(e)||!1,d&&(c=m.getStateById(d)),!c&&b&&!m.isTraditionalAnchor(a)&&(c=m.createStateObject(null,null,e))),c},m.getIdByUrl=function(a){var c=m.urlToId[a]||m.store.urlToId[a]||b;return c},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b=!1,c;return c=m.extractState(a.url),b=c&&c.id!==a.id,b},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b=!1,c,d,e;return m.savedStates.length&&(c=a.id,d=m.getLastSavedState(),e=d.id,b=c===e),b},m.saveState=function(a){return m.isLastSavedState(a)?!1:(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){var b=null;return typeof a=="undefined"?b=m.savedStates[m.savedStates.length-1]:a<0?b=m.savedStates[m.savedStates.length+a]:b=m.savedStates[a],b},m.getHash=function(){var a=m.unescapeHash(d.location.hash);return a},m.unescapeString=function(b){var c=b,d;for(;;){d=a.unescape(c);if(d===c)break;c=d}return c},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=m.unescapeString(b),b},m.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},m.setHash=function(a,b){var c,e,f;return b!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(c=m.escapeHash(a),m.busy(!0),e=m.extractState(a,!0),e&&!m.emulated.pushState?m.pushState(e.data,e.title,e.url,!1):d.location.hash!==c&&(m.bugs.setHash?(f=m.getPageUrl(),m.pushState(null,null,f+"#"+c,!1)):d.location.hash=c),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.escape(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b),b},m.setTitle=function(a){var b=a.title,c;b||(c=m.getStateByIndex(0),c&&c.url===a.url&&(b=c.title||m.options.initialTitle));try{d.getElementsByTagName("title")[0].innerHTML=b.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=b,m},m.queues=[],m.busy=function(a){typeof a!="undefined"?m.busy.flag=a:typeof m.busy.flag=="undefined"&&(m.busy.flag=!1);if(!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(m.busy.flag)return;for(a=m.queues.length-1;a>=0;--a){c=m.queues[a];if(c.length===0)continue;d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay)}};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return typeof a=="function"&&(a={callback:a}),typeof b!="undefined"&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b=m.extractState(d.location.href),c;if(!m.isLastSavedState(b))c=b;else return;return c||(c=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m};if(m.emulated.pushState){var o=function(){};m.pushState=m.pushState||o,m.replaceState=m.replaceState||o}else m.onPopState=function(b,c){var e=!1,f=!1,g,h;return m.doubleCheckComplete(),g=m.getHash(),g?(h=m.extractState(g||d.location.href,!0),h?m.replaceState(h.data,h.title,h.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(e=m.Adapter.extractEventData("state",b,c)||!1,e?f=m.getStateById(e):m.expectedStateId?f=m.getStateById(m.expectedStateId):f=m.extractState(d.location.href),f||(f=m.createStateObject(null,null,d.location.href)),m.expectedStateId=!1,m.isLastSavedState(f)?(m.busy(!1),!1):(m.storeState(f),m.saveState(f),m.setTitle(f),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(p){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"beforeunload",m.clearAllIntervals),m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(d.location.href,!0))),f&&(m.onUnload=function(){var a,b;try{a=k.parse(f.getItem("History.store"))||{}}catch(c){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState){if(!m.idToState.hasOwnProperty(b))continue;a.idToState[b]=m.idToState[b]}for(b in m.urlToId){if(!m.urlToId.hasOwnProperty(b))continue;a.urlToId[b]=m.urlToId[b]}for(b in m.stateToId){if(!m.stateToId.hasOwnProperty(b))continue;a.stateToId[b]=m.stateToId[b]}m.store=a,m.normalizeStore(),f.setItem("History.store",k.stringify(a))},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload));if(!m.emulated.pushState){m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval));if(e.vendor==="Apple Computer, Inc."||(e.appCodeName||"")==="Mozilla")m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})}},m.init()}(window)
|
data/javascripts/picky.min.js
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
Array.prototype.index=function(a){for(var
|
2
|
-
"en",
|
3
|
-
function PickyData(a){var
|
4
|
-
0.5).fadeTo("fast",1)},
|
5
|
-
12},500)}};this.liveResultsCallback=function(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
b.text();
|
10
|
-
m=setInterval(
|
11
|
-
|
12
|
-
a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.maxSuggestions=a.maxSuggestions||3;a.results=$(a.resultsSelector||
|
13
|
-
function(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
(
|
18
|
-
|
19
|
-
|
1
|
+
Array.prototype.index=function(a){for(var c=0,i=this.length;c<i;c++)if(this[c]==a)return c;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 c=0,i=this.length;c<i;c++)a(c,this[c]);return this};Array.prototype.map=function(a){for(var c=0,i=this.length;c<i;c++)this[c]=a(c,this[c]);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 c=PickyI18n.locale||
|
2
|
+
"en",i=a.split(".").concat(c),g=dictionary,j=0,k=i.length;j<k;j++){g=g[i[j]];if(g==undefined){g="Translation missing: "+a+"."+c;break}}return g};function Allocation(a,c,i,g,j,k){var p=this;this.type=a;this.weight=c;this.count=i;this.combination=g;this.ids=j||[];this.entries=this.rendered=k||[];this.isType=function(r){return r==p.type}}function Allocations(a){this.allocations=[];for(var c=0,i=a.length;c<i;c++){var g=a[c];this.allocations.push(new Allocation(g[0],g[1],g[2],g[3],g[4],g[5]))}this.length=this.allocations.length;this.remove=function(j){this.allocations.splice(j,1)};this.each=function(j){this.allocations.each(j)}}
|
3
|
+
function PickyData(a){var c=a.total,i=a.duration,g=a.offset,j=new Allocations(a.allocations||[]);this.original_hash=a;this.total=c;this.duration=i;this.offset=g;this.allocations=j;this.renderedAmount=function(){var k=0;j.each(function(p,r){k+=r.rendered.length});return k};this.isEmpty=function(){return c==0}};var PickyView=function(a,c){var i=c.showResultsLimit||10,g=c.input,j=c.reset,k=c.button,p=c.counter,r=c.form,w=c.moreSelector,v=c.results,s=c.noResults,y=new PickyAddination(this,v),f=new PickyAllocationsCloud(this,c),d=new PickyResultsRenderer(y,c),h=function(){j.fadeTo(166,1)},m=function(){f.hide();v.empty();s.hide()},o=function(b){g.val(b);j.fadeTo(166,0);r.attr("class","empty");p.empty();m()};this.reset=o;var e=function(){return g.val()};this.text=e;var q=function(b){p.text(b);b>0&&b<=5&&p.fadeTo("fast",
|
4
|
+
0.5).fadeTo("fast",1)},u=function(b){if(b.isEmpty())return"none";if(b.total>i&&b.allocations.length>1)return"support";return"ok"};this.insert=function(b){g.val(b);g.select()};this.fullResultsCallback=function(b){var n=u(b);r.attr("class",n);if(b.isEmpty()){m();q(0);s.show();h()}else if(b.total>i&&b.allocations.length>1){m();h();f.show(b);q(b.total)}else if(b.offset==0){m();q(b.total);d.render(v,b);v.show();h();g.focus()}else{n=$(w).position().top;y.remove();d.render(v,b);$("body").animate({scrollTop:n-
|
5
|
+
12},500)}};this.liveResultsCallback=function(b){var n=u(b);r.attr("class",n);q(b.total)};this.allocationChosen=function(b){b=b.data.query;a.insert(b);a.allocationChosen(b)};this.addinationClicked=function(b){a.addinationClicked(e(),b)};(function(){g.keyup(function(b){if(e()==""){o();a.searchTextCleared()}else h();a.searchTextEntered(e(),b)});p.click(function(){a.searchButtonClicked(e())});k.click(function(){a.searchButtonClicked(e())});j.click(function(){o();a.clearButtonClicked();g.focus()})})();
|
6
|
+
g.focus()};var PickyBackend=function(a){var c=function(i,g,j){var k=j||{};k=$.extend({query:i},j);$.getJSON(a,k,function(p){g&&g(new PickyData(p))})};this.search=function(i,g,j,k){c(i,function(p){g&&g(k,p)},j)}},LiveBackend=function(a){var c=a.live||alert("A live backend path must be provided."),i=new PickyBackend(c);this.search=function(g,j,k,p){p=p||{};latestRequestTimestamp=new Date;p.live=latestRequestTimestamp;k=$.extend({ids:a.liveResults||0,offset:0},k);i.search(g,function(r,w){if(!r.live||r.live==latestRequestTimestamp)j&&
|
7
|
+
j(w)},k,p)}},FullBackend=function(a){var c=a.full||alert("A full backend path must be provided."),i=new PickyBackend(c);this.search=function(g,j,k,p){p=p||{};latestRequestTimestamp=new Date;p.full=latestRequestTimestamp;k=$.extend({ids:a.fullResults||20,offset:0},k);i.search(g,function(r,w){if(!r.full||r.full==latestRequestTimestamp)j&&j(w)},k,p)}};var PickyController=function(a){var c=new PickyView(this,a),i=a.backends,g=a.beforeInsert||function(){},j=a.before||function(){},k=a.success||function(){},p=a.after||function(){},r=a.searchOnEmpty||false,w=a.liveRendered||false,v=a.liveSearchInterval||180,s,y=function(b){return(b=b&&b.match(/q=([^&]+)/))&&decodeURIComponent(b[1]).replace(/\+/g," ").replace(/#/g,"")||""};this.extractQuery=y;var f=function(){var b=window.History&&window.History.getState();return y(b&&b.url)};this.lastFullQuery=f;var d=
|
8
|
+
function(b,n,A,x){var z=j(n,x);if(z!=undefined)n=z;s=[b,n,A,x];z=n;if(z!=f()){z=!r&&z==""?"":"?q="+escape(z).replace(/\*/g,"%2A");window.History&&window.History.getState()&&window.History.pushState&&window.History.pushState(null,null,z)}if(!r&&n=="")c.reset();else(b=i[b])&&b.search(n,A,x)};this.resend=function(){s&&d.apply(this,s)};var h=function(b,n){b=k(b,n)||b;c.fullResultsCallback(b);p(b,n)},m=function(b,n){clearInterval(e);d("full",b,h,n||{})};a=function(b,n){b=k(b,n)||b;c.liveResultsCallback(b);
|
9
|
+
p(b,n)};var o=w?h:a,e,q=function(){var b=c.text();d("live",b,o,{});clearInterval(e)};e=setInterval(q,v);clearInterval(e);var u=function(b,n,A){var x=g(b);if(x!=undefined)b=x;c.insert(b);A&&m(b,n)};this.insert=u;this.clearButtonClicked=function(){clearInterval(e)};this.searchTextCleared=function(){clearInterval(e)};this.searchTextEntered=function(b,n){if($.inArray(n.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(n.keyCode==
|
10
|
+
13)m(b);else{clearInterval(e);e=setInterval(q,v)}};this.searchButtonClicked=function(b){m(b)};this.allocationChosen=function(b){m(b)};this.addinationClicked=function(b,n){m(b,{offset:n.data.offset})};window.History&&window.History.Adapter.bind(window,"statechange",function(){var b=window.History.getState();b=y(b.url);b!=undefined&&b!=(s&&s.length>1&&s[1])&&u(b,{},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||{};a.explanation_delimiters={ch:"und",de:"und",en:"and",fr:"et",it:"e"};var c=a.backends;if(c){c.live||alert("Both a full and live backend must be provided.");c.full||alert("Both a full and live backend must be provided.")}else a.backends={live:new LiveBackend(a),full:new FullBackend(a)};
|
11
|
+
c=a.enclosingSelector||".picky";var i=a.formSelector||c+" form";a.form=$(i);a.input=$(a.inputSelector||i+" input[type=search]");a.reset=$(a.resetSelector||i+" div.reset");a.button=$(a.buttonSelector||i+" input[type=button]");a.counter=$(a.counterSelector||i+" div.status");a.results=$(a.resultsSelector||c+" div.results");a.noResults=$(a.noResultsSelector||c+" div.no_results");a.moreSelector=a.moreSelector||c+" div.results div.addination:last";a.allocations=$(a.allocationsSelector||c+" .allocations");
|
12
|
+
a.shownAllocations=a.allocations.find(".shown");a.showMoreAllocations=a.allocations.find(".more");a.hiddenAllocations=a.allocations.find(".hidden");a.maxSuggestions=a.maxSuggestions||3;a.results=$(a.resultsSelector||c+" div.results");a.resultsDivider=a.resultsDivider||"";a.nonPartial=a.nonPartial||[];a.wrapResults=a.wrapResults||"<ol></ol>";var g=a.controller&&new a.controller(a)||new PickyController(a);var j=this.insert=function(k,p,r){g.insert(k,p||{},r||true)};this.resend=g.resend;this.insertFromURL=
|
13
|
+
function(k){if(k)j(k);else(k=g.lastFullQuery())&&j(k)}};var PickyAddination=function(a,c){this.remove=function(){c.find(".addination").remove()};this.render=function(i){var g=i.total,j,k=i.renderedAmount();j=i.offset+k;k=j+k;i=i.total;if(i<k)k=i;j={offset:j,start:j+1,end:k};if(j.offset<g){g=$("<div class='addination'>"+t("results.addination.more")+"</div>");g.bind("click",{offset:j.offset},a.addinationClicked);return g}else return""}};var PickyResultsRenderer=function(a,c){var i=c.locale,g=c.explanations||{},j=c.explanation_delimiters||{},k=c.resultsDivider,p=c.wrapResults,r=c.nonPartial,w=function(d){var h=d[d.length-1];if(h===undefined)return[];d=d.slice(0,d.length-1);if(d==[])d=[d];if(!r.include(h[0]))if(h[1].match(/[^\*~]$/))h[1]+="*";d.push(h);return d};this.asteriskifyLastToken=w;var v=function(d){for(var h=g[i]||{},m=[],o,e=0,q=d.length;e<q;e++){o=d[e];var u=o[0];u=h[u]||u;m.push([u,o[1]])}return m};this.explainCategory=
|
14
|
+
v;var s=function(d,h){return[d.replace(/([\w\s\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00e9\u00e8\u00e0\,]+)/,"<strong>$1</strong>"),h].join(" ")};this.strongify=s;var y=function(d,h){var m=j[i],o="",e=[],q=[];v(w(h)).each(function(u,b){var n=b[0],A=b[1];A=A.replace(/[\w,]+:(.+)/,"$1");if(o==""||n==o){e.push(A);o=n}else{var x=s(o,e.join(" "));e=[];e.push(A);o=n;q.push(x)}});q.push(s(o,e.join(" ")));q=q.join(" "+m+" ");return q='<span class="explanation">'+d+" "+q+"</span>"};this.explain=y;var f=function(d,
|
15
|
+
h){var m='<div class="header">';m+=y(h.type,h.combination);if(d.offset>0)m+='<div class="tothetop"><a href="#" onclick="javascript:$(\'body\').animate({scrollTop: 0}, 500);">↑</a></div>';m+="</div>";return m};this.renderHeader=f;this.render=function(d,h){h.allocations.each(function(m,o){if(o.entries.length>0){d.append(f(h,o)).append(o.entries.join(k));d.children("li").wrapAll(p)}});d.append(a.render(h))}};function AllocationRenderer(a){function c(f){var d={},h={},m={},o=[],e;e=0;for(l=f.length;e<l;e++){var q=f[e][0];if(q in d){d[q].push(f[e][1]);h[q].push(f[e][2]);o.push(e)}else{d[q]=[f[e][1]];h[q]=[f[e][2]];m[e]=q}}for(e in m){f[e][1]=d[m[e]];f[e][2]=h[m[e]]}for(e=o.length-1;e>=0;e--)f.remove(o[e]);return f}function i(f){f.map(function(d){return"%"+(d+1)+"$s"});return f.join(" ")}function g(f){if(f.length==0)return"";f=c(f);f.sort(function(u,b){return u[0]<b[0]?-1:1});for(var d=[],h=0,m=f.length;h<
|
16
|
+
m;h++)d.push(f[h][0]);var o=d.length==1,e=s[d.join(",")];if(e===undefined)e=s[d]=i(d);if(typeof e==="string"){s[d]={format:e,ignoreSingle:true};e=s[d]}var q=e.format;f.each(function(u,b){var n=b[0],A=b[1],x=b[2];x.map(function(z,B){var C=A[z];if(C.charAt(C.length-1)=="*")B+="...";return B});e.filter&&x.map(function(z,B){return e.filter(B)});if(o&&!(e&&e.ignoreSingle)){n=w[n]||n;return q=x.join(" ")+" ("+n+")"}x.map(function(z,B){return B.replace(/[\w,]+:(.+)/,"$1")});q=q.replace(RegExp("%"+
|
17
|
+
(u+1)+"\\$s","g"),x.join(" "))});return q}function j(f){for(var d=[],h=0,m=v.length;h<m;h++)d.push([]);d.push([]);h=0;for(m=f.length;h<m;h++){for(var o=f[h],e=o[0],q=false,u=0,b=v.length;u<b;u++)if(v[u].include(e)){d[u].push(o);q=true;break}q||d[d.length-1].push(o)}var n;for(f=d.length-1;f>=0;f--){n=d[f];if(n.length>0)break}n=n[n.length-1];y.include(n[0])||(n[1]=n[1].valueOf()+"*");return d}function k(f){var d=[];j(f).each(function(h,m){var o=g(m);o&&d.push(o)});return d.join(" ")}var p=a.locale,
|
18
|
+
r=a.qualifiers&&a.qualifiers[p]||{},w=a.explanations&&a.explanations[p]||{},v=a.groups||[],s=a.choices&&a.choices[p]||{},y=a.nonPartial||[];this.explanation=this.query=this.text="";this.contract=c;this.makeUpMissingFormat=i;this.rendered=g;this.groupify=j;this.querify=function(f){var d=[],h,m,o;for(o in f){h=f[o][0];h=r[h]||h;m=(m=f[o][1])||"";m=m.charAt(m.length-1)=="*"?"*":"";d[o]=h+":"+f[o][2]+m}return d.join(" ")};this.suggestify=k;this.render=function(f){return k(f.combination)}};var PickyAllocationsCloud=function(a,c){var i=c.allocations,g=c.shownAllocations,j=c.showMoreAllocations,k=c.hiddenAllocations,p=c.maxSuggestions,r=function(){i.hide()},w=function(f){r();a.allocationChosen(f)},v=new AllocationRenderer(c),s=function(f){var d=[];f.each(function(h,m){var o=v.querify(m.combination),e=v.render(m);e=$('<li><div class="text">'+e+'</div><div class="count">'+m.count+"</div></li>");e.bind("click",{query:o},w);d.push(e)});return d},y=function(f){if(f.length==0)return i.hide();
|
19
|
+
g.empty();j.hide();k.empty().hide();if(f.length>p){$.each(f.slice(0,p-1),function(d,h){g.append(h)});$.each(f.slice(p-1),function(d,h){k.append(h)});j.show()}else $.each(f,function(d,h){g.append(h)});return i.show()};j.click(function(){j.hide();k.show()});this.hide=r;this.show=function(f){y(s(f.allocations));i.show()}};
|
data/lib/picky-client/helper.rb
CHANGED
@@ -27,29 +27,25 @@ module Picky
|
|
27
27
|
HTML
|
28
28
|
end
|
29
29
|
def self.input options = {}
|
30
|
-
|
31
|
-
placeholder_text = options[:placeholder] || 'Search here...'
|
32
|
-
<<-HTML
|
30
|
+
<<-INPUT
|
33
31
|
<form class="empty" onkeypress="return event.keyCode != 13;">
|
34
32
|
<div class="status"></div>
|
35
|
-
<input type="search" placeholder="#{
|
33
|
+
<input type="search" placeholder="#{options[:placeholder] || 'Search here...'}" autocorrect="off" class="query"/>
|
36
34
|
<a class="reset" title="clear"></a>
|
37
|
-
<input type="button" value="#{
|
35
|
+
<input type="button" value="#{options[:button] || 'search'}"/>
|
38
36
|
</form>
|
39
|
-
|
37
|
+
INPUT
|
40
38
|
end
|
41
39
|
def self.results options = {}
|
42
|
-
|
43
|
-
more_allocations = options[:more] || 'more'
|
44
|
-
<<-HTML
|
40
|
+
<<-RESULTS
|
45
41
|
<div class="results"></div>
|
46
|
-
<div class="no_results">#{no_results}</div>
|
42
|
+
<div class="no_results">#{options[:no_results] || 'Sorry, no results found!'}</div>
|
47
43
|
<div class="allocations">
|
48
44
|
<ol class="shown"></ol>
|
49
|
-
<ol class="more">#{
|
45
|
+
<ol class="more">#{options[:more] || 'more'}</ol>
|
50
46
|
<ol class="hidden"></ol>
|
51
47
|
</div>
|
52
|
-
|
48
|
+
RESULTS
|
53
49
|
end
|
54
50
|
|
55
51
|
# Returns a cached version if you always use a single language.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|