|
/*!
* WADE JavaScript Library v2.0 for zepto
* http://www.wadecn.com/
* auth:xiedx@asiainfo-linkage.com
* Copyright 2014, WADE
*/
define(["zepto"],function(e){var d=function(g){return g.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1");
};var c={scriptEval:false};var f=Object.prototype.toString;e.Collection=function(h,g){this.items=[];this.map={};this.keys=[];this.length=0;this.allowFunctions=h===true;
if(g){this.getKey=g;}};e.Collection.prototype={allowFunctions:false,add:function(h,i){if(arguments.length==1){i=arguments[0];h=this.getKey(i);}if(typeof h!="undefined"&&h!==null){var g=this.map[h];
if(typeof g!="undefined"){return this.replace(h,i);}this.map[h]=i;}this.length++;this.items.push(i);this.keys.push(h);return i;},getKey:function(g){return g.id;
},replace:function(i,j){if(arguments.length==1){j=arguments[0];i=this.getKey(j);}var g=this.map[i];if(typeof i=="undefined"||i===null||typeof g=="undefined"){return this.add(i,j);
}var h=this.indexOfKey(i);this.items[h]=j;this.map[i]=j;return j;},addAll:function(l){if(arguments.length>1||e.isArray(l)){var h=arguments.length>1?arguments:l;
for(var k=0,g=h.length;k<g;k++){this.add(h[k]);}}else{for(var j in l){if(this.allowFunctions||typeof l[j]!="function"){this.add(j,l[j]);}}}},each:function(l,k){var h=[].concat(this.items);
for(var j=0,g=h.length;j<g;j++){if(l.call(k||h[j],h[j],j,g)===false){break;}}},eachKey:function(k,j){for(var h=0,g=this.keys.length;h<g;h++){k.call(j||window,this.keys[h],this.items[h],h,g);
}},find:function(k,j){for(var h=0,g=this.items.length;h<g;h++){if(k.call(j||window,this.items[h],this.keys[h])){return this.items[h];}}return null;},insert:function(g,h,i){if(arguments.length==2){i=arguments[1];
h=this.getKey(i);}if(this.containsKey(h)){this.suspendEvents();this.removeKey(h);this.resumeEvents();}if(g>=this.length){return this.add(h,i);}this.length++;
this.items.splice(g,0,i);if(typeof h!="undefined"&&h!==null){this.map[h]=i;}this.keys.splice(g,0,h);return i;},remove:function(g){return this.removeAt(this.indexOf(g));
},removeAt:function(g){if(g<this.length&&g>=0){this.length--;var i=this.items[g];this.items.splice(g,1);var h=this.keys[g];if(typeof h!="undefined"){delete this.map[h];
}this.keys.splice(g,1);return i;}return false;},removeKey:function(g){return this.removeAt(this.indexOfKey(g));},getCount:function(){return this.length;
},indexOf:function(g){return e.inArray(g,this.items);},indexOfKey:function(g){return e.inArray(g,this.keys);},item:function(h){var g=this.map[h],i=g!==undefined?g:(typeof h=="number")?this.items[h]:undefined;
return typeof i!="function"||this.allowFunctions?i:null;},itemAt:function(g){return this.items[g];},key:function(g){return this.map[g];},contains:function(g){return this.indexOf(g)!=-1;
},containsKey:function(g){return typeof this.map[g]!="undefined";},clear:function(){this.length=0;this.items=[];this.keys=[];this.map={};},first:function(){return this.items[0];
},last:function(){return this.items[this.length-1];},_sort:function(o,g,n){var j,k,h=String(g).toUpperCase()=="DESC"?-1:1,m=[],p=this.keys,l=this.items;
n=n||function(q,i){return q-i;};for(j=0,k=l.length;j<k;j++){m[m.length]={key:p[j],value:l[j],index:j};}m.sort(function(q,i){var r=n(q[o],i[o])*h;if(r===0){r=(q.index<i.index?-1:1);
}return r;});for(j=0,k=m.length;j<k;j++){l[j]=m[j].value;p[j]=m[j].key;}},sort:function(g,h){this._sort("value",g,h);},reorder:function(j){this.suspendEvents();
var h=this.items,i=0,l=h.length,g=[],k=[];for(oldIndex in j){g[j[oldIndex]]=h[oldIndex];}for(i=0;i<l;i++){if(j[i]==undefined){k.push(h[i]);}}for(i=0;i<l;
i++){if(g[i]==undefined){g[i]=k.shift();}}this.clear();this.addAll(g);this.resumeEvents();},keySort:function(g,h){this._sort("key",g,h||function(j,i){var l=String(j).toUpperCase(),k=String(i).toUpperCase();
return l>k?1:(l<k?-1:0);});},getRange:function(l,g){var h=this.items;if(h.length<1){return[];}l=l||0;g=Math.min(typeof g=="undefined"?this.length-1:g,this.length-1);
var j,k=[];if(l<=g){for(j=l;j<=g;j++){k[k.length]=h[j];}}else{for(j=l;j>=g;j--){k[k.length]=h[j];}}return k;},filter:function(i,h,j,g){if(!h){return this.clone();
}h=this.createValueMatcher(h,j,g);return this.filterBy(function(k){return k&&h.test(k[i]);});},filterBy:function(n,m){var o=new e.Collection();o.getKey=this.getKey;
var h=this.keys,l=this.items;for(var j=0,g=l.length;j<g;j++){if(n.call(m||this,l[j],h[j])){o.add(h[j],l[j]);}}return o;},findIndex:function(i,h,k,j,g){if(!h){return -1;
}h=this.createValueMatcher(h,j,g);return this.findIndexBy(function(l){return l&&h.test(l[i]);},null,k);},findIndexBy:function(n,m,o){var h=this.keys,l=this.items;
for(var j=(o||0),g=l.length;j<g;j++){if(n.call(m||this,l[j],h[j])){return j;}}return -1;},createValueMatcher:function(i,j,g,h){if(!i.exec){i=String(i);
if(j===true){i=d(i);}else{i="^"+d(i);if(h===true){i+="$";}}i=new RegExp(i,g?"":"i");}return i;},clone:function(){var m=new e.Collection();var h=this.keys,l=this.items;
for(var j=0,g=l.length;j<g;j++){m.add(h[j],l[j]);}m.getKey=this.getKey;return m;}};e.extend(e,{noop:function(){},error:function(g){throw g;},isNumber:function(g){return typeof g==="number"&&isFinite(g);
},isNumeric:function(g){return !isNaN(parseFloat(g))&&isFinite(g);},isString:function(g){return typeof g==="string";},isBoolean:function(g){return typeof g==="boolean";
},isFunction:function(g){return f.call(g)==="[object Function]";},isObject:function(g){return f.call(g)==="[object Object]";},isEmptyObject:function(h){for(var g in h){return false;
}return true;},isElement:function(g){return g?g.nodeType!==undefined:false;},isNodeName:function(h,g){return e.nodeName(h,g);},nodeName:function(h,g){return h.nodeName&&h.nodeName.toUpperCase()===g.toUpperCase();
},isWindow:function(g){return g&&typeof g==="object"&&"setInterval" in g;},trim:function(g){return(g||"").replace(rtrim,"");},inArray:function(j,k){if(k.indexOf){return k.indexOf(j);
}for(var g=0,h=k.length;g<h;g++){if(k[g]===j){return g;}}return -1;},makeArray:function(i,h){var g=h||[];if(i!=null){if(i.length==null||typeof i==="string"||e.isFunction(i)||(typeof i!=="function"&&i.setInterval)){push.call(g,i);
}else{e.merge(g,i);}}return g;},merge:function(n,k){var m=n.length,h=0;if(typeof k.length==="number"){for(var g=k.length;h<g;h++){n[m++]=k[h];}}else{while(k[h]!==undefined){n[m++]=k[h++];
}}n.length=m;return n;},grep:function(h,m,g){var j=[];for(var k=0,l=h.length;k<l;k++){if(!g!==!m(h[k],k)){j.push(h[k]);}}return j;},map:function(h,n,g){var j=[],m;
for(var k=0,l=h.length;k<l;k++){m=n(h[k],k,g);if(m!=null){j[j.length]=m;}}return j.concat.apply([],j);},each:function(k,o,j){var h,l=0,m=k.length,g=m===undefined||e.isFunction(k);
if(j){if(g){for(h in k){if(o.apply(k[h],j)===false){break;}}}else{for(;l<m;){if(o.apply(k[l++],j)===false){break;}}}}else{if(g){for(h in k){if(o.call(k[h],h,k[h])===false){break;
}}}else{for(var n=k[0];l<m&&o.call(n,l,n)!==false;n=k[++l]){}}}return k;},parseJSON:function(g){if(typeof g!=="string"||!g){return null;}g=e.trim(g);if(/^[\],:{}\s]*$/.test(g.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return window.JSON&&window.JSON.parse?window.JSON.parse(g):(new Function("return "+g))();
}else{e.error("Invalid JSON: "+g);}},globalEval:function(i){if(i&&rnotwhite.test(i)){var h=document.getElementsByTagName("head")[0]||document.documentElement,g=document.createElement("script");
g.type="text/javascript";if(c.scriptEval){g.appendChild(document.createTextNode(i));}else{g.text=i;}h.insertBefore(g,h.firstChild);h.removeChild(g);}},uaMatch:function(h){h=h.toLowerCase();
var g=/(webkit)[ \/]([\w.]+)/.exec(h)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(h)||/(msie) ([\w.]+)/.exec(h)||!/compatible/.test(h)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(h)||/(gecko)[ \/]([^\s]*)/i.exec(h)||[];
return{browser:g[1]||"",version:g[2]||"0"};},browser:{}});e.extend(e,{parseJsonString:function(k){if(!k||!typeof(k)=="string"){return"";}k=k.replace(/([:{}\[\]\"])[\s|\u00A0]+/g,"$1");
k=k.replace(/[\s|\u00A0]+([:{}\[\]\"])/g,"$1");k=k.replace(/,([^\":{}\[\]]+):\"/g,',"$1":"');k=k.replace(/,([^\":{}\[\]]+):\{/g,',"$1":{');k=k.replace(/,([^\":{}\[\]]+):\[/g,',"$1":[');
k=k.replace(/\{([^\":{}\[\]]+):\"/g,'{"$1":"');k=k.replace(/\{([^\":{}\[\]]+):\{/g,'{"$1":{');k=k.replace(/\{([^\":{}\[\]]+):\[/g,'{"$1":[');k=k.replace(/\\\":(null|undefined)(,|})/g,'\\":\\"\\"$2');
k=k.replace(/\\\":(true|false)(,|})/g,'\\":\\"$1\\"$2');k=k.replace(/\\\":(-)?([0-9\.]+)(,|})/g,'\\":\\"$1$2\\"$3');k=k.replace(/\\\"/g,"!~b~!");k=k.replace(/:(null|undefined)(,|})/g,':""$2');
k=k.replace(/:(true|false)(,|})/g,':"$1"$2');k=k.replace(/:(-)?([0-9\.]+)(,|})/g,':"$1$2"$3');var g="";for(var h=0;h<k.length;h++){var j=k.charAt(h);switch(j){case"\b":g+="\u005Cb";
break;case"\f":g+="\u005Cf";break;case"\r":g+="\u005Cr";break;case"\t":g+="\u005Ct";break;case"\n":g+="\u005Cn";break;case'"':g+="!~a~!";break;default:g+=j;
break;}}k=g;k=k.replace(/{!~a~!/g,'{"');k=k.replace(/!~a~!}/g,'"}');k=k.replace(/!~a~!,!~a~!/g,'","');k=k.replace(/!~a~!:!~a~!/g,'":"');k=k.replace(/!~a~!:\[/g,'":[');
k=k.replace(/\],!~a~!/g,'],"');k=k.replace(/!~a~!:{/g,'":{');k=k.replace(/},!~a~!/g,'},"');k=k.replace(/\u005C!~a~!/g,'\u005C"');k=k.replace(/!~a~!/g,'\u005C"');
k=k.replace(/!~b~!/g,'\u005C"');return k;},parseJsonValue:function(k){if(!k||!typeof(k)=="string"){return k;}var g="";for(var h=0;h<k.length;h++){var j=k.charAt(h);
switch(j){case"\b":g+="\u005Cb";break;case"\f":g+="\u005Cf";break;case"\r":g+="\u005Cr";break;case"\t":g+="\u005Ct";break;case"\n":g+="\u005Cn";break;case'"':g+='\u005C"';
break;default:g+=j;break;}}return g;}});e.DataMap=function(g){if(!this.parseString){return new e.DataMap(g);}e.Collection.call(this);if(g){if(e.isString(g)){this.parseString(g);
}else{if(typeof(g)=="object"){this.parseObject(g);}}}};e.DataMap.prototype=new e.Collection();e.extend(e.DataMap.prototype,{get:function(h,g){var i=this.item(h);
if(arguments.length>1&&(typeof(i)=="undefined"||i==null)){return arguments[1];}return i;},parseString:function(g){g=e.parseJsonString(g);(new Function("this.parseObject("+g+")")).apply(this);
},parseObject:function(h){for(var g in h){if(h[g]&&e.isArray(h[g])){this.add(g,new e.DatasetList(h[g]));}else{if(h[g]&&e.isObject(h[g])){this.add(g,new e.DataMap(h[g]));
}else{this.add(g,(h[g]==undefined||h[g]==null)?"":h[g]);}}}}});e.DataMap.prototype.toString=function(){var g=[],i="";for(var h in this.map){i='"'+h+'":';
if(typeof(this.map[h])=="undefined"||this.map[h]==null){i+='""';}else{if(typeof(this.map[h])=="string"||!isNaN(this.map[h])){i+='"'+e.parseJsonValue(""+this.map[h])+'"';
}else{i+=this.map[h].toString();}}g.push(i);}return"{"+g.join(",")+"}";};e.DataMap.prototype.put=e.DataMap.prototype.add;e.DatasetList=function(g){if(!this.parseString){return new e.DatasetList(g);
}this.items=[];this.length=0;if(typeof(g)=="string"&&g!=""){this.parseString(g);}if(typeof(g)=="object"&&(g instanceof Array)&&g.length){this.parseArray(g);
}};e.extend(e.DatasetList.prototype,{add:function(g){this.length=(this.length+1);this.items.push(g);},item:function(h,i,g){if(h<this.length&&h>=0){var j=this.items[h];
if((typeof(j)!="undefined")&&(j instanceof e.DataMap)&&arguments.length>1&&typeof(arguments[1])=="string"&&arguments[1]!=""){return j.get(i,g);}return j;
}return;},each:function(l,k){var h=[].concat(this.items);for(var j=0,g=h.length;j<g;j=j+1){if(l.call(k||h[j],h[j],j,g)===false){break;}}},remove:function(g){return this.removeAt(this.indexOf(g));
},removeAt:function(g){if(g<this.length&&g>=0){this.length=(this.length-1);this.items.splice(g,1);}},indexOf:function(j){if(!this.items.indexOf){for(var h=0,g=this.items.length;
h<g;h=h+1){if(this.items[h]==j){return h;}}return -1;}else{return this.items.indexOf(j);}},getCount:function(){return this.length;},parseString:function(g){g=e.parseJsonString(g);
(new Function("this.parseArray("+g+")")).apply(this);},parseArray:function(h){for(var g=0;g<h.length;g++){if(h[g]&&e.isArray(h[g])){this.add(new e.DatasetList(h[g]));
}else{if(h[g]&&e.isObject(h[g])){this.add(new e.DataMap(h[g]));}else{if(h[g]!=undefined&&h[g]!=null){this.add(h[g]);}}}}},clear:function(){this.items=[];
this.length=0;}});e.DatasetList.prototype.toString=function(){var g=[],j="";for(var h=0;h<this.items.length;h++){j="";if(typeof(this.items[h])=="undefined"||this.items[h]==null){j+='""';
}else{if(typeof(this.items[h])=="string"){j='"'+e.parseJsonValue(this.items[h])+'"';}else{j=this.items[h].toString();}}g.push(j);}return"["+g.join(",")+"]";
};e.DatasetList.prototype.get=e.DatasetList.prototype.item;e.DatasetList.prototype.put=e.DatasetList.prototype.add;var b=/%20/g,a=/^(\w+:)?\/\/([^\/?#]+)/;
e.extend(e,{active:0,param:function(g){var h=[];if(!g||!e.isObject(g)){return"";}for(var j in g){i(j,g[j]);}return h.join("&").replace(b,"+");function i(l,m){if(e.isArray(m)){e.each(m,function(o,n){if(/\[\]$/.test(l)){k(l,n);
}else{i(l+"["+(typeof n==="object"||e.isArray(n)?o:"")+"]",n);}});}else{if(m!=null&&typeof m==="object"){e.each(m,function(o,n){i(l+"["+o+"]",n);});}else{k(l,m);
}}}function k(l,m){m=e.isFunction(m)?m():m;h[h.length]=encodeURIComponent(l)+"="+encodeURIComponent(m);}},get:function(g,i,j,h){if(e.isFunction(i)){h=h||j;
j=i;i=null;}return e.ajaxRequest({type:"GET",url:g,data:i,success:j,dataType:h});},getScript:function(g,h){return e.get(g,null,h,"script");},getJSON:function(g,h,i){return e.get(g,h,i,"json");
},post:function(g,i,j,h){if(e.isFunction(i)){h=h||j;j=i;i={};}return e.ajaxRequest({type:"POST",url:g,data:i,success:j,dataType:h});},ajaxSetup:function(g){e.extend(e.ajaxSettings,g);
},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:window.XMLHttpRequest&&(window.location.protocol!=="file:"||!window.ActiveXObject)?function(){return new window.XMLHttpRequest();
}:function(){try{return new window.ActiveXObject("Microsoft.XMLHTTP");}catch(g){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/"+"*"}},lastModified:{},etag:{},ajaxRequest:function(v){var q=e.extend(true,{},e.ajaxSettings,v);
var A,u,z,B=v&&v.context||q,i=q.type.toUpperCase();if(q.data&&q.processData&&typeof q.data!=="string"){q.data=e.param(q.data,q.traditional);}if(q.dataType==="jsonp"){if(i==="GET"){if(!jsre.test(q.url)){q.url+=(rquery.test(q.url)?"&":"?")+(q.jsonp||"callback")+"=?";
}}else{if(!q.data||!jsre.test(q.data)){q.data=(q.data?q.data+"&":"")+(q.jsonp||"callback")+"=?";}}q.dataType="json";}if(q.dataType==="json"&&(q.data&&jsre.test(q.data)||jsre.test(q.url))){A=q.jsonpCallback||("jsonp"+jsc++);
if(q.data){q.data=(q.data+"").replace(jsre,"="+A+"$1");}q.url=q.url.replace(jsre,"="+A+"$1");q.dataType="script";window[A]=window[A]||function(s){z=s;l();
o();window[A]=undefined;try{delete window[A];}catch(C){}if(j){j.removeChild(x);}};}if(q.dataType==="script"&&q.cache===null){q.cache=false;}if(q.cache===false&&i==="GET"){var g=now();
var y=q.url.replace(rts,"$1_="+g+"$2");q.url=y+((y===q.url)?(rquery.test(q.url)?"&":"?")+"_="+g:"");}if(q.data&&i==="GET"){q.url+=(rquery.test(q.url)?"&":"?")+q.data;
}var t=a.exec(q.url),k=t&&(t[1]&&t[1]!==location.protocol||t[2]!==location.host);if(q.dataType==="script"&&i==="GET"&&k){var j=document.getElementsByTagName("head")[0]||document.documentElement;
var x=document.createElement("script");x.src=q.url;if(q.scriptCharset){x.charset=q.scriptCharset;}if(!A){var r=false;x.onload=x.onreadystatechange=function(){if(!r&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){r=true;
l();o();x.onload=x.onreadystatechange=null;if(j&&x.parentNode){j.removeChild(x);}}};}j.insertBefore(x,j.firstChild);return undefined;}var n=false;var m=q.xhr();
if(!m){return;}if(q.username){m.open(i,q.url,q.async,q.username,q.password);}else{m.open(i,q.url,q.async);}try{if(q.data||v&&v.contentType){m.setRequestHeader("Content-Type",q.contentType+(q.encoding?"; charset="+q.encoding:""));
}if(q.ifModified){if(e.lastModified[q.url]){m.setRequestHeader("If-Modified-Since",e.lastModified[q.url]);}if(e.etag[q.url]){m.setRequestHeader("If-None-Match",e.etag[q.url]);
}}if(!k){m.setRequestHeader("X-Requested-With","XMLHttpRequest");}m.setRequestHeader("Accept",q.dataType&&q.accepts[q.dataType]?q.accepts[q.dataType]+", */"+"*":q.accepts._default);
}catch(w){}if(q.beforeSend&&q.beforeSend.call(B,m,q)===false){m.abort();return false;}var p=m.onreadystatechange=function(s){if(!m||m.readyState===0||s==="abort"){if(!n){o();
}n=true;if(m){m.onreadystatechange=e.noop;}}else{if(!n&&m&&(m.readyState===4||s==="timeout")){n=true;m.onreadystatechange=e.noop;u=s==="timeout"?"timeout":!e.httpSuccess(m)?"error":q.ifModified&&e.httpNotModified(m,q.url)?"notmodified":"success";
var D;if(u==="success"){try{z=e.httpData(m,q.dataType,q);}catch(C){u="parsererror";D=C;}}if(u==="success"||u==="notmodified"){if(!A){l();}}else{e.handleError(q,m,u,D);
}o();if(s==="timeout"){m.abort();}if(q.async){m=null;}}}};try{var h=m.abort;m.abort=function(){if(m){h.call(m);}p("abort");};}catch(w){}if(q.async&&q.timeout>0){setTimeout(function(){if(m&&!n){p("timeout");
}},q.timeout);}try{m.send(i==="POST"||i==="PUT"||i==="DELETE"?q.data:null);}catch(w){e.handleError(q,m,null,w);o();}if(!q.async){p();}function l(){if(q.success){q.success.call(B,z,u,m);
}}function o(){if(q.complete){q.complete.call(B,m,u);}}return m;},handleError:function(h,j,g,i){if(h.error){h.error.call(h.context||h,j,g,i);}},httpSuccess:function(h){try{return !h.status&&location.protocol==="file:"||(h.status>=200&&h.status<300)||h.status===304||h.status===1223||h.status===0;
}catch(g){}return false;},httpNotModified:function(j,g){var i=j.getResponseHeader("Last-Modified"),h=j.getResponseHeader("Etag");if(i){e.lastModified[g]=i;
}if(h){e.etag[g]=h;}return j.status===304||j.status===0;},httpData:function(l,j,i){var h=l.getResponseHeader("content-type")||"",g=j==="xml"||!j&&h.indexOf("xml")>=0,k=g?l.responseXML:l.responseText;
if(g&&k.documentElement.nodeName==="parsererror"){e.error("parsererror");}if(i&&i.dataFilter){k=i.dataFilter(k,j);}if(typeof k==="string"){if(j==="json"||!j&&h.indexOf("json")>=0){k=e.parseJSON(k);
}else{if(j==="script"||!j&&h.indexOf("javascript")>=0){e.globalEval(k);}}}return k;}});return e;});
|