├── .gitignore ├── bower.json ├── component.json ├── Makefile ├── composer.json ├── README.md ├── zepto.min.js └── zepto.js /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | components 3 | composer.lock 4 | vendor 5 | zepto 6 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zepto", 3 | "description": "Shim repository for the Zepto.js JavaScript library.", 4 | "version": "1.2.0", 5 | "main": "./zepto.js", 6 | "ignore": [ 7 | "*.md", 8 | ".gitignore", 9 | "Makefile" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zepto", 3 | "repo": "components/zepto", 4 | "description": "Shim repository for the Zepto.js JavaScript library.", 5 | "version": "1.2.0", 6 | "main": "zepto.js", 7 | "scripts": [ 8 | "zepto.js" 9 | ], 10 | "files": [ 11 | "zepto.min.js" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VERSION=1.2.0 2 | 3 | default: zepto 4 | @cd $< && git fetch origin --quiet && git checkout --force --quiet v$(VERSION) && npm install && npm run-script dist 5 | @cp -f $> zepto.js 7 | @cp -f $/dev/null || du -h zepto.* 9 | @sed -i.bak 's/\("version": \{1,\}\)".\{1,\}"/\1"$(VERSION)"/' bower.json component.json && rm -f *.bak 10 | 11 | zepto: 12 | @git clone https://github.com/madrobby/zepto.git $@ 13 | 14 | .PHONY: default 15 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "components/zepto", 3 | "description": "Shim repository for the Zepto.js JavaScript library.", 4 | "type": "component", 5 | "keywords": [ 6 | "JavaScript" 7 | ], 8 | "homepage": "http://zeptojs.com", 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "Thomas Fuchs", 13 | "homepage": "https://github.com/madrobby" 14 | } 15 | ], 16 | "extra": { 17 | "component": { 18 | "scripts": [ 19 | "zepto.js" 20 | ], 21 | "files": [ 22 | "zepto.min.js" 23 | ], 24 | "shim": { 25 | "exports": "Zepto" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Zepto.js 2 | ======== 3 | 4 | Shim repository for the [Zepto.js](http://zeptojs.com/) JavaScript library. 5 | 6 | Package Managers 7 | ---------------- 8 | 9 | * [Bower](http://twitter.github.com/bower/): `zepto` 10 | * [Component](https://github.com/component/component): `components/zepto` 11 | * [Composer](http://packagist.org/packages/components/zepto): `components/zepto` 12 | 13 | Maintanance 14 | ----------- 15 | 16 | To build a new release, update the target version in the [Makefile](Makefile), and run [make](http://www.gnu.org/software/make/): 17 | 18 | make 19 | 20 | Commit and push the changes to the `master` branch: 21 | 22 | git add -A 23 | git commit -m "Update Zepto" 24 | git push origin master 25 | 26 | Tag and push the new version: 27 | 28 | git tag 1.1.4 29 | git push origin 1.1.4 30 | -------------------------------------------------------------------------------- /zepto.min.js: -------------------------------------------------------------------------------- 1 | /* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */ 2 | !function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):e(t)}(this,function(t){var e=function(){function $(t){return null==t?String(t):S[C.call(t)]||"object"}function F(t){return"function"==$(t)}function k(t){return null!=t&&t==t.window}function M(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function R(t){return"object"==$(t)}function Z(t){return R(t)&&!k(t)&&Object.getPrototypeOf(t)==Object.prototype}function z(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!k(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function q(t){return a.call(t,function(t){return null!=t})}function H(t){return t.length>0?r.fn.concat.apply([],t):t}function I(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function V(t){return t in l?l[t]:l[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function _(t,e){return"number"!=typeof e||h[I(t)]?e:e+"px"}function B(t){var e,n;return c[t]||(e=f.createElement(t),f.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),c[t]=n),c[t]}function U(t){return"children"in t?u.call(t.children):r.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function X(t,e){var n,r=t?t.length:0;for(n=0;r>n;n++)this[n]=t[n];this.length=r,this.selector=e||""}function J(t,r,i){for(n in r)i&&(Z(r[n])||L(r[n]))?(Z(r[n])&&!Z(t[n])&&(t[n]={}),L(r[n])&&!L(t[n])&&(t[n]=[]),J(t[n],r[n],i)):r[n]!==e&&(t[n]=r[n])}function W(t,e){return null==e?r(t):r(t).filter(e)}function Y(t,e,n,r){return F(e)?e.call(t,n,r):e}function G(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function K(t,n){var r=t.className||"",i=r&&r.baseVal!==e;return n===e?i?r.baseVal:r:void(i?r.baseVal=n:t.className=n)}function Q(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?r.parseJSON(t):t):t}catch(e){return t}}function tt(t,e){e(t);for(var n=0,r=t.childNodes.length;r>n;n++)tt(t.childNodes[n],e)}var e,n,r,i,O,P,o=[],s=o.concat,a=o.filter,u=o.slice,f=t.document,c={},l={},h={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,d=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,g=/^(?:body|html)$/i,v=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],x=["after","prepend","before","append"],b=f.createElement("table"),E=f.createElement("tr"),j={tr:f.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:E,th:E,"*":f.createElement("div")},w=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},C=S.toString,N={},A=f.createElement("div"),D={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},L=Array.isArray||function(t){return t instanceof Array};return N.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=A).appendChild(t),r=~N.qsa(i,e).indexOf(t),o&&A.removeChild(t),r},O=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},P=function(t){return a.call(t,function(e,n){return t.indexOf(e)==n})},N.fragment=function(t,n,i){var o,s,a;return d.test(t)&&(o=r(f.createElement(RegExp.$1))),o||(t.replace&&(t=t.replace(m,"<$1>")),n===e&&(n=p.test(t)&&RegExp.$1),n in j||(n="*"),a=j[n],a.innerHTML=""+t,o=r.each(u.call(a.childNodes),function(){a.removeChild(this)})),Z(i)&&(s=r(o),r.each(i,function(t,e){y.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},N.Z=function(t,e){return new X(t,e)},N.isZ=function(t){return t instanceof N.Z},N.init=function(t,n){var i;if(!t)return N.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&p.test(t))i=N.fragment(t,RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}else{if(F(t))return r(f).ready(t);if(N.isZ(t))return t;if(L(t))i=q(t);else if(R(t))i=[t],t=null;else if(p.test(t))i=N.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}}return N.Z(i,t)},r=function(t,e){return N.init(t,e)},r.extend=function(t){var e,n=u.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){J(t,n,e)}),t},N.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:u.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=f.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=$,r.isFunction=F,r.isWindow=k,r.isArray=L,r.isPlainObject=Z,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return o.indexOf.call(e,t,n)},r.camelCase=O,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,r=[];if(z(t))for(i=0;i=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return o.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return F(t)?this.not(this.not(t)):r(a.call(this,function(e){return N.matches(e,t)}))},add:function(t,e){return r(P(this.concat(r(t,e))))},is:function(t){return this.length>0&&N.matches(this[0],t)},not:function(t){var n=[];if(F(t)&&t.call!==e)this.each(function(e){t.call(this,e)||n.push(this)});else{var i="string"==typeof t?this.filter(t):z(t)&&F(t.item)?u.call(t):r(t);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return R(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!R(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!R(t)?t:r(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?r(t).filter(function(){var t=this;return o.some.call(n,function(e){return r.contains(e,t)})}):1==this.length?r(N.qsa(this[0],t)):this.map(function(){return N.qsa(this,t)}):r()},closest:function(t,e){var n=[],i="object"==typeof t&&r(t);return this.each(function(r,o){for(;o&&!(i?i.indexOf(o)>=0:N.matches(o,t));)o=o!==e&&!M(o)&&o.parentNode;o&&n.indexOf(o)<0&&n.push(o)}),r(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){return(t=t.parentNode)&&!M(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return W(e,t)},parent:function(t){return W(P(this.pluck("parentNode")),t)},children:function(t){return W(this.map(function(){return U(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||u.call(this.childNodes)})},siblings:function(t){return W(this.map(function(t,e){return a.call(U(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=F(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){r(this[0]).before(t=r(t));for(var e;(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=F(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var n=r(this);(t===e?"none"==n.css("display"):t)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(Y(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,r){var i;return"string"!=typeof t||1 in arguments?this.each(function(e){if(1===this.nodeType)if(R(t))for(n in t)G(this,n,t[n]);else G(this,t,Y(this,r,e,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:e},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){G(this,t)},this)})},prop:function(t,e){return t=D[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=D[t]||t,this.each(function(){delete this[t]})},data:function(t,n){var r="data-"+t.replace(v,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?Q(i):e},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=Y(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=r(this),i=Y(this,e,t,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(f.documentElement!==this[0]&&!r.contains(f.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+t.pageXOffset,top:n.top+t.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(t,e){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[O(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(L(t)){if(!i)return;var o={},s=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[O(e)]||s.getPropertyValue(e)}),o}}var a="";if("string"==$(t))e||0===e?a=I(t)+":"+_(t,e):this.each(function(){this.style.removeProperty(I(t))});else for(n in t)t[n]||0===t[n]?a+=I(n)+":"+_(n,t[n])+";":this.each(function(){this.style.removeProperty(I(n))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?o.some.call(this,function(t){return this.test(K(t))},V(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var n=K(this),o=Y(this,t,e,n);o.split(/\s+/g).forEach(function(t){r(this).hasClass(t)||i.push(t)},this),i.length&&K(this,n+(n?" ":"")+i.join(" "))}}):this},removeClass:function(t){return this.each(function(n){if("className"in this){if(t===e)return K(this,"");i=K(this),Y(this,t,n,i).split(/\s+/g).forEach(function(t){i=i.replace(V(t)," ")}),K(this,i.trim())}})},toggleClass:function(t,n){return t?this.each(function(i){var o=r(this),s=Y(this,t,i,K(this));s.split(/\s+/g).forEach(function(t){(n===e?!o.hasClass(t):n)?o.addClass(t):o.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var n="scrollTop"in this[0];return t===e?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var n="scrollLeft"in this[0];return t===e?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=g.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||f.body;t&&!g.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(t){var n=t.replace(/./,function(t){return t[0].toUpperCase()});r.fn[t]=function(i){var o,s=this[0];return i===e?k(s)?s["inner"+n]:M(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[t]:this.each(function(e){s=r(this),s.css(t,Y(this,i,e,s[t]()))})}}),x.forEach(function(n,i){var o=i%2;r.fn[n]=function(){var n,a,s=r.map(arguments,function(t){var i=[];return n=$(t),"array"==n?(t.forEach(function(t){return t.nodeType!==e?i.push(t):r.zepto.isZ(t)?i=i.concat(t.get()):void(i=i.concat(N.fragment(t)))}),i):"object"==n||null==t?t:N.fragment(t)}),u=this.length>1;return s.length<1?this:this.each(function(e,n){a=o?n:n.parentNode,n=0==i?n.nextSibling:1==i?n.firstChild:2==i?n:null;var c=r.contains(f.documentElement,a);s.forEach(function(e){if(u)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,n),c&&tt(e,function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var n=e.ownerDocument?e.ownerDocument.defaultView:t;n.eval.call(n,e.innerHTML)}})})})},r.fn[o?n+"To":"insert"+(i?"Before":"After")]=function(t){return r(t)[n](this),this}}),N.Z.prototype=X.prototype=r.fn,N.uniq=P,N.deserializeValue=Q,r.zepto=N,r}();return t.Zepto=e,void 0===t.$&&(t.$=e),function(e){function h(t){return t._zid||(t._zid=n++)}function p(t,e,n,r){if(e=d(e),e.ns)var i=m(e.ns);return(a[h(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||h(t.fn)===h(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function g(t,e){return t.del&&!f&&t.e in c||!!e}function v(t){return l[t]||f&&c[t]||t}function y(t,n,i,o,s,u,f){var c=h(t),p=a[c]||(a[c]=[]);n.split(/\s/).forEach(function(n){if("ready"==n)return e(document).ready(i);var a=d(n);a.fn=i,a.sel=s,a.e in l&&(i=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?a.fn.apply(this,arguments):void 0}),a.del=u;var c=u||i;a.proxy=function(e){if(e=T(e),!e.isImmediatePropagationStopped()){e.data=o;var n=c.apply(t,e._args==r?[e]:[e].concat(e._args));return n===!1&&(e.preventDefault(),e.stopPropagation()),n}},a.i=p.length,p.push(a),"addEventListener"in t&&t.addEventListener(v(a.e),a.proxy,g(a,f))})}function x(t,e,n,r,i){var o=h(t);(e||"").split(/\s/).forEach(function(e){p(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(v(e.e),e.proxy,g(e,i))})})}function T(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(w,function(e,r){var i=n[e];t[e]=function(){return this[r]=b,i&&i.apply(n,arguments)},t[r]=E}),t.timeStamp||(t.timeStamp=Date.now()),(n.defaultPrevented!==r?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=b)),t}function S(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===r||(n[e]=t[e]);return T(n,t)}var r,n=1,i=Array.prototype.slice,o=e.isFunction,s=function(t){return"string"==typeof t},a={},u={},f="onfocusin"in t,c={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",e.event={add:y,remove:x},e.proxy=function(t,n){var r=2 in arguments&&i.call(arguments,2);if(o(t)){var a=function(){return t.apply(n,r?r.concat(i.call(arguments)):arguments)};return a._zid=h(t),a}if(s(n))return r?(r.unshift(t[n],t),e.proxy.apply(null,r)):e.proxy(t[n],t);throw new TypeError("expected function")},e.fn.bind=function(t,e,n){return this.on(t,e,n)},e.fn.unbind=function(t,e){return this.off(t,e)},e.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,w={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(t,e,n){return this.on(e,t,n)},e.fn.undelegate=function(t,e,n){return this.off(e,t,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,a,u,f){var c,l,h=this;return t&&!s(t)?(e.each(t,function(t,e){h.on(t,n,a,e,f)}),h):(s(n)||o(u)||u===!1||(u=a,a=n,n=r),(u===r||a===!1)&&(u=a,a=r),u===!1&&(u=E),h.each(function(r,o){f&&(c=function(t){return x(o,t.type,u),u.apply(this,arguments)}),n&&(l=function(t){var r,s=e(t.target).closest(n,o).get(0);return s&&s!==o?(r=e.extend(S(t),{currentTarget:s,liveFired:o}),(c||u).apply(s,[r].concat(i.call(arguments,1)))):void 0}),y(o,t,u,a,n,l||c)}))},e.fn.off=function(t,n,i){var a=this;return t&&!s(t)?(e.each(t,function(t,e){a.off(t,n,e)}),a):(s(n)||o(i)||i===!1||(i=n,n=r),i===!1&&(i=E),a.each(function(){x(this,t,i,n)}))},e.fn.trigger=function(t,n){return t=s(t)||e.isPlainObject(t)?e.Event(t):T(t),t._args=n,this.each(function(){t.type in c&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,n){var r,i;return this.each(function(o,a){r=S(s(t)?e.Event(t):t),r._args=n,r.target=a,e.each(p(a,t.type||t),function(t,e){return i=e.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(t,e){s(t)||(e=t,t=e.type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),T(n)}}(e),function(e){function p(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function d(t,e,n,i){return t.global?p(e||r,n,i):void 0}function m(t){t.global&&0===e.active++&&d(t,null,"ajaxStart")}function g(t){t.global&&!--e.active&&d(t,null,"ajaxStop")}function v(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||d(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void d(e,n,"ajaxSend",[t,e])}function y(t,e,n,r){var i=n.context,o="success";n.success.call(i,t,o,e),r&&r.resolveWith(i,[t,o,e]),d(n,i,"ajaxSuccess",[e,n,t]),b(o,e,n)}function x(t,e,n,r,i){var o=r.context;r.error.call(o,n,e,t),i&&i.rejectWith(o,[n,e,t]),d(r,o,"ajaxError",[n,r,t||e]),b(e,n,r)}function b(t,e,n){var r=n.context;n.complete.call(r,e,t),d(n,r,"ajaxComplete",[e,n]),g(n)}function E(t,e,n){if(n.dataFilter==j)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function j(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==f?"json":a.test(t)?"script":u.test(t)&&"xml")||"text"}function T(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function S(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=T(t.url,t.data),t.data=void 0)}function C(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function O(t,n,r,i){var o,s=e.isArray(n),a=e.isPlainObject(n);e.each(n,function(n,u){o=e.type(u),i&&(n=r?i:i+"["+(a||"object"==o||"array"==o?n:"")+"]"),!i&&s?t.add(u.name,u.value):"array"==o||!r&&"object"==o?O(t,u,r,n):t.add(n,u)})}var i,o,n=+new Date,r=t.document,s=/)<[^<]*)*<\/script>/gi,a=/^(?:text|application)\/javascript/i,u=/^(?:text|application)\/xml/i,f="application/json",c="text/html",l=/^\s*$/,h=r.createElement("a");h.href=t.location.href,e.active=0,e.ajaxJSONP=function(i,o){if(!("type"in i))return e.ajax(i);var c,p,s=i.jsonpCallback,a=(e.isFunction(s)?s():s)||"Zepto"+n++,u=r.createElement("script"),f=t[a],l=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:l};return o&&o.promise(h),e(u).on("load error",function(n,r){clearTimeout(p),e(u).off().remove(),"error"!=n.type&&c?y(c[0],h,i,o):x(null,r||"error",h,i,o),t[a]=f,c&&e.isFunction(f)&&f(c[0]),f=c=void 0}),v(h,i)===!1?(l("abort"),h):(t[a]=function(){c=arguments},u.src=i.url.replace(/\?(.+)=\?/,"?$1="+a),r.head.appendChild(u),i.timeout>0&&(p=setTimeout(function(){l("timeout")},i.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:j,success:j,error:j,complete:j,context:null,global:!0,xhr:function(){return new t.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:f,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:j},e.ajax=function(n){var u,f,s=e.extend({},n||{}),a=e.Deferred&&e.Deferred();for(i in e.ajaxSettings)void 0===s[i]&&(s[i]=e.ajaxSettings[i]);m(s),s.crossDomain||(u=r.createElement("a"),u.href=s.url,u.href=u.href,s.crossDomain=h.protocol+"//"+h.host!=u.protocol+"//"+u.host),s.url||(s.url=t.location.toString()),(f=s.url.indexOf("#"))>-1&&(s.url=s.url.slice(0,f)),S(s);var c=s.dataType,p=/\?.+=\?/.test(s.url);if(p&&(c="jsonp"),s.cache!==!1&&(n&&n.cache===!0||"script"!=c&&"jsonp"!=c)||(s.url=T(s.url,"_="+Date.now())),"jsonp"==c)return p||(s.url=T(s.url,s.jsonp?s.jsonp+"=?":s.jsonp===!1?"":"callback=?")),e.ajaxJSONP(s,a);var P,d=s.accepts[c],g={},b=function(t,e){g[t.toLowerCase()]=[t,e]},C=/^([\w-]+:)\/\//.test(s.url)?RegExp.$1:t.location.protocol,N=s.xhr(),O=N.setRequestHeader;if(a&&a.promise(N),s.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",d||"*/*"),(d=s.mimeType||d)&&(d.indexOf(",")>-1&&(d=d.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(d)),(s.contentType||s.contentType!==!1&&s.data&&"GET"!=s.type.toUpperCase())&&b("Content-Type",s.contentType||"application/x-www-form-urlencoded"),s.headers)for(o in s.headers)b(o,s.headers[o]);if(N.setRequestHeader=b,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=j,clearTimeout(P);var t,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==C){if(c=c||w(s.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)t=N.response;else{t=N.responseText;try{t=E(t,c,s),"script"==c?(1,eval)(t):"xml"==c?t=N.responseXML:"json"==c&&(t=l.test(t)?null:e.parseJSON(t))}catch(r){n=r}if(n)return x(n,"parsererror",N,s,a)}y(t,N,s,a)}else x(N.statusText||null,N.status?"error":"abort",N,s,a)}},v(N,s)===!1)return N.abort(),x(null,"abort",N,s,a),N;var A="async"in s?s.async:!0;if(N.open(s.type,s.url,A,s.username,s.password),s.xhrFields)for(o in s.xhrFields)N[o]=s.xhrFields[o];for(o in g)O.apply(N,g[o]);return s.timeout>0&&(P=setTimeout(function(){N.onreadystatechange=j,N.abort(),x(null,"timeout",N,s,a)},s.timeout)),N.send(s.data?s.data:null),N},e.get=function(){return e.ajax(C.apply(null,arguments))},e.post=function(){var t=C.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=C.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,r){if(!this.length)return this;var a,i=this,o=t.split(/\s/),u=C(t,n,r),f=u.success;return o.length>1&&(u.url=o[0],a=o[1]),u.success=function(t){i.html(a?e("
").html(t.replace(s,"")).find(a):t),f&&f.apply(i,arguments)},e.ajax(u),this};var N=encodeURIComponent;e.param=function(t,n){var r=[];return r.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(t)+"="+N(n))},O(r,t,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;t.getComputedStyle=function(t,e){try{return n(t,e)}catch(r){return null}}}}(),e}); -------------------------------------------------------------------------------- /zepto.js: -------------------------------------------------------------------------------- 1 | /* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */ 2 | (function(global, factory) { 3 | if (typeof define === 'function' && define.amd) 4 | define(function() { return factory(global) }) 5 | else 6 | factory(global) 7 | }(this, function(window) { 8 | var Zepto = (function() { 9 | var undefined, key, $, classList, emptyArray = [], concat = emptyArray.concat, filter = emptyArray.filter, slice = emptyArray.slice, 10 | document = window.document, 11 | elementDisplay = {}, classCache = {}, 12 | cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 }, 13 | fragmentRE = /^\s*<(\w+|!)[^>]*>/, 14 | singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, 15 | tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, 16 | rootNodeRE = /^(?:body|html)$/i, 17 | capitalRE = /([A-Z])/g, 18 | 19 | // special attributes that should be get/set via method calls 20 | methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'], 21 | 22 | adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ], 23 | table = document.createElement('table'), 24 | tableRow = document.createElement('tr'), 25 | containers = { 26 | 'tr': document.createElement('tbody'), 27 | 'tbody': table, 'thead': table, 'tfoot': table, 28 | 'td': tableRow, 'th': tableRow, 29 | '*': document.createElement('div') 30 | }, 31 | readyRE = /complete|loaded|interactive/, 32 | simpleSelectorRE = /^[\w-]*$/, 33 | class2type = {}, 34 | toString = class2type.toString, 35 | zepto = {}, 36 | camelize, uniq, 37 | tempParent = document.createElement('div'), 38 | propMap = { 39 | 'tabindex': 'tabIndex', 40 | 'readonly': 'readOnly', 41 | 'for': 'htmlFor', 42 | 'class': 'className', 43 | 'maxlength': 'maxLength', 44 | 'cellspacing': 'cellSpacing', 45 | 'cellpadding': 'cellPadding', 46 | 'rowspan': 'rowSpan', 47 | 'colspan': 'colSpan', 48 | 'usemap': 'useMap', 49 | 'frameborder': 'frameBorder', 50 | 'contenteditable': 'contentEditable' 51 | }, 52 | isArray = Array.isArray || 53 | function(object){ return object instanceof Array } 54 | 55 | zepto.matches = function(element, selector) { 56 | if (!selector || !element || element.nodeType !== 1) return false 57 | var matchesSelector = element.matches || element.webkitMatchesSelector || 58 | element.mozMatchesSelector || element.oMatchesSelector || 59 | element.matchesSelector 60 | if (matchesSelector) return matchesSelector.call(element, selector) 61 | // fall back to performing a selector: 62 | var match, parent = element.parentNode, temp = !parent 63 | if (temp) (parent = tempParent).appendChild(element) 64 | match = ~zepto.qsa(parent, selector).indexOf(element) 65 | temp && tempParent.removeChild(element) 66 | return match 67 | } 68 | 69 | function type(obj) { 70 | return obj == null ? String(obj) : 71 | class2type[toString.call(obj)] || "object" 72 | } 73 | 74 | function isFunction(value) { return type(value) == "function" } 75 | function isWindow(obj) { return obj != null && obj == obj.window } 76 | function isDocument(obj) { return obj != null && obj.nodeType == obj.DOCUMENT_NODE } 77 | function isObject(obj) { return type(obj) == "object" } 78 | function isPlainObject(obj) { 79 | return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype 80 | } 81 | 82 | function likeArray(obj) { 83 | var length = !!obj && 'length' in obj && obj.length, 84 | type = $.type(obj) 85 | 86 | return 'function' != type && !isWindow(obj) && ( 87 | 'array' == type || length === 0 || 88 | (typeof length == 'number' && length > 0 && (length - 1) in obj) 89 | ) 90 | } 91 | 92 | function compact(array) { return filter.call(array, function(item){ return item != null }) } 93 | function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array } 94 | camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) } 95 | function dasherize(str) { 96 | return str.replace(/::/g, '/') 97 | .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') 98 | .replace(/([a-z\d])([A-Z])/g, '$1_$2') 99 | .replace(/_/g, '-') 100 | .toLowerCase() 101 | } 102 | uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) } 103 | 104 | function classRE(name) { 105 | return name in classCache ? 106 | classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)')) 107 | } 108 | 109 | function maybeAddPx(name, value) { 110 | return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value 111 | } 112 | 113 | function defaultDisplay(nodeName) { 114 | var element, display 115 | if (!elementDisplay[nodeName]) { 116 | element = document.createElement(nodeName) 117 | document.body.appendChild(element) 118 | display = getComputedStyle(element, '').getPropertyValue("display") 119 | element.parentNode.removeChild(element) 120 | display == "none" && (display = "block") 121 | elementDisplay[nodeName] = display 122 | } 123 | return elementDisplay[nodeName] 124 | } 125 | 126 | function children(element) { 127 | return 'children' in element ? 128 | slice.call(element.children) : 129 | $.map(element.childNodes, function(node){ if (node.nodeType == 1) return node }) 130 | } 131 | 132 | function Z(dom, selector) { 133 | var i, len = dom ? dom.length : 0 134 | for (i = 0; i < len; i++) this[i] = dom[i] 135 | this.length = len 136 | this.selector = selector || '' 137 | } 138 | 139 | // `$.zepto.fragment` takes a html string and an optional tag name 140 | // to generate DOM nodes from the given html string. 141 | // The generated DOM nodes are returned as an array. 142 | // This function can be overridden in plugins for example to make 143 | // it compatible with browsers that don't support the DOM fully. 144 | zepto.fragment = function(html, name, properties) { 145 | var dom, nodes, container 146 | 147 | // A special case optimization for a single tag 148 | if (singleTagRE.test(html)) dom = $(document.createElement(RegExp.$1)) 149 | 150 | if (!dom) { 151 | if (html.replace) html = html.replace(tagExpanderRE, "<$1>") 152 | if (name === undefined) name = fragmentRE.test(html) && RegExp.$1 153 | if (!(name in containers)) name = '*' 154 | 155 | container = containers[name] 156 | container.innerHTML = '' + html 157 | dom = $.each(slice.call(container.childNodes), function(){ 158 | container.removeChild(this) 159 | }) 160 | } 161 | 162 | if (isPlainObject(properties)) { 163 | nodes = $(dom) 164 | $.each(properties, function(key, value) { 165 | if (methodAttributes.indexOf(key) > -1) nodes[key](value) 166 | else nodes.attr(key, value) 167 | }) 168 | } 169 | 170 | return dom 171 | } 172 | 173 | // `$.zepto.Z` swaps out the prototype of the given `dom` array 174 | // of nodes with `$.fn` and thus supplying all the Zepto functions 175 | // to the array. This method can be overridden in plugins. 176 | zepto.Z = function(dom, selector) { 177 | return new Z(dom, selector) 178 | } 179 | 180 | // `$.zepto.isZ` should return `true` if the given object is a Zepto 181 | // collection. This method can be overridden in plugins. 182 | zepto.isZ = function(object) { 183 | return object instanceof zepto.Z 184 | } 185 | 186 | // `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and 187 | // takes a CSS selector and an optional context (and handles various 188 | // special cases). 189 | // This method can be overridden in plugins. 190 | zepto.init = function(selector, context) { 191 | var dom 192 | // If nothing given, return an empty Zepto collection 193 | if (!selector) return zepto.Z() 194 | // Optimize for string selectors 195 | else if (typeof selector == 'string') { 196 | selector = selector.trim() 197 | // If it's a html fragment, create nodes from it 198 | // Note: In both Chrome 21 and Firefox 15, DOM error 12 199 | // is thrown if the fragment doesn't begin with < 200 | if (selector[0] == '<' && fragmentRE.test(selector)) 201 | dom = zepto.fragment(selector, RegExp.$1, context), selector = null 202 | // If there's a context, create a collection on that context first, and select 203 | // nodes from there 204 | else if (context !== undefined) return $(context).find(selector) 205 | // If it's a CSS selector, use it to select nodes. 206 | else dom = zepto.qsa(document, selector) 207 | } 208 | // If a function is given, call it when the DOM is ready 209 | else if (isFunction(selector)) return $(document).ready(selector) 210 | // If a Zepto collection is given, just return it 211 | else if (zepto.isZ(selector)) return selector 212 | else { 213 | // normalize array if an array of nodes is given 214 | if (isArray(selector)) dom = compact(selector) 215 | // Wrap DOM nodes. 216 | else if (isObject(selector)) 217 | dom = [selector], selector = null 218 | // If it's a html fragment, create nodes from it 219 | else if (fragmentRE.test(selector)) 220 | dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null 221 | // If there's a context, create a collection on that context first, and select 222 | // nodes from there 223 | else if (context !== undefined) return $(context).find(selector) 224 | // And last but no least, if it's a CSS selector, use it to select nodes. 225 | else dom = zepto.qsa(document, selector) 226 | } 227 | // create a new Zepto collection from the nodes found 228 | return zepto.Z(dom, selector) 229 | } 230 | 231 | // `$` will be the base `Zepto` object. When calling this 232 | // function just call `$.zepto.init, which makes the implementation 233 | // details of selecting nodes and creating Zepto collections 234 | // patchable in plugins. 235 | $ = function(selector, context){ 236 | return zepto.init(selector, context) 237 | } 238 | 239 | function extend(target, source, deep) { 240 | for (key in source) 241 | if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { 242 | if (isPlainObject(source[key]) && !isPlainObject(target[key])) 243 | target[key] = {} 244 | if (isArray(source[key]) && !isArray(target[key])) 245 | target[key] = [] 246 | extend(target[key], source[key], deep) 247 | } 248 | else if (source[key] !== undefined) target[key] = source[key] 249 | } 250 | 251 | // Copy all but undefined properties from one or more 252 | // objects to the `target` object. 253 | $.extend = function(target){ 254 | var deep, args = slice.call(arguments, 1) 255 | if (typeof target == 'boolean') { 256 | deep = target 257 | target = args.shift() 258 | } 259 | args.forEach(function(arg){ extend(target, arg, deep) }) 260 | return target 261 | } 262 | 263 | // `$.zepto.qsa` is Zepto's CSS selector implementation which 264 | // uses `document.querySelectorAll` and optimizes for some special cases, like `#id`. 265 | // This method can be overridden in plugins. 266 | zepto.qsa = function(element, selector){ 267 | var found, 268 | maybeID = selector[0] == '#', 269 | maybeClass = !maybeID && selector[0] == '.', 270 | nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked 271 | isSimple = simpleSelectorRE.test(nameOnly) 272 | return (element.getElementById && isSimple && maybeID) ? // Safari DocumentFragment doesn't have getElementById 273 | ( (found = element.getElementById(nameOnly)) ? [found] : [] ) : 274 | (element.nodeType !== 1 && element.nodeType !== 9 && element.nodeType !== 11) ? [] : 275 | slice.call( 276 | isSimple && !maybeID && element.getElementsByClassName ? // DocumentFragment doesn't have getElementsByClassName/TagName 277 | maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class 278 | element.getElementsByTagName(selector) : // Or a tag 279 | element.querySelectorAll(selector) // Or it's not simple, and we need to query all 280 | ) 281 | } 282 | 283 | function filtered(nodes, selector) { 284 | return selector == null ? $(nodes) : $(nodes).filter(selector) 285 | } 286 | 287 | $.contains = document.documentElement.contains ? 288 | function(parent, node) { 289 | return parent !== node && parent.contains(node) 290 | } : 291 | function(parent, node) { 292 | while (node && (node = node.parentNode)) 293 | if (node === parent) return true 294 | return false 295 | } 296 | 297 | function funcArg(context, arg, idx, payload) { 298 | return isFunction(arg) ? arg.call(context, idx, payload) : arg 299 | } 300 | 301 | function setAttribute(node, name, value) { 302 | value == null ? node.removeAttribute(name) : node.setAttribute(name, value) 303 | } 304 | 305 | // access className property while respecting SVGAnimatedString 306 | function className(node, value){ 307 | var klass = node.className || '', 308 | svg = klass && klass.baseVal !== undefined 309 | 310 | if (value === undefined) return svg ? klass.baseVal : klass 311 | svg ? (klass.baseVal = value) : (node.className = value) 312 | } 313 | 314 | // "true" => true 315 | // "false" => false 316 | // "null" => null 317 | // "42" => 42 318 | // "42.5" => 42.5 319 | // "08" => "08" 320 | // JSON => parse if valid 321 | // String => self 322 | function deserializeValue(value) { 323 | try { 324 | return value ? 325 | value == "true" || 326 | ( value == "false" ? false : 327 | value == "null" ? null : 328 | +value + "" == value ? +value : 329 | /^[\[\{]/.test(value) ? $.parseJSON(value) : 330 | value ) 331 | : value 332 | } catch(e) { 333 | return value 334 | } 335 | } 336 | 337 | $.type = type 338 | $.isFunction = isFunction 339 | $.isWindow = isWindow 340 | $.isArray = isArray 341 | $.isPlainObject = isPlainObject 342 | 343 | $.isEmptyObject = function(obj) { 344 | var name 345 | for (name in obj) return false 346 | return true 347 | } 348 | 349 | $.isNumeric = function(val) { 350 | var num = Number(val), type = typeof val 351 | return val != null && type != 'boolean' && 352 | (type != 'string' || val.length) && 353 | !isNaN(num) && isFinite(num) || false 354 | } 355 | 356 | $.inArray = function(elem, array, i){ 357 | return emptyArray.indexOf.call(array, elem, i) 358 | } 359 | 360 | $.camelCase = camelize 361 | $.trim = function(str) { 362 | return str == null ? "" : String.prototype.trim.call(str) 363 | } 364 | 365 | // plugin compatibility 366 | $.uuid = 0 367 | $.support = { } 368 | $.expr = { } 369 | $.noop = function() {} 370 | 371 | $.map = function(elements, callback){ 372 | var value, values = [], i, key 373 | if (likeArray(elements)) 374 | for (i = 0; i < elements.length; i++) { 375 | value = callback(elements[i], i) 376 | if (value != null) values.push(value) 377 | } 378 | else 379 | for (key in elements) { 380 | value = callback(elements[key], key) 381 | if (value != null) values.push(value) 382 | } 383 | return flatten(values) 384 | } 385 | 386 | $.each = function(elements, callback){ 387 | var i, key 388 | if (likeArray(elements)) { 389 | for (i = 0; i < elements.length; i++) 390 | if (callback.call(elements[i], i, elements[i]) === false) return elements 391 | } else { 392 | for (key in elements) 393 | if (callback.call(elements[key], key, elements[key]) === false) return elements 394 | } 395 | 396 | return elements 397 | } 398 | 399 | $.grep = function(elements, callback){ 400 | return filter.call(elements, callback) 401 | } 402 | 403 | if (window.JSON) $.parseJSON = JSON.parse 404 | 405 | // Populate the class2type map 406 | $.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { 407 | class2type[ "[object " + name + "]" ] = name.toLowerCase() 408 | }) 409 | 410 | // Define methods that will be available on all 411 | // Zepto collections 412 | $.fn = { 413 | constructor: zepto.Z, 414 | length: 0, 415 | 416 | // Because a collection acts like an array 417 | // copy over these useful array functions. 418 | forEach: emptyArray.forEach, 419 | reduce: emptyArray.reduce, 420 | push: emptyArray.push, 421 | sort: emptyArray.sort, 422 | splice: emptyArray.splice, 423 | indexOf: emptyArray.indexOf, 424 | concat: function(){ 425 | var i, value, args = [] 426 | for (i = 0; i < arguments.length; i++) { 427 | value = arguments[i] 428 | args[i] = zepto.isZ(value) ? value.toArray() : value 429 | } 430 | return concat.apply(zepto.isZ(this) ? this.toArray() : this, args) 431 | }, 432 | 433 | // `map` and `slice` in the jQuery API work differently 434 | // from their array counterparts 435 | map: function(fn){ 436 | return $($.map(this, function(el, i){ return fn.call(el, i, el) })) 437 | }, 438 | slice: function(){ 439 | return $(slice.apply(this, arguments)) 440 | }, 441 | 442 | ready: function(callback){ 443 | // need to check if document.body exists for IE as that browser reports 444 | // document ready when it hasn't yet created the body element 445 | if (readyRE.test(document.readyState) && document.body) callback($) 446 | else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false) 447 | return this 448 | }, 449 | get: function(idx){ 450 | return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length] 451 | }, 452 | toArray: function(){ return this.get() }, 453 | size: function(){ 454 | return this.length 455 | }, 456 | remove: function(){ 457 | return this.each(function(){ 458 | if (this.parentNode != null) 459 | this.parentNode.removeChild(this) 460 | }) 461 | }, 462 | each: function(callback){ 463 | emptyArray.every.call(this, function(el, idx){ 464 | return callback.call(el, idx, el) !== false 465 | }) 466 | return this 467 | }, 468 | filter: function(selector){ 469 | if (isFunction(selector)) return this.not(this.not(selector)) 470 | return $(filter.call(this, function(element){ 471 | return zepto.matches(element, selector) 472 | })) 473 | }, 474 | add: function(selector,context){ 475 | return $(uniq(this.concat($(selector,context)))) 476 | }, 477 | is: function(selector){ 478 | return this.length > 0 && zepto.matches(this[0], selector) 479 | }, 480 | not: function(selector){ 481 | var nodes=[] 482 | if (isFunction(selector) && selector.call !== undefined) 483 | this.each(function(idx){ 484 | if (!selector.call(this,idx)) nodes.push(this) 485 | }) 486 | else { 487 | var excludes = typeof selector == 'string' ? this.filter(selector) : 488 | (likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector) 489 | this.forEach(function(el){ 490 | if (excludes.indexOf(el) < 0) nodes.push(el) 491 | }) 492 | } 493 | return $(nodes) 494 | }, 495 | has: function(selector){ 496 | return this.filter(function(){ 497 | return isObject(selector) ? 498 | $.contains(this, selector) : 499 | $(this).find(selector).size() 500 | }) 501 | }, 502 | eq: function(idx){ 503 | return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1) 504 | }, 505 | first: function(){ 506 | var el = this[0] 507 | return el && !isObject(el) ? el : $(el) 508 | }, 509 | last: function(){ 510 | var el = this[this.length - 1] 511 | return el && !isObject(el) ? el : $(el) 512 | }, 513 | find: function(selector){ 514 | var result, $this = this 515 | if (!selector) result = $() 516 | else if (typeof selector == 'object') 517 | result = $(selector).filter(function(){ 518 | var node = this 519 | return emptyArray.some.call($this, function(parent){ 520 | return $.contains(parent, node) 521 | }) 522 | }) 523 | else if (this.length == 1) result = $(zepto.qsa(this[0], selector)) 524 | else result = this.map(function(){ return zepto.qsa(this, selector) }) 525 | return result 526 | }, 527 | closest: function(selector, context){ 528 | var nodes = [], collection = typeof selector == 'object' && $(selector) 529 | this.each(function(_, node){ 530 | while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector))) 531 | node = node !== context && !isDocument(node) && node.parentNode 532 | if (node && nodes.indexOf(node) < 0) nodes.push(node) 533 | }) 534 | return $(nodes) 535 | }, 536 | parents: function(selector){ 537 | var ancestors = [], nodes = this 538 | while (nodes.length > 0) 539 | nodes = $.map(nodes, function(node){ 540 | if ((node = node.parentNode) && !isDocument(node) && ancestors.indexOf(node) < 0) { 541 | ancestors.push(node) 542 | return node 543 | } 544 | }) 545 | return filtered(ancestors, selector) 546 | }, 547 | parent: function(selector){ 548 | return filtered(uniq(this.pluck('parentNode')), selector) 549 | }, 550 | children: function(selector){ 551 | return filtered(this.map(function(){ return children(this) }), selector) 552 | }, 553 | contents: function() { 554 | return this.map(function() { return this.contentDocument || slice.call(this.childNodes) }) 555 | }, 556 | siblings: function(selector){ 557 | return filtered(this.map(function(i, el){ 558 | return filter.call(children(el.parentNode), function(child){ return child!==el }) 559 | }), selector) 560 | }, 561 | empty: function(){ 562 | return this.each(function(){ this.innerHTML = '' }) 563 | }, 564 | // `pluck` is borrowed from Prototype.js 565 | pluck: function(property){ 566 | return $.map(this, function(el){ return el[property] }) 567 | }, 568 | show: function(){ 569 | return this.each(function(){ 570 | this.style.display == "none" && (this.style.display = '') 571 | if (getComputedStyle(this, '').getPropertyValue("display") == "none") 572 | this.style.display = defaultDisplay(this.nodeName) 573 | }) 574 | }, 575 | replaceWith: function(newContent){ 576 | return this.before(newContent).remove() 577 | }, 578 | wrap: function(structure){ 579 | var func = isFunction(structure) 580 | if (this[0] && !func) 581 | var dom = $(structure).get(0), 582 | clone = dom.parentNode || this.length > 1 583 | 584 | return this.each(function(index){ 585 | $(this).wrapAll( 586 | func ? structure.call(this, index) : 587 | clone ? dom.cloneNode(true) : dom 588 | ) 589 | }) 590 | }, 591 | wrapAll: function(structure){ 592 | if (this[0]) { 593 | $(this[0]).before(structure = $(structure)) 594 | var children 595 | // drill down to the inmost element 596 | while ((children = structure.children()).length) structure = children.first() 597 | $(structure).append(this) 598 | } 599 | return this 600 | }, 601 | wrapInner: function(structure){ 602 | var func = isFunction(structure) 603 | return this.each(function(index){ 604 | var self = $(this), contents = self.contents(), 605 | dom = func ? structure.call(this, index) : structure 606 | contents.length ? contents.wrapAll(dom) : self.append(dom) 607 | }) 608 | }, 609 | unwrap: function(){ 610 | this.parent().each(function(){ 611 | $(this).replaceWith($(this).children()) 612 | }) 613 | return this 614 | }, 615 | clone: function(){ 616 | return this.map(function(){ return this.cloneNode(true) }) 617 | }, 618 | hide: function(){ 619 | return this.css("display", "none") 620 | }, 621 | toggle: function(setting){ 622 | return this.each(function(){ 623 | var el = $(this) 624 | ;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide() 625 | }) 626 | }, 627 | prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') }, 628 | next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') }, 629 | html: function(html){ 630 | return 0 in arguments ? 631 | this.each(function(idx){ 632 | var originHtml = this.innerHTML 633 | $(this).empty().append( funcArg(this, html, idx, originHtml) ) 634 | }) : 635 | (0 in this ? this[0].innerHTML : null) 636 | }, 637 | text: function(text){ 638 | return 0 in arguments ? 639 | this.each(function(idx){ 640 | var newText = funcArg(this, text, idx, this.textContent) 641 | this.textContent = newText == null ? '' : ''+newText 642 | }) : 643 | (0 in this ? this.pluck('textContent').join("") : null) 644 | }, 645 | attr: function(name, value){ 646 | var result 647 | return (typeof name == 'string' && !(1 in arguments)) ? 648 | (0 in this && this[0].nodeType == 1 && (result = this[0].getAttribute(name)) != null ? result : undefined) : 649 | this.each(function(idx){ 650 | if (this.nodeType !== 1) return 651 | if (isObject(name)) for (key in name) setAttribute(this, key, name[key]) 652 | else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name))) 653 | }) 654 | }, 655 | removeAttr: function(name){ 656 | return this.each(function(){ this.nodeType === 1 && name.split(' ').forEach(function(attribute){ 657 | setAttribute(this, attribute) 658 | }, this)}) 659 | }, 660 | prop: function(name, value){ 661 | name = propMap[name] || name 662 | return (1 in arguments) ? 663 | this.each(function(idx){ 664 | this[name] = funcArg(this, value, idx, this[name]) 665 | }) : 666 | (this[0] && this[0][name]) 667 | }, 668 | removeProp: function(name){ 669 | name = propMap[name] || name 670 | return this.each(function(){ delete this[name] }) 671 | }, 672 | data: function(name, value){ 673 | var attrName = 'data-' + name.replace(capitalRE, '-$1').toLowerCase() 674 | 675 | var data = (1 in arguments) ? 676 | this.attr(attrName, value) : 677 | this.attr(attrName) 678 | 679 | return data !== null ? deserializeValue(data) : undefined 680 | }, 681 | val: function(value){ 682 | if (0 in arguments) { 683 | if (value == null) value = "" 684 | return this.each(function(idx){ 685 | this.value = funcArg(this, value, idx, this.value) 686 | }) 687 | } else { 688 | return this[0] && (this[0].multiple ? 689 | $(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') : 690 | this[0].value) 691 | } 692 | }, 693 | offset: function(coordinates){ 694 | if (coordinates) return this.each(function(index){ 695 | var $this = $(this), 696 | coords = funcArg(this, coordinates, index, $this.offset()), 697 | parentOffset = $this.offsetParent().offset(), 698 | props = { 699 | top: coords.top - parentOffset.top, 700 | left: coords.left - parentOffset.left 701 | } 702 | 703 | if ($this.css('position') == 'static') props['position'] = 'relative' 704 | $this.css(props) 705 | }) 706 | if (!this.length) return null 707 | if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0])) 708 | return {top: 0, left: 0} 709 | var obj = this[0].getBoundingClientRect() 710 | return { 711 | left: obj.left + window.pageXOffset, 712 | top: obj.top + window.pageYOffset, 713 | width: Math.round(obj.width), 714 | height: Math.round(obj.height) 715 | } 716 | }, 717 | css: function(property, value){ 718 | if (arguments.length < 2) { 719 | var element = this[0] 720 | if (typeof property == 'string') { 721 | if (!element) return 722 | return element.style[camelize(property)] || getComputedStyle(element, '').getPropertyValue(property) 723 | } else if (isArray(property)) { 724 | if (!element) return 725 | var props = {} 726 | var computedStyle = getComputedStyle(element, '') 727 | $.each(property, function(_, prop){ 728 | props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop)) 729 | }) 730 | return props 731 | } 732 | } 733 | 734 | var css = '' 735 | if (type(property) == 'string') { 736 | if (!value && value !== 0) 737 | this.each(function(){ this.style.removeProperty(dasherize(property)) }) 738 | else 739 | css = dasherize(property) + ":" + maybeAddPx(property, value) 740 | } else { 741 | for (key in property) 742 | if (!property[key] && property[key] !== 0) 743 | this.each(function(){ this.style.removeProperty(dasherize(key)) }) 744 | else 745 | css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';' 746 | } 747 | 748 | return this.each(function(){ this.style.cssText += ';' + css }) 749 | }, 750 | index: function(element){ 751 | return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0]) 752 | }, 753 | hasClass: function(name){ 754 | if (!name) return false 755 | return emptyArray.some.call(this, function(el){ 756 | return this.test(className(el)) 757 | }, classRE(name)) 758 | }, 759 | addClass: function(name){ 760 | if (!name) return this 761 | return this.each(function(idx){ 762 | if (!('className' in this)) return 763 | classList = [] 764 | var cls = className(this), newName = funcArg(this, name, idx, cls) 765 | newName.split(/\s+/g).forEach(function(klass){ 766 | if (!$(this).hasClass(klass)) classList.push(klass) 767 | }, this) 768 | classList.length && className(this, cls + (cls ? " " : "") + classList.join(" ")) 769 | }) 770 | }, 771 | removeClass: function(name){ 772 | return this.each(function(idx){ 773 | if (!('className' in this)) return 774 | if (name === undefined) return className(this, '') 775 | classList = className(this) 776 | funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){ 777 | classList = classList.replace(classRE(klass), " ") 778 | }) 779 | className(this, classList.trim()) 780 | }) 781 | }, 782 | toggleClass: function(name, when){ 783 | if (!name) return this 784 | return this.each(function(idx){ 785 | var $this = $(this), names = funcArg(this, name, idx, className(this)) 786 | names.split(/\s+/g).forEach(function(klass){ 787 | (when === undefined ? !$this.hasClass(klass) : when) ? 788 | $this.addClass(klass) : $this.removeClass(klass) 789 | }) 790 | }) 791 | }, 792 | scrollTop: function(value){ 793 | if (!this.length) return 794 | var hasScrollTop = 'scrollTop' in this[0] 795 | if (value === undefined) return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset 796 | return this.each(hasScrollTop ? 797 | function(){ this.scrollTop = value } : 798 | function(){ this.scrollTo(this.scrollX, value) }) 799 | }, 800 | scrollLeft: function(value){ 801 | if (!this.length) return 802 | var hasScrollLeft = 'scrollLeft' in this[0] 803 | if (value === undefined) return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset 804 | return this.each(hasScrollLeft ? 805 | function(){ this.scrollLeft = value } : 806 | function(){ this.scrollTo(value, this.scrollY) }) 807 | }, 808 | position: function() { 809 | if (!this.length) return 810 | 811 | var elem = this[0], 812 | // Get *real* offsetParent 813 | offsetParent = this.offsetParent(), 814 | // Get correct offsets 815 | offset = this.offset(), 816 | parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset() 817 | 818 | // Subtract element margins 819 | // note: when an element has margin: auto the offsetLeft and marginLeft 820 | // are the same in Safari causing offset.left to incorrectly be 0 821 | offset.top -= parseFloat( $(elem).css('margin-top') ) || 0 822 | offset.left -= parseFloat( $(elem).css('margin-left') ) || 0 823 | 824 | // Add offsetParent borders 825 | parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0 826 | parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0 827 | 828 | // Subtract the two offsets 829 | return { 830 | top: offset.top - parentOffset.top, 831 | left: offset.left - parentOffset.left 832 | } 833 | }, 834 | offsetParent: function() { 835 | return this.map(function(){ 836 | var parent = this.offsetParent || document.body 837 | while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static") 838 | parent = parent.offsetParent 839 | return parent 840 | }) 841 | } 842 | } 843 | 844 | // for now 845 | $.fn.detach = $.fn.remove 846 | 847 | // Generate the `width` and `height` functions 848 | ;['width', 'height'].forEach(function(dimension){ 849 | var dimensionProperty = 850 | dimension.replace(/./, function(m){ return m[0].toUpperCase() }) 851 | 852 | $.fn[dimension] = function(value){ 853 | var offset, el = this[0] 854 | if (value === undefined) return isWindow(el) ? el['inner' + dimensionProperty] : 855 | isDocument(el) ? el.documentElement['scroll' + dimensionProperty] : 856 | (offset = this.offset()) && offset[dimension] 857 | else return this.each(function(idx){ 858 | el = $(this) 859 | el.css(dimension, funcArg(this, value, idx, el[dimension]())) 860 | }) 861 | } 862 | }) 863 | 864 | function traverseNode(node, fun) { 865 | fun(node) 866 | for (var i = 0, len = node.childNodes.length; i < len; i++) 867 | traverseNode(node.childNodes[i], fun) 868 | } 869 | 870 | // Generate the `after`, `prepend`, `before`, `append`, 871 | // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods. 872 | adjacencyOperators.forEach(function(operator, operatorIndex) { 873 | var inside = operatorIndex % 2 //=> prepend, append 874 | 875 | $.fn[operator] = function(){ 876 | // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings 877 | var argType, nodes = $.map(arguments, function(arg) { 878 | var arr = [] 879 | argType = type(arg) 880 | if (argType == "array") { 881 | arg.forEach(function(el) { 882 | if (el.nodeType !== undefined) return arr.push(el) 883 | else if ($.zepto.isZ(el)) return arr = arr.concat(el.get()) 884 | arr = arr.concat(zepto.fragment(el)) 885 | }) 886 | return arr 887 | } 888 | return argType == "object" || arg == null ? 889 | arg : zepto.fragment(arg) 890 | }), 891 | parent, copyByClone = this.length > 1 892 | if (nodes.length < 1) return this 893 | 894 | return this.each(function(_, target){ 895 | parent = inside ? target : target.parentNode 896 | 897 | // convert all methods to a "before" operation 898 | target = operatorIndex == 0 ? target.nextSibling : 899 | operatorIndex == 1 ? target.firstChild : 900 | operatorIndex == 2 ? target : 901 | null 902 | 903 | var parentInDocument = $.contains(document.documentElement, parent) 904 | 905 | nodes.forEach(function(node){ 906 | if (copyByClone) node = node.cloneNode(true) 907 | else if (!parent) return $(node).remove() 908 | 909 | parent.insertBefore(node, target) 910 | if (parentInDocument) traverseNode(node, function(el){ 911 | if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' && 912 | (!el.type || el.type === 'text/javascript') && !el.src){ 913 | var target = el.ownerDocument ? el.ownerDocument.defaultView : window 914 | target['eval'].call(target, el.innerHTML) 915 | } 916 | }) 917 | }) 918 | }) 919 | } 920 | 921 | // after => insertAfter 922 | // prepend => prependTo 923 | // before => insertBefore 924 | // append => appendTo 925 | $.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){ 926 | $(html)[operator](this) 927 | return this 928 | } 929 | }) 930 | 931 | zepto.Z.prototype = Z.prototype = $.fn 932 | 933 | // Export internal API functions in the `$.zepto` namespace 934 | zepto.uniq = uniq 935 | zepto.deserializeValue = deserializeValue 936 | $.zepto = zepto 937 | 938 | return $ 939 | })() 940 | 941 | window.Zepto = Zepto 942 | window.$ === undefined && (window.$ = Zepto) 943 | 944 | ;(function($){ 945 | var _zid = 1, undefined, 946 | slice = Array.prototype.slice, 947 | isFunction = $.isFunction, 948 | isString = function(obj){ return typeof obj == 'string' }, 949 | handlers = {}, 950 | specialEvents={}, 951 | focusinSupported = 'onfocusin' in window, 952 | focus = { focus: 'focusin', blur: 'focusout' }, 953 | hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' } 954 | 955 | specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents' 956 | 957 | function zid(element) { 958 | return element._zid || (element._zid = _zid++) 959 | } 960 | function findHandlers(element, event, fn, selector) { 961 | event = parse(event) 962 | if (event.ns) var matcher = matcherFor(event.ns) 963 | return (handlers[zid(element)] || []).filter(function(handler) { 964 | return handler 965 | && (!event.e || handler.e == event.e) 966 | && (!event.ns || matcher.test(handler.ns)) 967 | && (!fn || zid(handler.fn) === zid(fn)) 968 | && (!selector || handler.sel == selector) 969 | }) 970 | } 971 | function parse(event) { 972 | var parts = ('' + event).split('.') 973 | return {e: parts[0], ns: parts.slice(1).sort().join(' ')} 974 | } 975 | function matcherFor(ns) { 976 | return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)') 977 | } 978 | 979 | function eventCapture(handler, captureSetting) { 980 | return handler.del && 981 | (!focusinSupported && (handler.e in focus)) || 982 | !!captureSetting 983 | } 984 | 985 | function realEvent(type) { 986 | return hover[type] || (focusinSupported && focus[type]) || type 987 | } 988 | 989 | function add(element, events, fn, data, selector, delegator, capture){ 990 | var id = zid(element), set = (handlers[id] || (handlers[id] = [])) 991 | events.split(/\s/).forEach(function(event){ 992 | if (event == 'ready') return $(document).ready(fn) 993 | var handler = parse(event) 994 | handler.fn = fn 995 | handler.sel = selector 996 | // emulate mouseenter, mouseleave 997 | if (handler.e in hover) fn = function(e){ 998 | var related = e.relatedTarget 999 | if (!related || (related !== this && !$.contains(this, related))) 1000 | return handler.fn.apply(this, arguments) 1001 | } 1002 | handler.del = delegator 1003 | var callback = delegator || fn 1004 | handler.proxy = function(e){ 1005 | e = compatible(e) 1006 | if (e.isImmediatePropagationStopped()) return 1007 | e.data = data 1008 | var result = callback.apply(element, e._args == undefined ? [e] : [e].concat(e._args)) 1009 | if (result === false) e.preventDefault(), e.stopPropagation() 1010 | return result 1011 | } 1012 | handler.i = set.length 1013 | set.push(handler) 1014 | if ('addEventListener' in element) 1015 | element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture)) 1016 | }) 1017 | } 1018 | function remove(element, events, fn, selector, capture){ 1019 | var id = zid(element) 1020 | ;(events || '').split(/\s/).forEach(function(event){ 1021 | findHandlers(element, event, fn, selector).forEach(function(handler){ 1022 | delete handlers[id][handler.i] 1023 | if ('removeEventListener' in element) 1024 | element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture)) 1025 | }) 1026 | }) 1027 | } 1028 | 1029 | $.event = { add: add, remove: remove } 1030 | 1031 | $.proxy = function(fn, context) { 1032 | var args = (2 in arguments) && slice.call(arguments, 2) 1033 | if (isFunction(fn)) { 1034 | var proxyFn = function(){ return fn.apply(context, args ? args.concat(slice.call(arguments)) : arguments) } 1035 | proxyFn._zid = zid(fn) 1036 | return proxyFn 1037 | } else if (isString(context)) { 1038 | if (args) { 1039 | args.unshift(fn[context], fn) 1040 | return $.proxy.apply(null, args) 1041 | } else { 1042 | return $.proxy(fn[context], fn) 1043 | } 1044 | } else { 1045 | throw new TypeError("expected function") 1046 | } 1047 | } 1048 | 1049 | $.fn.bind = function(event, data, callback){ 1050 | return this.on(event, data, callback) 1051 | } 1052 | $.fn.unbind = function(event, callback){ 1053 | return this.off(event, callback) 1054 | } 1055 | $.fn.one = function(event, selector, data, callback){ 1056 | return this.on(event, selector, data, callback, 1) 1057 | } 1058 | 1059 | var returnTrue = function(){return true}, 1060 | returnFalse = function(){return false}, 1061 | ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/, 1062 | eventMethods = { 1063 | preventDefault: 'isDefaultPrevented', 1064 | stopImmediatePropagation: 'isImmediatePropagationStopped', 1065 | stopPropagation: 'isPropagationStopped' 1066 | } 1067 | 1068 | function compatible(event, source) { 1069 | if (source || !event.isDefaultPrevented) { 1070 | source || (source = event) 1071 | 1072 | $.each(eventMethods, function(name, predicate) { 1073 | var sourceMethod = source[name] 1074 | event[name] = function(){ 1075 | this[predicate] = returnTrue 1076 | return sourceMethod && sourceMethod.apply(source, arguments) 1077 | } 1078 | event[predicate] = returnFalse 1079 | }) 1080 | 1081 | event.timeStamp || (event.timeStamp = Date.now()) 1082 | 1083 | if (source.defaultPrevented !== undefined ? source.defaultPrevented : 1084 | 'returnValue' in source ? source.returnValue === false : 1085 | source.getPreventDefault && source.getPreventDefault()) 1086 | event.isDefaultPrevented = returnTrue 1087 | } 1088 | return event 1089 | } 1090 | 1091 | function createProxy(event) { 1092 | var key, proxy = { originalEvent: event } 1093 | for (key in event) 1094 | if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key] 1095 | 1096 | return compatible(proxy, event) 1097 | } 1098 | 1099 | $.fn.delegate = function(selector, event, callback){ 1100 | return this.on(event, selector, callback) 1101 | } 1102 | $.fn.undelegate = function(selector, event, callback){ 1103 | return this.off(event, selector, callback) 1104 | } 1105 | 1106 | $.fn.live = function(event, callback){ 1107 | $(document.body).delegate(this.selector, event, callback) 1108 | return this 1109 | } 1110 | $.fn.die = function(event, callback){ 1111 | $(document.body).undelegate(this.selector, event, callback) 1112 | return this 1113 | } 1114 | 1115 | $.fn.on = function(event, selector, data, callback, one){ 1116 | var autoRemove, delegator, $this = this 1117 | if (event && !isString(event)) { 1118 | $.each(event, function(type, fn){ 1119 | $this.on(type, selector, data, fn, one) 1120 | }) 1121 | return $this 1122 | } 1123 | 1124 | if (!isString(selector) && !isFunction(callback) && callback !== false) 1125 | callback = data, data = selector, selector = undefined 1126 | if (callback === undefined || data === false) 1127 | callback = data, data = undefined 1128 | 1129 | if (callback === false) callback = returnFalse 1130 | 1131 | return $this.each(function(_, element){ 1132 | if (one) autoRemove = function(e){ 1133 | remove(element, e.type, callback) 1134 | return callback.apply(this, arguments) 1135 | } 1136 | 1137 | if (selector) delegator = function(e){ 1138 | var evt, match = $(e.target).closest(selector, element).get(0) 1139 | if (match && match !== element) { 1140 | evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element}) 1141 | return (autoRemove || callback).apply(match, [evt].concat(slice.call(arguments, 1))) 1142 | } 1143 | } 1144 | 1145 | add(element, event, callback, data, selector, delegator || autoRemove) 1146 | }) 1147 | } 1148 | $.fn.off = function(event, selector, callback){ 1149 | var $this = this 1150 | if (event && !isString(event)) { 1151 | $.each(event, function(type, fn){ 1152 | $this.off(type, selector, fn) 1153 | }) 1154 | return $this 1155 | } 1156 | 1157 | if (!isString(selector) && !isFunction(callback) && callback !== false) 1158 | callback = selector, selector = undefined 1159 | 1160 | if (callback === false) callback = returnFalse 1161 | 1162 | return $this.each(function(){ 1163 | remove(this, event, callback, selector) 1164 | }) 1165 | } 1166 | 1167 | $.fn.trigger = function(event, args){ 1168 | event = (isString(event) || $.isPlainObject(event)) ? $.Event(event) : compatible(event) 1169 | event._args = args 1170 | return this.each(function(){ 1171 | // handle focus(), blur() by calling them directly 1172 | if (event.type in focus && typeof this[event.type] == "function") this[event.type]() 1173 | // items in the collection might not be DOM elements 1174 | else if ('dispatchEvent' in this) this.dispatchEvent(event) 1175 | else $(this).triggerHandler(event, args) 1176 | }) 1177 | } 1178 | 1179 | // triggers event handlers on current element just as if an event occurred, 1180 | // doesn't trigger an actual event, doesn't bubble 1181 | $.fn.triggerHandler = function(event, args){ 1182 | var e, result 1183 | this.each(function(i, element){ 1184 | e = createProxy(isString(event) ? $.Event(event) : event) 1185 | e._args = args 1186 | e.target = element 1187 | $.each(findHandlers(element, event.type || event), function(i, handler){ 1188 | result = handler.proxy(e) 1189 | if (e.isImmediatePropagationStopped()) return false 1190 | }) 1191 | }) 1192 | return result 1193 | } 1194 | 1195 | // shortcut methods for `.bind(event, fn)` for each event type 1196 | ;('focusin focusout focus blur load resize scroll unload click dblclick '+ 1197 | 'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+ 1198 | 'change select keydown keypress keyup error').split(' ').forEach(function(event) { 1199 | $.fn[event] = function(callback) { 1200 | return (0 in arguments) ? 1201 | this.bind(event, callback) : 1202 | this.trigger(event) 1203 | } 1204 | }) 1205 | 1206 | $.Event = function(type, props) { 1207 | if (!isString(type)) props = type, type = props.type 1208 | var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true 1209 | if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name]) 1210 | event.initEvent(type, bubbles, true) 1211 | return compatible(event) 1212 | } 1213 | 1214 | })(Zepto) 1215 | 1216 | ;(function($){ 1217 | var jsonpID = +new Date(), 1218 | document = window.document, 1219 | key, 1220 | name, 1221 | rscript = /)<[^<]*)*<\/script>/gi, 1222 | scriptTypeRE = /^(?:text|application)\/javascript/i, 1223 | xmlTypeRE = /^(?:text|application)\/xml/i, 1224 | jsonType = 'application/json', 1225 | htmlType = 'text/html', 1226 | blankRE = /^\s*$/, 1227 | originAnchor = document.createElement('a') 1228 | 1229 | originAnchor.href = window.location.href 1230 | 1231 | // trigger a custom event and return false if it was cancelled 1232 | function triggerAndReturn(context, eventName, data) { 1233 | var event = $.Event(eventName) 1234 | $(context).trigger(event, data) 1235 | return !event.isDefaultPrevented() 1236 | } 1237 | 1238 | // trigger an Ajax "global" event 1239 | function triggerGlobal(settings, context, eventName, data) { 1240 | if (settings.global) return triggerAndReturn(context || document, eventName, data) 1241 | } 1242 | 1243 | // Number of active Ajax requests 1244 | $.active = 0 1245 | 1246 | function ajaxStart(settings) { 1247 | if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart') 1248 | } 1249 | function ajaxStop(settings) { 1250 | if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop') 1251 | } 1252 | 1253 | // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable 1254 | function ajaxBeforeSend(xhr, settings) { 1255 | var context = settings.context 1256 | if (settings.beforeSend.call(context, xhr, settings) === false || 1257 | triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) 1258 | return false 1259 | 1260 | triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]) 1261 | } 1262 | function ajaxSuccess(data, xhr, settings, deferred) { 1263 | var context = settings.context, status = 'success' 1264 | settings.success.call(context, data, status, xhr) 1265 | if (deferred) deferred.resolveWith(context, [data, status, xhr]) 1266 | triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]) 1267 | ajaxComplete(status, xhr, settings) 1268 | } 1269 | // type: "timeout", "error", "abort", "parsererror" 1270 | function ajaxError(error, type, xhr, settings, deferred) { 1271 | var context = settings.context 1272 | settings.error.call(context, xhr, type, error) 1273 | if (deferred) deferred.rejectWith(context, [xhr, type, error]) 1274 | triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type]) 1275 | ajaxComplete(type, xhr, settings) 1276 | } 1277 | // status: "success", "notmodified", "error", "timeout", "abort", "parsererror" 1278 | function ajaxComplete(status, xhr, settings) { 1279 | var context = settings.context 1280 | settings.complete.call(context, xhr, status) 1281 | triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]) 1282 | ajaxStop(settings) 1283 | } 1284 | 1285 | function ajaxDataFilter(data, type, settings) { 1286 | if (settings.dataFilter == empty) return data 1287 | var context = settings.context 1288 | return settings.dataFilter.call(context, data, type) 1289 | } 1290 | 1291 | // Empty function, used as default callback 1292 | function empty() {} 1293 | 1294 | $.ajaxJSONP = function(options, deferred){ 1295 | if (!('type' in options)) return $.ajax(options) 1296 | 1297 | var _callbackName = options.jsonpCallback, 1298 | callbackName = ($.isFunction(_callbackName) ? 1299 | _callbackName() : _callbackName) || ('Zepto' + (jsonpID++)), 1300 | script = document.createElement('script'), 1301 | originalCallback = window[callbackName], 1302 | responseData, 1303 | abort = function(errorType) { 1304 | $(script).triggerHandler('error', errorType || 'abort') 1305 | }, 1306 | xhr = { abort: abort }, abortTimeout 1307 | 1308 | if (deferred) deferred.promise(xhr) 1309 | 1310 | $(script).on('load error', function(e, errorType){ 1311 | clearTimeout(abortTimeout) 1312 | $(script).off().remove() 1313 | 1314 | if (e.type == 'error' || !responseData) { 1315 | ajaxError(null, errorType || 'error', xhr, options, deferred) 1316 | } else { 1317 | ajaxSuccess(responseData[0], xhr, options, deferred) 1318 | } 1319 | 1320 | window[callbackName] = originalCallback 1321 | if (responseData && $.isFunction(originalCallback)) 1322 | originalCallback(responseData[0]) 1323 | 1324 | originalCallback = responseData = undefined 1325 | }) 1326 | 1327 | if (ajaxBeforeSend(xhr, options) === false) { 1328 | abort('abort') 1329 | return xhr 1330 | } 1331 | 1332 | window[callbackName] = function(){ 1333 | responseData = arguments 1334 | } 1335 | 1336 | script.src = options.url.replace(/\?(.+)=\?/, '?$1=' + callbackName) 1337 | document.head.appendChild(script) 1338 | 1339 | if (options.timeout > 0) abortTimeout = setTimeout(function(){ 1340 | abort('timeout') 1341 | }, options.timeout) 1342 | 1343 | return xhr 1344 | } 1345 | 1346 | $.ajaxSettings = { 1347 | // Default type of request 1348 | type: 'GET', 1349 | // Callback that is executed before request 1350 | beforeSend: empty, 1351 | // Callback that is executed if the request succeeds 1352 | success: empty, 1353 | // Callback that is executed the the server drops error 1354 | error: empty, 1355 | // Callback that is executed on request complete (both: error and success) 1356 | complete: empty, 1357 | // The context for the callbacks 1358 | context: null, 1359 | // Whether to trigger "global" Ajax events 1360 | global: true, 1361 | // Transport 1362 | xhr: function () { 1363 | return new window.XMLHttpRequest() 1364 | }, 1365 | // MIME types mapping 1366 | // IIS returns Javascript as "application/x-javascript" 1367 | accepts: { 1368 | script: 'text/javascript, application/javascript, application/x-javascript', 1369 | json: jsonType, 1370 | xml: 'application/xml, text/xml', 1371 | html: htmlType, 1372 | text: 'text/plain' 1373 | }, 1374 | // Whether the request is to another domain 1375 | crossDomain: false, 1376 | // Default timeout 1377 | timeout: 0, 1378 | // Whether data should be serialized to string 1379 | processData: true, 1380 | // Whether the browser should be allowed to cache GET responses 1381 | cache: true, 1382 | //Used to handle the raw response data of XMLHttpRequest. 1383 | //This is a pre-filtering function to sanitize the response. 1384 | //The sanitized response should be returned 1385 | dataFilter: empty 1386 | } 1387 | 1388 | function mimeToDataType(mime) { 1389 | if (mime) mime = mime.split(';', 2)[0] 1390 | return mime && ( mime == htmlType ? 'html' : 1391 | mime == jsonType ? 'json' : 1392 | scriptTypeRE.test(mime) ? 'script' : 1393 | xmlTypeRE.test(mime) && 'xml' ) || 'text' 1394 | } 1395 | 1396 | function appendQuery(url, query) { 1397 | if (query == '') return url 1398 | return (url + '&' + query).replace(/[&?]{1,2}/, '?') 1399 | } 1400 | 1401 | // serialize payload and append it to the URL for GET requests 1402 | function serializeData(options) { 1403 | if (options.processData && options.data && $.type(options.data) != "string") 1404 | options.data = $.param(options.data, options.traditional) 1405 | if (options.data && (!options.type || options.type.toUpperCase() == 'GET' || 'jsonp' == options.dataType)) 1406 | options.url = appendQuery(options.url, options.data), options.data = undefined 1407 | } 1408 | 1409 | $.ajax = function(options){ 1410 | var settings = $.extend({}, options || {}), 1411 | deferred = $.Deferred && $.Deferred(), 1412 | urlAnchor, hashIndex 1413 | for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key] 1414 | 1415 | ajaxStart(settings) 1416 | 1417 | if (!settings.crossDomain) { 1418 | urlAnchor = document.createElement('a') 1419 | urlAnchor.href = settings.url 1420 | // cleans up URL for .href (IE only), see https://github.com/madrobby/zepto/pull/1049 1421 | urlAnchor.href = urlAnchor.href 1422 | settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host) 1423 | } 1424 | 1425 | if (!settings.url) settings.url = window.location.toString() 1426 | if ((hashIndex = settings.url.indexOf('#')) > -1) settings.url = settings.url.slice(0, hashIndex) 1427 | serializeData(settings) 1428 | 1429 | var dataType = settings.dataType, hasPlaceholder = /\?.+=\?/.test(settings.url) 1430 | if (hasPlaceholder) dataType = 'jsonp' 1431 | 1432 | if (settings.cache === false || ( 1433 | (!options || options.cache !== true) && 1434 | ('script' == dataType || 'jsonp' == dataType) 1435 | )) 1436 | settings.url = appendQuery(settings.url, '_=' + Date.now()) 1437 | 1438 | if ('jsonp' == dataType) { 1439 | if (!hasPlaceholder) 1440 | settings.url = appendQuery(settings.url, 1441 | settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?') 1442 | return $.ajaxJSONP(settings, deferred) 1443 | } 1444 | 1445 | var mime = settings.accepts[dataType], 1446 | headers = { }, 1447 | setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] }, 1448 | protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol, 1449 | xhr = settings.xhr(), 1450 | nativeSetHeader = xhr.setRequestHeader, 1451 | abortTimeout 1452 | 1453 | if (deferred) deferred.promise(xhr) 1454 | 1455 | if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest') 1456 | setHeader('Accept', mime || '*/*') 1457 | if (mime = settings.mimeType || mime) { 1458 | if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0] 1459 | xhr.overrideMimeType && xhr.overrideMimeType(mime) 1460 | } 1461 | if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET')) 1462 | setHeader('Content-Type', settings.contentType || 'application/x-www-form-urlencoded') 1463 | 1464 | if (settings.headers) for (name in settings.headers) setHeader(name, settings.headers[name]) 1465 | xhr.setRequestHeader = setHeader 1466 | 1467 | xhr.onreadystatechange = function(){ 1468 | if (xhr.readyState == 4) { 1469 | xhr.onreadystatechange = empty 1470 | clearTimeout(abortTimeout) 1471 | var result, error = false 1472 | if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) { 1473 | dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')) 1474 | 1475 | if (xhr.responseType == 'arraybuffer' || xhr.responseType == 'blob') 1476 | result = xhr.response 1477 | else { 1478 | result = xhr.responseText 1479 | 1480 | try { 1481 | // http://perfectionkills.com/global-eval-what-are-the-options/ 1482 | // sanitize response accordingly if data filter callback provided 1483 | result = ajaxDataFilter(result, dataType, settings) 1484 | if (dataType == 'script') (1,eval)(result) 1485 | else if (dataType == 'xml') result = xhr.responseXML 1486 | else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result) 1487 | } catch (e) { error = e } 1488 | 1489 | if (error) return ajaxError(error, 'parsererror', xhr, settings, deferred) 1490 | } 1491 | 1492 | ajaxSuccess(result, xhr, settings, deferred) 1493 | } else { 1494 | ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred) 1495 | } 1496 | } 1497 | } 1498 | 1499 | if (ajaxBeforeSend(xhr, settings) === false) { 1500 | xhr.abort() 1501 | ajaxError(null, 'abort', xhr, settings, deferred) 1502 | return xhr 1503 | } 1504 | 1505 | var async = 'async' in settings ? settings.async : true 1506 | xhr.open(settings.type, settings.url, async, settings.username, settings.password) 1507 | 1508 | if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name] 1509 | 1510 | for (name in headers) nativeSetHeader.apply(xhr, headers[name]) 1511 | 1512 | if (settings.timeout > 0) abortTimeout = setTimeout(function(){ 1513 | xhr.onreadystatechange = empty 1514 | xhr.abort() 1515 | ajaxError(null, 'timeout', xhr, settings, deferred) 1516 | }, settings.timeout) 1517 | 1518 | // avoid sending empty string (#319) 1519 | xhr.send(settings.data ? settings.data : null) 1520 | return xhr 1521 | } 1522 | 1523 | // handle optional data/success arguments 1524 | function parseArguments(url, data, success, dataType) { 1525 | if ($.isFunction(data)) dataType = success, success = data, data = undefined 1526 | if (!$.isFunction(success)) dataType = success, success = undefined 1527 | return { 1528 | url: url 1529 | , data: data 1530 | , success: success 1531 | , dataType: dataType 1532 | } 1533 | } 1534 | 1535 | $.get = function(/* url, data, success, dataType */){ 1536 | return $.ajax(parseArguments.apply(null, arguments)) 1537 | } 1538 | 1539 | $.post = function(/* url, data, success, dataType */){ 1540 | var options = parseArguments.apply(null, arguments) 1541 | options.type = 'POST' 1542 | return $.ajax(options) 1543 | } 1544 | 1545 | $.getJSON = function(/* url, data, success */){ 1546 | var options = parseArguments.apply(null, arguments) 1547 | options.dataType = 'json' 1548 | return $.ajax(options) 1549 | } 1550 | 1551 | $.fn.load = function(url, data, success){ 1552 | if (!this.length) return this 1553 | var self = this, parts = url.split(/\s/), selector, 1554 | options = parseArguments(url, data, success), 1555 | callback = options.success 1556 | if (parts.length > 1) options.url = parts[0], selector = parts[1] 1557 | options.success = function(response){ 1558 | self.html(selector ? 1559 | $('
').html(response.replace(rscript, "")).find(selector) 1560 | : response) 1561 | callback && callback.apply(self, arguments) 1562 | } 1563 | $.ajax(options) 1564 | return this 1565 | } 1566 | 1567 | var escape = encodeURIComponent 1568 | 1569 | function serialize(params, obj, traditional, scope){ 1570 | var type, array = $.isArray(obj), hash = $.isPlainObject(obj) 1571 | $.each(obj, function(key, value) { 1572 | type = $.type(value) 1573 | if (scope) key = traditional ? scope : 1574 | scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']' 1575 | // handle data in serializeArray() format 1576 | if (!scope && array) params.add(value.name, value.value) 1577 | // recurse into nested objects 1578 | else if (type == "array" || (!traditional && type == "object")) 1579 | serialize(params, value, traditional, key) 1580 | else params.add(key, value) 1581 | }) 1582 | } 1583 | 1584 | $.param = function(obj, traditional){ 1585 | var params = [] 1586 | params.add = function(key, value) { 1587 | if ($.isFunction(value)) value = value() 1588 | if (value == null) value = "" 1589 | this.push(escape(key) + '=' + escape(value)) 1590 | } 1591 | serialize(params, obj, traditional) 1592 | return params.join('&').replace(/%20/g, '+') 1593 | } 1594 | })(Zepto) 1595 | 1596 | ;(function($){ 1597 | $.fn.serializeArray = function() { 1598 | var name, type, result = [], 1599 | add = function(value) { 1600 | if (value.forEach) return value.forEach(add) 1601 | result.push({ name: name, value: value }) 1602 | } 1603 | if (this[0]) $.each(this[0].elements, function(_, field){ 1604 | type = field.type, name = field.name 1605 | if (name && field.nodeName.toLowerCase() != 'fieldset' && 1606 | !field.disabled && type != 'submit' && type != 'reset' && type != 'button' && type != 'file' && 1607 | ((type != 'radio' && type != 'checkbox') || field.checked)) 1608 | add($(field).val()) 1609 | }) 1610 | return result 1611 | } 1612 | 1613 | $.fn.serialize = function(){ 1614 | var result = [] 1615 | this.serializeArray().forEach(function(elm){ 1616 | result.push(encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value)) 1617 | }) 1618 | return result.join('&') 1619 | } 1620 | 1621 | $.fn.submit = function(callback) { 1622 | if (0 in arguments) this.bind('submit', callback) 1623 | else if (this.length) { 1624 | var event = $.Event('submit') 1625 | this.eq(0).trigger(event) 1626 | if (!event.isDefaultPrevented()) this.get(0).submit() 1627 | } 1628 | return this 1629 | } 1630 | 1631 | })(Zepto) 1632 | 1633 | ;(function(){ 1634 | // getComputedStyle shouldn't freak out when called 1635 | // without a valid element as argument 1636 | try { 1637 | getComputedStyle(undefined) 1638 | } catch(e) { 1639 | var nativeGetComputedStyle = getComputedStyle 1640 | window.getComputedStyle = function(element, pseudoElement){ 1641 | try { 1642 | return nativeGetComputedStyle(element, pseudoElement) 1643 | } catch(e) { 1644 | return null 1645 | } 1646 | } 1647 | } 1648 | })() 1649 | return Zepto 1650 | })) 1651 | ; 1652 | --------------------------------------------------------------------------------