quo.js 16 KB

1234567891011121314151617181920212223242526
  1. /* QuoJS 2.2.0 | http://quojs.tapquo.com | Copyright (C) 2011,2012 Javi Jiménez Villar (@soyjavi) */
  2. (function(){var a;a=function(){var i,h,b;h=[];b=function(f,n){f=f||h;f.__proto__=b.prototype;f.selector=n||"";return f};i=function(f,n){var p;if(f){p=i.getDOMObject(f,n);if(n)f+=" "+n;return b(p,f)}else return b()};i.extend=function(f){Array.prototype.slice.call(arguments,1).forEach(function(n){var p,s;s=[];for(p in n)s.push(f[p]=n[p]);return s});return f};b.prototype=i.fn={};return i}();window.Quo=a;"$$"in window||(window.$$=a)}).call(this);(function(){(function(a){var i,h,b,f,n,p,s,r;i=[];f=Object.prototype;b=/^\s*<(\w+|!)[^>]*>/;n=document.createElement("table");p=document.createElement("tr");h={tr:document.createElement("tbody"),tbody:n,thead:n,tfoot:n,td:p,th:p,"*":document.createElement("div")};a.toType=function(j){return f.toString.call(j).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};a.isOwnProperty=function(j,m){return f.hasOwnProperty.call(j,m)};a.getDOMObject=function(j,m){var l,d,c;l=null;d=[1,9,11];c=a.toType(j);if(c==="array")l=
  3. s(j);else if(c==="string"&&b.test(j)){l=a.fragment(j.trim(),RegExp.$1);j=null}else if(c==="string"){l=a.query(document,j);if(m)l=l.length===1?a.query(l[0],m):a.map(function(){return a.query(l,m)})}else if(d.indexOf(j.nodeType)>=0||j===window){l=[j];j=null}return l};a.map=function(j,m){var l,d,c;c=[];l=void 0;if(a.toType(j)==="array")for(l=0;l<j.length;){d=m(j[l],l);d!=null&&c.push(d);l++}else for(l in j){d=m(j[l],l);d!=null&&c.push(d)}return r(c)};a.each=function(j,m){var l;l=void 0;if(a.toType(j)===
  4. "array")for(l=0;l<j.length;){if(m.call(j[l],l,j[l])===false)break;l++}else for(l in j)if(m.call(j[l],l,j[l])===false)break;return j};a.mix=function(){var j,m,l,d,c;l={};j=0;for(d=arguments.length;j<d;){m=arguments[j];for(c in m)if(a.isOwnProperty(m,c)&&m[c]!==undefined)l[c]=m[c];j++}return l};a.fragment=function(j,m){var l;if(m==null)m="*";m in h||(m="*");l=h[m];l.innerHTML=""+j;return a.each(Array.prototype.slice.call(l.childNodes),function(){return l.removeChild(this)})};a.fn.map=function(j){return a.map(this,
  5. function(m,l){return j.call(m,l,m)})};a.fn.instance=function(j){return this.map(function(){return this[j]})};a.fn.filter=function(j){return a([].filter.call(this,function(m){return m.parentNode&&a.query(m.parentNode,j).indexOf(m)>=0}))};a.fn.forEach=i.forEach;a.fn.indexOf=i.indexOf;s=function(j){return j.filter(function(m){return m!==void 0&&m!==null})};r=function(j){return j.length>0?[].concat.apply([],j):j}})(Quo)}).call(this);(function(){(function(a){a.fn.attr=function(i,h){return a.toType(i)==="string"&&h===void 0?this[0].getAttribute(i):this.each(function(){return this.setAttribute(i,h)})};a.fn.data=function(i,h){return this.attr("data-"+i,h)};a.fn.val=function(i){return a.toType(i)==="string"?this.each(function(){return this.value=i}):this.length>0?this[0].value:null};a.fn.show=function(){return this.style("display","block")};a.fn.hide=function(){return this.style("display","none")};a.fn.height=function(){return this.offset().height};
  6. a.fn.width=function(){return this.offset().width};a.fn.offset=function(){var i;i=this[0].getBoundingClientRect();return{left:i.left+window.pageXOffset,top:i.top+window.pageYOffset,width:i.width,height:i.height}};a.fn.remove=function(){return this.each(function(){if(this.parentNode!=null)return this.parentNode.removeChild(this)})}})(Quo)}).call(this);(function(){(function(a){var i,h,b,f,n,p,s;b=null;i=/WebKit\/([\d.]+)/;h={Android:/(Android)\s+([\d.]+)/,ipad:/(iPad).*OS\s([\d_]+)/,iphone:/(iPhone\sOS)\s([\d_]+)/,blackberry:/(BlackBerry).*Version\/([\d.]+)/,webos:/(webOS|hpwOS)[\s\/]([\d.]+)/};a.isMobile=function(){b=b||n();return b.isMobile};a.environment=function(){return b=b||n()};a.isOnline=function(){return navigator.onLine};n=function(){var r,j;j=navigator.userAgent;r={};r.browser=f(j);r.os=p(j);r.isMobile=!!r.os;r.screen=s();return r};f=
  7. function(r){var j;return(j=r.match(i))?j[0]:r};p=function(r){var j,m,l;j=null;for(m in h)if(l=r.match(h[m])){j={name:m==="iphone"||m==="ipad"?"ios":m,version:l[2].replace("_",".")};break}return j};s=function(){return{width:window.innerWidth,height:window.innerHeight}}})(Quo)}).call(this);(function(){(function(a){var i;a.fn.text=function(h){return h||a.toType(h)==="number"?this.each(function(){return this.textContent=h}):this[0].textContent};a.fn.html=function(h){var b;b=a.toType(h);return h||b==="number"||b==="null"?this.each(function(){if(b==="string"||b==="number"||b==="null")return this.innerHTML=h;else{this.innerHTML=null;return this.appendChild(h)}}):this[0].innerHTML};a.fn.append=function(h){return this.each(function(){if(a.toType(h)==="string"){if(h)return this.appendChild(i(h))}else return this.insertBefore(h)})};
  8. a.fn.prepend=function(h){return this.each(function(){var b;if(a.toType(h)==="string")return this.innerHTML=h+this.innerHTML;else{b=this.parentNode;return b.insertBefore(h,b.firstChild)}})};a.fn.replaceWith=function(h){return this.each(function(){var b;if(a.toType(h)==="string")h=i(h);(b=this.parentNode)&&b.insertBefore(h,this);return a(this).remove()})};a.fn.empty=function(){return this.each(function(){this.innerHTML=null})};i=function(h){var b;b=document.createElement("div");b.innerHTML=h;return b.firstChild}})(Quo)}).call(this);(function(){(function(a){var i,h;a.query=function(b,f){var n;n=b.querySelectorAll(f);return n=Array.prototype.slice.call(n)};a.fn.find=function(b){var f;f=this.length===1?Quo.query(this[0],b):this.map(function(){return Quo.query(this,b)});return a(f)};a.fn.parent=function(b){var f;f=b?h(this):this.instance("parentNode");return i(f,b)};a.fn.siblings=function(b){var f;f=this.map(function(n,p){return Array.prototype.slice.call(p.parentNode.children).filter(function(s){return s!==p})});return i(f,b)};
  9. a.fn.children=function(b){var f;f=this.map(function(){return Array.prototype.slice.call(this.children)});return i(f,b)};a.fn.get=function(b){return b===undefined?this:this[b]};a.fn.first=function(){return a(this[0])};a.fn.last=function(){return a(this[this.length-1])};a.fn.closest=function(b,f){var n,p;p=this[0];n=a(b);for(n.length||(p=null);p&&n.indexOf(p)<0;)p=p!==f&&p!==document&&p.parentNode;return a(p)};a.fn.each=function(b){this.forEach(function(f,n){return b.call(f,n,f)});return this};h=function(b){var f;
  10. for(f=[];b.length>0;)b=a.map(b,function(n){if((n=n.parentNode)&&n!==document&&f.indexOf(n)<0){f.push(n);return n}});return f};i=function(b,f){return f===undefined?a(b):a(b).filter(f)}})(Quo)}).call(this);(function(){(function(a){var i,h;a.fn.addClass=function(b){return this.each(function(){if(!h(b,this.className)){this.className+=" "+b;return this.className=this.className.trim()}})};a.fn.removeClass=function(b){return this.each(function(){if(b){if(h(b,this.className))return this.className=this.className.replace(b," ").replace(/\s+/g," ").trim()}else return this.className=""})};a.fn.toggleClass=function(b){return this.each(function(){if(h(b,this.className))return this.className=this.className.replace(b,
  11. " ");else{this.className+=" "+b;return this.className=this.className.trim()}})};a.fn.hasClass=function(b){return h(b,this[0].className)};a.fn.style=function(b,f){return f?this.each(function(){return this.style[b]=f}):this[0].style[b]||i(this[0],b)};h=function(b,f){return f.split(/\s+/g).indexOf(b)>=0};i=function(b,f){return document.defaultView.getComputedStyle(b,"")[f]}})(Quo)}).call(this);(function(){(function(a){var i,h,b,f,n,p,s,r,j,m,l;i={TYPE:"GET",MIME:"json"};b={script:"text/javascript, application/javascript",json:"application/json",xml:"application/xml, text/xml",html:"text/html",text:"text/plain"};h=0;a.ajaxSettings={type:i.TYPE,async:true,success:{},error:{},context:null,dataType:i.MIME,headers:{},xhr:function(){return new window.XMLHttpRequest},crossDomain:false,timeout:0};a.ajax=function(d){var c,e,k;e=a.mix(a.ajaxSettings,d);if(e.type===i.TYPE)e.url+=a.serializeParameters(e.data,
  12. "?");else e.data=a.serializeParameters(e.data);if(f(e.url))return a.jsonp(e);k=e.xhr();k.onreadystatechange=function(){if(k.readyState===4){clearTimeout(c);return j(k,e)}};k.open(e.type,e.url,e.async);r(k,e);if(e.timeout>0)c=setTimeout(function(){return l(k,e)},e.timeout);try{k.send(e.data)}catch(q){k=q;p("Resource not found",k,e)}return e.async?k:n(k,e)};a.jsonp=function(d){var c,e,k,q;if(d.async){e="jsonp"+ ++h;k=document.createElement("script");q={abort:function(){a(k).remove();if(e in window)return window[e]=
  13. {}}};c=void 0;window[e]=function(v){clearTimeout(c);a(k).remove();delete window[e];return m(v,q,d)};k.src=d.url.replace(/=\?/,"="+e);a("head").append(k);if(d.timeout>0)c=setTimeout(function(){return l(q,d)},d.timeout);return q}else return console.error("QuoJS.ajax: Unable to make jsonp synchronous call.")};a.get=function(d,c,e,k){return a.ajax({url:d,data:c,success:e,dataType:k})};a.post=function(d,c,e,k){return s("POST",d,c,e,k)};a.put=function(d,c,e,k){return s("PUT",d,c,e,k)};a["delete"]=function(d,
  14. c,e,k){return s("DELETE",d,c,e,k)};a.json=function(d,c,e){return a.ajax({url:d,data:c,success:e,dataType:i.MIME})};a.serializeParameters=function(d,c){var e,k;if(c==null)c="";k=c;for(e in d)if(d.hasOwnProperty(e)){if(k!==c)k+="&";k+=e+"="+d[e]}return k===c?"":k};j=function(d,c){if(d.status>=200&&d.status<300||d.status===0)c.async&&m(n(d,c),d,c);else p("QuoJS.ajax: Unsuccesful request",d,c)};m=function(d,c,e){e.success.call(e.context,d,c)};p=function(d,c,e){e.error.call(e.context,d,c,e)};r=function(d,
  15. c){var e;if(c.contentType)c.headers["Content-Type"]=c.contentType;if(c.dataType)c.headers.Accept=b[c.dataType];for(e in c.headers)d.setRequestHeader(e,c.headers[e])};l=function(d,c){d.onreadystatechange={};d.abort();p("QuoJS.ajax: Timeout exceeded",d,c)};s=function(d,c,e,k,q){return a.ajax({type:d,url:c,data:e,success:k,dataType:q,contentType:"application/x-www-form-urlencoded"})};n=function(d,c){var e;if(e=d.responseText)if(c.dataType===i.MIME)try{e=JSON.parse(e)}catch(k){e=k;p("QuoJS.ajax: Parse Error",
  16. d,c)}else if(c.dataType==="xml")e=d.responseXML;return e};f=function(d){return/=\?/.test(d)}})(Quo)}).call(this);(function(){(function(a){var i,h;i=/complete|loaded|interactive/;h={touch:"touchstart",tap:"tap"};["touch","tap"].forEach(function(b){a.fn[b]=function(f){return a(document.body).delegate(this.selector,h[b],f)};return this});a.fn.on=function(b,f,n){return f===undefined||a.toType(f)==="function"?this.bind(b,f):this.delegate(f,b,n)};a.fn.off=function(b,f,n){return f===undefined||a.toType(f)==="function"?this.unbind(b,f):this.undelegate(f,b,n)};a.fn.ready=function(b){i.test(document.readyState)?b(a):
  17. a.fn.addEvent(document,"DOMContentLoaded",function(){return b(a)});return this}})(Quo)}).call(this);(function(){(function(a){var i,h,b,f,n,p,s,r,j,m,l;i=1;f={};b={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};h={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",tap:"click",doubletap:"dblclick",orientationchange:"resize"};a.Event=function(d,c){var e,k;e=document.createEvent("Events");e.initEvent(d,true,true,null,null,null,null,null,null,null,null,null,null,null,null);if(c)for(k in c)e[k]=c[k];return e};
  18. a.fn.bind=function(d,c){return this.each(function(){m(this,d,c)})};a.fn.unbind=function(d,c){return this.each(function(){l(this,d,c)})};a.fn.delegate=function(d,c,e){return this.each(function(k,q){m(q,c,e,d,function(v){return function(y){var x,u;if(u=a(y.target).closest(d,q).get(0)){x=a.extend(n(y),{currentTarget:u,liveFired:q});return v.apply(u,[x].concat([].slice.call(arguments,1)))}}})})};a.fn.undelegate=function(d,c,e){return this.each(function(){l(this,c,e,d)})};a.fn.trigger=function(d,c){if(a.toType(d)===
  19. "string")d=a.Event(d,c);return this.each(function(){this.dispatchEvent(d)})};a.fn.addEvent=function(d,c,e){return d.addEventListener?d.addEventListener(c,e,false):d.attachEvent?d.attachEvent("on"+c,e):d["on"+c]=e};a.fn.removeEvent=function(d,c,e){return d.removeEventListener?d.removeEventListener(c,e,false):d.detachEvent?d.detachEvent("on"+c,e):d["on"+c]=null};m=function(d,c,e,k,q){var v;c=s(c);v=j(d);v=f[v]||(f[v]=[]);q=q&&q(e,c);c={event:c,callback:e,selector:k,proxy:p(q,e,d),delegate:q,index:v.length};
  20. v.push(c);return a.fn.addEvent(d,c.event,c.proxy)};l=function(d,c,e,k){var q;c=s(c);q=j(d);return r(q,c,e,k).forEach(function(v){delete f[q][v.index];return a.fn.removeEvent(d,v.event,v.proxy)})};j=function(d){return d._id||(d._id=i++)};s=function(d){return(a.isMobile()?d:h[d])||d};p=function(d,c,e){c=d||c;return function(k){var q;q=c.apply(e,[k].concat(k.data));q===false&&k.preventDefault();return q}};r=function(d,c,e,k){return(f[d]||[]).filter(function(q){return q&&(!c||q.event===c)&&(!e||q.fn===
  21. e)&&(!k||q.selector===k)})};n=function(d){var c;c=a.extend({originalEvent:d},d);a.each(b,function(e,k){c[e]=function(){this[k]=function(){return true};return d[e].apply(d,arguments)};return c[k]=function(){return false}});return c}})(Quo)}).call(this);(function(){(function(a){var i,h,b,f,n,p,s,r,j,m,l,d,c,e,k,q,v,y,x,u;b={};h=[];i=[];f=void 0;["doubleTap","hold","swipe","swiping","swipeLeft","swipeRight","swipeUp","swipeDown","rotate","rotating","rotateLeft","rotateRight","pinch","pinching","pinchIn","pinchOut","drag","dragLeft","dragRight","dragUp","dragDown"].forEach(function(g){a.fn[g]=function(o){return this.on(g,o)}});a(document).ready(function(){return e()});e=function(){var g;g=a(document.body);g.bind("touchstart",v);g.bind("touchmove",
  22. q);g.bind("touchend",k);return g.bind("touchcancel",r)};v=function(g){var o,t,w;t=Date.now();o=t-(b.last||t);f&&clearTimeout(f);w=l(g);g=w.length;h=m(w,g);b.el=a(y(w[0].target));b.fingers=g;b.last=t;if(g===1){b.isDoubleTap=o>0&&o<=250;return setTimeout(d,650)}else if(g===2){b.initial_angle=parseInt(n(h),10);b.initial_distance=parseInt(j(h),10);b.angle_difference=0;return b.distance_difference=0}};q=function(g){var o,t;if(b.el){t=l(g);o=t.length;if(o===b.fingers){i=m(t,o);c(g)&&u("swiping");if(o===
  23. 2){s();p();g.preventDefault()}}else r()}return true};c=function(){var g,o;g=false;if(i[0]){g=Math.abs(h[0].x-i[0].x)>30;o=Math.abs(h[0].y-i[0].y)>30;g=b.el&&(g||o)}return g};k=function(){var g;if(b.isDoubleTap){u("doubleTap");return r()}else if(b.fingers===1)if(c()){u("swipe");g=x(h[0].x,i[0].x,h[0].y,i[0].y);u("swipe"+g);return r()}else{u("tap");return f=setTimeout(r,250)}else if(b.fingers===2){g=false;if(b.angle_difference!==0){u("rotate",{angle:b.angle_difference});g=b.angle_difference>0?"rotateRight":
  24. "rotateLeft";u(g,{angle:b.angle_difference});g=true}if(b.distance_difference!==0){u("pinch",{angle:b.distance_difference});g=b.distance_difference>0?"pinchOut":"pinchIn";u(g,{distance:b.distance_difference});g=true}if(!g&&i[0])if(Math.abs(h[0].x-i[0].x)>10||Math.abs(h[0].y-i[0].y)>10){u("drag");g=x(h[0].x,i[0].x,h[0].y,i[0].y);u("drag"+g)}return r()}};m=function(g,o){var t,w;w=[];for(t=0;t<o;){w.push({x:g[t].pageX,y:g[t].pageY});t++}return w};s=function(){var g,o,t;g=parseInt(n(i),10);g=parseInt(b.initial_angle-
  25. g,10);if(Math.abs(g)>20||b.angle_difference!==0){o=0;for(t=b.angle_difference<0?"-":"+";Math.abs(g-b.angle_difference)>90&&o++<10;)eval("diff "+t+"= 180;");b.angle_difference=parseInt(g,10);return u("rotating",{angle:b.angle_difference})}};p=function(){var g;g=parseInt(j(i),10);g=b.initial_distance-g;if(Math.abs(g)>10){b.distance_difference=g;return u("pinching",{distance:g})}};u=function(g,o){if(b.el){o=o||{};if(i[0]){o.iniTouch=b.fingers>1?h:h[0];o.currentTouch=b.fingers>1?i:i[0]}return b.el.trigger(g,
  26. o)}};r=function(){h=[];i=[];b={};return clearTimeout(f)};n=function(g){var o;o=g[0];g=g[1];o=Math.atan((g.y-o.y)*-1/(g.x-o.x))*(180/Math.PI);return o<0?o+180:o};j=function(g){var o;o=g[0];g=g[1];return Math.sqrt((g.x-o.x)*(g.x-o.x)+(g.y-o.y)*(g.y-o.y))*-1};l=function(g){return a.isMobile()?g.touches:[g]};y=function(g){return"tagName"in g?g:g.parentNode};x=function(g,o,t,w){return Math.abs(g-o)>=Math.abs(t-w)?g-o>0?"Left":"Right":t-w>0?"Up":"Down"};d=function(){if(b.last&&Date.now()-b.last>=650)return u("hold")}})(Quo)}).call(this);