... | ... |
@@ -8,38 +8,38 @@ |
8 | 8 |
|
9 | 9 |
/*! |
10 | 10 |
* Ender: open module JavaScript framework (client-lib) |
11 |
- * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat) |
|
12 |
- * http://ender.no.de |
|
11 |
+ * copyright Dustin Diaz & Jacob Thornton 2011-2012 (@ded @fat) |
|
12 |
+ * http://ender.jit.su |
|
13 | 13 |
* License MIT |
14 | 14 |
*/ |
15 |
-!function(a){function d(a){var c=b[a]||window[a];if(!c)throw new Error("Requested module '"+a+"' has not been defined.");return c}function e(a,c){return b[a]=c}function f(a,b){for(var c in b)c!="noConflict"&&c!="_VERSION"&&(a[c]=b[c]);return a}function g(a,b,c){return h._select&&(typeof a=="string"||a.nodeName||a.length&&"item"in a||a==window)?(c=h._select(a,b),c.selector=a):c=isFinite(a.length)?a:[a],f(c,g)}function h(a,b){return g(a,b)}a.global=a;var b={},c=a.$;a.provide=e,a.require=d,f(h,{_VERSION:"0.3.4",fn:a.$&&a.$.fn||{},ender:function(a,b){f(b?g:h,a)},_select:function(a,b){return(b||document).querySelectorAll(a)}}),f(g,{forEach:function(a,b,c){for(c=0,l=this.length;c<l;++c)c in this&&a.call(b||this[c],this[c],c,this);return this},$:h}),h.noConflict=function(){return a.$=c,this},typeof module!="undefined"&&module.exports&&(module.exports=h),a.ender=a.$=a.ender||h}(this),!function(){var module={exports:{}},exports=module.exports; |
|
15 |
+(function(context){function require(identifier){var module=modules["$"+identifier]||window[identifier];if(!module)throw new Error("Ender Error: Requested module '"+identifier+"' has not been defined.");return module}function provide(name,what){return modules["$"+name]=what}function aug(o,o2){for(var k in o2)k!="noConflict"&&k!="_VERSION"&&(o[k]=o2[k]);return o}function Ender(s,r){var elements,i;this.selector=s;if(typeof s=="undefined"){elements=[];this.selector=""}else typeof s=="string"||s.nodeName||s.length&&"item"in s||s==window?elements=ender._select(s,r):elements=isFinite(s.length)?s:[s];this.length=elements.length;for(i=this.length;i--;)this[i]=elements[i]}function ender(s,r){return new Ender(s,r)}context.global=context;var modules={},old=context.$,oldEnder=context.ender,oldRequire=context.require,oldProvide=context.provide;context.provide=provide;context.require=require;Ender.prototype.forEach=function(fn,opt_scope){var i,l;for(i=0,l=this.length;i<l;++i)i in this&&fn.call(opt_scope||this[i],this[i],i,this);return this};Ender.prototype.$=ender;ender._VERSION="0.4.3-dev";ender.fn=Ender.prototype;ender.ender=function(o,chain){aug(chain?Ender.prototype:ender,o)};ender._select=function(s,r){return typeof s=="string"?(r||document).querySelectorAll(s):s.nodeName?[s]:s};ender.noConflict=function(callback){context.$=old;if(callback){context.provide=oldProvide;context.require=oldRequire;context.ender=oldEnder;typeof callback=="function"&&callback(require,provide,this)}return this};typeof module!="undefined"&&module.exports&&(module.exports=ender);context.ender=context.$=ender}(this));(function(){var module={exports:{}},exports=module.exports; |
|
16 | 16 |
/*! |
17 | 17 |
* Reqwest! A general purpose XHR connection manager |
18 |
- * (c) Dustin Diaz 2011 |
|
18 |
+ * (c) Dustin Diaz 2012 |
|
19 | 19 |
* https://github.com/ded/reqwest |
20 | 20 |
* license MIT |
21 | 21 |
*/ |
22 |
-!function(a,b){typeof define=="function"?define(b):typeof module!="undefined"?module.exports=b():this[a]=b()}("reqwest",function(){function handleReadyState(a,b,c){return function(){a&&a[readyState]==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept=c.Accept||"text/javascript, text/html, application/xml, text/xml, */*",b.crossOrigin||(c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest"),c[contentType]=c[contentType]||"application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d])}function getCallbackName(a,b){var c=a.jsonpCallback||"callback";if(a.url.slice(-(c.length+2))==c+"=?"){var d="reqwest_"+b;return a.url=a.url.substr(0,a.url.length-1)+d,d}var e=new RegExp(c+"=([\\w]+)");return a.url.match(e)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var g=xhr(),h=(a.method||"GET").toUpperCase(),i=typeof a=="string"?a:a.url,j=a.processData!==!1&&a.data&&typeof a.data!="string"?reqwest.toQueryString(a.data):a.data||null;return h=="GET"&&j&&j!==""&&(i+=(/\?/.test(i)?"&":"?")+j)&&(j=null),g.open(h,i,!0),setHeaders(g,a),g.onreadystatechange=handleReadyState(g,b,c),a.before&&a.before(g),g.send(j),g}var d=doc.createElement("script"),e=0,f=uniqid++;win[getCallbackName(a,f)]=generalCallback,d.type="text/javascript",d.src=a.url,d.async=!0,typeof d.onreadystatechange!="undefined"&&(d.event="onclick",d.htmlFor=d.id="_reqwest_"+f),d.onload=d.onreadystatechange=function(){if(d[readyState]&&d[readyState]!=="complete"&&d[readyState]!=="loaded"||e)return!1;d.onload=d.onreadystatechange=null,d.onclick&&d.onclick(),a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(d),e=1},head.appendChild(d)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){return/\.json$/.test(a)?"json":/\.jsonp$/.test(a)?"jsonp":/\.js$/.test(a)?"js":/\.html?$/.test(a)?"html":/\.xml$/.test(a)?"xml":"js"}function init(o,fn){function complete(a){o.timeout&&clearTimeout(self.timeout),self.timeout=null,o.complete&&o.complete(a)}function success(resp){var r=resp.responseText;if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a,b,c){o.error&&o.error(a,b,c),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function normalize(a){return a?a.replace(/\r?\n/g,"\r\n"):""}function serial(a,b){var c=a.name,d=a.tagName.toLowerCase(),e;if(a.disabled||!c)return;switch(d){case"input":if(!/reset|button|image|file/i.test(a.type)){var f=/checkbox/i.test(a.type),g=/radio/i.test(a.type),h=a.value;(!f&&!g||a.checked)&&b(c,normalize(f&&h===""?"on":h))}break;case"textarea":b(c,normalize(a.value));break;case"select":if(a.type.toLowerCase()==="select-one")e=a.selectedIndex<0?null:a.options[a.selectedIndex],e&&!e.disabled&&b(c,normalize(e.value||e.text));else for(var i=0;a.length&&i<a.length;i++)e=a.options[i],e.selected&&!e.disabled&&b(c,normalize(e.value||e.text))}}function eachFormElement(){var a=this,b=function(b,c){for(var d=0;d<c.length;d++){var e=b[byTag](c[d]);for(var f=0;f<e.length;f++)serial(e[f],a)}};for(var c=0;c<arguments.length;c++){var d=arguments[c];/input|select|textarea/i.test(d.tagName)&&serial(d,a),b(d,["input","select","textarea"])}}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var a={};return eachFormElement.apply(function(b,c){b in a?(a[b]&&!isArray(a[b])&&(a[b]=[a[b]]),a[b].push(c)):a[b]=c},arguments),a}var context=this,win=window,doc=document,old=context.reqwest,twoHundo=/^20\d$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",head=doc[byTag]("head")[0],uniqid=0,lastValue,xhr="XMLHttpRequest"in win?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")};Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}};var isArray=typeof Array.isArray=="function"?Array.isArray:function(a){return Object.prototype.toString.call(a)=="[object Array]"};return reqwest.serializeArray=function(){var a=[];return eachFormElement.apply(function(b,c){a.push({name:b,value:c})},arguments),a},reqwest.serialize=function(){if(arguments.length===0)return"";var a,b,c=Array.prototype.slice.call(arguments,0);return a=c.pop(),a&&a.nodeType&&c.push(a)&&(a=null),a&&(a=a.type),a=="map"?b=serializeHash:a=="array"?b=reqwest.serializeArray:b=serializeQueryString,b.apply(null,c)},reqwest.toQueryString=function(a){var b="",c,d=encodeURIComponent,e=function(a,c){b+=d(a)+"="+d(c)+"&"};if(isArray(a))for(c=0;a&&c<a.length;c++)e(a[c].name,a[c].value);else for(var f in a){if(!Object.hasOwnProperty.call(a,f))continue;var g=a[f];if(isArray(g))for(c=0;c<g.length;c++)e(f,g[c]);else e(f,a[f])}return b.replace(/&$/,"").replace(/%20/g,"+")},reqwest.noConflict=function(){return context.reqwest=old,this},reqwest}),provide("reqwest",module.exports),!function(a){var b=require("reqwest"),c=function(a){return function(){var c=(this&&this.length>0?this:[]).concat(Array.prototype.slice.call(arguments,0));return b[a].apply(null,c)}},d=c("serialize"),e=c("serializeArray");a.ender({ajax:b,serialize:d,serializeArray:e,toQueryString:b.toQueryString}),a.ender({serialize:d,serializeArray:e},!0)}(ender)}(),!function(){var a={exports:{}},b=a.exports; |
|
22 |
+;!function(name,definition){typeof module!="undefined"?module.exports=definition():typeof define=="function"&&define.amd?define(definition):this[name]=definition()}("reqwest",function(){function handleReadyState(o,success,error){return function(){o&&o[readyState]==4&&(twoHundo.test(o.status)?success(o):error(o))}}function setHeaders(http,o){var headers=o.headers||{},h;headers.Accept=headers.Accept||defaultHeaders.accept[o.type]||defaultHeaders.accept["*"];!o.crossOrigin&&!headers[requestedWith]&&(headers[requestedWith]=defaultHeaders.requestedWith);headers[contentType]||(headers[contentType]=o.contentType||defaultHeaders.contentType);for(h in headers)headers.hasOwnProperty(h)&&http.setRequestHeader(h,headers[h])}function setCredentials(http,o){typeof o.withCredentials!="undefined"&&typeof http.withCredentials!="undefined"&&(http.withCredentials=!!o.withCredentials)}function generalCallback(data){lastValue=data}function urlappend(url,s){return url+(/\?/.test(url)?"&":"?")+s}function handleJsonp(o,fn,err,url){var reqId=uniqid++,cbkey=o.jsonpCallback||"callback",cbval=o.jsonpCallbackName||reqwest.getcallbackPrefix(reqId),cbreg=new RegExp("((^|\\?|&)"+cbkey+")=([^&]+)"),match=url.match(cbreg),script=doc.createElement("script"),loaded=0;match?match[3]==="?"?url=url.replace(cbreg,"$1="+cbval):cbval=match[3]:url=urlappend(url,cbkey+"="+cbval);win[cbval]=generalCallback;script.type="text/javascript";script.src=url;script.async=!0;if(typeof script.onreadystatechange!="undefined"){script.event="onclick";script.htmlFor=script.id="_reqwest_"+reqId}script.onload=script.onreadystatechange=function(){if(script[readyState]&&script[readyState]!=="complete"&&script[readyState]!=="loaded"||loaded)return!1;script.onload=script.onreadystatechange=null;script.onclick&&script.onclick();o.success&&o.success(lastValue);lastValue=undefined;head.removeChild(script);loaded=1};head.appendChild(script)}function getRequest(o,fn,err){var method=(o.method||"GET").toUpperCase(),url=typeof o=="string"?o:o.url,data=o.processData!==!1&&o.data&&typeof o.data!="string"?reqwest.toQueryString(o.data):o.data||null,http;if((o.type=="jsonp"||method=="GET")&&data){url=urlappend(url,data);data=null}if(o.type=="jsonp")return handleJsonp(o,fn,err,url);http=xhr();http.open(method,url,!0);setHeaders(http,o);setCredentials(http,o);http.onreadystatechange=handleReadyState(http,fn,err);o.before&&o.before(http);http.send(data);return http}function Reqwest(o,fn){this.o=o;this.fn=fn;init.apply(this,arguments)}function setType(url){var m=url.match(/\.(json|jsonp|html|xml)(\?|$)/);return m?m[1]:"js"}function init(o,fn){function complete(resp){o.timeout&&clearTimeout(self.timeout);self.timeout=null;while(self._completeHandlers.length>0)self._completeHandlers.shift()(resp)}function success(resp){var r=resp.responseText;if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML}self._responseArgs.resp=resp;self._fulfilled=!0;fn(resp);while(self._fulfillmentHandlers.length>0)self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(resp,msg,t){self._responseArgs.resp=resp;self._responseArgs.msg=msg;self._responseArgs.t=t;self._erred=!0;while(self._errorHandlers.length>0)self._errorHandlers.shift()(resp,msg,t);complete(resp)}this.url=typeof o=="string"?o:o.url;this.timeout=null;this._fulfilled=!1;this._fulfillmentHandlers=[];this._errorHandlers=[];this._completeHandlers=[];this._erred=!1;this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){};o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout));o.success&&this._fulfillmentHandlers.push(function(){o.success.apply(o,arguments)});o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)});o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)});this.request=getRequest(o,success,error)}function reqwest(o,fn){return new Reqwest(o,fn)}function normalize(s){return s?s.replace(/\r?\n/g,"\r\n"):""}function serial(el,cb){var n=el.name,t=el.tagName.toLowerCase(),optCb=function(o){o&&!o.disabled&&cb(n,normalize(o.attributes.value&&o.attributes.value.specified?o.value:o.text))};if(el.disabled||!n)return;switch(t){case"input":if(!/reset|button|image|file/i.test(el.type)){var ch=/checkbox/i.test(el.type),ra=/radio/i.test(el.type),val=el.value;(!ch&&!ra||el.checked)&&cb(n,normalize(ch&&val===""?"on":val))}break;case"textarea":cb(n,normalize(el.value));break;case"select":if(el.type.toLowerCase()==="select-one")optCb(el.selectedIndex>=0?el.options[el.selectedIndex]:null);else for(var i=0;el.length&&i<el.length;i++)el.options[i].selected&&optCb(el.options[i])}}function eachFormElement(){var cb=this,e,i,j,serializeSubtags=function(e,tags){for(var i=0;i<tags.length;i++){var fa=e[byTag](tags[i]);for(j=0;j<fa.length;j++)serial(fa[j],cb)}};for(i=0;i<arguments.length;i++){e=arguments[i];/input|select|textarea/i.test(e.tagName)&&serial(e,cb);serializeSubtags(e,["input","select","textarea"])}}function serializeQueryString(){return reqwest.toQueryString(reqwest.serializeArray.apply(null,arguments))}function serializeHash(){var hash={};eachFormElement.apply(function(name,value){if(name in hash){hash[name]&&!isArray(hash[name])&&(hash[name]=[hash[name]]);hash[name].push(value)}else hash[name]=value},arguments);return hash}var win=window,doc=document,twoHundo=/^20\d$/,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",requestedWith="X-Requested-With",head=doc[byTag]("head")[0],uniqid=0,callbackPrefix="reqwest_"+ +(new Date),lastValue,xmlHttpRequest="XMLHttpRequest",isArray=typeof Array.isArray=="function"?Array.isArray:function(a){return a instanceof Array},defaultHeaders={contentType:"application/x-www-form-urlencoded",requestedWith:xmlHttpRequest,accept:{"*":"text/javascript, text/html, application/xml, text/xml, */*",xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript",js:"application/javascript, text/javascript"}},xhr=win[xmlHttpRequest]?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")};Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)},then:function(success,fail){if(this._fulfilled)success(this._responseArgs.resp);else if(this._erred)fail(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t);else{this._fulfillmentHandlers.push(success);this._errorHandlers.push(fail)}return this},always:function(fn){this._fulfilled||this._erred?fn(this._responseArgs.resp):this._completeHandlers.push(fn);return this},fail:function(fn){this._erred?fn(this._responseArgs.resp,this._responseArgs.msg,this._responseArgs.t):this._errorHandlers.push(fn);return this}};reqwest.serializeArray=function(){var arr=[];eachFormElement.apply(function(name,value){arr.push({name:name,value:value})},arguments);return arr};reqwest.serialize=function(){if(arguments.length===0)return"";var opt,fn,args=Array.prototype.slice.call(arguments,0);opt=args.pop();opt&&opt.nodeType&&args.push(opt)&&(opt=null);opt&&(opt=opt.type);opt=="map"?fn=serializeHash:opt=="array"?fn=reqwest.serializeArray:fn=serializeQueryString;return fn.apply(null,args)};reqwest.toQueryString=function(o){var qs="",i,enc=encodeURIComponent,push=function(k,v){qs+=enc(k)+"="+enc(v)+"&"};if(isArray(o))for(i=0;o&&i<o.length;i++)push(o[i].name,o[i].value);else for(var k in o){if(!Object.hasOwnProperty.call(o,k))continue;var v=o[k];if(isArray(v))for(i=0;i<v.length;i++)push(k,v[i]);else push(k,o[k])}return qs.replace(/&$/,"").replace(/%20/g,"+")};reqwest.getcallbackPrefix=function(reqId){return callbackPrefix};reqwest.compat=function(o,fn){if(o){o.type&&(o.method=o.type)&&delete o.type;o.dataType&&(o.type=o.dataType);o.jsonpCallback&&(o.jsonpCallbackName=o.jsonpCallback)&&delete o.jsonpCallback;o.jsonp&&(o.jsonpCallback=o.jsonp)}return new Reqwest(o,fn)};return reqwest});provide("reqwest",module.exports);!function($){var r=require("reqwest"),integrate=function(method){return function(){var args=Array.prototype.slice.call(arguments,0),i=this&&this.length||0;while(i--)args.unshift(this[i]);return r[method].apply(null,args)}},s=integrate("serialize"),sa=integrate("serializeArray");$.ender({ajax:r,serialize:r.serialize,serializeArray:r.serializeArray,toQueryString:r.toQueryString});$.ender({serialize:s,serializeArray:sa},!0)}(ender)})();(function(){var module={exports:{}},exports=module.exports; |
|
23 | 23 |
/*! |
24 |
- * bean.js - copyright Jacob Thornton 2011 |
|
24 |
+ * Bean - copyright (c) Jacob Thornton 2011-2012 |
|
25 | 25 |
* https://github.com/fat/bean |
26 |
- * MIT License |
|
27 |
- * special thanks to: |
|
28 |
- * dean edwards: http://dean.edwards.name/ |
|
29 |
- * dperini: https://github.com/dperini/nwevents |
|
30 |
- * the entire mootools team: github.com/mootools/mootools-core |
|
26 |
+ * MIT license |
|
31 | 27 |
*/ |
32 |
-!function(b,c){typeof define=="function"?define(c):typeof a!="undefined"?a.exports=c():this[b]=c()}("bean",function(){function F(a){var b=a.relatedTarget;return b?b!=this&&b.prefix!="xul"&&!/document/.test(this.toString())&&!p(this,b):b===null}var a=window,b=1,c={},d={},e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=function(a,b){var c=b.parentNode;while(c!==null){if(c==a)return!0;c=c.parentNode}},q=function(a,c){return a.__uid=c&&c+"::"+b++||a.__uid||b++},r=function(a){var b=q(a);return c[b]=c[b]||{}},s=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&a["_on"+e]===null&&(a["_on"+e]=0),a[d?i:k]("on"+b,c)},t=function(b,c,d){return function(e){return e=D(e||((this.ownerDocument||this.document||this).parentWindow||a).event),c.apply(b,[e].concat(d))}},u=function(b,c,d,e,f){return function(g){if(e?e.apply(this,arguments):n?!0:g&&g.propertyName=="_on"+d||!g)g=g?D(g||((this.ownerDocument||this.document||this).parentWindow||a).event):null,c.apply(b,Array.prototype.slice.call(arguments,g?0:1).concat(f))}},v=function(a,b,c,e){var h=b.replace(g,""),i=r(a),j=i[h]||(i[h]={}),k=c,l=q(c,b.replace(f,""));if(j[l])return a;var m=G[h];m&&(c=m.condition?u(a,c,h,m.condition):c,h=m.base||h);var p=E[h];c=p?t(a,c,e):u(a,c,h,!1,e),p=n||p;if(h=="unload"){var v=c;c=function(){w(a,h,c)&&v()}}return a[o]&&s(a,p?h:"propertychange",c,!0,!p&&h),j[l]=c,c.__uid=l,c.__originalFn=k,h=="unload"?a:d[q(a)]=a},w=function(a,b,c){function l(b){c=j[k][b];if(!c)return;delete j[k][b];if(a[o]){k=G[k]?G[k].base:k;var d=n||E[k];s(a,d?k:"propertychange",c,!1,!d&&k)}}var d,e,h,i,j=r(a),k=b.replace(g,"");if(!j||!j[k])return a;e=b.replace(f,""),h=e?e.split("."):[c.__uid],l(e);for(i=h.length;i--;l(h[i]));return a},x=function(a,b,c){return function(d){var e=typeof a=="string"?c(a,this):a;for(var f=d.target;f&&f!=this;f=f.parentNode)for(var g=e.length;g--;)if(e[g]==f)return b.apply(f,arguments)}},y=function(a,b,c,d,e){if(typeof b=="object"&&!c)for(var f in b)b.hasOwnProperty(f)&&y(a,f,b[f]);else{var g=typeof c=="string",h=(g?c:b).split(" ");c=g?x(b,d,e):c;for(var i=h.length;i--;)v(a,h[i],c,Array.prototype.slice.call(arguments,g?4:3))}return a},z=function(a,b,c){var d,e,h,i,j,k=typeof b=="string",l=k&&b.replace(f,""),m=w,n=r(a);l=l&&l.split(".");if(k&&/\s/.test(b)){b=b.split(" "),j=b.length-1;while(z(a,b[j])&&j--);return a}i=k?b.replace(g,""):b;if(!n||l||k&&!n[i]){for(d in n)if(n.hasOwnProperty(d))for(j in n[d])for(e=l.length;e--;)n[d].hasOwnProperty(j)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(j)&&m(a,[d,j].join("."));return a}if(typeof c=="function")m(a,i,c);else if(l)m(a,b);else{m=i?m:z,h=k&&i,i=i?c||n[i]||i:n;for(d in i)i.hasOwnProperty(d)&&(m(a,h||d,i[d]),delete i[d])}return a},A=function(a,b,c){var d,e,h,i,j=b.split(" ");for(h=j.length;h--;){b=j[h].replace(g,"");var k=E[b],l=j[h].replace(f,""),m=r(a)[b];if(l){l=l.split(".");for(e=l.length;e--;)for(i in m)m.hasOwnProperty(i)&&(new RegExp("^"+l[e]+"::\\d*(\\..*)?$")).test(i)&&m[i].apply(a,[!1].concat(c))}else if(!c&&a[o])B(k,b,a);else for(e in m)m.hasOwnProperty(e)&&m[e].apply(a,[!1].concat(c))}return a},B=n?function(b,c,d){evt=document.createEvent(b?"HTMLEvents":"UIEvents"),evt[b?"initEvent":"initUIEvent"](c,!0,!0,a,1),d.dispatchEvent(evt)}:function(a,b,c){a?c.fireEvent("on"+b,document.createEventObject()):c["_on"+b]++},C=function(a,b,c){var d=r(b),e,f,g=q(a);e=c?d[c]:d;for(f in e)e.hasOwnProperty(f)&&(c?y:C)(a,c||b,c?e[f].__originalFn:f);return a},D=function(a){var b={};if(!a)return b;var c=a.type,d=a.target||a.srcElement;b.preventDefault=D.preventDefault(a),b.stopPropagation=D.stopPropagation(a),b.target=d&&d.nodeType==3?d.parentNode:d;if(~c.indexOf("key"))b.keyCode=a.which||a.keyCode;else if(/click|mouse|menu/i.test(c)){b.rightClick=a.which==3||a.button==2,b.pos={x:0,y:0};if(a.pageX||a.pageY)b.clientX=a.pageX,b.clientY=a.pageY;else if(a.clientX||a.clientY)b.clientX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.clientY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;e.test(c)&&(b.relatedTarget=a.relatedTarget||a[(c=="mouseover"?"from":"to")+"Element"])}for(var f in a)f in b||(b[f]=a[f]);return b};D.preventDefault=function(a){return function(){a.preventDefault?a.preventDefault():a.returnValue=!1}},D.stopPropagation=function(a){return function(){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}};var E={click:1,dblclick:1,mouseup:1,mousedown:1,contextmenu:1,mousewheel:1,DOMMouseScroll:1,mouseover:1,mouseout:1,mousemove:1,selectstart:1,selectend:1,keydown:1,keypress:1,keyup:1,orientationchange:1,touchstart:1,touchmove:1,touchend:1,touchcancel:1,gesturestart:1,gesturechange:1,gestureend:1,focus:1,blur:1,change:1,reset:1,select:1,submit:1,load:1,unload:1,beforeunload:1,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1},G={mouseenter:{base:"mouseover",condition:F},mouseleave:{base:"mouseout",condition:F},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}},H={add:y,remove:z,clone:C,fire:A},I=function(a){var b=z(a).__uid;b&&(delete d[b],delete c[b])};return a[i]&&y(a,"unload",function(){for(var b in d)d.hasOwnProperty(b)&&I(d[b]);a.CollectGarbage&&CollectGarbage()}),H.noConflict=function(){return context.bean=old,this},H}),provide("bean",a.exports),!function(a){var b=require("bean"),c=function(c,d,e){var f=d?[d]:[];return function(){for(var e,g=0,h=this.length;g<h;g++)e=[this[g]].concat(f,Array.prototype.slice.call(arguments,0)),e.length==4&&e.push(a),!arguments.length&&c=="add"&&d&&(c="fire"),b[c].apply(this,e);return this}},d=c("add"),e=c("remove"),f=c("fire"),g={on:d,addListener:d,bind:d,listen:d,delegate:d,unbind:e,unlisten:e,removeListener:e,undelegate:e,emit:f,trigger:f,cloneEvents:c("clone"),hover:function(a,c,d){for(d=this.length;d--;)b.add.call(this,this[d],"mouseenter",a),b.add.call(this,this[d],"mouseleave",c);return this}},h,i=["blur","change","click","dblclick","error","focus","focusin","focusout","keydown","keypress","keyup","load","mousedown","mouseenter","mouseleave","mouseout","mouseover","mouseup","mousemove","resize","scroll","select","submit","unload"];for(h=i.length;h--;)g[i[h]]=c("add",i[h]);a.ender(g,!0)}(ender)}(),!function(){var a={exports:{}},b=a.exports; |
|
28 |
+;!function(name,context,definition){typeof module!="undefined"&&module.exports?module.exports=definition(name,context):typeof define=="function"&&typeof define.amd=="object"?define(definition):context[name]=definition(name,context)}("bean",this,function(name,context){var win=window,old=context[name],namespaceRegex=/[^\.]*(?=\..*)\.|.*/,nameRegex=/\..*/,addEvent="addEventListener",removeEvent="removeEventListener",doc=document||{},root=doc.documentElement||{},W3C_MODEL=root[addEvent],eventSupport=W3C_MODEL?addEvent:"attachEvent",ONE={},slice=Array.prototype.slice,str2arr=function(s,d){return s.split(d||" ")},isString=function(o){return typeof o=="string"},isFunction=function(o){return typeof o=="function"},standardNativeEvents="click dblclick mouseup mousedown contextmenu mousewheel mousemultiwheel DOMMouseScroll mouseover mouseout mousemove selectstart selectend keydown keypress keyup orientationchange focus blur change reset select submit load unload beforeunload resize move DOMContentLoaded readystatechange message error abort scroll ",w3cNativeEvents="show input invalid touchstart touchmove touchend touchcancel gesturestart gesturechange gestureend textinputreadystatechange pageshow pagehide popstate hashchange offline online afterprint beforeprint dragstart dragenter dragover dragleave drag drop dragend loadstart progress suspend emptied stalled loadmetadata loadeddata canplay canplaythrough playing waiting seeking seeked ended durationchange timeupdate play pause ratechange volumechange cuechange checking noupdate downloading cached updateready obsolete ",nativeEvents=function(hash,events,i){for(i=0;i<events.length;i++)events[i]&&(hash[events[i]]=1);return hash}({},str2arr(standardNativeEvents+(W3C_MODEL?w3cNativeEvents:""))),customEvents=function(){var isAncestor="compareDocumentPosition"in root?function(element,container){return container.compareDocumentPosition&&(container.compareDocumentPosition(element)&16)===16}:"contains"in root?function(element,container){container=container.nodeType===9||container===window?root:container;return container!==element&&container.contains(element)}:function(element,container){while(element=element.parentNode)if(element===container)return 1;return 0},check=function(event){var related=event.relatedTarget;return related?related!==this&&related.prefix!=="xul"&&!/document/.test(this.toString())&&!isAncestor(related,this):related==null};return{mouseenter:{base:"mouseover",condition:check},mouseleave:{base:"mouseout",condition:check},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}}}(),Event=function(){var commonProps=str2arr("altKey attrChange attrName bubbles cancelable ctrlKey currentTarget detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey srcElement target timeStamp type view which propertyName"),mouseProps=commonProps.concat(str2arr("button buttons clientX clientY dataTransfer fromElement offsetX offsetY pageX pageY screenX screenY toElement")),mouseWheelProps=mouseProps.concat(str2arr("wheelDelta wheelDeltaX wheelDeltaY wheelDeltaZ axis")),keyProps=commonProps.concat(str2arr("char charCode key keyCode keyIdentifier keyLocation location")),textProps=commonProps.concat(str2arr("data")),touchProps=commonProps.concat(str2arr("touches targetTouches changedTouches scale rotation")),messageProps=commonProps.concat(str2arr("data origin source")),stateProps=commonProps.concat(str2arr("state")),overOutRegex=/over|out/,typeFixers=[{reg:/key/i,fix:function(event,newEvent){newEvent.keyCode=event.keyCode||event.which;return keyProps}},{reg:/click|mouse(?!(.*wheel|scroll))|menu|drag|drop/i,fix:function(event,newEvent,type){newEvent.rightClick=event.which===3||event.button===2;newEvent.pos={x:0,y:0};if(event.pageX||event.pageY){newEvent.clientX=event.pageX;newEvent.clientY=event.pageY}else if(event.clientX||event.clientY){newEvent.clientX=event.clientX+doc.body.scrollLeft+root.scrollLeft;newEvent.clientY=event.clientY+doc.body.scrollTop+root.scrollTop}overOutRegex.test(type)&&(newEvent.relatedTarget=event.relatedTarget||event[(type=="mouseover"?"from":"to")+"Element"]);return mouseProps}},{reg:/mouse.*(wheel|scroll)/i,fix:function(){return mouseWheelProps}},{reg:/^text/i,fix:function(){return textProps}},{reg:/^touch|^gesture/i,fix:function(){return touchProps}},{reg:/^message$/i,fix:function(){return messageProps}},{reg:/^popstate$/i,fix:function(){return stateProps}},{reg:/.*/,fix:function(){return commonProps}}],typeFixerMap={},Event=function(event,element,isNative){if(!arguments.length)return;event=event||((element.ownerDocument||element.document||element).parentWindow||win).event;this.originalEvent=event;this.isNative=isNative;this.isBean=!0;if(!event)return;var type=event.type,target=event.target||event.srcElement,i,l,p,props,fixer;this.target=target&&target.nodeType===3?target.parentNode:target;if(isNative){fixer=typeFixerMap[type];if(!fixer)for(i=0,l=typeFixers.length;i<l;i++)if(typeFixers[i].reg.test(type)){typeFixerMap[type]=fixer=typeFixers[i].fix;break}props=fixer(event,this,type);for(i=props.length;i--;)!((p=props[i])in this)&&p in event&&(this[p]=event[p])}};Event.prototype.preventDefault=function(){this.originalEvent.preventDefault?this.originalEvent.preventDefault():this.originalEvent.returnValue=!1};Event.prototype.stopPropagation=function(){this.originalEvent.stopPropagation?this.originalEvent.stopPropagation():this.originalEvent.cancelBubble=!0};Event.prototype.stop=function(){this.preventDefault();this.stopPropagation();this.stopped=!0};Event.prototype.stopImmediatePropagation=function(){this.originalEvent.stopImmediatePropagation&&this.originalEvent.stopImmediatePropagation();this.isImmediatePropagationStopped=function(){return!0}};Event.prototype.isImmediatePropagationStopped=function(){return this.originalEvent.isImmediatePropagationStopped&&this.originalEvent.isImmediatePropagationStopped()};Event.prototype.clone=function(currentTarget){var ne=new Event(this,this.element,this.isNative);ne.currentTarget=currentTarget;return ne};return Event}(),targetElement=function(element,isNative){return!W3C_MODEL&&!isNative&&(element===doc||element===win)?root:element},RegEntry=function(){var wrappedHandler=function(element,fn,condition,args){var call=function(event,eargs){return fn.apply(element,args?slice.call(eargs,event?0:1).concat(args):eargs)},findTarget=function(event,eventElement){return fn.__beanDel?fn.__beanDel.ft(event.target,element):eventElement},handler=condition?function(event){var target=findTarget(event,this);if(condition.apply(target,arguments)){event&&(event.currentTarget=target);return call(event,arguments)}}:function(event){fn.__beanDel&&(event=event.clone(findTarget(event)));return call(event,arguments)};handler.__beanDel=fn.__beanDel;return handler},RegEntry=function(element,type,handler,original,namespaces,args,root){var customType=customEvents[type],isNative;type=="unload"&&(handler=once(removeListener,element,type,handler,original));if(customType){customType.condition&&(handler=wrappedHandler(element,handler,customType.condition,args));type=customType.base||type}this.isNative=isNative=nativeEvents[type]&&!!element[eventSupport];this.customType=!W3C_MODEL&&!isNative&&type;this.element=element;this.type=type;this.original=original;this.namespaces=namespaces;this.eventType=W3C_MODEL||isNative?type:"propertychange";this.target=targetElement(element,isNative);this[eventSupport]=!!this.target[eventSupport];this.root=root;this.handler=wrappedHandler(element,handler,null,args)};RegEntry.prototype.inNamespaces=function(checkNamespaces){var i,j,c=0;if(!checkNamespaces)return!0;if(!this.namespaces)return!1;for(i=checkNamespaces.length;i--;)for(j=this.namespaces.length;j--;)checkNamespaces[i]==this.namespaces[j]&&c++;return checkNamespaces.length===c};RegEntry.prototype.matches=function(checkElement,checkOriginal,checkHandler){return this.element===checkElement&&(!checkOriginal||this.original===checkOriginal)&&(!checkHandler||this.handler===checkHandler)};return RegEntry}(),registry=function(){var map={},forAll=function(element,type,original,handler,root,fn){var pfx=root?"r":"$";if(!type||type=="*")for(var t in map)t.charAt(0)==pfx&&forAll(element,t.substr(1),original,handler,root,fn);else{var i=0,l,list=map[pfx+type],all=element=="*";if(!list)return;for(l=list.length;i<l;i++)if((all||list[i].matches(element,original,handler))&&!fn(list[i],list,i,type))return}},has=function(element,type,original,root){var i,list=map[(root?"r":"$")+type];if(list)for(i=list.length;i--;)if(!list[i].root&&list[i].matches(element,original,null))return!0;return!1},get=function(element,type,original,root){var entries=[];forAll(element,type,original,null,root,function(entry){return entries.push(entry)});return entries},put=function(entry){var has=!entry.root&&!this.has(entry.element,entry.type,null,!1),key=(entry.root?"r":"$")+entry.type;(map[key]||(map[key]=[])).push(entry);return has},del=function(entry){forAll(entry.element,entry.type,null,entry.handler,entry.root,function(entry,list,i){list.splice(i,1);entry.removed=!0;list.length===0&&delete map[(entry.root?"r":"$")+entry.type];return!1})},entries=function(){var t,entries=[];for(t in map)t.charAt(0)=="$"&&(entries=entries.concat(map[t]));return entries};return{has:has,get:get,put:put,del:del,entries:entries}}(),selectorEngine,setSelectorEngine=function(e){arguments.length?selectorEngine=e:selectorEngine=doc.querySelectorAll?function(s,r){return r.querySelectorAll(s)}:function(){throw new Error("Bean: No selector engine installed")}},rootListener=function(event,type){if(!W3C_MODEL&&type&&event&&event.propertyName!="_on"+type)return;var listeners=registry.get(this,type||event.type,null,!1),l=listeners.length,i=0;event=new Event(event,this,!0);type&&(event.type=type);for(;i<l&&!event.isImmediatePropagationStopped();i++)listeners[i].removed||listeners[i].handler.call(this,event)},listener=W3C_MODEL?function(element,type,add){element[add?addEvent:removeEvent](type,rootListener,!1)}:function(element,type,add,custom){var entry;if(add){registry.put(entry=new RegEntry(element,custom||type,function(event){rootListener.call(element,event,custom)},rootListener,null,null,!0));custom&&element["_on"+custom]==null&&(element["_on"+custom]=0);entry.target.attachEvent("on"+entry.eventType,entry.handler)}else{entry=registry.get(element,custom||type,rootListener,!0)[0];if(entry){entry.target.detachEvent("on"+entry.eventType,entry.handler);registry.del(entry)}}},once=function(rm,element,type,fn,originalFn){return function(){fn.apply(this,arguments);rm(element,type,originalFn)}},removeListener=function(element,orgType,handler,namespaces){var type=orgType&&orgType.replace(nameRegex,""),handlers=registry.get(element,type,null,!1),removed={},i,l;for(i=0,l=handlers.length;i<l;i++)if((!handler||handlers[i].original===handler)&&handlers[i].inNamespaces(namespaces)){registry.del(handlers[i]);!removed[handlers[i].eventType]&&handlers[i][eventSupport]&&(removed[handlers[i].eventType]={t:handlers[i].eventType,c:handlers[i].type})}for(i in removed)registry.has(element,removed[i].t,null,!1)||listener(element,removed[i].t,!1,removed[i].c)},delegate=function(selector,fn){var findTarget=function(target,root){var i,array=isString(selector)?selectorEngine(selector,root):selector;for(;target&&target!==root;target=target.parentNode)for(i=array.length;i--;)if(array[i]===target)return target},handler=function(e){var match=findTarget(e.target,this);match&&fn.apply(match,arguments)};handler.__beanDel={ft:findTarget,selector:selector};return handler},fireListener=W3C_MODEL?function(isNative,type,element){var evt=doc.createEvent(isNative?"HTMLEvents":"UIEvents");evt[isNative?"initEvent":"initUIEvent"](type,!0,!0,win,1);element.dispatchEvent(evt)}:function(isNative,type,element){element=targetElement(element,isNative);isNative?element.fireEvent("on"+type,doc.createEventObject()):element["_on"+type]++},off=function(element,typeSpec,fn){var isTypeStr=isString(typeSpec),k,type,namespaces,i;if(isTypeStr&&typeSpec.indexOf(" ")>0){typeSpec=str2arr(typeSpec);for(i=typeSpec.length;i--;)off(element,typeSpec[i],fn);return element}type=isTypeStr&&typeSpec.replace(nameRegex,"");type&&customEvents[type]&&(type=customEvents[type].base);if(!typeSpec||isTypeStr){if(namespaces=isTypeStr&&typeSpec.replace(namespaceRegex,""))namespaces=str2arr(namespaces,".");removeListener(element,type,fn,namespaces)}else if(isFunction(typeSpec))removeListener(element,null,typeSpec);else for(k in typeSpec)typeSpec.hasOwnProperty(k)&&off(element,k,typeSpec[k]);return element},on=function(element,events,selector,fn){var originalFn,type,types,i,args,entry,first;if(selector===undefined&&typeof events=="object"){for(type in events)events.hasOwnProperty(type)&&on.call(this,element,type,events[type]);return}if(!isFunction(selector)){originalFn=fn;args=slice.call(arguments,4);fn=delegate(selector,originalFn,selectorEngine)}else{args=slice.call(arguments,3);fn=originalFn=selector}types=str2arr(events);this===ONE&&(fn=once(off,element,events,fn,originalFn));for(i=types.length;i--;){first=registry.put(entry=new RegEntry(element,types[i].replace(nameRegex,""),fn,originalFn,str2arr(types[i].replace(namespaceRegex,""),"."),args,!1));entry[eventSupport]&&first&&listener(element,entry.eventType,!0,entry.customType)}return element},add=function(element,events,fn,delfn){return on.apply(null,isString(fn)?[element,fn,events,delfn].concat(arguments.length>3?slice.call(arguments,5):[]):slice.call(arguments))},one=function(){return on.apply(ONE,arguments)},fire=function(element,type,args){var types=str2arr(type),i,j,l,names,handlers;for(i=types.length;i--;){type=types[i].replace(nameRegex,"");if(names=types[i].replace(namespaceRegex,""))names=str2arr(names,".");if(!names&&!args&&element[eventSupport])fireListener(nativeEvents[type],type,element);else{handlers=registry.get(element,type,null,!1);args=[!1].concat(args);for(j=0,l=handlers.length;j<l;j++)handlers[j].inNamespaces(names)&&handlers[j].handler.apply(element,args)}}return element},clone=function(element,from,type){var handlers=registry.get(from,type,null,!1),l=handlers.length,i=0,args,beanDel;for(;i<l;i++)if(handlers[i].original){args=[element,handlers[i].type];(beanDel=handlers[i].handler.__beanDel)&&args.push(beanDel.selector);args.push(handlers[i].original);on.apply(null,args)}return element},bean={on:on,add:add,one:one,off:off,remove:off,clone:clone,fire:fire,setSelectorEngine:setSelectorEngine,noConflict:function(){context[name]=old;return this}};if(win.attachEvent){var cleanup=function(){var i,entries=registry.entries();for(i in entries)entries[i].type&&entries[i].type!=="unload"&&off(entries[i].element,entries[i].type);win.detachEvent("onunload",cleanup);win.CollectGarbage&&win.CollectGarbage()};win.attachEvent("onunload",cleanup)}setSelectorEngine();return bean});provide("bean",module.exports);!function($){var b=require("bean"),integrate=function(method,type,method2){var _args=type?[type]:[];return function(){for(var i=0,l=this.length;i<l;i++){!arguments.length&&method=="on"&&type&&(method="fire");b[method].apply(this,[this[i]].concat(_args,Array.prototype.slice.call(arguments,0)))}return this}},add=integrate("add"),on=integrate("on"),one=integrate("one"),off=integrate("off"),fire=integrate("fire"),clone=integrate("clone"),hover=function(enter,leave,i){for(i=this.length;i--;){b.on.call(this,this[i],"mouseenter",enter);b.on.call(this,this[i],"mouseleave",leave)}return this},methods={on:on,addListener:on,bind:on,listen:on,delegate:add,one:one,off:off,unbind:off,unlisten:off,removeListener:off,undelegate:off,emit:fire,trigger:fire,cloneEvents:clone,hover:hover},shortcuts="blur change click dblclick error focus focusin focusout keydown keypress keyup load mousedown mouseenter mouseleave mouseout mouseover mouseup mousemove resize scroll select submit unload".split(" ");for(var i=shortcuts.length;i--;)methods[shortcuts[i]]=integrate("on",shortcuts[i]);b.setSelectorEngine($);$.ender(methods,!0)}(ender)})();(function(){var module={exports:{}},exports=module.exports; |
|
33 | 29 |
/*! |
34 |
- * Bonzo: DOM Utility (c) Dustin Diaz 2011 |
|
30 |
+ * Bonzo: DOM Utility (c) Dustin Diaz 2012 |
|
35 | 31 |
* https://github.com/ded/bonzo |
36 | 32 |
* License MIT |
37 | 33 |
*/ |
38 |
-!function(b,c){typeof define=="function"?define(c):typeof a!="undefined"?a.exports=c():this[b]=c()}("bonzo",function(){function x(a){return new RegExp("(^|\\s+)"+a+"(\\s+|$)")}function y(a,b,c){for(var d=0,e=a.length;d<e;d++)b.call(c||a[d],a[d],d,a);return a}function z(a){return a.replace(/-(.)/g,function(a,b){return b.toUpperCase()})}function A(a){return a&&a.nodeName&&a.nodeType==1}function B(a,b,c,d){for(d=0,j=a.length;d<j;++d)if(b.call(c,a[d],d,a))return!0;return!1}function D(a,b,c){var d=0,g=b||this,h=[],i=f&&typeof a=="string"&&a.charAt(0)!="<"?f(a):a;return y(J(i),function(a){y(g,function(b){var f=!b[e]||b[e]&&!b[e][e]?function(){var a=b.cloneNode(!0);return g.$&&g.cloneEvents&&g.$(a).cloneEvents(b),a}():b;c(a,f),h[d]=f,d++})},this),y(h,function(a,b){g[b]=a}),g.length=d,g}function E(a,b,c){var d=N(a),e=d.css("position"),f=d.offset(),g="relative",h=e==g,i=[parseInt(d.css("left"),10),parseInt(d.css("top"),10)];e=="static"&&(d.css("position",g),e=g),isNaN(i[0])&&(i[0]=h?0:a.offsetLeft),isNaN(i[1])&&(i[1]=h?0:a.offsetTop),b!=null&&(a.style.left=b-f.left+i[0]+q),c!=null&&(a.style.top=c-f.top+i[1]+q)}function F(a,b){return x(b).test(a.className)}function G(a,b){a.className=w(a.className+" "+b)}function H(a,b){a.className=w(a.className.replace(x(b)," "))}function I(a){this.length=0;if(a){a=typeof a!="string"&&!a.nodeType&&typeof a.length!="undefined"?a:[a],this.length=a.length;for(var b=0;b<a.length;b++)this[b]=a[b]}}function J(a){return typeof a=="string"?N.create(a):A(a)?[a]:a}function K(a,c,d){var e=this[0];return a==null&&c==null?(L(e)?M():{x:e.scrollLeft,y:e.scrollTop})[d]:(L(e)?b.scrollTo(a,c):(a!=null&&(e.scrollLeft=a),c!=null&&(e.scrollTop=c)),this)}function L(a){return a===b||/^(?:body|html)$/i.test(a.tagName)}function M(){return{x:b.pageXOffset||d.scrollLeft,y:b.pageYOffset||d.scrollTop}}function N(a,b){return new I(a,b)}var a=this,b=window,c=b.document,d=c.documentElement,e="parentNode",f=null,g=/^checked|value|selected$/,h=/select|fieldset|table|tbody|tfoot|td|tr|colgroup/i,i="table",k={thead:i,tbody:i,tfoot:i,tr:"tbody",th:"tr",td:"tr",fieldset:"form",option:"select"},l=/^checked|selected$/,m=/msie/i.test(navigator.userAgent),n=[],o=0,p=/^-?[\d\.]+$/,q="px",r="setAttribute",s="getAttribute",t=/(^\s*|\s*$)/g,u={lineHeight:1,zoom:1,zIndex:1,opacity:1},v=function(){var a=["webkitTransform","MozTransform","OTransform","msTransform","Transform"],b;for(b=0;b<a.length;b++)if(a[b]in c.createElement("a").style)return a[b]}(),w=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(t,"")},C=c.defaultView&&c.defaultView.getComputedStyle?function(a,b){b=b=="transform"?v:b,b=b=="transform-origin"?v+"Origin":b;var d=null;b=="float"&&(b="cssFloat");var e=c.defaultView.getComputedStyle(a,"");return e&&(d=e[z(b)]),a.style[b]||d}:m&&d.currentStyle?function(a,b){b=z(b),b=b=="float"?"styleFloat":b;if(b=="opacity"){var c=100;try{c=a.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(d){try{c=a.filters("alpha").opacity}catch(e){}}return c/100}var f=a.currentStyle?a.currentStyle[b]:null;return a.style[b]||f}:function(a,b){return a.style[z(b)]};I.prototype={get:function(a){return this[a]},each:function(a,b){return y(this,a,b)},map:function(a,b){var c=[],d,e;for(e=0;e<this.length;e++)d=a.call(this,this[e],e),b?b(d)&&c.push(d):c.push(d);return c},first:function(){return N(this[0])},last:function(){return N(this[this.length-1])},html:function(a,b){function f(b){while(b.firstChild)b.removeChild(b.firstChild);y(J(a),function(a){b.appendChild(a)})}var c=b?d.textContent===null?"innerText":"textContent":"innerHTML",e;return typeof a!="undefined"?this.each(function(b){(e=b.tagName.match(h))?f(b,e[0]):b[c]=a}):this[0]?this[0][c]:""},text:function(a){return this.html(a,1)},addClass:function(a){return this.each(function(b){F(b,a)||G(b,a)})},removeClass:function(a){return this.each(function(b){F(b,a)&&H(b,a)})},hasClass:function(a){return B(this,function(b){return F(b,a)})},toggleClass:function(a,b){return this.each(function(c){typeof b!="undefined"?b?G(c,a):H(c,a):F(c,a)?H(c,a):G(c,a)})},show:function(a){return this.each(function(b){b.style.display=a||""})},hide:function(a){return this.each(function(a){a.style.display="none"})},append:function(a){return this.each(function(b){y(J(a),function(a){b.appendChild(a)})})},prepend:function(a){return this.each(function(b){var c=b.firstChild;y(J(a),function(a){b.insertBefore(a,c)})})},appendTo:function(a,b){return D.call(this,a,b,function(a,b){a.appendChild(b)})},prependTo:function(a,b){return D.call(this,a,b,function(a,b){a.insertBefore(b,a.firstChild)})},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},related:function(a){return this.map(function(b){b=b[a];while(b&&b.nodeType!==1)b=b[a];return b||0},function(a){return a})},before:function(a){return this.each(function(b){y(N.create(a),function(a){b[e].insertBefore(a,b)})})},after:function(a){return this.each(function(b){y(N.create(a),function(a){b[e].insertBefore(a,b.nextSibling)})})},insertBefore:function(a,b){return D.call(this,a,b,function(a,b){a[e].insertBefore(b,a)})},insertAfter:function(a,b){return D.call(this,a,b,function(a,b){var c=a.nextSibling;c?a[e].insertBefore(b,c):a[e].appendChild(b)})},replaceWith:function(a){return this.each(function(b){b.parentNode.replaceChild(N.create(a)[0],b)})},css:function(a,d,e){function g(a,b,c){for(var d in f)f.hasOwnProperty(d)&&(c=f[d],(b=z(d))&&p.test(c)&&!(b in u)&&(c+=q),b=b=="transform"?v:b,b=b=="transformOrigin"?v+"Origin":b,a.style[b]=c)}if(d===undefined&&typeof a=="string")return d=this[0],d?d==c||d==b?(e=d==c?N.doc():N.viewport(),a=="width"?e.width:a=="height"?e.height:""):C(d,a):null;var f=a;typeof a=="string"&&(f={},f[a]=d),m&&f.opacity&&(f.filter="alpha(opacity="+f.opacity*100+")",f.zoom=a.zoom||1,delete f.opacity);if(d=f["float"])m?f.styleFloat=d:f.cssFloat=d,delete f["float"];return this.each(g)},offset:function(a,b){if(typeof a=="number"||typeof b=="number")return this.each(function(c){E(c,a,b)});var c=this[0],d=c.offsetWidth,e=c.offsetHeight,f=c.offsetTop,g=c.offsetLeft;while(c=c.offsetParent)f+=c.offsetTop,g+=c.offsetLeft;return{top:f,left:g,height:e,width:d}},attr:function(a,b){var c=this[0];if(typeof a=="string"||a instanceof String)return typeof b=="undefined"?g.test(a)?l.test(a)&&typeof c[a]=="string"?!0:c[a]:c[s](a):this.each(function(c){g.test(a)?c[a]=b:c[r](a,b)});for(var d in a)a.hasOwnProperty(d)&&this.attr(d,a[d]);return this},val:function(a){return typeof a=="string"?this.attr("value",a):this[0].value},removeAttr:function(a){return this.each(function(b){l.test(a)?b[a]=!1:b.removeAttribute(a)})},data:function(a,b){var c=this[0];if(typeof b=="undefined"){c[s]("data-node-uid")||c[r]("data-node-uid",++o);var d=c[s]("data-node-uid");return n[d]||(n[d]={}),n[d][a]}return this.each(function(c){c[s]("data-node-uid")||c[r]("data-node-uid",++o);var d=c[s]("data-node-uid"),e=n[d]||(n[d]={});e[a]=b})},remove:function(){return this.each(function(a){a[e]&&a[e].removeChild(a)})},empty:function(){return this.each(function(a){while(a.firstChild)a.removeChild(a.firstChild)})},detach:function(){return this.map(function(a){return a[e].removeChild(a)})},scrollTop:function(a){return K.call(this,null,a,"y")},scrollLeft:function(a){return K.call(this,a,null,"x")},toggle:function(a){return this.each(function(a){a.style.display=a.offsetWidth||a.offsetHeight?"none":"block"}),a&&a(),this}},N.setQueryEngine=function(a){f=a,delete N.setQueryEngine},N.aug=function(a,b){for(var c in a)a.hasOwnProperty(c)&&((b||I.prototype)[c]=a[c])},N.create=function(a){return typeof a=="string"?function(){var b=/^<([^\s>]+)/.exec(a),d=c.createElement(b&&k[b[1].toLowerCase()]||"div"),e=[];d.innerHTML=a;var f=d.childNodes;d=d.firstChild,e.push(d);while(d=d.nextSibling)d.nodeType==1&&e.push(d);return e}():A(a)?[a.cloneNode(!0)]:[]},N.doc=function(){var a=this.viewport();return{width:Math.max(c.body.scrollWidth,d.scrollWidth,a.width),height:Math.max(c.body.scrollHeight,d.scrollHeight,a.height)}},N.firstChild=function(a){for(var b=a.childNodes,c=0,d=b&&b.length||0,e;c<d;c++)b[c].nodeType===1&&(e=b[d=c]);return e},N.viewport=function(){return{width:m?d.clientWidth:self.innerWidth,height:m?d.clientHeight:self.innerHeight}},N.isAncestor="compareDocumentPosition"in d?function(a,b){return(a.compareDocumentPosition(b)&16)==16}:"contains"in d?function(a,b){return a!==b&&a.contains(b)}:function(a,b){while(b=b[e])if(b===a)return!0;return!1};var O=a.bonzo;return N.noConflict=function(){return a.bonzo=O,this},N}),provide("bonzo",a.exports),!function(a){function c(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return c;return-1}function d(a){var b=[],c,d;e:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue e;b[b.length]=a[c]}return b}function e(a,b,c){return a?b.css(c,a):function(a){return a=parseInt(b.css(c),10),isNaN(a)?b[0]["offset"+c.replace(/^\w/,function(a){return a.toUpperCase()})]:a}()}var b=require("bonzo");b.setQueryEngine(a),a.ender(b),a.ender(b(),!0),a.ender({create:function(c){return a(b.create(c))}}),a.id=function(b){return a([document.getElementById(b)])},a.ender({parents:function(b,e){var f=a(b),g,h,i,j=[];for(g=0,h=this.length;g<h;g++){i=this[g];while(i=i.parentNode)if(~c(f,i)){j.push(i);if(e)break}}return a(d(j))},closest:function(a){return this.parents(a,!0)},first:function(){return a(this[0])},last:function(){return a(this[this.length-1])},next:function(){return a(b(this).next())},previous:function(){return a(b(this).previous())},appendTo:function(a){return b(this.selector).appendTo(a,this)},prependTo:function(a){return b(this.selector).prependTo(a,this)},insertAfter:function(a){return b(this.selector).insertAfter(a,this)},insertBefore:function(a){return b(this.selector).insertBefore(a,this)},siblings:function(){var b,c,d,e=[];for(b=0,c=this.length;b<c;b++){d=this[b];while(d=d.previousSibling)d.nodeType==1&&e.push(d);d=this[b];while(d=d.nextSibling)d.nodeType==1&&e.push(d)}return a(e)},children:function(){var c,e,f=[];for(c=0,l=this.length;c<l;c++){if(!(e=b.firstChild(this[c])))continue;f.push(e);while(e=e.nextSibling)e.nodeType==1&&f.push(e)}return a(d(f))},height:function(a){return e(a,this,"height")},width:function(a){return e(a,this,"width")}},!0)}(ender)}(),!function(){var a={exports:{}},b=a.exports;!function(b,c){typeof define=="function"?define(c):typeof a!="undefined"?a.exports=c():this[b]=this.domReady=c()}("domready",function(a){function l(a){k=1;while(a=b.shift())a()}var b=[],c,d=!1,e=document,f=e.documentElement,g=f.doScroll,h="DOMContentLoaded",i="addEventListener",j="onreadystatechange",k=/^loade|c/.test(e.readyState);return e[i]&&e[i](h,c=function(){e.removeEventListener(h,c,d),l()},d),g&&e.attachEvent(j,c=function(){/^c/.test(e.readyState)&&(e.detachEvent(j,c),l())}),a=g?function(c){self!=top?k?c():b.push(c):function(){try{f.doScroll("left")}catch(b){return setTimeout(function(){a(c)},50)}c()}()}:function(a){k?a():b.push(a)}}),provide("domready",a.exports),!function(a){var b=require("domready");a.ender({domReady:b}),a.ender({ready:function(a){return b(a),this}},!0)}(ender)}(),!function(){var a={exports:{}},b=a.exports; |
|
34 |
+(function(name,context,definition){typeof module!="undefined"&&module.exports?module.exports=definition():typeof context["define"]=="function"&&context.define.amd?define(definition):context[name]=definition()})("bonzo",this,function(){function isNode(node){return node&&node.nodeName&&(node.nodeType==1||node.nodeType==11)}function normalize(node,host,clone){var i,l,ret;if(typeof node=="string")return bonzo.create(node);isNode(node)&&(node=[node]);if(clone){ret=[];for(i=0,l=node.length;i<l;i++)ret[i]=cloneNode(host,node[i]);return ret}return node}function classReg(c){return new RegExp("(^|\\s+)"+c+"(\\s+|$)")}function each(ar,fn,opt_scope,opt_rev){var ind,i=0,l=ar.length;for(;i<l;i++){ind=opt_rev?ar.length-i-1:i;fn.call(opt_scope||ar[ind],ar[ind],ind,ar)}return ar}function deepEach(ar,fn,opt_scope){for(var i=0,l=ar.length;i<l;i++)if(isNode(ar[i])){deepEach(ar[i].childNodes,fn,opt_scope);fn.call(opt_scope||ar[i],ar[i],i,ar)}return ar}function camelize(s){return s.replace(/-(.)/g,function(m,m1){return m1.toUpperCase()})}function decamelize(s){return s?s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():s}function data(el){el[getAttribute]("data-node-uid")||el[setAttribute]("data-node-uid",++uuids);var uid=el[getAttribute]("data-node-uid");return uidMap[uid]||(uidMap[uid]={})}function clearData(el){var uid=el[getAttribute]("data-node-uid");uid&&delete uidMap[uid]}function dataValue(d){var f;try{return d===null||d===undefined?undefined:d==="true"?!0:d==="false"?!1:d==="null"?null:(f=parseFloat(d))==d?f:d}catch(e){}return undefined}function some(ar,fn,opt_scope){for(var i=0,j=ar.length;i<j;++i)if(fn.call(opt_scope||null,ar[i],i,ar))return!0;return!1}function styleProperty(p){p=="transform"&&(p=features.transform)||/^transform-?[Oo]rigin$/.test(p)&&(p=features.transform+"Origin")||p=="float"&&(p=features.cssFloat);return p?camelize(p):null}function insert(target,host,fn,rev){var i=0,self=host||this,r=[],nodes=query&&typeof target=="string"&&target.charAt(0)!="<"?query(target):target;each(normalize(nodes),function(t,j){each(self,function(el){fn(t,r[i++]=j>0?cloneNode(self,el):el)},null,rev)},this,rev);self.length=i;each(r,function(e){self[--i]=e},null,!rev);return self}function xy(el,x,y){var $el=bonzo(el),style=$el.css("position"),offset=$el.offset(),rel="relative",isRel=style==rel,delta=[parseInt($el.css("left"),10),parseInt($el.css("top"),10)];if(style=="static"){$el.css("position",rel);style=rel}isNaN(delta[0])&&(delta[0]=isRel?0:el.offsetLeft);isNaN(delta[1])&&(delta[1]=isRel?0:el.offsetTop);x!=null&&(el.style.left=x-offset.left+delta[0]+px);y!=null&&(el.style.top=y-offset.top+delta[1]+px)}function setter(el,v){return typeof v=="function"?v(el):v}function Bonzo(elements){this.length=0;if(elements){elements=typeof elements!="string"&&!elements.nodeType&&typeof elements.length!="undefined"?elements:[elements];this.length=elements.length;for(var i=0;i<elements.length;i++)this[i]=elements[i]}}function cloneNode(host,el){var c=el.cloneNode(!0),cloneElems,elElems;if(host.$&&typeof host.cloneEvents=="function"){host.$(c).cloneEvents(el);cloneElems=host.$(c).find("*");elElems=host.$(el).find("*");for(var i=0;i<elElems.length;i++)host.$(cloneElems[i]).cloneEvents(elElems[i])}return c}function scroll(x,y,type){var el=this[0];if(!el)return this;if(x==null&&y==null)return(isBody(el)?getWindowScroll():{x:el.scrollLeft,y:el.scrollTop})[type];if(isBody(el))win.scrollTo(x,y);else{x!=null&&(el.scrollLeft=x);y!=null&&(el.scrollTop=y)}return this}function isBody(element){return element===win||/^(?:body|html)$/i.test(element.tagName)}function getWindowScroll(){return{x:win.pageXOffset||html.scrollLeft,y:win.pageYOffset||html.scrollTop}}function createScriptFromHtml(html){var scriptEl=document.createElement("script"),matches=html.match(simpleScriptTagRe);scriptEl.src=matches[1];return scriptEl}function bonzo(els){return new Bonzo(els)}var win=window,doc=win.document,html=doc.documentElement,parentNode="parentNode",specialAttributes=/^(checked|value|selected|disabled)$/i,specialTags=/^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i,simpleScriptTagRe=/\s*<script +src=['"]([^'"]+)['"]>/,table=["<table>","</table>",1],td=["<table><tbody><tr>","</tr></tbody></table>",3],option=["<select>","</select>",1],noscope=["_","",0,1],tagMap={thead:table,tbody:table,tfoot:table,colgroup:table,caption:table,tr:["<table><tbody>","</tbody></table>",2],th:td,td:td,col:["<table><colgroup>","</colgroup></table>",2],fieldset:["<form>","</form>",1],legend:["<form><fieldset>","</fieldset></form>",2],option:option,optgroup:option,script:noscope,style:noscope,link:noscope,param:noscope,base:noscope},stateAttributes=/^(checked|selected|disabled)$/,ie=/msie/i.test(navigator.userAgent),hasClass,addClass,removeClass,uidMap={},uuids=0,digit=/^-?[\d\.]+$/,dattr=/^data-(.+)$/,px="px",setAttribute="setAttribute",getAttribute="getAttribute",byTag="getElementsByTagName",features=function(){var e=doc.createElement("p");e.innerHTML='<a href="#x">x</a><table style="float:left;"></table>';return{hrefExtended:e[byTag]("a")[0][getAttribute]("href")!="#x",autoTbody:e[byTag]("tbody").length!==0,computedStyle:doc.defaultView&&doc.defaultView.getComputedStyle,cssFloat:e[byTag]("table")[0].style.styleFloat?"styleFloat":"cssFloat",transform:function(){var props=["transform","webkitTransform","MozTransform","OTransform","msTransform"],i;for(i=0;i<props.length;i++)if(props[i]in e.style)return props[i]}(),classList:"classList"in e,opasity:function(){return typeof doc.createElement("a").style.opacity!="undefined"}()}}(),trimReplace=/(^\s*|\s*$)/g,whitespaceRegex=/\s+/,toString=String.prototype.toString,unitless={lineHeight:1,zoom:1,zIndex:1,opacity:1,boxFlex:1,WebkitBoxFlex:1,MozBoxFlex:1},query=doc.querySelectorAll&&function(selector){return doc.querySelectorAll(selector)},trim=String.prototype.trim?function(s){return s.trim()}:function(s){return s.replace(trimReplace,"")},getStyle=features.computedStyle?function(el,property){var value=null,computed=doc.defaultView.getComputedStyle(el,"");computed&&(value=computed[property]);return el.style[property]||value}:ie&&html.currentStyle?function(el,property){if(property=="opacity"&&!features.opasity){var val=100;try{val=el.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(e1){try{val=el.filters("alpha").opacity}catch(e2){}}return val/100}var value=el.currentStyle?el.currentStyle[property]:null;return el.style[property]||value}:function(el,property){return el.style[property]};if(features.classList){hasClass=function(el,c){return el.classList.contains(c)};addClass=function(el,c){el.classList.add(c)};removeClass=function(el,c){el.classList.remove(c)}}else{hasClass=function(el,c){return classReg(c).test(el.className)};addClass=function(el,c){el.className=trim(el.className+" "+c)};removeClass=function(el,c){el.className=trim(el.className.replace(classReg(c)," "))}}Bonzo.prototype={get:function(index){return this[index]||null},each:function(fn,opt_scope){return each(this,fn,opt_scope)},deepEach:function(fn,opt_scope){return deepEach(this,fn,opt_scope)},map:function(fn,opt_reject){var m=[],n,i;for(i=0;i<this.length;i++){n=fn.call(this,this[i],i);opt_reject?opt_reject(n)&&m.push(n):m.push(n)}return m},html:function(h,opt_text){var method=opt_text?html.textContent===undefined?"innerText":"textContent":"innerHTML",that=this,append=function(el,i){each(normalize(h,that,i),function(node){el.appendChild(node)})},updateElement=function(el,i){try{if(opt_text||typeof h=="string"&&!specialTags.test(el.tagName))return el[method]=h}catch(e){}append(el,i)};return typeof h!="undefined"?this.empty().each(updateElement):this[0]?this[0][method]:""},text:function(opt_text){return this.html(opt_text,!0)},append:function(node){var that=this;return this.each(function(el,i){each(normalize(node,that,i),function(i){el.appendChild(i)})})},prepend:function(node){var that=this;return this.each(function(el,i){var first=el.firstChild;each(normalize(node,that,i),function(i){el.insertBefore(i,first)})})},appendTo:function(target,opt_host){return insert.call(this,target,opt_host,function(t,el){t.appendChild(el)})},prependTo:function(target,opt_host){return insert.call(this,target,opt_host,function(t,el){t.insertBefore(el,t.firstChild)},1)},before:function(node){var that=this;return this.each(function(el,i){each(normalize(node,that,i),function(i){el[parentNode].insertBefore(i,el)})})},after:function(node){var that=this;return this.each(function(el,i){each(normalize(node,that,i),function(i){el[parentNode].insertBefore(i,el.nextSibling)},null,1)})},insertBefore:function(target,opt_host){return insert.call(this,target,opt_host,function(t,el){t[parentNode].insertBefore(el,t)})},insertAfter:function(target,opt_host){return insert.call(this,target,opt_host,function(t,el){var sibling=t.nextSibling;sibling?t[parentNode].insertBefore(el,sibling):t[parentNode].appendChild(el)},1)},replaceWith:function(node){bonzo(normalize(node)).insertAfter(this);return this.remove()},addClass:function(c){c=toString.call(c).split(whitespaceRegex);return this.each(function(el){each(c,function(c){c&&!hasClass(el,setter(el,c))&&addClass(el,setter(el,c))})})},removeClass:function(c){c=toString.call(c).split(whitespaceRegex);return this.each(function(el){each(c,function(c){c&&hasClass(el,setter(el,c))&&removeClass(el,setter(el,c))})})},hasClass:function(c){c=toString.call(c).split(whitespaceRegex);return some(this,function(el){return some(c,function(c){return c&&hasClass(el,c)})})},toggleClass:function(c,opt_condition){c=toString.call(c).split(whitespaceRegex);return this.each(function(el){each(c,function(c){c&&(typeof opt_condition!="undefined"?opt_condition?addClass(el,c):removeClass(el,c):hasClass(el,c)?removeClass(el,c):addClass(el,c))})})},show:function(opt_type){opt_type=typeof opt_type=="string"?opt_type:"";return this.each(function(el){el.style.display=opt_type})},hide:function(){return this.each(function(el){el.style.display="none"})},toggle:function(opt_callback,opt_type){opt_type=typeof opt_type=="string"?opt_type:"";typeof opt_callback!="function"&&(opt_callback=null);return this.each(function(el){el.style.display=el.offsetWidth||el.offsetHeight?"none":opt_type;opt_callback&&opt_callback.call(el)})},first:function(){return bonzo(this.length?this[0]:[])},last:function(){return bonzo(this.length?this[this.length-1]:[])},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},parent:function(){return this.related(parentNode)},related:function(method){return this.map(function(el){el=el[method];while(el&&el.nodeType!==1)el=el[method];return el||0},function(el){return el})},focus:function(){this.length&&this[0].focus();return this},blur:function(){this.length&&this[0].blur();return this},css:function(o,opt_v){function fn(el,p,v){for(var k in iter)if(iter.hasOwnProperty(k)){v=iter[k];(p=styleProperty(k))&&digit.test(v)&&!(p in unitless)&&(v+=px);try{el.style[p]=setter(el,v)}catch(e){}}}var p,iter=o;if(opt_v===undefined&&typeof o=="string"){opt_v=this[0];if(!opt_v)return null;if(opt_v===doc||opt_v===win){p=opt_v===doc?bonzo.doc():bonzo.viewport();return o=="width"?p.width:o=="height"?p.height:""}return(o=styleProperty(o))?getStyle(opt_v,o):null}if(typeof o=="string"){iter={};iter[o]=opt_v}if(ie&&iter.opacity){iter.filter="alpha(opacity="+iter.opacity*100+")";iter.zoom=o.zoom||1;delete iter.opacity}return this.each(fn)},offset:function(opt_x,opt_y){if(!opt_x||typeof opt_x!="object"||typeof opt_x.top!="number"&&typeof opt_x.left!="number"){if(typeof opt_x=="number"||typeof opt_y=="number")return this.each(function(el){xy(el,opt_x,opt_y)});if(!this[0])return{top:0,left:0,height:0,width:0};var el=this[0],de=el.ownerDocument.documentElement,bcr=el.getBoundingClientRect(),scroll=getWindowScroll(),width=el.offsetWidth,height=el.offsetHeight,top=bcr.top+scroll.y-Math.max(0,de&&de.clientTop,doc.body.clientTop),left=bcr.left+scroll.x-Math.max(0,de&&de.clientLeft,doc.body.clientLeft);return{top:top,left:left,height:height,width:width}}return this.each(function(el){xy(el,opt_x.left,opt_x.top)})},dim:function(){if(!this.length)return{height:0,width:0};var el=this[0],de=el.nodeType==9&&el.documentElement,orig=!de&&!!el.style&&!el.offsetWidth&&!el.offsetHeight?function(t){var s={position:el.style.position||"",visibility:el.style.visibility||"",display:el.style.display||""};t.first().css({position:"absolute",visibility:"hidden",display:"block"});return s}(this):null,width=de?Math.max(el.body.scrollWidth,el.body.offsetWidth,de.scrollWidth,de.offsetWidth,de.clientWidth):el.offsetWidth,height=de?Math.max(el.body.scrollHeight,el.body.offsetHeight,de.scrollWidth,de.offsetWidth,de.clientHeight):el.offsetHeight;orig&&this.first().css(orig);return{height:height,width:width}},attr:function(k,opt_v){var el=this[0];if(typeof k=="string"||k instanceof String)return typeof opt_v=="undefined"?el?specialAttributes.test(k)?stateAttributes.test(k)&&typeof el[k]=="string"?!0:el[k]:k!="href"&&k!="src"||!features.hrefExtended?el[getAttribute](k):el[getAttribute](k,2):null:this.each(function(el){specialAttributes.test(k)?el[k]=setter(el,opt_v):el[setAttribute](k,setter(el,opt_v))});for(var n in k)k.hasOwnProperty(n)&&this.attr(n,k[n]);return this},removeAttr:function(k){return this.each(function(el){stateAttributes.test(k)?el[k]=!1:el.removeAttribute(k)})},val:function(s){return typeof s=="string"?this.attr("value",s):this.length?this[0].value:null},data:function(opt_k,opt_v){var el=this[0],o,m;if(typeof opt_v=="undefined"){if(!el)return null;o=data(el);if(typeof opt_k=="undefined"){each(el.attributes,function(a){(m=(""+a.name).match(dattr))&&(o[camelize(m[1])]=dataValue(a.value))});return o}typeof o[opt_k]=="undefined"&&(o[opt_k]=dataValue(this.attr("data-"+decamelize(opt_k))));return o[opt_k]}return this.each(function(el){data(el)[opt_k]=opt_v})},remove:function(){this.deepEach(clearData);return this.detach()},empty:function(){return this.each(function(el){deepEach(el.childNodes,clearData);while(el.firstChild)el.removeChild(el.firstChild)})},detach:function(){return this.each(function(el){el[parentNode]&&el[parentNode].removeChild(el)})},scrollTop:function(y){return scroll.call(this,null,y,"y")},scrollLeft:function(x){return scroll.call(this,x,null,"x")}};bonzo.setQueryEngine=function(q){query=q;delete bonzo.setQueryEngine};bonzo.aug=function(o,target){for(var k in o)o.hasOwnProperty(k)&&((target||Bonzo.prototype)[k]=o[k])};bonzo.create=function(node){return typeof node=="string"&&node!==""?function(){if(simpleScriptTagRe.test(node))return[createScriptFromHtml(node)];var tag=node.match(/^\s*<([^\s>]+)/),el=doc.createElement("div"),els=[],p=tag?tagMap[tag[1].toLowerCase()]:null,dep=p?p[2]+1:1,ns=p&&p[3],pn=parentNode,tb=features.autoTbody&&p&&p[0]=="<table>"&&!/<tbody/i.test(node);el.innerHTML=p?p[0]+node+p[1]:node;while(dep--)el=el.firstChild;ns&&el&&el.nodeType!==1&&(el=el.nextSibling);do(!tag||el.nodeType==1)&&(!tb||el.tagName.toLowerCase()!="tbody")&&els.push(el);while(el=el.nextSibling);each(els,function(el){el[pn]&&el[pn].removeChild(el)});return els}():isNode(node)?[node.cloneNode(!0)]:[]};bonzo.doc=function(){var vp=bonzo.viewport();return{width:Math.max(doc.body.scrollWidth,html.scrollWidth,vp.width),height:Math.max(doc.body.scrollHeight,html.scrollHeight,vp.height)}};bonzo.firstChild=function(el){for(var c=el.childNodes,i=0,j=c&&c.length||0,e;i<j;i++)c[i].nodeType===1&&(e=c[j=i]);return e};bonzo.viewport=function(){return{width:ie?html.clientWidth:self.innerWidth,height:ie?html.clientHeight:self.innerHeight}};bonzo.isAncestor="compareDocumentPosition"in html?function(container,element){return(container.compareDocumentPosition(element)&16)==16}:"contains"in html?function(container,element){return container!==element&&container.contains(element)}:function(container,element){while(element=element[parentNode])if(element===container)return!0;return!1};return bonzo});provide("bonzo",module.exports);(function($){function indexOf(ar,val){for(var i=0;i<ar.length;i++)if(ar[i]===val)return i;return-1}function uniq(ar){var r=[],i=0,j=0,k,item,inIt;for(;item=ar[i];++i){inIt=!1;for(k=0;k<r.length;++k)if(r[k]===item){inIt=!0;break}inIt||(r[j++]=item)}return r}function dimension(type,opt_v){return typeof opt_v=="undefined"?b(this).dim()[type]:this.css(type,opt_v)}var b=require("bonzo");b.setQueryEngine($);$.ender(b);$.ender(b(),!0);$.ender({create:function(node){return $(b.create(node))}});$.id=function(id){return $([document.getElementById(id)])};$.ender({parents:function(selector,closest){if(!this.length)return this;selector||(selector="*");var collection=$(selector),j,k,p,r=[];for(j=0,k=this.length;j<k;j++){p=this[j];while(p=p.parentNode)if(~indexOf(collection,p)){r.push(p);if(closest)break}}return $(uniq(r))},parent:function(){return $(uniq(b(this).parent()))},closest:function(selector){return this.parents(selector,!0)},first:function(){return $(this.length?this[0]:this)},last:function(){return $(this.length?this[this.length-1]:[])},next:function(){return $(b(this).next())},previous:function(){return $(b(this).previous())},appendTo:function(t){return b(this.selector).appendTo(t,this)},prependTo:function(t){return b(this.selector).prependTo(t,this)},insertAfter:function(t){return b(this.selector).insertAfter(t,this)},insertBefore:function(t){return b(this.selector).insertBefore(t,this)},siblings:function(){var i,l,p,r=[];for(i=0,l=this.length;i<l;i++){p=this[i];while(p=p.previousSibling)p.nodeType==1&&r.push(p);p=this[i];while(p=p.nextSibling)p.nodeType==1&&r.push(p)}return $(r)},children:function(){var i,l,el,r=[];for(i=0,l=this.length;i<l;i++){if(!(el=b.firstChild(this[i])))continue;r.push(el);while(el=el.nextSibling)el.nodeType==1&&r.push(el)}return $(uniq(r))},height:function(v){return dimension.call(this,"height",v)},width:function(v){return dimension.call(this,"width",v)}},!0)})(ender)})();(function(){var module={exports:{}},exports=module.exports; |
|
35 |
+/*! |
|
36 |
+ * domready (c) Dustin Diaz 2012 - License MIT |
|
37 |
+ */ |
|
38 |
+;!function(name,definition){typeof module!="undefined"?module.exports=definition():typeof define=="function"&&typeof define.amd=="object"?define(definition):this[name]=definition()}("domready",function(ready){function flush(f){loaded=1;while(f=fns.shift())f()}var fns=[],fn,f=!1,doc=document,testEl=doc.documentElement,hack=testEl.doScroll,domContentLoaded="DOMContentLoaded",addEventListener="addEventListener",onreadystatechange="onreadystatechange",readyState="readyState",loaded=/^loade|c/.test(doc[readyState]);doc[addEventListener]&&doc[addEventListener](domContentLoaded,fn=function(){doc.removeEventListener(domContentLoaded,fn,f);flush()},f);hack&&doc.attachEvent(onreadystatechange,fn=function(){if(/^c/.test(doc[readyState])){doc.detachEvent(onreadystatechange,fn);flush()}});return ready=hack?function(fn){self!=top?loaded?fn():fns.push(fn):function(){try{testEl.doScroll("left")}catch(e){return setTimeout(function(){ready(fn)},50)}fn()}()}:function(fn){loaded?fn():fns.push(fn)}});provide("domready",module.exports);!function($){var ready=require("domready");$.ender({domReady:ready});$.ender({ready:function(f){ready(f);return this}},!0)}(ender)})();(function(){var module={exports:{}},exports=module.exports; |
|
39 | 39 |
/*! |
40 |
- * Qwery - A Blazing Fast query selector engine |
|
40 |
+ * @preserve Qwery - A Blazing Fast query selector engine |
|
41 | 41 |
* https://github.com/ded/qwery |
42 |
- * copyright Dustin Diaz & Jacob Thornton 2011 |
|
42 |
+ * copyright Dustin Diaz 2012 |
|
43 | 43 |
* MIT License |
44 | 44 |
*/ |
45 |
-!function(b,c){typeof define=="function"?define(c):typeof a!="undefined"?a.exports=c():this[b]=c()}("qwery",function(){function M(){this.c={}}function R(a){l=[];for(e=0,h=a.length;e<h;e++)$(a[e])?l=l.concat(a[e]):l.push(a[e]);return l}function S(a){while(a=a.previousSibling)if(a.nodeType==1)break;return a}function T(a){return a.match(K)}function U(a,b,c,d,f,g,h,i,k,l,m){var n,o,p;if(b&&this.tagName.toLowerCase()!==b)return!1;if(c&&(n=c.match(v))&&n[1]!==this.id)return!1;if(c&&(q=c.match(w)))for(e=q.length;e--;){o=q[e].slice(1);if(!(N.g(o)||N.s(o,new RegExp("(^|\\s+)"+o+"(\\s+|$)"))).test(this.className))return!1}if(k&&ba.pseudos[k]&&!ba.pseudos[k](this,m))return!1;if(d&&!h){j=this.attributes;for(p in j)if(Object.prototype.hasOwnProperty.call(j,p)&&(j[p].name||p)==f)return this}return d&&!W(g,this.getAttribute(f)||"",h)?!1:this}function V(a){return O.g(a)||O.s(a,a.replace(E,"\\$1"))}function W(a,b,c){switch(a){case"=":return b==c;case"^=":return b.match(P.g("^="+c)||P.s("^="+c,new RegExp("^"+V(c))));case"$=":return b.match(P.g("$="+c)||P.s("$="+c,new RegExp(V(c)+"$")));case"*=":return b.match(P.g(c)||P.s(c,new RegExp(V(c))));case"~=":return b.match(P.g("~="+c)||P.s("~="+c,new RegExp("(?:^|\\s+)"+V(c)+"(?:\\s+|$)")));case"|=":return b.match(P.g("|="+c)||P.s("|="+c,new RegExp("^"+V(c)+"(-|$)")))}return 0}function X(a){var c=[],d=[],e,f=0,g,h,i,j,k,l,m,n,o,q,r,s=Q.g(a)||Q.s(a,a.split(J)),t=a.match(I),u;s=s.slice(0);if(!s.length)return c;k=s.pop(),n=s.length&&(i=s[s.length-1].match(x))?b.getElementById(i[1]):b;if(!n)return c;o=T(k),m=t&&/^[+~]$/.test(t[t.length-1])?function(a){while(n=n.nextSibling)n.nodeType==1&&(o[1]?o[1]==n.tagName.toLowerCase():1)&&a.push(n);return a}([]):n.getElementsByTagName(o[1]||"*");for(e=0,h=m.length;e<h;e++)if(q=U.apply(m[e],o))c[f++]=q;if(!s.length)return c;for(f=0,h=c.length,g=0;f<h;f++){j=c[f];for(e=s.length;e--;)while(j=L[t[e]](j,c[f]))if(p=U.apply(j,T(s[e])))break;p&&(d[g++]=c[f])}return d}function Y(a){return a&&a.nodeType&&(a.nodeType==1||a.nodeType==9)}function Z(a){var b=[],c,d;e:for(c=0;c<a.length;c++){for(d=0;d<b.length;d++)if(b[d]==a[c])continue e;b[b.length]=a[c]}return b}function $(a){return typeof a=="object"&&isFinite(a.length)}function _(a){return a?typeof a=="string"?ba(a)[0]:$(a)?a[0]:a:b}function ba(a,c){var d=_(c);return!d||!a?[]:a===window||Y(a)?!c||a!==window&&Y(d)&&bb(a,d)?[a]:[]:a&&$(a)?R(a):(i=a.match(x))?(n=b.getElementById(i[1]))?[n]:[]:(i=a.match(z))?R(d.getElementsByTagName(i[1])):bd(a,d)}var a=this,b=document,c=a.qwery,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u=b.documentElement,v=/#([\w\-]+)/,w=/\.[\w\-]+/g,x=/^#([\w\-]+$)/,y=/^\.([\w\-]+)$/,z=/^([\w\-]+)$/,A=/^([\w]+)?\.([\w\-]+)$/,B=/\s*([\s\+\~>])\s*/g,C=/[\s\>\+\~]/,D=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,E=/([.*+?\^=!:${}()|\[\]\/\\])/g,F=/^([a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,G=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,H=/:([\w\-]+)(\(['"]?([\s\w\+\-]+)['"]?\))?/,I=new RegExp("("+C.source+")"+D.source,"g"),J=new RegExp(C.source+D.source),K=new RegExp(F.source+"("+G.source+")?"+"("+H.source+")?"),L={" ":function(a){return a&&a!==u&&a.parentNode},">":function(a,b){return a&&a.parentNode==b.parentNode&&a.parentNode},"~":function(a){return a&&a.previousSibling},"+":function(a,b,c,d){return a?(c=S(a),d=S(b),c&&d&&c==d&&c):!1}};M.prototype={g:function(a){return this.c[a]||undefined},s:function(a,b){return this.c[a]=b,b}};var N=new M,O=new M,P=new M,Q=new M,bb="compareDocumentPosition"in u?function(a,b){return(b.compareDocumentPosition(a)&16)==16}:"contains"in u?function(a,c){return c=c==b||c==window?u:c,c!==a&&c.contains(a)}:function(a,b){while(a=a.parentNode)if(a===b)return 1;return 0},bc=function(){if(!b.querySelector||!b.querySelectorAll)return!1;try{return b.querySelectorAll(":nth-of-type(1)").length}catch(a){return!1}}(),bd=bc?function(a,c){return b.getElementsByClassName&&(i=a.match(y))?R(c.getElementsByClassName(i[1])):R(c.querySelectorAll(a))}:function(a,c){a=a.replace(B,"$1");var d=[],e,g,j=[],k;if(i=a.match(A)){s=c.getElementsByTagName(i[1]||"*"),l=N.g(i[2])||N.s(i[2],new RegExp("(^|\\s+)"+i[2]+"(\\s+|$)"));for(k=0,h=s.length,f=0;k<h;k++)l.test(s[k].className)&&(d[f++]=s[k]);return d}for(k=0,s=a.split(","),h=s.length;k<h;k++)j[k]=X(s[k]);for(k=0,h=j.length;k<h&&(g=j[k]);k++){var m=g;if(c!==b){m=[];for(f=0,i=g.length;f<i&&(e=g[f]);f++)bb(e,c)&&m.push(e)}d=d.concat(m)}return Z(d)};return ba.uniq=Z,ba.pseudos={},ba.noConflict=function(){return a.qwery=c,this},ba}),provide("qwery",a.exports),!function(a,b){function f(b,c){var d=/^\s*<([^\s>]+)\s*/.exec(b)[1],f=(c||a).createElement(e[d]||"div"),g=[];f.innerHTML=b;var h=f.childNodes;f=f.firstChild,f.nodeType==1&&g.push(f);while(f=f.nextSibling)f.nodeType==1&&g.push(f);return g}var c=require("qwery"),d="table",e={thead:d,tbody:d,tfoot:d,tr:"tbody",th:"tr",td:"tr",fieldset:"form",option:"select"};b._select=function(a,b){return/^\s*</.test(a)?f(a,b):c(a,b)},b.pseudos=c.pseudos,b.ender({find:function(a){var d=[],e,f,g,h,i;for(e=0,f=this.length;e<f;e++){i=c(a,this[e]);for(g=0,h=i.length;g<h;g++)d.push(i[g])}return b(c.uniq(d))},and:function(a){var c=b(a);for(var d=this.length,e=0,f=this.length+c.length;d<f;d++,e++)this[d]=c[e];return this}},!0)}(document,ender)}() |
|
46 | 45 |
\ No newline at end of file |
46 |
+(function(name,context,definition){typeof module!="undefined"&&module.exports?module.exports=definition():typeof context["define"]=="function"&&context.define.amd?define(definition):context[name]=definition()})("qwery",this,function(){function cache(){this.c={}}function classRegex(c){return classCache.g(c)||classCache.s(c,"(^|\\s+)"+c+"(\\s+|$)",1)}function each(a,fn){var i=0,l=a.length;for(;i<l;i++)fn(a[i])}function flatten(ar){for(var r=[],i=0,l=ar.length;i<l;++i)arrayLike(ar[i])?r=r.concat(ar[i]):r[r.length]=ar[i];return r}function arrayify(ar){var i=0,l=ar.length,r=[];for(;i<l;i++)r[i]=ar[i];return r}function previous(n){while(n=n.previousSibling)if(n[nodeType]==1)break;return n}function q(query){return query.match(chunker)}function interpret(whole,tag,idsAndClasses,wholeAttribute,attribute,qualifier,value,wholePseudo,pseudo,wholePseudoVal,pseudoVal){var i,m,k,o,classes;if(this[nodeType]!==1)return!1;if(tag&&tag!=="*"&&this[tagName]&&this[tagName].toLowerCase()!==tag)return!1;if(idsAndClasses&&(m=idsAndClasses.match(id))&&m[1]!==this.id)return!1;if(idsAndClasses&&(classes=idsAndClasses.match(clas)))for(i=classes.length;i--;)if(!classRegex(classes[i].slice(1)).test(this.className))return!1;if(pseudo&&qwery.pseudos[pseudo]&&!qwery.pseudos[pseudo](this,pseudoVal))return!1;if(wholeAttribute&&!value){o=this.attributes;for(k in o)if(Object.prototype.hasOwnProperty.call(o,k)&&(o[k].name||k)==attribute)return this}return wholeAttribute&&!checkAttr(qualifier,getAttr(this,attribute)||"",value)?!1:this}function clean(s){return cleanCache.g(s)||cleanCache.s(s,s.replace(specialChars,"\\$1"))}function checkAttr(qualify,actual,val){switch(qualify){case"=":return actual==val;case"^=":return actual.match(attrCache.g("^="+val)||attrCache.s("^="+val,"^"+clean(val),1));case"$=":return actual.match(attrCache.g("$="+val)||attrCache.s("$="+val,clean(val)+"$",1));case"*=":return actual.match(attrCache.g(val)||attrCache.s(val,clean(val),1));case"~=":return actual.match(attrCache.g("~="+val)||attrCache.s("~="+val,"(?:^|\\s+)"+clean(val)+"(?:\\s+|$)",1));case"|=":return actual.match(attrCache.g("|="+val)||attrCache.s("|="+val,"^"+clean(val)+"(-|$)",1))}return 0}function _qwery(selector,_root){var r=[],ret=[],i,l,m,token,tag,els,intr,item,root=_root,tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr)),dividedTokens=selector.match(dividers);if(!tokens.length)return r;token=(tokens=tokens.slice(0)).pop();tokens.length&&(m=tokens[tokens.length-1].match(idOnly))&&(root=byId(_root,m[1]));if(!root)return r;intr=q(token);els=root!==_root&&root[nodeType]!==9&÷dTokens&&/^[+~]$/.test(dividedTokens[dividedTokens.length-1])?function(r){while(root=root.nextSibling)root[nodeType]==1&&(intr[1]?intr[1]==root[tagName].toLowerCase():1)&&(r[r.length]=root);return r}([]):root[byTag](intr[1]||"*");for(i=0,l=els.length;i<l;i++)if(item=interpret.apply(els[i],intr))r[r.length]=item;if(!tokens.length)return r;each(r,function(e){ancestorMatch(e,tokens,dividedTokens)&&(ret[ret.length]=e)});return ret}function is(el,selector,root){if(isNode(selector))return el==selector;if(arrayLike(selector))return!!~flatten(selector).indexOf(el);var selectors=selector.split(","),tokens,dividedTokens;while(selector=selectors.pop()){tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr));dividedTokens=selector.match(dividers);tokens=tokens.slice(0);if(interpret.apply(el,q(tokens.pop()))&&(!tokens.length||ancestorMatch(el,tokens,dividedTokens,root)))return!0}return!1}function ancestorMatch(el,tokens,dividedTokens,root){function crawl(e,i,p){while(p=walker[dividedTokens[i]](p,e))if(isNode(p)&&interpret.apply(p,q(tokens[i]))){if(!i)return p;if(cand=crawl(p,i-1,p))return cand}}var cand;return(cand=crawl(el,tokens.length-1,el))&&(!root||isAncestor(cand,root))}function isNode(el,t){return el&&typeof el=="object"&&(t=el[nodeType])&&(t==1||t==9)}function uniq(ar){var a=[],i,j;e:for(i=0;i<ar.length;++i){for(j=0;j<a.length;++j)if(a[j]==ar[i])continue e;a[a.length]=ar[i]}return a}function arrayLike(o){return typeof o=="object"&&isFinite(o.length)}function normalizeRoot(root){return root?typeof root=="string"?qwery(root)[0]:!root[nodeType]&&arrayLike(root)?root[0]:root:doc}function byId(root,id,el){return root[nodeType]===9?root.getElementById(id):root.ownerDocument&&((el=root.ownerDocument.getElementById(id))&&isAncestor(el,root)&&el||!isAncestor(root,root.ownerDocument)&&select('[id="'+id+'"]',root)[0])}function qwery(selector,_root){var m,el,root=normalizeRoot(_root);if(!root||!selector)return[];if(selector===window||isNode(selector))return!_root||selector!==window&&isNode(root)&&isAncestor(selector,root)?[selector]:[];if(selector&&arrayLike(selector))return flatten(selector);if(m=selector.match(easy)){if(m[1])return(el=byId(root,m[1]))?[el]:[];if(m[2])return arrayify(root[byTag](m[2]));if(hasByClass&&m[3])return arrayify(root[byClass](m[3]))}return select(selector,root)}function collectSelector(root,collector){return function(s){var oid,nid;if(splittable.test(s)){if(root[nodeType]!==9){(nid=oid=root.getAttribute("id"))||root.setAttribute("id",nid="__qwerymeupscotty");s='[id="'+nid+'"]'+s;collector(root.parentNode||root,s,!0);oid||root.removeAttribute("id")}return}s.length&&collector(root,s,!1)}}var doc=document,html=doc.documentElement,byClass="getElementsByClassName",byTag="getElementsByTagName",qSA="querySelectorAll",useNativeQSA="useNativeQSA",tagName="tagName",nodeType="nodeType",select,id=/#([\w\-]+)/,clas=/\.[\w\-]+/g,idOnly=/^#([\w\-]+)$/,classOnly=/^\.([\w\-]+)$/,tagOnly=/^([\w\-]+)$/,tagAndOrClass=/^([\w]+)?\.([\w\-]+)$/,splittable=/(^|,)\s*[>~+]/,normalizr=/^\s+|\s*([,\s\+\~>]|$)\s*/g,splitters=/[\s\>\+\~]/,splittersMore=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,specialChars=/([.*+?\^=!:${}()|\[\]\/\\])/g,simple=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,attr=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,pseudo=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,easy=new RegExp(idOnly.source+"|"+tagOnly.source+"|"+classOnly.source),dividers=new RegExp("("+splitters.source+")"+splittersMore.source,"g"),tokenizr=new RegExp(splitters.source+splittersMore.source),chunker=new RegExp(simple.source+"("+attr.source+")?"+"("+pseudo.source+")?"),walker={" ":function(node){return node&&node!==html&&node.parentNode},">":function(node,contestant){return node&&node.parentNode==contestant.parentNode&&node.parentNode},"~":function(node){return node&&node.previousSibling},"+":function(node,contestant,p1,p2){return node?(p1=previous(node))&&(p2=previous(contestant))&&p1==p2&&p1:!1}};cache.prototype={g:function(k){return this.c[k]||undefined},s:function(k,v,r){v=r?new RegExp(v):v;return this.c[k]=v}};var classCache=new cache,cleanCache=new cache,attrCache=new cache,tokenCache=new cache,isAncestor="compareDocumentPosition"in html?function(element,container){return(container.compareDocumentPosition(element)&16)==16}:"contains"in html?function(element,container){container=container[nodeType]===9||container==window?html:container;return container!==element&&container.contains(element)}:function(element,container){while(element=element.parentNode)if(element===container)return 1;return 0},getAttr=function(){var e=doc.createElement("p");return(e.innerHTML='<a href="#x">x</a>')&&e.firstChild.getAttribute("href")!="#x"?function(e,a){return a==="class"?e.className:a==="href"||a==="src"?e.getAttribute(a,2):e.getAttribute(a)}:function(e,a){return e.getAttribute(a)}}(),hasByClass=!!doc[byClass],hasQSA=doc.querySelector&&doc[qSA],selectQSA=function(selector,root){var result=[],ss,e;try{if(root[nodeType]===9||!splittable.test(selector))return arrayify(root[qSA](selector));each(ss=selector.split(","),collectSelector(root,function(ctx,s){e=ctx[qSA](s);e.length==1?result[result.length]=e.item(0):e.length&&(result=result.concat(arrayify(e)))}));return ss.length>1&&result.length>1?uniq(result):result}catch(ex){}return selectNonNative(selector,root)},selectNonNative=function(selector,root){var result=[],items,m,i,l,r,ss;selector=selector.replace(normalizr,"$1");if(m=selector.match(tagAndOrClass)){r=classRegex(m[2]);items=root[byTag](m[1]||"*");for(i=0,l=items.length;i<l;i++)r.test(items[i].className)&&(result[result.length]=items[i]);return result}each(ss=selector.split(","),collectSelector(root,function(ctx,s,rewrite){r=_qwery(s,ctx);for(i=0,l=r.length;i<l;i++)if(ctx[nodeType]===9||rewrite||isAncestor(r[i],root))result[result.length]=r[i]}));return ss.length>1&&result.length>1?uniq(result):result},configure=function(options){typeof options[useNativeQSA]!="undefined"&&(select=options[useNativeQSA]?hasQSA?selectQSA:selectNonNative:selectNonNative)};configure({useNativeQSA:!0});qwery.configure=configure;qwery.uniq=uniq;qwery.is=is;qwery.pseudos={};return qwery});provide("qwery",module.exports);(function($){var q=function(){var r;try{r=require("qwery")}catch(ex){r=require("qwery-mobile")}finally{return r}}();$.pseudos=q.pseudos;$._select=function(s,r){return($._select=function(){var b;if(typeof $.create=="function")return function(s,r){return/^\s*</.test(s)?$.create(s,r):q(s,r)};try{b=require("bonzo");return function(s,r){return/^\s*</.test(s)?b.create(s,r):q(s,r)}}catch(e){}return q}())(s,r)};$.ender({find:function(s){var r=[],i,l,j,k,els;for(i=0,l=this.length;i<l;i++){els=q(s,this[i]);for(j=0,k=els.length;j<k;j++)r.push(els[j])}return $(q.uniq(r))},and:function(s){var plus=$(s);for(var i=this.length,j=0,l=this.length+plus.length;i<l;i++,j++)this[i]=plus[j];this.length+=plus.length;return this},is:function(s,r){var i,l;for(i=0,l=this.length;i<l;i++)if(q.is(this[i],s,r))return!0;return!1}},!0)})(ender)})() |
|
47 | 47 |
\ No newline at end of file |
... | ... |
@@ -1,1497 +1,3256 @@ |
1 | 1 |
/*! |
2 |
- * Ender: open module JavaScript framework |
|
3 |
- * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat) |
|
4 |
- * https://ender.no.de |
|
2 |
+ * ============================================================= |
|
3 |
+ * Ender: open module JavaScript framework (https://ender.no.de) |
|
4 |
+ * Build: ender build jeesh reqwest |
|
5 |
+ * ============================================================= |
|
6 |
+ */ |
|
7 |
+ |
|
8 |
+/*! |
|
9 |
+ * Ender: open module JavaScript framework (client-lib) |
|
10 |
+ * copyright Dustin Diaz & Jacob Thornton 2011-2012 (@ded @fat) |
|
11 |
+ * http://ender.jit.su |
|
5 | 12 |
* License MIT |
6 |
- * Build: ender -b jeesh |
|
7 | 13 |
*/ |
8 |
-!function (context) { |
|
14 |
+(function (context) { |
|
15 |
+ |
|
16 |
+ // a global object for node.js module compatiblity |
|
17 |
+ // ============================================ |
|
18 |
+ |
|
19 |
+ context['global'] = context |
|
20 |
+ |
|
21 |
+ // Implements simple module system |
|
22 |
+ // losely based on CommonJS Modules spec v1.1.1 |
|
23 |
+ // ============================================ |
|
24 |
+ |
|
25 |
+ var modules = {} |
|
26 |
+ , old = context['$'] |
|
27 |
+ , oldEnder = context['ender'] |
|
28 |
+ , oldRequire = context['require'] |
|
29 |
+ , oldProvide = context['provide'] |
|
30 |
+ |
|
31 |
+ function require (identifier) { |
|
32 |
+ // modules can be required from ender's build system, or found on the window |
|
33 |
+ var module = modules['$' + identifier] || window[identifier] |
|
34 |
+ if (!module) throw new Error("Ender Error: Requested module '" + identifier + "' has not been defined.") |
|
35 |
+ return module |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ function provide (name, what) { |
|
39 |
+ return (modules['$' + name] = what) |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ context['provide'] = provide |
|
43 |
+ context['require'] = require |
|
9 | 44 |
|
10 | 45 |
function aug(o, o2) { |
11 |
- for (var k in o2) { |
|
12 |
- k != 'noConflict' && k != '_VERSION' && (o[k] = o2[k]); |
|
13 |
- } |
|
14 |
- return o; |
|
46 |
+ for (var k in o2) k != 'noConflict' && k != '_VERSION' && (o[k] = o2[k]) |
|
47 |
+ return o |
|
15 | 48 |
} |
16 | 49 |
|
17 |
- function boosh(s, r) { |
|
18 |
- var els; |
|
19 |
- if (ender._select && typeof s == 'string' || s.nodeName || s.length && 'item' in s || s == window) { //string || node || nodelist || window |
|
20 |
- els = ender._select(s, r); |
|
21 |
- els.selector = s; |
|
50 |
+ /** |
|
51 |
+ * main Ender return object |
|
52 |
+ * @constructor |
|
53 |
+ * @param {Array|Node|string} s a CSS selector or DOM node(s) |
|
54 |
+ * @param {Array.|Node} r a root node(s) |
|
55 |
+ */ |
|
56 |
+ function Ender(s, r) { |
|
57 |
+ var elements |
|
58 |
+ , i |
|
59 |
+ |
|
60 |
+ this.selector = s |
|
61 |
+ // string || node || nodelist || window |
|
62 |
+ if (typeof s == 'undefined') { |
|
63 |
+ elements = [] |
|
64 |
+ this.selector = '' |
|
65 |
+ } else if (typeof s == 'string' || s.nodeName || (s.length && 'item' in s) || s == window) { |
|
66 |
+ elements = ender._select(s, r) |
|
22 | 67 |
} else { |
23 |
- els = isFinite(s.length) ? s : [s]; |
|
68 |
+ elements = isFinite(s.length) ? s : [s] |
|
24 | 69 |
} |
25 |
- return aug(els, boosh); |
|
70 |
+ this.length = elements.length |
|
71 |
+ for (i = this.length; i--;) this[i] = elements[i] |
|
26 | 72 |
} |
27 | 73 |
|
28 |
- function ender(s, r) { |
|
29 |
- return boosh(s, r); |
|
74 |
+ /** |
|
75 |
+ * @param {function(el, i, inst)} fn |
|
76 |
+ * @param {Object} opt_scope |
|
77 |
+ * @returns {Ender} |
|
78 |
+ */ |
|
79 |
+ Ender.prototype['forEach'] = function (fn, opt_scope) { |
|
80 |
+ var i, l |
|
81 |
+ // opt out of native forEach so we can intentionally call our own scope |
|
82 |
+ // defaulting to the current item and be able to return self |
|
83 |
+ for (i = 0, l = this.length; i < l; ++i) i in this && fn.call(opt_scope || this[i], this[i], i, this) |
|
84 |
+ // return self for chaining |
|
85 |
+ return this |
|
30 | 86 |
} |
31 | 87 |
|
32 |
- aug(ender, { |
|
33 |
- _VERSION: '0.2.0', |
|
34 |
- ender: function (o, chain) { |
|
35 |
- aug(chain ? boosh : ender, o); |
|
36 |
- } |
|
37 |
- }); |
|
88 |
+ Ender.prototype.$ = ender // handy reference to self |
|
38 | 89 |
|
39 |
- aug(boosh, { |
|
40 |
- forEach: function (fn, scope) { |
|
41 |
- // opt out of native forEach so we can intentionally call our own scope |
|
42 |
- // defaulting to the current item |
|
43 |
- for (var i = 0, l = this.length; i < l; ++i) { |
|
44 |
- i in this && fn.call(scope || this[i], this[i], i, this); |
|
45 |
- } |
|
46 |
- // return self for chaining |
|
47 |
- return this; |
|
48 |
- } |
|
49 |
- }); |
|
50 | 90 |
|
51 |
- var old = context.$; |
|
52 |
- ender.noConflict = function () { |
|
53 |
- context.$ = old; |
|
54 |
- return this; |
|
55 |
- }; |
|
91 |
+ function ender(s, r) { |
|
92 |
+ return new Ender(s, r) |
|
93 |
+ } |
|
56 | 94 |
|
57 |
- (typeof module !== 'undefined') && module.exports && (module.exports = ender); |
|
58 |
- // use subscript notation as extern for Closure compilation |
|
59 |
- context['ender'] = context['$'] = ender; |
|
95 |
+ ender['_VERSION'] = '0.4.3-dev' |
|
60 | 96 |
|
61 |
-}(this); |
|
62 |
-/*! |
|
63 |
- * bean.js - copyright Jacob Thornton 2011 |
|
64 |
- * https://github.com/fat/bean |
|
65 |
- * MIT License |
|
66 |
- * special thanks to: |
|
67 |
- * dean edwards: http://dean.edwards.name/ |
|
68 |
- * dperini: https://github.com/dperini/nwevents |
|
69 |
- * the entire mootools team: github.com/mootools/mootools-core |
|
70 |
- */ |
|
71 |
-!function (context) { |
|
72 |
- var __uid = 1, registry = {}, collected = {}, |
|
73 |
- overOut = /over|out/, |
|
74 |
- namespace = /[^\.]*(?=\..*)\.|.*/, |
|
75 |
- stripName = /\..*/, |
|
76 |
- addEvent = 'addEventListener', |
|
77 |
- attachEvent = 'attachEvent', |
|
78 |
- removeEvent = 'removeEventListener', |
|
79 |
- detachEvent = 'detachEvent', |
|
80 |
- doc = context.document || {}, |
|
81 |
- root = doc.documentElement || {}, |
|
82 |
- W3C_MODEL = root[addEvent], |
|
83 |
- eventSupport = W3C_MODEL ? addEvent : attachEvent, |
|
97 |
+ ender.fn = Ender.prototype // for easy compat to jQuery plugins |
|
84 | 98 |
|
85 |
- isDescendant = function (parent, child) { |
|
86 |
- var node = child.parentNode; |
|
87 |
- while (node != null) { |
|
88 |
- if (node == parent) { |
|
89 |
- return true; |
|
90 |
- } |
|
91 |
- node = node.parentNode; |
|
92 |
- } |
|
93 |
- }, |
|
94 |
- |
|
95 |
- retrieveUid = function (obj, uid) { |
|
96 |
- return (obj.__uid = uid || obj.__uid || __uid++); |
|
97 |
- }, |
|
99 |
+ ender.ender = function (o, chain) { |
|
100 |
+ aug(chain ? Ender.prototype : ender, o) |
|
101 |
+ } |
|
98 | 102 |
|
99 |
- retrieveEvents = function (element) { |
|
100 |
- var uid = retrieveUid(element); |
|
101 |
- return (registry[uid] = registry[uid] || {}); |
|
102 |
- }, |
|
103 |
+ ender._select = function (s, r) { |
|
104 |
+ if (typeof s == 'string') return (r || document).querySelectorAll(s) |
|
105 |
+ if (s.nodeName) return [s] |
|
106 |
+ return s |
|
107 |
+ } |
|
103 | 108 |
|
104 |
- listener = W3C_MODEL ? function (element, type, fn, add) { |
|
105 |
- element[add ? addEvent : removeEvent](type, fn, false); |
|
106 |
- } : function (element, type, fn, add, custom) { |
|
107 |
- custom && add && (element['_on' + custom] = element['_on' + custom] || 0); |
|
108 |
- element[add ? attachEvent : detachEvent]('on' + type, fn); |
|
109 |
- }, |
|
110 | 109 |
|
111 |
- nativeHandler = function (element, fn, args) { |
|
112 |
- return function (event) { |
|
113 |
- event = fixEvent(event || ((this.ownerDocument || this.document || this).parentWindow || context).event); |
|
114 |
- return fn.apply(element, [event].concat(args)); |
|
115 |
- }; |
|
116 |
- }, |
|
110 |
+ // use callback to receive Ender's require & provide and remove them from global |
|
111 |
+ ender.noConflict = function (callback) { |
|
112 |
+ context['$'] = old |
|
113 |
+ if (callback) { |
|
114 |
+ context['provide'] = oldProvide |
|
115 |
+ context['require'] = oldRequire |
|
116 |
+ context['ender'] = oldEnder |
|
117 |
+ if (typeof callback == 'function') callback(require, provide, this) |
|
118 |
+ } |
|
119 |
+ return this |
|
120 |
+ } |
|
117 | 121 |
|
118 |
- customHandler = function (element, fn, type, condition, args) { |
|
119 |
- return function (event) { |
|
120 |
- if (condition ? condition.call(this, event) : W3C_MODEL ? true : event && event.propertyName == '_on' + type || !event) { |
|
121 |
- fn.apply(element, [event].concat(args)); |
|
122 |
+ if (typeof module !== 'undefined' && module.exports) module.exports = ender |
|
123 |
+ // use subscript notation as extern for Closure compilation |
|
124 |
+ context['ender'] = context['$'] = ender |
|
125 |
+ |
|
126 |
+}(this)); |
|
127 |
+ |
|
128 |
+(function () { |
|
129 |
+ |
|
130 |
+ var module = { exports: {} }, exports = module.exports; |
|
131 |
+ |
|
132 |
+ /*! |
|
133 |
+ * Reqwest! A general purpose XHR connection manager |
|
134 |
+ * (c) Dustin Diaz 2012 |
|
135 |
+ * https://github.com/ded/reqwest |
|
136 |
+ * license MIT |
|
137 |
+ */ |
|
138 |
+ !function (name, definition) { |
|
139 |
+ if (typeof module != 'undefined') module.exports = definition() |
|
140 |
+ else if (typeof define == 'function' && define.amd) define(definition) |
|
141 |
+ else this[name] = definition() |
|
142 |
+ }('reqwest', function () { |
|
143 |
+ |
|
144 |
+ var win = window |
|
145 |
+ , doc = document |
|
146 |
+ , twoHundo = /^20\d$/ |
|
147 |
+ , byTag = 'getElementsByTagName' |
|
148 |
+ , readyState = 'readyState' |
|
149 |
+ , contentType = 'Content-Type' |
|
150 |
+ , requestedWith = 'X-Requested-With' |
|
151 |
+ , head = doc[byTag]('head')[0] |
|
152 |
+ , uniqid = 0 |
|
153 |
+ , callbackPrefix = 'reqwest_' + (+new Date()) |
|
154 |
+ , lastValue // data stored by the most recent JSONP callback |
|
155 |
+ , xmlHttpRequest = 'XMLHttpRequest' |
|
156 |
+ |
|
157 |
+ var isArray = typeof Array.isArray == 'function' ? Array.isArray : function (a) { |
|
158 |
+ return a instanceof Array |
|
159 |
+ } |
|
160 |
+ var defaultHeaders = { |
|
161 |
+ contentType: 'application/x-www-form-urlencoded' |
|
162 |
+ , requestedWith: xmlHttpRequest |
|
163 |
+ , accept: { |
|
164 |
+ '*': 'text/javascript, text/html, application/xml, text/xml, */*' |
|
165 |
+ , xml: 'application/xml, text/xml' |
|
166 |
+ , html: 'text/html' |
|
167 |
+ , text: 'text/plain' |
|
168 |
+ , json: 'application/json, text/javascript' |
|
169 |
+ , js: 'application/javascript, text/javascript' |
|
170 |
+ } |
|
122 | 171 |
} |
123 |
- }; |
|
124 |
- }, |
|
125 |
- |
|
126 |
- addListener = function (element, orgType, fn, args) { |
|
127 |
- var type = orgType.replace(stripName, ''), |
|
128 |
- events = retrieveEvents(element), |
|
129 |
- handlers = events[type] || (events[type] = {}), |
|
130 |
- uid = retrieveUid(fn, orgType.replace(namespace, '')); |
|
131 |
- if (handlers[uid]) { |
|
132 |
- return element; |
|
133 |
- } |
|
134 |
- var custom = customEvents[type]; |
|
135 |
- if (custom) { |
|
136 |
- fn = custom.condition ? customHandler(element, fn, type, custom.condition) : fn; |
|
137 |
- type = custom.base || type; |
|
138 |
- } |
|
139 |
- var isNative = nativeEvents[type]; |
|
140 |
- fn = isNative ? nativeHandler(element, fn, args) : customHandler(element, fn, type, false, args); |
|
141 |
- isNative = W3C_MODEL || isNative; |
|
142 |
- if (type == 'unload') { |
|
143 |
- var org = fn; |
|
144 |
- fn = function () { |
|
145 |
- removeListener(element, type, fn) && org(); |
|
146 |
- }; |
|
147 |
- } |
|
148 |
- element[eventSupport] && listener(element, isNative ? type : 'propertychange', fn, true, !isNative && type); |
|
149 |
- handlers[uid] = fn; |
|
150 |
- fn.__uid = uid; |
|
151 |
- return type == 'unload' ? element : (collected[retrieveUid(element)] = element); |
|
152 |
- }, |
|
153 |
- |
|
154 |
- removeListener = function (element, orgType, handler) { |
|
155 |
- var uid, names, uids, i, events = retrieveEvents(element), type = orgType.replace(stripName, ''); |
|
156 |
- if (!events || !events[type]) { |
|
157 |
- return element; |
|
158 |
- } |
|
159 |
- names = orgType.replace(namespace, ''); |
|
160 |
- uids = names ? names.split('.') : [handler.__uid]; |
|
161 |
- for (i = uids.length; i--;) { |
|
162 |
- uid = uids[i]; |
|
163 |
- handler = events[type][uid]; |
|
164 |
- delete events[type][uid]; |
|
165 |
- if (element[eventSupport]) { |
|
166 |
- type = customEvents[type] ? customEvents[type].base : type; |
|
167 |
- var isNative = W3C_MODEL || nativeEvents[type]; |
|
168 |
- listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type); |
|
169 |
- } |
|
170 |
- } |
|
171 |
- return element; |
|
172 |
- }, |
|
173 |
- |
|
174 |
- del = function (selector, fn, $) { |
|
175 |
- return function (e) { |
|
176 |
- var array = typeof selector == 'string' ? $(selector, this) : selector; |
|
177 |
- for (var target = e.target; target && target != this; target = target.parentNode) { |
|
178 |
- for (var i = array.length; i--;) { |
|
179 |
- if (array[i] == target) { |
|
180 |
- return fn.apply(target, arguments); |
|
172 |
+ var xhr = win[xmlHttpRequest] ? |
|
173 |
+ function () { |
|
174 |
+ return new XMLHttpRequest() |
|
175 |
+ } : |
|
176 |
+ function () { |
|
177 |
+ return new ActiveXObject('Microsoft.XMLHTTP') |
|
178 |
+ } |
|
179 |
+ |
|
180 |
+ function handleReadyState(o, success, error) { |
|
181 |
+ return function () { |
|
182 |
+ if (o && o[readyState] == 4) { |
|
183 |
+ if (twoHundo.test(o.status)) { |
|
184 |
+ success(o) |
|
185 |
+ } else { |
|
186 |
+ error(o) |
|
181 | 187 |
} |
182 | 188 |
} |
183 | 189 |
} |
184 |
- }; |
|
185 |
- }, |
|
186 |
- |
|
187 |
- add = function (element, events, fn, delfn, $) { |
|
188 |
- if (typeof events == 'object' && !fn) { |
|
189 |
- for (var type in events) { |
|
190 |
- events.hasOwnProperty(type) && add(element, type, events[type]); |
|
191 |
- } |
|
192 |
- } else { |
|
193 |
- var isDel = typeof fn == 'string', types = (isDel ? fn : events).split(' '); |
|
194 |
- fn = isDel ? del(events, delfn, $) : fn; |
|
195 |
- for (var i = types.length; i--;) { |
|
196 |
- addListener(element, types[i], fn, Array.prototype.slice.call(arguments, isDel ? 4 : 3)); |
|
190 |
+ } |
|
191 |
+ |
|
192 |
+ function setHeaders(http, o) { |
|
193 |
+ var headers = o.headers || {}, h |
|
194 |
+ headers.Accept = headers.Accept || defaultHeaders.accept[o.type] || defaultHeaders.accept['*'] |
|
195 |
+ // breaks cross-origin requests with legacy browsers |
|
196 |
+ if (!o.crossOrigin && !headers[requestedWith]) headers[requestedWith] = defaultHeaders.requestedWith |
|
197 |
+ if (!headers[contentType]) headers[contentType] = o.contentType || defaultHeaders.contentType |
|
198 |
+ for (h in headers) { |
|
199 |
+ headers.hasOwnProperty(h) && http.setRequestHeader(h, headers[h]) |
|
197 | 200 |
} |
198 | 201 |
} |
199 |
- return element; |
|
200 |
- }, |
|
201 |
- |
|
202 |
- remove = function (element, orgEvents, fn) { |
|
203 |
- var k, type, events, |
|
204 |
- isString = typeof(orgEvents) == 'string', |
|
205 |
- names = isString && orgEvents.replace(namespace, ''), |
|
206 |
- rm = removeListener, |
|
207 |
- attached = retrieveEvents(element); |
|
208 |
- if (isString && /\s/.test(orgEvents)) { |
|
209 |
- orgEvents = orgEvents.split(' '); |
|
210 |
- var i = orgEvents.length - 1; |
|
211 |
- while (remove(element, orgEvents[i]) && i--) {} |
|
212 |
- return element; |
|
213 |
- } |
|
214 |
- events = isString ? orgEvents.replace(stripName, '') : orgEvents; |
|
215 |
- if (!attached || (isString && !attached[events])) { |
|
216 |
- return element; |
|
217 |
- } |
|
218 |
- if (typeof fn == 'function') { |
|
219 |
- rm(element, events, fn); |
|
220 |
- } else if (names) { |
|
221 |
- rm(element, orgEvents); |
|
222 |
- } else { |
|
223 |
- rm = events ? rm : remove; |
|
224 |
- type = isString && events; |
|
225 |
- events = events ? (fn || attached[events] || events) : attached; |
|
226 |
- for (k in events) { |
|
227 |
- events.hasOwnProperty(k) && rm(element, type || k, events[k]); |
|
202 |
+ |
|
203 |
+ function setCredentials(http, o) { |
|
204 |
+ if (typeof o.withCredentials !== "undefined" && typeof http.withCredentials !== "undefined") { |
|
205 |
+ http.withCredentials = !!o.withCredentials |
|
228 | 206 |
} |
229 | 207 |
} |
230 |
- return element; |
|
231 |
- }, |
|
232 |
- |
|
233 |
- fire = function (element, type, args) { |
|
234 |
- var evt, k, i, types = type.split(' '); |
|
235 |
- for (i = types.length; i--;) { |
|
236 |
- type = types[i].replace(stripName, ''); |
|
237 |
- var isNative = nativeEvents[type], |
|
238 |
- isNamespace = types[i].replace(namespace, ''), |
|
239 |
- handlers = retrieveEvents(element)[type]; |
|
240 |
- if (isNamespace) { |
|
241 |
- isNamespace = isNamespace.split('.'); |
|
242 |
- for (k = isNamespace.length; k--;) { |
|
243 |
- handlers[isNamespace[k]] && handlers[isNamespace[k]].apply(element, args); |
|
244 |
- } |
|
245 |
- } else if (!args && element[eventSupport]) { |
|
246 |
- fireListener(isNative, type, element); |
|
208 |
+ |
|
209 |
+ function generalCallback(data) { |
|
210 |
+ lastValue = data |
|
211 |
+ } |
|
212 |
+ |
|
213 |
+ function urlappend(url, s) { |
|
214 |
+ return url + (/\?/.test(url) ? '&' : '?') + s |
|
215 |
+ } |
|
216 |
+ |
|
217 |
+ function handleJsonp(o, fn, err, url) { |
|
218 |
+ var reqId = uniqid++ |
|
219 |
+ , cbkey = o.jsonpCallback || 'callback' // the 'callback' key |
|
220 |
+ , cbval = o.jsonpCallbackName || reqwest.getcallbackPrefix(reqId) |
|
221 |
+ // , cbval = o.jsonpCallbackName || ('reqwest_' + reqId) // the 'callback' value |
|
222 |
+ , cbreg = new RegExp('((^|\\?|&)' + cbkey + ')=([^&]+)') |
|
223 |
+ , match = url.match(cbreg) |
|
224 |
+ , script = doc.createElement('script') |
|
225 |
+ , loaded = 0 |
|
226 |
+ |
|
227 |
+ if (match) { |
|
228 |
+ if (match[3] === '?') { |
|
229 |
+ url = url.replace(cbreg, '$1=' + cbval) // wildcard callback func name |
|
230 |
+ } else { |
|
231 |
+ cbval = match[3] // provided callback func name |
|
232 |
+ } |
|
247 | 233 |
} else { |
248 |
- for (k in handlers) { |
|
249 |
- handlers.hasOwnProperty(k) && handlers[k].apply(element, args); |
|
234 |
+ url = urlappend(url, cbkey + '=' + cbval) // no callback details, add 'em |
|
235 |
+ } |
|
236 |
+ |
|
237 |
+ win[cbval] = generalCallback |
|
238 |
+ |
|
239 |
+ script.type = 'text/javascript' |
|
240 |
+ script.src = url |
|
241 |
+ script.async = true |
|
242 |
+ if (typeof script.onreadystatechange !== 'undefined') { |
|
243 |
+ // need this for IE due to out-of-order onreadystatechange(), binding script |
|
244 |
+ // execution to an event listener gives us control over when the script |
|
245 |
+ // is executed. See http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html |
|
246 |
+ script.event = 'onclick' |
|
247 |
+ script.htmlFor = script.id = '_reqwest_' + reqId |
|
248 |
+ } |
|
249 |
+ |
|
250 |
+ script.onload = script.onreadystatechange = function () { |
|
251 |
+ if ((script[readyState] && script[readyState] !== 'complete' && script[readyState] !== 'loaded') || loaded) { |
|
252 |
+ return false |
|
250 | 253 |
} |
254 |
+ script.onload = script.onreadystatechange = null |
|
255 |
+ script.onclick && script.onclick() |
|
256 |
+ // Call the user callback with the last value stored and clean up values and scripts. |
|
257 |
+ o.success && o.success(lastValue) |
|
258 |
+ lastValue = undefined |
|
259 |
+ head.removeChild(script) |
|
260 |
+ loaded = 1 |
|
251 | 261 |
} |
262 |
+ |
|
263 |
+ // Add the script to the DOM head |
|
264 |
+ head.appendChild(script) |
|
252 | 265 |
} |
253 |
- return element; |
|
254 |
- }, |
|
255 |
- |
|
256 |
- fireListener = W3C_MODEL ? function (isNative, type, element) { |
|
257 |
- evt = document.createEvent(isNative ? "HTMLEvents" : "UIEvents"); |
|
258 |
- evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, context, 1); |
|
259 |
- element.dispatchEvent(evt); |
|
260 |
- } : function (isNative, type, element) { |
|
261 |
- isNative ? element.fireEvent('on' + type, document.createEventObject()) : element['_on' + type]++; |
|
262 |
- }, |
|
263 |
- |
|
264 |
- clone = function (element, from, type) { |
|
265 |
- var events = retrieveEvents(from), obj, k; |
|
266 |
- obj = type ? events[type] : events; |
|
267 |
- for (k in obj) { |
|
268 |
- obj.hasOwnProperty(k) && (type ? add : clone)(element, type || from, type ? obj[k] : k); |
|
269 |
- } |
|
270 |
- return element; |
|
271 |
- }, |
|
272 |
- |
|
273 |
- fixEvent = function (e) { |
|
274 |
- var result = {}; |
|
275 |
- if (!e) { |
|
276 |
- return result; |
|
277 |
- } |
|
278 |
- var type = e.type, target = e.target || e.srcElement; |
|
279 |
- result.preventDefault = fixEvent.preventDefault(e); |
|
280 |
- result.stopPropagation = fixEvent.stopPropagation(e); |
|
281 |
- result.target = target && target.nodeType == 3 ? target.parentNode : target; |
|
282 |
- if (~type.indexOf('key')) { |
|
283 |
- result.keyCode = e.which || e.keyCode; |
|
284 |
- } else if ((/click|mouse|menu/i).test(type)) { |
|
285 |
- result.rightClick = e.which == 3 || e.button == 2; |
|
286 |
- result.pos = { x: 0, y: 0 }; |
|
287 |
- if (e.pageX || e.pageY) { |
|
288 |
- result.clientX = e.pageX; |
|
289 |
- result.clientY = e.pageY; |
|
290 |
- } else if (e.clientX || e.clientY) { |
|
291 |
- result.clientX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; |
|
292 |
- result.clientY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; |
|
293 |
- } |
|
294 |
- overOut.test(type) && (result.relatedTarget = e.relatedTarget || e[(type == 'mouseover' ? 'from' : 'to') + 'Element']); |
|
295 |
- } |
|
296 |
- for (var k in e) { |
|
297 |
- if (!(k in result)) { |
|
298 |
- result[k] = e[k]; |
|
299 |
- } |
|
300 |
- } |
|
301 |
- return result; |
|
302 |
- }; |
|
303 |
- |
|
304 |
- fixEvent.preventDefault = function (e) { |
|
305 |
- return function () { |
|
306 |
- if (e.preventDefault) { |
|
307 |
- e.preventDefault(); |
|
266 |
+ |
|
267 |
+ function getRequest(o, fn, err) { |
|
268 |
+ var method = (o.method || 'GET').toUpperCase() |
|
269 |
+ , url = typeof o === 'string' ? o : o.url |
|
270 |
+ // convert non-string objects to query-string form unless o.processData is false |
|
271 |
+ , data = (o.processData !== false && o.data && typeof o.data !== 'string') |
|
272 |
+ ? reqwest.toQueryString(o.data) |
|
273 |
+ : (o.data || null) |
|
274 |
+ , http |
|
275 |
+ |
|
276 |
+ // if we're working on a GET request and we have data then we should append |
|
277 |
+ // query string to end of URL and not post data |
|
278 |
+ if ((o.type == 'jsonp' || method == 'GET') && data) { |
|
279 |
+ url = urlappend(url, data) |
|
280 |
+ data = null |
|
308 | 281 |
} |
309 |
- else { |
|
310 |
- e.returnValue = false; |
|
282 |
+ |
|
283 |
+ if (o.type == 'jsonp') return handleJsonp(o, fn, err, url) |
|
284 |
+ |
|
285 |
+ http = xhr() |
|
286 |
+ http.open(method, url, true) |
|
287 |
+ setHeaders(http, o) |
|
288 |
+ setCredentials(http, o) |
|
289 |
+ http.onreadystatechange = handleReadyState(http, fn, err) |
|
290 |
+ o.before && o.before(http) |
|
291 |
+ http.send(data) |
|
292 |
+ return http |
|
293 |
+ } |
|
294 |
+ |
|
295 |
+ function Reqwest(o, fn) { |
|
296 |
+ this.o = o |
|
297 |
+ this.fn = fn |
|
298 |
+ |
|
299 |
+ init.apply(this, arguments) |
|
300 |
+ } |
|
301 |
+ |
|
302 |
+ function setType(url) { |
|
303 |
+ var m = url.match(/\.(json|jsonp|html|xml)(\?|$)/) |
|
304 |
+ return m ? m[1] : 'js' |
|
305 |
+ } |
|
306 |
+ |
|
307 |
+ function init(o, fn) { |
|
308 |
+ |
|
309 |
+ this.url = typeof o == 'string' ? o : o.url |
|
310 |
+ this.timeout = null |
|
311 |
+ |
|
312 |
+ // whether request has been fulfilled for purpose |
|
313 |
+ // of tracking the Promises |
|
314 |
+ this._fulfilled = false |
|
315 |
+ // success handlers |
|
316 |
+ this._fulfillmentHandlers = [] |
|
317 |
+ // error handlers |
|
318 |
+ this._errorHandlers = [] |
|
319 |
+ // complete (both success and fail) handlers |
|
320 |
+ this._completeHandlers = [] |
|
321 |
+ this._erred = false |
|
322 |
+ this._responseArgs = {} |
|
323 |
+ |
|
324 |
+ var self = this |
|
325 |
+ , type = o.type || setType(this.url) |
|
326 |
+ |
|
327 |
+ fn = fn || function () {} |
|
328 |
+ |
|
329 |
+ if (o.timeout) { |
|
330 |
+ this.timeout = setTimeout(function () { |
|
331 |
+ self.abort() |
|
332 |
+ }, o.timeout) |
|
311 | 333 |
} |
312 |
- }; |
|
313 |
- }; |
|
314 |
- |
|
315 |
- fixEvent.stopPropagation = function (e) { |
|
316 |
- return function () { |
|
317 |
- if (e.stopPropagation) { |
|
318 |
- e.stopPropagation(); |
|
319 |
- } else { |
|
320 |
- e.cancelBubble = true; |
|
334 |
+ |
|
335 |
+ if (o.success) { |
|
336 |
+ this._fulfillmentHandlers.push(function () { |
|
337 |
+ o.success.apply(o, arguments) |
|
338 |
+ }) |
|
321 | 339 |
} |
322 |
- }; |
|
323 |
- }; |
|
324 |
- |
|
325 |
- var nativeEvents = { click: 1, dblclick: 1, mouseup: 1, mousedown: 1, contextmenu: 1, //mouse buttons |
|
326 |
- mousewheel: 1, DOMMouseScroll: 1, //mouse wheel |
|
327 |
- mouseover: 1, mouseout: 1, mousemove: 1, selectstart: 1, selectend: 1, //mouse movement |
|
328 |
- keydown: 1, keypress: 1, keyup: 1, //keyboard |
|
329 |
- orientationchange: 1, // mobile |
|
330 |
- touchstart: 1, touchmove: 1, touchend: 1, touchcancel: 1, // touch |
|
331 |
- gesturestart: 1, gesturechange: 1, gestureend: 1, // gesture |
|
332 |
- focus: 1, blur: 1, change: 1, reset: 1, select: 1, submit: 1, //form elements |
|
333 |
- load: 1, unload: 1, beforeunload: 1, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window |
|
334 |
- error: 1, abort: 1, scroll: 1 }; //misc |
|
335 |
- |
|
336 |
- function check(event) { |
|
337 |
- var related = event.relatedTarget; |
|
338 |
- if (!related) { |
|
339 |
- return related == null; |
|
340 |
+ |
|
341 |
+ if (o.error) { |
|
342 |
+ this._errorHandlers.push(function () { |
|
343 |
+ o.error.apply(o, arguments) |
|
344 |
+ }) |
|
345 |
+ } |
|
346 |
+ |
|
347 |
+ if (o.complete) { |
|
348 |
+ this._completeHandlers.push(function () { |
|
349 |
+ o.complete.apply(o, arguments) |
|
350 |
+ }) |
|
351 |
+ } |
|
352 |
+ |
|
353 |
+ function complete(resp) { |
|
354 |
+ o.timeout && clearTimeout(self.timeout) |
|
355 |
+ self.timeout = null |
|
356 |
+ while (self._completeHandlers.length > 0) { |
|
357 |
+ self._completeHandlers.shift()(resp) |
|
358 |
+ } |
|
359 |
+ } |
|
360 |
+ |
|
361 |
+ function success(resp) { |
|
362 |
+ var r = resp.responseText |
|
363 |
+ if (r) { |
|
364 |
+ switch (type) { |
|
365 |
+ case 'json': |
|
366 |
+ try { |
|
367 |
+ resp = win.JSON ? win.JSON.parse(r) : eval('(' + r + ')') |
|
368 |
+ } catch (err) { |
|
369 |
+ return error(resp, 'Could not parse JSON in response', err) |
|
370 |
+ } |
|
371 |
+ break; |
|
372 |
+ case 'js': |
|
373 |
+ resp = eval(r) |
|
374 |
+ break; |
|
375 |
+ case 'html': |
|
376 |
+ resp = r |
|
377 |
+ break; |
|
378 |
+ case 'xml': |
|
379 |
+ resp = resp.responseXML; |
|
380 |
+ break; |
|
381 |
+ } |
|
382 |
+ } |
|
383 |
+ |
|
384 |
+ self._responseArgs.resp = resp |
|
385 |
+ self._fulfilled = true |
|
386 |
+ fn(resp) |
|
387 |
+ while (self._fulfillmentHandlers.length > 0) { |
|
388 |
+ self._fulfillmentHandlers.shift()(resp) |
|
389 |
+ } |
|
390 |
+ |
|
391 |
+ complete(resp) |
|
392 |
+ } |
|
393 |
+ |
|
394 |
+ function error(resp, msg, t) { |
|
395 |
+ self._responseArgs.resp = resp |
|
396 |
+ self._responseArgs.msg = msg |
|
397 |
+ self._responseArgs.t = t |
|
398 |
+ self._erred = true |
|
399 |
+ while (self._errorHandlers.length > 0) { |
|
400 |
+ self._errorHandlers.shift()(resp, msg, t) |
|
401 |
+ } |
|
402 |
+ complete(resp) |
|
403 |
+ } |
|
404 |
+ |
|
405 |
+ this.request = getRequest(o, success, error) |
|
340 | 406 |
} |
341 |
- return (related != this && related.prefix != 'xul' && !/document/.test(this.toString()) && !isDescendant(this, related)); |
|
342 |
- } |
|
343 |
- |
|
344 |
- var customEvents = { |
|
345 |
- mouseenter: { base: 'mouseover', condition: check }, |
|
346 |
- mouseleave: { base: 'mouseout', condition: check }, |
|
347 |
- mousewheel: { base: /Firefox/.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel' } |
|
348 |
- }; |
|
349 |
- |
|
350 |
- var bean = { add: add, remove: remove, clone: clone, fire: fire }; |
|
351 |
- |
|
352 |
- var clean = function (el) { |
|
353 |
- var uid = remove(el).__uid; |
|
354 |
- if (uid) { |
|
355 |
- delete collected[uid]; |
|
356 |
- delete registry[uid]; |
|
407 |
+ |
|
408 |
+ Reqwest.prototype = { |
|
409 |
+ abort: function () { |
|
410 |
+ this.request.abort() |
|
411 |
+ } |
|
412 |
+ |
|
413 |
+ , retry: function () { |
|
414 |
+ init.call(this, this.o, this.fn) |
|
415 |
+ } |
|
416 |
+ |
|
417 |
+ /** |
|
418 |
+ * Small deviation from the Promises A CommonJs specification |
|
419 |
+ * http://wiki.commonjs.org/wiki/Promises/A |
|
420 |
+ */ |
|
421 |
+ |
|
422 |
+ /** |
|
423 |
+ * `then` will execute upon successful requests |
|
424 |
+ */ |
|
425 |
+ , then: function (success, fail) { |
|
426 |
+ if (this._fulfilled) { |
|
427 |
+ success(this._responseArgs.resp) |
|
428 |
+ } else if (this._erred) { |
|
429 |
+ fail(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) |
|
430 |
+ } else { |
|
431 |
+ this._fulfillmentHandlers.push(success) |
|
432 |
+ this._errorHandlers.push(fail) |
|
433 |
+ } |
|
434 |
+ return this |
|
435 |
+ } |
|
436 |
+ |
|
437 |
+ /** |
|
438 |
+ * `always` will execute whether the request succeeds or fails |
|
439 |
+ */ |
|
440 |
+ , always: function (fn) { |
|
441 |
+ if (this._fulfilled || this._erred) { |
|
442 |
+ fn(this._responseArgs.resp) |
|
443 |
+ } else { |
|
444 |
+ this._completeHandlers.push(fn) |
|
445 |
+ } |
|
446 |
+ return this |
|
447 |
+ } |
|
448 |
+ |
|
449 |
+ /** |
|
450 |
+ * `fail` will execute when the request fails |
|
451 |
+ */ |
|
452 |
+ , fail: function (fn) { |
|
453 |
+ if (this._erred) { |
|
454 |
+ fn(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) |
|
455 |
+ } else { |
|
456 |
+ this._errorHandlers.push(fn) |
|
457 |
+ } |
|
458 |
+ return this |
|
459 |
+ } |
|
357 | 460 |
} |
358 |
- }; |
|
359 |
- |
|
360 |
- if (context[attachEvent]) { |
|
361 |
- add(context, 'unload', function () { |
|
362 |
- for (var k in collected) { |
|
363 |
- collected.hasOwnProperty(k) && clean(collected[k]); |
|
461 |
+ |
|
462 |
+ function reqwest(o, fn) { |
|
463 |
+ return new Reqwest(o, fn) |
|
464 |
+ } |
|
465 |
+ |
|
466 |
+ // normalize newline variants according to spec -> CRLF |
|
467 |
+ function normalize(s) { |
|
468 |
+ return s ? s.replace(/\r?\n/g, '\r\n') : '' |
|
469 |
+ } |
|
470 |
+ |
|
471 |
+ function serial(el, cb) { |
|
472 |
+ var n = el.name |
|
473 |
+ , t = el.tagName.toLowerCase() |
|
474 |
+ , optCb = function (o) { |
|
475 |
+ // IE gives value="" even where there is no value attribute |
|
476 |
+ // 'specified' ref: http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-862529273 |
|
477 |
+ if (o && !o.disabled) |
|
478 |
+ cb(n, normalize(o.attributes.value && o.attributes.value.specified ? o.value : o.text)) |
|
479 |
+ } |
|
480 |
+ |
|
481 |
+ // don't serialize elements that are disabled or without a name |
|
482 |
+ if (el.disabled || !n) return; |
|
483 |
+ |
|
484 |
+ switch (t) { |
|
485 |
+ case 'input': |
|
486 |
+ if (!/reset|button|image|file/i.test(el.type)) { |
|
487 |
+ var ch = /checkbox/i.test(el.type) |
|
488 |
+ , ra = /radio/i.test(el.type) |
|
489 |
+ , val = el.value; |
|
490 |
+ // WebKit gives us "" instead of "on" if a checkbox has no value, so correct it here |
|
491 |
+ (!(ch || ra) || el.checked) && cb(n, normalize(ch && val === '' ? 'on' : val)) |
|
492 |
+ } |
|
493 |
+ break; |
|
494 |
+ case 'textarea': |
|
495 |
+ cb(n, normalize(el.value)) |
|
496 |
+ break; |
|
497 |
+ case 'select': |
|
498 |
+ if (el.type.toLowerCase() === 'select-one') { |
|
499 |
+ optCb(el.selectedIndex >= 0 ? el.options[el.selectedIndex] : null) |
|
500 |
+ } else { |
|
501 |
+ for (var i = 0; el.length && i < el.length; i++) { |
|
502 |
+ el.options[i].selected && optCb(el.options[i]) |
|
503 |
+ } |
|
504 |
+ } |
|
505 |
+ break; |
|
364 | 506 |
} |
365 |
- context.CollectGarbage && CollectGarbage(); |
|
366 |
- }); |
|
367 |
- } |
|
368 |
- |
|
369 |
- var oldBean = context.bean; |
|
370 |
- bean.noConflict = function () { |
|
371 |
- context.bean = oldBean; |
|
372 |
- return this; |
|
373 |
- }; |
|
374 |
- |
|
375 |
- (typeof module !== 'undefined' && module.exports) ? |
|
376 |
- (module.exports = bean) : |
|
377 |
- (context['bean'] = bean); |
|
378 |
- |
|
379 |
-}(this);!function ($) { |
|
380 |
- var b = bean.noConflict(), |
|
381 |
- integrate = function (method, type, method2) { |
|
382 |
- var _args = type ? [type] : []; |
|
383 |
- return function () { |
|
384 |
- for (var args, i = 0, l = this.length; i < l; i++) { |
|
385 |
- args = [this[i]].concat(_args, Array.prototype.slice.call(arguments, 0)); |
|
386 |
- args.length == 4 && args.push($); |
|
387 |
- !arguments.length && method == 'add' && type && (method = 'fire'); |
|
388 |
- b[method].apply(this, args); |
|
507 |
+ } |
|
508 |
+ |
|
509 |
+ // collect up all form elements found from the passed argument elements all |
|
510 |
+ // the way down to child elements; pass a '<form>' or form fields. |
|
511 |
+ // called with 'this'=callback to use for serial() on each element |
|
512 |
+ function eachFormElement() { |
|
513 |
+ var cb = this |
|
514 |
+ , e, i, j |
|
515 |
+ , serializeSubtags = function (e, tags) { |
|
516 |
+ for (var i = 0; i < tags.length; i++) { |
|
517 |
+ var fa = e[byTag](tags[i]) |
|
518 |
+ for (j = 0; j < fa.length; j++) serial(fa[j], cb) |
|
389 | 519 |
} |
390 |
- return this; |
|
391 |
- }; |
|
392 |
- }; |
|
393 |
- |
|
394 |
- var add = integrate('add'), |
|
395 |
- remove = integrate('remove'), |
|
396 |
- fire = integrate('fire'); |
|
397 |
- |
|
398 |
- var methods = { |
|
399 |
- |
|
400 |
- on: add, |
|
401 |
- addListener: add, |
|
402 |
- bind: add, |
|
403 |
- listen: add, |
|
404 |
- delegate: add, |
|
405 |
- |
|
406 |
- unbind: remove, |
|
407 |
- unlisten: remove, |
|
408 |
- removeListener: remove, |
|
409 |
- undelegate: remove, |
|
410 |
- |
|
411 |
- emit: fire, |
|
412 |
- trigger: fire, |
|
413 |
- |
|
414 |
- cloneEvents: integrate('clone'), |
|
415 |
- |
|
416 |
- hover: function (enter, leave) { |
|
417 |
- for (var i = 0, l = this.length; i < l; i++) { |
|
418 |
- b.add.call(this, this[i], 'mouseenter', enter); |
|
419 |
- b.add.call(this, this[i], 'mouseleave', leave); |
|
520 |
+ } |
|
521 |
+ |
|
522 |
+ for (i = 0; i < arguments.length; i++) { |
|
523 |
+ e = arguments[i] |
|
524 |
+ if (/input|select|textarea/i.test(e.tagName)) serial(e, cb) |
|
525 |
+ serializeSubtags(e, [ 'input', 'select', 'textarea' ]) |
|
420 | 526 |
} |
421 |
- return this; |
|
422 | 527 |
} |
423 |
- }; |
|
424 |
- |
|
425 |
- var shortcuts = [ |
|
426 |
- 'blur', 'change', 'click', 'dblclick', 'error', 'focus', 'focusin', |
|
427 |
- 'focusout', 'keydown', 'keypress', 'keyup', 'load', 'mousedown', |
|
428 |
- 'mouseenter', 'mouseleave', 'mouseout', 'mouseover', 'mouseup', |
|
429 |
- 'resize', 'scroll', 'select', 'submit', 'unload' |
|
430 |
- ]; |
|
431 |
- |
|
432 |
- for (var i = shortcuts.length; i--;) { |
|
433 |
- var shortcut = shortcuts[i]; |
|
434 |
- methods[shortcut] = integrate('add', shortcut); |
|
435 |
- } |
|
436 |
- |
|
437 |
- $.ender(methods, true); |
|
438 |
-}(ender); |
|
439 |
-/*! |
|
440 |
- * bonzo.js - copyright @dedfat 2011 |
|
441 |
- * https://github.com/ded/bonzo |
|
442 |
- * Follow our software http://twitter.com/dedfat |
|
443 |
- * MIT License |
|
444 |
- */ |
|
445 |
-!function (context) { |
|
446 |
- |
|
447 |
- var doc = context.document, |
|
448 |
- html = doc.documentElement, |
|
449 |
- query = null, |
|
450 |
- byTag = 'getElementsByTagName', |
|
451 |
- specialAttributes = /^checked|value|selected$/, |
|
452 |
- specialTags = /select|map|fieldset|table|tbody|tr|colgroup/i, |
|
453 |
- tagMap = { select: 'option', table: 'tbody', tr: 'td' }, |
|
454 |
- stateAttributes = /^checked|selected$/, |
|
455 |
- ie = /msie/i.test(navigator.userAgent), |
|
456 |
- uidList = [], |
|
457 |
- uuids = 0, |
|
458 |
- digit = /^-?[\d\.]+$/, |
|
459 |
- px = 'px', |
|
460 |
- // commonly used methods |
|
461 |
- setAttribute = 'setAttribute', |
|
462 |
- getAttribute = 'getAttribute', |
|
463 |
- trimReplace = /(^\s*|\s*$)/g, |
|
464 |
- unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1 }; |
|
465 |
- |
|
466 |
- function classReg(c) { |
|
467 |
- return new RegExp("(^|\\s+)" + c + "(\\s+|$)"); |
|
468 |
- } |
|
469 |
- |
|
470 |
- function each(ar, fn, scope) { |
|
471 |
- for (var i = 0, l = ar.length; i < l; i++) { |
|
472 |
- fn.call(scope || ar[i], ar[i], i, ar); |
|
528 |
+ |
|
529 |
+ // standard query string style serialization |
|
530 |
+ function serializeQueryString() { |
|
531 |
+ return reqwest.toQueryString(reqwest.serializeArray.apply(null, arguments)) |
|
473 | 532 |
} |
474 |
- return ar; |
|
475 |
- } |
|
476 |
- |
|
477 |
- var trim = String.prototype.trim ? |
|
478 |
- function (s) { |
|
479 |
- return s.trim(); |
|
480 |
- } : |
|
481 |
- function (s) { |
|
482 |
- return s.replace(trimReplace, ''); |
|
483 |
- }; |
|
484 |
- |
|
485 |
- function camelize(s) { |
|
486 |
- return s.replace(/-(.)/g, function (m, m1) { |
|
487 |
- return m1.toUpperCase(); |
|
488 |
- }); |
|
489 |
- } |
|
490 |
- |
|
491 |
- function is(node) { |
|
492 |
- return node && node.nodeName && node.nodeType == 1; |
|
493 |
- } |
|
494 |
- |
|
495 |
- function some(ar, fn, scope) { |
|
496 |
- for (var i = 0, j = ar.length; i < j; ++i) { |
|
497 |
- if (fn.call(scope, ar[i], i, ar)) { |
|
498 |
- return true; |
|
499 |
- } |
|
533 |
+ |
|
534 |
+ // { 'name': 'value', ... } style serialization |
|
535 |
+ function serializeHash() { |
|
536 |
+ var hash = {} |
|
537 |
+ eachFormElement.apply(function (name, value) { |
|
538 |
+ if (name in hash) { |
|
539 |
+ hash[name] && !isArray(hash[name]) && (hash[name] = [hash[name]]) |
|
540 |
+ hash[name].push(value) |
|
541 |
+ } else hash[name] = value |
|
542 |
+ }, arguments) |
|
543 |
+ return hash |
|
500 | 544 |
} |
501 |
- return false; |
|
502 |
- } |
|
503 |
- |
|
504 |
- var getStyle = doc.defaultView && doc.defaultView.getComputedStyle ? |
|
505 |
- function (el, property) { |
|
506 |
- var value = null; |
|
507 |
- if (property == 'float') { |
|
508 |
- property = 'cssFloat'; |
|
509 |
- } |
|
510 |
- var computed = doc.defaultView.getComputedStyle(el, ''); |
|
511 |
- computed && (value = computed[camelize(property)]); |
|
512 |
- return el.style[property] || value; |
|
513 |
- |
|
514 |
- } : (ie && html.currentStyle) ? |
|
515 |
- |
|
516 |
- function (el, property) { |
|
517 |
- property = camelize(property); |
|
518 |
- property = property == 'float' ? 'styleFloat' : property; |
|
519 |
- |
|
520 |
- if (property == 'opacity') { |
|
521 |
- var val = 100; |
|
522 |
- try { |
|
523 |
- val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity; |
|
524 |
- } catch (e1) { |
|
525 |
- try { |
|
526 |
- val = el.filters('alpha').opacity; |
|
527 |
- } catch (e2) {} |
|
545 |
+ |
|
546 |
+ // [ { name: 'name', value: 'value' }, ... ] style serialization |
|
547 |
+ reqwest.serializeArray = function () { |
|
548 |
+ var arr = [] |
|
549 |
+ eachFormElement.apply(function (name, value) { |
|
550 |
+ arr.push({name: name, value: value}) |
|
551 |
+ }, arguments) |
|
552 |
+ return arr |
|
553 |
+ } |
|
554 |
+ |
|
555 |
+ reqwest.serialize = function () { |
|
556 |
+ if (arguments.length === 0) return '' |
|
557 |
+ var opt, fn |
|
558 |
+ , args = Array.prototype.slice.call(arguments, 0) |
|
559 |
+ |
|
560 |
+ opt = args.pop() |
|
561 |
+ opt && opt.nodeType && args.push(opt) && (opt = null) |
|
562 |
+ opt && (opt = opt.type) |
|
563 |
+ |
|
564 |
+ if (opt == 'map') fn = serializeHash |
|
565 |
+ else if (opt == 'array') fn = reqwest.serializeArray |
|
566 |
+ else fn = serializeQueryString |
|
567 |
+ |
|
568 |
+ return fn.apply(null, args) |
|
569 |
+ } |
|
570 |
+ |
|
571 |
+ reqwest.toQueryString = function (o) { |
|
572 |
+ var qs = '', i |
|
573 |
+ , enc = encodeURIComponent |
|
574 |
+ , push = function (k, v) { |
|
575 |
+ qs += enc(k) + '=' + enc(v) + '&' |
|
576 |
+ } |
|
577 |
+ |
|
578 |
+ if (isArray(o)) { |
|
579 |
+ for (i = 0; o && i < o.length; i++) push(o[i].name, o[i].value) |
|
580 |
+ } else { |
|
581 |
+ for (var k in o) { |
|
582 |
+ if (!Object.hasOwnProperty.call(o, k)) continue; |
|
583 |
+ var v = o[k] |
|
584 |
+ if (isArray(v)) { |
|
585 |
+ for (i = 0; i < v.length; i++) push(k, v[i]) |
|
586 |
+ } else push(k, o[k]) |
|
528 | 587 |
} |
529 |
- return val / 100; |
|
530 | 588 |
} |
531 |
- var value = el.currentStyle ? el.currentStyle[property] : null; |
|
532 |
- return el.style[property] || value; |
|
533 |
- } : |
|
534 |
- |
|
535 |
- function (el, property) { |
|
536 |
- return el.style[camelize(property)]; |
|
537 |
- }; |
|
538 |
- |
|
539 |
- function insert(target, host, fn) { |
|
540 |
- var i = 0, self = host || this, r = []; |
|
541 |
- each(normalize(query ? query(target) : target), function (t) { |
|
542 |
- each(self, function (el) { |
|
543 |
- var n = el.cloneNode(true); |
|
544 |
- fn(t, n); |
|
545 |
- r[i] = n; |
|
546 |
- i++; |
|
547 |
- }); |
|
548 |
- }, this); |
|
549 |
- each(r, function (e, i) { |
|
550 |
- self[i] = e; |
|
551 |
- }); |
|
552 |
- self.length = i; |
|
553 |
- return self; |
|
554 |
- } |
|
555 |
- |
|
556 |
- function xy(el, x, y) { |
|
557 |
- var $el = bonzo(el), |
|
558 |
- style = $el.css('position'), |
|
559 |
- offset = $el.offset(), |
|
560 |
- rel = 'relative', |
|
561 |
- isRel = style == rel, |
|
562 |
- delta = [parseInt($el.css('left'), 10), parseInt($el.css('top'), 10)]; |
|
563 |
- |
|
564 |
- if (style == 'static') { |
|
565 |
- $el.css('position', rel); |
|
566 |
- style = rel; |
|
589 |
+ |
|
590 |
+ // spaces should be + according to spec |
|
591 |
+ return qs.replace(/&$/, '').replace(/%20/g, '+') |
|
567 | 592 |
} |
568 |
- |
|
569 |
- isNaN(delta[0]) && (delta[0] = isRel ? 0 : el.offsetLeft); |
|
570 |
- isNaN(delta[1]) && (delta[1] = isRel ? 0 : el.offsetTop); |
|
571 |
- |
|
572 |
- x !== null && (el.style.left = x - offset.left + delta[0] + 'px'); |
|
573 |
- y !== null && (el.style.top = y - offset.top + delta[1] + 'px'); |
|
574 |
- |
|
575 |
- } |
|
576 |
- |
|
577 |
- function Bonzo(elements) { |
|
578 |
- this.length = 0; |
|
579 |
- this.original = elements; |
|
580 |
- if (elements) { |
|
581 |
- elements = typeof elements !== 'string' && |
|
582 |
- !elements.nodeType && |
|
583 |
- typeof elements.length !== 'undefined' ? |
|
584 |
- elements : |
|
585 |
- [elements]; |
|
586 |
- this.length = elements.length; |
|
587 |
- for (var i = 0; i < elements.length; i++) { |
|
588 |
- this[i] = elements[i]; |
|
593 |
+ |
|
594 |
+ reqwest.getcallbackPrefix = function (reqId) { |
|
595 |
+ return callbackPrefix |
|
596 |
+ } |
|
597 |
+ |
|
598 |
+ // jQuery and Zepto compatibility, differences can be remapped here so you can call |
|
599 |
+ // .ajax.compat(options, callback) |
|
600 |
+ reqwest.compat = function (o, fn) { |
|
601 |
+ if (o) { |
|
602 |
+ o.type && (o.method = o.type) && delete o.type |
|
603 |
+ o.dataType && (o.type = o.dataType) |
|
604 |
+ o.jsonpCallback && (o.jsonpCallbackName = o.jsonpCallback) && delete o.jsonpCallback |
|
605 |
+ o.jsonp && (o.jsonpCallback = o.jsonp) |
|
589 | 606 |
} |
607 |
+ return new Reqwest(o, fn) |
|
590 | 608 |
} |
591 |
- } |
|
592 |
- |
|
593 |
- Bonzo.prototype = { |
|
594 |
- |
|
595 |
- each: function (fn, scope) { |
|
596 |
- return each(this, fn, scope); |
|
597 |
- }, |
|
598 |
- |
|
599 |
- map: function (fn, reject) { |
|
600 |
- var m = [], n, i; |
|
601 |
- for (i = 0; i < this.length; i++) { |
|
602 |
- n = fn.call(this, this[i]); |
|
603 |
- reject ? (reject(n) && m.push(n)) : m.push(n); |
|
604 |
- } |
|
605 |
- return m; |
|
606 |
- }, |
|
607 |
- |
|
608 |
- first: function () { |
|
609 |
- return bonzo(this[0]); |
|
610 |
- }, |
|
611 |
- |
|
612 |
- last: function () { |
|
613 |
- return bonzo(this[this.length - 1]); |
|
614 |
- }, |
|
615 |
- |
|
616 |
- html: function (h, text) { |
|
617 |
- var method = text ? |
|
618 |
- html.textContent == null ? |
|
619 |
- 'innerText' : |
|
620 |
- 'textContent' : |
|
621 |
- 'innerHTML', m; |
|
622 |
- function append(el, tag) { |
|
623 |
- while (el.firstChild) { |
|
624 |
- el.removeChild(el.firstChild); |
|
625 |
- } |
|
626 |
- each(normalize(h, tag), function (node) { |
|
627 |
- el.appendChild(node); |
|
628 |
- }); |
|
629 |
- } |
|
630 |
- return typeof h !== 'undefined' ? |
|
631 |
- this.each(function (el) { |
|
632 |
- (m = el.tagName.match(specialTags)) ? |
|
633 |
- append(el, m[0]) : |
|
634 |
- (el[method] = h); |
|
635 |
- }) : |
|
636 |
- this[0] ? this[0][method] : ''; |
|
637 |
- }, |
|
638 |
- |
|
639 |
- text: function (text) { |
|
640 |
- return this.html(text, 1); |
|
641 |
- }, |
|
642 |
- |
|
643 |
- addClass: function (c) { |
|
644 |
- return this.each(function (el) { |
|
645 |
- this.hasClass(el, c) || (el.className = trim(el.className + ' ' + c)); |
|
646 |
- }, this); |
|
647 |
- }, |
|
648 |
- |
|
649 |
- removeClass: function (c) { |
|
650 |
- return this.each(function (el) { |
|
651 |
- this.hasClass(el, c) && (el.className = trim(el.className.replace(classReg(c), ' '))); |
|
652 |
- }, this); |
|
653 |
- }, |
|
654 |
- |
|
655 |
- hasClass: function (el, c) { |
|
656 |
- return typeof c == 'undefined' ? |
|
657 |
- some(this, function (i) { |
|
658 |
- return classReg(el).test(i.className); |
|
659 |
- }) : |
|
660 |
- classReg(c).test(el.className); |
|
661 |
- }, |
|
662 |
- |
|
663 |
- toggleClass: function (c, condition) { |
|
664 |
- if (typeof condition !== 'undefined' && !condition) { |
|
665 |
- return this; |
|
666 |
- } |
|
667 |
- return this.each(function (el) { |
|
668 |
- this.hasClass(el, c) ? |
|
669 |
- (el.className = trim(el.className.replace(classReg(c), ' '))) : |
|
670 |
- (el.className = trim(el.className + ' ' + c)); |
|
671 |
- }, this); |
|
672 |
- }, |
|
673 |
- |
|
674 |
- show: function (type) { |
|
675 |
- return this.each(function (el) { |
|
676 |
- el.style.display = type || ''; |
|
677 |
- }); |
|
678 |
- }, |
|
679 |
- |
|
680 |
- hide: function (elements) { |
|
681 |
- return this.each(function (el) { |
|
682 |
- el.style.display = 'none'; |
|
683 |
- }); |
|
684 |
- }, |
|
685 |
- |
|
686 |
- append: function (node) { |
|
687 |
- return this.each(function (el) { |
|
688 |
- each(normalize(node), function (i) { |
|
689 |
- el.appendChild(i); |
|
690 |
- }); |
|
691 |
- }); |
|
692 |
- }, |
|
693 |
- |
|
694 |
- prepend: function (node) { |
|
695 |
- return this.each(function (el) { |
|
696 |
- var first = el.firstChild; |
|
697 |
- each(normalize(node), function (i) { |
|
698 |
- el.insertBefore(i, first); |
|
699 |
- }); |
|
700 |
- }); |
|
701 |
- }, |
|
702 |
- |
|
703 |
- appendTo: function (target, host) { |
|
704 |
- return insert.call(this, target, host, function (t, el) { |
|
705 |
- t.appendChild(el); |
|
706 |
- }); |
|
707 |
- }, |
|
708 |
- |
|
709 |
- prependTo: function (target, host) { |
|
710 |
- return insert.call(this, target, host, function (t, el) { |
|
711 |
- t.insertBefore(el, t.firstChild); |
|
712 |
- }); |
|
713 |
- }, |
|
714 |
- |
|
715 |
- next: function () { |
|
716 |
- return this.related('nextSibling'); |
|
717 |
- }, |
|
718 |
- |
|
719 |
- previous: function () { |
|
720 |
- return this.related('previousSibling'); |
|
721 |
- }, |
|
722 |
- |
|
723 |
- related: function (method) { |
|
724 |
- return this.map( |
|
725 |
- function (el) { |
|
726 |
- el = el[method]; |
|
727 |
- while (el && el.nodeType !== 1) { |
|
728 |
- el = el[method]; |
|
609 |
+ |
|
610 |
+ return reqwest |
|
611 |
+ }); |
|
612 |
+ |
|
613 |
+ |
|
614 |
+ provide("reqwest", module.exports); |
|
615 |
+ |
|
616 |
+ !function ($) { |
|
617 |
+ var r = require('reqwest') |
|
618 |
+ , integrate = function(method) { |
|
619 |
+ return function() { |
|
620 |
+ var args = Array.prototype.slice.call(arguments, 0) |
|
621 |
+ , i = (this && this.length) || 0 |
|
622 |
+ while (i--) args.unshift(this[i]) |
|
623 |
+ return r[method].apply(null, args) |
|
729 | 624 |
} |
730 |
- return el || 0; |
|
731 |
- }, |
|
732 |
- function (el) { |
|
733 |
- return el; |
|
734 | 625 |
} |
735 |
- ); |
|
736 |
- }, |
|
737 |
- |
|
738 |
- before: function (node) { |
|
739 |
- return this.each(function (el) { |
|
740 |
- each(bonzo.create(node), function (i) { |
|
741 |
- el.parentNode.insertBefore(i, el); |
|
742 |
- }); |
|
743 |
- }); |
|
744 |
- }, |
|
745 |
- |
|
746 |
- after: function (node) { |
|
747 |
- return this.each(function (el) { |
|
748 |
- each(bonzo.create(node), function (i) { |
|
749 |
- el.parentNode.insertBefore(i, el.nextSibling); |
|
750 |
- }); |
|
751 |
- }); |
|
752 |
- }, |
|
753 |
- |
|
754 |
- insertBefore: function (target, host) { |
|
755 |
- return insert.call(this, target, host, function (t, el) { |
|
756 |
- t.parentNode.insertBefore(el, t); |
|
757 |
- }); |
|
758 |
- }, |
|
759 |
- |
|
760 |
- insertAfter: function (target, host) { |
|
761 |
- return insert.call(this, target, host, function (t, el) { |
|
762 |
- var sibling = t.nextSibling; |
|
763 |
- if (sibling) { |
|
764 |
- t.parentNode.insertBefore(el, sibling); |
|
626 |
+ , s = integrate('serialize') |
|
627 |
+ , sa = integrate('serializeArray') |
|
628 |
+ |
|
629 |
+ $.ender({ |
|
630 |
+ ajax: r |
|
631 |
+ , serialize: r.serialize |
|
632 |
+ , serializeArray: r.serializeArray |
|
633 |
+ , toQueryString: r.toQueryString |
|
634 |
+ }) |
|
635 |
+ |
|
636 |
+ $.ender({ |
|
637 |
+ serialize: s |
|
638 |
+ , serializeArray: sa |
|
639 |
+ }, true) |
|
640 |
+ }(ender); |
|
641 |
+ |
|
642 |
+ |
|
643 |
+}()); |
|
644 |
+ |
|
645 |
+(function () { |
|
646 |
+ |
|
647 |
+ var module = { exports: {} }, exports = module.exports; |
|
648 |
+ |
|
649 |
+ /*! |
|
650 |
+ * Bean - copyright (c) Jacob Thornton 2011-2012 |
|
651 |
+ * https://github.com/fat/bean |
|
652 |
+ * MIT license |
|
653 |
+ */ |
|
654 |
+ !(function (name, context, definition) { |
|
655 |
+ if (typeof module != 'undefined' && module.exports) module.exports = definition(name, context); |
|
656 |
+ else if (typeof define == 'function' && typeof define.amd == 'object') define(definition); |
|
657 |
+ else context[name] = definition(name, context); |
|
658 |
+ }('bean', this, function (name, context) { |
|
659 |
+ var win = window |
|
660 |
+ , old = context[name] |
|
661 |
+ , namespaceRegex = /[^\.]*(?=\..*)\.|.*/ |
|
662 |
+ , nameRegex = /\..*/ |
|
663 |
+ , addEvent = 'addEventListener' |
|
664 |
+ , removeEvent = 'removeEventListener' |
|
665 |
+ , doc = document || {} |
|
666 |
+ , root = doc.documentElement || {} |
|
667 |
+ , W3C_MODEL = root[addEvent] |
|
668 |
+ , eventSupport = W3C_MODEL ? addEvent : 'attachEvent' |
|
669 |
+ , ONE = {} // singleton for quick matching making add() do one() |
|
670 |
+ |
|
671 |
+ , slice = Array.prototype.slice |
|
672 |
+ , str2arr = function (s, d) { return s.split(d || ' ') } |
|
673 |
+ , isString = function (o) { return typeof o == 'string' } |
|
674 |
+ , isFunction = function (o) { return typeof o == 'function' } |
|
675 |
+ |
|
676 |
+ // events that we consider to be 'native', anything not in this list will |
|
677 |
+ // be treated as a custom event |
|
678 |
+ , standardNativeEvents = |
|
679 |
+ 'click dblclick mouseup mousedown contextmenu ' + // mouse buttons |
|
680 |
+ 'mousewheel mousemultiwheel DOMMouseScroll ' + // mouse wheel |
|
681 |
+ 'mouseover mouseout mousemove selectstart selectend ' + // mouse movement |
|
682 |
+ 'keydown keypress keyup ' + // keyboard |
|
683 |
+ 'orientationchange ' + // mobile |
|
684 |
+ 'focus blur change reset select submit ' + // form elements |
|
685 |
+ 'load unload beforeunload resize move DOMContentLoaded ' + // window |
|
686 |
+ 'readystatechange message ' + // window |
|
687 |
+ 'error abort scroll ' // misc |
|
688 |
+ // element.fireEvent('onXYZ'... is not forgiving if we try to fire an event |
|
689 |
+ // that doesn't actually exist, so make sure we only do these on newer browsers |
|
690 |
+ , w3cNativeEvents = |
|
691 |
+ 'show ' + // mouse buttons |
|
692 |
+ 'input invalid ' + // form elements |
|
693 |
+ 'touchstart touchmove touchend touchcancel ' + // touch |
|
694 |
+ 'gesturestart gesturechange gestureend ' + // gesture |
|
695 |
+ 'textinput' + // TextEvent |
|
696 |
+ 'readystatechange pageshow pagehide popstate ' + // window |
|
697 |
+ 'hashchange offline online ' + // window |
|
698 |
+ 'afterprint beforeprint ' + // printing |
|
699 |
+ 'dragstart dragenter dragover dragleave drag drop dragend ' + // dnd |
|
700 |
+ 'loadstart progress suspend emptied stalled loadmetadata ' + // media |
|
701 |
+ 'loadeddata canplay canplaythrough playing waiting seeking ' + // media |
|
702 |
+ 'seeked ended durationchange timeupdate play pause ratechange ' + // media |
|
703 |
+ 'volumechange cuechange ' + // media |
|
704 |
+ 'checking noupdate downloading cached updateready obsolete ' // appcache |
|
705 |
+ |
|
706 |
+ // convert to a hash for quick lookups |
|
707 |
+ , nativeEvents = (function (hash, events, i) { |
|
708 |
+ for (i = 0; i < events.length; i++) events[i] && (hash[events[i]] = 1) |
|
709 |
+ return hash |
|
710 |
+ }({}, str2arr(standardNativeEvents + (W3C_MODEL ? w3cNativeEvents : '')))) |
|
711 |
+ |
|
712 |
+ // custom events are events that we *fake*, they are not provided natively but |
|
713 |
+ // we can use native events to generate them |
|
714 |
+ , customEvents = (function () { |
|
715 |
+ var isAncestor = 'compareDocumentPosition' in root |
|
716 |
+ ? function (element, container) { |
|
717 |
+ return container.compareDocumentPosition && (container.compareDocumentPosition(element) & 16) === 16 |
|
718 |
+ } |
|
719 |
+ : 'contains' in root |
|
720 |
+ ? function (element, container) { |
|
721 |
+ container = container.nodeType === 9 || container === window ? root : container |
|
722 |
+ return container !== element && container.contains(element) |
|
723 |
+ } |
|
724 |
+ : function (element, container) { |
|
725 |
+ while (element = element.parentNode) if (element === container) return 1 |
|
726 |
+ return 0 |
|
727 |
+ } |
|
728 |
+ , check = function (event) { |
|
729 |
+ var related = event.relatedTarget |
|
730 |
+ return !related |
|
731 |
+ ? related == null |
|
732 |
+ : (related !== this && related.prefix !== 'xul' && !/document/.test(this.toString()) |
|
733 |
+ && !isAncestor(related, this)) |
|
734 |
+ } |
|
735 |
+ |
|
736 |
+ return { |
|
737 |
+ mouseenter: { base: 'mouseover', condition: check } |
|
738 |
+ , mouseleave: { base: 'mouseout', condition: check } |
|
739 |
+ , mousewheel: { base: /Firefox/.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel' } |
|
740 |
+ } |
|
741 |
+ }()) |
|
742 |
+ |
|
743 |
+ // we provide a consistent Event object across browsers by taking the actual DOM |
|
744 |
+ // event object and generating a new one from its properties. |
|
745 |
+ , Event = (function () { |
|
746 |
+ // a whitelist of properties (for different event types) tells us what to check for and copy |
|
747 |
+ var commonProps = str2arr('altKey attrChange attrName bubbles cancelable ctrlKey currentTarget ' + |
|
748 |
+ 'detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey ' + |
|
749 |
+ 'srcElement target timeStamp type view which propertyName') |
|
750 |
+ , mouseProps = commonProps.concat(str2arr('button buttons clientX clientY dataTransfer ' + |
|
751 |
+ 'fromElement offsetX offsetY pageX pageY screenX screenY toElement')) |
|
752 |
+ , mouseWheelProps = mouseProps.concat(str2arr('wheelDelta wheelDeltaX wheelDeltaY wheelDeltaZ ' + |
|
753 |
+ 'axis')) // 'axis' is FF specific |
|
754 |
+ , keyProps = commonProps.concat(str2arr('char charCode key keyCode keyIdentifier ' + |
|
755 |
+ 'keyLocation location')) |
|
756 |
+ , textProps = commonProps.concat(str2arr('data')) |
|
757 |
+ , touchProps = commonProps.concat(str2arr('touches targetTouches changedTouches scale rotation')) |
|
758 |
+ , messageProps = commonProps.concat(str2arr('data origin source')) |
|
759 |
+ , stateProps = commonProps.concat(str2arr('state')) |
|
760 |
+ , overOutRegex = /over|out/ |
|
761 |
+ // some event types need special handling and some need special properties, do that all here |
|
762 |
+ , typeFixers = [ |
|
763 |
+ { // key events |
|
764 |
+ reg: /key/i |
|
765 |
+ , fix: function (event, newEvent) { |
|
766 |
+ newEvent.keyCode = event.keyCode || event.which |
|
767 |
+ return keyProps |
|
768 |
+ } |
|
769 |
+ } |
|
770 |
+ , { // mouse events |
|
771 |
+ reg: /click|mouse(?!(.*wheel|scroll))|menu|drag|drop/i |
|
772 |
+ , fix: function (event, newEvent, type) { |
|
773 |
+ newEvent.rightClick = event.which === 3 || event.button === 2 |
|
774 |
+ newEvent.pos = { x: 0, y: 0 } |
|
775 |
+ if (event.pageX || event.pageY) { |
|
776 |
+ newEvent.clientX = event.pageX |
|
777 |
+ newEvent.clientY = event.pageY |
|
778 |
+ } else if (event.clientX || event.clientY) { |
|
779 |
+ newEvent.clientX = event.clientX + doc.body.scrollLeft + root.scrollLeft |
|
780 |
+ newEvent.clientY = event.clientY + doc.body.scrollTop + root.scrollTop |
|
781 |
+ } |
|
782 |
+ if (overOutRegex.test(type)) { |
|
783 |
+ newEvent.relatedTarget = event.relatedTarget |
|
784 |
+ || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'] |
|
785 |
+ } |
|
786 |
+ return mouseProps |
|
787 |
+ } |
|
788 |
+ } |
|
789 |
+ , { // mouse wheel events |
|
790 |
+ reg: /mouse.*(wheel|scroll)/i |
|
791 |
+ , fix: function () { return mouseWheelProps } |
|
792 |
+ } |
|
793 |
+ , { // TextEvent |
|
794 |
+ reg: /^text/i |
|
795 |
+ , fix: function () { return textProps } |
|
796 |
+ } |
|
797 |
+ , { // touch and gesture events |
|
798 |
+ reg: /^touch|^gesture/i |
|
799 |
+ , fix: function () { return touchProps } |
|
800 |
+ } |
|
801 |
+ , { // message events |
|
802 |
+ reg: /^message$/i |
|
803 |
+ , fix: function () { return messageProps } |
|
804 |
+ } |
|
805 |
+ , { // popstate events |
|
806 |
+ reg: /^popstate$/i |
|
807 |
+ , fix: function () { return stateProps } |
|
808 |
+ } |
|
809 |
+ , { // everything else |
|
810 |
+ reg: /.*/ |
|
811 |
+ , fix: function () { return commonProps } |
|
812 |
+ } |
|
813 |
+ ] |
|
814 |
+ , typeFixerMap = {} // used to map event types to fixer functions (above), a basic cache mechanism |
|
815 |
+ |
|
816 |
+ , Event = function (event, element, isNative) { |
|
817 |
+ if (!arguments.length) return |
|
818 |
+ event = event || ((element.ownerDocument || element.document || element).parentWindow || win).event |
|
819 |
+ this.originalEvent = event |
|
820 |
+ this.isNative = isNative |
|
821 |
+ this.isBean = true |
|
822 |
+ |
|
823 |
+ if (!event) return |
|
824 |
+ |
|
825 |
+ var type = event.type |
|
826 |
+ , target = event.target || event.srcElement |
|
827 |
+ , i, l, p, props, fixer |
|
828 |
+ |
|
829 |
+ this.target = target && target.nodeType === 3 ? target.parentNode : target |
|
830 |
+ |
|
831 |
+ if (isNative) { // we only need basic augmentation on custom events, the rest expensive & pointless |
|
832 |
+ fixer = typeFixerMap[type] |
|
833 |
+ if (!fixer) { // haven't encountered this event type before, map a fixer function for it |
|
834 |
+ for (i = 0, l = typeFixers.length; i < l; i++) { |
|
835 |
+ if (typeFixers[i].reg.test(type)) { // guaranteed to match at least one, last is .* |
|
836 |
+ typeFixerMap[type] = fixer = typeFixers[i].fix |
|
837 |
+ break |
|
838 |
+ } |
|
839 |
+ } |
|
840 |
+ } |
|
841 |
+ |
|
842 |
+ props = fixer(event, this, type) |
|
843 |
+ for (i = props.length; i--;) { |
|
844 |
+ if (!((p = props[i]) in this) && p in event) this[p] = event[p] |
|
845 |
+ } |
|
846 |
+ } |
|
847 |
+ } |
|
848 |
+ |
|
849 |
+ // preventDefault() and stopPropagation() are a consistent interface to those functions |
|
850 |
+ // on the DOM, stop() is an alias for both of them together |
|
851 |
+ Event.prototype.preventDefault = function () { |
|
852 |
+ if (this.originalEvent.preventDefault) this.originalEvent.preventDefault() |
|
853 |
+ else this.originalEvent.returnValue = false |
|
854 |
+ } |
|
855 |
+ Event.prototype.stopPropagation = function () { |
|
856 |
+ if (this.originalEvent.stopPropagation) this.originalEvent.stopPropagation() |
|
857 |
+ else this.originalEvent.cancelBubble = true |
|
858 |
+ } |
|
859 |
+ Event.prototype.stop = function () { |
|
860 |
+ this.preventDefault() |
|
861 |
+ this.stopPropagation() |
|
862 |
+ this.stopped = true |
|
863 |
+ } |
|
864 |
+ // stopImmediatePropagation() has to be handled internally because we manage the event list for |
|
865 |
+ // each element |
|
866 |
+ // note that originalElement may be a Bean#Event object in some situations |
|
867 |
+ Event.prototype.stopImmediatePropagation = function () { |
|
868 |
+ if (this.originalEvent.stopImmediatePropagation) this.originalEvent.stopImmediatePropagation() |
|
869 |
+ this.isImmediatePropagationStopped = function () { return true } |
|
870 |
+ } |
|
871 |
+ Event.prototype.isImmediatePropagationStopped = function () { |
|
872 |
+ return this.originalEvent.isImmediatePropagationStopped && this.originalEvent.isImmediatePropagationStopped() |
|
873 |
+ } |
|
874 |
+ Event.prototype.clone = function (currentTarget) { |
|
875 |
+ //TODO: this is ripe for optimisation, new events are *expensive* |
|
876 |
+ // improving this will speed up delegated events |
|
877 |
+ var ne = new Event(this, this.element, this.isNative) |
|
878 |
+ ne.currentTarget = currentTarget |
|
879 |
+ return ne |
|
880 |
+ } |
|
881 |
+ |
|
882 |
+ return Event |
|
883 |
+ }()) |
|
884 |
+ |
|
885 |
+ // if we're in old IE we can't do onpropertychange on doc or win so we use doc.documentElement for both |
|
886 |
+ , targetElement = function (element, isNative) { |
|
887 |
+ return !W3C_MODEL && !isNative && (element === doc || element === win) ? root : element |
|
765 | 888 |
} |
766 |
- else { |
|
767 |
- t.parentNode.appendChild(el); |
|
889 |
+ |
|
890 |
+ /** |
|
891 |
+ * Bean maintains an internal registry for event listeners. We don't touch elements, objects |
|
892 |
+ * or functions to identify them, instead we store everything in the registry. |
|
893 |
+ * Each event listener has a RegEntry object, we have one 'registry' for the whole instance. |
|
894 |
+ */ |
|
895 |
+ , RegEntry = (function () { |
|
896 |
+ // each handler is wrapped so we can handle delegation and custom events |
|
897 |
+ var wrappedHandler = function (element, fn, condition, args) { |
|
898 |
+ var call = function (event, eargs) { |
|
899 |
+ return fn.apply(element, args ? slice.call(eargs, event ? 0 : 1).concat(args) : eargs) |
|
900 |
+ } |
|
901 |
+ , findTarget = function (event, eventElement) { |
|
902 |
+ return fn.__beanDel ? fn.__beanDel.ft(event.target, element) : eventElement |
|
903 |
+ } |
|
904 |
+ , handler = condition |
|
905 |
+ ? function (event) { |
|
906 |
+ var target = findTarget(event, this) // deleated event |
|
907 |
+ if (condition.apply(target, arguments)) { |
|
908 |
+ if (event) event.currentTarget = target |
|
909 |
+ return call(event, arguments) |
|
910 |
+ } |
|
911 |
+ } |
|
912 |
+ : function (event) { |
|
913 |
+ if (fn.__beanDel) event = event.clone(findTarget(event)) // delegated event, fix the fix |
|
914 |
+ return call(event, arguments) |
|
915 |
+ } |
|
916 |
+ handler.__beanDel = fn.__beanDel |
|
917 |
+ return handler |
|
918 |
+ } |
|
919 |
+ |
|
920 |
+ , RegEntry = function (element, type, handler, original, namespaces, args, root) { |
|
921 |
+ var customType = customEvents[type] |
|
922 |
+ , isNative |
|
923 |
+ |
|
924 |
+ if (type == 'unload') { |
|
925 |
+ // self clean-up |
|
926 |
+ handler = once(removeListener, element, type, handler, original) |
|
927 |
+ } |
|
928 |
+ |
|
929 |
+ if (customType) { |
|
930 |
+ if (customType.condition) { |
|
931 |
+ handler = wrappedHandler(element, handler, customType.condition, args) |
|
932 |
+ } |
|
933 |
+ type = customType.base || type |
|
934 |
+ } |
|
935 |
+ |
|
936 |
+ this.isNative = isNative = nativeEvents[type] && !!element[eventSupport] |
|
937 |
+ this.customType = !W3C_MODEL && !isNative && type |
|
938 |
+ this.element = element |
|
939 |
+ this.type = type |
|
940 |
+ this.original = original |
|
941 |
+ this.namespaces = namespaces |
|
942 |
+ this.eventType = W3C_MODEL || isNative ? type : 'propertychange' |
|
943 |
+ this.target = targetElement(element, isNative) |
|
944 |
+ this[eventSupport] = !!this.target[eventSupport] |
|
945 |
+ this.root = root |
|
946 |
+ this.handler = wrappedHandler(element, handler, null, args) |
|
947 |
+ } |
|
948 |
+ |
|
949 |
+ // given a list of namespaces, is our entry in any of them? |
|
950 |
+ RegEntry.prototype.inNamespaces = function (checkNamespaces) { |
|
951 |
+ var i, j, c = 0 |
|
952 |
+ if (!checkNamespaces) return true |
|
953 |
+ if (!this.namespaces) return false |
|
954 |
+ for (i = checkNamespaces.length; i--;) { |
|
955 |
+ for (j = this.namespaces.length; j--;) { |
|
956 |
+ if (checkNamespaces[i] == this.namespaces[j]) c++ |
|
957 |
+ } |
|
958 |
+ } |
|
959 |
+ return checkNamespaces.length === c |
|
960 |
+ } |
|
961 |
+ |
|
962 |
+ // match by element, original fn (opt), handler fn (opt) |
|
963 |
+ RegEntry.prototype.matches = function (checkElement, checkOriginal, checkHandler) { |
|
964 |
+ return this.element === checkElement && |
|
965 |
+ (!checkOriginal || this.original === checkOriginal) && |
|
966 |
+ (!checkHandler || this.handler === checkHandler) |
|
967 |
+ } |
|
968 |
+ |
|
969 |
+ return RegEntry |
|
970 |
+ }()) |
|
971 |
+ |
|
972 |
+ , registry = (function () { |
|
973 |
+ // our map stores arrays by event type, just because it's better than storing |
|
974 |
+ // everything in a single array. |
|
975 |
+ // uses '$' as a prefix for the keys for safety and 'r' as a special prefix for |
|
976 |
+ // rootListeners so we can look them up fast |
|
977 |
+ var map = {} |
|
978 |
+ |
|
979 |
+ // generic functional search of our registry for matching listeners, |
|
980 |
+ // `fn` returns false to break out of the loop |
|
981 |
+ , forAll = function (element, type, original, handler, root, fn) { |
|
982 |
+ var pfx = root ? 'r' : '$' |
|
983 |
+ if (!type || type == '*') { |
|
984 |
+ // search the whole registry |
|
985 |
+ for (var t in map) { |
|
986 |
+ if (t.charAt(0) == pfx) { |
|
987 |
+ forAll(element, t.substr(1), original, handler, root, fn) |
|
988 |
+ } |
|
989 |
+ } |
|
990 |
+ } else { |
|
991 |
+ var i = 0, l, list = map[pfx + type], all = element == '*' |
|
992 |
+ if (!list) return |
|
993 |
+ for (l = list.length; i < l; i++) { |
|
994 |
+ if ((all || list[i].matches(element, original, handler)) && !fn(list[i], list, i, type)) return |
|
995 |
+ } |
|
996 |
+ } |
|
997 |
+ } |
|
998 |
+ |
|
999 |
+ , has = function (element, type, original, root) { |
|
1000 |
+ // we're not using forAll here simply because it's a bit slower and this |
|
1001 |
+ // needs to be fast |
|
1002 |
+ var i, list = map[(root ? 'r' : '$') + type] |
|
1003 |
+ if (list) { |
|
1004 |
+ for (i = list.length; i--;) { |
|
1005 |
+ if (!list[i].root && list[i].matches(element, original, null)) return true |
|
1006 |
+ } |
|
1007 |
+ } |
|
1008 |
+ return false |
|
1009 |
+ } |
|
1010 |
+ |
|
1011 |
+ , get = function (element, type, original, root) { |
|
1012 |
+ var entries = [] |
|
1013 |
+ forAll(element, type, original, null, root, function (entry) { |
|
1014 |
+ return entries.push(entry) |
|
1015 |
+ }) |
|
1016 |
+ return entries |
|
1017 |
+ } |
|
1018 |
+ |
|
1019 |
+ , put = function (entry) { |
|
1020 |
+ var has = !entry.root && !this.has(entry.element, entry.type, null, false) |
|
1021 |
+ , key = (entry.root ? 'r' : '$') + entry.type |
|
1022 |
+ ;(map[key] || (map[key] = [])).push(entry) |
|
1023 |
+ return has |
|
1024 |
+ } |
|
1025 |
+ |
|
1026 |
+ , del = function (entry) { |
|
1027 |
+ forAll(entry.element, entry.type, null, entry.handler, entry.root, function (entry, list, i) { |
|
1028 |
+ list.splice(i, 1) |
|
1029 |
+ entry.removed = true |
|
1030 |
+ if (list.length === 0) delete map[(entry.root ? 'r' : '$') + entry.type] |
|
1031 |
+ return false |
|
1032 |
+ }) |
|
1033 |
+ } |
|
1034 |
+ |
|
1035 |
+ // dump all entries, used for onunload |
|
1036 |
+ , entries = function () { |
|
1037 |
+ var t, entries = [] |
|
1038 |
+ for (t in map) { |
|
1039 |
+ if (t.charAt(0) == '$') entries = entries.concat(map[t]) |
|
1040 |
+ } |
|
1041 |
+ return entries |
|
1042 |
+ } |
|
1043 |
+ |
|
1044 |
+ return { has: has, get: get, put: put, del: del, entries: entries } |
|
1045 |
+ }()) |
|
1046 |
+ |
|
1047 |
+ // we need a selector engine for delegated events, use querySelectorAll if it exists |
|
1048 |
+ // but for older browsers we need Qwery, Sizzle or similar |
|
1049 |
+ , selectorEngine |
|
1050 |
+ , setSelectorEngine = function (e) { |
|
1051 |
+ if (!arguments.length) { |
|
1052 |
+ selectorEngine = doc.querySelectorAll |
|
1053 |
+ ? function (s, r) { |
|
1054 |
+ return r.querySelectorAll(s) |
|
1055 |
+ } |
|
1056 |
+ : function () { |
|
1057 |
+ throw new Error('Bean: No selector engine installed') // eeek |
|
1058 |
+ } |
|
1059 |
+ } else { |
|
1060 |
+ selectorEngine = e |
|
1061 |
+ } |
|
768 | 1062 |
} |
769 |
- }); |
|
770 |
- }, |
|
771 |
- |
|
772 |
- css: function (o, v) { |
|
773 |
- // is this a request for just getting a style? |
|
774 |
- if (v === undefined && typeof o == 'string') { |
|
775 |
- return getStyle(this[0], o); |
|
1063 |
+ |
|
1064 |
+ // we attach this listener to each DOM event that we need to listen to, only once |
|
1065 |
+ // per event type per DOM element |
|
1066 |
+ , rootListener = function (event, type) { |
|
1067 |
+ if (!W3C_MODEL && type && event && event.propertyName != '_on' + type) return |
|
1068 |
+ |
|
1069 |
+ var listeners = registry.get(this, type || event.type, null, false) |
|
1070 |
+ , l = listeners.length |
|
1071 |
+ , i = 0 |
|
1072 |
+ |
|
1073 |
+ event = new Event(event, this, true) |
|
1074 |
+ if (type) event.type = type |
|
1075 |
+ |
|
1076 |
+ // iterate through all handlers registered for this type, calling them unless they have |
|
1077 |
+ // been removed by a previous handler or stopImmediatePropagation() has been called |
|
1078 |
+ for (; i < l && !event.isImmediatePropagationStopped(); i++) { |
|
1079 |
+ if (!listeners[i].removed) listeners[i].handler.call(this, event) |
|
1080 |
+ } |
|
1081 |
+ } |
|
1082 |
+ |
|
1083 |
+ // add and remove listeners to DOM elements |
|
1084 |
+ , listener = W3C_MODEL |
|
1085 |
+ ? function (element, type, add) { |
|
1086 |
+ // new browsers |
|
1087 |
+ element[add ? addEvent : removeEvent](type, rootListener, false) |
|
1088 |
+ } |
|
1089 |
+ : function (element, type, add, custom) { |
|
1090 |
+ // IE8 and below, use attachEvent/detachEvent and we have to piggy-back propertychange events |
|
1091 |
+ // to simulate event bubbling etc. |
|
1092 |
+ var entry |
|
1093 |
+ if (add) { |
|
1094 |
+ registry.put(entry = new RegEntry( |
|
1095 |
+ element |
|
1096 |
+ , custom || type |
|
1097 |
+ , function (event) { // handler |
|
1098 |
+ rootListener.call(element, event, custom) |
|
1099 |
+ } |
|
1100 |
+ , rootListener |
|
1101 |
+ , null |
|
1102 |
+ , null |
|
1103 |
+ , true // is root |
|
1104 |
+ )) |
|
1105 |
+ if (custom && element['_on' + custom] == null) element['_on' + custom] = 0 |
|
1106 |
+ entry.target.attachEvent('on' + entry.eventType, entry.handler) |
|
1107 |
+ } else { |
|
1108 |
+ entry = registry.get(element, custom || type, rootListener, true)[0] |
|
1109 |
+ if (entry) { |
|
1110 |
+ entry.target.detachEvent('on' + entry.eventType, entry.handler) |
|
1111 |
+ registry.del(entry) |
|
1112 |
+ } |
|
1113 |
+ } |
|
1114 |
+ } |
|
1115 |
+ |
|
1116 |
+ , once = function (rm, element, type, fn, originalFn) { |
|
1117 |
+ // wrap the handler in a handler that does a remove as well |
|
1118 |
+ return function () { |
|
1119 |
+ fn.apply(this, arguments) |
|
1120 |
+ rm(element, type, originalFn) |
|
1121 |
+ } |
|
1122 |
+ } |
|
1123 |
+ |
|
1124 |
+ , removeListener = function (element, orgType, handler, namespaces) { |
|
1125 |
+ var type = orgType && orgType.replace(nameRegex, '') |
|
1126 |
+ , handlers = registry.get(element, type, null, false) |
|
1127 |
+ , removed = {} |
|
1128 |
+ , i, l |
|
1129 |
+ |
|
1130 |
+ for (i = 0, l = handlers.length; i < l; i++) { |
|
1131 |
+ if ((!handler || handlers[i].original === handler) && handlers[i].inNamespaces(namespaces)) { |
|
1132 |
+ // TODO: this is problematic, we have a registry.get() and registry.del() that |
|
1133 |
+ // both do registry searches so we waste cycles doing this. Needs to be rolled into |
|
1134 |
+ // a single registry.forAll(fn) that removes while finding, but the catch is that |
|
1135 |
+ // we'll be splicing the arrays that we're iterating over. Needs extra tests to |
|
1136 |
+ // make sure we don't screw it up. @rvagg |
|
1137 |
+ registry.del(handlers[i]) |
|
1138 |
+ if (!removed[handlers[i].eventType] && handlers[i][eventSupport]) |
|
1139 |
+ removed[handlers[i].eventType] = { t: handlers[i].eventType, c: handlers[i].type } |
|
1140 |
+ } |
|
1141 |
+ } |
|
1142 |
+ // check each type/element for removed listeners and remove the rootListener where it's no longer needed |
|
1143 |
+ for (i in removed) { |
|
1144 |
+ if (!registry.has(element, removed[i].t, null, false)) { |
|
1145 |
+ // last listener of this type, remove the rootListener |
|
1146 |
+ listener(element, removed[i].t, false, removed[i].c) |
|
1147 |
+ } |
|
1148 |
+ } |
|
1149 |
+ } |
|
1150 |
+ |
|
1151 |
+ // set up a delegate helper using the given selector, wrap the handler function |
|
1152 |
+ , delegate = function (selector, fn) { |
|
1153 |
+ //TODO: findTarget (therefore $) is called twice, once for match and once for |
|
1154 |
+ // setting e.currentTarget, fix this so it's only needed once |
|
1155 |
+ var findTarget = function (target, root) { |
|
1156 |
+ var i, array = isString(selector) ? selectorEngine(selector, root) : selector |
|
1157 |
+ for (; target && target !== root; target = target.parentNode) { |
|
1158 |
+ for (i = array.length; i--;) { |
|
1159 |
+ if (array[i] === target) return target |
|
1160 |
+ } |
|
1161 |
+ } |
|
1162 |
+ } |
|
1163 |
+ , handler = function (e) { |
|
1164 |
+ var match = findTarget(e.target, this) |
|
1165 |
+ if (match) fn.apply(match, arguments) |
|
1166 |
+ } |
|
1167 |
+ |
|
1168 |
+ // __beanDel isn't pleasant but it's a private function, not exposed outside of Bean |
|
1169 |
+ handler.__beanDel = { |
|
1170 |
+ ft : findTarget // attach it here for customEvents to use too |
|
1171 |
+ , selector : selector |
|
1172 |
+ } |
|
1173 |
+ return handler |
|
1174 |
+ } |
|
1175 |
+ |
|
1176 |
+ , fireListener = W3C_MODEL ? function (isNative, type, element) { |
|
1177 |
+ // modern browsers, do a proper dispatchEvent() |
|
1178 |
+ var evt = doc.createEvent(isNative ? 'HTMLEvents' : 'UIEvents') |
|
1179 |
+ evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, win, 1) |
|
1180 |
+ element.dispatchEvent(evt) |
|
1181 |
+ } : function (isNative, type, element) { |
|
1182 |
+ // old browser use onpropertychange, just increment a custom property to trigger the event |
|
1183 |
+ element = targetElement(element, isNative) |
|
1184 |
+ isNative ? element.fireEvent('on' + type, doc.createEventObject()) : element['_on' + type]++ |
|
1185 |
+ } |
|
1186 |
+ |
|
1187 |
+ /** |
|
1188 |
+ * Public API: off(), on(), add(), (remove()), one(), fire(), clone() |
|
1189 |
+ */ |
|
1190 |
+ |
|
1191 |
+ /** |
|
1192 |
+ * off(element[, eventType(s)[, handler ]]) |
|
1193 |
+ */ |
|
1194 |
+ , off = function (element, typeSpec, fn) { |
|
1195 |
+ var isTypeStr = isString(typeSpec) |
|
1196 |
+ , k, type, namespaces, i |
|
1197 |
+ |
|
1198 |
+ if (isTypeStr && typeSpec.indexOf(' ') > 0) { |
|
1199 |
+ // off(el, 't1 t2 t3', fn) or off(el, 't1 t2 t3') |
|
1200 |
+ typeSpec = str2arr(typeSpec) |
|
1201 |
+ for (i = typeSpec.length; i--;) |
|
1202 |
+ off(element, typeSpec[i], fn) |
|
1203 |
+ return element |
|
1204 |
+ } |
|
1205 |
+ |
|
1206 |
+ type = isTypeStr && typeSpec.replace(nameRegex, '') |
|
1207 |
+ if (type && customEvents[type]) type = customEvents[type].base |
|
1208 |
+ |
|
1209 |
+ if (!typeSpec || isTypeStr) { |
|
1210 |
+ // off(el) or off(el, t1.ns) or off(el, .ns) or off(el, .ns1.ns2.ns3) |
|
1211 |
+ if (namespaces = isTypeStr && typeSpec.replace(namespaceRegex, '')) namespaces = str2arr(namespaces, '.') |
|
1212 |
+ removeListener(element, type, fn, namespaces) |
|
1213 |
+ } else if (isFunction(typeSpec)) { |
|
1214 |
+ // off(el, fn) |
|
1215 |
+ removeListener(element, null, typeSpec) |
|
1216 |
+ } else { |
|
1217 |
+ // off(el, { t1: fn1, t2, fn2 }) |
|
1218 |
+ for (k in typeSpec) { |
|
1219 |
+ if (typeSpec.hasOwnProperty(k)) off(element, k, typeSpec[k]) |
|
1220 |
+ } |
|
1221 |
+ } |
|
1222 |
+ |
|
1223 |
+ return element |
|
1224 |
+ } |
|
1225 |
+ |
|
1226 |
+ /** |
|
1227 |
+ * on(element, eventType(s)[, selector], handler[, args ]) |
|
1228 |
+ */ |
|
1229 |
+ , on = function(element, events, selector, fn) { |
|
1230 |
+ var originalFn, type, types, i, args, entry, first |
|
1231 |
+ |
|
1232 |
+ //TODO: the undefined check means you can't pass an 'args' argument, fix this perhaps? |
|
1233 |
+ if (selector === undefined && typeof events == 'object') { |
|
1234 |
+ //TODO: this can't handle delegated events |
|
1235 |
+ for (type in events) { |
|
1236 |
+ if (events.hasOwnProperty(type)) { |
|
1237 |
+ on.call(this, element, type, events[type]) |
|
1238 |
+ } |
|
1239 |
+ } |
|
1240 |
+ return |
|
1241 |
+ } |
|
1242 |
+ |
|
1243 |
+ if (!isFunction(selector)) { |
|
1244 |
+ // delegated event |
|
1245 |
+ originalFn = fn |
|
1246 |
+ args = slice.call(arguments, 4) |
|
1247 |
+ fn = delegate(selector, originalFn, selectorEngine) |
|
1248 |
+ } else { |
|
1249 |
+ args = slice.call(arguments, 3) |
|
1250 |
+ fn = originalFn = selector |
|
1251 |
+ } |
|
1252 |
+ |
|
1253 |
+ types = str2arr(events) |
|
1254 |
+ |
|
1255 |
+ // special case for one(), wrap in a self-removing handler |
|
1256 |
+ if (this === ONE) { |
|
1257 |
+ fn = once(off, element, events, fn, originalFn) |
|
1258 |
+ } |
|
1259 |
+ |
|
1260 |
+ for (i = types.length; i--;) { |
|
1261 |
+ // add new handler to the registry and check if it's the first for this element/type |
|
1262 |
+ first = registry.put(entry = new RegEntry( |
|
1263 |
+ element |
|
1264 |
+ , types[i].replace(nameRegex, '') // event type |
|
1265 |
+ , fn |
|
1266 |
+ , originalFn |
|
1267 |
+ , str2arr(types[i].replace(namespaceRegex, ''), '.') // namespaces |
|
1268 |
+ , args |
|
1269 |
+ , false // not root |
|
1270 |
+ )) |
|
1271 |
+ if (entry[eventSupport] && first) { |
|
1272 |
+ // first event of this type on this element, add root listener |
|
1273 |
+ listener(element, entry.eventType, true, entry.customType) |
|
1274 |
+ } |
|
1275 |
+ } |
|
1276 |
+ |
|
1277 |
+ return element |
|
1278 |
+ } |
|
1279 |
+ |
|
1280 |
+ /** |
|
1281 |
+ * add(element[, selector], eventType(s), handler[, args ]) |
|
1282 |
+ * |
|
1283 |
+ * Deprecated: kept (for now) for backward-compatibility |
|
1284 |
+ */ |
|
1285 |
+ , add = function (element, events, fn, delfn) { |
|
1286 |
+ return on.apply( |
|
1287 |
+ null |
|
1288 |
+ , !isString(fn) |
|
1289 |
+ ? slice.call(arguments) |
|
1290 |
+ : [ element, fn, events, delfn ].concat(arguments.length > 3 ? slice.call(arguments, 5) : []) |
|
1291 |
+ ) |
|
1292 |
+ } |
|
1293 |
+ |
|
1294 |
+ /** |
|
1295 |
+ * one(element, eventType(s)[, selector], handler[, args ]) |
|
1296 |
+ */ |
|
1297 |
+ , one = function () { |
|
1298 |
+ return on.apply(ONE, arguments) |
|
1299 |
+ } |
|
1300 |
+ |
|
1301 |
+ /** |
|
1302 |
+ * fire(element, eventType(s)[, args ]) |
|
1303 |
+ * |
|
1304 |
+ * The optional 'args' argument must be an array, if no 'args' argument is provided |
|
1305 |
+ * then we can use the browser's DOM event system, otherwise we trigger handlers manually |
|
1306 |
+ */ |
|
1307 |
+ , fire = function (element, type, args) { |
|
1308 |
+ var types = str2arr(type) |
|
1309 |
+ , i, j, l, names, handlers |
|
1310 |
+ |
|
1311 |
+ for (i = types.length; i--;) { |
|
1312 |
+ type = types[i].replace(nameRegex, '') |
|
1313 |
+ if (names = types[i].replace(namespaceRegex, '')) names = str2arr(names, '.') |
|
1314 |
+ if (!names && !args && element[eventSupport]) { |
|
1315 |
+ fireListener(nativeEvents[type], type, element) |
|
1316 |
+ } else { |
|
1317 |
+ // non-native event, either because of a namespace, arguments or a non DOM element |
|
1318 |
+ // iterate over all listeners and manually 'fire' |
|
1319 |
+ handlers = registry.get(element, type, null, false) |
|
1320 |
+ args = [false].concat(args) |
|
1321 |
+ for (j = 0, l = handlers.length; j < l; j++) { |
|
1322 |
+ if (handlers[j].inNamespaces(names)) { |
|
1323 |
+ handlers[j].handler.apply(element, args) |
|
1324 |
+ } |
|
1325 |
+ } |
|
1326 |
+ } |
|
1327 |
+ } |
|
1328 |
+ return element |
|
1329 |
+ } |
|
1330 |
+ |
|
1331 |
+ /** |
|
1332 |
+ * clone(dstElement, srcElement[, eventType ]) |
|
1333 |
+ * |
|
1334 |
+ * TODO: perhaps for consistency we should allow the same flexibility in type specifiers? |
|
1335 |
+ */ |
|
1336 |
+ , clone = function (element, from, type) { |
|
1337 |
+ var handlers = registry.get(from, type, null, false) |
|
1338 |
+ , l = handlers.length |
|
1339 |
+ , i = 0 |
|
1340 |
+ , args, beanDel |
|
1341 |
+ |
|
1342 |
+ for (; i < l; i++) { |
|
1343 |
+ if (handlers[i].original) { |
|
1344 |
+ args = [ element, handlers[i].type ] |
|
1345 |
+ if (beanDel = handlers[i].handler.__beanDel) args.push(beanDel.selector) |
|
1346 |
+ args.push(handlers[i].original) |
|
1347 |
+ on.apply(null, args) |
|
1348 |
+ } |
|
1349 |
+ } |
|
1350 |
+ return element |
|
1351 |
+ } |
|
1352 |
+ |
|
1353 |
+ , bean = { |
|
1354 |
+ on : on |
|
1355 |
+ , add : add |
|
1356 |
+ , one : one |
|
1357 |
+ , off : off |
|
1358 |
+ , remove : off |
|
1359 |
+ , clone : clone |
|
1360 |
+ , fire : fire |
|
1361 |
+ , setSelectorEngine : setSelectorEngine |
|
1362 |
+ , noConflict : function () { |
|
1363 |
+ context[name] = old |
|
1364 |
+ return this |
|
1365 |
+ } |
|
1366 |
+ } |
|
1367 |
+ |
|
1368 |
+ // for IE, clean up on unload to avoid leaks |
|
1369 |
+ if (win.attachEvent) { |
|
1370 |
+ var cleanup = function () { |
|
1371 |
+ var i, entries = registry.entries() |
|
1372 |
+ for (i in entries) { |
|
1373 |
+ if (entries[i].type && entries[i].type !== 'unload') off(entries[i].element, entries[i].type) |
|
1374 |
+ } |
|
1375 |
+ win.detachEvent('onunload', cleanup) |
|
1376 |
+ win.CollectGarbage && win.CollectGarbage() |
|
776 | 1377 |
} |
777 |
- var iter = o; |
|
778 |
- if (typeof o == 'string') { |
|
779 |
- iter = {}; |
|
780 |
- iter[o] = v; |
|
1378 |
+ win.attachEvent('onunload', cleanup) |
|
1379 |
+ } |
|
1380 |
+ |
|
1381 |
+ // initialize selector engine to internal default (qSA or throw Error) |
|
1382 |
+ setSelectorEngine() |
|
1383 |
+ |
|
1384 |
+ return bean |
|
1385 |
+ })); |
|
1386 |
+ |
|
1387 |
+ |
|
1388 |
+ provide("bean", module.exports); |
|
1389 |
+ |
|
1390 |
+ !function ($) { |
|
1391 |
+ var b = require('bean') |
|
1392 |
+ |
|
1393 |
+ , integrate = function (method, type, method2) { |
|
1394 |
+ var _args = type ? [type] : [] |
|
1395 |
+ return function () { |
|
1396 |
+ for (var i = 0, l = this.length; i < l; i++) { |
|
1397 |
+ if (!arguments.length && method == 'on' && type) method = 'fire' |
|
1398 |
+ b[method].apply(this, [this[i]].concat(_args, Array.prototype.slice.call(arguments, 0))) |
|
1399 |
+ } |
|
1400 |
+ return this |
|
1401 |
+ } |
|
1402 |
+ } |
|
1403 |
+ |
|
1404 |
+ , add = integrate('add') |
|
1405 |
+ , on = integrate('on') |
|
1406 |
+ , one = integrate('one') |
|
1407 |
+ , off = integrate('off') |
|
1408 |
+ , fire = integrate('fire') |
|
1409 |
+ , clone = integrate('clone') |
|
1410 |
+ |
|
1411 |
+ , hover = function (enter, leave, i) { // i for internal |
|
1412 |
+ for (i = this.length; i--;) { |
|
1413 |
+ b.on.call(this, this[i], 'mouseenter', enter) |
|
1414 |
+ b.on.call(this, this[i], 'mouseleave', leave) |
|
1415 |
+ } |
|
1416 |
+ return this |
|
1417 |
+ } |
|
1418 |
+ |
|
1419 |
+ , methods = { |
|
1420 |
+ on : on |
|
1421 |
+ , addListener : on |
|
1422 |
+ , bind : on |
|
1423 |
+ , listen : on |
|
1424 |
+ , delegate : add // jQuery compat, same arg order as add() |
|
1425 |
+ |
|
1426 |
+ , one : one |
|
1427 |
+ |
|
1428 |
+ , off : off |
|
1429 |
+ , unbind : off |
|
1430 |
+ , unlisten : off |
|
1431 |
+ , removeListener : off |
|
1432 |
+ , undelegate : off |
|
1433 |
+ |
|
1434 |
+ , emit : fire |
|
1435 |
+ , trigger : fire |
|
1436 |
+ |
|
1437 |
+ , cloneEvents : clone |
|
1438 |
+ |
|
1439 |
+ , hover : hover |
|
1440 |
+ } |
|
1441 |
+ |
|
1442 |
+ , shortcuts = |
|
1443 |
+ ('blur change click dblclick error focus focusin focusout keydown keypress ' |
|
1444 |
+ + 'keyup load mousedown mouseenter mouseleave mouseout mouseover mouseup ' |
|
1445 |
+ + 'mousemove resize scroll select submit unload').split(' ') |
|
1446 |
+ |
|
1447 |
+ for (var i = shortcuts.length; i--;) { |
|
1448 |
+ methods[shortcuts[i]] = integrate('on', shortcuts[i]) |
|
1449 |
+ } |
|
1450 |
+ |
|
1451 |
+ b.setSelectorEngine($) |
|
1452 |
+ |
|
1453 |
+ $.ender(methods, true) |
|
1454 |
+ }(ender); |
|
1455 |
+ |
|
1456 |
+}()); |
|
1457 |
+ |
|
1458 |
+(function () { |
|
1459 |
+ |
|
1460 |
+ var module = { exports: {} }, exports = module.exports; |
|
1461 |
+ |
|
1462 |
+ /*! |
|
1463 |
+ * Bonzo: DOM Utility (c) Dustin Diaz 2012 |
|
1464 |
+ * https://github.com/ded/bonzo |
|
1465 |
+ * License MIT |
|
1466 |
+ */ |
|
1467 |
+ (function (name, context, definition) { |
|
1468 |
+ if (typeof module != 'undefined' && module.exports) module.exports = definition() |
|
1469 |
+ else if (typeof context['define'] == 'function' && context['define']['amd']) define(definition) |
|
1470 |
+ else context[name] = definition() |
|
1471 |
+ })('bonzo', this, function() { |
|
1472 |
+ var win = window |
|
1473 |
+ , doc = win.document |
|
1474 |
+ , html = doc.documentElement |
|
1475 |
+ , parentNode = 'parentNode' |
|
1476 |
+ , specialAttributes = /^(checked|value|selected|disabled)$/i |
|
1477 |
+ , specialTags = /^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i // tags that we have trouble inserting *into* |
|
1478 |
+ , simpleScriptTagRe = /\s*<script +src=['"]([^'"]+)['"]>/ |
|
1479 |
+ , table = ['<table>', '</table>', 1] |
|
1480 |
+ , td = ['<table><tbody><tr>', '</tr></tbody></table>', 3] |
|
1481 |
+ , option = ['<select>', '</select>', 1] |
|
1482 |
+ , noscope = ['_', '', 0, 1] |
|
1483 |
+ , tagMap = { // tags that we have trouble *inserting* |
|
1484 |
+ thead: table, tbody: table, tfoot: table, colgroup: table, caption: table |
|
1485 |
+ , tr: ['<table><tbody>', '</tbody></table>', 2] |
|
1486 |
+ , th: td , td: td |
|
1487 |
+ , col: ['<table><colgroup>', '</colgroup></table>', 2] |
|
1488 |
+ , fieldset: ['<form>', '</form>', 1] |
|
1489 |
+ , legend: ['<form><fieldset>', '</fieldset></form>', 2] |
|
1490 |
+ , option: option, optgroup: option |
|
1491 |
+ , script: noscope, style: noscope, link: noscope, param: noscope, base: noscope |
|
1492 |
+ } |
|
1493 |
+ , stateAttributes = /^(checked|selected|disabled)$/ |
|
1494 |
+ , ie = /msie/i.test(navigator.userAgent) |
|
1495 |
+ , hasClass, addClass, removeClass |
|
1496 |
+ , uidMap = {} |
|
1497 |
+ , uuids = 0 |
|
1498 |
+ , digit = /^-?[\d\.]+$/ |
|
1499 |
+ , dattr = /^data-(.+)$/ |
|
1500 |
+ , px = 'px' |
|
1501 |
+ , setAttribute = 'setAttribute' |
|
1502 |
+ , getAttribute = 'getAttribute' |
|
1503 |
+ , byTag = 'getElementsByTagName' |
|
1504 |
+ , features = function() { |
|
1505 |
+ var e = doc.createElement('p') |
|
1506 |
+ e.innerHTML = '<a href="#x">x</a><table style="float:left;"></table>' |
|
1507 |
+ return { |
|
1508 |
+ hrefExtended: e[byTag]('a')[0][getAttribute]('href') != '#x' // IE < 8 |
|
1509 |
+ , autoTbody: e[byTag]('tbody').length !== 0 // IE < 8 |
|
1510 |
+ , computedStyle: doc.defaultView && doc.defaultView.getComputedStyle |
|
1511 |
+ , cssFloat: e[byTag]('table')[0].style.styleFloat ? 'styleFloat' : 'cssFloat' |
|
1512 |
+ , transform: function () { |
|
1513 |
+ var props = ['transform', 'webkitTransform', 'MozTransform', 'OTransform', 'msTransform'], i |
|
1514 |
+ for (i = 0; i < props.length; i++) { |
|
1515 |
+ if (props[i] in e.style) return props[i] |
|
1516 |
+ } |
|
1517 |
+ }() |
|
1518 |
+ , classList: 'classList' in e |
|
1519 |
+ , opasity: function () { |
|
1520 |
+ return typeof doc.createElement('a').style.opacity !== 'undefined' |
|
1521 |
+ }() |
|
1522 |
+ } |
|
1523 |
+ }() |
|
1524 |
+ , trimReplace = /(^\s*|\s*$)/g |
|
1525 |
+ , whitespaceRegex = /\s+/ |
|
1526 |
+ , toString = String.prototype.toString |
|
1527 |
+ , unitless = { lineHeight: 1, zoom: 1, zIndex: 1, opacity: 1, boxFlex: 1, WebkitBoxFlex: 1, MozBoxFlex: 1 } |
|
1528 |
+ , query = doc.querySelectorAll && function (selector) { return doc.querySelectorAll(selector) } |
|
1529 |
+ , trim = String.prototype.trim ? |
|
1530 |
+ function (s) { |
|
1531 |
+ return s.trim() |
|
1532 |
+ } : |
|
1533 |
+ function (s) { |
|
1534 |
+ return s.replace(trimReplace, '') |
|
1535 |
+ } |
|
1536 |
+ |
|
1537 |
+ |
|
1538 |
+ function isNode(node) { |
|
1539 |
+ return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11) |
|
1540 |
+ } |
|
1541 |
+ |
|
1542 |
+ |
|
1543 |
+ function normalize(node, host, clone) { |
|
1544 |
+ var i, l, ret |
|
1545 |
+ if (typeof node == 'string') return bonzo.create(node) |
|
1546 |
+ if (isNode(node)) node = [ node ] |
|
1547 |
+ if (clone) { |
|
1548 |
+ ret = [] // don't change original array |
|
1549 |
+ for (i = 0, l = node.length; i < l; i++) ret[i] = cloneNode(host, node[i]) |
|
1550 |
+ return ret |
|
781 | 1551 |
} |
782 |
- |
|
783 |
- if (ie && iter.opacity) { |
|
784 |
- // oh this 'ol gamut |
|
785 |
- iter.filter = 'alpha(opacity=' + (iter.opacity * 100) + ')'; |
|
786 |
- // give it layout |
|
787 |
- iter.zoom = o.zoom || 1; |
|
788 |
- delete iter.opacity; |
|
1552 |
+ return node |
|
1553 |
+ } |
|
1554 |
+ |
|
1555 |
+ |
|
1556 |
+ /** |
|
1557 |
+ * @param {string} c a class name to test |
|
1558 |
+ * @return {boolean} |
|
1559 |
+ */ |
|
1560 |
+ function classReg(c) { |
|
1561 |
+ return new RegExp("(^|\\s+)" + c + "(\\s+|$)") |
|
1562 |
+ } |
|
1563 |
+ |
|
1564 |
+ |
|
1565 |
+ /** |
|
1566 |
+ * @param {Bonzo|Array} ar |
|
1567 |
+ * @param {function(Object, number, (Bonzo|Array))} fn |
|
1568 |
+ * @param {Object=} opt_scope |
|
1569 |
+ * @param {boolean=} opt_rev |
|
1570 |
+ * @return {Bonzo|Array} |
|
1571 |
+ */ |
|
1572 |
+ function each(ar, fn, opt_scope, opt_rev) { |
|
1573 |
+ var ind, i = 0, l = ar.length |
|
1574 |
+ for (; i < l; i++) { |
|
1575 |
+ ind = opt_rev ? ar.length - i - 1 : i |
|
1576 |
+ fn.call(opt_scope || ar[ind], ar[ind], ind, ar) |
|
789 | 1577 |
} |
790 |
- |
|
791 |
- if (v = iter['float']) { |
|
792 |
- // float is a reserved style word. w3 uses cssFloat, ie uses styleFloat |
|
793 |
- ie ? (iter.styleFloat = v) : (iter.cssFloat = v); |
|
794 |
- delete iter['float']; |
|
1578 |
+ return ar |
|
1579 |
+ } |
|
1580 |
+ |
|
1581 |
+ |
|
1582 |
+ /** |
|
1583 |
+ * @param {Bonzo|Array} ar |
|
1584 |
+ * @param {function(Object, number, (Bonzo|Array))} fn |
|
1585 |
+ * @param {Object=} opt_scope |
|
1586 |
+ * @return {Bonzo|Array} |
|
1587 |
+ */ |
|
1588 |
+ function deepEach(ar, fn, opt_scope) { |
|
1589 |
+ for (var i = 0, l = ar.length; i < l; i++) { |
|
1590 |
+ if (isNode(ar[i])) { |
|
1591 |
+ deepEach(ar[i].childNodes, fn, opt_scope) |
|
1592 |
+ fn.call(opt_scope || ar[i], ar[i], i, ar) |
|
1593 |
+ } |
|
795 | 1594 |
} |
796 |
- |
|
797 |
- var fn = function (el, p, v) { |
|
798 |
- for (var k in iter) { |
|
799 |
- if (iter.hasOwnProperty(k)) { |
|
800 |
- v = iter[k]; |
|
801 |
- // change "5" to "5px" - unless you're line-height, which is allowed |
|
802 |
- (p = camelize(k)) && digit.test(v) && !(p in unitless) && (v += px); |
|
803 |
- el.style[p] = v; |
|
1595 |
+ return ar |
|
1596 |
+ } |
|
1597 |
+ |
|
1598 |
+ |
|
1599 |
+ /** |
|
1600 |
+ * @param {string} s |
|
1601 |
+ * @return {string} |
|
1602 |
+ */ |
|
1603 |
+ function camelize(s) { |
|
1604 |
+ return s.replace(/-(.)/g, function (m, m1) { |
|
1605 |
+ return m1.toUpperCase() |
|
1606 |
+ }) |
|
1607 |
+ } |
|
1608 |
+ |
|
1609 |
+ |
|
1610 |
+ /** |
|
1611 |
+ * @param {string} s |
|
1612 |
+ * @return {string} |
|
1613 |
+ */ |
|
1614 |
+ function decamelize(s) { |
|
1615 |
+ return s ? s.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() : s |
|
1616 |
+ } |
|
1617 |
+ |
|
1618 |
+ |
|
1619 |
+ /** |
|
1620 |
+ * @param {Element} el |
|
1621 |
+ * @return {*} |
|
1622 |
+ */ |
|
1623 |
+ function data(el) { |
|
1624 |
+ el[getAttribute]('data-node-uid') || el[setAttribute]('data-node-uid', ++uuids) |
|
1625 |
+ var uid = el[getAttribute]('data-node-uid') |
|
1626 |
+ return uidMap[uid] || (uidMap[uid] = {}) |
|
1627 |
+ } |
|
1628 |
+ |
|
1629 |
+ |
|
1630 |
+ /** |
|
1631 |
+ * removes the data associated with an element |
|
1632 |
+ * @param {Element} el |
|
1633 |
+ */ |
|
1634 |
+ function clearData(el) { |
|
1635 |
+ var uid = el[getAttribute]('data-node-uid') |
|
1636 |
+ if (uid) delete uidMap[uid] |
|
1637 |
+ } |
|
1638 |
+ |
|
1639 |
+ |
|
1640 |
+ function dataValue(d) { |
|
1641 |
+ var f |
|
1642 |
+ try { |
|
1643 |
+ return (d === null || d === undefined) ? undefined : |
|
1644 |
+ d === 'true' ? true : |
|
1645 |
+ d === 'false' ? false : |
|
1646 |
+ d === 'null' ? null : |
|
1647 |
+ (f = parseFloat(d)) == d ? f : d; |
|
1648 |
+ } catch(e) {} |
|
1649 |
+ return undefined |
|
1650 |
+ } |
|
1651 |
+ |
|
1652 |
+ |
|
1653 |
+ /** |
|
1654 |
+ * @param {Bonzo|Array} ar |
|
1655 |
+ * @param {function(Object, number, (Bonzo|Array))} fn |
|
1656 |
+ * @param {Object=} opt_scope |
|
1657 |
+ * @return {boolean} whether `some`thing was found |
|
1658 |
+ */ |
|
1659 |
+ function some(ar, fn, opt_scope) { |
|
1660 |
+ for (var i = 0, j = ar.length; i < j; ++i) if (fn.call(opt_scope || null, ar[i], i, ar)) return true |
|
1661 |
+ return false |
|
1662 |
+ } |
|
1663 |
+ |
|
1664 |
+ |
|
1665 |
+ /** |
|
1666 |
+ * this could be a giant enum of CSS properties |
|
1667 |
+ * but in favor of file size sans-closure deadcode optimizations |
|
1668 |
+ * we're just asking for any ol string |
|
1669 |
+ * then it gets transformed into the appropriate style property for JS access |
|
1670 |
+ * @param {string} p |
|
1671 |
+ * @return {string} |
|
1672 |
+ */ |
|
1673 |
+ function styleProperty(p) { |
|
1674 |
+ (p == 'transform' && (p = features.transform)) || |
|
1675 |
+ (/^transform-?[Oo]rigin$/.test(p) && (p = features.transform + 'Origin')) || |
|
1676 |
+ (p == 'float' && (p = features.cssFloat)) |
|
1677 |
+ return p ? camelize(p) : null |
|
1678 |
+ } |
|
1679 |
+ |
|
1680 |
+ var getStyle = features.computedStyle ? |
|
1681 |
+ function (el, property) { |
|
1682 |
+ var value = null |
|
1683 |
+ , computed = doc.defaultView.getComputedStyle(el, '') |
|
1684 |
+ computed && (value = computed[property]) |
|
1685 |
+ return el.style[property] || value |
|
1686 |
+ } : |
|
1687 |
+ |
|
1688 |
+ (ie && html.currentStyle) ? |
|
1689 |
+ |
|
1690 |
+ /** |
|
1691 |
+ * @param {Element} el |
|
1692 |
+ * @param {string} property |
|
1693 |
+ * @return {string|number} |
|
1694 |
+ */ |
|
1695 |
+ function (el, property) { |
|
1696 |
+ if (property == 'opacity' && !features.opasity) { |
|
1697 |
+ var val = 100 |
|
1698 |
+ try { |
|
1699 |
+ val = el['filters']['DXImageTransform.Microsoft.Alpha'].opacity |
|
1700 |
+ } catch (e1) { |
|
1701 |
+ try { |
|
1702 |
+ val = el['filters']('alpha').opacity |
|
1703 |
+ } catch (e2) {} |
|
804 | 1704 |
} |
1705 |
+ return val / 100 |
|
805 | 1706 |
} |
806 |
- }; |
|
807 |
- return this.each(fn); |
|
808 |
- }, |
|
809 |
- |
|
810 |
- offset: function (x, y) { |
|
811 |
- if (x || y) { |
|
812 |
- return this.each(function (el) { |
|
813 |
- xy(el, x, y); |
|
814 |
- }); |
|
815 |
- } |
|
816 |
- var el = this[0]; |
|
817 |
- var width = el.offsetWidth; |
|
818 |
- var height = el.offsetHeight; |
|
819 |
- var top = el.offsetTop; |
|
820 |
- var left = el.offsetLeft; |
|
821 |
- while (el = el.offsetParent) { |
|
822 |
- top = top + el.offsetTop; |
|
823 |
- left = left + el.offsetLeft; |
|
1707 |
+ var value = el.currentStyle ? el.currentStyle[property] : null |
|
1708 |
+ return el.style[property] || value |
|
1709 |
+ } : |
|
1710 |
+ |
|
1711 |
+ function (el, property) { |
|
1712 |
+ return el.style[property] |
|
824 | 1713 |
} |
825 |
- |
|
826 |
- return { |
|
827 |
- top: top, |
|
828 |
- left: left, |
|
829 |
- height: height, |
|
830 |
- width: width |
|
831 |
- }; |
|
832 |
- }, |
|
833 |
- |
|
834 |
- attr: function (k, v) { |
|
835 |
- var el = this[0]; |
|
836 |
- return typeof v == 'undefined' ? |
|
837 |
- specialAttributes.test(k) ? |
|
838 |
- stateAttributes.test(k) && typeof el[k] == 'string' ? |
|
839 |
- true : el[k] : el[getAttribute](k) : |
|
840 |
- this.each(function (el) { |
|
841 |
- k == 'value' ? (el.value = v) : el[setAttribute](k, v); |
|
842 |
- }); |
|
843 |
- }, |
|
844 |
- |
|
845 |
- val: function (s) { |
|
846 |
- return (typeof s == 'string') ? this.attr('value', s) : this[0].value; |
|
847 |
- }, |
|
848 |
- |
|
849 |
- removeAttr: function (k) { |
|
850 |
- return this.each(function (el) { |
|
851 |
- el.removeAttribute(k); |
|
852 |
- }); |
|
853 |
- }, |
|
854 |
- |
|
855 |
- data: function (k, v) { |
|
856 |
- var el = this[0]; |
|
857 |
- if (typeof v === 'undefined') { |
|
858 |
- el[getAttribute]('data-node-uid') || el[setAttribute]('data-node-uid', ++uuids); |
|
859 |
- var uid = el[getAttribute]('data-node-uid'); |
|
860 |
- uidList[uid] || (uidList[uid] = {}); |
|
861 |
- return uidList[uid][k]; |
|
862 |
- } else { |
|
863 |
- return this.each(function (el) { |
|
864 |
- el[getAttribute]('data-node-uid') || el[setAttribute]('data-node-uid', ++uuids); |
|
865 |
- var uid = el[getAttribute]('data-node-uid'); |
|
866 |
- var o = {}; |
|
867 |
- o[k] = v; |
|
868 |
- uidList[uid] = o; |
|
869 |
- }); |
|
870 |
- } |
|
871 |
- }, |
|
872 |
- |
|
873 |
- remove: function () { |
|
874 |
- return this.each(function (el) { |
|
875 |
- el.parentNode && el.parentNode.removeChild(el); |
|
876 |
- }); |
|
877 |
- }, |
|
878 |
- |
|
879 |
- empty: function () { |
|
880 |
- return this.each(function (el) { |
|
881 |
- while (el.firstChild) { |
|
882 |
- el.removeChild(el.firstChild); |
|
883 |
- } |
|
884 |
- }); |
|
885 |
- }, |
|
886 |
- |
|
887 |
- detach: function () { |
|
888 |
- return this.map(function (el) { |
|
889 |
- return el.parentNode.removeChild(el); |
|
890 |
- }); |
|
891 |
- }, |
|
892 |
- |
|
893 |
- scrollTop: function (y) { |
|
894 |
- return scroll.call(this, null, y, 'y'); |
|
895 |
- }, |
|
896 |
- |
|
897 |
- scrollLeft: function (x) { |
|
898 |
- return scroll.call(this, x, null, 'x'); |
|
1714 |
+ |
|
1715 |
+ // this insert method is intense |
|
1716 |
+ function insert(target, host, fn, rev) { |
|
1717 |
+ var i = 0, self = host || this, r = [] |
|
1718 |
+ // target nodes could be a css selector if it's a string and a selector engine is present |
|
1719 |
+ // otherwise, just use target |
|
1720 |
+ , nodes = query && typeof target == 'string' && target.charAt(0) != '<' ? query(target) : target |
|
1721 |
+ // normalize each node in case it's still a string and we need to create nodes on the fly |
|
1722 |
+ each(normalize(nodes), function (t, j) { |
|
1723 |
+ each(self, function (el) { |
|
1724 |
+ fn(t, r[i++] = j > 0 ? cloneNode(self, el) : el) |
|
1725 |
+ }, null, rev) |
|
1726 |
+ }, this, rev) |
|
1727 |
+ self.length = i |
|
1728 |
+ each(r, function (e) { |
|
1729 |
+ self[--i] = e |
|
1730 |
+ }, null, !rev) |
|
1731 |
+ return self |
|
899 | 1732 |
} |
900 |
- }; |
|
901 |
- |
|
902 |
- function normalize(node, tag) { |
|
903 |
- return typeof node == 'string' ? bonzo.create(node, tag) : is(node) ? [node] : node; |
|
904 |
- } |
|
905 |
- |
|
906 |
- function scroll(x, y, type) { |
|
907 |
- var el = this[0]; |
|
908 |
- if (x == null && y == null) { |
|
909 |
- return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type]; |
|
1733 |
+ |
|
1734 |
+ |
|
1735 |
+ /** |
|
1736 |
+ * sets an element to an explicit x/y position on the page |
|
1737 |
+ * @param {Element} el |
|
1738 |
+ * @param {?number} x |
|
1739 |
+ * @param {?number} y |
|
1740 |
+ */ |
|
1741 |
+ function xy(el, x, y) { |
|
1742 |
+ var $el = bonzo(el) |
|
1743 |
+ , style = $el.css('position') |
|
1744 |
+ , offset = $el.offset() |
|
1745 |
+ , rel = 'relative' |
|
1746 |
+ , isRel = style == rel |
|
1747 |
+ , delta = [parseInt($el.css('left'), 10), parseInt($el.css('top'), 10)] |
|
1748 |
+ |
|
1749 |
+ if (style == 'static') { |
|
1750 |
+ $el.css('position', rel) |
|
1751 |
+ style = rel |
|
1752 |
+ } |
|
1753 |
+ |
|
1754 |
+ isNaN(delta[0]) && (delta[0] = isRel ? 0 : el.offsetLeft) |
|
1755 |
+ isNaN(delta[1]) && (delta[1] = isRel ? 0 : el.offsetTop) |
|
1756 |
+ |
|
1757 |
+ x != null && (el.style.left = x - offset.left + delta[0] + px) |
|
1758 |
+ y != null && (el.style.top = y - offset.top + delta[1] + px) |
|
1759 |
+ |
|
910 | 1760 |
} |
911 |
- if (isBody(el)) { |
|
912 |
- window.scrollTo(x, y); |
|
913 |
- } else { |
|
914 |
- x != null && (el.scrollLeft = x); |
|
915 |
- y != null && (el.scrollTop = y); |
|
1761 |
+ |
|
1762 |
+ // classList support for class management |
|
1763 |
+ // altho to be fair, the api sucks because it won't accept multiple classes at once |
|
1764 |
+ if (features.classList) { |
|
1765 |
+ hasClass = function (el, c) { |
|
1766 |
+ return el.classList.contains(c) |
|
1767 |
+ } |
|
1768 |
+ addClass = function (el, c) { |
|
1769 |
+ el.classList.add(c) |
|
1770 |
+ } |
|
1771 |
+ removeClass = function (el, c) { |
|
1772 |
+ el.classList.remove(c) |
|
1773 |
+ } |
|
916 | 1774 |
} |
917 |
- return this; |
|
918 |
- } |
|
919 |
- |
|
920 |
- function isBody(element) { |
|
921 |
- return element === window || (/^(?:body|html)$/i).test(element.tagName); |
|
922 |
- } |
|
923 |
- |
|
924 |
- function getWindowScroll() { |
|
925 |
- return { x: window.pageXOffset || html.scrollLeft, y: window.pageYOffset || html.scrollTop }; |
|
926 |
- } |
|
927 |
- |
|
928 |
- function bonzo(els, host) { |
|
929 |
- return new Bonzo(els, host); |
|
930 |
- } |
|
931 |
- |
|
932 |
- bonzo.setQueryEngine = function (q) { |
|
933 |
- query = q; |
|
934 |
- delete bonzo.setQueryEngine; |
|
935 |
- }; |
|
936 |
- |
|
937 |
- bonzo.aug = function (o, target) { |
|
938 |
- for (var k in o) { |
|
939 |
- o.hasOwnProperty(k) && ((target || Bonzo.prototype)[k] = o[k]); |
|
1775 |
+ else { |
|
1776 |
+ hasClass = function (el, c) { |
|
1777 |
+ return classReg(c).test(el.className) |
|
1778 |
+ } |
|
1779 |
+ addClass = function (el, c) { |
|
1780 |
+ el.className = trim(el.className + ' ' + c) |
|
1781 |
+ } |
|
1782 |
+ removeClass = function (el, c) { |
|
1783 |
+ el.className = trim(el.className.replace(classReg(c), ' ')) |
|
1784 |
+ } |
|
940 | 1785 |
} |
941 |
- }; |
|
942 |
- |
|
943 |
- bonzo.create = function (node, tag) { |
|
944 |
- return typeof node == 'string' ? |
|
945 |
- function () { |
|
946 |
- var t = tag ? tagMap[tag.toLowerCase()] : null; |
|
947 |
- var el = doc.createElement(t || 'div'), els = []; |
|
948 |
- if (tag) { |
|
949 |
- var bitches = node.match(new RegExp("<" + t + ">.+?<\\/" + t + ">", "g")); |
|
950 |
- each(bitches, function (m) { |
|
951 |
- m = m.replace(/<(.+)>(.+?)<\/\1>/, '$2'); |
|
952 |
- var bah = doc.createElement(t); |
|
953 |
- bah.appendChild(doc.createDocumentFragment(m)); |
|
954 |
- el.appendChild(bah); |
|
955 |
- }); |
|
956 |
- } else { |
|
957 |
- el.innerHTML = node; |
|
1786 |
+ |
|
1787 |
+ |
|
1788 |
+ /** |
|
1789 |
+ * this allows method calling for setting values |
|
1790 |
+ * |
|
1791 |
+ * @example |
|
1792 |
+ * bonzo(elements).css('color', function (el) { |
|
1793 |
+ * return el.getAttribute('data-original-color') |
|
1794 |
+ * }) |
|
1795 |
+ * |
|
1796 |
+ * @param {Element} el |
|
1797 |
+ * @param {function (Element)|string} |
|
1798 |
+ * @return {string} |
|
1799 |
+ */ |
|
1800 |
+ function setter(el, v) { |
|
1801 |
+ return typeof v == 'function' ? v(el) : v |
|
1802 |
+ } |
|
1803 |
+ |
|
1804 |
+ /** |
|
1805 |
+ * @constructor |
|
1806 |
+ * @param {Array.<Element>|Element|Node|string} elements |
|
1807 |
+ */ |
|
1808 |
+ function Bonzo(elements) { |
|
1809 |
+ this.length = 0 |
|
1810 |
+ if (elements) { |
|
1811 |
+ elements = typeof elements !== 'string' && |
|
1812 |
+ !elements.nodeType && |
|
1813 |
+ typeof elements.length !== 'undefined' ? |
|
1814 |
+ elements : |
|
1815 |
+ [elements] |
|
1816 |
+ this.length = elements.length |
|
1817 |
+ for (var i = 0; i < elements.length; i++) this[i] = elements[i] |
|
1818 |
+ } |
|
1819 |
+ } |
|
1820 |
+ |
|
1821 |
+ Bonzo.prototype = { |
|
1822 |
+ |
|
1823 |
+ /** |
|
1824 |
+ * @param {number} index |
|
1825 |
+ * @return {Element|Node} |
|
1826 |
+ */ |
|
1827 |
+ get: function (index) { |
|
1828 |
+ return this[index] || null |
|
958 | 1829 |
} |
959 |
- var nodes = el.childNodes; |
|
960 |
- el = el.firstChild; |
|
961 |
- els.push(el); |
|
962 |
- while (el = el.nextSibling) { |
|
963 |
- (el.nodeType == 1) && els.push(el); |
|
1830 |
+ |
|
1831 |
+ // itetators |
|
1832 |
+ /** |
|
1833 |
+ * @param {function(Element|Node)} fn |
|
1834 |
+ * @param {Object=} opt_scope |
|
1835 |
+ * @return {Bonzo} |
|
1836 |
+ */ |
|
1837 |
+ , each: function (fn, opt_scope) { |
|
1838 |
+ return each(this, fn, opt_scope) |
|
964 | 1839 |
} |
965 |
- return els; |
|
966 |
- |
|
967 |
- }() : is(node) ? [node.cloneNode(true)] : []; |
|
968 |
- }; |
|
969 |
- |
|
970 |
- bonzo.doc = function () { |
|
971 |
- var w = html.scrollWidth, |
|
972 |
- h = html.scrollHeight, |
|
973 |
- vp = this.viewport(); |
|
974 |
- return { |
|
975 |
- width: Math.max(w, vp.width), |
|
976 |
- height: Math.max(h, vp.height) |
|
977 |
- }; |
|
978 |
- }; |
|
979 |
- |
|
980 |
- bonzo.firstChild = function (el) { |
|
981 |
- for (var c = el.childNodes, i = 0, j = (c && c.length) || 0, e; i < j; i++) { |
|
982 |
- if (c[i].nodeType === 1) { |
|
983 |
- e = c[j = i]; |
|
1840 |
+ |
|
1841 |
+ /** |
|
1842 |
+ * @param {Function} fn |
|
1843 |
+ * @param {Object=} opt_scope |
|
1844 |
+ * @return {Bonzo} |
|
1845 |
+ */ |
|
1846 |
+ , deepEach: function (fn, opt_scope) { |
|
1847 |
+ return deepEach(this, fn, opt_scope) |
|
1848 |
+ } |
|
1849 |
+ |
|
1850 |
+ |
|
1851 |
+ /** |
|
1852 |
+ * @param {Function} fn |
|
1853 |
+ * @param {Function=} opt_reject |
|
1854 |
+ * @return {Array} |
|
1855 |
+ */ |
|
1856 |
+ , map: function (fn, opt_reject) { |
|
1857 |
+ var m = [], n, i |
|
1858 |
+ for (i = 0; i < this.length; i++) { |
|
1859 |
+ n = fn.call(this, this[i], i) |
|
1860 |
+ opt_reject ? (opt_reject(n) && m.push(n)) : m.push(n) |
|
1861 |
+ } |
|
1862 |
+ return m |
|
1863 |
+ } |
|
1864 |
+ |
|
1865 |
+ // text and html inserters! |
|
1866 |
+ |
|
1867 |
+ /** |
|
1868 |
+ * @param {string} h the HTML to insert |
|
1869 |
+ * @param {boolean=} opt_text whether to set or get text content |
|
1870 |
+ * @return {Bonzo|string} |
|
1871 |
+ */ |
|
1872 |
+ , html: function (h, opt_text) { |
|
1873 |
+ var method = opt_text |
|
1874 |
+ ? html.textContent === undefined ? 'innerText' : 'textContent' |
|
1875 |
+ : 'innerHTML' |
|
1876 |
+ , that = this |
|
1877 |
+ , append = function (el, i) { |
|
1878 |
+ each(normalize(h, that, i), function (node) { |
|
1879 |
+ el.appendChild(node) |
|
1880 |
+ }) |
|
1881 |
+ } |
|
1882 |
+ , updateElement = function (el, i) { |
|
1883 |
+ try { |
|
1884 |
+ if (opt_text || (typeof h == 'string' && !specialTags.test(el.tagName))) { |
|
1885 |
+ return el[method] = h |
|
1886 |
+ } |
|
1887 |
+ } catch (e) {} |
|
1888 |
+ append(el, i) |
|
1889 |
+ } |
|
1890 |
+ return typeof h != 'undefined' |
|
1891 |
+ ? this.empty().each(updateElement) |
|
1892 |
+ : this[0] ? this[0][method] : '' |
|
1893 |
+ } |
|
1894 |
+ |
|
1895 |
+ /** |
|
1896 |
+ * @param {string=} opt_text the text to set, otherwise this is a getter |
|
1897 |
+ * @return {Bonzo|string} |
|
1898 |
+ */ |
|
1899 |
+ , text: function (opt_text) { |
|
1900 |
+ return this.html(opt_text, true) |
|
1901 |
+ } |
|
1902 |
+ |
|
1903 |
+ // more related insertion methods |
|
1904 |
+ |
|
1905 |
+ /** |
|
1906 |
+ * @param {Bonzo|string|Element|Array} node |
|
1907 |
+ * @return {Bonzo} |
|
1908 |
+ */ |
|
1909 |
+ , append: function (node) { |
|
1910 |
+ var that = this |
|
1911 |
+ return this.each(function (el, i) { |
|
1912 |
+ each(normalize(node, that, i), function (i) { |
|
1913 |
+ el.appendChild(i) |
|
1914 |
+ }) |
|
1915 |
+ }) |
|
1916 |
+ } |
|
1917 |
+ |
|
1918 |
+ |
|
1919 |
+ /** |
|
1920 |
+ * @param {Bonzo|string|Element|Array} node |
|
1921 |
+ * @return {Bonzo} |
|
1922 |
+ */ |
|
1923 |
+ , prepend: function (node) { |
|
1924 |
+ var that = this |
|
1925 |
+ return this.each(function (el, i) { |
|
1926 |
+ var first = el.firstChild |
|
1927 |
+ each(normalize(node, that, i), function (i) { |
|
1928 |
+ el.insertBefore(i, first) |
|
1929 |
+ }) |
|
1930 |
+ }) |
|
1931 |
+ } |
|
1932 |
+ |
|
1933 |
+ |
|
1934 |
+ /** |
|
1935 |
+ * @param {Bonzo|string|Element|Array} target the location for which you'll insert your new content |
|
1936 |
+ * @param {Object=} opt_host an optional host scope (primarily used when integrated with Ender) |
|
1937 |
+ * @return {Bonzo} |
|
1938 |
+ */ |
|
1939 |
+ , appendTo: function (target, opt_host) { |
|
1940 |
+ return insert.call(this, target, opt_host, function (t, el) { |
|
1941 |
+ t.appendChild(el) |
|
1942 |
+ }) |
|
1943 |
+ } |
|
1944 |
+ |
|
1945 |
+ |
|
1946 |
+ /** |
|
1947 |
+ * @param {Bonzo|string|Element|Array} target the location for which you'll insert your new content |
|
1948 |
+ * @param {Object=} opt_host an optional host scope (primarily used when integrated with Ender) |
|
1949 |
+ * @return {Bonzo} |
|
1950 |
+ */ |
|
1951 |
+ , prependTo: function (target, opt_host) { |
|
1952 |
+ return insert.call(this, target, opt_host, function (t, el) { |
|
1953 |
+ t.insertBefore(el, t.firstChild) |
|
1954 |
+ }, 1) |
|
1955 |
+ } |
|
1956 |
+ |
|
1957 |
+ |
|
1958 |
+ /** |
|
1959 |
+ * @param {Bonzo|string|Element|Array} node |
|
1960 |
+ * @return {Bonzo} |
|
1961 |
+ */ |
|
1962 |
+ , before: function (node) { |
|
1963 |
+ var that = this |
|
1964 |
+ return this.each(function (el, i) { |
|
1965 |
+ each(normalize(node, that, i), function (i) { |
|
1966 |
+ el[parentNode].insertBefore(i, el) |
|
1967 |
+ }) |
|
1968 |
+ }) |
|
1969 |
+ } |
|
1970 |
+ |
|
1971 |
+ |
|
1972 |
+ /** |
|
1973 |
+ * @param {Bonzo|string|Element|Array} node |
|
1974 |
+ * @return {Bonzo} |
|
1975 |
+ */ |
|
1976 |
+ , after: function (node) { |
|
1977 |
+ var that = this |
|
1978 |
+ return this.each(function (el, i) { |
|
1979 |
+ each(normalize(node, that, i), function (i) { |
|
1980 |
+ el[parentNode].insertBefore(i, el.nextSibling) |
|
1981 |
+ }, null, 1) |
|
1982 |
+ }) |
|
1983 |
+ } |
|
1984 |
+ |
|
1985 |
+ |
|
1986 |
+ /** |
|
1987 |
+ * @param {Bonzo|string|Element|Array} target the location for which you'll insert your new content |
|
1988 |
+ * @param {Object=} opt_host an optional host scope (primarily used when integrated with Ender) |
|
1989 |
+ * @return {Bonzo} |
|
1990 |
+ */ |
|
1991 |
+ , insertBefore: function (target, opt_host) { |
|
1992 |
+ return insert.call(this, target, opt_host, function (t, el) { |
|
1993 |
+ t[parentNode].insertBefore(el, t) |
|
1994 |
+ }) |
|
1995 |
+ } |
|
1996 |
+ |
|
1997 |
+ |
|
1998 |
+ /** |
|
1999 |
+ * @param {Bonzo|string|Element|Array} target the location for which you'll insert your new content |
|
2000 |
+ * @param {Object=} opt_host an optional host scope (primarily used when integrated with Ender) |
|
2001 |
+ * @return {Bonzo} |
|
2002 |
+ */ |
|
2003 |
+ , insertAfter: function (target, opt_host) { |
|
2004 |
+ return insert.call(this, target, opt_host, function (t, el) { |
|
2005 |
+ var sibling = t.nextSibling |
|
2006 |
+ sibling ? |
|
2007 |
+ t[parentNode].insertBefore(el, sibling) : |
|
2008 |
+ t[parentNode].appendChild(el) |
|
2009 |
+ }, 1) |
|
2010 |
+ } |
|
2011 |
+ |
|
2012 |
+ |
|
2013 |
+ /** |
|
2014 |
+ * @param {Bonzo|string|Element|Array} node |
|
2015 |
+ * @return {Bonzo} |
|
2016 |
+ */ |
|
2017 |
+ , replaceWith: function (node) { |
|
2018 |
+ bonzo(normalize(node)).insertAfter(this) |
|
2019 |
+ return this.remove() |
|
2020 |
+ } |
|
2021 |
+ |
|
2022 |
+ // class management |
|
2023 |
+ |
|
2024 |
+ /** |
|
2025 |
+ * @param {string} c |
|
2026 |
+ * @return {Bonzo} |
|
2027 |
+ */ |
|
2028 |
+ , addClass: function (c) { |
|
2029 |
+ c = toString.call(c).split(whitespaceRegex) |
|
2030 |
+ return this.each(function (el) { |
|
2031 |
+ // we `each` here so you can do $el.addClass('foo bar') |
|
2032 |
+ each(c, function (c) { |
|
2033 |
+ if (c && !hasClass(el, setter(el, c))) |
|
2034 |
+ addClass(el, setter(el, c)) |
|
2035 |
+ }) |
|
2036 |
+ }) |
|
2037 |
+ } |
|
2038 |
+ |
|
2039 |
+ |
|
2040 |
+ /** |
|
2041 |
+ * @param {string} c |
|
2042 |
+ * @return {Bonzo} |
|
2043 |
+ */ |
|
2044 |
+ , removeClass: function (c) { |
|
2045 |
+ c = toString.call(c).split(whitespaceRegex) |
|
2046 |
+ return this.each(function (el) { |
|
2047 |
+ each(c, function (c) { |
|
2048 |
+ if (c && hasClass(el, setter(el, c))) |
|
2049 |
+ removeClass(el, setter(el, c)) |
|
2050 |
+ }) |
|
2051 |
+ }) |
|
2052 |
+ } |
|
2053 |
+ |
|
2054 |
+ |
|
2055 |
+ /** |
|
2056 |
+ * @param {string} c |
|
2057 |
+ * @return {boolean} |
|
2058 |
+ */ |
|
2059 |
+ , hasClass: function (c) { |
|
2060 |
+ c = toString.call(c).split(whitespaceRegex) |
|
2061 |
+ return some(this, function (el) { |
|
2062 |
+ return some(c, function (c) { |
|
2063 |
+ return c && hasClass(el, c) |
|
2064 |
+ }) |
|
2065 |
+ }) |
|
2066 |
+ } |
|
2067 |
+ |
|
2068 |
+ |
|
2069 |
+ /** |
|
2070 |
+ * @param {string} c classname to toggle |
|
2071 |
+ * @param {boolean=} opt_condition whether to add or remove the class straight away |
|
2072 |
+ * @return {Bonzo} |
|
2073 |
+ */ |
|
2074 |
+ , toggleClass: function (c, opt_condition) { |
|
2075 |
+ c = toString.call(c).split(whitespaceRegex) |
|
2076 |
+ return this.each(function (el) { |
|
2077 |
+ each(c, function (c) { |
|
2078 |
+ if (c) { |
|
2079 |
+ typeof opt_condition !== 'undefined' ? |
|
2080 |
+ opt_condition ? addClass(el, c) : removeClass(el, c) : |
|
2081 |
+ hasClass(el, c) ? removeClass(el, c) : addClass(el, c) |
|
2082 |
+ } |
|
2083 |
+ }) |
|
2084 |
+ }) |
|
2085 |
+ } |
|
2086 |
+ |
|
2087 |
+ // display togglers |
|
2088 |
+ |
|
2089 |
+ /** |
|
2090 |
+ * @param {string=} opt_type useful to set back to anything other than an empty string |
|
2091 |
+ * @return {Bonzo} |
|
2092 |
+ */ |
|
2093 |
+ , show: function (opt_type) { |
|
2094 |
+ opt_type = typeof opt_type == 'string' ? opt_type : '' |
|
2095 |
+ return this.each(function (el) { |
|
2096 |
+ el.style.display = opt_type |
|
2097 |
+ }) |
|
2098 |
+ } |
|
2099 |
+ |
|
2100 |
+ |
|
2101 |
+ /** |
|
2102 |
+ * @return {Bonzo} |
|
2103 |
+ */ |
|
2104 |
+ , hide: function () { |
|
2105 |
+ return this.each(function (el) { |
|
2106 |
+ el.style.display = 'none' |
|
2107 |
+ }) |
|
2108 |
+ } |
|
2109 |
+ |
|
2110 |
+ |
|
2111 |
+ /** |
|
2112 |
+ * @param {Function=} opt_callback |
|
2113 |
+ * @param {string=} opt_type |
|
2114 |
+ * @return {Bonzo} |
|
2115 |
+ */ |
|
2116 |
+ , toggle: function (opt_callback, opt_type) { |
|
2117 |
+ opt_type = typeof opt_type == 'string' ? opt_type : ''; |
|
2118 |
+ typeof opt_callback != 'function' && (opt_callback = null) |
|
2119 |
+ return this.each(function (el) { |
|
2120 |
+ el.style.display = (el.offsetWidth || el.offsetHeight) ? 'none' : opt_type; |
|
2121 |
+ opt_callback && opt_callback.call(el) |
|
2122 |
+ }) |
|
2123 |
+ } |
|
2124 |
+ |
|
2125 |
+ |
|
2126 |
+ // DOM Walkers & getters |
|
2127 |
+ |
|
2128 |
+ /** |
|
2129 |
+ * @return {Element|Node} |
|
2130 |
+ */ |
|
2131 |
+ , first: function () { |
|
2132 |
+ return bonzo(this.length ? this[0] : []) |
|
2133 |
+ } |
|
2134 |
+ |
|
2135 |
+ |
|
2136 |
+ /** |
|
2137 |
+ * @return {Element|Node} |
|
2138 |
+ */ |
|
2139 |
+ , last: function () { |
|
2140 |
+ return bonzo(this.length ? this[this.length - 1] : []) |
|
2141 |
+ } |
|
2142 |
+ |
|
2143 |
+ |
|
2144 |
+ /** |
|
2145 |
+ * @return {Element|Node} |
|
2146 |
+ */ |
|
2147 |
+ , next: function () { |
|
2148 |
+ return this.related('nextSibling') |
|
2149 |
+ } |
|
2150 |
+ |
|
2151 |
+ |
|
2152 |
+ /** |
|
2153 |
+ * @return {Element|Node} |
|
2154 |
+ */ |
|
2155 |
+ , previous: function () { |
|
2156 |
+ return this.related('previousSibling') |
|
2157 |
+ } |
|
2158 |
+ |
|
2159 |
+ |
|
2160 |
+ /** |
|
2161 |
+ * @return {Element|Node} |
|
2162 |
+ */ |
|
2163 |
+ , parent: function() { |
|
2164 |
+ return this.related(parentNode) |
|
2165 |
+ } |
|
2166 |
+ |
|
2167 |
+ |
|
2168 |
+ /** |
|
2169 |
+ * @private |
|
2170 |
+ * @param {string} method the directional DOM method |
|
2171 |
+ * @return {Element|Node} |
|
2172 |
+ */ |
|
2173 |
+ , related: function (method) { |
|
2174 |
+ return this.map( |
|
2175 |
+ function (el) { |
|
2176 |
+ el = el[method] |
|
2177 |
+ while (el && el.nodeType !== 1) { |
|
2178 |
+ el = el[method] |
|
2179 |
+ } |
|
2180 |
+ return el || 0 |
|
2181 |
+ }, |
|
2182 |
+ function (el) { |
|
2183 |
+ return el |
|
2184 |
+ } |
|
2185 |
+ ) |
|
2186 |
+ } |
|
2187 |
+ |
|
2188 |
+ |
|
2189 |
+ /** |
|
2190 |
+ * @return {Bonzo} |
|
2191 |
+ */ |
|
2192 |
+ , focus: function () { |
|
2193 |
+ this.length && this[0].focus() |
|
2194 |
+ return this |
|
2195 |
+ } |
|
2196 |
+ |
|
2197 |
+ |
|
2198 |
+ /** |
|
2199 |
+ * @return {Bonzo} |
|
2200 |
+ */ |
|
2201 |
+ , blur: function () { |
|
2202 |
+ this.length && this[0].blur() |
|
2203 |
+ return this |
|
2204 |
+ } |
|
2205 |
+ |
|
2206 |
+ // style getter setter & related methods |
|
2207 |
+ |
|
2208 |
+ /** |
|
2209 |
+ * @param {Object|string} o |
|
2210 |
+ * @param {string=} opt_v |
|
2211 |
+ * @return {Bonzo|string} |
|
2212 |
+ */ |
|
2213 |
+ , css: function (o, opt_v) { |
|
2214 |
+ var p, iter = o |
|
2215 |
+ // is this a request for just getting a style? |
|
2216 |
+ if (opt_v === undefined && typeof o == 'string') { |
|
2217 |
+ // repurpose 'v' |
|
2218 |
+ opt_v = this[0] |
|
2219 |
+ if (!opt_v) return null |
|
2220 |
+ if (opt_v === doc || opt_v === win) { |
|
2221 |
+ p = (opt_v === doc) ? bonzo.doc() : bonzo.viewport() |
|
2222 |
+ return o == 'width' ? p.width : o == 'height' ? p.height : '' |
|
2223 |
+ } |
|
2224 |
+ return (o = styleProperty(o)) ? getStyle(opt_v, o) : null |
|
2225 |
+ } |
|
2226 |
+ |
|
2227 |
+ if (typeof o == 'string') { |
|
2228 |
+ iter = {} |
|
2229 |
+ iter[o] = opt_v |
|
2230 |
+ } |
|
2231 |
+ |
|
2232 |
+ if (ie && iter.opacity) { |
|
2233 |
+ // oh this 'ol gamut |
|
2234 |
+ iter.filter = 'alpha(opacity=' + (iter.opacity * 100) + ')' |
|
2235 |
+ // give it layout |
|
2236 |
+ iter.zoom = o.zoom || 1; |
|
2237 |
+ delete iter.opacity; |
|
2238 |
+ } |
|
2239 |
+ |
|
2240 |
+ function fn(el, p, v) { |
|
2241 |
+ for (var k in iter) { |
|
2242 |
+ if (iter.hasOwnProperty(k)) { |
|
2243 |
+ v = iter[k]; |
|
2244 |
+ // change "5" to "5px" - unless you're line-height, which is allowed |
|
2245 |
+ (p = styleProperty(k)) && digit.test(v) && !(p in unitless) && (v += px) |
|
2246 |
+ try { el.style[p] = setter(el, v) } catch(e) {} |
|
2247 |
+ } |
|
2248 |
+ } |
|
2249 |
+ } |
|
2250 |
+ return this.each(fn) |
|
2251 |
+ } |
|
2252 |
+ |
|
2253 |
+ |
|
2254 |
+ /** |
|
2255 |
+ * @param {number=} opt_x |
|
2256 |
+ * @param {number=} opt_y |
|
2257 |
+ * @return {Bonzo|number} |
|
2258 |
+ */ |
|
2259 |
+ , offset: function (opt_x, opt_y) { |
|
2260 |
+ if (opt_x && typeof opt_x == 'object' && (typeof opt_x.top == 'number' || typeof opt_x.left == 'number')) { |
|
2261 |
+ return this.each(function (el) { |
|
2262 |
+ xy(el, opt_x.left, opt_x.top) |
|
2263 |
+ }) |
|
2264 |
+ } else if (typeof opt_x == 'number' || typeof opt_y == 'number') { |
|
2265 |
+ return this.each(function (el) { |
|
2266 |
+ xy(el, opt_x, opt_y) |
|
2267 |
+ }) |
|
2268 |
+ } |
|
2269 |
+ if (!this[0]) return { |
|
2270 |
+ top: 0 |
|
2271 |
+ , left: 0 |
|
2272 |
+ , height: 0 |
|
2273 |
+ , width: 0 |
|
2274 |
+ } |
|
2275 |
+ var el = this[0] |
|
2276 |
+ , de = el.ownerDocument.documentElement |
|
2277 |
+ , bcr = el.getBoundingClientRect() |
|
2278 |
+ , scroll = getWindowScroll() |
|
2279 |
+ , width = el.offsetWidth |
|
2280 |
+ , height = el.offsetHeight |
|
2281 |
+ , top = bcr.top + scroll.y - Math.max(0, de && de.clientTop, doc.body.clientTop) |
|
2282 |
+ , left = bcr.left + scroll.x - Math.max(0, de && de.clientLeft, doc.body.clientLeft) |
|
2283 |
+ |
|
2284 |
+ return { |
|
2285 |
+ top: top |
|
2286 |
+ , left: left |
|
2287 |
+ , height: height |
|
2288 |
+ , width: width |
|
2289 |
+ } |
|
2290 |
+ } |
|
2291 |
+ |
|
2292 |
+ |
|
2293 |
+ /** |
|
2294 |
+ * @return {number} |
|
2295 |
+ */ |
|
2296 |
+ , dim: function () { |
|
2297 |
+ if (!this.length) return { height: 0, width: 0 } |
|
2298 |
+ var el = this[0] |
|
2299 |
+ , de = el.nodeType == 9 && el.documentElement // document |
|
2300 |
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ? |
|
2301 |
+ // el isn't visible, can't be measured properly, so fix that |
|
2302 |
+ function (t) { |
|
2303 |
+ var s = { |
|
2304 |
+ position: el.style.position || '' |
|
2305 |
+ , visibility: el.style.visibility || '' |
|
2306 |
+ , display: el.style.display || '' |
|
2307 |
+ } |
|
2308 |
+ t.first().css({ |
|
2309 |
+ position: 'absolute' |
|
2310 |
+ , visibility: 'hidden' |
|
2311 |
+ , display: 'block' |
|
2312 |
+ }) |
|
2313 |
+ return s |
|
2314 |
+ }(this) : null |
|
2315 |
+ , width = de |
|
2316 |
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth) |
|
2317 |
+ : el.offsetWidth |
|
2318 |
+ , height = de |
|
2319 |
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight) |
|
2320 |
+ : el.offsetHeight |
|
2321 |
+ |
|
2322 |
+ orig && this.first().css(orig) |
|
2323 |
+ return { |
|
2324 |
+ height: height |
|
2325 |
+ , width: width |
|
2326 |
+ } |
|
2327 |
+ } |
|
2328 |
+ |
|
2329 |
+ // attributes are hard. go shopping |
|
2330 |
+ |
|
2331 |
+ /** |
|
2332 |
+ * @param {string} k an attribute to get or set |
|
2333 |
+ * @param {string=} opt_v the value to set |
|
2334 |
+ * @return {Bonzo|string} |
|
2335 |
+ */ |
|
2336 |
+ , attr: function (k, opt_v) { |
|
2337 |
+ var el = this[0] |
|
2338 |
+ if (typeof k != 'string' && !(k instanceof String)) { |
|
2339 |
+ for (var n in k) { |
|
2340 |
+ k.hasOwnProperty(n) && this.attr(n, k[n]) |
|
2341 |
+ } |
|
2342 |
+ return this |
|
2343 |
+ } |
|
2344 |
+ return typeof opt_v == 'undefined' ? |
|
2345 |
+ !el ? null : specialAttributes.test(k) ? |
|
2346 |
+ stateAttributes.test(k) && typeof el[k] == 'string' ? |
|
2347 |
+ true : el[k] : (k == 'href' || k =='src') && features.hrefExtended ? |
|
2348 |
+ el[getAttribute](k, 2) : el[getAttribute](k) : |
|
2349 |
+ this.each(function (el) { |
|
2350 |
+ specialAttributes.test(k) ? (el[k] = setter(el, opt_v)) : el[setAttribute](k, setter(el, opt_v)) |
|
2351 |
+ }) |
|
2352 |
+ } |
|
2353 |
+ |
|
2354 |
+ |
|
2355 |
+ /** |
|
2356 |
+ * @param {string} k |
|
2357 |
+ * @return {Bonzo} |
|
2358 |
+ */ |
|
2359 |
+ , removeAttr: function (k) { |
|
2360 |
+ return this.each(function (el) { |
|
2361 |
+ stateAttributes.test(k) ? (el[k] = false) : el.removeAttribute(k) |
|
2362 |
+ }) |
|
2363 |
+ } |
|
2364 |
+ |
|
2365 |
+ |
|
2366 |
+ /** |
|
2367 |
+ * @param {string=} opt_s |
|
2368 |
+ * @return {Bonzo|string} |
|
2369 |
+ */ |
|
2370 |
+ , val: function (s) { |
|
2371 |
+ return (typeof s == 'string') ? |
|
2372 |
+ this.attr('value', s) : |
|
2373 |
+ this.length ? this[0].value : null |
|
2374 |
+ } |
|
2375 |
+ |
|
2376 |
+ // use with care and knowledge. this data() method uses data attributes on the DOM nodes |
|
2377 |
+ // to do this differently costs a lot more code. c'est la vie |
|
2378 |
+ /** |
|
2379 |
+ * @param {string|Object=} opt_k the key for which to get or set data |
|
2380 |
+ * @param {Object=} opt_v |
|
2381 |
+ * @return {Bonzo|Object} |
|
2382 |
+ */ |
|
2383 |
+ , data: function (opt_k, opt_v) { |
|
2384 |
+ var el = this[0], o, m |
|
2385 |
+ if (typeof opt_v === 'undefined') { |
|
2386 |
+ if (!el) return null |
|
2387 |
+ o = data(el) |
|
2388 |
+ if (typeof opt_k === 'undefined') { |
|
2389 |
+ each(el.attributes, function (a) { |
|
2390 |
+ (m = ('' + a.name).match(dattr)) && (o[camelize(m[1])] = dataValue(a.value)) |
|
2391 |
+ }) |
|
2392 |
+ return o |
|
2393 |
+ } else { |
|
2394 |
+ if (typeof o[opt_k] === 'undefined') |
|
2395 |
+ o[opt_k] = dataValue(this.attr('data-' + decamelize(opt_k))) |
|
2396 |
+ return o[opt_k] |
|
2397 |
+ } |
|
2398 |
+ } else { |
|
2399 |
+ return this.each(function (el) { data(el)[opt_k] = opt_v }) |
|
2400 |
+ } |
|
2401 |
+ } |
|
2402 |
+ |
|
2403 |
+ // DOM detachment & related |
|
2404 |
+ |
|
2405 |
+ /** |
|
2406 |
+ * @return {Bonzo} |
|
2407 |
+ */ |
|
2408 |
+ , remove: function () { |
|
2409 |
+ this.deepEach(clearData) |
|
2410 |
+ return this.detach() |
|
2411 |
+ } |
|
2412 |
+ |
|
2413 |
+ |
|
2414 |
+ /** |
|
2415 |
+ * @return {Bonzo} |
|
2416 |
+ */ |
|
2417 |
+ , empty: function () { |
|
2418 |
+ return this.each(function (el) { |
|
2419 |
+ deepEach(el.childNodes, clearData) |
|
2420 |
+ |
|
2421 |
+ while (el.firstChild) { |
|
2422 |
+ el.removeChild(el.firstChild) |
|
2423 |
+ } |
|
2424 |
+ }) |
|
2425 |
+ } |
|
2426 |
+ |
|
2427 |
+ |
|
2428 |
+ /** |
|
2429 |
+ * @return {Bonzo} |
|
2430 |
+ */ |
|
2431 |
+ , detach: function () { |
|
2432 |
+ return this.each(function (el) { |
|
2433 |
+ el[parentNode] && el[parentNode].removeChild(el) |
|
2434 |
+ }) |
|
2435 |
+ } |
|
2436 |
+ |
|
2437 |
+ // who uses a mouse anyway? oh right. |
|
2438 |
+ |
|
2439 |
+ /** |
|
2440 |
+ * @param {number} y |
|
2441 |
+ */ |
|
2442 |
+ , scrollTop: function (y) { |
|
2443 |
+ return scroll.call(this, null, y, 'y') |
|
2444 |
+ } |
|
2445 |
+ |
|
2446 |
+ |
|
2447 |
+ /** |
|
2448 |
+ * @param {number} x |
|
2449 |
+ */ |
|
2450 |
+ , scrollLeft: function (x) { |
|
2451 |
+ return scroll.call(this, x, null, 'x') |
|
2452 |
+ } |
|
2453 |
+ |
|
2454 |
+ } |
|
2455 |
+ |
|
2456 |
+ |
|
2457 |
+ function cloneNode(host, el) { |
|
2458 |
+ var c = el.cloneNode(true) |
|
2459 |
+ , cloneElems |
|
2460 |
+ , elElems |
|
2461 |
+ |
|
2462 |
+ // check for existence of an event cloner |
|
2463 |
+ // preferably https://github.com/fat/bean |
|
2464 |
+ // otherwise Bonzo won't do this for you |
|
2465 |
+ if (host.$ && typeof host.cloneEvents == 'function') { |
|
2466 |
+ host.$(c).cloneEvents(el) |
|
2467 |
+ |
|
2468 |
+ // clone events from every child node |
|
2469 |
+ cloneElems = host.$(c).find('*') |
|
2470 |
+ elElems = host.$(el).find('*') |
|
2471 |
+ |
|
2472 |
+ for (var i = 0; i < elElems.length; i++) |
|
2473 |
+ host.$(cloneElems[i]).cloneEvents(elElems[i]) |
|
984 | 2474 |
} |
2475 |
+ return c |
|
985 | 2476 |
} |
986 |
- return e; |
|
987 |
- }; |
|
988 |
- |
|
989 |
- bonzo.viewport = function () { |
|
990 |
- var h = self.innerHeight, |
|
991 |
- w = self.innerWidth; |
|
992 |
- ie && (h = html.clientHeight) && (w = html.clientWidth); |
|
993 |
- return { |
|
994 |
- width: w, |
|
995 |
- height: h |
|
996 |
- }; |
|
997 |
- }; |
|
998 |
- |
|
999 |
- bonzo.isAncestor = 'compareDocumentPosition' in html ? |
|
1000 |
- function (container, element) { |
|
1001 |
- return (container.compareDocumentPosition(element) & 16) == 16; |
|
1002 |
- } : 'contains' in html ? |
|
1003 |
- function (container, element) { |
|
1004 |
- return container !== element && container.contains(element); |
|
1005 |
- } : |
|
1006 |
- function (container, element) { |
|
1007 |
- while (element = element.parentNode) { |
|
1008 |
- if (element === container) { |
|
1009 |
- return true; |
|
1010 |
- } |
|
1011 |
- } |
|
1012 |
- return false; |
|
1013 |
- }; |
|
1014 |
- |
|
1015 |
- var old = context.bonzo; |
|
1016 |
- bonzo.noConflict = function () { |
|
1017 |
- context.bonzo = old; |
|
1018 |
- return this; |
|
1019 |
- }; |
|
1020 |
- context['bonzo'] = bonzo; |
|
1021 |
- |
|
1022 |
-}(this);!function ($) { |
|
1023 |
- |
|
1024 |
- var b = bonzo; |
|
1025 |
- b.setQueryEngine($); |
|
1026 |
- $.ender(b); |
|
1027 |
- $.ender(b(), true); |
|
1028 |
- $.ender({ |
|
1029 |
- create: function (node) { |
|
1030 |
- return $(b.create(node)); |
|
2477 |
+ |
|
2478 |
+ function scroll(x, y, type) { |
|
2479 |
+ var el = this[0] |
|
2480 |
+ if (!el) return this |
|
2481 |
+ if (x == null && y == null) { |
|
2482 |
+ return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type] |
|
2483 |
+ } |
|
2484 |
+ if (isBody(el)) { |
|
2485 |
+ win.scrollTo(x, y) |
|
2486 |
+ } else { |
|
2487 |
+ x != null && (el.scrollLeft = x) |
|
2488 |
+ y != null && (el.scrollTop = y) |
|
2489 |
+ } |
|
2490 |
+ return this |
|
1031 | 2491 |
} |
1032 |
- }); |
|
1033 |
- |
|
1034 |
- $.id = function (id) { |
|
1035 |
- return $([document.getElementById(id)]); |
|
1036 |
- }; |
|
1037 |
- |
|
1038 |
- function indexOf(ar, val) { |
|
1039 |
- for (var i = 0; i < ar.length; i++) { |
|
1040 |
- if (ar[i] === val) { |
|
1041 |
- return i; |
|
2492 |
+ |
|
2493 |
+ function isBody(element) { |
|
2494 |
+ return element === win || (/^(?:body|html)$/i).test(element.tagName) |
|
2495 |
+ } |
|
2496 |
+ |
|
2497 |
+ function getWindowScroll() { |
|
2498 |
+ return { x: win.pageXOffset || html.scrollLeft, y: win.pageYOffset || html.scrollTop } |
|
2499 |
+ } |
|
2500 |
+ |
|
2501 |
+ function createScriptFromHtml(html) { |
|
2502 |
+ var scriptEl = document.createElement('script') |
|
2503 |
+ , matches = html.match(simpleScriptTagRe) |
|
2504 |
+ scriptEl.src = matches[1] |
|
2505 |
+ return scriptEl |
|
2506 |
+ } |
|
2507 |
+ |
|
2508 |
+ /** |
|
2509 |
+ * @param {Array.<Element>|Element|Node|string} els |
|
2510 |
+ * @return {Bonzo} |
|
2511 |
+ */ |
|
2512 |
+ function bonzo(els) { |
|
2513 |
+ return new Bonzo(els) |
|
2514 |
+ } |
|
2515 |
+ |
|
2516 |
+ bonzo.setQueryEngine = function (q) { |
|
2517 |
+ query = q; |
|
2518 |
+ delete bonzo.setQueryEngine |
|
2519 |
+ } |
|
2520 |
+ |
|
2521 |
+ bonzo.aug = function (o, target) { |
|
2522 |
+ // for those standalone bonzo users. this love is for you. |
|
2523 |
+ for (var k in o) { |
|
2524 |
+ o.hasOwnProperty(k) && ((target || Bonzo.prototype)[k] = o[k]) |
|
1042 | 2525 |
} |
1043 | 2526 |
} |
1044 |
- return -1; |
|
1045 |
- } |
|
1046 |
- |
|
1047 |
- function uniq(ar) { |
|
1048 |
- var a = [], i, j; |
|
1049 |
- label: |
|
1050 |
- for (i = 0; i < ar.length; i++) { |
|
1051 |
- for (j = 0; j < a.length; j++) { |
|
1052 |
- if (a[j] == ar[i]) { |
|
1053 |
- continue label; |
|
2527 |
+ |
|
2528 |
+ bonzo.create = function (node) { |
|
2529 |
+ // hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh |
|
2530 |
+ return typeof node == 'string' && node !== '' ? |
|
2531 |
+ function () { |
|
2532 |
+ if (simpleScriptTagRe.test(node)) return [createScriptFromHtml(node)] |
|
2533 |
+ var tag = node.match(/^\s*<([^\s>]+)/) |
|
2534 |
+ , el = doc.createElement('div') |
|
2535 |
+ , els = [] |
|
2536 |
+ , p = tag ? tagMap[tag[1].toLowerCase()] : null |
|
2537 |
+ , dep = p ? p[2] + 1 : 1 |
|
2538 |
+ , ns = p && p[3] |
|
2539 |
+ , pn = parentNode |
|
2540 |
+ , tb = features.autoTbody && p && p[0] == '<table>' && !(/<tbody/i).test(node) |
|
2541 |
+ |
|
2542 |
+ el.innerHTML = p ? (p[0] + node + p[1]) : node |
|
2543 |
+ while (dep--) el = el.firstChild |
|
2544 |
+ // for IE NoScope, we may insert cruft at the begining just to get it to work |
|
2545 |
+ if (ns && el && el.nodeType !== 1) el = el.nextSibling |
|
2546 |
+ do { |
|
2547 |
+ // tbody special case for IE<8, creates tbody on any empty table |
|
2548 |
+ // we don't want it if we're just after a <thead>, <caption>, etc. |
|
2549 |
+ if ((!tag || el.nodeType == 1) && (!tb || el.tagName.toLowerCase() != 'tbody')) { |
|
2550 |
+ els.push(el) |
|
2551 |
+ } |
|
2552 |
+ } while (el = el.nextSibling) |
|
2553 |
+ // IE < 9 gives us a parentNode which messes up insert() check for cloning |
|
2554 |
+ // `dep` > 1 can also cause problems with the insert() check (must do this last) |
|
2555 |
+ each(els, function(el) { el[pn] && el[pn].removeChild(el) }) |
|
2556 |
+ return els |
|
2557 |
+ }() : isNode(node) ? [node.cloneNode(true)] : [] |
|
2558 |
+ } |
|
2559 |
+ |
|
2560 |
+ bonzo.doc = function () { |
|
2561 |
+ var vp = bonzo.viewport() |
|
2562 |
+ return { |
|
2563 |
+ width: Math.max(doc.body.scrollWidth, html.scrollWidth, vp.width) |
|
2564 |
+ , height: Math.max(doc.body.scrollHeight, html.scrollHeight, vp.height) |
|
2565 |
+ } |
|
2566 |
+ } |
|
2567 |
+ |
|
2568 |
+ bonzo.firstChild = function (el) { |
|
2569 |
+ for (var c = el.childNodes, i = 0, j = (c && c.length) || 0, e; i < j; i++) { |
|
2570 |
+ if (c[i].nodeType === 1) e = c[j = i] |
|
2571 |
+ } |
|
2572 |
+ return e |
|
2573 |
+ } |
|
2574 |
+ |
|
2575 |
+ bonzo.viewport = function () { |
|
2576 |
+ return { |
|
2577 |
+ width: ie ? html.clientWidth : self.innerWidth |
|
2578 |
+ , height: ie ? html.clientHeight : self.innerHeight |
|
2579 |
+ } |
|
2580 |
+ } |
|
2581 |
+ |
|
2582 |
+ bonzo.isAncestor = 'compareDocumentPosition' in html ? |
|
2583 |
+ function (container, element) { |
|
2584 |
+ return (container.compareDocumentPosition(element) & 16) == 16 |
|
2585 |
+ } : 'contains' in html ? |
|
2586 |
+ function (container, element) { |
|
2587 |
+ return container !== element && container.contains(element); |
|
2588 |
+ } : |
|
2589 |
+ function (container, element) { |
|
2590 |
+ while (element = element[parentNode]) { |
|
2591 |
+ if (element === container) { |
|
2592 |
+ return true |
|
2593 |
+ } |
|
1054 | 2594 |
} |
2595 |
+ return false |
|
2596 |
+ } |
|
2597 |
+ |
|
2598 |
+ return bonzo |
|
2599 |
+ }); // the only line we care about using a semi-colon. placed here for concatenation tools |
|
2600 |
+ |
|
2601 |
+ |
|
2602 |
+ provide("bonzo", module.exports); |
|
2603 |
+ |
|
2604 |
+ (function ($) { |
|
2605 |
+ |
|
2606 |
+ var b = require('bonzo') |
|
2607 |
+ b.setQueryEngine($) |
|
2608 |
+ $.ender(b) |
|
2609 |
+ $.ender(b(), true) |
|
2610 |
+ $.ender({ |
|
2611 |
+ create: function (node) { |
|
2612 |
+ return $(b.create(node)) |
|
1055 | 2613 |
} |
1056 |
- a[a.length] = ar[i]; |
|
2614 |
+ }) |
|
2615 |
+ |
|
2616 |
+ $.id = function (id) { |
|
2617 |
+ return $([document.getElementById(id)]) |
|
1057 | 2618 |
} |
1058 |
- return a; |
|
1059 |
- } |
|
1060 |
- |
|
1061 |
- $.ender({ |
|
1062 |
- parents: function (selector, closest) { |
|
1063 |
- var collection = $(selector), j, k, p, r = []; |
|
1064 |
- for (j = 0, k = this.length; j < k; j++) { |
|
1065 |
- p = this[j]; |
|
1066 |
- while (p = p.parentNode) { |
|
1067 |
- if (indexOf(collection, p) !== -1) { |
|
1068 |
- r.push(p); |
|
1069 |
- if (closest) break; |
|
2619 |
+ |
|
2620 |
+ function indexOf(ar, val) { |
|
2621 |
+ for (var i = 0; i < ar.length; i++) if (ar[i] === val) return i |
|
2622 |
+ return -1 |
|
2623 |
+ } |
|
2624 |
+ |
|
2625 |
+ function uniq(ar) { |
|
2626 |
+ var r = [], i = 0, j = 0, k, item, inIt |
|
2627 |
+ for (; item = ar[i]; ++i) { |
|
2628 |
+ inIt = false |
|
2629 |
+ for (k = 0; k < r.length; ++k) { |
|
2630 |
+ if (r[k] === item) { |
|
2631 |
+ inIt = true; break |
|
1070 | 2632 |
} |
1071 | 2633 |
} |
2634 |
+ if (!inIt) r[j++] = item |
|
1072 | 2635 |
} |
1073 |
- return $(uniq(r)); |
|
1074 |
- }, |
|
1075 |
- |
|
1076 |
- closest: function (selector) { |
|
1077 |
- return this.parents(selector, true); |
|
1078 |
- }, |
|
1079 |
- |
|
1080 |
- first: function () { |
|
1081 |
- return $(this[0]); |
|
1082 |
- }, |
|
1083 |
- |
|
1084 |
- last: function () { |
|
1085 |
- return $(this[this.length - 1]); |
|
1086 |
- }, |
|
1087 |
- |
|
1088 |
- next: function () { |
|
1089 |
- return $(b(this).next()); |
|
1090 |
- }, |
|
1091 |
- |
|
1092 |
- previous: function () { |
|
1093 |
- return $(b(this).previous()); |
|
1094 |
- }, |
|
1095 |
- |
|
1096 |
- appendTo: function (t) { |
|
1097 |
- return b(this.selector).appendTo(t, this); |
|
1098 |
- }, |
|
1099 |
- |
|
1100 |
- prependTo: function (t) { |
|
1101 |
- return b(this.selector).prependTo(t, this); |
|
1102 |
- }, |
|
1103 |
- |
|
1104 |
- insertAfter: function (t) { |
|
1105 |
- return b(this.selector).insertAfter(t, this); |
|
1106 |
- }, |
|
1107 |
- |
|
1108 |
- insertBefore: function (t) { |
|
1109 |
- return b(this.selector).insertBefore(t, this); |
|
1110 |
- }, |
|
1111 |
- |
|
1112 |
- siblings: function () { |
|
1113 |
- var i, l, p, r = []; |
|
1114 |
- for (i = 0, l = this.length; i < l; i++) { |
|
1115 |
- p = this[i]; |
|
1116 |
- while (p = p.previousSibling) { |
|
1117 |
- p.nodeType == 1 && r.push(p); |
|
2636 |
+ return r |
|
2637 |
+ } |
|
2638 |
+ |
|
2639 |
+ $.ender({ |
|
2640 |
+ parents: function (selector, closest) { |
|
2641 |
+ if (!this.length) return this |
|
2642 |
+ if (!selector) selector = '*' |
|
2643 |
+ var collection = $(selector), j, k, p, r = [] |
|
2644 |
+ for (j = 0, k = this.length; j < k; j++) { |
|
2645 |
+ p = this[j] |
|
2646 |
+ while (p = p.parentNode) { |
|
2647 |
+ if (~indexOf(collection, p)) { |
|
2648 |
+ r.push(p) |
|
2649 |
+ if (closest) break; |
|
2650 |
+ } |
|
2651 |
+ } |
|
1118 | 2652 |
} |
1119 |
- p = this[i]; |
|
1120 |
- while (p = p.nextSibling) { |
|
1121 |
- p.nodeType == 1 && r.push(p); |
|
2653 |
+ return $(uniq(r)) |
|
2654 |
+ } |
|
2655 |
+ |
|
2656 |
+ , parent: function() { |
|
2657 |
+ return $(uniq(b(this).parent())) |
|
2658 |
+ } |
|
2659 |
+ |
|
2660 |
+ , closest: function (selector) { |
|
2661 |
+ return this.parents(selector, true) |
|
2662 |
+ } |
|
2663 |
+ |
|
2664 |
+ , first: function () { |
|
2665 |
+ return $(this.length ? this[0] : this) |
|
2666 |
+ } |
|
2667 |
+ |
|
2668 |
+ , last: function () { |
|
2669 |
+ return $(this.length ? this[this.length - 1] : []) |
|
2670 |
+ } |
|
2671 |
+ |
|
2672 |
+ , next: function () { |
|
2673 |
+ return $(b(this).next()) |
|
2674 |
+ } |
|
2675 |
+ |
|
2676 |
+ , previous: function () { |
|
2677 |
+ return $(b(this).previous()) |
|
2678 |
+ } |
|
2679 |
+ |
|
2680 |
+ , appendTo: function (t) { |
|
2681 |
+ return b(this.selector).appendTo(t, this) |
|
2682 |
+ } |
|
2683 |
+ |
|
2684 |
+ , prependTo: function (t) { |
|
2685 |
+ return b(this.selector).prependTo(t, this) |
|
2686 |
+ } |
|
2687 |
+ |
|
2688 |
+ , insertAfter: function (t) { |
|
2689 |
+ return b(this.selector).insertAfter(t, this) |
|
2690 |
+ } |
|
2691 |
+ |
|
2692 |
+ , insertBefore: function (t) { |
|
2693 |
+ return b(this.selector).insertBefore(t, this) |
|
2694 |
+ } |
|
2695 |
+ |
|
2696 |
+ , siblings: function () { |
|
2697 |
+ var i, l, p, r = [] |
|
2698 |
+ for (i = 0, l = this.length; i < l; i++) { |
|
2699 |
+ p = this[i] |
|
2700 |
+ while (p = p.previousSibling) p.nodeType == 1 && r.push(p) |
|
2701 |
+ p = this[i] |
|
2702 |
+ while (p = p.nextSibling) p.nodeType == 1 && r.push(p) |
|
1122 | 2703 |
} |
2704 |
+ return $(r) |
|
1123 | 2705 |
} |
1124 |
- return $(r); |
|
1125 |
- }, |
|
1126 |
- |
|
1127 |
- children: function () { |
|
1128 |
- var el, r = []; |
|
1129 |
- for (i = 0, l = this.length; i < l; i++) { |
|
1130 |
- if (!(el = b.firstChild(this[i]))) { |
|
1131 |
- continue; |
|
2706 |
+ |
|
2707 |
+ , children: function () { |
|
2708 |
+ var i, l, el, r = [] |
|
2709 |
+ for (i = 0, l = this.length; i < l; i++) { |
|
2710 |
+ if (!(el = b.firstChild(this[i]))) continue; |
|
2711 |
+ r.push(el) |
|
2712 |
+ while (el = el.nextSibling) el.nodeType == 1 && r.push(el) |
|
1132 | 2713 |
} |
1133 |
- r.push(el); |
|
1134 |
- while (el = el.nextSibling) { |
|
1135 |
- el.nodeType == 1 && r.push(el); |
|
2714 |
+ return $(uniq(r)) |
|
2715 |
+ } |
|
2716 |
+ |
|
2717 |
+ , height: function (v) { |
|
2718 |
+ return dimension.call(this, 'height', v) |
|
2719 |
+ } |
|
2720 |
+ |
|
2721 |
+ , width: function (v) { |
|
2722 |
+ return dimension.call(this, 'width', v) |
|
2723 |
+ } |
|
2724 |
+ }, true) |
|
2725 |
+ |
|
2726 |
+ /** |
|
2727 |
+ * @param {string} type either width or height |
|
2728 |
+ * @param {number=} opt_v becomes a setter instead of a getter |
|
2729 |
+ * @return {number} |
|
2730 |
+ */ |
|
2731 |
+ function dimension(type, opt_v) { |
|
2732 |
+ return typeof opt_v == 'undefined' |
|
2733 |
+ ? b(this).dim()[type] |
|
2734 |
+ : this.css(type, opt_v) |
|
2735 |
+ } |
|
2736 |
+ }(ender)); |
|
2737 |
+ |
|
2738 |
+}()); |
|
2739 |
+ |
|
2740 |
+(function () { |
|
2741 |
+ |
|
2742 |
+ var module = { exports: {} }, exports = module.exports; |
|
2743 |
+ |
|
2744 |
+ /*! |
|
2745 |
+ * domready (c) Dustin Diaz 2012 - License MIT |
|
2746 |
+ */ |
|
2747 |
+ !function (name, definition) { |
|
2748 |
+ if (typeof module != 'undefined') module.exports = definition() |
|
2749 |
+ else if (typeof define == 'function' && typeof define.amd == 'object') define(definition) |
|
2750 |
+ else this[name] = definition() |
|
2751 |
+ }('domready', function (ready) { |
|
2752 |
+ |
|
2753 |
+ var fns = [], fn, f = false |
|
2754 |
+ , doc = document |
|
2755 |
+ , testEl = doc.documentElement |
|
2756 |
+ , hack = testEl.doScroll |
|
2757 |
+ , domContentLoaded = 'DOMContentLoaded' |
|
2758 |
+ , addEventListener = 'addEventListener' |
|
2759 |
+ , onreadystatechange = 'onreadystatechange' |
|
2760 |
+ , readyState = 'readyState' |
|
2761 |
+ , loaded = /^loade|c/.test(doc[readyState]) |
|
2762 |
+ |
|
2763 |
+ function flush(f) { |
|
2764 |
+ loaded = 1 |
|
2765 |
+ while (f = fns.shift()) f() |
|
2766 |
+ } |
|
2767 |
+ |
|
2768 |
+ doc[addEventListener] && doc[addEventListener](domContentLoaded, fn = function () { |
|
2769 |
+ doc.removeEventListener(domContentLoaded, fn, f) |
|
2770 |
+ flush() |
|
2771 |
+ }, f) |
|
2772 |
+ |
|
2773 |
+ |
|
2774 |
+ hack && doc.attachEvent(onreadystatechange, fn = function () { |
|
2775 |
+ if (/^c/.test(doc[readyState])) { |
|
2776 |
+ doc.detachEvent(onreadystatechange, fn) |
|
2777 |
+ flush() |
|
2778 |
+ } |
|
2779 |
+ }) |
|
2780 |
+ |
|
2781 |
+ return (ready = hack ? |
|
2782 |
+ function (fn) { |
|
2783 |
+ self != top ? |
|
2784 |
+ loaded ? fn() : fns.push(fn) : |
|
2785 |
+ function () { |
|
2786 |
+ try { |
|
2787 |
+ testEl.doScroll('left') |
|
2788 |
+ } catch (e) { |
|
2789 |
+ return setTimeout(function() { ready(fn) }, 50) |
|
2790 |
+ } |
|
2791 |
+ fn() |
|
2792 |
+ }() |
|
2793 |
+ } : |
|
2794 |
+ function (fn) { |
|
2795 |
+ loaded ? fn() : fns.push(fn) |
|
2796 |
+ }) |
|
2797 |
+ }) |
|
2798 |
+ |
|
2799 |
+ provide("domready", module.exports); |
|
2800 |
+ |
|
2801 |
+ !function ($) { |
|
2802 |
+ var ready = require('domready') |
|
2803 |
+ $.ender({domReady: ready}) |
|
2804 |
+ $.ender({ |
|
2805 |
+ ready: function (f) { |
|
2806 |
+ ready(f) |
|
2807 |
+ return this |
|
2808 |
+ } |
|
2809 |
+ }, true) |
|
2810 |
+ }(ender); |
|
2811 |
+ |
|
2812 |
+}()); |
|
2813 |
+ |
|
2814 |
+(function () { |
|
2815 |
+ |
|
2816 |
+ var module = { exports: {} }, exports = module.exports; |
|
2817 |
+ |
|
2818 |
+ /*! |
|
2819 |
+ * @preserve Qwery - A Blazing Fast query selector engine |
|
2820 |
+ * https://github.com/ded/qwery |
|
2821 |
+ * copyright Dustin Diaz 2012 |
|
2822 |
+ * MIT License |
|
2823 |
+ */ |
|
2824 |
+ |
|
2825 |
+ (function (name, context, definition) { |
|
2826 |
+ if (typeof module != 'undefined' && module.exports) module.exports = definition() |
|
2827 |
+ else if (typeof context['define'] == 'function' && context['define']['amd']) define(definition) |
|
2828 |
+ else context[name] = definition() |
|
2829 |
+ })('qwery', this, function () { |
|
2830 |
+ var doc = document |
|
2831 |
+ , html = doc.documentElement |
|
2832 |
+ , byClass = 'getElementsByClassName' |
|
2833 |
+ , byTag = 'getElementsByTagName' |
|
2834 |
+ , qSA = 'querySelectorAll' |
|
2835 |
+ , useNativeQSA = 'useNativeQSA' |
|
2836 |
+ , tagName = 'tagName' |
|
2837 |
+ , nodeType = 'nodeType' |
|
2838 |
+ , select // main select() method, assign later |
|
2839 |
+ |
|
2840 |
+ , id = /#([\w\-]+)/ |
|
2841 |
+ , clas = /\.[\w\-]+/g |
|
2842 |
+ , idOnly = /^#([\w\-]+)$/ |
|
2843 |
+ , classOnly = /^\.([\w\-]+)$/ |
|
2844 |
+ , tagOnly = /^([\w\-]+)$/ |
|
2845 |
+ , tagAndOrClass = /^([\w]+)?\.([\w\-]+)$/ |
|
2846 |
+ , splittable = /(^|,)\s*[>~+]/ |
|
2847 |
+ , normalizr = /^\s+|\s*([,\s\+\~>]|$)\s*/g |
|
2848 |
+ , splitters = /[\s\>\+\~]/ |
|
2849 |
+ , splittersMore = /(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/ |
|
2850 |
+ , specialChars = /([.*+?\^=!:${}()|\[\]\/\\])/g |
|
2851 |
+ , simple = /^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/ |
|
2852 |
+ , attr = /\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/ |
|
2853 |
+ , pseudo = /:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/ |
|
2854 |
+ , easy = new RegExp(idOnly.source + '|' + tagOnly.source + '|' + classOnly.source) |
|
2855 |
+ , dividers = new RegExp('(' + splitters.source + ')' + splittersMore.source, 'g') |
|
2856 |
+ , tokenizr = new RegExp(splitters.source + splittersMore.source) |
|
2857 |
+ , chunker = new RegExp(simple.source + '(' + attr.source + ')?' + '(' + pseudo.source + ')?') |
|
2858 |
+ |
|
2859 |
+ var walker = { |
|
2860 |
+ ' ': function (node) { |
|
2861 |
+ return node && node !== html && node.parentNode |
|
2862 |
+ } |
|
2863 |
+ , '>': function (node, contestant) { |
|
2864 |
+ return node && node.parentNode == contestant.parentNode && node.parentNode |
|
2865 |
+ } |
|
2866 |
+ , '~': function (node) { |
|
2867 |
+ return node && node.previousSibling |
|
2868 |
+ } |
|
2869 |
+ , '+': function (node, contestant, p1, p2) { |
|
2870 |
+ if (!node) return false |
|
2871 |
+ return (p1 = previous(node)) && (p2 = previous(contestant)) && p1 == p2 && p1 |
|
1136 | 2872 |
} |
1137 | 2873 |
} |
1138 |
- return $(uniq(r)); |
|
1139 |
- }, |
|
1140 |
- |
|
1141 |
- height: function (v) { |
|
1142 |
- return v ? this.css('height', v) : parseInt(this.css('height'), 10); |
|
1143 |
- }, |
|
1144 |
- |
|
1145 |
- width: function (v) { |
|
1146 |
- return v ? this.css('width', v) : parseInt(this.css('width'), 10); |
|
2874 |
+ |
|
2875 |
+ function cache() { |
|
2876 |
+ this.c = {} |
|
1147 | 2877 |
} |
1148 |
- }, true); |
|
1149 |
- |
|
1150 |
-}(ender || $); |
|
1151 |
- |
|
1152 |
-!function () { var exports = {}, module = { exports: exports }; !function (doc) { |
|
1153 |
- var loaded = 0, fns = [], ol, f = false, |
|
1154 |
- testEl = doc.createElement('a'), |
|
1155 |
- domContentLoaded = 'DOMContentLoaded', |
|
1156 |
- addEventListener = 'addEventListener', |
|
1157 |
- onreadystatechange = 'onreadystatechange'; |
|
1158 |
- |
|
1159 |
- /^loade|c/.test(doc.readyState) && (loaded = 1); |
|
1160 |
- |
|
1161 |
- function flush() { |
|
1162 |
- loaded = 1; |
|
1163 |
- for (var i = 0, l = fns.length; i < l; i++) { |
|
1164 |
- fns[i](); |
|
2878 |
+ cache.prototype = { |
|
2879 |
+ g: function (k) { |
|
2880 |
+ return this.c[k] || undefined |
|
2881 |
+ } |
|
2882 |
+ , s: function (k, v, r) { |
|
2883 |
+ v = r ? new RegExp(v) : v |
|
2884 |
+ return (this.c[k] = v) |
|
2885 |
+ } |
|
1165 | 2886 |
} |
1166 |
- } |
|
1167 |
- doc[addEventListener] && doc[addEventListener](domContentLoaded, function fn() { |
|
1168 |
- doc.removeEventListener(domContentLoaded, fn, f); |
|
1169 |
- flush(); |
|
1170 |
- }, f); |
|
1171 |
- |
|
1172 |
- |
|
1173 |
- testEl.doScroll && doc.attachEvent(onreadystatechange, (ol = function ol() { |
|
1174 |
- if (/^c/.test(doc.readyState)) { |
|
1175 |
- doc.detachEvent(onreadystatechange, ol); |
|
1176 |
- flush(); |
|
2887 |
+ |
|
2888 |
+ var classCache = new cache() |
|
2889 |
+ , cleanCache = new cache() |
|
2890 |
+ , attrCache = new cache() |
|
2891 |
+ , tokenCache = new cache() |
|
2892 |
+ |
|
2893 |
+ function classRegex(c) { |
|
2894 |
+ return classCache.g(c) || classCache.s(c, '(^|\\s+)' + c + '(\\s+|$)', 1) |
|
1177 | 2895 |
} |
1178 |
- })); |
|
1179 |
- |
|
1180 |
- var domReady = testEl.doScroll ? |
|
1181 |
- function (fn) { |
|
1182 |
- self != top ? |
|
1183 |
- !loaded ? |
|
1184 |
- fns.push(fn) : |
|
1185 |
- fn() : |
|
1186 |
- !function () { |
|
1187 |
- try { |
|
1188 |
- testEl.doScroll('left'); |
|
1189 |
- } catch (e) { |
|
1190 |
- return setTimeout(function() { |
|
1191 |
- domReady(fn); |
|
1192 |
- }, 50); |
|
1193 |
- } |
|
1194 |
- fn(); |
|
1195 |
- }(); |
|
1196 |
- } : |
|
1197 |
- function (fn) { |
|
1198 |
- loaded ? fn() : fns.push(fn); |
|
1199 |
- }; |
|
1200 |
- |
|
1201 |
- (typeof module !== 'undefined') && module.exports ? |
|
1202 |
- (module.exports = {domReady: domReady}) : |
|
1203 |
- (window.domReady = domReady); |
|
1204 |
- |
|
1205 |
-}(document); $.ender(module.exports); }.call($); |
|
1206 |
-/*! |
|
1207 |
- * qwery.js - copyright @dedfat |
|
1208 |
- * https://github.com/ded/qwery |
|
1209 |
- * Follow our software http://twitter.com/dedfat |
|
1210 |
- * MIT License |
|
1211 |
- */ |
|
1212 |
- |
|
1213 |
-!function (context, doc) { |
|
1214 |
- |
|
1215 |
- var c, i, j, k, l, m, o, p, r, v, |
|
1216 |
- el, node, len, found, classes, item, items, token, |
|
1217 |
- id = /#([\w\-]+)/, |
|
1218 |
- clas = /\.[\w\-]+/g, |
|
1219 |
- idOnly = /^#([\w\-]+$)/, |
|
1220 |
- classOnly = /^\.([\w\-]+)$/, |
|
1221 |
- tagOnly = /^([\w\-]+)$/, |
|
1222 |
- tagAndOrClass = /^([\w]+)?\.([\w\-]+)$/, |
|
1223 |
- html = doc.documentElement, |
|
1224 |
- tokenizr = /\s(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\])/, |
|
1225 |
- specialChars = /([.*+?\^=!:${}()|\[\]\/\\])/g, |
|
1226 |
- simple = /^([a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/, |
|
1227 |
- attr = /\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/, |
|
1228 |
- chunker = new RegExp(simple.source + '(' + attr.source + ')?'); |
|
1229 |
- |
|
1230 |
- function array(ar) { |
|
1231 |
- r = []; |
|
1232 |
- for (i = 0, len = ar.length; i < len; i++) { |
|
1233 |
- r[i] = ar[i]; |
|
2896 |
+ |
|
2897 |
+ // not quite as fast as inline loops in older browsers so don't use liberally |
|
2898 |
+ function each(a, fn) { |
|
2899 |
+ var i = 0, l = a.length |
|
2900 |
+ for (; i < l; i++) fn(a[i]) |
|
1234 | 2901 |
} |
1235 |
- return r; |
|
1236 |
- } |
|
1237 |
- |
|
1238 |
- var cache = function () { |
|
1239 |
- this.c = {}; |
|
1240 |
- }; |
|
1241 |
- cache.prototype = { |
|
1242 |
- g: function (k) { |
|
1243 |
- return this.c[k] || undefined; |
|
1244 |
- }, |
|
1245 |
- s: function (k, v) { |
|
1246 |
- this.c[k] = v; |
|
1247 |
- return v; |
|
1248 |
- } |
|
1249 |
- }; |
|
1250 |
- |
|
1251 |
- var classCache = new cache(), |
|
1252 |
- cleanCache = new cache(), |
|
1253 |
- attrCache = new cache(), |
|
1254 |
- tokenCache = new cache(); |
|
1255 |
- |
|
1256 |
- function q(query) { |
|
1257 |
- return query.match(chunker); |
|
1258 |
- } |
|
1259 |
- |
|
1260 |
- function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value) { |
|
1261 |
- var m, c, k; |
|
1262 |
- if (tag && this.tagName.toLowerCase() !== tag) { |
|
1263 |
- return false; |
|
2902 |
+ |
|
2903 |
+ function flatten(ar) { |
|
2904 |
+ for (var r = [], i = 0, l = ar.length; i < l; ++i) arrayLike(ar[i]) ? (r = r.concat(ar[i])) : (r[r.length] = ar[i]) |
|
2905 |
+ return r |
|
1264 | 2906 |
} |
1265 |
- if (idsAndClasses && (m = idsAndClasses.match(id)) && m[1] !== this.id) { |
|
1266 |
- return false; |
|
2907 |
+ |
|
2908 |
+ function arrayify(ar) { |
|
2909 |
+ var i = 0, l = ar.length, r = [] |
|
2910 |
+ for (; i < l; i++) r[i] = ar[i] |
|
2911 |
+ return r |
|
1267 | 2912 |
} |
1268 |
- if (idsAndClasses && (classes = idsAndClasses.match(clas))) { |
|
1269 |
- for (i = classes.length; i--;) { |
|
1270 |
- c = classes[i].slice(1); |
|
1271 |
- if (!(classCache.g(c) || classCache.s(c, new RegExp('(^|\\s+)' + c + '(\\s+|$)'))).test(this.className)) { |
|
1272 |
- return false; |
|
1273 |
- } |
|
1274 |
- } |
|
2913 |
+ |
|
2914 |
+ function previous(n) { |
|
2915 |
+ while (n = n.previousSibling) if (n[nodeType] == 1) break; |
|
2916 |
+ return n |
|
1275 | 2917 |
} |
1276 |
- if (wholeAttribute && !value) { |
|
1277 |
- o = this.attributes; |
|
1278 |
- for (k in o) { |
|
1279 |
- if (Object.prototype.hasOwnProperty.call(o, k) && (o[k].name || k) == attribute) { |
|
1280 |
- return this; |
|
2918 |
+ |
|
2919 |
+ function q(query) { |
|
2920 |
+ return query.match(chunker) |
|
2921 |
+ } |
|
2922 |
+ |
|
2923 |
+ // called using `this` as element and arguments from regex group results. |
|
2924 |
+ // given => div.hello[title="world"]:foo('bar') |
|
2925 |
+ // div.hello[title="world"]:foo('bar'), div, .hello, [title="world"], title, =, world, :foo('bar'), foo, ('bar'), bar] |
|
2926 |
+ function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value, wholePseudo, pseudo, wholePseudoVal, pseudoVal) { |
|
2927 |
+ var i, m, k, o, classes |
|
2928 |
+ if (this[nodeType] !== 1) return false |
|
2929 |
+ if (tag && tag !== '*' && this[tagName] && this[tagName].toLowerCase() !== tag) return false |
|
2930 |
+ if (idsAndClasses && (m = idsAndClasses.match(id)) && m[1] !== this.id) return false |
|
2931 |
+ if (idsAndClasses && (classes = idsAndClasses.match(clas))) { |
|
2932 |
+ for (i = classes.length; i--;) if (!classRegex(classes[i].slice(1)).test(this.className)) return false |
|
2933 |
+ } |
|
2934 |
+ if (pseudo && qwery.pseudos[pseudo] && !qwery.pseudos[pseudo](this, pseudoVal)) return false |
|
2935 |
+ if (wholeAttribute && !value) { // select is just for existance of attrib |
|
2936 |
+ o = this.attributes |
|
2937 |
+ for (k in o) { |
|
2938 |
+ if (Object.prototype.hasOwnProperty.call(o, k) && (o[k].name || k) == attribute) { |
|
2939 |
+ return this |
|
2940 |
+ } |
|
1281 | 2941 |
} |
1282 | 2942 |
} |
2943 |
+ if (wholeAttribute && !checkAttr(qualifier, getAttr(this, attribute) || '', value)) { |
|
2944 |
+ // select is for attrib equality |
|
2945 |
+ return false |
|
2946 |
+ } |
|
2947 |
+ return this |
|
1283 | 2948 |
} |
1284 |
- if (wholeAttribute && !checkAttr(qualifier, this.getAttribute(attribute) || '', value)) { |
|
1285 |
- return false; |
|
2949 |
+ |
|
2950 |
+ function clean(s) { |
|
2951 |
+ return cleanCache.g(s) || cleanCache.s(s, s.replace(specialChars, '\\$1')) |
|
1286 | 2952 |
} |
1287 |
- return this; |
|
1288 |
- } |
|
1289 |
- |
|
1290 |
- function loopAll(tokens) { |
|
1291 |
- var r = [], token = tokens.pop(), intr = q(token), tag = intr[1] || '*', i, l, els, |
|
1292 |
- root = tokens.length && (m = tokens[0].match(idOnly)) ? doc.getElementById(m[1]) : doc; |
|
1293 |
- if (!root) { |
|
1294 |
- return r; |
|
2953 |
+ |
|
2954 |
+ function checkAttr(qualify, actual, val) { |
|
2955 |
+ switch (qualify) { |
|
2956 |
+ case '=': |
|
2957 |
+ return actual == val |
|
2958 |
+ case '^=': |
|
2959 |
+ return actual.match(attrCache.g('^=' + val) || attrCache.s('^=' + val, '^' + clean(val), 1)) |
|
2960 |
+ case '$=': |
|
2961 |
+ return actual.match(attrCache.g('$=' + val) || attrCache.s('$=' + val, clean(val) + '$', 1)) |
|
2962 |
+ case '*=': |
|
2963 |
+ return actual.match(attrCache.g(val) || attrCache.s(val, clean(val), 1)) |
|
2964 |
+ case '~=': |
|
2965 |
+ return actual.match(attrCache.g('~=' + val) || attrCache.s('~=' + val, '(?:^|\\s+)' + clean(val) + '(?:\\s+|$)', 1)) |
|
2966 |
+ case '|=': |
|
2967 |
+ return actual.match(attrCache.g('|=' + val) || attrCache.s('|=' + val, '^' + clean(val) + '(-|$)', 1)) |
|
2968 |
+ } |
|
2969 |
+ return 0 |
|
1295 | 2970 |
} |
1296 |
- els = root.getElementsByTagName(tag); |
|
1297 |
- for (i = 0, l = els.length; i < l; i++) { |
|
1298 |
- el = els[i]; |
|
1299 |
- if (item = interpret.apply(el, intr)) { |
|
1300 |
- r.push(item); |
|
2971 |
+ |
|
2972 |
+ // given a selector, first check for simple cases then collect all base candidate matches and filter |
|
2973 |
+ function _qwery(selector, _root) { |
|
2974 |
+ var r = [], ret = [], i, l, m, token, tag, els, intr, item, root = _root |
|
2975 |
+ , tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr)) |
|
2976 |
+ , dividedTokens = selector.match(dividers) |
|
2977 |
+ |
|
2978 |
+ if (!tokens.length) return r |
|
2979 |
+ |
|
2980 |
+ token = (tokens = tokens.slice(0)).pop() // copy cached tokens, take the last one |
|
2981 |
+ if (tokens.length && (m = tokens[tokens.length - 1].match(idOnly))) root = byId(_root, m[1]) |
|
2982 |
+ if (!root) return r |
|
2983 |
+ |
|
2984 |
+ intr = q(token) |
|
2985 |
+ // collect base candidates to filter |
|
2986 |
+ els = root !== _root && root[nodeType] !== 9 && dividedTokens && /^[+~]$/.test(dividedTokens[dividedTokens.length - 1]) ? |
|
2987 |
+ function (r) { |
|
2988 |
+ while (root = root.nextSibling) { |
|
2989 |
+ root[nodeType] == 1 && (intr[1] ? intr[1] == root[tagName].toLowerCase() : 1) && (r[r.length] = root) |
|
2990 |
+ } |
|
2991 |
+ return r |
|
2992 |
+ }([]) : |
|
2993 |
+ root[byTag](intr[1] || '*') |
|
2994 |
+ // filter elements according to the right-most part of the selector |
|
2995 |
+ for (i = 0, l = els.length; i < l; i++) { |
|
2996 |
+ if (item = interpret.apply(els[i], intr)) r[r.length] = item |
|
1301 | 2997 |
} |
2998 |
+ if (!tokens.length) return r |
|
2999 |
+ |
|
3000 |
+ // filter further according to the rest of the selector (the left side) |
|
3001 |
+ each(r, function (e) { if (ancestorMatch(e, tokens, dividedTokens)) ret[ret.length] = e }) |
|
3002 |
+ return ret |
|
1302 | 3003 |
} |
1303 |
- return r; |
|
1304 |
- } |
|
1305 |
- |
|
1306 |
- function clean(s) { |
|
1307 |
- return cleanCache.g(s) || cleanCache.s(s, s.replace(specialChars, '\\$1')); |
|
1308 |
- } |
|
1309 |
- |
|
1310 |
- function checkAttr(qualify, actual, val) { |
|
1311 |
- switch (qualify) { |
|
1312 |
- case '=': |
|
1313 |
- return actual == val; |
|
1314 |
- case '^=': |
|
1315 |
- return actual.match(attrCache.g('^=' + val) || attrCache.s('^=' + val, new RegExp('^' + clean(val)))); |
|
1316 |
- case '$=': |
|
1317 |
- return actual.match(attrCache.g('$=' + val) || attrCache.s('$=' + val, new RegExp(clean(val) + '$'))); |
|
1318 |
- case '*=': |
|
1319 |
- return actual.match(attrCache.g(val) || attrCache.s(val, new RegExp(clean(val)))); |
|
1320 |
- case '~=': |
|
1321 |
- return actual.match(attrCache.g('~=' + val) || attrCache.s('~=' + val, new RegExp('(?:^|\\s+)' + clean(val) + '(?:\\s+|$)'))); |
|
1322 |
- case '|=': |
|
1323 |
- return actual.match(attrCache.g('|=' + val) || attrCache.s('|=' + val, new RegExp('^' + clean(val) + '(-|$)'))); |
|
1324 |
- } |
|
1325 |
- return false; |
|
1326 |
- } |
|
1327 |
- |
|
1328 |
- function _qwery(selector) { |
|
1329 |
- var r = [], ret = [], i, l, |
|
1330 |
- tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr)); |
|
1331 |
- tokens = tokens.slice(0); |
|
1332 |
- if (!tokens.length) { |
|
1333 |
- return r; |
|
1334 |
- } |
|
1335 |
- r = loopAll(tokens); |
|
1336 |
- if (!tokens.length) { |
|
1337 |
- return r; |
|
1338 |
- } |
|
1339 |
- // loop through all descendent tokens |
|
1340 |
- for (j = 0, l = r.length, k = 0; j < l; j++) { |
|
1341 |
- node = r[j]; |
|
1342 |
- p = node; |
|
1343 |
- // loop through each token |
|
1344 |
- for (i = tokens.length; i--;) { |
|
1345 |
- z: // loop through parent nodes |
|
1346 |
- while (p !== html && (p = p.parentNode)) { |
|
1347 |
- if (found = interpret.apply(p, q(tokens[i]))) { |
|
1348 |
- break z; |
|
3004 |
+ |
|
3005 |
+ // compare element to a selector |
|
3006 |
+ function is(el, selector, root) { |
|
3007 |
+ if (isNode(selector)) return el == selector |
|
3008 |
+ if (arrayLike(selector)) return !!~flatten(selector).indexOf(el) // if selector is an array, is el a member? |
|
3009 |
+ |
|
3010 |
+ var selectors = selector.split(','), tokens, dividedTokens |
|
3011 |
+ while (selector = selectors.pop()) { |
|
3012 |
+ tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr)) |
|
3013 |
+ dividedTokens = selector.match(dividers) |
|
3014 |
+ tokens = tokens.slice(0) // copy array |
|
3015 |
+ if (interpret.apply(el, q(tokens.pop())) && (!tokens.length || ancestorMatch(el, tokens, dividedTokens, root))) { |
|
3016 |
+ return true |
|
3017 |
+ } |
|
3018 |
+ } |
|
3019 |
+ return false |
|
3020 |
+ } |
|
3021 |
+ |
|
3022 |
+ // given elements matching the right-most part of a selector, filter out any that don't match the rest |
|
3023 |
+ function ancestorMatch(el, tokens, dividedTokens, root) { |
|
3024 |
+ var cand |
|
3025 |
+ // recursively work backwards through the tokens and up the dom, covering all options |
|
3026 |
+ function crawl(e, i, p) { |
|
3027 |
+ while (p = walker[dividedTokens[i]](p, e)) { |
|
3028 |
+ if (isNode(p) && (interpret.apply(p, q(tokens[i])))) { |
|
3029 |
+ if (i) { |
|
3030 |
+ if (cand = crawl(p, i - 1, p)) return cand |
|
3031 |
+ } else return p |
|
1349 | 3032 |
} |
1350 | 3033 |
} |
1351 | 3034 |
} |
1352 |
- found && (ret[k++] = node); |
|
3035 |
+ return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root)) |
|
1353 | 3036 |
} |
1354 |
- return ret; |
|
1355 |
- } |
|
1356 |
- |
|
1357 |
- function boilerPlate(selector, _root, fn) { |
|
1358 |
- var root = (typeof _root == 'string') ? fn(_root)[0] : (_root || doc); |
|
1359 |
- if (selector === window || isNode(selector)) { |
|
1360 |
- return !_root || (selector !== window && isNode(root) && isAncestor(selector, root)) ? [selector] : []; |
|
3037 |
+ |
|
3038 |
+ function isNode(el, t) { |
|
3039 |
+ return el && typeof el === 'object' && (t = el[nodeType]) && (t == 1 || t == 9) |
|
1361 | 3040 |
} |
1362 |
- if (selector && typeof selector === 'object' && isFinite(selector.length)) { |
|
1363 |
- return array(selector); |
|
3041 |
+ |
|
3042 |
+ function uniq(ar) { |
|
3043 |
+ var a = [], i, j; |
|
3044 |
+ o: |
|
3045 |
+ for (i = 0; i < ar.length; ++i) { |
|
3046 |
+ for (j = 0; j < a.length; ++j) if (a[j] == ar[i]) continue o |
|
3047 |
+ a[a.length] = ar[i] |
|
3048 |
+ } |
|
3049 |
+ return a |
|
1364 | 3050 |
} |
1365 |
- if (m = selector.match(idOnly)) { |
|
1366 |
- return (el = doc.getElementById(m[1])) ? [el] : []; |
|
3051 |
+ |
|
3052 |
+ function arrayLike(o) { |
|
3053 |
+ return (typeof o === 'object' && isFinite(o.length)) |
|
1367 | 3054 |
} |
1368 |
- if (m = selector.match(tagOnly)) { |
|
1369 |
- return array(root.getElementsByTagName(m[1])); |
|
3055 |
+ |
|
3056 |
+ function normalizeRoot(root) { |
|
3057 |
+ if (!root) return doc |
|
3058 |
+ if (typeof root == 'string') return qwery(root)[0] |
|
3059 |
+ if (!root[nodeType] && arrayLike(root)) return root[0] |
|
3060 |
+ return root |
|
1370 | 3061 |
} |
1371 |
- return false; |
|
1372 |
- } |
|
1373 |
- |
|
1374 |
- function isNode(el) { |
|
1375 |
- return (el && el.nodeType && (el.nodeType == 1 || el.nodeType == 9)); |
|
1376 |
- } |
|
1377 |
- |
|
1378 |
- function uniq(ar) { |
|
1379 |
- var a = [], i, j; |
|
1380 |
- label: |
|
1381 |
- for (i = 0; i < ar.length; i++) { |
|
1382 |
- for (j = 0; j < a.length; j++) { |
|
1383 |
- if (a[j] == ar[i]) { |
|
1384 |
- continue label; |
|
1385 |
- } |
|
1386 |
- } |
|
1387 |
- a[a.length] = ar[i]; |
|
3062 |
+ |
|
3063 |
+ function byId(root, id, el) { |
|
3064 |
+ // if doc, query on it, else query the parent doc or if a detached fragment rewrite the query and run on the fragment |
|
3065 |
+ return root[nodeType] === 9 ? root.getElementById(id) : |
|
3066 |
+ root.ownerDocument && |
|
3067 |
+ (((el = root.ownerDocument.getElementById(id)) && isAncestor(el, root) && el) || |
|
3068 |
+ (!isAncestor(root, root.ownerDocument) && select('[id="' + id + '"]', root)[0])) |
|
1388 | 3069 |
} |
1389 |
- return a; |
|
1390 |
- } |
|
1391 |
- |
|
1392 |
- function qwery(selector, _root) { |
|
1393 |
- var root = (typeof _root == 'string') ? qwery(_root)[0] : (_root || doc); |
|
1394 |
- if (!root || !selector) { |
|
1395 |
- return []; |
|
3070 |
+ |
|
3071 |
+ function qwery(selector, _root) { |
|
3072 |
+ var m, el, root = normalizeRoot(_root) |
|
3073 |
+ |
|
3074 |
+ // easy, fast cases that we can dispatch with simple DOM calls |
|
3075 |
+ if (!root || !selector) return [] |
|
3076 |
+ if (selector === window || isNode(selector)) { |
|
3077 |
+ return !_root || (selector !== window && isNode(root) && isAncestor(selector, root)) ? [selector] : [] |
|
3078 |
+ } |
|
3079 |
+ if (selector && arrayLike(selector)) return flatten(selector) |
|
3080 |
+ if (m = selector.match(easy)) { |
|
3081 |
+ if (m[1]) return (el = byId(root, m[1])) ? [el] : [] |
|
3082 |
+ if (m[2]) return arrayify(root[byTag](m[2])) |
|
3083 |
+ if (hasByClass && m[3]) return arrayify(root[byClass](m[3])) |
|
3084 |
+ } |
|
3085 |
+ |
|
3086 |
+ return select(selector, root) |
|
1396 | 3087 |
} |
1397 |
- if (m = boilerPlate(selector, _root, qwery)) { |
|
1398 |
- return m; |
|
3088 |
+ |
|
3089 |
+ // where the root is not document and a relationship selector is first we have to |
|
3090 |
+ // do some awkward adjustments to get it to work, even with qSA |
|
3091 |
+ function collectSelector(root, collector) { |
|
3092 |
+ return function (s) { |
|
3093 |
+ var oid, nid |
|
3094 |
+ if (splittable.test(s)) { |
|
3095 |
+ if (root[nodeType] !== 9) { |
|
3096 |
+ // make sure the el has an id, rewrite the query, set root to doc and run it |
|
3097 |
+ if (!(nid = oid = root.getAttribute('id'))) root.setAttribute('id', nid = '__qwerymeupscotty') |
|
3098 |
+ s = '[id="' + nid + '"]' + s // avoid byId and allow us to match context element |
|
3099 |
+ collector(root.parentNode || root, s, true) |
|
3100 |
+ oid || root.removeAttribute('id') |
|
3101 |
+ } |
|
3102 |
+ return; |
|
3103 |
+ } |
|
3104 |
+ s.length && collector(root, s, false) |
|
3105 |
+ } |
|
1399 | 3106 |
} |
1400 |
- return select(selector, root); |
|
1401 |
- } |
|
1402 |
- |
|
1403 |
- var isAncestor = 'compareDocumentPosition' in html ? |
|
1404 |
- function (element, container) { |
|
1405 |
- return (container.compareDocumentPosition(element) & 16) == 16; |
|
1406 |
- } : 'contains' in html ? |
|
1407 |
- function (element, container) { |
|
1408 |
- container = container == doc || container == window ? html : container; |
|
1409 |
- return container !== element && container.contains(element); |
|
1410 |
- } : |
|
1411 |
- function (element, container) { |
|
1412 |
- while (element = element.parentNode) { |
|
1413 |
- if (element === container) { |
|
1414 |
- return 1; |
|
1415 |
- } |
|
1416 |
- } |
|
1417 |
- return 0; |
|
1418 |
- }, |
|
1419 |
- |
|
1420 |
- select = (doc.querySelector && doc.querySelectorAll) ? |
|
1421 |
- function (selector, root) { |
|
1422 |
- if (doc.getElementsByClassName && (m = selector.match(classOnly))) { |
|
1423 |
- return array((root).getElementsByClassName(m[1])); |
|
1424 |
- } |
|
1425 |
- return array((root).querySelectorAll(selector)); |
|
1426 |
- } : |
|
1427 |
- function (selector, root) { |
|
1428 |
- var result = [], collection, collections = [], i; |
|
1429 |
- if (m = selector.match(tagAndOrClass)) { |
|
1430 |
- items = root.getElementsByTagName(m[1] || '*'); |
|
1431 |
- r = classCache.g(m[2]) || classCache.s(m[2], new RegExp('(^|\\s+)' + m[2] + '(\\s+|$)')); |
|
1432 |
- for (i = 0, l = items.length, j = 0; i < l; i++) { |
|
1433 |
- r.test(items[i].className) && (result[j++] = items[i]); |
|
1434 |
- } |
|
1435 |
- return result; |
|
1436 |
- } |
|
1437 |
- for (i = 0, items = selector.split(','), l = items.length; i < l; i++) { |
|
1438 |
- collections[i] = _qwery(items[i]); |
|
1439 |
- } |
|
1440 |
- for (i = 0, l = collections.length; i < l && (collection = collections[i]); i++) { |
|
1441 |
- var ret = collection; |
|
1442 |
- if (root !== doc) { |
|
1443 |
- ret = []; |
|
1444 |
- for (j = 0, m = collection.length; j < m && (element = collection[j]); j++) { |
|
1445 |
- // make sure element is a descendent of root |
|
1446 |
- isAncestor(element, root) && ret.push(element); |
|
3107 |
+ |
|
3108 |
+ var isAncestor = 'compareDocumentPosition' in html ? |
|
3109 |
+ function (element, container) { |
|
3110 |
+ return (container.compareDocumentPosition(element) & 16) == 16 |
|
3111 |
+ } : 'contains' in html ? |
|
3112 |
+ function (element, container) { |
|
3113 |
+ container = container[nodeType] === 9 || container == window ? html : container |
|
3114 |
+ return container !== element && container.contains(element) |
|
3115 |
+ } : |
|
3116 |
+ function (element, container) { |
|
3117 |
+ while (element = element.parentNode) if (element === container) return 1 |
|
3118 |
+ return 0 |
|
3119 |
+ } |
|
3120 |
+ , getAttr = function () { |
|
3121 |
+ // detect buggy IE src/href getAttribute() call |
|
3122 |
+ var e = doc.createElement('p') |
|
3123 |
+ return ((e.innerHTML = '<a href="#x">x</a>') && e.firstChild.getAttribute('href') != '#x') ? |
|
3124 |
+ function (e, a) { |
|
3125 |
+ return a === 'class' ? e.className : (a === 'href' || a === 'src') ? |
|
3126 |
+ e.getAttribute(a, 2) : e.getAttribute(a) |
|
3127 |
+ } : |
|
3128 |
+ function (e, a) { return e.getAttribute(a) } |
|
3129 |
+ }() |
|
3130 |
+ , hasByClass = !!doc[byClass] |
|
3131 |
+ // has native qSA support |
|
3132 |
+ , hasQSA = doc.querySelector && doc[qSA] |
|
3133 |
+ // use native qSA |
|
3134 |
+ , selectQSA = function (selector, root) { |
|
3135 |
+ var result = [], ss, e |
|
3136 |
+ try { |
|
3137 |
+ if (root[nodeType] === 9 || !splittable.test(selector)) { |
|
3138 |
+ // most work is done right here, defer to qSA |
|
3139 |
+ return arrayify(root[qSA](selector)) |
|
3140 |
+ } |
|
3141 |
+ // special case where we need the services of `collectSelector()` |
|
3142 |
+ each(ss = selector.split(','), collectSelector(root, function (ctx, s) { |
|
3143 |
+ e = ctx[qSA](s) |
|
3144 |
+ if (e.length == 1) result[result.length] = e.item(0) |
|
3145 |
+ else if (e.length) result = result.concat(arrayify(e)) |
|
3146 |
+ })) |
|
3147 |
+ return ss.length > 1 && result.length > 1 ? uniq(result) : result |
|
3148 |
+ } catch (ex) { } |
|
3149 |
+ return selectNonNative(selector, root) |
|
3150 |
+ } |
|
3151 |
+ // no native selector support |
|
3152 |
+ , selectNonNative = function (selector, root) { |
|
3153 |
+ var result = [], items, m, i, l, r, ss |
|
3154 |
+ selector = selector.replace(normalizr, '$1') |
|
3155 |
+ if (m = selector.match(tagAndOrClass)) { |
|
3156 |
+ r = classRegex(m[2]) |
|
3157 |
+ items = root[byTag](m[1] || '*') |
|
3158 |
+ for (i = 0, l = items.length; i < l; i++) { |
|
3159 |
+ if (r.test(items[i].className)) result[result.length] = items[i] |
|
1447 | 3160 |
} |
3161 |
+ return result |
|
1448 | 3162 |
} |
1449 |
- result = result.concat(ret); |
|
3163 |
+ // more complex selector, get `_qwery()` to do the work for us |
|
3164 |
+ each(ss = selector.split(','), collectSelector(root, function (ctx, s, rewrite) { |
|
3165 |
+ r = _qwery(s, ctx) |
|
3166 |
+ for (i = 0, l = r.length; i < l; i++) { |
|
3167 |
+ if (ctx[nodeType] === 9 || rewrite || isAncestor(r[i], root)) result[result.length] = r[i] |
|
3168 |
+ } |
|
3169 |
+ })) |
|
3170 |
+ return ss.length > 1 && result.length > 1 ? uniq(result) : result |
|
3171 |
+ } |
|
3172 |
+ , configure = function (options) { |
|
3173 |
+ // configNativeQSA: use fully-internal selector or native qSA where present |
|
3174 |
+ if (typeof options[useNativeQSA] !== 'undefined') |
|
3175 |
+ select = !options[useNativeQSA] ? selectNonNative : hasQSA ? selectQSA : selectNonNative |
|
3176 |
+ } |
|
3177 |
+ |
|
3178 |
+ configure({ useNativeQSA: true }) |
|
3179 |
+ |
|
3180 |
+ qwery.configure = configure |
|
3181 |
+ qwery.uniq = uniq |
|
3182 |
+ qwery.is = is |
|
3183 |
+ qwery.pseudos = {} |
|
3184 |
+ |
|
3185 |
+ return qwery |
|
3186 |
+ }); |
|
3187 |
+ |
|
3188 |
+ |
|
3189 |
+ provide("qwery", module.exports); |
|
3190 |
+ |
|
3191 |
+ (function ($) { |
|
3192 |
+ var q = function () { |
|
3193 |
+ var r |
|
3194 |
+ try { |
|
3195 |
+ r = require('qwery') |
|
3196 |
+ } catch (ex) { |
|
3197 |
+ r = require('qwery-mobile') |
|
3198 |
+ } finally { |
|
3199 |
+ return r |
|
1450 | 3200 |
} |
1451 |
- return uniq(result); |
|
1452 |
- }; |
|
3201 |
+ }() |
|
3202 |
+ |
|
3203 |
+ $.pseudos = q.pseudos |
|
3204 |
+ |
|
3205 |
+ $._select = function (s, r) { |
|
3206 |
+ // detect if sibling module 'bonzo' is available at run-time |
|
3207 |
+ // rather than load-time since technically it's not a dependency and |
|
3208 |
+ // can be loaded in any order |
|
3209 |
+ // hence the lazy function re-definition |
|
3210 |
+ return ($._select = (function () { |
|
3211 |
+ var b |
|
3212 |
+ if (typeof $.create == 'function') return function (s, r) { |
|
3213 |
+ return /^\s*</.test(s) ? $.create(s, r) : q(s, r) |
|
3214 |
+ } |
|
3215 |
+ try { |
|
3216 |
+ b = require('bonzo') |
|
3217 |
+ return function (s, r) { |
|
3218 |
+ return /^\s*</.test(s) ? b.create(s, r) : q(s, r) |
|
3219 |
+ } |
|
3220 |
+ } catch (e) { } |
|
3221 |
+ return q |
|
3222 |
+ })())(s, r) |
|
3223 |
+ } |
|
3224 |
+ |
|
3225 |
+ $.ender({ |
|
3226 |
+ find: function (s) { |
|
3227 |
+ var r = [], i, l, j, k, els |
|
3228 |
+ for (i = 0, l = this.length; i < l; i++) { |
|
3229 |
+ els = q(s, this[i]) |
|
3230 |
+ for (j = 0, k = els.length; j < k; j++) r.push(els[j]) |
|
3231 |
+ } |
|
3232 |
+ return $(q.uniq(r)) |
|
3233 |
+ } |
|
3234 |
+ , and: function (s) { |
|
3235 |
+ var plus = $(s) |
|
3236 |
+ for (var i = this.length, j = 0, l = this.length + plus.length; i < l; i++, j++) { |
|
3237 |
+ this[i] = plus[j] |
|
3238 |
+ } |
|
3239 |
+ this.length += plus.length |
|
3240 |
+ return this |
|
3241 |
+ } |
|
3242 |
+ , is: function(s, r) { |
|
3243 |
+ var i, l |
|
3244 |
+ for (i = 0, l = this.length; i < l; i++) { |
|
3245 |
+ if (q.is(this[i], s, r)) { |
|
3246 |
+ return true |
|
3247 |
+ } |
|
3248 |
+ } |
|
3249 |
+ return false |
|
3250 |
+ } |
|
3251 |
+ }, true) |
|
3252 |
+ }(ender)); |
|
3253 |
+ |
|
1453 | 3254 |
|
1454 |
- qwery.uniq = uniq; |
|
1455 |
- var oldQwery = context.qwery; |
|
1456 |
- qwery.noConflict = function () { |
|
1457 |
- context.qwery = oldQwery; |
|
1458 |
- return this; |
|
1459 |
- }; |
|
1460 |
- context['qwery'] = qwery; |
|
3255 |
+}()); |
|
1461 | 3256 |
|
1462 |
-}(this, document);!function (doc) { |
|
1463 |
- var q = qwery.noConflict(); |
|
1464 |
- function create(node, root) { |
|
1465 |
- var el = (root || doc).createElement('div'), els = []; |
|
1466 |
- el.innerHTML = node; |
|
1467 |
- var nodes = el.childNodes; |
|
1468 |
- el = el.firstChild; |
|
1469 |
- els.push(el); |
|
1470 |
- while (el = el.nextSibling) { |
|
1471 |
- (el.nodeType == 1) && els.push(el); |
|
1472 |
- } |
|
1473 |
- return els; |
|
1474 |
- }; |
|
1475 |
- $._select = function (s, r) { |
|
1476 |
- return /^\s*</.test(s) ? create(s, r) : q(s, r); |
|
1477 |
- }; |
|
1478 |
- $.ender({ |
|
1479 |
- find: function (s) { |
|
1480 |
- var r = [], i, l, j, k, els; |
|
1481 |
- for (i = 0, l = this.length; i < l; i++) { |
|
1482 |
- els = q(s, this[i]); |
|
1483 |
- for (j = 0, k = els.length; j < k; j++) { |
|
1484 |
- r.push(els[j]); |
|
1485 |
- } |
|
1486 |
- } |
|
1487 |
- return $(q.uniq(r)); |
|
1488 |
- } |
|
1489 |
- , and: function (s) { |
|
1490 |
- var plus = $(s); |
|
1491 |
- for (var i = this.length, j = 0, l = this.length + plus.length; i < l; i++, j++) { |
|
1492 |
- this[i] = plus[j]; |
|
1493 |
- } |
|
1494 |
- return this; |
|
1495 |
- } |
|
1496 |
- }, true); |
|
1497 |
-}(document); |