avalon-rails 1.3.9.1.20150212184918 → 1.4.1.1.20150404164109

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
- !function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("Avalon requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function r(){e.console&&avalon.config.debug&&Function.apply.call(console.log,console,arguments)}function o(){}function i(e,t){"string"==typeof e&&(e=e.match(St)||[]);for(var n={},r=void 0!==t?t:1,a=0,o=e.length;o>a;a++)n[e[a]]=r;return n}function l(e){function t(r,a){return n.push(r)>e&&delete t[n.shift()],t[r]=a}var n=[];return t}function s(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function c(e){return jt.test(Dt.call(e))}function u(e,t){return e=Math.floor(e)||0,0>e?Math.max(t+e,0):Math.min(e,t)}function f(e){if(!e)return!1;var t=e.length;if(t===t>>>0){var n=Dt.call(e).slice(8,-1);if(/(?:regexp|string|function|window|global)$/i.test(n))return!1;if("Array"===n)return!0;try{return{}.propertyIsEnumerable.call(e,"length")===!1?/^\s?function/.test(e.item||e.callee):!0}catch(r){return!e.window}}return!1}function p(e,t,n){var r="for(var "+e+"i=0,n = this.length; i < n; i++){"+t.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+n;return Function("fn,scope",r)}function d(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}}function v(){return(new XMLSerializer).serializeToString(this)}function h(e,t){if(e&&e.childNodes)for(var n,r=e.childNodes,a=0;n=r[a++];)if(n.tagName){var o=Ct.createElementNS(an,n.tagName.toLowerCase());Ft.forEach.call(n.attributes,function(e){o.setAttribute(e.name,e.value)}),h(n,o),t.appendChild(o)}}function m(e){var t={};for(var n in e)t[n]=e[n];var r=t.target=e.srcElement;if(0===e.type.indexOf("key"))t.which=null!=e.charCode?e.charCode:e.keyCode;else if(ln.test(e.type)){var a=r.ownerDocument||Ct,o="BackCompat"===a.compatMode?a.body:a.documentElement;t.pageX=e.clientX+(o.scrollLeft>>0)-(o.clientLeft>>0),t.pageY=e.clientY+(o.scrollTop>>0)-(o.clientTop>>0),t.wheelDeltaY=t.wheelDelta,t.wheelDeltaX=0}return t.timeStamp=new Date-0,t.originalEvent=e,t.preventDefault=function(){e.returnValue=!1},t.stopPropagation=function(){e.cancelBubble=!0},t}function g(e){for(var t in e)if(Pt.call(e,t)){var n=e[t];"function"==typeof g.plugins[t]?g.plugins[t](n):"object"==typeof g[t]?avalon.mix(g[t],n):g[t]=n}return this}function y(e){return(e+"").replace(mn,"\\$&")}function b(e,t,n){if(Yt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;if(-1!==Cn.indexOf(e))return!1;var r=n.$special;return e&&"$"===e.charAt(0)&&!r[e]?!1:!0}function x(e,t,n,r){switch(e.type){case 0:var a=e.get,o=e.set;if(Yt(o)){var i=r.$events,l=i[t];i[t]=[],o.call(r,n),i[t]=l}return a.call(r);case 1:return n;case 2:if(n!==r.$model[t]){var s=e.svmodel=C(r,t,n,e.valueType);n=s.$model;var c=Tn[s.$id];c&&c()}return n}}function $(e,t,n){if(Array.isArray(e)){var r=e.concat();e.length=0;var a=E(e);return a.pushArray(r),a}if("number"==typeof e.nodeType)return e;if(e.$id&&e.$events)return e;Array.isArray(e.$skipArray)||(e.$skipArray=[]),e.$skipArray.$special=t||{};var i={};n=n||{};var l={},s={},c=[];for(var u in e)!function(t,r){if(n[t]=r,b(t,r,e.$skipArray)){l[t]=[];var a=avalon.type(r),u=function(e){var t=u._name,n=this,r=n.$model,a=r[t],o=n.$events;return arguments.length?void(_t||(1===u.type||(e=x(u,t,e,n),u.type))&&(Mn(a,e)||(r[t]=e,o.$digest?u.pedding||(u.pedding=!0,setTimeout(function(){j(o[t]),w(n,t,r[t],a),u.pedding=!1})):(j(o[t]),w(n,t,e,a))))):0===u.type?(e=u.get.call(n),a!==e&&(r[t]=e,o.$digest?u.pedding||(u.pedding=!0,setTimeout(function(){w(n,t,r[t],a),u.pedding=!1})):w(n,t,e,a)),e):(M(o[t]),u.svmodel||a)};"object"===a&&Yt(r.get)&&Object.keys(r).length<=2?(u.set=r.set,u.get=r.get,u.type=0,c.push(function(){var e={evaluator:function(){e.type=Math.random(),e.element=null,n[t]=u.get.call(i)},element:Tt,type:Math.random(),handler:o,args:[]};It[wt]=e,u.call(i),delete It[wt]})):Nt.test(a)?(u.type=2,u.valueType=a,c.push(function(){var e=$(r,0,n[t]);u.svmodel=e,e.$events[kt]=l[t]})):u.type=1,u._name=t,s[t]=u}}(u,e[u]);Cn.forEach(function(t){delete e[t],delete n[t]}),i=kn(i,_n(s),e);for(var f in e)s[f]||(i[f]=e[f]);i.$id=Xt(),i.$model=n,i.$events=l;for(u in bn){var p=bn[u];Rt||(p=p.bind(i)),i[u]=p}return An?Object.defineProperty(i,"hasOwnProperty",{value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0}):i.hasOwnProperty=function(e){return e in i.$model},c.forEach(function(e){e()}),i}function w(e,t,n,r){e.$events&&bn.$fire.call(e,t,n,r)}function C(e,t,n,r){var a=e[t];if("array"===r)return Array.isArray(n)&&a!==n?(a._.$unwatch(),a.clear(),a._.$watch(),a.pushArray(n.concat()),a):a;var o=e.$events[t],i=a.$events.$withProxyPool;i&&(gt(i,"with"),a.$events.$withProxyPool=null);var l=$(n);return l.$events[kt]=o,Tn[l.$id]=function(e){for(;e=o.shift();)!function(e){avalon.nextTick(function(){e.type&&(e.rollback&&e.rollback(),Zt[e.type](e,e.vmodels))})}(e);delete Tn[l.$id]},l}function T(e,t,n,r){var a=t[n];return 4!==arguments.length?a.call(e):void a.call(e,r)}function E(e){var t=[];t.$id=Xt(),t.$model=e,t.$events={},t.$events[kt]=[],t._=$({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in bn)t[n]=bn[n];return avalon.mix(t,Nn),t}function A(e,t,n,r,a,o,i){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=this.$model.slice(t,t+n).map(function(e){return Nt.test(avalon.type(e))?e.$id?e:$(e,0,e):e});Sn.apply(this,[t,0].concat(c)),this._fire("add",t,n);break;case"del":var u=this._splice(t,n);this._fire("del",t,n)}a&&(e=a,t=o,n=i,s=2,a=0)}return this._fire("index",r),this.length!==l&&(this._.length=this.length),u}function k(e,t){for(var n={},r=0,a=t.length;a>r;r++){n[r]=e[r];var o=t[r];o in n?(e[r]=n[o],delete n[o]):e[r]=e[o]}}function O(e){It[wt]=e,avalon.openComputedCollect=!0;var t=e.evaluator;if(t)try{var n=Ln.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(r){delete e.evaluator;var a=e.element;if(3===a.nodeType){var o=a.parentNode;g.commentInterpolate?o.replaceChild(Ct.createComment(e.value),a):a.data=fn+e.value+pn}}avalon.openComputedCollect=!1,delete It[wt]}function M(e){var t=It[wt];e&&t&&avalon.Array.ensure(e,t)&&t.element&&_(t,e)}function _(e,t){e.$uuid=e.$uuid||Xt(),t.$uuid=t.$uuid||Xt();var n={data:e,list:t,$$uuid:e.$uuid+t.$uuid};jn[n.$$uuid]||(jn[n.$$uuid]=1,jn.push(n))}function S(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function N(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?"number"==typeof e.sourceIndex?0===e.sourceIndex:!Vt.contains(e):!avalon.contains(Vt,e)}function L(){for(var e,t=jn.length,n=t,r=0,a=[],o={},i={};e=jn[--t];){var l=e.data,s=l.type;o[s]?o[s]++:(o[s]=1,a.push(s))}var c=!1;if(a.forEach(function(e){Pn[e]!==o[e]&&(i[e]=1,c=!0)}),t=n,c)for(;e=jn[--t];)l=e.data,void 0!==l.element&&i[l.type]&&N(l.element)&&(r++,jn.splice(t,1),delete jn[e.$$uuid],avalon.Array.remove(e.list,l),S(l),e.data=e.list=null);Pn=o,Hn=new Date}function j(e){if(e&&e.length){new Date-Hn>444&&"object"==typeof e[0]&&L();for(var t,n=Bt.call(arguments,1),r=e.length;t=e[--r];){var a=t.element;if(a&&a.parentNode)if(t.$repeat)t.handler.apply(t,n);else if("on"!==t.type){var i=t.evaluator||o;t.handler(i.apply(0,t.args||[]),a,t)}}}}function H(e){var t=e.nodeName;return t.toLowerCase()===t&&e.scopeName&&""===e.outerText}function P(e){"url(#default#VML)"!==e.currentStyle.behavior&&(e.style.behavior="url(#default#VML)",e.style.display="inline-block",e.style.zoom=1)}function D(e,t,n){var r=setTimeout(function(){var a=e.innerHTML;clearTimeout(r),a===n?t():D(e,t,a)})}function F(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function B(e,t){for(var n,r=0;n=e[r++];)n.vmodels=t,Zt[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function I(e,t){return e.priority-t.priority}function R(e,t){for(var n,a,o=ar?ar(e):avalon.slice(e.attributes),i=[],l={},s=0;a=o[s++];)if(a.specified&&(n=a.name.match(zn))){var c=n[1],u=n[2]||"",f=a.value,p=a.name;if(l[p]=f,Gn[c]?(u=c,c="on"):Jn[c]&&(r("ms-"+c+"已经被废弃,请使用ms-attr-*代替"),"enabled"===c&&(c="disabled",f="!("+f+")"),u=c,c="attr",e.removeAttribute(p),p="ms-attr-"+u,e.setAttribute(p,f),n=[p],l[p]=f),"function"==typeof Zt[c]){var d={type:c,param:u,element:e,name:n[0],value:f,priority:c in Yn?Yn[c]:10*c.charCodeAt(0)+(Number(u)||0)};if("html"===c||"text"===c){var v=X(f);avalon.mix(d,v),d.filters=d.filters.replace(or,function(){return d.type="html",d.group=1,""})}"ms-if-loop"===p&&(d.priority+=100),t.length&&(i.push(d),"widget"===c&&(e.msData=e.msData||l))}}i.sort(I),l["ms-attr-checked"]&&l["ms-duplex"]&&r("warning!一个元素上不能同时定义ms-attr-checked与ms-duplex");var h=!0;for(s=0;d=i[s];s++){if(c=d.type,Zn.test(c))return B(i.slice(0,s+1),t);h&&(h=!Qn.test(c))}B(i,t),h&&!Wn[e.tagName]&&hn.test(e.innerHTML.replace(lr,"<").replace(sr,">"))&&(Xn&&Xn(e),V(e,t))}function V(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;W(n,n.nodeType,t),n=r}}function U(e,t){for(var n,r=0;n=e[r++];)W(n,n.nodeType,t)}function W(e,t,n){1===t?q(e,n):3===t&&dn.test(e.data)?Y(e,n):g.commentInterpolate&&8===t&&!dn.test(e.nodeValue)&&Y(e,n)}function q(e,t,n){var a=e.getAttribute("ms-skip");if(!e.getAttributeNode)return r("warning "+e.tagName+" no getAttributeNode method");var o=e.getAttributeNode("ms-important"),i=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(n=o||i){var l=avalon.vmodels[n.value];if(!l)return;t=n===o?[l]:[l].concat(t);var s=n.name;e.removeAttribute(s),avalon(e).removeClass(s),F(e,l)}R(e,t)}}function X(e){if(e.indexOf("|")>0){var t=e.replace(rstringLiteral,function(e){return Math.pow(10,e.length)}),n=t.replace(ir,"ᄢ㍄").indexOf("|");if(n>-1)return{filters:e.slice(n),value:e.slice(0,n),expr:!0}}return{value:e,filters:"",expr:!0}}function z(e){for(var t,n,r=[],a=0;;){if(n=e.indexOf(fn,a),-1===n)break;if(t=e.slice(a,n),t&&r.push({value:t,filters:"",expr:!1}),a=n+fn.length,n=e.indexOf(pn,a),-1===n)break;t=e.slice(a,n),t&&r.push(X(t)),a=n+pn.length}return t=e.slice(a),t&&r.push({value:t,expr:!1,filters:""}),r}function Y(e,t){var n=[];if(8===e.nodeType)var r=X(e.nodeValue),a=[r];else a=z(e.data);if(a.length){for(var o=0;r=a[o++];){var i=Ct.createTextNode(r.value);r.expr&&(r.type="text",r.element=i,r.filters=r.filters.replace(or,function(){return r.type="html",r.group=1,""}),n.push(r)),Ut.appendChild(i)}e.parentNode.replaceChild(Ut,e),n.length&&B(n,t)}}function G(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function J(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function Z(e){if(!("classList"in e)){e.classList={node:e};for(var t in cr)e.classList[t.slice(1)]=cr[t]}return e.classList}function Q(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:ur.test(e)?avalon.parseJSON(e):e}catch(t){}return e}function K(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}function et(e,t){if(e.offsetWidth<=0){if(Er.test(hr["@:get"](e,"display"))){var n={node:e};for(var r in Tr)n[r]=e.style[r],e.style[r]=Tr[r];t.push(n)}var a=e.parentNode;a&&1===a.nodeType&&et(a,t)}}function tt(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function nt(e,t,n,r){for(var a,o=[],i=" = "+n+".",l=e.length;a=e[--l];)t.hasOwnProperty(a)&&(o.push(a+i+a),r.vars.push(a),"duplex"===r.type&&(e.get=n+"."+a),e.splice(l,1));return o}function rt(e){for(var t=[],n={},r=0;r<e.length;r++){var a=e[r],o=a&&"string"==typeof a.$id?a.$id:a;n[o]||(n[o]=t.push(a))}return t}function at(e,t){return t=t.replace(Rr,"").replace(Vr,function(){return"],|"}).replace(Ur,function(e,t){return"["+Mr(t)}).replace(Wr,function(){return'"],["'}).replace(qr,function(){return'",'})+"]","return avalon.filters.$filter("+e+", "+t+")"}function ot(e,t,n){var a=n.type,i=n.filters||"",l=t.map(function(e){return String(e.$id).replace(Ir,"$1")})+e+a+i,s=Dr(e).concat(),c=[],u=[],f=[],p="";t=rt(t),n.vars=[];for(var d=0,v=t.length;v>d;d++)if(s.length){var h="vm"+wt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,nt(s,t[d],h,n))}if(c.length||"duplex"!==a){"duplex"!==a&&(e.indexOf("||")>-1||e.indexOf("&&")>-1)&&n.vars.forEach(function(t){var n=new RegExp("\\b"+t+"(?:\\.\\w+|\\[\\w+\\])+","ig");e=e.replace(n,function(n){var r=n.charAt(t.length),a=zt?e.slice(arguments[1]+n.length):RegExp.rightContext,o=/^\s*\(/.test(a);if("."===r||"["===r||o){var i="var"+String(Math.random()).replace(/^0\./,"");if(o){var l=n.split(".");if(l.length>2){var s=l.pop();return c.push(i+" = "+l.join(".")),i+"."+s}return n}return c.push(i+" = "+n),i}return n})}),n.args=f;var m=Fr[l];if(m)return void(n.evaluator=m);if(p=c.join(", "),p&&(p="var "+p),/\S/.test(i)){if(!/text|html/.test(n.type))throw Error("ms-"+n.type+"不支持过滤器");e="\nvar ret"+wt+" = "+e+";\r\n",e+=at("ret"+wt,i)}else{if("duplex"===a){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Br.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(o,u.concat(g)),n.evaluator=Fr(l,m)}catch(y){r("debug: parse error,"+y.message)}return}if("on"===a){-1===e.indexOf("(")?e+=".call(this, $event)":e=e.replace("(",".call(this,"),u.push("$event"),e="\nreturn "+e+";";var b=e.lastIndexOf("\nreturn"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(o,u.concat("'use strict';\n"+p+e)),n.evaluator=Fr(l,m)}catch(y){r("debug: parse error,"+y.message)}finally{s=textBuffer=u=null}}}function it(e,t,n,r,a){Array.isArray(r)&&(e=r.map(function(e){return e.expr?"("+e.value+")":Mr(e.value)}).join(" + ")),ot(e,t,n),n.evaluator&&!a&&(n.handler=Qt[n.handlerName||n.type],O(n))}function lt(e){return null==e?"":e}function st(e,t,n){return t.param.replace(/\w+/g,function(r){var a=avalon.duplexHooks[r];a&&"function"==typeof a[n]&&(e=a[n](e,t))}),e}function ct(){for(var e=na.length-1;e>=0;e--){var t=na[e];t()===!1&&na.splice(e,1)}na.length||clearInterval(ta)}function ut(e,t,n,r){var a=e.template.cloneNode(!0),o=avalon.slice(a.childNodes);n.$stamp&&a.insertBefore(n.$stamp,a.firstChild),t.appendChild(a);var i=[n].concat(e.vmodels),l={nodes:o,vmodels:i};r.push(l)}function ft(e,t){var n=e.proxies[t];return n?n.$stamp:e.element}function pt(e,t,n){for(;;){var r=t.previousSibling;if(!r)break;if(r.parentNode.removeChild(r),n&&n.call(r),r===e)break}}function dt(e){var t={$host:[],$outer:{},$stamp:1,$index:0,$first:!1,$last:!1,$remove:avalon.noop};t[e]={get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}};var n={$last:1,$first:1,$index:1},r=$(t,n),a=r.$events;return a[e]=a.$first=a.$last=a.$index,r.$id=Xt("$proxy$each"),r}function vt(e,t){for(var n,r=t.param||"el",a=0,o=oa.length;o>a;a++){var i=oa[a];i&&i.hasOwnProperty(r)&&(n=i,oa.splice(a,1))}n||(n=dt(r));var l=t.$repeat,s=l.length-1;return n.$index=e,n.$first=0===e,n.$last=e===s,n.$host=l,n.$outer=t.$outer,n.$stamp=t.clone.cloneNode(!1),n.$remove=function(){return l.removeAt(n.$index)},n}function ht(){var e=$({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Xt("$proxy$with"),e}function mt(e,t){var n=ia.pop();n||(n=ht());var r=t.$repeat;return n.$key=e,n.$host=r,n.$outer=t.$outer,r.$events?n.$events.$val=r.$events[e]:n.$events={},n}function gt(e,t){var n="each"===t?oa:ia;avalon.each(e,function(e,t){if(t.$events){for(var r in t.$events)Array.isArray(t.$events[r])&&(t.$events[r].forEach(function(e){"object"==typeof e&&S(e)}),t.$events[r].length=0);t.$host=t.$outer={},n.unshift(t)>g.maxRepeatSize&&n.pop()}}),"each"===t&&(e.length=0)}function yt(e,t){var n="_"+e;if(!yt[n]){var r=Ct.createElement(e);Vt.appendChild(r),t=Rt?getComputedStyle(r,null).display:r.currentStyle.display,Vt.removeChild(r),yt[n]=t}return yt[n]}function bt(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var a=isFinite(+e)?+e:0,o=isFinite(+t)?Math.abs(t):0,i="undefined"==typeof r?",":r,l="undefined"==typeof n?".":n,s="",c=function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)};return s=(o?c(a,o):""+Math.round(a)).split("."),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(s[1]||"").length<o&&(s[1]=s[1]||"",s[1]+=new Array(o-s[1].length+1).join("0")),s.join(l)}function xt(){Ct.body&&(gn&&(ha["domReady!"].state=4,gn.checkDeps()),ma.forEach(function(e){e(avalon)}),xt=o)}function $t(){try{Vt.doScroll("left"),xt()}catch(e){setTimeout($t)}}var wt=new Date-0,Ct=e.document,Tt=Ct.getElementsByTagName("head")[0],Et=Tt.insertBefore(document.createElement("avalon"),Tt.firstChild);Et.innerHTML="X<style id='avalonStyle'>.avalonHide{ display: none!important }</style>",Et.setAttribute("ms-skip","1"),Et.className="avalonHide";var At=/\[native code\]/,kt="$"+wt,Ot=e.require,Mt=e.define,_t=!1,St=/[^, ]+/g,Nt=/^(?:object|array)$/,Lt=/^\[object SVG\w*Element\]$/,jt=/^\[object (?:Window|DOMWindow|global)\]$/,Ht=Object.prototype,Pt=Ht.hasOwnProperty,Dt=Ht.toString,Ft=Array.prototype,Bt=Ft.slice,It={},Rt=e.dispatchEvent,Vt=Ct.documentElement,Ut=Ct.createDocumentFragment(),Wt=Ct.createElement("div"),qt={};"Boolean Number String Function Array Date RegExp Object Error".replace(St,function(e){qt["[object "+e+"]"]=e.toLowerCase()});var Xt=function(e){return e=e||"avalon",(e+Math.random()+Math.random()).replace(/0\./g,"")},zt=s();avalon=function(e){return new avalon.init(e)},avalon.init=function(e){this[0]=this.element=e},avalon.fn=avalon.prototype=avalon.init.prototype,avalon.type=function(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?qt[Dt.call(e)]||"object":typeof e};var Yt="object"==typeof alert?function(e){try{return/^\s*\bfunction\b/.test(e+"")}catch(t){return!1}}:function(e){return"[object Function]"===Dt.call(e)};avalon.isFunction=Yt,avalon.isWindow=function(e){return e?e==e.document&&e.document!=e:!1},c(e)&&(avalon.isWindow=c);var Gt;for(Gt in avalon({}))break;var Jt="0"!==Gt;avalon.isPlainObject=function(e,t){if(!e||"object"!==avalon.type(e)||e.nodeType||avalon.isWindow(e))return!1;try{if(e.constructor&&!Pt.call(e,"constructor")&&!Pt.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(Jt)for(t in e)return Pt.call(e,t);for(t in e);return void 0===t||Pt.call(e,t)},At.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(e){return"[object Object]"===Dt.call(e)&&Object.getPrototypeOf(e)===Ht}),avalon.mix=avalon.fn.mix=function(){var e,t,n,r,a,o,i=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof i&&(c=i,i=arguments[1]||{},l++),"object"==typeof i||Yt(i)||(i={}),l===s&&(i=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e){n=i[t];try{r=e[t]}catch(u){continue}i!==r&&(c&&r&&(avalon.isPlainObject(r)||(a=Array.isArray(r)))?(a?(a=!1,o=n&&Array.isArray(n)?n:[]):o=n&&avalon.isPlainObject(n)?n:{},i[t]=avalon.mix(c,o,r)):void 0!==r&&(i[t]=r))}return i},avalon.mix({rword:St,subscribers:kt,version:1.391,ui:{},log:r,slice:Rt?function(e,t,n){return Bt.call(e,t,n)}:function(e,t,n){var r=[],a=e.length;if(void 0===n&&(n=a),"number"==typeof n&&isFinite(n)){t=u(t,a),n=u(n,a);for(var o=t;n>o;++o)r[o-t]=e[o]}return r},noop:o,error:function(e,t){throw new(t||Error)(e)},oneObject:i,range:function(e,t,n){n||(n=1),null==t&&(t=e||0,e=0);for(var r=-1,a=Math.max(0,Math.ceil((t-e)/n)),o=new Array(a);++r<a;)o[r]=e,e+=n;return o},eventHooks:{},bind:function(e,t,n,r){var a=avalon.eventHooks,o=a[t];"object"==typeof o&&(t=o.type,o.deel&&(n=o.deel(e,n)));var i=Rt?n:function(t){n.call(e,m(t))};return Rt?e.addEventListener(t,i,!!r):e.attachEvent("on"+t,i),i},unbind:function(e,t,n,r){var a=avalon.eventHooks,i=a[t],l=n||o;"object"==typeof i&&(t=i.type),Rt?e.removeEventListener(t,l,!!r):e.detachEvent("on"+t,l)},css:function(e,t,n){e instanceof avalon&&(e=e[0]);var r,a=/[_-]/.test(t)?J(t):t;if(t=avalon.cssName(a)||a,void 0===n||"boolean"==typeof n){r=hr[a+":get"]||hr["@:get"],"background"===t&&(t="backgroundColor");var o=r(e,t);return n===!0?parseFloat(o)||0:o}if(""===n)e.style[t]="";else{if(null==n||n!==n)return;isFinite(n)&&!avalon.cssNumber[a]&&(n+="px"),r=hr[a+":set"]||hr["@:set"],r(e,t,n)}},each:function(e,t){if(e){var n=0;if(f(e))for(var r=e.length;r>n&&t(n,e[n])!==!1;n++);else for(n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)break}},getWidgetData:function(e,t){var n=avalon(e).data(),r={};for(var a in n)0===a.indexOf(t)&&(r[a.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[a]);return r},Array:{ensure:function(e,t){return-1===e.indexOf(t)?e.push(t):void 0},removeAt:function(e,t){return!!e.splice(t,1).length},remove:function(e,t){var n=e.indexOf(t);return~n?avalon.Array.removeAt(e,n):!1}}});var Zt=avalon.bindingHandlers={},Qt=avalon.bindingExecutors={};if(avalon.nextTick=e.setImmediate?setImmediate.bind(e):function(e){setTimeout(e,0)},!"司徒正美".trim){var Kt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(Kt,"")}}var en=!{toString:null}.propertyIsEnumerable("toString"),tn=function(){}.propertyIsEnumerable("prototype"),nn=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],rn=nn.length;if(Object.keys||(Object.keys=function(e){var t=[],n=tn&&"function"==typeof e;if("string"==typeof e||e&&e.callee)for(var r=0;r<e.length;++r)t.push(String(r));else for(var a in e)n&&"prototype"===a||!Pt.call(e,a)||t.push(String(a));if(en)for(var o=e.constructor,i=o&&o.prototype===e,l=0;rn>l;l++){var s=nn[l];i&&"constructor"===s||!Pt.call(e,s)||t.push(s)}return t}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Dt.call(e)}),o.bind||(Function.prototype.bind=function(e){if(arguments.length<2&&void 0===e)return this;var t=this,n=arguments;return function(){var r,a=[];for(r=1;r<n.length;r++)a.push(n[r]);for(r=0;r<arguments.length;r++)a.push(arguments[r]);return t.apply(e,a)}}),At.test([].map)||avalon.mix(Ft,{indexOf:function(e,t){var n=this.length,r=~~t;for(0>r&&(r+=n);n>r;r++)if(this[r]===e)return r;return-1},lastIndexOf:function(e,t){var n=this.length,r=null==t?n-1:t;for(0>r&&(r=Math.max(0,n+r));r>=0;r--)if(this[r]===e)return r;return-1},forEach:p("","_",""),filter:p("r=[],j=0,","if(_)r[j++]=this[i]","return r"),map:p("r=[],","r[i]=_","return r"),some:p("","if(_)return true","return false"),every:p("","if(!_)return false","return true")}),avalon.contains=d,Vt.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),Ct.contains||(Ct.contains=function(e){return d(Ct,e)}),e.SVGElement){var an="http://www.w3.org/2000/svg",on=Ct.createElementNS(an,"svg");on.innerHTML='<circle cx="50" cy="50" r="40" fill="red" />',Lt.test(on.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:v,set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,r=avalon.parseHTML(e);if("svg"===t)n.insertBefore(r,this);else{var a=Ct.createDocumentFragment();h(r,a),n.insertBefore(a,this)}n.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var e=this.outerHTML,t=new RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),n=new RegExp("</"+this.nodeName+">$","i");return e.replace(t,"").replace(n,"")},set:function(e){if(avalon.clearHTML){avalon.clearHTML(this);var t=avalon.parseHTML(e);h(t,this)}}}})}!Vt.outerHTML&&e.HTMLElement&&HTMLElement.prototype.__defineGetter__("outerHTML",v);var ln=/^(?:mouse|contextmenu|drag)|click/,sn=avalon.eventHooks;if("onmouseenter"in Vt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){sn[e]={type:t,deel:function(t,n){return function(r){var a=r.relatedTarget;return a&&(a===t||16&t.compareDocumentPosition(a))?void 0:(delete r.type,r.type=e,n.call(t,r))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!sn.animationend&&(sn.animationend={type:n})}),"oninput"in Ct.createElement("input")||(sn.input={type:"propertychange",deel:function(e,t){return function(n){return"value"===n.propertyName?(n.type="input",t.call(e,n)):void 0}}}),void 0===Ct.onmousewheel){var cn=void 0!==Ct.onwheel?"wheel":"DOMMouseScroll",un="wheel"===cn?"deltaY":"detail";sn.mousewheel={type:cn,deel:function(e,t){return function(n){n.wheelDeltaY=n.wheelDelta=n[un]>0?-120:120,n.wheelDeltaX=0,Object.defineProperty&&Object.defineProperty(n,"type",{value:"mousewheel"}),t.call(e,n)}}}}var fn,pn,dn,vn,hn,mn=/[-.*+?^${}()|[\]\/\\]/g,gn=o,yn={loader:function(t){e.define=t?gn.define:Mt,e.require=t?gn:Ot},interpolate:function(e){if(fn=e[0],pn=e[1],fn===pn)throw new SyntaxError("openTag!==closeTag");if(e+""=="<!--,-->")g.commentInterpolate=!0;else{var t=fn+"test"+pn;if(Wt.innerHTML=t,Wt.innerHTML!==t&&Wt.innerHTML.indexOf("&lt;")>-1)throw new SyntaxError("此定界符不合法");Wt.innerHTML=""}var n=y(fn),r=y(pn);dn=new RegExp(n+"(.*?)"+r),vn=new RegExp(n+"(.*?)"+r,"g"),hn=new RegExp(n+".*?"+r+"|\\sms-")}};g.debug=!0,g.plugins=yn,g.plugins.interpolate(["{{","}}"]),g.paths={},g.shim={},g.maxRepeatSize=100,avalon.config=g;var bn={$watch:function(e,t){if("function"==typeof t){var n=this.$events[e];n?n.push(t):this.$events[e]=[t]}else this.$events=this.$watch.backup;return this},$unwatch:function(e,t){var n=arguments.length;if(0===n)this.$watch.backup=this.$events,this.$events={};else if(1===n)this.$events[e]=[];else for(var r=this.$events[e]||[],a=r.length;~--a<0;)if(r[a]===t)return r.splice(a,1);return this},$fire:function(e){var t,n,r,a;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var o=this.$events,i=Bt.call(arguments,1),l=[e].concat(i);if("all"===t)for(n in avalon.vmodels)r=avalon.vmodels[n],r!==this&&r.$fire.apply(r,l);else if("up"===t||"down"===t){var s=o.expr?$n(o.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(r=avalon.vmodels[n],r!==this&&r.$events.expr){var c=$n(r.$events.expr);if(0===c.length)continue;Array.prototype.forEach.call(c,function(e){Array.prototype.forEach.call(s,function(n){var a="down"===t?n.contains(e):e.contains(n);a&&(e._avalon=r)})})}var u=Ct.getElementsByTagName("*"),f=[];for(Array.prototype.forEach.call(u,function(e){e._avalon&&(f.push(e._avalon),e._avalon="",e.removeAttribute("_avalon"))}),"up"===t&&f.reverse(),n=0;(a=f[n++])&&a.$fire.apply(a,l)!==!1;);}else{var p=o[e]||[],d=o.$all||[];for(n=0;a=p[n++];)Yt(a)&&a.apply(this,i);for(n=0;a=d[n++];)Yt(a)&&a.apply(this,arguments)}}},xn=/(\w+)\[(avalonctrl)="(\S+)"\]/,$n=Ct.querySelectorAll?function(e){return Ct.querySelectorAll(e)}:function(e){for(var t,n=e.match(xn),r=Ct.getElementsByTagName(n[1]),a=[],o=0;t=r[o++];)t.getAttribute(n[2])===n[3]&&a.push(t);return a},wn=avalon.vmodels={};avalon.define=function(e,t){var n=e.$id||e;if(n||r("warning: vm必须指定$id"),wn[n]&&r("warning: "+n+" 已经存在于avalon.vmodels中"),"object"==typeof e)var a=$(e);else{var i={$watch:o};t(i),a=$(i),_t=!0,t(a),_t=!1}return a.$id=n,wn[n]=a};var Cn=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray").match(St),Tn={},En=Object.defineProperty,An=!0;try{En({},"_",{value:"x"});var kn=Object.defineProperties}catch(On){An=!1}var Mn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},_n=Rt?function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t}:function(e){return e};An||("__defineGetter__"in avalon&&(En=function(e,t,n){return"value"in n&&(e[t]=n.value),"get"in n&&e.__defineGetter__(t,n.get),"set"in n&&e.__defineSetter__(t,n.set),e},kn=function(e,t){for(var n in t)t.hasOwnProperty(n)&&En(e,n,t[n]);return e}),zt&&(e.execScript(["Function parseVB(code)"," ExecuteGlobal(code)","End Function","Dim VBClassBodies",'Set VBClassBodies=CreateObject("Scripting.Dictionary")',"Function findOrDefineVBClass(name,body)"," Dim found",' found=""'," For Each key in VBClassBodies"," If body=VBClassBodies.Item(key) Then"," found=key"," Exit For"," End If"," next",' If found="" Then',' parseVB("Class " + name + body)'," VBClassBodies.Add name, body"," found=name"," End If"," findOrDefineVBClass=found","End Function"].join("\n"),"VBScript"),kn=function(t,n,r){var a="VBClass"+setTimeout("1"),o=[];o.push("\r\n Private [__data__], [__proxy__]"," Public Default Function [__const__](d, p)"," Set [__data__] = d: set [__proxy__] = p"," Set [__const__] = Me"," End Function");for(t in r)n.hasOwnProperty(t)||o.push(" Public ["+t+"]");Cn.forEach(function(e){n.hasOwnProperty(e)||o.push(" Public ["+e+"]")}),o.push(" Public [hasOwnProperty]");for(t in n)o.push(" Public Property Let ["+t+"](val"+wt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+wt+")"," End Property"," Public Property Set ["+t+"](val"+wt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+wt+")"," End Property"," Public Property Get ["+t+"]"," On Error Resume Next"," Set["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," If Err.Number <> 0 Then"," ["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," End If"," On Error Goto 0"," End Property");o.push("End Class");var i=o.join("\r\n"),l=e.findOrDefineVBClass(a,i);l===a&&e.parseVB(["Function "+a+"Factory(a, b)"," Dim o"," Set o = (New "+a+")(a, b)"," Set "+a+"Factory = o","End Function"].join("\r\n"));var s=e[l+"Factory"](n,T);return s}));var Sn=Ft.splice,Nn={_splice:Sn,_fire:function(e,t,n){j(this.$events[kt],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Ft.push.apply(this.$model,e),A.call(this,"add",n,t,n)),t+n},push:function(){var e,t=[],n=arguments.length;for(e=0;n>e;e++)t[e]=arguments[e];return this.pushArray(arguments)},unshift:function(){var e=arguments.length,t=this.length;return e&&(Ft.unshift.apply(this.$model,arguments),A.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return A.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return A.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,r=[],a=Sn.apply(this.$model,arguments);return a.length&&(r.push("del",e,a.length,0),t=!0),n>2&&(t?r.splice(3,1,0,"add",e,n-2):r.push("add",e,n-2,0),t=!0),t?A.apply(this,r):[]},contains:function(e){return-1!==this.indexOf(e)},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>=0?(this.$model.splice(e,1),A.call(this,"del",e,1,0)):[]},clear:function(){return this.$model.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))e.forEach(function(e){this.remove(e)},this);else if("function"==typeof e)for(var t=this.length-1;t>=0;t--){var n=this[t];e(n,t)&&this.removeAt(t)}else this.clear()},ensure:function(e){return this.contains(e)||this.push(e),this},set:function(e,t){if(e>=0){var n=avalon.type(t);t&&t.$model&&(t=t.$model);var r=this[e];if("object"===n)for(var a in t)r.hasOwnProperty(a)&&(r[a]=t[a]);else"array"===n?r.clear().push.apply(r,t):r!==t&&(this[e]=t,this.$model[e]=t,this._fire("set",e,t))}return this}};"sort,reverse".replace(St,function(e){Nn[e]=function(){var t,n=this.$model,r=n.concat(),a=Math.random(),o=[];Ft[e].apply(n,arguments);for(var i=0,l=r.length;l>i;i++){var s=n[i],c=r[i];if(Mn(s,c))o.push(i);else{var u=r.indexOf(s);o.push(u),r[u]=a,t=!0}}return t&&(k(this,o),this._fire("move",o),this._fire("index",0)),this}});var Ln=/^(duplex|on)$/,jn=avalon.$$subscribers=[],Hn=new Date,Pn={},Dn={area:[1,"<map>"],param:[1,"<object>"],col:[2,"<table><tbody></tbody><colgroup>","</table>"],legend:[1,"<fieldset>"],option:[1,"<select multiple='multiple'>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],th:[3,"<table><tbody><tr>","</tr></tbody></table>"],td:[3,"<table><tbody><tr>"],g:[1,'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">',"</svg>"],_default:Rt?[0,""]:[1,"X<div>"]};Dn.optgroup=Dn.option,Dn.tbody=Dn.tfoot=Dn.colgroup=Dn.caption=Dn.thead,String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(St,function(e){Dn[e]=Dn.g
2
- });var Fn=/<([\w:]+)/,Bn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,In=Rt?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/gi,Rn=i(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),Vn=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,Un=Ct.createElement("script");avalon.parseHTML=function(e){if("string"!=typeof e)return Ct.createDocumentFragment();e=e.replace(Bn,"<$1></$2>").trim();var t,r,a=(Fn.exec(e)||["",""])[1].toLowerCase(),o=Dn[a]||Dn._default,i=Ut.cloneNode(!1),l=Wt;Rt||(e=e.replace(In,"<br class=msNoScope>$1")),l.innerHTML=o[1]+e+(o[2]||"");var s=l.getElementsByTagName("script");if(s.length)for(var c,u=0;c=s[u++];)Rn[c.type]&&(r=Un.cloneNode(!1),Ft.forEach.call(c.attributes,function(e){e&&e.specified&&(r[e.name]=e.value,r.setAttribute(e.name,e.value))}),r.text=c.text,c.parentNode.replaceChild(r,c));for(u=o[0];u--;l=l.lastChild);if(!Rt){for(s=l.getElementsByTagName("br"),n=s.length;c=s[--n];)"msNoScope"===c.className&&c.parentNode.removeChild(c);for(s=l.all,u=0;c=s[u++];)H(c)&&P(c)}for(;t=l.firstChild;)i.appendChild(t);return i},avalon.innerHTML=function(e,t){if(!Rt&&!In.test(t)&&!Vn.test(t))try{return void(e.innerHTML=t)}catch(n){}var r=this.parseHTML(t);this.clearHTML(e).appendChild(r)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},avalon.scan=function(e,t){e=e||Vt;var n=t?[].concat(t):[];q(e,n)};var Wn=i("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),qn=function(e,t,n){var r=e.getAttribute(t);if(r)for(var a,o=0;a=n[o++];)if(a.hasOwnProperty(r)&&"function"==typeof a[r])return a[r]},Xn=zt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var r=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=r}}:0,zn=/ms-(\w+)-?(.*)/,Yn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Gn=i("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),Jn=i("value,title,alt,checked,selected,disabled,readonly,enabled"),Zn=/^if|widget|repeat$/,Qn=/^each|with|html|include$/;if(!"1"[0])var Kn=l(512),er=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,tr=/^['"]/,nr=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,rr=/&amp;/g,ar=function(e){var t=e.outerHTML;if("</"===t.slice(0,2)||!t.trim())return[];var n,r,a,o=t.match(nr)[0],i=[];if(Kn[o])return Kn[o];for(;r=er.exec(o);){a=r[2],a&&(a=(tr.test(a)?a.slice(1,-1):a).replace(rr,"&"));var l=r[1].toLowerCase();n=l.match(zn);var s={name:l,specified:!0,value:a||""};i.push(s)}return Kn(o,i)};var or=/\|\s*html\s*/,ir=/\|\|/g,lr=/&lt;/g,sr=/&gt;/g;rstringLiteral=/(['"])(\\\1|.)+?\1/g;var cr={_toString:function(){var e=this.node,t=e.className,n="string"==typeof t?t:t.baseVal;return n.split(/\s+/).join(" ")},_contains:function(e){return(" "+this+" ").indexOf(" "+e+" ")>-1},_add:function(e){this.contains(e)||this._set(this+" "+e)},_remove:function(e){this._set((" "+this+" ").replace(" "+e+" "," "))},__set:function(e){e=e.trim();var t=this.node;Lt.test(t)?t.setAttribute("class",e):t.className=e}};"add,remove".replace(St,function(e){avalon.fn[e+"Class"]=function(t){var n=this[0];return t&&"string"==typeof t&&n&&1===n.nodeType&&t.replace(/\S+/g,function(t){Z(n)[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&Z(t).contains(e)},toggleClass:function(e,t){for(var n,r=0,a=e.split(/\s+/),o="boolean"==typeof t;n=a[r++];){var i=o?t:!this.hasClass(n);this[i?"addClass":"removeClass"](n)}return this},attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){switch(e="data-"+G(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return Q(n);case 0:var r={};return Ft.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=J(e.slice(5)),r[e]=Q(t.value)))}),r}},removeData:function(e){return e="data-"+G(e),this[0].removeAttribute(e),this},css:function(e,t){if(avalon.isPlainObject(e))for(var n in e)avalon.css(this,n,e[n]);else var r=avalon.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=avalon.css(e[0],"borderTopWidth",!0),r.left+=avalon.css(e[0],"borderLeftWidth",!0)),{top:t.top-r.top-avalon.css(n,"marginTop",!0),left:t.left-r.left-avalon.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===avalon.css(e,"position");)e=e.offsetParent;return avalon(e)},bind:function(e,t,n){return this[0]?avalon.bind(this[0],e,t,n):void 0},unbind:function(e,t,n){return this[0]&&avalon.unbind(this[0],e,t,n),this},val:function(e){var t=this[0];if(t&&1===t.nodeType){var n=0===arguments.length,r=n?":get":":set",a=kr[tt(t)+r];if(a)var o=a(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?o:this}});var ur=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,fr=/^[\],:{}\s]*$/,pr=/(?:^|:|,)(?:\s*\[)+/g,dr=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,vr=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g;avalon.parseJSON=e.JSON?JSON.parse:function(e){if("string"==typeof e){if(e=e.trim(),e&&fr.test(e.replace(dr,"@").replace(vr,"]").replace(pr,"")))return new Function("return "+e)();avalon.error("Invalid JSON: "+e)}return e},avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var r=this[0]||{},a=K(r),o="scrollTop"===e;return arguments.length?void(a?a.scrollTo(o?avalon(a).scrollLeft():n,o?n:avalon(a).scrollTop()):r[e]=n):a?t in a?a[t]:Vt[e]:r[e]}});var hr=avalon.cssHooks={},mr=["","-webkit-","-o-","-moz-","-ms-"],gr={"float":Rt?"cssFloat":"styleFloat"};if(avalon.cssNumber=i("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(gr[e])return gr[e];t=t||Vt.style;for(var r=0,a=mr.length;a>r;r++)if(n=J(mr[r]+e),n in t)return gr[e]=n;return null},hr["@:set"]=function(e,t,n){try{e.style[t]=n}catch(r){}},e.getComputedStyle)hr["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,r=getComputedStyle(e,null);return r&&(n="filter"===t?r.getPropertyValue(t):r[t],""===n&&(n=e.style[t])),n},hr["opacity:get"]=function(e){var t=hr["@:get"](e,"opacity");return""===t?"1":t};else{var yr=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,br=/^(top|right|bottom|left)$/,xr=/alpha\([^)]*\)/i,$r=!!e.XDomainRequest,wr="DXImageTransform.Microsoft.Alpha",Cr={thin:$r?"1px":"2px",medium:$r?"3px":"4px",thick:$r?"5px":"6px"};hr["@:get"]=function(e,t){var n=e.currentStyle,r=n[t];if(yr.test(r)&&!br.test(r)){var a=e.style,o=a.left,i=e.runtimeStyle.left;e.runtimeStyle.left=n.left,a.left="fontSize"===t?"1em":r||0,r=a.pixelLeft+"px",a.left=o,e.runtimeStyle.left=i}return"medium"===r&&(t=t.replace("Width","Style"),"none"===n[t]&&(r="0px")),""===r?"auto":Cr[r]||r},hr["opacity:set"]=function(e,t,n){var r=e.style,a=isFinite(n)&&1>=n?"alpha(opacity="+100*n+")":"",o=r.filter||"";r.zoom=1,r.filter=(xr.test(o)?o.replace(xr,a):o+" "+a).trim(),r.filter||r.removeAttribute("filter")},hr["opacity:get"]=function(e){var t=e.filters.alpha||e.filters[wr],n=t&&t.enabled?t.opacity:100;return n/100+""}}"top,left".replace(St,function(e){hr[e+":get"]=function(t){var n=hr["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Tr={position:"absolute",visibility:"hidden",display:"block"},Er=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(St,function(e){var t=e.toLowerCase(),n="client"+e,r="scroll"+e,a="offset"+e;hr[t+":get"]=function(t,n,r){var o=-4;"number"==typeof r&&(o=r),n="Width"===e?["Left","Right"]:["Top","Bottom"];var i=t[a];return 2===o?i+avalon.css(t,"margin"+n[0],!0)+avalon.css(t,"margin"+n[1],!0):(0>o&&(i=i-avalon.css(t,"border"+n[0]+"Width",!0)-avalon.css(t,"border"+n[1]+"Width",!0)),-4===o&&(i=i-avalon.css(t,"padding"+n[0],!0)-avalon.css(t,"padding"+n[1],!0)),i)},hr[t+"&get"]=function(e){var n=[];et(e,n);for(var r,a=hr[t+":get"](e),o=0;r=n[o++];){e=r.node;for(var i in r)"string"==typeof r[i]&&(e.style[i]=r[i])}return a},avalon.fn[t]=function(o){var i=this[0];if(0===arguments.length){if(i.setTimeout)return i["inner"+e]||i.document.documentElement[n];if(9===i.nodeType){var l=i.documentElement;return Math.max(i.body[r],l[r],i.body[a],l[a],l[n])}return hr[t+"&get"](i)}return this.css(t,o)},avalon.fn["inner"+e]=function(){return hr[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return hr[t+":get"](this[0],void 0,e===!0?2:0)}}),avalon.fn.offset=function(){var e=this[0],t={left:0,top:0};if(!e||!e.tagName||!e.ownerDocument)return t;var n=e.ownerDocument,r=n.body,a=n.documentElement,o=n.defaultView||n.parentWindow;if(!avalon.contains(a,e))return t;e.getBoundingClientRect&&(t=e.getBoundingClientRect());var i=a.clientTop||r.clientTop,l=a.clientLeft||r.clientLeft,s=Math.max(o.pageYOffset||0,a.scrollTop,r.scrollTop),c=Math.max(o.pageXOffset||0,a.scrollLeft,r.scrollLeft);return{top:t.top+s-i,left:t.left+c-l}};var Ar=/^<option(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s+value[\s=]/i,kr={"option:get":zt?function(e){return Ar.test(e.outerHTML)?e.value:e.text.trim()}:function(e){return e.value},"select:get":function(e,t){for(var n,r=e.options,a=e.selectedIndex,o=kr["option:get"],i="select-one"===e.type||0>a,l=i?null:[],s=i?a+1:r.length,c=0>a?s:i?a:0;s>c;c++)if(n=r[c],(n.selected||c===a)&&!n.disabled){if(t=o(n),i)return t;l.push(t)}return l},"select:set":function(e,t,n){t=[].concat(t);for(var r,a=kr["option:get"],o=0;r=e.options[o++];)(r.selected=t.indexOf(a(r))>-1)&&(n=!0);n||(e.selectedIndex=-1)}},Or={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},Mr=e.JSON&&JSON.stringify||function(e){return'"'+e.replace(/[\\\"\x00-\x1f]/g,function(e){var t=Or[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'},_r="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,undefined",Sr=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Nr=/[^\w$]+/g,Lr=new RegExp(["\\b"+_r.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),jr=/\b\d[^,]*/g,Hr=/^,+|,+$/g,Pr=l(512),Dr=function(e){var t=","+e.trim();if(Pr[t])return Pr[t];var n=e.replace(Sr,"").replace(Nr,",").replace(Lr,"").replace(jr,"").replace(Hr,"").split(/^$|,+/);return Pr(t,rt(n))},Fr=l(128),Br=/\w\[.*\]|\w\.\w/,Ir=/(\$proxy\$[a-z]+)\d+$/,Rr=/\)\s*$/,Vr=/\)\s*\|/g,Ur=/\|\s*([$\w]+)/g,Wr=/"\s*\["/g,qr=/"\s*\(/g;avalon.parseExprProxy=it;var Xr="autofocus,autoplay,async,allowTransparency,checked,controls,declare,disabled,defer,defaultChecked,defaultSelectedcontentEditable,isMap,loop,multiple,noHref,noResize,noShade,open,readOnly,selected",zr={};Xr.replace(St,function(e){zr[e.toLowerCase()]=e});var Yr={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},Gr="accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan,dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight,rowSpan,tabIndex,useMap,vSpace,valueType,vAlign";Gr.replace(St,function(e){Yr[e.toLowerCase()]=e});var Jr=/<noscript.*?>(?:[\s\S]+?)<\/noscript>/gim,Zr=/<noscript.*?>([\s\S]+?)<\/noscript>/im,Qr=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},Kr=avalon.templateCache={};Zt.attr=function(e,t){var n=e.value.trim(),r=!0;if(n.indexOf(fn)>-1&&n.indexOf(pn)>2&&(r=!1,dn.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(r=!0,n=RegExp.$1)),"include"===e.type){var a=e.element;e.includeRendered=qn(a,"data-include-rendered",t),e.includeLoaded=qn(a,"data-include-loaded",t);var o=e.includeReplaced=!!avalon(a).data("includeReplace");e.startInclude=Ct.createComment("ms-include"),e.endInclude=Ct.createComment("ms-include-end"),o?(e.element=e.startInclude,a.parentNode.insertBefore(e.startInclude,a),a.parentNode.insertBefore(e.endInclude,a.nextSibling)):(a.insertBefore(e.startInclude,a.firstChild),a.appendChild(e.endInclude))}e.handlerName="attr",it(n,t,e,r?0:z(e.value))},Qt.attr=function(t,n,r){var a=r.type,o=r.param;if("css"===a)avalon(n).css(o,t);else if("attr"===a){if(zr[o]){var i=zr[o];if("boolean"==typeof n[i])return n[i]=!!t}var l=t===!1||null===t||void 0===t;if(!Rt&&Yr[o]&&(o=Yr[o]),l)return n.removeAttribute(o);var s=Lt.test(n)?!1:Ct.namespaces&&H(n)?!0:o in n.cloneNode(!1);s?n[o]=t:n.setAttribute(o,t)}else if("include"===a&&t){var c=r.vmodels,u=r.includeRendered,f=r.includeLoaded,p=r.includeReplaced,d=p?n.parentNode:n,v=function(e){for(f&&(e=f.apply(d,[e].concat(c))),u&&D(d,function(){u.call(d)},0/0);;){var t=r.startInclude.nextSibling;if(!t||t===r.endInclude)break;d.removeChild(t)}var n=avalon.parseHTML(e),a=avalon.slice(n.childNodes);d.insertBefore(n,r.endInclude),U(a,c)};if("src"===r.param)if(Kr[t])avalon.nextTick(function(){v(Kr[t])});else{var h=Qr();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;(e>=200&&300>e||304===e||1223===e)&&v(Kr[t]=h.responseText)}},h.open("GET",t,!0),"withCredentials"in h&&(h.withCredentials=!0),h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.send(null)}else{var m=t&&1===t.nodeType?t:Ct.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=Qr(),h.open("GET",location,!1),h.send(null);for(var g=Ct.getElementsByTagName("noscript"),y=(h.responseText||"").match(Jr)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(Zr)||["","&nbsp;"])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Vt.hasAttribute||"string"!=typeof t||"src"!==a&&"href"!==a||(t=t.replace(/&amp;/g,"&")),n[a]=t,e.chrome&&"EMBED"===n.tagName){var w=n.parentNode,C=document.createComment("ms-src");w.replaceChild(C,n),w.replaceChild(n,C)}},"title,alt,src,value,css,include,href".replace(St,function(e){Zt[e]=Zt.attr}),Zt["class"]=function(e,t){var n,a=e.param,o=e.value;if(e.handlerName="class",!a||isFinite(a)){e.param="";var i=o.replace(vn,function(e){return e.replace(/./g,"0")}),l=i.indexOf(":");if(-1===l)var s=o;else{if(s=o.slice(0,l),n=o.slice(l+1),ot(n,t,e),!e.evaluator)return r("debug: ms-class '"+(n||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=dn.test(s);c||(e.immobileClass=s),it("",t,e,c?z(s):0)}else e.immobileClass=e.oldStyle=e.param,it(o,t,e)},Qt["class"]=function(e,t,n){var r=avalon(t),a=n.type;if("class"===a&&n.oldStyle)r.toggleClass(n.oldStyle,!!e);else switch(n.toggleClass=n._evaluator?!!n._evaluator.apply(t,n._args):!0,n.newClass=n.immobileClass||e,n.oldClass&&n.newClass!==n.oldClass&&r.removeClass(n.oldClass),n.oldClass=n.newClass,a){case"class":r.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var o="mouseenter",i="mouseleave";if("active"===a){t.tabIndex=t.tabIndex||-1,o="mousedown",i="mouseup";var l=r.bind("mouseleave",function(){n.toggleClass&&r.removeClass(n.newClass)})}var s=r.bind(o,function(){n.toggleClass&&r.addClass(n.newClass)}),c=r.bind(i,function(){n.toggleClass&&r.removeClass(n.newClass)});n.rollback=function(){r.unbind("mouseleave",l),r.unbind(o,s),r.unbind(i,c)},n.hasBindEvent=!0}}},"hover,active".replace(St,function(e){Zt[e]=Zt["class"]}),Qt.data=function(e,t,n){var r="data-"+n.param;e&&"object"==typeof e?t[r]=e:t.setAttribute(r,String(e))};var ea=Zt.duplex=function(e,t){var n,a=e.element;if(it(e.value,t,e,0,1),e.changed=qn(a,"data-duplex-changed",t)||o,e.evaluator&&e.args){var l=[],s=i("string,number,boolean,checked");"radio"===a.type&&""===e.param&&(e.param="checked"),a.msData&&(a.msData["ms-duplex"]=e.value),e.param.replace(/\w+/g,function(t){/^(checkbox|radio)$/.test(a.type)&&/^(radio|checked)$/.test(t)&&("radio"===t&&r("ms-duplex-radio已经更名为ms-duplex-checked"),t="checked",e.isChecked=!0),"bool"===t?(t="boolean",r("ms-duplex-bool已经更名为ms-duplex-boolean")):"text"===t&&(t="string",r("ms-duplex-text已经更名为ms-duplex-string")),s[t]&&(n=!0),avalon.Array.ensure(l,t)}),n||l.push("string"),e.param=l.join("-"),e.bound=function(t,n){a.addEventListener?a.addEventListener(t,n,!1):a.attachEvent("on"+t,n);var r=e.rollback;e.rollback=function(){a.avalonSetter=null,avalon.unbind(a,t,n),r&&r()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=st);f(null,e,"init");var p=a.tagName;ea[p]&&ea[p](a,e.evaluator.apply(null,e.args),e)}};avalon.duplexHooks={checked:{get:function(e,t){return!t.element.oldValue}},string:{get:function(e){return e},set:lt},"boolean":{get:function(e){return"true"===e},set:lt},number:{get:function(e){return isFinite(e)?parseFloat(e)||0:e},set:lt}};var ta,na=[];avalon.tick=function(e){1===na.push(e)&&(ta=setInterval(ct,60))};var ra=o;!new function(){function e(e){avalon.contains(Vt,this)&&(t[this.tagName].call(this,e),this.avalonSetter&&this.avalonSetter())}try{var t={},n=HTMLInputElement.prototype,r=HTMLTextAreaElement.prototype,a=HTMLInputElement.prototype;Object.getOwnPropertyNames(a),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(r,"value").set,Object.defineProperty(r,"value",{set:e})}catch(o){ra=avalon.tick}},zt&&avalon.bind(Ct,"selectionchange",function(){var e=Ct.activeElement;e&&"function"==typeof e.avalonSetter&&e.avalonSetter()}),ea.INPUT=function(e,t,n){function a(e){n.changed.call(this,e,n)}function o(){p=!0}function i(){p=!1}function l(){if(!p){var r=e.oldValue=e.value,o=n.pipe(r,n,"get");f.data("duplex-observe")!==!1&&(t(o),a.call(e,o),f.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}}function s(e){setTimeout(function(){l(e)})}var c=e.type,u=n.bound,f=avalon(e),p=!1;if(n.handler=function(){var r=n.pipe(t(),n,"set")+"";r!==e.oldValue&&(e.value=r)},n.isChecked||"radio"===e.type){var d=6===zt;l=function(){if(f.data("duplex-observe")!==!1){var r=n.pipe(e.value,n,"get");t(r),a.call(e,r)}},n.handler=function(){var r=t(),a=n.isChecked?!!r:r+""===e.value;e.oldValue=a,d?setTimeout(function(){e.defaultChecked=a,e.checked=a},31):e.checked=a},u("click",l)}else if("checkbox"===c)l=function(){if(f.data("duplex-observe")!==!1){var o=e.checked?"ensure":"remove",i=t();Array.isArray(i)||(r("ms-duplex应用于checkbox上要对应一个数组"),i=[i]),avalon.Array[o](i,n.pipe(e.value,n,"get")),a.call(e,i)}},n.handler=function(){var r=[].concat(t());e.checked=r.indexOf(n.pipe(e.value,n,"get"))>-1},u(Rt?"change":"click",l);else{var v=e.getAttribute("data-duplex-event")||e.getAttribute("data-event")||"input";e.attributes["data-event"]&&r("data-event指令已经废弃,请改用data-duplex-event"),v.replace(St,function(e){switch(e){case"input":zt?(zt>8?u("input",l):u("propertychange",function(e){"value"===e.propertyName&&l()}),u("dragend",s)):(u("input",l),u("compositionstart",o),u("compositionend",i),u("DOMAutoComplete",l));break;default:u(e,l)}})}/text|password/.test(e.type)&&ra(function(){if(Vt.contains(e))e.value!==e.oldValue&&l();else if(!e.msRetain)return!1}),e.avalonSetter=l,e.oldValue=e.value,O(n),a.call(e,e.value)},ea.TEXTAREA=ea.INPUT,ea.SELECT=function(e,t,n){function a(){if(o.data("duplex-observe")!==!1){var r=o.val();r=Array.isArray(r)?r.map(function(e){return n.pipe(e,n,"get")}):n.pipe(r,n,"get"),r+""!==e.oldValue&&t(r),n.changed.call(e,r,n)}}var o=avalon(e);n.handler=function(){var n=t();n=n&&n.$model||n,Array.isArray(n)?e.multiple||r("ms-duplex在<select multiple=true>上要求对应一个数组"):e.multiple&&r("ms-duplex在<select multiple=false>不能对应一个数组"),n=Array.isArray(n)?n.map(String):n+"",n+""!==e.oldValue&&(o.val(n),e.oldValue=n+"")},n.bound("change",a),D(e,function(){O(n),n.changed.call(e,t(),n)},0/0)},Qt.html=function(e,t,n){e=null==e?"":e;var r="group"in n,a=r?t.parentNode:t;if(a){if(11===e.nodeType)var o=e;else if(1===e.nodeType||e.item){var i=1===e.nodeType?e.childNodes:e.item?e:[];for(o=Ut.cloneNode(!0);i[0];)o.appendChild(i[0])}else o=avalon.parseHTML(e);var l=Ct.createComment("ms-html");if(r){a.insertBefore(l,t);for(var s=n.group,c=1;s>c;){var u=t.nextSibling;u&&(a.removeChild(u),c++)}a.removeChild(t),n.element=l}else avalon.clearHTML(a).appendChild(l);r&&(n.group=o.childNodes.length||1),i=avalon.slice(o.childNodes),i[0]&&(l.parentNode&&l.parentNode.replaceChild(o,l),r&&(n.element=i[0])),U(i,n.vmodels)}},Zt["if"]=Zt.data=Zt.text=Zt.html=function(e,t){it(e.value,t,e)},Qt["if"]=function(e,t,n){if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),R(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=Ct.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,Et.appendChild(t),n.rollback=function(){t.parentNode===Et&&Et.removeChild(t)}}};var aa=/\(([^)]*)\)/;Zt.on=function(e,t){var n=e.value;e.type="on";var r=e.param.replace(/-\d+$/,"");if("function"==typeof Zt.on[r+"Hook"]&&Zt.on[r+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var a=(n.match(aa)||["",""])[1].trim();(""===a||"$event"===a)&&(n=n.replace(aa,""))}it(n,t,e)},Qt.on=function(e,t,n){e=function(e){var t=n.evaluator||o;return t.apply(this,n.args.concat(e))};var r=n.param.replace(/-\d+$/,"");if("scan"===r)e.call(t,{type:r});else if("function"==typeof n.specialBind)n.specialBind(t,e);else var a=avalon.bind(t,r,e);n.rollback=function(){"function"==typeof n.specialUnbind?n.specialUnbind():avalon.unbind(t,r,a)}},Zt.repeat=function(e,t){var n=e.type;it(e.value,t,e,0,1),e.proxies=[];var r=!1;try{var a=e.$repeat=e.evaluator.apply(0,e.args||[]),o=avalon.type(a);"object"!==o&&"array"!==o&&(r=!0,avalon.log("warning:"+e.value+"对应类型不正确"))}catch(i){r=!0,avalon.log("warning:"+e.value+"编译出错")}var l=e.value.split(".")||[];if(l.length>1){l.pop();for(var s,c=l[0],u=0;s=t[u++];)if(s&&s.hasOwnProperty(c)){var f=s[c].$events||{};f[kt]=f[kt]||[],f[kt].push(e);break}}var p=e.element;p.removeAttribute(e.name),e.sortedCallback=qn(p,"data-with-sorted",t),e.renderedCallback=qn(p,"data-"+n+"-rendered",t);var d=Xt(n),v=e.element=Ct.createComment(d+":end");if(e.clone=Ct.createComment(d),Ut.appendChild(v),"each"===n||"with"===n?(e.template=p.innerHTML.trim(),avalon.clearHTML(p).appendChild(v)):(e.template=p.outerHTML.trim(),p.parentNode.replaceChild(v,p)),e.template=avalon.parseHTML(e.template),e.rollback=function(){var t=e.element;if(t){Qt.repeat.call(e,"clear");var n=t.parentNode,r=e.template,a=r.firstChild;n.replaceChild(r,t);var o=e.$stamp;o&&o.parentNode&&o.parentNode.removeChild(o),a=e.element="repeat"===e.type?a:n}},!r){e.handler=Qt.repeat,e.$outer={};var h="$key",m="$val";for(Array.isArray(a)&&(h="$first",m="$last"),u=0;s=t[u++];)if(s.hasOwnProperty(h)&&s.hasOwnProperty(m)){e.$outer=s;break}var g=a.$events,y=(g||{})[kt];if(y&&avalon.Array.ensure(y,e)&&_(e,y),"object"===o){e.$with=!0;var b=g?g.$withProxyPool||(g.$withProxyPool={}):{};e.handler("append",a,b)}else a.length&&e.handler("add",0,a.length)}},Qt.repeat=function(e,t,n){if(e){var r=this,a=r.element,i=a.parentNode,l=r.proxies,s=Ut.cloneNode(!1);switch(e){case"add":for(var c,u=t+n,f=r.$repeat,p=f.length-1,d=[],v=ft(r,t),h=t;u>h;h++){var m=vt(h,r);l.splice(h,0,m),ut(r,s,m,d)}for(i.insertBefore(s,v),h=0;c=d[h++];)U(c.nodes,c.vmodels),c.nodes=c.vmodels=null;break;case"del":v=l[t].$stamp,a=ft(r,t+n),pt(v,a);var g=l.splice(t,n);gt(g,"each");break;case"clear":var y=r.$stamp||l[0];y&&(v=y.$stamp||y,pt(v,a)),gt(l,"each");break;case"move":v=l[0].$stamp;var b,x=v.nodeValue,$=[],w=[];for(pt(v,a,function(){w.unshift(this),this.nodeValue===x&&($.unshift(w),w=[])}),k(l,t),k($,t);w=$.shift();)for(;b=w.shift();)s.appendChild(b);i.insertBefore(s,a);break;case"index":for(p=l.length-1;n=l[t];t++)n.$index=t,n.$first=0===t,n.$last=t===p;return;case"set":return m=l[t],void(m&&j(m.$events.$index));case"append":var C=n,T=[];d=[];for(var E in t)t.hasOwnProperty(E)&&"hasOwnProperty"!==E&&T.push(E);if(r.sortedCallback){var A=r.sortedCallback.call(i,T);A&&Array.isArray(A)&&A.length&&(T=A)}for(h=0;E=T[h++];)"hasOwnProperty"!==E&&(C[E]||(C[E]=mt(E,r)),ut(r,s,C[E],d));var O=r.$stamp=r.clone;for(i.insertBefore(O,a),i.insertBefore(s,a),h=0;c=d[h++];)U(c.nodes,c.vmodels),c.nodes=c.vmodels=null}"clear"===e&&(e="del");var M=r.renderedCallback||o,_=arguments;D(i,function(){M.apply(i,_),i.oldValue&&"SELECT"===i.tagName&&avalon(i).val(i.oldValue.split(","))},0/0)}},"with,each".replace(St,function(e){Zt[e]=Zt.repeat});var oa=[],ia=[];Qt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else"textContent"in t?t.textContent=e:t.innerText=e},avalon.parseDisplay=yt,Zt.visible=function(e,t){var n=avalon(e.element),r=n.css("display");if("none"===r){var a=n[0].style,o=/visibility/i.test(a.cssText),i=n.css("visibility");a.display="",a.visibility="hidden",r=n.css("display"),"none"===r&&(r=yt(n[0].nodeName)),a.visibility=o?i:""}e.display=r,it(e.value,t,e)},Qt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Zt.widget=function(t,n){var r=t.value.match(St),a=t.element,i=r[0],l=r[1];l&&"$"!==l||(l=Xt(i));var s=r[2]||i,c=avalon.ui[i];if("function"==typeof c){n=a.vmodels||n;for(var u,f=0;u=n[f++];)if(u.hasOwnProperty(s)&&"object"==typeof u[s]){var p=u[s];p=p.$model||p;break}if(p){var d=p[i+"Id"];"string"==typeof d&&(l=d)}var v=avalon.getWidgetData(a,i);t.value=[i,l,s].join(","),t[i+"Id"]=l,t.evaluator=o,a.msData["ms-widget-id"]=l;var h=t[i+"Options"]=avalon.mix({},c.defaults,p||{},v);a.removeAttribute("ms-widget");var m=c(a,t,n)||{};m.$id?(avalon.vmodels[l]=m,F(a,m),m.hasOwnProperty("$init")&&m.$init(function(){avalon.scan(a,[m].concat(n)),"function"==typeof h.onInit&&h.onInit.call(a,m,h,n)}),t.rollback=function(){try{m.widgetElement=null,m.$remove()}catch(e){}a.msData={},delete avalon.vmodels[m.$id]},_(t,la),e.chrome&&a.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(L)})):avalon.scan(a,n)}else n.length&&(a.vmodels=n)};var la=[],sa=/<script[^>]*>([\S\s]*?)<\/script\s*>/gim,ca=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,ua=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,fa={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},pa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,da=/([^\#-~| |!])/g,va=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n=void 0===n?"...":n,e.length>t?e.slice(0,t-n.length)+n:String(e)},$filter:function(e){for(var t=1,n=arguments.length;n>t;t++){var r=arguments[t],a=avalon.filters[r.shift()];if("function"==typeof a){var o=[e].concat(r);e=a.apply(null,o)}}return e},camelize:J,sanitize:function(e){return e.replace(sa,"").replace(ua,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=fa[t[1]];n&&(e=e.replace(n,function(e,t,n){var r=n.charAt(0);return t+"="+r+"javascript:void(0)"+r}))}return e.replace(ca," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&amp;").replace(pa,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(da,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},currency:function(e,t,n){return(t||"¥")+bt(e,isFinite(n)?n:2)},number:function(e,t){return bt(e,isFinite(t)?t:3)}};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var r="";for(0>e&&(r="-",e=-e),e=""+e;e.length<t;)e="0"+e;return n&&(e=e.substr(e.length-t)),r+e}function n(e,n,r,a){return function(o){var i=o["get"+e]();return(r>0||i>-r)&&(i+=r),0===i&&-12===r&&(i=12),t(i,n,a)}}function r(e,t){return function(n,r){var a=n["get"+e](),o=(t?"SHORT"+e:e).toUpperCase();return r[o][a]}}function a(e){var n=-1*e.getTimezoneOffset(),r=n>=0?"+":"";return r+=t(Math[n>0?"floor":"ceil"](n/60),2)+t(Math.abs(n%60),2)}function o(e,t){return e.getHours()<12?t.AMPMS[0]:t.AMPMS[1]}var i={yyyy:n("FullYear",4),yy:n("FullYear",2,0,!0),y:n("FullYear",1),MMMM:r("Month"),MMM:r("Month",!0),MM:n("Month",2,1),M:n("Month",1,1),dd:n("Date",2),d:n("Date",1),HH:n("Hours",2),H:n("Hours",1),hh:n("Hours",2,-12),h:n("Hours",1,-12),mm:n("Minutes",2),m:n("Minutes",1),ss:n("Seconds",2),s:n("Seconds",1),sss:n("Milliseconds",3),EEEE:r("Day"),EEE:r("Day",!0),a:o,Z:a},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;va.date=function(t,n){var r,a,o=va.date.locate,c="",u=[];if(n=n||"mediumDate",n=o[n]||n,"string"==typeof t)if(/^\d+$/.test(t))t=e(t);else if(s.test(t))t=+RegExp.$1;else{var f=t.trim(),p=[0,0,0,0,0,0,0],d=new Date(0);f=f.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,r,a){var o=4===a.length?[a,n,r]:[n,r,a];return p[0]=e(o[0]),p[1]=e(o[1])-1,p[2]=e(o[2]),""});var v=d.setFullYear,h=d.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,r,a,o){return p[3]=e(n),p[4]=e(r),p[5]=e(a),o&&(p[6]=Math.round(1e3*parseFloat("0."+o))),""});var m=0,g=0;f=f.replace(/Z|([+-])(\d\d):?(\d\d)/,function(t,n,r,a){return v=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+r),g=e(n+a)),""}),p[3]-=m,p[4]-=g,v.apply(d,p.slice(0,3)),h.apply(d,p.slice(3)),t=d}if("number"==typeof t&&(t=new Date(t)),"date"===avalon.type(t)){for(;n;)a=l.exec(n),a?(u=u.concat(a.slice(1)),n=u.pop()):(u.push(n),n=null);return u.forEach(function(e){r=i[e],c+=r?r(t,o):e.replace(/(^'|'$)/g,"").replace(/''/g,"'")}),c}};var c={AMPMS:{0:"上午",1:"下午"},DAY:{0:"星期日",1:"星期一",2:"星期二",3:"星期三",4:"星期四",5:"星期五",6:"星期六"},MONTH:{0:"1月",1:"2月",2:"3月",3:"4月",4:"5月",5:"6月",6:"7月",7:"8月",8:"9月",9:"10月",10:"11月",11:"12月"},SHORTDAY:{0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"},fullDate:"y年M月d日EEEE",longDate:"y年M月d日",medium:"yyyy-M-d H:mm:ss",mediumDate:"yyyy-M-d",mediumTime:"H:mm:ss","short":"yy-M-d ah:mm",shortDate:"yy-M-d",shortTime:"ah:mm"};c.SHORTMONTH=c.MONTH,va.date.locate=c};var ha=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};ha.exports=ha.avalon,new function(){function t(e,t){var n="js";e=e.replace(/^(\w+)\!/,function(e,t){return n=t,""}),"ready"===n&&(r("debug: ready!已经被废弃,请使用domReady!"),n="domReady");var a="";e=e.replace(D,function(e){return a=e,""});var o="."+n,i=/js|css/.test(o)?o:"";e=e.replace(/\.[a-z0-9]+$/g,function(e){return e===o?(i=e,""):e});var l=avalon.mix({query:a,ext:i,res:n,name:e,toUrl:h},t);return l.toUrl(e),l}function n(e){var t=e.name,n=e.res,r=ha[t],a=t&&e.urlNoQuery;if(r&&r.state>=3)return t;if(r=ha[a],r&&r.state>=3)return gn(r.deps||[],r.factory,a),a;if(t&&!r){r=ha[a]={id:a,state:1};var o=function(a){P[n]=a,a.load(t,e,function(e){arguments.length&&void 0!==e&&(r.exports=e),r.state=4,s()})};P[n]?o(P[n]):gn([n],o)}return t?a:n+"!"}function i(e,t){for(var n,r=0;n=e[r++];)if(4!==ha[n].state&&(n===t||i(ha[n].deps,t)))return!0}function l(e,t,n){var a=u(e.src);return e.onload=e.onreadystatechange=e.onerror=null,t||n&&ha[a]&&!ha[a].state?(setTimeout(function(){Tt.removeChild(e),e=null}),void r("debug: 加载 "+a+" 失败"+t+" "+!ha[a].state)):!0}function s(){e:for(var e,t=E.length;e=E[--t];){var n=ha[e],r=n.deps;if(r){for(var a,o=0;a=r[o];o++){var i=O[a];if(i&&(a=r[o]=i),4!==Object(ha[a]).state)continue e}4!==n.state&&(E.splice(t,1),v(n.id,n.deps,n.factory),s())}}}function c(e,t,n){function a(){if(!"1"[0]&&!i)return i=setTimeout(a,150);if(c||H.test(o.readyState)){clearTimeout(i);var u=A.pop();u&&u.require(t),n&&n(),l(o,!1,!c)&&(r("debug: 已成功加载 "+e),t&&E.push(t),s())}}var o=Ct.createElement("script");o.className=kt;var i,c="onload"in o,u=c?"onload":"onreadystatechange";o[u]=a,o.onerror=function(){l(o,!0)},Tt.insertBefore(o,Tt.firstChild),o.src=e,r("debug: 正准备加载 "+e)
3
- }function u(e){return(e||"").replace(D,"")}function f(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(e,t){return"1"[0]?e[t]:e.getAttribute(t,4)}function d(){var t;try{a.b.c()}catch(n){t=n.stack,!t&&e.opera&&(t=(String(n).match(/of linked script \S+/g)||[]).join(" "))}if(t)return t=t.split(/[@ ]/g).pop(),t="("===t[0]?t.slice(1,-1):t.replace(/\s/,""),u(t.replace(/(:\d+)?:\d+$/i,""));for(var r,o=Tt.getElementsByTagName("script"),i=o.length;r=o[--i];)if(r.className===kt&&"interactive"===r.readyState){var l=p(r,"src");return r.className=u(l)}}function v(t,n,r){var a=Object(ha[t]);a.state=4;for(var o,i=0,l=[];o=n[i++];)if(o=O[o]||o,"exports"===o){var s=a.exports||(a.exports={});l.push(s)}else l.push(ha[o].exports);var c=r.apply(e,l);return void 0!==c&&(a.exports=c),delete a.factory,c}function h(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,r=this.baseUrl,a=this.parentUrl||r;$(e,g.paths,function(e,r){t=t.replace(r,e),n=1}),n||$(e,g.packages,function(e,n,r){t=t.replace(r.name,r.location)}),this.mapUrl&&$(this.mapUrl,g.map,function(e){$(t,e,function(e,n){t=t.replace(n,e),a=r})});var o=this.ext;o&&n&&t.slice(-o.length)===o&&(t=t.slice(0,-o.length)),f(t)||(a=this.built||/^\w/.test(t)?r:a,t=C(a,t));var i=t+o;return t=i+this.query,$(e,g.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=i}function m(e,t,n){var r=x(e,t,n);return r.sort(w),r}function y(e){return new RegExp("^"+e+"(/|$)")}function b(t){return function(){var n;return t.init&&(n=t.init.apply(e,arguments)),n||t.exports&&T(t.exports)}}function x(e,t,n){var r=[];for(var a in e)if(e.hasOwnProperty(a)){var o={name:a,val:e[a]};r.push(o),o.reg="*"===a&&t?/^/:y(a),n&&"*"!==a&&(o.reg=new RegExp("/"+a.replace(/^\//,"")+"(/|$)"))}return r}function $(e,t,n){t=t||[];for(var r,a=0;r=t[a++];)if(r.reg.test(e))return n(r.val,r.name,r),!1}function w(e,t){var n=e.name,r=t.name;return"*"===r?-1:"*"===n?1:r.length-n.length}function C(e,t){if("/"!==e.charAt(e.length-1)&&(e+="/"),"./"===t.slice(0,2))return e+t.slice(2);if(".."===t.slice(0,2)){for(e+=t;F.test(e);)e=e.replace(F,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function T(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var E=[],A=[],k=/\.js$/i,O={},M=[],_=!1;gn=avalon.require=function(e,r,a,i){if(_){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var l=[],c={},u=a||"callback"+setTimeout("1");i=i||{},i.baseUrl=g.baseUrl;var f=!!i.built;if(a&&(i.parentUrl=a.substr(0,a.lastIndexOf("/")),i.mapUrl=a.replace(k,"")),f){var p=t(i.defineName,i);u=p.urlNoQuery}else e.forEach(function(e){var r=t(e,i),a=n(r);a&&(c[a]||(l.push(a),c[a]="司徒正美"))});var d=ha[u];d&&4===d.state||(ha[u]={id:u,deps:f?e.concat():l,factory:r||o,state:3}),d||E.push(u),s()}else if(M.push(avalon.slice(arguments)),arguments.length<=2){_=!0;for(var v,h=M.splice(0,M.length);v=h.shift();)gn.apply(null,v)}},gn.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var r={built:!_,defineName:e},a=[t,n,r];n.require=function(e){if(a.splice(2,0,e),ha[e]){ha[e].state=3;var t=!1;try{t=i(ha[e].deps,e)}catch(r){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,gn.apply(null,a)};var o=r.built?"unknown":d();if(o){var l=ha[o];l&&(l.state=2),n.require(o)}else A.push(n)},gn.config=g,gn.define.amd=ha;var S=g["orig.paths"]={},N=g["orig.map"]={},L=g.packages=[],j=g["orig.args"]={};avalon.mix(yn,{paths:function(e){avalon.mix(S,e),g.paths=m(S)},map:function(e){avalon.mix(N,e);var t=m(N,1,1);avalon.each(t,function(e,t){t.val=m(t.val)}),g.map=t},packages:function(e){e=e.concat(L);for(var t,n={},r=[],a=0;t=e[a++];){t="string"==typeof t?{name:t}:t;var o=t.name;if(!n[o]){var i=t.location?t.location:C(o,t.main||"main");i=i.replace(k,""),r.push(t),n[o]=t.location=i,t.reg=y(o)}}g.packages=r.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(j,e),g.urlArgs=m(j,1)},baseUrl:function(e){if(!f(e)){var t=Tt.getElementsByTagName("base")[0];t&&Tt.removeChild(t);var n=Ct.createElement("a");n.href=e,e=p(n,"href"),t&&Tt.insertBefore(t,Tt.firstChild)}e.length>3&&(g.baseUrl=e)},shim:function(e){for(var t in e){var n=e[t];Array.isArray(n)&&(n=e[t]={deps:n}),n.exportsFn||!n.exports&&!n.init||(n.exportsFn=b(n))}g.shim=e}});var H=Ct.documentMode>=8?/loaded/:/complete|loaded/,P=gn.plugins={ready:{load:o},js:{load:function(e,t,n){var r=t.url,a=t.urlNoQuery,o=g.shim[e.replace(k,"")];o?gn(o.deps||[],function(){var e=avalon.slice(arguments);c(r,a,function(){n(o.exportsFn?o.exportsFn.apply(0,e):void 0)})}):c(r,a)}},css:{load:function(e,t,n){var a=t.url,o=Ct.createElement("link");o.rel="stylesheet",o.href=a,Tt.insertBefore(o,Tt.firstChild),r("debug: 已成功加载 "+a),n()}},text:{load:function(e,t,n){var a=t.url,o=Qr();o.onreadystatechange=function(){if(4===o.readyState){var e=o.status;e>399&&600>e?avalon.error(a+" 对应资源不存在或没有开启 CORS"):(r("debug: 已成功加载 "+a),n(o.responseText))}},o.open("GET",a,!0),"withCredentials"in o&&(o.withCredentials=!0),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.send(),r("debug: 正准备加载 "+a)}}};gn.checkDeps=s;var D=/(\?[^#]*)$/,F=/\/\w+\/\.\./,B=Ct.scripts[Ct.scripts.length-1],I=B.getAttribute("data-main");if(I){yn.baseUrl(I);var R=g.baseUrl;g.baseUrl=R.slice(0,R.lastIndexOf("/")+1),c(R.replace(k,"")+".js")}else{var V=u(p(B,"src"));g.baseUrl=V.slice(0,V.lastIndexOf("/")+1)}};var ma=[];if("complete"===Ct.readyState)setTimeout(xt);else if(Rt)Ct.addEventListener("DOMContentLoaded",xt);else{Ct.attachEvent("onreadystatechange",function(){"complete"===Ct.readyState&&xt()});try{var ga=null===e.frameElement}catch(On){}Vt.doScroll&&ga&&e.external&&$t()}avalon.bind(e,"load",xt),avalon.ready=function(e){xt===o?e(avalon):ma.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(Ct.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=avalon),avalon},void 0===t&&(e.avalon=avalon),avalon});
1
+ !function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("Avalon requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(){e.console&&avalon.config.debug&&Function.apply.call(console.log,console,arguments)}function r(){}function i(e,t){"string"==typeof e&&(e=e.match(_t)||[]);for(var n={},r=void 0!==t?t:1,a=0,i=e.length;i>a;a++)n[e[a]]=r;return n}function o(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function l(e){return Lt.test(Pt.call(e))}function s(e,t){return e=Math.floor(e)||0,0>e?Math.max(t+e,0):Math.min(e,t)}function c(e){if(!e)return!1;var t=e.length;if(t===t>>>0){var n=Pt.call(e).slice(8,-1);if(/(?:regexp|string|function|window|global)$/i.test(n))return!1;if("Array"===n)return!0;try{return{}.propertyIsEnumerable.call(e,"length")===!1?/^\s?function/.test(e.item||e.callee):!0}catch(r){return!e.window}}return!1}function u(e,t,n){var r="for(var "+e+"i=0,n = this.length; i < n; i++){"+t.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+n;return Function("fn,scope",r)}function f(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}}function p(){return(new XMLSerializer).serializeToString(this)}function d(e,t){if(e&&e.childNodes)for(var n,r=e.childNodes,a=0;n=r[a++];)if(n.tagName){var i=$t.createElementNS(an,n.tagName.toLowerCase());Dt.forEach.call(n.attributes,function(e){i.setAttribute(e.name,e.value)}),d(n,i),t.appendChild(i)}}function v(e){var t={};for(var n in e)t[n]=e[n];var r=t.target=e.srcElement;if(0===e.type.indexOf("key"))t.which=null!=e.charCode?e.charCode:e.keyCode;else if(ln.test(e.type)){var a=r.ownerDocument||$t,i="BackCompat"===a.compatMode?a.body:a.documentElement;t.pageX=e.clientX+(i.scrollLeft>>0)-(i.clientLeft>>0),t.pageY=e.clientY+(i.scrollTop>>0)-(i.clientTop>>0),t.wheelDeltaY=t.wheelDelta,t.wheelDeltaX=0}return t.timeStamp=new Date-0,t.originalEvent=e,t.preventDefault=function(){e.returnValue=!1},t.stopPropagation=function(){e.cancelBubble=!0},t}function h(e){for(var t in e)if(Ht.call(e,t)){var n=e[t];"function"==typeof h.plugins[t]?h.plugins[t](n):"object"==typeof h[t]?avalon.mix(h[t],n):h[t]=n}return this}function m(e){return(e+"").replace(mn,"\\$&")}function g(e,t,n){if(Xt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;if(-1!==wn.indexOf(e))return!1;var r=n.$special;return e&&"$"===e.charAt(0)&&!r[e]?!1:!0}function y(e,t,n,r){switch(e.type){case 0:var a=e.get,i=e.set;if(Xt(i)){var o=r.$events,l=o[t];o[t]=[],i.call(r,n),o[t]=l}return a.call(r);case 1:return n;case 2:if(n!==r.$model[t]){var s=e.svmodel=$(r,t,n,e.valueType);n=s.$model;var c=Cn[s.$id];c&&c()}return n}}function b(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=C(e);return i.pushArray(a),i}if(!e||e.nodeType>0||e.$id&&e.$events)return e;Array.isArray(e.$skipArray)||(e.$skipArray=[]),e.$skipArray.$special=t||{};var o={};n=n||{};var l={},s={},c=[];for(var u in e)!function(t,a){if(n[t]=a,g(t,a,e.$skipArray)){l[t]=[];var i=avalon.type(a),u=function(e){var t=u._name,n=this,r=n.$model,a=r[t],i=n.$events;return arguments.length?void(Ot||(1===u.type||(e=y(u,t,e,n),u.type))&&(Mn(a,e)||(r[t]=e,S(i[t]),x(n,t,e,a)))):0===u.type?(e=u.get.call(n),a!==e&&(r[t]=e,x(n,t,e,a)),e):(k(i[t]),u.svmodel||a)};"object"===i&&Xt(a.get)&&Object.keys(a).length<=2?(u.set=a.set,u.get=a.get,u.type=0,c.push(function(){var e={evaluator:function(){e.type=Math.random(),e.element=null,n[t]=u.get.call(o)},element:wt,type:Math.random(),handler:r,args:[]};Bt[xt]=e,u.call(o),delete Bt[xt]})):Nt.test(i)?(u.type=2,u.valueType=i,c.push(function(){var e=b(a,0,n[t]);u.svmodel=e,e.$events[At]=l[t]})):u.type=1,u._name=t,s[t]=u}}(u,e[u]);wn.forEach(function(t){delete e[t],delete n[t]}),o=An(o,On(s),e);for(var f in e)s[f]||(o[f]=e[f]);o.$id=qt(),o.$model=n,o.$events=l;for(u in xn){var p=xn[u];It||(p=p.bind(o)),o[u]=p}return En?Object.defineProperty(o,"hasOwnProperty",{value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0}):o.hasOwnProperty=function(e){return e in o.$model},c.forEach(function(e){e()}),o}function x(e,t,n,r){e.$events&&xn.$fire.call(e,t,n,r)}function $(e,t,n,r){var a=e[t];if("array"===r)return Array.isArray(n)&&a!==n?(a._.$unwatch(),a.clear(),a._.$watch(),a.pushArray(n.concat()),a):a;var i=e.$events[t],o=a.$events.$withProxyPool;o&&(mt(o,"with"),a.$events.$withProxyPool=null);var l=b(n);return l.$events[At]=i,Cn[l.$id]=function(e){for(;e=i.shift();)!function(e){avalon.nextTick(function(){var t=e.type;t&&Jt[t]&&(e.rollback&&e.rollback(),Jt[t](e,e.vmodels))})}(e);delete Cn[l.$id]},l}function w(e,t,n,r){var a=t[n];return 4!==arguments.length?a.call(e):void a.call(e,r)}function C(e){var t=[];t.$id=qt(),t.$model=e,t.$events={},t.$events[At]=[],t._=b({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in xn)t[n]=xn[n];return avalon.mix(t,Nn),t}function T(e,t,n,r,a,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=this.$model.slice(t,t+n).map(function(e){return Nt.test(avalon.type(e))?e.$id?e:b(e,0,e):e});_n.apply(this,[t,0].concat(c)),this._fire("add",t,n);break;case"del":var u=this._splice(t,n);this._fire("del",t,n)}a&&(e=a,t=i,n=o,s=2,a=0)}return this._fire("index",r),this.length!==l&&(this._.length=this.length),u}function E(e,t){for(var n={},r=0,a=t.length;a>r;r++){n[r]=e[r];var i=t[r];i in n?(e[r]=n[i],delete n[i]):e[r]=e[i]}}function A(e){Bt[xt]=e,avalon.openComputedCollect=!0;var t=e.evaluator;if(t)try{var n=Sn.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(r){delete e.evaluator;var a=e.element;if(3===a.nodeType){var i=a.parentNode;h.commentInterpolate?i.replaceChild($t.createComment(e.value),a):a.data=fn+e.value+pn}}avalon.openComputedCollect=!1,delete Bt[xt]}function k(e){var t=Bt[xt];e&&t&&avalon.Array.ensure(e,t)&&t.element&&M(t,e)}function M(e,t){e.$uuid=e.$uuid||qt(),t.$uuid=t.$uuid||qt();var n={data:e,list:t,$$uuid:e.$uuid+t.$uuid};Ln[n.$$uuid]||(Ln[n.$$uuid]=1,Ln.push(n))}function O(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function _(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?"number"==typeof e.sourceIndex?0===e.sourceIndex:!Rt.contains(e):!avalon.contains(Rt,e)}function N(){for(var e,t=Ln.length,n=t,r=0,a=[],i={},o={};e=Ln[--t];){var l=e.data,s=l.type;i[s]?i[s]++:(i[s]=1,a.push(s))}var c=!1;if(a.forEach(function(e){Hn[e]!==i[e]&&(o[e]=1,c=!0)}),t=n,c)for(;e=Ln[--t];)l=e.data,void 0!==l.element&&o[l.type]&&_(l.element)&&(r++,Ln.splice(t,1),delete Ln[e.$$uuid],avalon.Array.remove(e.list,l),O(l),e.data=e.list=null);Hn=i,jn=new Date}function S(e){if(e&&e.length){new Date-jn>444&&"object"==typeof e[0]&&N();for(var t,n=Ft.call(arguments,1),a=e.length;t=e[--a];){var i=t.element;if(i&&i.parentNode)if(t.$repeat)t.handler.apply(t,n);else if("on"!==t.type){var o=t.evaluator||r;t.handler(o.apply(0,t.args||[]),i,t)}}}}function L(e){var t=e.nodeName;return t.toLowerCase()===t&&e.scopeName&&""===e.outerText}function j(e){"url(#default#VML)"!==e.currentStyle.behavior&&(e.style.behavior="url(#default#VML)",e.style.display="inline-block",e.style.zoom=1)}function H(e,t,n){var r=setTimeout(function(){var a=e.innerHTML;clearTimeout(r),a===n?t():H(e,t,a)})}function P(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function D(e,t){for(var n,r=0;n=e[r++];)n.vmodels=t,Jt[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function F(e,t){return e.priority-t.priority}function B(e,t){for(var r,a,i=ar?ar(e):avalon.slice(e.attributes),o=[],l={},s=0;a=i[s++];)if(a.specified&&(r=a.name.match(Xn))){var c=r[1],u=r[2]||"",f=a.value,p=a.name;if(l[p]=f,Gn[c]?(u=c,c="on"):Jn[c]&&(n("warning!请改用ms-attr-"+c+"代替ms-"+c+"!"),"enabled"===c&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),c="disabled",f="!("+f+")"),u=c,c="attr",e.removeAttribute(p),p="ms-attr-"+u,e.setAttribute(p,f),r=[p],l[p]=f),"function"==typeof Jt[c]){var d={type:c,param:u,element:e,name:r[0],value:f,priority:c in Yn?Yn[c]:10*c.charCodeAt(0)+(Number(u)||0)};if("html"===c||"text"===c){var v=W(f);avalon.mix(d,v),d.filters=d.filters.replace(ir,function(){return d.type="html",d.group=1,""})}"ms-if-loop"===p&&(d.priority+=100),t.length&&(o.push(d),"widget"===c&&(e.msData=e.msData||l))}}o.sort(F);var h=e.type;h&&l["ms-duplex"]&&(l["ms-attr-checked"]&&/radio|checkbox/.test(h)&&n("warning!"+h+"控件不能同时定义ms-attr-checked与ms-duplex"),l["ms-attr-value"]&&/text|password/.test(h)&&n("warning!"+h+"控件不能同时定义ms-attr-value与ms-duplex"));var m=!0;for(s=0;d=o[s];s++){if(c=d.type,Zn.test(c))return D(o.slice(0,s+1),t);m&&(m=!Qn.test(c))}D(o,t),m&&!Wn[e.tagName]&&hn.test(e.innerHTML.replace(lr,"<").replace(sr,">"))&&(zn&&zn(e),I(e,t))}function I(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;V(n,n.nodeType,t),n=r}}function R(e,t){for(var n,r=0;n=e[r++];)V(n,n.nodeType,t)}function V(e,t,n){1===t?U(e,n):3===t&&dn.test(e.data)?z(e,n):h.commentInterpolate&&8===t&&!dn.test(e.nodeValue)&&z(e,n)}function U(e,t,r){var a=e.getAttribute("ms-skip");if(!e.getAttributeNode)return n("warning "+e.tagName+" no getAttributeNode method");var i=e.getAttributeNode("ms-important"),o=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(r=i||o){var l=avalon.vmodels[r.value];if(!l)return;t=r===i?[l]:[l].concat(t);var s=r.name;e.removeAttribute(s),avalon(e).removeClass(s),P(e,l)}B(e,t)}}function W(e){if(e.indexOf("|")>0){var t=e.replace(rstringLiteral,function(e){return Array(e.length+1).join("1")}),n=t.replace(or,"ᄢ㍄").indexOf("|");if(n>-1)return{filters:e.slice(n),value:e.slice(0,n),expr:!0}}return{value:e,filters:"",expr:!0}}function q(e){for(var t,n,r=[],a=0;;){if(n=e.indexOf(fn,a),-1===n)break;if(t=e.slice(a,n),t&&r.push({value:t,filters:"",expr:!1}),a=n+fn.length,n=e.indexOf(pn,a),-1===n)break;t=e.slice(a,n),t&&r.push(W(t)),a=n+pn.length}return t=e.slice(a),t&&r.push({value:t,expr:!1,filters:""}),r}function z(e,t){var n=[];if(8===e.nodeType)var r=W(e.nodeValue),a=[r];else a=q(e.data);if(a.length){for(var i=0;r=a[i++];){var o=$t.createTextNode(r.value);r.expr&&(r.type="text",r.element=o,r.filters=r.filters.replace(ir,function(){return r.type="html",r.group=1,""}),n.push(r)),Vt.appendChild(o)}e.parentNode.replaceChild(Vt,e),n.length&&D(n,t)}}function X(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function Y(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function G(e){if(!("classList"in e)){e.classList={node:e};for(var t in cr)e.classList[t.slice(1)]=cr[t]}return e.classList}function J(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:ur.test(e)?avalon.parseJSON(e):e}catch(t){}return e}function Z(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}function Q(e,t){if(e.offsetWidth<=0){if(Er.test(hr["@:get"](e,"display"))){var n={node:e};for(var r in Tr)n[r]=e.style[r],e.style[r]=Tr[r];t.push(n)}var a=e.parentNode;a&&1===a.nodeType&&Q(a,t)}}function K(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function et(e,t,n,r){for(var a,i=[],o=" = "+n+".",l=e.length;a=e[--l];)t.hasOwnProperty(a)&&(i.push(a+o+a),r.vars.push(a),"duplex"===r.type&&(e.get=n+"."+a),e.splice(l,1));return i}function tt(e){for(var t=[],n={},r=0;r<e.length;r++){var a=e[r],i=a&&"string"==typeof a.$id?a.$id:a;n[i]||(n[i]=t.push(a))}return t}function nt(e,t){return t=t.replace(Rr,"").replace(Vr,function(){return"],|"}).replace(Ur,function(e,t){return"["+Or(t)}).replace(Wr,function(){return'"],["'}).replace(qr,function(){return'",'})+"]","return avalon.filters.$filter("+e+", "+t+")"}function rt(e,t,a){var i=a.type,o=a.filters||"",l=t.map(function(e){return String(e.$id).replace(Ir,"$1")})+e+i+o,s=Dr(e).concat(),c=[],u=[],f=[],p="";t=tt(t),a.vars=[];for(var d=0,v=t.length;v>d;d++)if(s.length){var h="vm"+xt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,et(s,t[d],h,a))}if(c.length||"duplex"!==i){"duplex"!==i&&(e.indexOf("||")>-1||e.indexOf("&&")>-1)&&a.vars.forEach(function(t){var n=new RegExp("\\b"+t+"(?:\\.\\w+|\\[\\w+\\])+","ig");e=e.replace(n,function(n){var r=n.charAt(t.length),a=zt?e.slice(arguments[1]+n.length):RegExp.rightContext,i=/^\s*\(/.test(a);if("."===r||"["===r||i){var o="var"+String(Math.random()).replace(/^0\./,"");if(i){var l=n.split(".");if(l.length>2){var s=l.pop();return c.push(o+" = "+l.join(".")),o+"."+s}return n}return c.push(o+" = "+n),o}return n})}),a.args=f;var m=Fr.get(l);if(m)return void(a.evaluator=m);if(p=c.join(", "),p&&(p="var "+p),/\S/.test(o)){if(!/text|html/.test(a.type))throw Error("ms-"+a.type+"不支持过滤器");e="\nvar ret"+xt+" = "+e+";\r\n",e+=nt("ret"+xt,o)}else{if("duplex"===i){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Br.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(r,u.concat(g)),a.evaluator=Fr.put(l,m)}catch(y){n("debug: parse error,"+y.message)}return}if("on"===i){-1===e.indexOf("(")?e+=".call(this, $event)":e=e.replace("(",".call(this,"),u.push("$event"),e="\nreturn "+e+";";var b=e.lastIndexOf("\nreturn"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(r,u.concat("'use strict';\n"+p+e)),a.evaluator=Fr.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function at(e,t,n,r,a){Array.isArray(r)&&(e=r.map(function(e){return e.expr?"("+e.value+")":Or(e.value)}).join(" + ")),rt(e,t,n),n.evaluator&&!a&&(n.handler=Zt[n.handlerName||n.type],A(n))}function it(e,t,n){var r=e.templateCache&&e.templateCache[t];if(r){for(var a,i=$t.createDocumentFragment();a=r.firstChild;)i.appendChild(a);return i}return avalon.parseHTML(n)}function ot(e){return null==e?"":e}function lt(e,t,n){return t.param.replace(/\w+/g,function(r){var a=avalon.duplexHooks[r];a&&"function"==typeof a[n]&&(e=a[n](e,t))}),e}function st(){for(var e=na.length-1;e>=0;e--){var t=na[e];t()===!1&&na.splice(e,1)}na.length||clearInterval(ta)}function ct(e,t,n,r){var a=e.template.cloneNode(!0),i=avalon.slice(a.childNodes);n.$stamp&&a.insertBefore(n.$stamp,a.firstChild),t.appendChild(a);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};r.push(l)}function ut(e,t){var n=e.proxies[t];return n?n.$stamp:e.element}function ft(e,t,n){for(;;){var r=t.previousSibling;if(!r)break;if(r.parentNode.removeChild(r),n&&n.call(r),r===e)break}}function pt(e){var t={$host:[],$outer:{},$stamp:1,$index:0,$first:!1,$last:!1,$remove:avalon.noop};t[e]={get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}};var n={$last:1,$first:1,$index:1},r=b(t,n),a=r.$events;return a[e]=a.$first=a.$last=a.$index,r.$id=qt("$proxy$each"),r}function dt(e,t){for(var n,r=t.param||"el",a=0,i=oa.length;i>a;a++){var o=oa[a];o&&o.hasOwnProperty(r)&&(n=o,oa.splice(a,1))}n||(n=pt(r));var l=t.$repeat,s=l.length-1;return n.$index=e,n.$first=0===e,n.$last=e===s,n.$host=l,n.$outer=t.$outer,n.$stamp=t.clone.cloneNode(!1),n.$remove=function(){return l.removeAt(n.$index)},n}function vt(){var e=b({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=qt("$proxy$with"),e}function ht(e,t){var n=la.pop();n||(n=vt());var r=t.$repeat;return n.$key=e,n.$host=r,n.$outer=t.$outer,r.$events?n.$events.$val=r.$events[e]:n.$events={},n}function mt(e,t){var n="each"===t?oa:la;avalon.each(e,function(e,t){if(t.$events){for(var r in t.$events)Array.isArray(t.$events[r])&&(t.$events[r].forEach(function(e){"object"==typeof e&&O(e)}),t.$events[r].length=0);t.$host=t.$outer={},n.unshift(t)>h.maxRepeatSize&&n.pop()}}),"each"===t&&(e.length=0)}function gt(e,t){var n="_"+e;if(!gt[n]){var r=$t.createElement(e);Rt.appendChild(r),t=It?getComputedStyle(r,null).display:r.currentStyle.display,Rt.removeChild(r),gt[n]=t}return gt[n]}function yt(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var a=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):3,o=r||",",l=n||".",s="",c=function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)};return s=(i?c(a,i):""+Math.round(a)).split("."),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(s[1]||"").length<i&&(s[1]=s[1]||"",s[1]+=new Array(i-s[1].length+1).join("0")),s.join(l)}function bt(){try{Rt.doScroll("left"),ba()}catch(e){setTimeout(bt)}}var xt=new Date-0,$t=e.document,wt=$t.getElementsByTagName("head")[0],Ct=wt.insertBefore(document.createElement("avalon"),wt.firstChild);Ct.innerHTML="X<style id='avalonStyle'>.avalonHide{ display: none!important }</style>",Ct.setAttribute("ms-skip","1"),Ct.className="avalonHide";var Tt,Et=/\[native code\]/,At="$"+xt,kt=e.require,Mt=e.define,Ot=!1,_t=/[^, ]+/g,Nt=/^(?:object|array)$/,St=/^\[object SVG\w*Element\]$/,Lt=/^\[object (?:Window|DOMWindow|global)\]$/,jt=Object.prototype,Ht=jt.hasOwnProperty,Pt=jt.toString,Dt=Array.prototype,Ft=Dt.slice,Bt={},It=e.dispatchEvent,Rt=$t.documentElement,Vt=$t.createDocumentFragment(),Ut=$t.createElement("div"),Wt={};"Boolean Number String Function Array Date RegExp Object Error".replace(_t,function(e){Wt["[object "+e+"]"]=e.toLowerCase()});var qt=function(e){return e=e||"avalon",(e+Math.random()+Math.random()).replace(/0\./g,"")},zt=o();avalon=function(e){return new avalon.init(e)},avalon.nextTick=new function(){function t(){for(var e=i.length,t=0;e>t;t++)i[t]();i=i.slice(e)}var n=e.setImmediate,r=e.MutationObserver,a=It&&e.postMessage;if(n)return n.bind(e);var i=[];if(r){var o=document.createTextNode("avalon");return new r(t).observe(o,{characterData:!0}),function(e){i.push(e),o.data=Math.random()}}return a?(e.addEventListener("message",function(n){var r=n.source;r!==e&&null!==r||"process-tick"!==n.data||(n.stopPropagation(),t())}),function(t){i.push(t),e.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}},avalon.init=function(e){this[0]=this.element=e},avalon.fn=avalon.prototype=avalon.init.prototype,avalon.type=function(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?Wt[Pt.call(e)]||"object":typeof e};var Xt="object"==typeof alert?function(e){try{return/^\s*\bfunction\b/.test(e+"")}catch(t){return!1}}:function(e){return"[object Function]"===Pt.call(e)};avalon.isFunction=Xt,avalon.isWindow=function(e){return e?e==e.document&&e.document!=e:!1},l(e)&&(avalon.isWindow=l);var Yt;for(Yt in avalon({}))break;var Gt="0"!==Yt;avalon.isPlainObject=function(e,t){if(!e||"object"!==avalon.type(e)||e.nodeType||avalon.isWindow(e))return!1;try{if(e.constructor&&!Ht.call(e,"constructor")&&!Ht.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(Gt)for(t in e)return Ht.call(e,t);for(t in e);return void 0===t||Ht.call(e,t)},Et.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(e){return"[object Object]"===Pt.call(e)&&Object.getPrototypeOf(e)===jt}),avalon.mix=avalon.fn.mix=function(){var e,t,n,r,a,i,o=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[1]||{},l++),"object"==typeof o||Xt(o)||(o={}),l===s&&(o=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e){n=o[t];try{r=e[t]}catch(u){continue}o!==r&&(c&&r&&(avalon.isPlainObject(r)||(a=Array.isArray(r)))?(a?(a=!1,i=n&&Array.isArray(n)?n:[]):i=n&&avalon.isPlainObject(n)?n:{},o[t]=avalon.mix(c,i,r)):void 0!==r&&(o[t]=r))}return o},avalon.mix({rword:_t,subscribers:At,version:1.41,ui:{},log:n,slice:It?function(e,t,n){return Ft.call(e,t,n)}:function(e,t,n){var r=[],a=e.length;if(void 0===n&&(n=a),"number"==typeof n&&isFinite(n)){t=s(t,a),n=s(n,a);for(var i=t;n>i;++i)r[i-t]=e[i]}return r},noop:r,error:function(e,t){throw(t||Error)(e)},oneObject:i,range:function(e,t,n){n||(n=1),null==t&&(t=e||0,e=0);for(var r=-1,a=Math.max(0,Math.ceil((t-e)/n)),i=new Array(a);++r<a;)i[r]=e,e+=n;return i},eventHooks:{},bind:function(e,t,n,r){var a=avalon.eventHooks,i=a[t];"object"==typeof i&&(t=i.type,i.deel&&(n=i.deel(e,t,n,r)));var o=It?n:function(t){n.call(e,v(t))};return It?e.addEventListener(t,o,!!r):e.attachEvent("on"+t,o),o},unbind:function(e,t,n,a){var i=avalon.eventHooks,o=i[t],l=n||r;"object"==typeof o&&(t=o.type,o.deel&&(n=o.deel(e,t,n,!1))),It?e.removeEventListener(t,l,!!a):e.detachEvent("on"+t,l)},css:function(e,t,n){e instanceof avalon&&(e=e[0]);var r,a=/[_-]/.test(t)?Y(t):t;if(t=avalon.cssName(a)||a,void 0===n||"boolean"==typeof n){r=hr[a+":get"]||hr["@:get"],"background"===t&&(t="backgroundColor");var i=r(e,t);return n===!0?parseFloat(i)||0:i}if(""===n)e.style[t]="";else{if(null==n||n!==n)return;isFinite(n)&&!avalon.cssNumber[a]&&(n+="px"),r=hr[a+":set"]||hr["@:set"],r(e,t,n)}},each:function(e,t){if(e){var n=0;if(c(e))for(var r=e.length;r>n&&t(n,e[n])!==!1;n++);else for(n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)break}},getWidgetData:function(e,t){var n=avalon(e).data(),r={};for(var a in n)0===a.indexOf(t)&&(r[a.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[a]);return r},Array:{ensure:function(e,t){return-1===e.indexOf(t)?e.push(t):void 0},removeAt:function(e,t){return!!e.splice(t,1).length},remove:function(e,t){var n=e.indexOf(t);return~n?avalon.Array.removeAt(e,n):!1}}});var Jt=avalon.bindingHandlers={},Zt=avalon.bindingExecutors={},Qt=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}var t=e.prototype;return t.put=function(e,t){var n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){var e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0)},t.get=function(e){var t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(!"司徒正美".trim){var Kt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(Kt,"")}}var en=!{toString:null}.propertyIsEnumerable("toString"),tn=function(){}.propertyIsEnumerable("prototype"),nn=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],rn=nn.length;if(Object.keys||(Object.keys=function(e){var t=[],n=tn&&"function"==typeof e;if("string"==typeof e||e&&e.callee)for(var r=0;r<e.length;++r)t.push(String(r));else for(var a in e)n&&"prototype"===a||!Ht.call(e,a)||t.push(String(a));if(en)for(var i=e.constructor,o=i&&i.prototype===e,l=0;rn>l;l++){var s=nn[l];o&&"constructor"===s||!Ht.call(e,s)||t.push(s)}return t}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Pt.call(e)}),r.bind||(Function.prototype.bind=function(e){if(arguments.length<2&&void 0===e)return this;var t=this,n=arguments;return function(){var r,a=[];for(r=1;r<n.length;r++)a.push(n[r]);for(r=0;r<arguments.length;r++)a.push(arguments[r]);return t.apply(e,a)}}),Et.test([].map)||avalon.mix(Dt,{indexOf:function(e,t){var n=this.length,r=~~t;for(0>r&&(r+=n);n>r;r++)if(this[r]===e)return r;return-1},lastIndexOf:function(e,t){var n=this.length,r=null==t?n-1:t;for(0>r&&(r=Math.max(0,n+r));r>=0;r--)if(this[r]===e)return r;return-1},forEach:u("","_",""),filter:u("r=[],j=0,","if(_)r[j++]=this[i]","return r"),map:u("r=[],","r[i]=_","return r"),some:u("","if(_)return true","return false"),every:u("","if(!_)return false","return true")}),avalon.contains=f,$t.contains||($t.contains=function(e){return f($t,e)}),e.SVGElement){$t.createTextNode("x").contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))});var an="http://www.w3.org/2000/svg",on=$t.createElementNS(an,"svg");on.innerHTML='<circle cx="50" cy="50" r="40" fill="red" />',St.test(on.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:p,set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,r=avalon.parseHTML(e);if("svg"===t)n.insertBefore(r,this);else{var a=$t.createDocumentFragment();d(r,a),n.insertBefore(a,this)}n.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var e=this.outerHTML,t=new RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),n=new RegExp("</"+this.nodeName+">$","i");return e.replace(t,"").replace(n,"")},set:function(e){if(avalon.clearHTML){avalon.clearHTML(this);var t=avalon.parseHTML(e);d(t,this)}}}})}!Rt.outerHTML&&e.HTMLElement&&HTMLElement.prototype.__defineGetter__("outerHTML",p);var ln=/^(?:mouse|contextmenu|drag)|click/,sn=avalon.eventHooks;if("onmouseenter"in Rt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){sn[e]={type:t,deel:function(t,n,r){return function(n){var a=n.relatedTarget;return a&&(a===t||16&t.compareDocumentPosition(a))?void 0:(delete n.type,n.type=e,r.call(t,n))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!sn.animationend&&(sn.animationend={type:n})}),"oninput"in $t.createElement("input")||(sn.input={type:"propertychange",deel:function(e,t,n){return function(t){return"value"===t.propertyName?(t.type="input",n.call(e,t)):void 0}}}),void 0===$t.onmousewheel){var cn=void 0!==$t.onwheel?"wheel":"DOMMouseScroll",un="wheel"===cn?"deltaY":"detail";sn.mousewheel={type:cn,deel:function(e,t,n){return function(t){t.wheelDeltaY=t.wheelDelta=t[un]>0?-120:120,t.wheelDeltaX=0,Object.defineProperty&&Object.defineProperty(t,"type",{value:"mousewheel"}),n.call(e,t)}}}}var fn,pn,dn,vn,hn,mn=/[-.*+?^${}()|[\]\/\\]/g,gn={loader:function(t){var n=Tt&&t;e.require=n?Tt:kt,e.define=n?Tt.define:Mt},interpolate:function(e){if(fn=e[0],pn=e[1],fn===pn)throw new SyntaxError("openTag!==closeTag");if(e+""=="<!--,-->")h.commentInterpolate=!0;else{var t=fn+"test"+pn;if(Ut.innerHTML=t,Ut.innerHTML!==t&&Ut.innerHTML.indexOf("&lt;")>-1)throw new SyntaxError("此定界符不合法");Ut.innerHTML=""}var n=m(fn),r=m(pn);dn=new RegExp(n+"(.*?)"+r),vn=new RegExp(n+"(.*?)"+r,"g"),hn=new RegExp(n+".*?"+r+"|\\sms-")}};h.debug=!0,h.plugins=gn,h.plugins.interpolate(["{{","}}"]),h.paths={},h.shim={},h.maxRepeatSize=100,avalon.config=h;var yn=/(\w+)\[(avalonctrl)="(\S+)"\]/,bn=$t.querySelectorAll?function(e){return $t.querySelectorAll(e)}:function(e){for(var t,n=e.match(yn),r=$t.getElementsByTagName(n[1]),a=[],i=0;t=r[i++];)t.getAttribute(n[2])===n[3]&&a.push(t);return a},xn={$watch:function(e,t){if("function"==typeof t){var n=this.$events[e];n?n.push(t):this.$events[e]=[t]}else this.$events=this.$watch.backup;return this},$unwatch:function(e,t){var n=arguments.length;if(0===n)this.$watch.backup=this.$events,this.$events={};else if(1===n)this.$events[e]=[];else for(var r=this.$events[e]||[],a=r.length;~--a<0;)if(r[a]===t)return r.splice(a,1);return this},$fire:function(e){var t,n,r,a;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var i=this.$events;if(i){var o=Ft.call(arguments,1),l=[e].concat(o);if("all"===t)for(n in avalon.vmodels)r=avalon.vmodels[n],r!==this&&r.$fire.apply(r,l);else if("up"===t||"down"===t){var s=i.expr?bn(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(r=avalon.vmodels[n],r!==this&&r.$events.expr){var c=bn(r.$events.expr);if(0===c.length)continue;Array.prototype.forEach.call(c,function(e){Array.prototype.forEach.call(s,function(n){var a="down"===t?n.contains(e):e.contains(n);a&&(e._avalon=r)})})}var u=$t.getElementsByTagName("*"),f=[];for(Array.prototype.forEach.call(u,function(e){e._avalon&&(f.push(e._avalon),e._avalon="",e.removeAttribute("_avalon"))}),"up"===t&&f.reverse(),n=0;(a=f[n++])&&a.$fire.apply(a,l)!==!1;);}else{var p=i[e]||[],d=i.$all||[];for(n=0;a=p[n++];)Xt(a)&&a.apply(this,o);for(n=0;a=d[n++];)Xt(a)&&a.apply(this,arguments)}}}},$n=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),$n[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var i=b(e);else{var o={$watch:r};t(o),i=b(o),Ot=!0,t(i),Ot=!1}return i.$id=a,$n[a]=i};var wn=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray").match(_t),Cn={},Tn=Object.defineProperty,En=!0;try{Tn({},"_",{value:"x"});var An=Object.defineProperties}catch(kn){En=!1}var Mn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},On=It?function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t}:function(e){return e};En||("__defineGetter__"in avalon&&(Tn=function(e,t,n){return"value"in n&&(e[t]=n.value),"get"in n&&e.__defineGetter__(t,n.get),"set"in n&&e.__defineSetter__(t,n.set),e},An=function(e,t){for(var n in t)t.hasOwnProperty(n)&&Tn(e,n,t[n]);return e}),zt&&(e.execScript(["Function parseVB(code)"," ExecuteGlobal(code)","End Function","Dim VBClassBodies",'Set VBClassBodies=CreateObject("Scripting.Dictionary")',"Function findOrDefineVBClass(name,body)"," Dim found",' found=""'," For Each key in VBClassBodies"," If body=VBClassBodies.Item(key) Then"," found=key"," Exit For"," End If"," next",' If found="" Then',' parseVB("Class " + name + body)'," VBClassBodies.Add name, body"," found=name"," End If"," findOrDefineVBClass=found","End Function"].join("\n"),"VBScript"),An=function(t,n,r){var a="VBClass"+setTimeout("1"),i=[];i.push("\r\n Private [__data__], [__proxy__]"," Public Default Function [__const__](d, p)"," Set [__data__] = d: set [__proxy__] = p"," Set [__const__] = Me"," End Function");for(t in r)n.hasOwnProperty(t)||i.push(" Public ["+t+"]");wn.forEach(function(e){n.hasOwnProperty(e)||i.push(" Public ["+e+"]")}),i.push(" Public [hasOwnProperty]");for(t in n)i.push(" Public Property Let ["+t+"](val"+xt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+xt+")"," End Property"," Public Property Set ["+t+"](val"+xt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+xt+")"," End Property"," Public Property Get ["+t+"]"," On Error Resume Next"," Set["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," If Err.Number <> 0 Then"," ["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," End If"," On Error Goto 0"," End Property");i.push("End Class");var o=i.join("\r\n"),l=e.findOrDefineVBClass(a,o);l===a&&e.parseVB(["Function "+a+"Factory(a, b)"," Dim o"," Set o = (New "+a+")(a, b)"," Set "+a+"Factory = o","End Function"].join("\r\n"));var s=e[l+"Factory"](n,w);return s}));var _n=Dt.splice,Nn={_splice:_n,_fire:function(e,t,n){S(this.$events[At],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Dt.push.apply(this.$model,e),T.call(this,"add",n,t,Math.max(0,n-1))),t+n},push:function(){var e,t=[],n=arguments.length;for(e=0;n>e;e++)t[e]=arguments[e];return this.pushArray(t)},unshift:function(){var e=arguments.length,t=this.length;return e&&(Dt.unshift.apply(this.$model,arguments),T.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return T.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return T.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,r=[],a=_n.apply(this.$model,arguments);return a.length&&(r.push("del",e,a.length,0),t=!0),n>2&&(t?r.splice(3,1,0,"add",e,n-2):r.push("add",e,n-2,0),t=!0),t?T.apply(this,r):[]},contains:function(e){return-1!==this.indexOf(e)},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>=0?(this.$model.splice(e,1),T.call(this,"del",e,1,0)):[]},clear:function(){return this.$model.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))e.forEach(function(e){this.remove(e)},this);else if("function"==typeof e)for(var t=this.length-1;t>=0;t--){var n=this[t];e(n,t)&&this.removeAt(t)}else this.clear()},ensure:function(e){return this.contains(e)||this.push(e),this},set:function(e,t){if(e>=0){var n=avalon.type(t);t&&t.$model&&(t=t.$model);var r=this[e];if("object"===n)for(var a in t)r.hasOwnProperty(a)&&(r[a]=t[a]);
2
+ else"array"===n?r.clear().push.apply(r,t):r!==t&&(this[e]=t,this.$model[e]=t,this._fire("set",e,t))}return this}};"sort,reverse".replace(_t,function(e){Nn[e]=function(){var t,n=this.$model,r=n.concat(),a=Math.random(),i=[];Dt[e].apply(n,arguments);for(var o=0,l=r.length;l>o;o++){var s=n[o],c=r[o];if(Mn(s,c))i.push(o);else{var u=r.indexOf(s);i.push(u),r[u]=a,t=!0}}return t&&(E(this,i),this._fire("move",i),this._fire("index",0)),this}});var Sn=/^(duplex|on)$/,Ln=avalon.$$subscribers=[],jn=new Date,Hn={},Pn={area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],col:[2,"<table><colgroup>","</colgroup></table>"],legend:[1,"<fieldset>","</fieldset>"],option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],tr:[2,"<table>","</table>"],td:[3,"<table><tr>","</tr></table>"],g:[1,'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">',"</svg>"],_default:It?[0,"",""]:[1,"X<div>","</div>"]};Pn.th=Pn.td,Pn.optgroup=Pn.option,Pn.tbody=Pn.tfoot=Pn.colgroup=Pn.caption=Pn.thead,String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(_t,function(e){Pn[e]=Pn.g});var Dn=/<([\w:]+)/,Fn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Bn=It?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/gi,In=i(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),Rn=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,Vn=$t.createElement("script"),Un=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Vt.cloneNode(!1);if("string"!=typeof e)return t;if(!Un.test(e))return t.appendChild($t.createTextNode(e)),t;e=e.replace(Fn,"<$1></$2>").trim();var n,r,a=(Dn.exec(e)||["",""])[1].toLowerCase(),i=Pn[a]||Pn._default,o=Ut;It||(e=e.replace(Bn,"<br class=msNoScope>$1")),o.innerHTML=i[1]+e+i[2];var l=o.getElementsByTagName("script");if(l.length)for(var s,c=0;s=l[c++];)In[s.type]&&(r=Vn.cloneNode(!1),Dt.forEach.call(s.attributes,function(e){e&&e.specified&&(r[e.name]=e.value,r.setAttribute(e.name,e.value))}),r.text=s.text,s.parentNode.replaceChild(r,s));if(!It){var u="X<div>"===i[1]?o.lastChild.firstChild:o.lastChild;if(u&&"TABLE"===u.tagName&&"tbody"!==a)for(l=u.childNodes,c=0;s=l[c++];)if("TBODY"===s.tagName&&!s.innerHTML){u.removeChild(s);break}l=o.getElementsByTagName("br");for(var f=l.length;s=l[--f];)"msNoScope"===s.className&&s.parentNode.removeChild(s);for(l=o.all,c=0;s=l[c++];)L(s)&&j(s)}for(c=i[0];c--;o=o.lastChild);for(;n=o.firstChild;)t.appendChild(n);return t},avalon.innerHTML=function(e,t){if(!It&&!Bn.test(t)&&!Rn.test(t))try{return void(e.innerHTML=t)}catch(n){}var r=this.parseHTML(t);this.clearHTML(e).appendChild(r)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},avalon.scan=function(e,t){e=e||Rt;var n=t?[].concat(t):[];U(e,n)};var Wn=i("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),qn=function(e,t,n){var r=e.getAttribute(t);if(r)for(var a,i=0;a=n[i++];)if(a.hasOwnProperty(r)&&"function"==typeof a[r])return a[r]},zn=zt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var r=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=r}}:0,Xn=/ms-(\w+)-?(.*)/,Yn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Gn=i("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),Jn=i("value,title,alt,checked,selected,disabled,readonly,enabled"),Zn=/^if|widget|repeat$/,Qn=/^each|with|html|include$/;if(!"1"[0])var Kn=new Qt(512),er=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,tr=/^['"]/,nr=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,rr=/&amp;/g,ar=function(e){var t=e.outerHTML;if("</"===t.slice(0,2)||!t.trim())return[];var n,r,a,i=t.match(nr)[0],o=[],l=Kn.get(i);if(l)return l;for(;r=er.exec(i);){a=r[2],a&&(a=(tr.test(a)?a.slice(1,-1):a).replace(rr,"&"));var s=r[1].toLowerCase();n=s.match(Xn);var c={name:s,specified:!0,value:a||""};o.push(c)}return Kn.put(i,o)};var ir=/\|\s*html\s*/,or=/\|\|/g,lr=/&lt;/g,sr=/&gt;/g;rstringLiteral=/(['"])(\\\1|.)+?\1/g;var cr={_toString:function(){var e=this.node,t=e.className,n="string"==typeof t?t:t.baseVal;return n.split(/\s+/).join(" ")},_contains:function(e){return(" "+this+" ").indexOf(" "+e+" ")>-1},_add:function(e){this.contains(e)||this._set(this+" "+e)},_remove:function(e){this._set((" "+this+" ").replace(" "+e+" "," "))},__set:function(e){e=e.trim();var t=this.node;St.test(t)?t.setAttribute("class",e):t.className=e}};"add,remove".replace(_t,function(e){avalon.fn[e+"Class"]=function(t){var n=this[0];return t&&"string"==typeof t&&n&&1===n.nodeType&&t.replace(/\S+/g,function(t){G(n)[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&G(t).contains(e)},toggleClass:function(e,t){for(var n,r=0,a=e.split(/\s+/),i="boolean"==typeof t;n=a[r++];){var o=i?t:!this.hasClass(n);this[o?"addClass":"removeClass"](n)}return this},attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){switch(e="data-"+X(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return J(n);case 0:var r={};return Dt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=Y(e.slice(5)),r[e]=J(t.value)))}),r}},removeData:function(e){return e="data-"+X(e),this[0].removeAttribute(e),this},css:function(e,t){if(avalon.isPlainObject(e))for(var n in e)avalon.css(this,n,e[n]);else var r=avalon.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=avalon.css(e[0],"borderTopWidth",!0),r.left+=avalon.css(e[0],"borderLeftWidth",!0)),{top:t.top-r.top-avalon.css(n,"marginTop",!0),left:t.left-r.left-avalon.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===avalon.css(e,"position");)e=e.offsetParent;return avalon(e||Rt)},bind:function(e,t,n){return this[0]?avalon.bind(this[0],e,t,n):void 0},unbind:function(e,t,n){return this[0]&&avalon.unbind(this[0],e,t,n),this},val:function(e){var t=this[0];if(t&&1===t.nodeType){var n=0===arguments.length,r=n?":get":":set",a=kr[K(t)+r];if(a)var i=a(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?i:this}});var ur=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,fr=/^[\],:{}\s]*$/,pr=/(?:^|:|,)(?:\s*\[)+/g,dr=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,vr=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g;avalon.parseJSON=e.JSON?JSON.parse:function(e){if("string"==typeof e){if(e=e.trim(),e&&fr.test(e.replace(dr,"@").replace(vr,"]").replace(pr,"")))return new Function("return "+e)();avalon.error("Invalid JSON: "+e)}return e},avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var r=this[0]||{},a=Z(r),i="scrollTop"===e;return arguments.length?void(a?a.scrollTo(i?avalon(a).scrollLeft():n,i?n:avalon(a).scrollTop()):r[e]=n):a?t in a?a[t]:Rt[e]:r[e]}});var hr=avalon.cssHooks={},mr=["","-webkit-","-o-","-moz-","-ms-"],gr={"float":It?"cssFloat":"styleFloat"};if(avalon.cssNumber=i("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(gr[e])return gr[e];t=t||Rt.style;for(var r=0,a=mr.length;a>r;r++)if(n=Y(mr[r]+e),n in t)return gr[e]=n;return null},hr["@:set"]=function(e,t,n){try{e.style[t]=n}catch(r){}},e.getComputedStyle)hr["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,r=getComputedStyle(e,null);return r&&(n="filter"===t?r.getPropertyValue(t):r[t],""===n&&(n=e.style[t])),n},hr["opacity:get"]=function(e){var t=hr["@:get"](e,"opacity");return""===t?"1":t};else{var yr=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,br=/^(top|right|bottom|left)$/,xr=/alpha\([^)]*\)/i,$r=!!e.XDomainRequest,wr="DXImageTransform.Microsoft.Alpha",Cr={thin:$r?"1px":"2px",medium:$r?"3px":"4px",thick:$r?"5px":"6px"};hr["@:get"]=function(e,t){var n=e.currentStyle,r=n[t];if(yr.test(r)&&!br.test(r)){var a=e.style,i=a.left,o=e.runtimeStyle.left;e.runtimeStyle.left=n.left,a.left="fontSize"===t?"1em":r||0,r=a.pixelLeft+"px",a.left=i,e.runtimeStyle.left=o}return"medium"===r&&(t=t.replace("Width","Style"),"none"===n[t]&&(r="0px")),""===r?"auto":Cr[r]||r},hr["opacity:set"]=function(e,t,n){var r=e.style,a=isFinite(n)&&1>=n?"alpha(opacity="+100*n+")":"",i=r.filter||"";r.zoom=1,r.filter=(xr.test(i)?i.replace(xr,a):i+" "+a).trim(),r.filter||r.removeAttribute("filter")},hr["opacity:get"]=function(e){var t=e.filters.alpha||e.filters[wr],n=t&&t.enabled?t.opacity:100;return n/100+""}}"top,left".replace(_t,function(e){hr[e+":get"]=function(t){var n=hr["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Tr={position:"absolute",visibility:"hidden",display:"block"},Er=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(_t,function(e){var t=e.toLowerCase(),n="client"+e,r="scroll"+e,a="offset"+e;hr[t+":get"]=function(t,n,r){var i=-4;"number"==typeof r&&(i=r),n="Width"===e?["Left","Right"]:["Top","Bottom"];var o=t[a];return 2===i?o+avalon.css(t,"margin"+n[0],!0)+avalon.css(t,"margin"+n[1],!0):(0>i&&(o=o-avalon.css(t,"border"+n[0]+"Width",!0)-avalon.css(t,"border"+n[1]+"Width",!0)),-4===i&&(o=o-avalon.css(t,"padding"+n[0],!0)-avalon.css(t,"padding"+n[1],!0)),o)},hr[t+"&get"]=function(e){var n=[];Q(e,n);for(var r,a=hr[t+":get"](e),i=0;r=n[i++];){e=r.node;for(var o in r)"string"==typeof r[o]&&(e.style[o]=r[o])}return a},avalon.fn[t]=function(i){var o=this[0];if(0===arguments.length){if(o.setTimeout)return o["inner"+e]||o.document.documentElement[n];if(9===o.nodeType){var l=o.documentElement;return Math.max(o.body[r],l[r],o.body[a],l[a],l[n])}return hr[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return hr[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return hr[t+":get"](this[0],void 0,e===!0?2:0)}}),avalon.fn.offset=function(){var e=this[0],t={left:0,top:0};if(!e||!e.tagName||!e.ownerDocument)return t;var n=e.ownerDocument,r=n.body,a=n.documentElement,i=n.defaultView||n.parentWindow;if(!avalon.contains(a,e))return t;e.getBoundingClientRect&&(t=e.getBoundingClientRect());var o=a.clientTop||r.clientTop,l=a.clientLeft||r.clientLeft,s=Math.max(i.pageYOffset||0,a.scrollTop,r.scrollTop),c=Math.max(i.pageXOffset||0,a.scrollLeft,r.scrollLeft);return{top:t.top+s-o,left:t.left+c-l}};var Ar=/^<option(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s+value[\s=]/i,kr={"option:get":zt?function(e){return Ar.test(e.outerHTML)?e.value:e.text.trim()}:function(e){return e.value},"select:get":function(e,t){for(var n,r=e.options,a=e.selectedIndex,i=kr["option:get"],o="select-one"===e.type||0>a,l=o?null:[],s=o?a+1:r.length,c=0>a?s:o?a:0;s>c;c++)if(n=r[c],(n.selected||c===a)&&!n.disabled){if(t=i(n),o)return t;l.push(t)}return l},"select:set":function(e,t,n){t=[].concat(t);for(var r,a=kr["option:get"],i=0;r=e.options[i++];)(r.selected=t.indexOf(a(r))>-1)&&(n=!0);n||(e.selectedIndex=-1)}},Mr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},Or=e.JSON&&JSON.stringify||function(e){return'"'+e.replace(/[\\\"\x00-\x1f]/g,function(e){var t=Mr[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'},_r=["break,case,catch,continue,debugger,default,delete,do,else,false","finally,for,function,if,in,instanceof,new,null,return,switch,this","throw,true,try,typeof,var,void,while,with","abstract,boolean,byte,char,class,const,double,enum,export,extends","final,float,goto,implements,import,int,interface,long,native","package,private,protected,public,short,static,super,synchronized","throws,transient,volatile","arguments,let,yield,undefined"].join(","),Nr=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Sr=/[^\w$]+/g,Lr=new RegExp(["\\b"+_r.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),jr=/\b\d[^,]*/g,Hr=/^,+|,+$/g,Pr=new Qt(512),Dr=function(e){var t=","+e.trim(),n=Pr.get(t);if(n)return n;var r=e.replace(Nr,"").replace(Sr,",").replace(Lr,"").replace(jr,"").replace(Hr,"").split(/^$|,+/);return Pr.put(t,tt(r))},Fr=new Qt(128),Br=/\w\[.*\]|\w\.\w/,Ir=/(\$proxy\$[a-z]+)\d+$/,Rr=/\)\s*$/,Vr=/\)\s*\|/g,Ur=/\|\s*([$\w]+)/g,Wr=/"\s*\["/g,qr=/"\s*\(/g;avalon.parseExprProxy=at;var zr=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),Xr={};zr.replace(_t,function(e){Xr[e.toLowerCase()]=e});var Yr={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},Gr=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");Gr.replace(_t,function(e){Yr[e.toLowerCase()]=e});var Jr=/<noscript.*?>(?:[\s\S]+?)<\/noscript>/gim,Zr=/<noscript.*?>([\s\S]+?)<\/noscript>/im,Qr=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},Kr=avalon.templateCache={};Jt.attr=function(e,t){var n=e.value.trim(),r=!0;if(n.indexOf(fn)>-1&&n.indexOf(pn)>2&&(r=!1,dn.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(r=!0,n=RegExp.$1)),"include"===e.type){var a=e.element;e.includeRendered=qn(a,"data-include-rendered",t),e.includeLoaded=qn(a,"data-include-loaded",t);var i=e.includeReplace=!!avalon(a).data("includeReplace");avalon(a).data("includeCache")&&(e.templateCache={}),e.startInclude=$t.createComment("ms-include"),e.endInclude=$t.createComment("ms-include-end"),i?(e.element=e.startInclude,a.parentNode.insertBefore(e.startInclude,a),a.parentNode.insertBefore(e.endInclude,a.nextSibling)):(a.insertBefore(e.startInclude,a.firstChild),a.appendChild(e.endInclude))}e.handlerName="attr",at(n,t,e,r?0:q(e.value))},Zt.attr=function(t,n,r){var a=r.type,i=r.param;if("css"===a)avalon(n).css(i,t);else if("attr"===a){if(Xr[i]){var o=Xr[i];if("boolean"==typeof n[o])return n[o]=!!t}var l=t===!1||null===t||void 0===t;if(!It&&Yr[i]&&(i=Yr[i]),l)return n.removeAttribute(i);var s=St.test(n)?!1:$t.namespaces&&L(n)?!0:i in n.cloneNode(!1);s?n[i]=t:n.setAttribute(i,t)}else if("include"===a&&t){var c=r.vmodels,u=r.includeRendered,f=r.includeLoaded,p=r.includeReplace,d=p?n.parentNode:n,v=function(e){f&&(e=f.apply(d,[e].concat(c))),u&&H(d,function(){u.call(d)},0/0);var n=r.includeLastID;if(r.templateCache&&n&&n!==t){var a=r.templateCache[n];a||(a=r.templateCache[n]=$t.createElement("div"),Ct.appendChild(a))}for(r.includeLastID=t;;){var i=r.startInclude.nextSibling;if(!i||i===r.endInclude)break;d.removeChild(i),a&&a.appendChild(i)}var o=it(r,t,e),l=avalon.slice(o.childNodes);d.insertBefore(o,r.endInclude),R(l,c)};if("src"===r.param)if(Kr[t])avalon.nextTick(function(){v(Kr[t])});else{var h=Qr();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;(e>=200&&300>e||304===e||1223===e)&&v(Kr[t]=h.responseText)}},h.open("GET",t,!0),"withCredentials"in h&&(h.withCredentials=!0),h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.send(null)}else{var m=t&&1===t.nodeType?t:$t.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=Qr(),h.open("GET",location,!1),h.send(null);for(var g=$t.getElementsByTagName("noscript"),y=(h.responseText||"").match(Jr)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(Zr)||["","&nbsp;"])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Rt.hasAttribute||"string"!=typeof t||"src"!==a&&"href"!==a||(t=t.replace(/&amp;/g,"&")),n[a]=t,e.chrome&&"EMBED"===n.tagName){var w=n.parentNode,C=document.createComment("ms-src");w.replaceChild(C,n),w.replaceChild(n,C)}},"title,alt,src,value,css,include,href".replace(_t,function(e){Jt[e]=Jt.attr}),Jt["class"]=function(e,t){var r,a=e.param,i=e.value;if(e.handlerName="class",!a||isFinite(a)){e.param="";var o=i.replace(vn,function(e){return e.replace(/./g,"0")}),l=o.indexOf(":");if(-1===l)var s=i;else{if(s=i.slice(0,l),r=i.slice(l+1),rt(r,t,e),!e.evaluator)return n("debug: ms-class '"+(r||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=dn.test(s);c||(e.immobileClass=s),at("",t,e,c?q(s):0)}else e.immobileClass=e.oldStyle=e.param,at(i,t,e)},Zt["class"]=function(e,t,n){var r=avalon(t),a=n.type;if("class"===a&&n.oldStyle)r.toggleClass(n.oldStyle,!!e);else switch(n.toggleClass=n._evaluator?!!n._evaluator.apply(t,n._args):!0,n.newClass=n.immobileClass||e,n.oldClass&&n.newClass!==n.oldClass&&r.removeClass(n.oldClass),n.oldClass=n.newClass,a){case"class":r.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var i="mouseenter",o="mouseleave";if("active"===a){t.tabIndex=t.tabIndex||-1,i="mousedown",o="mouseup";var l=r.bind("mouseleave",function(){n.toggleClass&&r.removeClass(n.newClass)})}var s=r.bind(i,function(){n.toggleClass&&r.addClass(n.newClass)}),c=r.bind(o,function(){n.toggleClass&&r.removeClass(n.newClass)});n.rollback=function(){r.unbind("mouseleave",l),r.unbind(i,s),r.unbind(o,c)},n.hasBindEvent=!0}}},"hover,active".replace(_t,function(e){Jt[e]=Jt["class"]}),Zt.data=function(e,t,n){var r="data-"+n.param;e&&"object"==typeof e?t[r]=e:t.setAttribute(r,String(e))};var ea=Jt.duplex=function(e,t){var a,o=e.element;if(at(e.value,t,e,0,1),e.changed=qn(o,"data-duplex-changed",t)||r,e.evaluator&&e.args){var l=[],s=i("string,number,boolean,checked");"radio"===o.type&&""===e.param&&(e.param="checked"),o.msData&&(o.msData["ms-duplex"]=e.value),e.param.replace(/\w+/g,function(t){/^(checkbox|radio)$/.test(o.type)&&/^(radio|checked)$/.test(t)&&("radio"===t&&n("ms-duplex-radio已经更名为ms-duplex-checked"),t="checked",e.isChecked=!0),"bool"===t?(t="boolean",n("ms-duplex-bool已经更名为ms-duplex-boolean")):"text"===t&&(t="string",n("ms-duplex-text已经更名为ms-duplex-string")),s[t]&&(a=!0),avalon.Array.ensure(l,t)}),a||l.push("string"),e.param=l.join("-"),e.bound=function(t,n){o.addEventListener?o.addEventListener(t,n,!1):o.attachEvent("on"+t,n);var r=e.rollback;e.rollback=function(){o.avalonSetter=null,avalon.unbind(o,t,n),r&&r()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=lt);f(null,e,"init");var p=o.tagName;ea[p]&&ea[p](o,e.evaluator.apply(null,e.args),e)}};avalon.duplexHooks={checked:{get:function(e,t){return!t.element.oldValue}},string:{get:function(e){return e},set:ot},"boolean":{get:function(e){return"true"===e},set:ot},number:{get:function(e,t){var n=parseFloat(e);if(-e===-n)return n;var r=/strong|medium|weak/.exec(t.element.getAttribute("data-duplex-number"))||["medium"];switch(r[0]){case"strong":return 0;case"medium":return""===e?"":0;case"weak":return e}},set:ot}};var ta,na=[];avalon.tick=function(e){1===na.push(e)&&(ta=setInterval(st,60))};var ra=r,aa=/text|password|hidden/;!new function(){function e(e){if(avalon.contains(Rt,this)){if(t[this.tagName].call(this,e),!aa.test(this.type))return;!this.msFocus&&this.avalonSetter&&this.avalonSetter()}}try{var t={},n=HTMLInputElement.prototype,r=HTMLTextAreaElement.prototype,a=HTMLInputElement.prototype;Object.getOwnPropertyNames(a),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(r,"value").set,Object.defineProperty(r,"value",{set:e})}catch(i){ra=avalon.tick}},zt&&avalon.bind($t,"selectionchange",function(){var e=$t.activeElement;e&&"function"==typeof e.avalonSetter&&e.avalonSetter()}),ea.INPUT=function(e,t,r){function a(e){r.changed.call(this,e,r)}function i(){f=!0}function o(){f=!1}function l(e){setTimeout(function(){p(e)})}var s=e.type,c=r.bound,u=avalon(e),f=!1,p=function(){if(!f){var n=e.oldValue=e.value,i=r.pipe(n,r,"get");u.data("duplex-observe")!==!1&&(t(i),a.call(e,i),u.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}};if(r.handler=function(){var n=r.pipe(t(),r,"set")+"";n!==e.oldValue&&(e.value=n)},r.isChecked||"radio"===s){var d=6===zt;p=function(){if(u.data("duplex-observe")!==!1){var n=r.pipe(e.value,r,"get");t(n),a.call(e,n)}},r.handler=function(){var n=t(),a=r.isChecked?!!n:n+""===e.value;e.oldValue=a,d?setTimeout(function(){e.defaultChecked=a,e.checked=a},31):e.checked=a},c("click",p)}else if("checkbox"===s)p=function(){if(u.data("duplex-observe")!==!1){var i=e.checked?"ensure":"remove",o=t();Array.isArray(o)||(n("ms-duplex应用于checkbox上要对应一个数组"),o=[o]),avalon.Array[i](o,r.pipe(e.value,r,"get")),a.call(e,o)}},r.handler=function(){var n=[].concat(t());e.checked=n.indexOf(r.pipe(e.value,r,"get"))>-1},c(It?"change":"click",p);else{var v=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),v.replace(_t,function(e){switch(e){case"input":zt?(zt>8?c("input",p):c("propertychange",function(e){"value"===e.propertyName&&p()}),c("dragend",l)):(c("input",p),c("compositionstart",i),c("compositionend",o),c("DOMAutoComplete",p));break;default:c(e,p)}}),c("focus",function(){e.msFocus=!0}),c("blur",function(){e.msFocus=!1}),aa.test(s)&&ra(function(){if(Rt.contains(e))e.msFocus||e.oldValue===e.value||p();else if(!e.msRetain)return!1}),e.avalonSetter=p}e.oldValue=e.value,A(r),a.call(e,e.value)},ea.TEXTAREA=ea.INPUT,ea.SELECT=function(e,t,r){function a(){if(i.data("duplex-observe")!==!1){var n=i.val();n=Array.isArray(n)?n.map(function(e){return r.pipe(e,r,"get")}):r.pipe(n,r,"get"),n+""!==e.oldValue&&t(n),r.changed.call(e,n,r)}}var i=avalon(e);r.handler=function(){var r=t();r=r&&r.$model||r,Array.isArray(r)?e.multiple||n("ms-duplex在<select multiple=true>上要求对应一个数组"):e.multiple&&n("ms-duplex在<select multiple=false>不能对应一个数组"),r=Array.isArray(r)?r.map(String):r+"",r+""!==e.oldValue&&(i.val(r),e.oldValue=r+"")},r.bound("change",a),H(e,function(){A(r),r.changed.call(e,t(),r)},0/0)},Zt.html=function(e,t,n){e=null==e?"":e;var r="group"in n,a=r?t.parentNode:t;if(a){if(11===e.nodeType)var i=e;else if(1===e.nodeType||e.item){var o=1===e.nodeType?e.childNodes:e.item?e:[];for(i=Vt.cloneNode(!0);o[0];)i.appendChild(o[0])}else i=avalon.parseHTML(e);var l=$t.createComment("ms-html");if(r){a.insertBefore(l,t);for(var s=n.group,c=1;s>c;){var u=t.nextSibling;u&&(a.removeChild(u),c++)}a.removeChild(t),n.element=l}else avalon.clearHTML(a).appendChild(l);r&&(n.group=i.childNodes.length||1),o=avalon.slice(i.childNodes),o[0]&&(l.parentNode&&l.parentNode.replaceChild(i,l),r&&(n.element=o[0])),R(o,n.vmodels)}},Jt["if"]=Jt.data=Jt.text=Jt.html=function(e,t){at(e.value,t,e)},Zt["if"]=function(e,t,n){if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),B(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=$t.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,Ct.appendChild(t),n.rollback=function(){t.parentNode===Ct&&Ct.removeChild(t)}}};var ia=/\(([^)]*)\)/;Jt.on=function(e,t){var n=e.value;e.type="on";var r=e.param.replace(/-\d+$/,"");if("function"==typeof Jt.on[r+"Hook"]&&Jt.on[r+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var a=(n.match(ia)||["",""])[1].trim();(""===a||"$event"===a)&&(n=n.replace(ia,""))}at(n,t,e)},Zt.on=function(e,t,n){e=function(e){var t=n.evaluator||r;return t.apply(this,n.args.concat(e))};var a=n.param.replace(/-\d+$/,"");if("scan"===a)e.call(t,{type:a});else if("function"==typeof n.specialBind)n.specialBind(t,e);else var i=avalon.bind(t,a,e);n.rollback=function(){"function"==typeof n.specialUnbind?n.specialUnbind():avalon.unbind(t,a,i)}},Jt.repeat=function(e,t){var n=e.type;at(e.value,t,e,0,1),e.proxies=[];var r=!1;try{var a=e.$repeat=e.evaluator.apply(0,e.args||[]),i=avalon.type(a);"object"!==i&&"array"!==i&&(r=!0,avalon.log("warning:"+e.value+"只能是对象或数组"))}catch(o){r=!0}var l=e.value.split(".")||[];if(l.length>1){l.pop();for(var s,c=l[0],u=0;s=t[u++];)if(s&&s.hasOwnProperty(c)){var f=s[c].$events||{};f[At]=f[At]||[],f[At].push(e);break}}var p=e.element;p.removeAttribute(e.name),e.sortedCallback=qn(p,"data-with-sorted",t),e.renderedCallback=qn(p,"data-"+n+"-rendered",t);var d=qt(n),v=e.element=$t.createComment(d+":end");if(e.clone=$t.createComment(d),Vt.appendChild(v),"each"===n||"with"===n?(e.template=p.innerHTML.trim(),avalon.clearHTML(p).appendChild(v)):(e.template=p.outerHTML.trim(),p.parentNode.replaceChild(v,p)),e.template=avalon.parseHTML(e.template),e.rollback=function(){var t=e.element;if(t){Zt.repeat.call(e,"clear");var n=t.parentNode,r=e.template,a=r.firstChild;n.replaceChild(r,t);var i=e.$stamp;i&&i.parentNode&&i.parentNode.removeChild(i),a=e.element="repeat"===e.type?a:n}},!r){e.handler=Zt.repeat,e.$outer={};var h="$key",m="$val";for(Array.isArray(a)&&(h="$first",m="$last"),u=0;s=t[u++];)if(s.hasOwnProperty(h)&&s.hasOwnProperty(m)){e.$outer=s;break}var g=a.$events,y=(g||{})[At];if(y&&avalon.Array.ensure(y,e)&&M(e,y),"object"===i){e.$with=!0;var b=g?g.$withProxyPool||(g.$withProxyPool={}):{};e.handler("append",a,b)}else a.length&&e.handler("add",0,a.length)}},Zt.repeat=function(e,t,n){if(e){var a=this,i=a.element,o=i.parentNode,l=a.proxies,s=Vt.cloneNode(!1);switch(e){case"add":for(var c,u=t+n,f=a.$repeat,p=f.length-1,d=[],v=ut(a,t),h=t;u>h;h++){var m=dt(h,a);l.splice(h,0,m),ct(a,s,m,d)}for(o.insertBefore(s,v),h=0;c=d[h++];)R(c.nodes,c.vmodels),c.nodes=c.vmodels=null;break;case"del":v=l[t].$stamp,i=ut(a,t+n),ft(v,i);var g=l.splice(t,n);mt(g,"each");break;case"clear":var y=a.$stamp||l[0];y&&(v=y.$stamp||y,ft(v,i)),mt(l,"each");break;case"move":v=l[0].$stamp;var b,x=v.nodeValue,$=[],w=[];for(ft(v,i,function(){w.unshift(this),this.nodeValue===x&&($.unshift(w),w=[])}),E(l,t),E($,t);w=$.shift();)for(;b=w.shift();)s.appendChild(b);o.insertBefore(s,i);break;case"index":for(p=l.length-1;n=l[t];t++)n.$index=t,n.$first=0===t,n.$last=t===p;return;case"set":return m=l[t],void(m&&S(m.$events.$index));case"append":var C=n,T=[];d=[];for(var A in t)t.hasOwnProperty(A)&&"hasOwnProperty"!==A&&T.push(A);if(a.sortedCallback){var k=a.sortedCallback.call(o,T);k&&Array.isArray(k)&&k.length&&(T=k)}for(h=0;A=T[h++];)"hasOwnProperty"!==A&&(C[A]||(C[A]=ht(A,a)),ct(a,s,C[A],d));var M=a.$stamp=a.clone;for(o.insertBefore(M,i),o.insertBefore(s,i),h=0;c=d[h++];)R(c.nodes,c.vmodels),c.nodes=c.vmodels=null}"clear"===e&&(e="del");var O=a.renderedCallback||r,_=arguments;H(o,function(){O.apply(o,_),o.oldValue&&"SELECT"===o.tagName&&avalon(o).val(o.oldValue.split(","))},0/0)}},"with,each".replace(_t,function(e){Jt[e]=Jt.repeat});var oa=[],la=[];Zt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else"textContent"in t?t.textContent=e:t.innerText=e},avalon.parseDisplay=gt,Jt.visible=function(e,t){var n=avalon(e.element),r=n.css("display");if("none"===r){var a=n[0].style,i=/visibility/i.test(a.cssText),o=n.css("visibility");a.display="",a.visibility="hidden",r=n.css("display"),"none"===r&&(r=gt(n[0].nodeName)),a.visibility=i?o:""}e.display=r,at(e.value,t,e)},Zt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Jt.widget=function(t,n){var a=t.value.match(_t),i=t.element,o=a[0],l=a[1];l&&"$"!==l||(l=qt(o));var s=a[2]||o,c=avalon.ui[o];if("function"==typeof c){n=i.vmodels||n;for(var u,f=0;u=n[f++];)if(u.hasOwnProperty(s)&&"object"==typeof u[s]){var p=u[s];p=p.$model||p;break}if(p){var d=p[o+"Id"];"string"==typeof d&&(l=d)}var v=avalon.getWidgetData(i,o);t.value=[o,l,s].join(","),t[o+"Id"]=l,t.evaluator=r,i.msData["ms-widget-id"]=l;var h=t[o+"Options"]=avalon.mix({},c.defaults,p||{},v);i.removeAttribute("ms-widget");var m=c(i,t,n)||{};m.$id?(avalon.vmodels[l]=m,P(i,m),m.hasOwnProperty("$init")&&m.$init(function(){avalon.scan(i,[m].concat(n)),"function"==typeof h.onInit&&h.onInit.call(i,m,h,n)}),t.rollback=function(){try{m.widgetElement=null,m.$remove()}catch(e){}i.msData={},delete avalon.vmodels[m.$id]},M(t,sa),e.chrome&&i.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(N)})):avalon.scan(i,n)}else n.length&&(i.vmodels=n)};var sa=[],ca=/<script[^>]*>([\S\s]*?)<\/script\s*>/gim,ua=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,fa=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,pa={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},da=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,va=/([^\#-~| |!])/g,ha=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n=void 0===n?"...":n,e.length>t?e.slice(0,t-n.length)+n:String(e)},$filter:function(e){for(var t=1,n=arguments.length;n>t;t++){var r=arguments[t],a=avalon.filters[r.shift()];if("function"==typeof a){var i=[e].concat(r);e=a.apply(null,i)}}return e},camelize:Y,sanitize:function(e){return e.replace(ca,"").replace(fa,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=pa[t[1]];n&&(e=e.replace(n,function(e,t,n){var r=n.charAt(0);return t+"="+r+"javascript:void(0)"+r}))}return e.replace(ua," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&amp;").replace(da,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(va,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},currency:function(e,t,n){return(t||"¥")+yt(e,isFinite(n)?n:2)},number:yt};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var r="";for(0>e&&(r="-",e=-e),e=""+e;e.length<t;)e="0"+e;return n&&(e=e.substr(e.length-t)),r+e}function n(e,n,r,a){return function(i){var o=i["get"+e]();return(r>0||o>-r)&&(o+=r),0===o&&-12===r&&(o=12),t(o,n,a)}}function r(e,t){return function(n,r){var a=n["get"+e](),i=(t?"SHORT"+e:e).toUpperCase();return r[i][a]}}function a(e){var n=-1*e.getTimezoneOffset(),r=n>=0?"+":"";return r+=t(Math[n>0?"floor":"ceil"](n/60),2)+t(Math.abs(n%60),2)}function i(e,t){return e.getHours()<12?t.AMPMS[0]:t.AMPMS[1]}var o={yyyy:n("FullYear",4),yy:n("FullYear",2,0,!0),y:n("FullYear",1),MMMM:r("Month"),MMM:r("Month",!0),MM:n("Month",2,1),M:n("Month",1,1),dd:n("Date",2),d:n("Date",1),HH:n("Hours",2),H:n("Hours",1),hh:n("Hours",2,-12),h:n("Hours",1,-12),mm:n("Minutes",2),m:n("Minutes",1),ss:n("Seconds",2),s:n("Seconds",1),sss:n("Milliseconds",3),EEEE:r("Day"),EEE:r("Day",!0),a:i,Z:a},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;ha.date=function(t,n){var r,a,i=ha.date.locate,c="",u=[];if(n=n||"mediumDate",n=i[n]||n,"string"==typeof t)if(/^\d+$/.test(t))t=e(t);else if(s.test(t))t=+RegExp.$1;else{var f=t.trim(),p=[0,0,0,0,0,0,0],d=new Date(0);f=f.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,r,a){var i=4===a.length?[a,n,r]:[n,r,a];return p[0]=e(i[0]),p[1]=e(i[1])-1,p[2]=e(i[2]),""});var v=d.setFullYear,h=d.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,r,a,i){return p[3]=e(n),p[4]=e(r),p[5]=e(a),i&&(p[6]=Math.round(1e3*parseFloat("0."+i))),""});var m=0,g=0;f=f.replace(/Z|([+-])(\d\d):?(\d\d)/,function(t,n,r,a){return v=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+r),g=e(n+a)),""}),p[3]-=m,p[4]-=g,v.apply(d,p.slice(0,3)),h.apply(d,p.slice(3)),t=d}if("number"==typeof t&&(t=new Date(t)),"date"===avalon.type(t)){for(;n;)a=l.exec(n),a?(u=u.concat(a.slice(1)),n=u.pop()):(u.push(n),n=null);return u.forEach(function(e){r=o[e],c+=r?r(t,i):e.replace(/(^'|'$)/g,"").replace(/''/g,"'")}),c}};var c={AMPMS:{0:"上午",1:"下午"},DAY:{0:"星期日",1:"星期一",2:"星期二",3:"星期三",4:"星期四",5:"星期五",6:"星期六"},MONTH:{0:"1月",1:"2月",2:"3月",3:"4月",4:"5月",5:"6月",6:"7月",7:"8月",8:"9月",9:"10月",10:"11月",11:"12月"},SHORTDAY:{0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"},fullDate:"y年M月d日EEEE",longDate:"y年M月d日",medium:"yyyy-M-d H:mm:ss",mediumDate:"yyyy-M-d",mediumTime:"H:mm:ss","short":"yy-M-d ah:mm",shortDate:"yy-M-d",shortTime:"ah:mm"};
3
+ c.SHORTMONTH=c.MONTH,ha.date.locate=c};var ma=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};ma.exports=ma.avalon,new function(){function t(e,t){var r="js";e=e.replace(/^(\w+)\!/,function(e,t){return r=t,""}),"ready"===r&&(n("debug: ready!已经被废弃,请使用domReady!"),r="domReady");var a="";e=e.replace(P,function(e){return a=e,""});var i="."+r,o=/js|css/.test(i)?i:"";e=e.replace(/\.[a-z0-9]+$/g,function(e){return e===i?(o=e,""):e});var l=avalon.mix({query:a,ext:o,res:r,name:e,toUrl:m},t);return l.toUrl(e),l}function i(e){var t=e.name,n=e.res,r=ma[t],a=t&&e.urlNoQuery;if(r&&r.state>=1)return t;if(r=ma[a],r&&r.state>=3)return Tt(r.deps||[],r.factory,a),a;if(t&&!r){r=ma[a]={id:a,state:1};var i=function(a){H[n]=a,a.load(t,e,function(e){arguments.length&&void 0!==e&&(r.exports=e),r.state=4,s()})};H[n]?i(H[n]):Tt([n],i)}return t?a:n+"!"}function o(e,t){for(var n,r=0;n=e[r++];)if(4!==ma[n].state&&(n===t||o(ma[n].deps,t)))return!0}function l(e,t,r){var a=u(e.src);return e.onload=e.onreadystatechange=e.onerror=null,t||r&&ma[a]&&!ma[a].state?(setTimeout(function(){wt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!ma[a].state)):!0}function s(){e:for(var e,t=E.length;e=E[--t];){var n=ma[e],r=n.deps;if(r){for(var a,i=0;a=r[i];i++)if(4!==Object(ma[a]).state)continue e;4!==n.state&&(E.splice(t,1),v(n.id,n.deps,n.factory),s())}}}function c(e,t,r){function a(){if(!"1"[0]&&!o)return o=setTimeout(a,150);if(c||j.test(i.readyState)){clearTimeout(o);var u=A.pop();u&&u.require(t),r&&r(),l(i,!1,!c)&&(n("debug: 已成功加载 "+e),t&&E.push(t),s())}}var i=$t.createElement("script");i.className=At;var o,c="onload"in i,u=c?"onload":"onreadystatechange";i[u]=a,i.onerror=function(){l(i,!0)},wt.insertBefore(i,wt.firstChild),i.src=e,n("debug: 正准备加载 "+e)}function u(e){return(e||"").replace(P,"")}function f(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(e,t){return"1"[0]?e[t]:e.getAttribute(t,4)}function d(){var t;try{a.b.c()}catch(n){t=n.stack,!t&&e.opera&&(t=(String(n).match(/of linked script \S+/g)||[]).join(" "))}if(t)return t=t.split(/[@ ]/g).pop(),t="("===t[0]?t.slice(1,-1):t.replace(/\s/,""),u(t.replace(/(:\d+)?:\d+$/i,""));for(var r,i=wt.getElementsByTagName("script"),o=i.length;r=i[--o];)if(r.className===At&&"interactive"===r.readyState){var l=p(r,"src");return r.className=u(l)}}function v(t,r,a){var i=Object(ma[t]);i.state=4;for(var o,l=0,s=[];o=r[l++];)if("exports"===o){var c=i.exports||(i.exports={});s.push(c)}else s.push(ma[o].exports);try{var u=a.apply(e,s)}catch(f){n("执行["+t+"]模块的factory抛错: "+f)}return void 0!==u&&(i.exports=u),D.test(t)&&delete ma[t],delete i.factory,u}function m(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,r=this.baseUrl,a=this.parentUrl||r;$(e,h.paths,function(e,r){t=t.replace(r,e),n=1}),n||$(e,h.packages,function(e,n,r){t=t.replace(r.name,r.location)}),this.mapUrl&&$(this.mapUrl,h.map,function(e){$(t,e,function(e,n){t=t.replace(n,e),a=r})});var i=this.ext;i&&n&&t.slice(-i.length)===i&&(t=t.slice(0,-i.length)),f(t)||(a=this.built||/^\w/.test(t)?r:a,t=C(a,t));var o=t+i;return t=o+this.query,$(e,h.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=o}function g(e,t,n){var r=x(e,t,n);return r.sort(w),r}function y(e){return new RegExp("^"+e+"(/|$)")}function b(t){return function(){var n;return t.init&&(n=t.init.apply(e,arguments)),n||t.exports&&T(t.exports)}}function x(e,t,n){var r=[];for(var a in e)if(Ht.call(e,a)){var i={name:a,val:e[a]};r.push(i),i.reg="*"===a&&t?/^/:y(a),n&&"*"!==a&&(i.reg=new RegExp("/"+a.replace(/^\//,"")+"(/|$)"))}return r}function $(e,t,n){t=t||[];for(var r,a=0;r=t[a++];)if(r.reg.test(e))return n(r.val,r.name,r),!1}function w(e,t){var n=e.name,r=t.name;return"*"===r?-1:"*"===n?1:r.length-n.length}function C(e,t){if("/"!==e.charAt(e.length-1)&&(e+="/"),"./"===t.slice(0,2))return e+t.slice(2);if(".."===t.slice(0,2)){for(e+=t;F.test(e);)e=e.replace(F,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function T(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var E=[],A=[],k=/\.js$/i,M=[],O=!1;Tt=avalon.require=function(e,n,a,o){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var l=[],c={},u=a||"callback"+setTimeout("1");o=o||{},o.baseUrl=h.baseUrl;var f=!!o.built;if(a&&(o.parentUrl=a.substr(0,a.lastIndexOf("/")),o.mapUrl=a.replace(k,"")),f){var p=t(o.defineName,o);u=p.urlNoQuery}else e.forEach(function(e){var n=t(e,o),r=i(n);r&&(c[r]||(l.push(r),c[r]="司徒正美"))});var d=ma[u];d&&4===d.state||(ma[u]={id:u,deps:f?e.concat():l,factory:n||r,state:3}),d||E.push(u),s()}else if(M.push(avalon.slice(arguments)),arguments.length<=2){O=!0;for(var v,m=M.splice(0,M.length);v=m.shift();)Tt.apply(null,v)}},Tt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var r={built:!O,defineName:e},a=[t,n,r];n.require=function(e){if(a.splice(2,0,e),ma[e]){ma[e].state=3;var t=!1;try{t=o(ma[e].deps,e)}catch(r){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,Tt.apply(null,a)};var i=r.built?"unknown":d();if(i){var l=ma[i];l&&(l.state=2),n.require(i)}else A.push(n)},Tt.config=h,Tt.define.amd=ma;var _=h["orig.paths"]={},N=h["orig.map"]={},S=h.packages=[],L=h["orig.args"]={};avalon.mix(gn,{paths:function(e){avalon.mix(_,e),h.paths=g(_)},map:function(e){avalon.mix(N,e);var t=g(N,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),h.map=t},packages:function(e){e=e.concat(S);for(var t,n={},r=[],a=0;t=e[a++];){t="string"==typeof t?{name:t}:t;var i=t.name;if(!n[i]){var o=t.location?t.location:C(i,t.main||"main");o=o.replace(k,""),r.push(t),n[i]=t.location=o,t.reg=y(i)}}h.packages=r.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(L,e),h.urlArgs=g(L,1)},baseUrl:function(e){if(!f(e)){var t=wt.getElementsByTagName("base")[0];t&&wt.removeChild(t);var n=$t.createElement("a");n.href=e,e=p(n,"href"),t&&wt.insertBefore(t,wt.firstChild)}e.length>3&&(h.baseUrl=e)},shim:function(e){for(var t in e){var n=e[t];Array.isArray(n)&&(n=e[t]={deps:n}),n.exportsFn||!n.exports&&!n.init||(n.exportsFn=b(n))}h.shim=e}});var j=$t.documentMode>=8?/loaded/:/complete|loaded/,H=Tt.plugins={ready:{load:r},js:{load:function(e,t,n){var r=t.url,a=t.urlNoQuery,i=h.shim[e.replace(k,"")];i?Tt(i.deps||[],function(){var e=avalon.slice(arguments);c(r,a,function(){n(i.exportsFn?i.exportsFn.apply(0,e):void 0)})}):c(r,a)}},css:{load:function(e,t,r){var a=t.url,i=$t.createElement("link");i.rel="stylesheet",i.href=a,wt.insertBefore(i,wt.firstChild),n("debug: 已成功加载 "+a),r()}},text:{load:function(e,t,r){var a=t.url,i=Qr();i.onreadystatechange=function(){if(4===i.readyState){var e=i.status;e>399&&600>e?avalon.error(a+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+a),r(i.responseText))}},i.open("GET",a,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+a)}}};Tt.checkDeps=s;var P=/(\?[^#]*)$/,D=/^callback\d+$/,F=/\/\w+\/\.\./,B=$t.scripts[$t.scripts.length-1],I=B.getAttribute("data-main");if(I){gn.baseUrl(I);var R=h.baseUrl;h.baseUrl=R.slice(0,R.lastIndexOf("/")+1),c(R.replace(k,"")+".js")}else{var V=u(p(B,"src"));h.baseUrl=V.slice(0,V.lastIndexOf("/")+1)}};var ga,ya=[],ba=function(e){for(ga=!0,Tt&&(ma["domReady!"].state=4,Tt.checkDeps());e=ya.shift();)e(avalon)};if("complete"===$t.readyState)setTimeout(ba);else if(It)$t.addEventListener("DOMContentLoaded",ba);else{$t.attachEvent("onreadystatechange",function(){"complete"===$t.readyState&&ba()});try{var xa=null===e.frameElement}catch(kn){}Rt.doScroll&&xa&&e.external&&bt()}avalon.bind(e,"load",ba),avalon.ready=function(e){ga?e(avalon):ya.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan($t.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var $a=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=$a),avalon},void 0===t&&(e.avalon=avalon),avalon});
@@ -5,7 +5,7 @@
5
5
  http://weibo.com/jslouvre/
6
6
 
7
7
  Released under the MIT license
8
- avalon.mobile.js 1.391 built in 2015.2.12
8
+ avalon.mobile.js 1.41 built in 2015.4.4
9
9
  support IE10+ and other browsers
10
10
  ==================================================*/
11
11
  (function(global, factory) {
@@ -46,10 +46,23 @@ function log() {
46
46
  console.log.apply(console, arguments)
47
47
  }
48
48
  }
49
+ /**
50
+ * Creates a new object without a prototype. This object is useful for lookup without having to
51
+ * guard against prototypically inherited properties via hasOwnProperty.
52
+ *
53
+ * Related micro-benchmarks:
54
+ * - http://jsperf.com/object-create2
55
+ * - http://jsperf.com/proto-map-lookup/2
56
+ * - http://jsperf.com/for-in-vs-object-keys2
57
+ */
58
+ function createMap() {
59
+ return Object.create(null)
60
+ }
49
61
 
50
62
  var subscribers = "$" + expose
51
63
  var otherRequire = window.require
52
64
  var otherDefine = window.define
65
+ var innerRequire
53
66
  var stopRepeatAssign = false
54
67
  var rword = /[^, ]+/g //切割字符串为一个个小块,以空格或豆号分开它们,结合replace实现字符串的forEach
55
68
  var rcomplexType = /^(?:object|array)$/
@@ -87,16 +100,6 @@ function oneObject(array, val) {
87
100
  return result
88
101
  }
89
102
 
90
- function createCache(maxLength) {
91
- var keys = []
92
- function cache(key, value) {
93
- if (keys.push(key) > maxLength) {
94
- delete cache[keys.shift()]
95
- }
96
- return cache[key] = value;
97
- }
98
- return cache;
99
- }
100
103
  //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
101
104
  var generateID = function(prefix) {
102
105
  prefix = prefix || "avalon"
@@ -111,13 +114,60 @@ function IE() {
111
114
  }
112
115
  }
113
116
  var IEVersion = IE()
114
- /*********************************************************************
115
- * avalon的静态方法定义区 *
116
- **********************************************************************/
117
+
117
118
  avalon = function(el) { //创建jQuery式的无new 实例化结构
118
119
  return new avalon.init(el)
119
120
  }
120
121
 
122
+ /*视浏览器情况采用最快的异步回调*/
123
+ avalon.nextTick = new function() {// jshint ignore:line
124
+ var tickImmediate = window.setImmediate
125
+ var tickObserver = window.MutationObserver
126
+ var tickPost = W3C && window.postMessage
127
+ if (tickImmediate) {
128
+ return tickImmediate.bind(window)
129
+ }
130
+
131
+ var queue = []
132
+ function callback() {
133
+ var n = queue.length
134
+ for (var i = 0; i < n; i++) {
135
+ queue[i]()
136
+ }
137
+ queue = queue.slice(n)
138
+ }
139
+
140
+ if (tickObserver) {
141
+ var node = document.createTextNode("avalon")
142
+ new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line
143
+ return function(fn) {
144
+ queue.push(fn)
145
+ node.data = Math.random()
146
+ }
147
+ }
148
+
149
+ if (tickPost) {
150
+ window.addEventListener("message", function(e) {
151
+ var source = e.source
152
+ if ((source === window || source === null) && e.data === "process-tick") {
153
+ e.stopPropagation()
154
+ callback()
155
+ }
156
+ })
157
+
158
+ return function(fn) {
159
+ queue.push(fn)
160
+ window.postMessage('process-tick', '*')
161
+ }
162
+ }
163
+
164
+ return function(fn) {
165
+ setTimeout(fn, 0)
166
+ }
167
+ }// jshint ignore:line
168
+ /*********************************************************************
169
+ * avalon的静态方法定义区 *
170
+ **********************************************************************/
121
171
  avalon.init = function(el) {
122
172
  this[0] = this.element = el
123
173
  }
@@ -213,7 +263,7 @@ function _number(a, len) { //用于模拟slice, splice的效果
213
263
  avalon.mix({
214
264
  rword: rword,
215
265
  subscribers: subscribers,
216
- version: 1.391,
266
+ version: 1.41,
217
267
  ui: {},
218
268
  log: log,
219
269
  slice: function(nodes, start, end) {
@@ -222,7 +272,7 @@ avalon.mix({
222
272
  noop: noop,
223
273
  /*如果不用Error对象封装一下,str在控制台下可能会乱码*/
224
274
  error: function(str, e) {
225
- throw new (e || Error)(str)
275
+ throw new (e || Error)(str)// jshint ignore:line
226
276
  },
227
277
  /*将一个以空格或逗号隔开的字符串或数组,转换成一个键值都为1的对象*/
228
278
  oneObject: oneObject,
@@ -259,7 +309,7 @@ avalon.mix({
259
309
  if (typeof hook === "object") {
260
310
  type = hook.type
261
311
  if (hook.deel) {
262
- fn = hook.deel(el, type, fn, true)
312
+ fn = hook.deel(el, type, fn, phase)
263
313
  }
264
314
  }
265
315
  if (!fn.unbind)
@@ -374,35 +424,107 @@ function isArrayLike(obj) {
374
424
  }
375
425
  return false
376
426
  }
377
- /*视浏览器情况采用最快的异步回调(在avalon.ready里,还有一个分支,用于处理IE6-9)*/
378
- avalon.nextTick = window.setImmediate ? setImmediate.bind(window) : function(callback) {
379
- setTimeout(callback, 0) //IE10-11 or W3C
380
- }
427
+
428
+
429
+ // https://github.com/rsms/js-lru
430
+ var Cache = new function() {// jshint ignore:line
431
+ function LRU(maxLength) {
432
+ this.size = 0
433
+ this.limit = maxLength
434
+ this.head = this.tail = void 0
435
+ this._keymap = {}
436
+ }
437
+
438
+ var p = LRU.prototype
439
+
440
+ p.put = function(key, value) {
441
+ var entry = {
442
+ key: key,
443
+ value: value
444
+ }
445
+ this._keymap[key] = entry
446
+ if (this.tail) {
447
+ this.tail.newer = entry
448
+ entry.older = this.tail
449
+ } else {
450
+ this.head = entry
451
+ }
452
+ this.tail = entry
453
+ if (this.size === this.limit) {
454
+ this.shift()
455
+ } else {
456
+ this.size++
457
+ }
458
+ return value
459
+ }
460
+
461
+ p.shift = function() {
462
+ var entry = this.head
463
+ if (entry) {
464
+ this.head = this.head.newer
465
+ this.head.older =
466
+ entry.newer =
467
+ entry.older =
468
+ this._keymap[entry.key] = void 0
469
+ }
470
+ }
471
+ p.get = function(key) {
472
+ var entry = this._keymap[key]
473
+ if (entry === void 0)
474
+ return
475
+ if (entry === this.tail) {
476
+ return entry.value
477
+ }
478
+ // HEAD--------------TAIL
479
+ // <.older .newer>
480
+ // <--- add direction --
481
+ // A B C <D> E
482
+ if (entry.newer) {
483
+ if (entry === this.head) {
484
+ this.head = entry.newer
485
+ }
486
+ entry.newer.older = entry.older // C <-- E.
487
+ }
488
+ if (entry.older) {
489
+ entry.older.newer = entry.newer // C. --> E
490
+ }
491
+ entry.newer = void 0 // D --x
492
+ entry.older = this.tail // D. --> E
493
+ if (this.tail) {
494
+ this.tail.newer = entry // E. <-- D
495
+ }
496
+ this.tail = entry
497
+ return entry.value
498
+ }
499
+ return LRU
500
+ }// jshint ignore:line
381
501
 
382
502
  /*********************************************************************
383
503
  * DOM 底层补丁 *
384
504
  **********************************************************************/
385
- if (!root.contains) { //safari5+是把contains方法放在Element.prototype上而不是Node.prototype
386
- Node.prototype.contains = function(arg) {
505
+ //safari5+是把contains方法放在Element.prototype上而不是Node.prototype
506
+ if (!DOC.contains) {
507
+ Node.prototype.contains = function (arg) {
387
508
  return !!(this.compareDocumentPosition(arg) & 16)
388
509
  }
389
510
  }
390
- avalon.contains = function(root, el) {
511
+ avalon.contains = function (root, el) {
391
512
  try {
392
513
  while ((el = el.parentNode))
393
514
  if (el === root)
394
- return true;
515
+ return true
395
516
  return false
396
517
  } catch (e) {
397
518
  return false
398
519
  }
399
520
  }
521
+
400
522
  if (window.SVGElement) {
401
523
  var svgns = "http://www.w3.org/2000/svg"
402
524
  var svg = DOC.createElementNS(svgns, "svg")
403
525
  svg.innerHTML = '<circle cx="50" cy="50" r="40" fill="red" />'
404
526
  if (!rsvg.test(svg.firstChild)) {// #409
405
-
527
+ /* jshint ignore:start */
406
528
  function enumerateNode(node, targetNode) {
407
529
  if (node && node.childNodes) {
408
530
  var nodes = node.childNodes
@@ -411,7 +533,7 @@ if (window.SVGElement) {
411
533
  var svg = DOC.createElementNS(svgns,
412
534
  el.tagName.toLowerCase())
413
535
  // copy attrs
414
- ap.forEach.call(el.attributes, function(attr) {
536
+ ap.forEach.call(el.attributes, function (attr) {
415
537
  svg.setAttribute(attr.name, attr.value)
416
538
  })
417
539
  // 递归处理子节点
@@ -421,14 +543,15 @@ if (window.SVGElement) {
421
543
  }
422
544
  }
423
545
  }
546
+ /* jshint ignore:end */
424
547
  Object.defineProperties(SVGElement.prototype, {
425
548
  "outerHTML": {//IE9-11,firefox不支持SVG元素的innerHTML,outerHTML属性
426
549
  enumerable: true,
427
550
  configurable: true,
428
- get: function() {
551
+ get: function () {
429
552
  return new XMLSerializer().serializeToString(this)
430
553
  },
431
- set: function(html) {
554
+ set: function (html) {
432
555
  var tagName = this.tagName.toLowerCase(),
433
556
  par = this.parentNode,
434
557
  frag = avalon.parseHTML(html)
@@ -447,13 +570,13 @@ if (window.SVGElement) {
447
570
  "innerHTML": {
448
571
  enumerable: true,
449
572
  configurable: true,
450
- get: function() {
573
+ get: function () {
451
574
  var s = this.outerHTML
452
575
  var ropen = new RegExp("<" + this.nodeName + '\\b(?:(["\'])[^"]*?(\\1)|[^>])*>', "i")
453
576
  var rclose = new RegExp("<\/" + this.nodeName + ">$", "i")
454
577
  return s.replace(ropen, "").replace(rclose, "")
455
578
  },
456
- set: function(html) {
579
+ set: function (html) {
457
580
  if (avalon.clearHTML) {
458
581
  avalon.clearHTML(this)
459
582
  var frag = avalon.parseHTML(html)
@@ -465,17 +588,17 @@ if (window.SVGElement) {
465
588
  }
466
589
  }
467
590
  //========================= event binding ====================
468
- var eventHooks = avalon.eventHooks
591
+ var eventHooks = avalon.eventHooks
469
592
  //针对firefox, chrome修正mouseenter, mouseleave(chrome30+)
470
593
  if (!("onmouseenter" in root)) {
471
594
  avalon.each({
472
595
  mouseenter: "mouseover",
473
596
  mouseleave: "mouseout"
474
- }, function(origType, fixType) {
597
+ }, function (origType, fixType) {
475
598
  eventHooks[origType] = {
476
599
  type: fixType,
477
- deel: function(elem, fn) {
478
- return function(e) {
600
+ deel: function (elem, _, fn) {
601
+ return function (e) {
479
602
  var t = e.relatedTarget
480
603
  if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) {
481
604
  delete e.type
@@ -491,7 +614,7 @@ if (!("onmouseenter" in root)) {
491
614
  avalon.each({
492
615
  AnimationEvent: "animationend",
493
616
  WebKitAnimationEvent: "webkitAnimationEnd"
494
- }, function(construct, fixType) {
617
+ }, function (construct, fixType) {
495
618
  if (window[construct] && !eventHooks.animationend) {
496
619
  eventHooks.animationend = {
497
620
  type: fixType
@@ -507,8 +630,8 @@ if (DOC.onmousewheel === void 0) {
507
630
  chrome wheel deltaY 下100 上-100 */
508
631
  eventHooks.mousewheel = {
509
632
  type: "wheel",
510
- deel: function(elem, fn) {
511
- return function(e) {
633
+ deel: function (elem, _, fn) {
634
+ return function (e) {
512
635
  e.wheelDeltaY = e.wheelDelta = e.deltaY > 0 ? -120 : 120
513
636
  e.wheelDeltaX = 0
514
637
  Object.defineProperty(e, "type", {
@@ -546,13 +669,14 @@ function escapeRegExp(target) {
546
669
  //将字符串安全格式化为正则表达式的源码
547
670
  return (target + "").replace(rregexp, "\\$&")
548
671
  }
549
- var innerRequire = noop
672
+
550
673
  var plugins = {
551
- loader: function(builtin) {
552
- window.define = builtin ? innerRequire.define : otherDefine
553
- window.require = builtin ? innerRequire : otherRequire
674
+ loader: function (builtin) {
675
+ var flag = innerRequire && builtin
676
+ window.require = flag ? innerRequire : otherRequire
677
+ window.define = flag ? innerRequire.define : otherDefine
554
678
  },
555
- interpolate: function(array) {
679
+ interpolate: function (array) {
556
680
  openTag = array[0]
557
681
  closeTag = array[1]
558
682
  if (openTag === closeTag) {
@@ -582,11 +706,15 @@ kernel.paths = {}
582
706
  kernel.shim = {}
583
707
  kernel.maxRepeatSize = 100
584
708
  avalon.config = kernel
709
+ var ravalon = /(\w+)\[(avalonctrl)="(\S+)"\]/
710
+ var findNodes = function(str) {
711
+ return DOC.querySelectorAll(str)
712
+ }
585
713
  /*********************************************************************
586
714
  * 事件总线 *
587
715
  **********************************************************************/
588
716
  var EventBus = {
589
- $watch: function(type, callback) {
717
+ $watch: function (type, callback) {
590
718
  if (typeof callback === "function") {
591
719
  var callbacks = this.$events[type]
592
720
  if (callbacks) {
@@ -599,7 +727,7 @@ var EventBus = {
599
727
  }
600
728
  return this
601
729
  },
602
- $unwatch: function(type, callback) {
730
+ $unwatch: function (type, callback) {
603
731
  var n = arguments.length
604
732
  if (n === 0) { //让此VM的所有$watch回调无效化
605
733
  this.$watch.backup = this.$events
@@ -617,13 +745,15 @@ var EventBus = {
617
745
  }
618
746
  return this
619
747
  },
620
- $fire: function(type) {
748
+ $fire: function (type) {
621
749
  var special, i, v, callback
622
750
  if (/^(\w+)!(\S+)$/.test(type)) {
623
751
  special = RegExp.$1
624
752
  type = RegExp.$2
625
753
  }
626
754
  var events = this.$events
755
+ if (!events)
756
+ return
627
757
  var args = aslice.call(arguments, 1)
628
758
  var detail = [type].concat(args)
629
759
  if (special === "all") {
@@ -646,22 +776,23 @@ var EventBus = {
646
776
  continue
647
777
  }
648
778
  //循环两个vmodel中的节点,查找匹配(向上匹配或者向下匹配)的节点并设置标识
649
- Array.prototype.forEach.call(eventNodes, function(node) {
650
- Array.prototype.forEach.call(elements, function(element) {
779
+ /* jshint ignore:start */
780
+ Array.prototype.forEach.call(eventNodes, function (node) {
781
+ Array.prototype.forEach.call(elements, function (element) {
651
782
  var ok = special === "down" ? element.contains(node) : //向下捕获
652
783
  node.contains(element) //向上冒泡
653
-
654
784
  if (ok) {
655
785
  node._avalon = v //符合条件的加一个标识
656
786
  }
657
787
  });
658
788
  })
789
+ /* jshint ignore:end */
659
790
  }
660
791
  }
661
792
  }
662
793
  var nodes = DOC.getElementsByTagName("*") //实现节点排序
663
794
  var alls = []
664
- Array.prototype.forEach.call(nodes, function(el) {
795
+ Array.prototype.forEach.call(nodes, function (el) {
665
796
  if (el._avalon) {
666
797
  alls.push(el._avalon)
667
798
  el._avalon = ""
@@ -691,16 +822,12 @@ var EventBus = {
691
822
  }
692
823
  }
693
824
 
694
- var ravalon = /(\w+)\[(avalonctrl)="(\S+)"\]/
695
- var findNodes = function(str) {
696
- return DOC.querySelectorAll(str)
697
- }
698
825
  /*********************************************************************
699
826
  * modelFactory *
700
827
  **********************************************************************/
701
828
  //avalon最核心的方法的两个方法之一(另一个是avalon.scan),返回一个ViewModel(VM)
702
- var VMODELS = avalon.vmodels = {} //所有vmodel都储存在这里
703
- avalon.define = function(id, factory) {
829
+ var VMODELS = avalon.vmodels = createMap() //所有vmodel都储存在这里
830
+ avalon.define = function (id, factory) {
704
831
  var $id = id.$id || id
705
832
  if (!$id) {
706
833
  log("warning: vm必须指定$id")
@@ -744,7 +871,7 @@ function isObservable(name, value, $skipArray) {
744
871
  return true
745
872
  }
746
873
  //ms-with,ms-each, ms-repeat绑定生成的代理对象储存池
747
- var midway = {}
874
+ var midway = createMap()
748
875
  function getNewValue(accessor, name, value, $vmodel) {
749
876
  switch (accessor.type) {
750
877
  case 0://计算属性
@@ -771,43 +898,29 @@ function getNewValue(accessor, name, value, $vmodel) {
771
898
  }
772
899
  }
773
900
 
774
- var defineProperty = Object.defineProperty
775
- var canHideOwn = true
776
- //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8
777
- //标准浏览器使用__defineGetter__, __defineSetter__实现
778
- try {
779
- defineProperty({}, "_", {
780
- value: "x"
781
- })
782
- var defineProperties = Object.defineProperties
783
- } catch (e) {
784
- canHideOwn = false
785
- }
786
901
  function modelFactory(source, $special, $model) {
787
902
  if (Array.isArray(source)) {
788
903
  var arr = source.concat()
789
904
  source.length = 0
790
- var collection = Collection(source)
905
+ var collection = Collection(source)// jshint ignore:line
791
906
  collection.pushArray(arr)
792
907
  return collection
793
908
  }
794
- if (typeof source.nodeType === "number") {
795
- return source
796
- }
797
- if (source.$id && source.$events) { //fix IE6-8 createWithProxy $val: val引发的BUG
909
+ //0 null undefined || Node || VModel
910
+ if (!source || source.nodeType > 0 || (source.$id && source.$events)) {
798
911
  return source
799
912
  }
800
913
  if (!Array.isArray(source.$skipArray)) {
801
914
  source.$skipArray = []
802
915
  }
803
- source.$skipArray.$special = $special || {} //强制要监听的属性
916
+ source.$skipArray.$special = $special || createMap() //强制要监听的属性
804
917
  var $vmodel = {} //要返回的对象, 它在IE6-8下可能被偷龙转凤
805
918
  $model = $model || {} //vmodels.$model属性
806
- var $events = {} //vmodel.$events属性
807
- var watchedProperties = {} //监控属性
919
+ var $events = createMap() //vmodel.$events属性
920
+ var watchedProperties = createMap() //监控属性
808
921
  var initCallbacks = [] //初始化才执行的函数
809
922
  for (var i in source) {
810
- (function(name, val) {
923
+ (function (name, val) {
811
924
  $model[name] = val
812
925
  if (!isObservable(name, val, source.$skipArray)) {
813
926
  return //过滤所有非监控属性
@@ -815,7 +928,7 @@ function modelFactory(source, $special, $model) {
815
928
  //总共产生三种accessor
816
929
  $events[name] = []
817
930
  var valueType = avalon.type(val)
818
- var accessor = function(newValue) {
931
+ var accessor = function (newValue) {
819
932
  var name = accessor._name
820
933
  var $vmodel = this
821
934
  var $model = $vmodel.$model
@@ -834,19 +947,8 @@ function modelFactory(source, $special, $model) {
834
947
  }
835
948
  if (!isEqual(oldValue, newValue)) {
836
949
  $model[name] = newValue
837
- if ($events.$digest) {
838
- if (!accessor.pedding) {
839
- accessor.pedding = true
840
- setTimeout(function() {
841
- notifySubscribers($events[name]) //同步视图
842
- safeFire($vmodel, name, $model[name], oldValue) //触发$watch回调
843
- accessor.pedding = false
844
- })
845
- }
846
- } else {
847
- notifySubscribers($events[name]) //同步视图
848
- safeFire($vmodel, name, newValue, oldValue) //触发$watch回调
849
- }
950
+ notifySubscribers($events[name]) //同步视图
951
+ safeFire($vmodel, name, newValue, oldValue) //触发$watch回调
850
952
  }
851
953
  } else {
852
954
  if (accessor.type === 0) { //type 0 计算属性 1 监控属性 2 对象属性
@@ -855,17 +957,7 @@ function modelFactory(source, $special, $model) {
855
957
  if (oldValue !== newValue) {
856
958
  $model[name] = newValue
857
959
  //这里不用同步视图
858
- if ($events.$digest) {
859
- if (!accessor.pedding) {
860
- accessor.pedding = true
861
- setTimeout(function() {
862
- safeFire($vmodel, name, $model[name], oldValue) //触发$watch回调
863
- accessor.pedding = false
864
- })
865
- }
866
- } else {
867
- safeFire($vmodel, name, newValue, oldValue) //触发$watch回调
868
- }
960
+ safeFire($vmodel, name, newValue, oldValue) //触发$watch回调
869
961
  }
870
962
  return newValue
871
963
  } else {
@@ -880,11 +972,11 @@ function modelFactory(source, $special, $model) {
880
972
  accessor.set = val.set
881
973
  accessor.get = val.get
882
974
  accessor.type = 0
883
- initCallbacks.push(function() {
975
+ initCallbacks.push(function () {
884
976
  var data = {
885
- evaluator: function() {
977
+ evaluator: function () {
886
978
  data.type = Math.random(),
887
- data.element = null
979
+ data.element = null
888
980
  $model[name] = accessor.get.call($vmodel)
889
981
  },
890
982
  element: head,
@@ -900,7 +992,7 @@ function modelFactory(source, $special, $model) {
900
992
  //第2种为对象属性,产生子VM与监控数组
901
993
  accessor.type = 2
902
994
  accessor.valueType = valueType
903
- initCallbacks.push(function() {
995
+ initCallbacks.push(function () {
904
996
  var svmodel = modelFactory(val, 0, $model[name])
905
997
  accessor.svmodel = svmodel
906
998
  svmodel.$events[subscribers] = $events[name]
@@ -911,15 +1003,15 @@ function modelFactory(source, $special, $model) {
911
1003
  }
912
1004
  accessor._name = name
913
1005
  watchedProperties[name] = accessor
914
- })(i, source[i])
1006
+ })(i, source[i])// jshint ignore:line
915
1007
  }
916
1008
 
917
- $$skipArray.forEach(function(name) {
1009
+ $$skipArray.forEach(function (name) {
918
1010
  delete source[name]
919
1011
  delete $model[name] //这些特殊属性不应该在$model中出现
920
1012
  })
921
1013
 
922
- $vmodel = defineProperties($vmodel, descriptorFactory(watchedProperties), source) //生成一个空的ViewModel
1014
+ $vmodel = Object.defineProperties($vmodel, descriptorFactory(watchedProperties), source) //生成一个空的ViewModel
923
1015
  for (var name in source) {
924
1016
  if (!watchedProperties[name]) {
925
1017
  $vmodel[name] = source[name]
@@ -929,37 +1021,27 @@ function modelFactory(source, $special, $model) {
929
1021
  $vmodel.$id = generateID()
930
1022
  $vmodel.$model = $model
931
1023
  $vmodel.$events = $events
932
- for ( i in EventBus) {
933
- var fn = EventBus[i]
934
- if (!W3C) { //在IE6-8下,VB对象的方法里的this并不指向自身,需要用bind处理一下
935
- fn = fn.bind($vmodel)
936
- }
937
- $vmodel[i] = fn
1024
+ for (i in EventBus) {
1025
+ $vmodel[i] = EventBus[i]
938
1026
  }
939
1027
 
940
- if (canHideOwn) {
941
- Object.defineProperty($vmodel, "hasOwnProperty", {
942
- value: function(name) {
943
- return name in this.$model
944
- },
945
- writable: false,
946
- enumerable: false,
947
- configurable: true
948
- })
1028
+ Object.defineProperty($vmodel, "hasOwnProperty", {
1029
+ value: function (name) {
1030
+ return name in this.$model
1031
+ },
1032
+ writable: false,
1033
+ enumerable: false,
1034
+ configurable: true
1035
+ })
949
1036
 
950
- } else {
951
- $vmodel.hasOwnProperty = function(name) {
952
- return name in $vmodel.$model
953
- }
954
- }
955
- initCallbacks.forEach(function(cb) { //收集依赖
1037
+ initCallbacks.forEach(function (cb) { //收集依赖
956
1038
  cb()
957
1039
  })
958
1040
  return $vmodel
959
1041
  }
960
1042
 
961
1043
  //比较两个值是否相等
962
- var isEqual = Object.is || function(v1, v2) {
1044
+ var isEqual = Object.is || function (v1, v2) {
963
1045
  if (v1 === 0 && v2 === 0) {
964
1046
  return 1 / v1 === 1 / v2
965
1047
  } else if (v1 !== v1) {
@@ -975,8 +1057,8 @@ function safeFire(a, b, c, d) {
975
1057
  }
976
1058
  }
977
1059
 
978
- var descriptorFactory = W3C ? function(obj) {
979
- var descriptors = {}
1060
+ var descriptorFactory = function (obj) {
1061
+ var descriptors = createMap()
980
1062
  for (var i in obj) {
981
1063
  descriptors[i] = {
982
1064
  get: obj[i],
@@ -986,12 +1068,8 @@ var descriptorFactory = W3C ? function(obj) {
986
1068
  }
987
1069
  }
988
1070
  return descriptors
989
- } : function(a) {
990
- return a
991
1071
  }
992
1072
 
993
-
994
-
995
1073
  //应用于第2种accessor
996
1074
  function objectFactory(parent, name, value, valueType) {
997
1075
  //a为原来的VM, b为新数组或新对象
@@ -1014,16 +1092,17 @@ function objectFactory(parent, name, value, valueType) {
1014
1092
  }
1015
1093
  var ret = modelFactory(value)
1016
1094
  ret.$events[subscribers] = iterators
1017
- midway[ret.$id] = function(data) {
1095
+ midway[ret.$id] = function (data) {
1018
1096
  while (data = iterators.shift()) {
1019
- (function(el) {
1020
- avalon.nextTick(function() {
1021
- if (el.type) { //重新绑定
1097
+ (function (el) {
1098
+ avalon.nextTick(function () {
1099
+ var type = el.type
1100
+ if (type && bindingHandlers[type]) { //#753
1022
1101
  el.rollback && el.rollback() //还原 ms-with ms-on
1023
- bindingHandlers[el.type](el, el.vmodels)
1102
+ bindingHandlers[type](el, el.vmodels)
1024
1103
  }
1025
1104
  })
1026
- })(data)
1105
+ })(data)// jshint ignore:line
1027
1106
  }
1028
1107
  delete midway[ret.$id]
1029
1108
  }
@@ -1043,7 +1122,7 @@ function Collection(model) {
1043
1122
  array._ = modelFactory({
1044
1123
  length: model.length
1045
1124
  })
1046
- array._.$watch("length", function(a, b) {
1125
+ array._.$watch("length", function (a, b) {
1047
1126
  array.$fire("length", a, b)
1048
1127
  })
1049
1128
  for (var i in EventBus) {
@@ -1058,13 +1137,15 @@ function mutateArray(method, pos, n, index, method2, pos2, n2) {
1058
1137
  while (--loop) {
1059
1138
  switch (method) {
1060
1139
  case "add":
1061
- var array = this.$model.slice(pos, pos + n).map(function(el) {
1140
+ /* jshint ignore:start */
1141
+ var array = this.$model.slice(pos, pos + n).map(function (el) {
1062
1142
  if (rcomplexType.test(avalon.type(el))) {
1063
1143
  return el.$id ? el : modelFactory(el, 0, el)
1064
1144
  } else {
1065
1145
  return el
1066
1146
  }
1067
1147
  })
1148
+ /* jshint ignore:end */
1068
1149
  _splice.apply(this, [pos, 0].concat(array))
1069
1150
  this._fire("add", pos, n)
1070
1151
  break
@@ -1091,30 +1172,30 @@ function mutateArray(method, pos, n, index, method2, pos2, n2) {
1091
1172
  var _splice = ap.splice
1092
1173
  var CollectionPrototype = {
1093
1174
  _splice: _splice,
1094
- _fire: function(method, a, b) {
1175
+ _fire: function (method, a, b) {
1095
1176
  notifySubscribers(this.$events[subscribers], method, a, b)
1096
1177
  },
1097
- size: function() { //取得数组长度,这个函数可以同步视图,length不能
1178
+ size: function () { //取得数组长度,这个函数可以同步视图,length不能
1098
1179
  return this._.length
1099
1180
  },
1100
- pushArray: function(array) {
1181
+ pushArray: function (array) {
1101
1182
  var m = array.length, n = this.length
1102
1183
  if (m) {
1103
1184
  ap.push.apply(this.$model, array)
1104
- mutateArray.call(this, "add", n, m, n)
1185
+ mutateArray.call(this, "add", n, m, Math.max(0, n - 1))
1105
1186
  }
1106
1187
  return m + n
1107
1188
  },
1108
- push: function() {
1189
+ push: function () {
1109
1190
  //http://jsperf.com/closure-with-arguments
1110
1191
  var array = []
1111
1192
  var i, n = arguments.length
1112
1193
  for (i = 0; i < n; i++) {
1113
1194
  array[i] = arguments[i]
1114
1195
  }
1115
- return this.pushArray(arguments)
1196
+ return this.pushArray(array)
1116
1197
  },
1117
- unshift: function() {
1198
+ unshift: function () {
1118
1199
  var m = arguments.length, n = this.length
1119
1200
  if (m) {
1120
1201
  ap.unshift.apply(this.$model, arguments)
@@ -1122,22 +1203,22 @@ var CollectionPrototype = {
1122
1203
  }
1123
1204
  return m + n //IE67的unshift不会返回长度
1124
1205
  },
1125
- shift: function() {
1206
+ shift: function () {
1126
1207
  if (this.length) {
1127
1208
  var el = this.$model.shift()
1128
1209
  mutateArray.call(this, "del", 0, 1, 0)
1129
1210
  return el //返回被移除的元素
1130
1211
  }
1131
1212
  },
1132
- pop: function() {
1133
- var m = this.length
1134
- if (m) {
1213
+ pop: function () {
1214
+ var n = this.length
1215
+ if (n) {
1135
1216
  var el = this.$model.pop()
1136
- mutateArray.call(this, "del", m - 1, 1, Math.max(0, m - 2))
1217
+ mutateArray.call(this, "del", n - 1, 1, Math.max(0, n - 2))
1137
1218
  return el //返回被移除的元素
1138
1219
  }
1139
1220
  },
1140
- splice: function(start) {
1221
+ splice: function (start) {
1141
1222
  var m = arguments.length, args = [], change
1142
1223
  var removed = _splice.apply(this.$model, arguments)
1143
1224
  if (removed.length) { //如果用户删掉了元素
@@ -1158,27 +1239,27 @@ var CollectionPrototype = {
1158
1239
  return []
1159
1240
  }
1160
1241
  },
1161
- contains: function(el) { //判定是否包含
1242
+ contains: function (el) { //判定是否包含
1162
1243
  return this.indexOf(el) !== -1
1163
1244
  },
1164
- remove: function(el) { //移除第一个等于给定值的元素
1245
+ remove: function (el) { //移除第一个等于给定值的元素
1165
1246
  return this.removeAt(this.indexOf(el))
1166
1247
  },
1167
- removeAt: function(index) { //移除指定索引上的元素
1248
+ removeAt: function (index) { //移除指定索引上的元素
1168
1249
  if (index >= 0) {
1169
1250
  this.$model.splice(index, 1)
1170
1251
  return mutateArray.call(this, "del", index, 1, 0)
1171
1252
  }
1172
1253
  return []
1173
1254
  },
1174
- clear: function() {
1255
+ clear: function () {
1175
1256
  this.$model.length = this.length = this._.length = 0 //清空数组
1176
1257
  this._fire("clear", 0)
1177
1258
  return this
1178
1259
  },
1179
- removeAll: function(all) { //移除N个元素
1260
+ removeAll: function (all) { //移除N个元素
1180
1261
  if (Array.isArray(all)) {
1181
- all.forEach(function(el) {
1262
+ all.forEach(function (el) {
1182
1263
  this.remove(el)
1183
1264
  }, this)
1184
1265
  } else if (typeof all === "function") {
@@ -1192,13 +1273,13 @@ var CollectionPrototype = {
1192
1273
  this.clear()
1193
1274
  }
1194
1275
  },
1195
- ensure: function(el) {
1276
+ ensure: function (el) {
1196
1277
  if (!this.contains(el)) { //只有不存在才push
1197
1278
  this.push(el)
1198
1279
  }
1199
1280
  return this
1200
1281
  },
1201
- set: function(index, val) {
1282
+ set: function (index, val) {
1202
1283
  if (index >= 0) {
1203
1284
  var valueType = avalon.type(val)
1204
1285
  if (val && val.$model) {
@@ -1237,8 +1318,8 @@ function sortByIndex(array, indexes) {
1237
1318
  }
1238
1319
  }
1239
1320
 
1240
- "sort,reverse".replace(rword, function(method) {
1241
- CollectionPrototype[method] = function() {
1321
+ "sort,reverse".replace(rword, function (method) {
1322
+ CollectionPrototype[method] = function () {
1242
1323
  var newArray = this.$model//这是要排序的新数组
1243
1324
  var oldArray = newArray.concat() //保持原来状态的旧数组
1244
1325
  var mask = Math.random()
@@ -1414,7 +1495,7 @@ function notifySubscribers(list) { //通知依赖于这个访问器的订阅者
1414
1495
  * HTML处理(parseHTML, innerHTML, clearHTML) *
1415
1496
  **************************************************************************/
1416
1497
  //parseHTML的辅助变量
1417
- var tagHooks = new function() {
1498
+ var tagHooks = new function() {// jshint ignore:line
1418
1499
  avalon.mix(this, {
1419
1500
  option: DOC.createElement("select"),
1420
1501
  thead: DOC.createElement("table"),
@@ -1429,7 +1510,7 @@ var tagHooks = new function() {
1429
1510
  this.optgroup = this.option
1430
1511
  this.tbody = this.tfoot = this.colgroup = this.caption = this.thead
1431
1512
  this.th = this.td
1432
- }
1513
+ }// jshint ignore:line
1433
1514
 
1434
1515
  String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(rword, function(tag) {
1435
1516
  tagHooks[tag] = tagHooks.g //处理SVG
@@ -1438,16 +1519,20 @@ var rtagName = /<([\w:]+)/
1438
1519
  var rxhtml = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig
1439
1520
  var scriptTypes = oneObject(["", "text/javascript", "text/ecmascript", "application/ecmascript", "application/javascript"])
1440
1521
  var script = DOC.createElement("script")
1441
-
1522
+ var rhtml = /<|&#?\w+;/
1442
1523
  avalon.parseHTML = function(html) {
1524
+ var fragment = hyperspace.cloneNode(false)
1443
1525
  if (typeof html !== "string" ) {
1444
- return DOC.createDocumentFragment()
1526
+ return fragment
1527
+ }
1528
+ if (!rhtml.test(html)) {
1529
+ fragment.appendChild(DOC.createTextNode(html))
1530
+ return fragment
1445
1531
  }
1446
1532
  html = html.replace(rxhtml, "<$1></$2>").trim()
1447
1533
  var tag = (rtagName.exec(html) || ["", ""])[1].toLowerCase(),
1448
1534
  //取得其标签名
1449
1535
  wrapper = tagHooks[tag] || tagHooks._default,
1450
- fragment = hyperspace.cloneNode(false),
1451
1536
  firstChild
1452
1537
  wrapper.innerHTML = html
1453
1538
  var els = wrapper.getElementsByTagName("script")
@@ -1457,7 +1542,7 @@ avalon.parseHTML = function(html) {
1457
1542
  var neo = script.cloneNode(false) //FF不能省略参数
1458
1543
  ap.forEach.call(el.attributes, function(attr) {
1459
1544
  neo.setAttribute(attr.name, attr.value)
1460
- })
1545
+ })// jshint ignore:line
1461
1546
  neo.text = el.text
1462
1547
  el.parentNode.replaceChild(neo, el)
1463
1548
  }
@@ -1579,7 +1664,7 @@ function scanAttr(elem, vmodels) {
1579
1664
  //防止setAttribute, removeAttribute时 attributes自动被同步,导致for循环出错
1580
1665
  var attributes = elem.hasAttributes() ? avalon.slice(elem.attributes) : []
1581
1666
  var bindings = [],
1582
- msData = {},
1667
+ msData = createMap(),
1583
1668
  match
1584
1669
  for (var i = 0, attr; attr = attributes[i++]; ) {
1585
1670
  if (attr.specified) {
@@ -1594,8 +1679,9 @@ function scanAttr(elem, vmodels) {
1594
1679
  param = type
1595
1680
  type = "on"
1596
1681
  } else if (obsoleteAttrs[type]) {
1597
- log("ms-" + type + "已经被废弃,请使用ms-attr-*代替")
1682
+ log("warning!请改用ms-attr-" + type + "代替ms-" + type + "!")
1598
1683
  if (type === "enabled") {//吃掉ms-enabled绑定,用ms-disabled代替
1684
+ log("warning!ms-enabled或ms-attr-enabled已经被废弃")
1599
1685
  type = "disabled"
1600
1686
  value = "!(" + value + ")"
1601
1687
  }
@@ -1619,11 +1705,11 @@ function scanAttr(elem, vmodels) {
1619
1705
  if (type === "html" || type === "text") {
1620
1706
  var token = getToken(value)
1621
1707
  avalon.mix(binding, token)
1622
- binding.filters = binding.filters.replace(rhasHtml, function() {
1708
+ binding.filters = binding.filters.replace(rhasHtml, function () {
1623
1709
  binding.type = "html"
1624
1710
  binding.group = 1
1625
1711
  return ""
1626
- })
1712
+ })// jshint ignore:line
1627
1713
  }
1628
1714
  if (name === "ms-if-loop") {
1629
1715
  binding.priority += 100
@@ -1638,8 +1724,14 @@ function scanAttr(elem, vmodels) {
1638
1724
  }
1639
1725
  }
1640
1726
  }
1641
- if (msData["ms-attr-checked"] && msData["ms-duplex"]) {
1642
- log("warning!一个元素上不能同时定义ms-attr-checked与ms-duplex")
1727
+ var control = elem.type
1728
+ if (control && msData["ms-duplex"]) {
1729
+ if (msData["ms-attr-checked"] && /radio|checkbox/.test(control)) {
1730
+ log("warning!" + control + "控件不能同时定义ms-attr-checked与ms-duplex")
1731
+ }
1732
+ if (msData["ms-attr-value"] && /text|password/.test(control)) {
1733
+ log("warning!" + control + "控件不能同时定义ms-attr-value与ms-duplex")
1734
+ }
1643
1735
  }
1644
1736
  bindings.sort(bindingSorter)
1645
1737
  var scanNode = true
@@ -1712,7 +1804,7 @@ var rhasHtml = /\|\s*html\s*/,
1712
1804
  function getToken(value) {
1713
1805
  if (value.indexOf("|") > 0) {
1714
1806
  var scapegoat = value.replace( rstringLiteral, function(_){
1715
- return Math.pow(10,_.length)
1807
+ return Array(_.length+1).join("1")// jshint ignore:line
1716
1808
  })
1717
1809
  var index = scapegoat.replace(r11a, "\u1122\u3344").indexOf("|") //干掉所有短路或
1718
1810
  if (index > -1) {
@@ -1787,7 +1879,7 @@ function scanText(textNode, vmodels) {
1787
1879
  token.type = "html"
1788
1880
  token.group = 1
1789
1881
  return ""
1790
- })
1882
+ })// jshint ignore:line
1791
1883
  bindings.push(token) //收集带有插值表达式的文本
1792
1884
  }
1793
1885
  hyperspace.appendChild(node)
@@ -1811,17 +1903,17 @@ function camelize(target) {
1811
1903
  if (target.indexOf("-") < 0 && target.indexOf("_") < 0) {
1812
1904
  return target //提前判断,提高getStyle等的效率
1813
1905
  }
1814
- return target.replace(/[-_][^-_]/g, function(match) {
1906
+ return target.replace(/[-_][^-_]/g, function (match) {
1815
1907
  return match.charAt(1).toUpperCase()
1816
1908
  })
1817
1909
  }
1818
1910
 
1819
- "add,remove".replace(rword, function(method) {
1820
- avalon.fn[method + "Class"] = function(cls) {
1911
+ "add,remove".replace(rword, function (method) {
1912
+ avalon.fn[method + "Class"] = function (cls) {
1821
1913
  var el = this[0]
1822
1914
  //https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/26
1823
1915
  if (cls && typeof cls === "string" && el && el.nodeType === 1) {
1824
- cls.replace(/\S+/g, function(c) {
1916
+ cls.replace(/\S+/g, function (c) {
1825
1917
  el.classList[method](c)
1826
1918
  })
1827
1919
  }
@@ -1830,11 +1922,11 @@ function camelize(target) {
1830
1922
  })
1831
1923
 
1832
1924
  avalon.fn.mix({
1833
- hasClass: function(cls) {
1925
+ hasClass: function (cls) {
1834
1926
  var el = this[0] || {} //IE10+, chrome8+, firefox3.6+, safari5.1+,opera11.5+支持classList,chrome24+,firefox26+支持classList2.0
1835
1927
  return el.nodeType === 1 && el.classList.contains(cls)
1836
1928
  },
1837
- toggleClass: function(value, stateVal) {
1929
+ toggleClass: function (value, stateVal) {
1838
1930
  var className, i = 0
1839
1931
  var classNames = value.split(/\s+/)
1840
1932
  var isBool = typeof stateVal === "boolean"
@@ -1844,7 +1936,7 @@ avalon.fn.mix({
1844
1936
  }
1845
1937
  return this
1846
1938
  },
1847
- attr: function(name, value) {
1939
+ attr: function (name, value) {
1848
1940
  if (arguments.length === 2) {
1849
1941
  this[0].setAttribute(name, value)
1850
1942
  return this
@@ -1852,7 +1944,7 @@ avalon.fn.mix({
1852
1944
  return this[0].getAttribute(name)
1853
1945
  }
1854
1946
  },
1855
- data: function(name, value) {
1947
+ data: function (name, value) {
1856
1948
  name = "data-" + hyphen(name || "")
1857
1949
  switch (arguments.length) {
1858
1950
  case 2:
@@ -1863,7 +1955,7 @@ avalon.fn.mix({
1863
1955
  return parseData(val)
1864
1956
  case 0:
1865
1957
  var ret = {}
1866
- ap.forEach.call(this[0].attributes, function(attr) {
1958
+ ap.forEach.call(this[0].attributes, function (attr) {
1867
1959
  if (attr) {
1868
1960
  name = attr.name
1869
1961
  if (!name.indexOf("data-")) {
@@ -1875,12 +1967,12 @@ avalon.fn.mix({
1875
1967
  return ret
1876
1968
  }
1877
1969
  },
1878
- removeData: function(name) {
1970
+ removeData: function (name) {
1879
1971
  name = "data-" + hyphen(name)
1880
1972
  this[0].removeAttribute(name)
1881
1973
  return this
1882
1974
  },
1883
- css: function(name, value) {
1975
+ css: function (name, value) {
1884
1976
  if (avalon.isPlainObject(name)) {
1885
1977
  for (var i in name) {
1886
1978
  avalon.css(this, i, name[i])
@@ -1890,7 +1982,7 @@ avalon.fn.mix({
1890
1982
  }
1891
1983
  return ret !== void 0 ? ret : this
1892
1984
  },
1893
- position: function() {
1985
+ position: function () {
1894
1986
  var offsetParent, offset,
1895
1987
  elem = this[0],
1896
1988
  parentOffset = {
@@ -1916,25 +2008,25 @@ avalon.fn.mix({
1916
2008
  left: offset.left - parentOffset.left - avalon.css(elem, "marginLeft", true)
1917
2009
  }
1918
2010
  },
1919
- offsetParent: function() {
2011
+ offsetParent: function () {
1920
2012
  var offsetParent = this[0].offsetParent
1921
2013
  while (offsetParent && avalon.css(offsetParent, "position") === "static") {
1922
2014
  offsetParent = offsetParent.offsetParent;
1923
2015
  }
1924
- return avalon(offsetParent)
2016
+ return avalon(offsetParent || root)
1925
2017
  },
1926
- bind: function(type, fn, phase) {
2018
+ bind: function (type, fn, phase) {
1927
2019
  if (this[0]) { //此方法不会链
1928
2020
  return avalon.bind(this[0], type, fn, phase)
1929
2021
  }
1930
2022
  },
1931
- unbind: function(type, fn, phase) {
2023
+ unbind: function (type, fn, phase) {
1932
2024
  if (this[0]) {
1933
2025
  avalon.unbind(this[0], type, fn, phase)
1934
2026
  }
1935
2027
  return this
1936
2028
  },
1937
- val: function(value) {
2029
+ val: function (value) {
1938
2030
  var node = this[0]
1939
2031
  if (node && node.nodeType === 1) {
1940
2032
  var get = arguments.length === 0
@@ -1953,7 +2045,7 @@ avalon.fn.mix({
1953
2045
  })
1954
2046
 
1955
2047
  if (root.dataset) {
1956
- avalon.fn.data = function(name, val) {
2048
+ avalon.fn.data = function (name, val) {
1957
2049
  var dataset = this[0].dataset
1958
2050
  switch (arguments.length) {
1959
2051
  case 2:
@@ -1963,8 +2055,8 @@ if (root.dataset) {
1963
2055
  val = dataset[name]
1964
2056
  return parseData(val)
1965
2057
  case 0:
1966
- var ret = {}
1967
- for (var name in dataset) {
2058
+ var ret = createMap()
2059
+ for (name in dataset) {
1968
2060
  ret[name] = parseData(dataset[name])
1969
2061
  }
1970
2062
  return ret
@@ -1988,15 +2080,15 @@ function parseData(data) {
1988
2080
  avalon.each({
1989
2081
  scrollLeft: "pageXOffset",
1990
2082
  scrollTop: "pageYOffset"
1991
- }, function(method, prop) {
1992
- avalon.fn[method] = function(val) {
2083
+ }, function (method, prop) {
2084
+ avalon.fn[method] = function (val) {
1993
2085
  var node = this[0] || {}, win = getWindow(node),
1994
2086
  top = method === "scrollTop"
1995
2087
  if (!arguments.length) {
1996
2088
  return win ? win[prop] : node[method]
1997
2089
  } else {
1998
2090
  if (win) {
1999
- win.scrollTo(!top ? val : avalon(win).scrollLeft(), top ? val : avalon(win).scrollTop())
2091
+ win.scrollTo(!top ? val : win[prop], top ? val : win[prop])
2000
2092
  } else {
2001
2093
  node[method] = val
2002
2094
  }
@@ -2009,14 +2101,14 @@ function getWindow(node) {
2009
2101
  }
2010
2102
 
2011
2103
  //=============================css相关==================================
2012
- var cssHooks = avalon.cssHooks = {}
2104
+ var cssHooks = avalon.cssHooks = createMap()
2013
2105
  var prefixes = ["", "-webkit-", "-moz-", "-ms-"]//去掉opera-15的支持
2014
2106
  var cssMap = {
2015
2107
  "float": "cssFloat"
2016
2108
  }
2017
2109
  avalon.cssNumber = oneObject("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom")
2018
2110
 
2019
- avalon.cssName = function(name, host, camelCase) {
2111
+ avalon.cssName = function (name, host, camelCase) {
2020
2112
  if (cssMap[name]) {
2021
2113
  return cssMap[name]
2022
2114
  }
@@ -2029,15 +2121,15 @@ avalon.cssName = function(name, host, camelCase) {
2029
2121
  }
2030
2122
  return null
2031
2123
  }
2032
- cssHooks["@:set"] = function(node, name, value) {
2124
+ cssHooks["@:set"] = function (node, name, value) {
2033
2125
  node.style[name] = value
2034
2126
  }
2035
2127
 
2036
- cssHooks["@:get"] = function(node, name) {
2128
+ cssHooks["@:get"] = function (node, name) {
2037
2129
  if (!node || !node.style) {
2038
2130
  throw new Error("getComputedStyle要求传入一个节点 " + node)
2039
2131
  }
2040
- var ret, computed = getComputedStyle(node, null)
2132
+ var ret, computed = getComputedStyle(node)
2041
2133
  if (computed) {
2042
2134
  ret = name === "filter" ? computed.getPropertyValue(name) : computed[name]
2043
2135
  if (ret === "") {
@@ -2046,13 +2138,13 @@ cssHooks["@:get"] = function(node, name) {
2046
2138
  }
2047
2139
  return ret
2048
2140
  }
2049
- cssHooks["opacity:get"] = function(node) {
2141
+ cssHooks["opacity:get"] = function (node) {
2050
2142
  var ret = cssHooks["@:get"](node, "opacity")
2051
2143
  return ret === "" ? "1" : ret
2052
2144
  }
2053
2145
 
2054
- "top,left".replace(rword, function(name) {
2055
- cssHooks[name + ":get"] = function(node) {
2146
+ "top,left".replace(rword, function (name) {
2147
+ cssHooks[name + ":get"] = function (node) {
2056
2148
  var computed = cssHooks["@:get"](node, name)
2057
2149
  return /px$/.test(computed) ? computed :
2058
2150
  avalon(node).position()[name] + "px"
@@ -2086,12 +2178,12 @@ function showHidden(node, array) {
2086
2178
  }
2087
2179
  }
2088
2180
 
2089
- "Width,Height".replace(rword, function(name) {//fix 481
2181
+ "Width,Height".replace(rword, function (name) {//fix 481
2090
2182
  var method = name.toLowerCase(),
2091
2183
  clientProp = "client" + name,
2092
2184
  scrollProp = "scroll" + name,
2093
2185
  offsetProp = "offset" + name
2094
- cssHooks[method + ":get"] = function(node, which, override) {
2186
+ cssHooks[method + ":get"] = function (node, which, override) {
2095
2187
  var boxSizing = -4
2096
2188
  if (typeof override === "number") {
2097
2189
  boxSizing = override
@@ -2099,23 +2191,17 @@ function showHidden(node, array) {
2099
2191
  which = name === "Width" ? ["Left", "Right"] : ["Top", "Bottom"]
2100
2192
  var ret = node[offsetProp] // border-box 0
2101
2193
  if (boxSizing === 2) { // margin-box 2
2102
- return ret
2103
- + avalon.css(node, "margin" + which[0], true)
2104
- + avalon.css(node, "margin" + which[1], true)
2194
+ return ret + avalon.css(node, "margin" + which[0], true) + avalon.css(node, "margin" + which[1], true)
2105
2195
  }
2106
2196
  if (boxSizing < 0) { // padding-box -2
2107
- ret = ret
2108
- - avalon.css(node, "border" + which[0] + "Width", true)
2109
- - avalon.css(node, "border" + which[1] + "Width", true)
2197
+ ret = ret - avalon.css(node, "border" + which[0] + "Width", true) - avalon.css(node, "border" + which[1] + "Width", true)
2110
2198
  }
2111
2199
  if (boxSizing === -4) { // content-box -4
2112
- ret = ret
2113
- - avalon.css(node, "padding" + which[0], true)
2114
- - avalon.css(node, "padding" + which[1], true)
2200
+ ret = ret - avalon.css(node, "padding" + which[0], true) - avalon.css(node, "padding" + which[1], true)
2115
2201
  }
2116
2202
  return ret
2117
2203
  }
2118
- cssHooks[method + "&get"] = function(node) {
2204
+ cssHooks[method + "&get"] = function (node) {
2119
2205
  var hidden = [];
2120
2206
  showHidden(node, hidden);
2121
2207
  var val = cssHooks[method + ":get"](node)
@@ -2129,11 +2215,11 @@ function showHidden(node, array) {
2129
2215
  }
2130
2216
  return val;
2131
2217
  }
2132
- avalon.fn[method] = function(value) { //会忽视其display
2218
+ avalon.fn[method] = function (value) { //会忽视其display
2133
2219
  var node = this[0]
2134
2220
  if (arguments.length === 0) {
2135
2221
  if (node.setTimeout) { //取得窗口尺寸,IE9后可以用node.innerWidth /innerHeight代替
2136
- return node["inner" + name]
2222
+ return node["inner" + name]
2137
2223
  }
2138
2224
  if (node.nodeType === 9) { //取得页面尺寸
2139
2225
  var doc = node.documentElement
@@ -2147,33 +2233,33 @@ function showHidden(node, array) {
2147
2233
  return this.css(method, value)
2148
2234
  }
2149
2235
  }
2150
- avalon.fn["inner" + name] = function() {
2236
+ avalon.fn["inner" + name] = function () {
2151
2237
  return cssHooks[method + ":get"](this[0], void 0, -2)
2152
2238
  }
2153
- avalon.fn["outer" + name] = function(includeMargin) {
2239
+ avalon.fn["outer" + name] = function (includeMargin) {
2154
2240
  return cssHooks[method + ":get"](this[0], void 0, includeMargin === true ? 2 : 0)
2155
2241
  }
2156
2242
  })
2157
- avalon.fn.offset = function() { //取得距离页面左右角的坐标
2158
- var node = this[0], box = {
2159
- left: 0,
2160
- top: 0
2161
- }
2162
- if (!node || !node.tagName || !node.ownerDocument) {
2163
- return box
2164
- }
2165
- var doc = node.ownerDocument,
2166
- root = doc.documentElement,
2167
- win = doc.defaultView
2168
- if (!root.contains(node)) {
2169
- return box
2170
- }
2171
- if (node.getBoundingClientRect !== void 0) {
2172
- box = node.getBoundingClientRect()
2173
- }
2174
- return {
2175
- top: box.top + win.pageYOffset - root.clientTop,
2176
- left: box.left + win.pageXOffset - root.clientLeft
2243
+ avalon.fn.offset = function () { //取得距离页面左右角的坐标
2244
+ var node = this[0]
2245
+ try {
2246
+ var rect = node.getBoundingClientRect()
2247
+ // Make sure element is not hidden (display: none) or disconnected
2248
+ // https://github.com/jquery/jquery/pull/2043/files#r23981494
2249
+ if (rect.width || rect.height || node.getClientRects().length) {
2250
+ var doc = node.ownerDocument
2251
+ var root = doc.documentElement
2252
+ var win = doc.defaultView
2253
+ return {
2254
+ top: rect.top + win.pageYOffset - root.clientTop,
2255
+ left: rect.left + win.pageXOffset - root.clientLeft
2256
+ }
2257
+ }
2258
+ } catch (e) {
2259
+ return {
2260
+ left: 0,
2261
+ top: 0
2262
+ }
2177
2263
  }
2178
2264
  }
2179
2265
  //=============================val相关=======================
@@ -2183,7 +2269,7 @@ function getValType(el) {
2183
2269
  return ret === "input" && /checkbox|radio/.test(el.type) ? "checked" : ret
2184
2270
  }
2185
2271
  var valHooks = {
2186
- "select:get": function(node, value) {
2272
+ "select:get": function (node, value) {
2187
2273
  var option, options = node.options,
2188
2274
  index = node.selectedIndex,
2189
2275
  one = node.type === "select-one" || index < 0,
@@ -2206,7 +2292,7 @@ var valHooks = {
2206
2292
  }
2207
2293
  return values
2208
2294
  },
2209
- "select:set": function(node, values, optionSet) {
2295
+ "select:set": function (node, values, optionSet) {
2210
2296
  values = [].concat(values) //强制转换为数组
2211
2297
  for (var i = 0, el; el = node.options[i++]; ) {
2212
2298
  if ((el.selected = values.indexOf(el.value) > -1)) {
@@ -2224,28 +2310,26 @@ var valHooks = {
2224
2310
  **********************************************************************/
2225
2311
  var quote = JSON.stringify
2226
2312
 
2227
- var keywords =
2228
- // 关键字
2229
- "break,case,catch,continue,debugger,default,delete,do,else,false" +
2230
- ",finally,for,function,if,in,instanceof,new,null,return,switch,this" +
2231
- ",throw,true,try,typeof,var,void,while,with" +
2232
- // 保留字
2233
- ",abstract,boolean,byte,char,class,const,double,enum,export,extends" +
2234
- ",final,float,goto,implements,import,int,interface,long,native" +
2235
- ",package,private,protected,public,short,static,super,synchronized" +
2236
- ",throws,transient,volatile" +
2237
- // ECMA 5 - use strict
2238
- ",arguments,let,yield" + ",undefined"
2313
+ var keywords = [
2314
+ "break,case,catch,continue,debugger,default,delete,do,else,false",
2315
+ "finally,for,function,if,in,instanceof,new,null,return,switch,this",
2316
+ "throw,true,try,typeof,var,void,while,with", /* 关键字*/
2317
+ "abstract,boolean,byte,char,class,const,double,enum,export,extends",
2318
+ "final,float,goto,implements,import,int,interface,long,native",
2319
+ "package,private,protected,public,short,static,super,synchronized",
2320
+ "throws,transient,volatile", /*保留字*/
2321
+ "arguments,let,yield,undefined" /* ECMA 5 - use strict*/].join(",")
2239
2322
  var rrexpstr = /\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g
2240
2323
  var rsplit = /[^\w$]+/g
2241
2324
  var rkeywords = new RegExp(["\\b" + keywords.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g')
2242
2325
  var rnumber = /\b\d[^,]*/g
2243
2326
  var rcomma = /^,+|,+$/g
2244
- var cacheVars = createCache(512)
2245
- var getVariables = function(code) {
2327
+ var cacheVars = new Cache(512)
2328
+ var getVariables = function (code) {
2246
2329
  var key = "," + code.trim()
2247
- if (cacheVars[key]) {
2248
- return cacheVars[key]
2330
+ var ret = cacheVars.get(key)
2331
+ if (ret) {
2332
+ return ret
2249
2333
  }
2250
2334
  var match = code
2251
2335
  .replace(rrexpstr, "")
@@ -2254,7 +2338,7 @@ var getVariables = function(code) {
2254
2338
  .replace(rnumber, "")
2255
2339
  .replace(rcomma, "")
2256
2340
  .split(/^$|,+/)
2257
- return cacheVars(key, uniqSet(match))
2341
+ return cacheVars.put(key, uniqSet(match))
2258
2342
  }
2259
2343
  /*添加赋值语句*/
2260
2344
 
@@ -2287,7 +2371,7 @@ function uniqSet(array) {
2287
2371
  return ret
2288
2372
  }
2289
2373
  //缓存求值函数,以便多次利用
2290
- var cacheExprs = createCache(128)
2374
+ var cacheExprs = new Cache(128)
2291
2375
  //取得求值函数及其传参
2292
2376
  var rduplex = /\w\[.*\]|\w\.\w/
2293
2377
  var rproxy = /(\$proxy\$[a-z]+)\d+$/
@@ -2299,16 +2383,16 @@ var rthimLeftParentheses = /"\s*\(/g
2299
2383
  function parseFilter(val, filters) {
2300
2384
  filters = filters
2301
2385
  .replace(rthimRightParentheses, "")//处理最后的小括号
2302
- .replace(rthimOtherParentheses, function() {//处理其他小括号
2386
+ .replace(rthimOtherParentheses, function () {//处理其他小括号
2303
2387
  return "],|"
2304
2388
  })
2305
- .replace(rquoteFilterName, function(a, b) { //处理|及它后面的过滤器的名字
2389
+ .replace(rquoteFilterName, function (a, b) { //处理|及它后面的过滤器的名字
2306
2390
  return "[" + quote(b)
2307
2391
  })
2308
- .replace(rpatchBracket, function() {
2392
+ .replace(rpatchBracket, function () {
2309
2393
  return '"],["'
2310
2394
  })
2311
- .replace(rthimLeftParentheses, function() {
2395
+ .replace(rthimLeftParentheses, function () {
2312
2396
  return '",'
2313
2397
  }) + "]"
2314
2398
  return "return avalon.filters.$filter(" + val + ", " + filters + ")"
@@ -2317,7 +2401,7 @@ function parseFilter(val, filters) {
2317
2401
  function parseExpr(code, scopes, data) {
2318
2402
  var dataType = data.type
2319
2403
  var filters = data.filters || ""
2320
- var exprId = scopes.map(function(el) {
2404
+ var exprId = scopes.map(function (el) {
2321
2405
  return String(el.$id).replace(rproxy, "$1")
2322
2406
  }) + code + dataType + filters
2323
2407
  var vars = getVariables(code).concat(),
@@ -2341,9 +2425,9 @@ function parseExpr(code, scopes, data) {
2341
2425
  }
2342
2426
  if (dataType !== "duplex" && (code.indexOf("||") > -1 || code.indexOf("&&") > -1)) {
2343
2427
  //https://github.com/RubyLouvre/avalon/issues/583
2344
- data.vars.forEach(function(v) {
2428
+ data.vars.forEach(function (v) {
2345
2429
  var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig")
2346
- code = code.replace(reg, function(_) {
2430
+ code = code.replace(reg, function (_) {
2347
2431
  var c = _.charAt(v.length)
2348
2432
  var r = IEVersion ? code.slice(arguments[1] + _.length) : RegExp.rightContext
2349
2433
  var method = /^\s*\(/.test(r)
@@ -2370,7 +2454,7 @@ function parseExpr(code, scopes, data) {
2370
2454
  //---------------args----------------
2371
2455
  data.args = args
2372
2456
  //---------------cache----------------
2373
- var fn = cacheExprs[exprId] //直接从缓存,免得重复生成
2457
+ var fn = cacheExprs.get(exprId) //直接从缓存,免得重复生成
2374
2458
  if (fn) {
2375
2459
  data.evaluator = fn
2376
2460
  return
@@ -2394,7 +2478,7 @@ function parseExpr(code, scopes, data) {
2394
2478
  "= vvv;\n} "
2395
2479
  try {
2396
2480
  fn = Function.apply(noop, names.concat(_body))
2397
- data.evaluator = cacheExprs(exprId, fn)
2481
+ data.evaluator = cacheExprs.put(exprId, fn)
2398
2482
  } catch (e) {
2399
2483
  log("debug: parse error," + e.message)
2400
2484
  }
@@ -2416,11 +2500,11 @@ function parseExpr(code, scopes, data) {
2416
2500
  }
2417
2501
  try {
2418
2502
  fn = Function.apply(noop, names.concat("'use strict';\n" + prefix + code))
2419
- data.evaluator = cacheExprs(exprId, fn)
2503
+ data.evaluator = cacheExprs.put(exprId, fn)
2420
2504
  } catch (e) {
2421
2505
  log("debug: parse error," + e.message)
2422
2506
  } finally {
2423
- vars = textBuffer = names = null //释放内存
2507
+ vars = assigns = names = null //释放内存
2424
2508
  }
2425
2509
  }
2426
2510
 
@@ -2429,7 +2513,7 @@ function parseExpr(code, scopes, data) {
2429
2513
 
2430
2514
  function parseExprProxy(code, scopes, data, tokens, noregister) {
2431
2515
  if (Array.isArray(tokens)) {
2432
- code = tokens.map(function(el) {
2516
+ code = tokens.map(function (el) {
2433
2517
  return el.expr ? "(" + el.value + ")" : quote(el.value)
2434
2518
  }).join(" + ")
2435
2519
  }
@@ -2443,10 +2527,12 @@ function parseExprProxy(code, scopes, data, tokens, noregister) {
2443
2527
  }
2444
2528
  }
2445
2529
  avalon.parseExprProxy = parseExprProxy
2446
- var bools = "autofocus,autoplay,async,allowTransparency,checked,controls,declare,disabled,defer,defaultChecked,defaultSelected" +
2447
- "contentEditable,isMap,loop,multiple,noHref,noResize,noShade,open,readOnly,selected"
2530
+ var bools = ["autofocus,autoplay,async,allowTransparency,checked,controls",
2531
+ "declare,disabled,defer,defaultChecked,defaultSelected",
2532
+ "contentEditable,isMap,loop,multiple,noHref,noResize,noShade",
2533
+ "open,readOnly,selected"].join(",")
2448
2534
  var boolMap = {}
2449
- bools.replace(rword, function(name) {
2535
+ bools.replace(rword, function (name) {
2450
2536
  boolMap[name.toLowerCase()] = name
2451
2537
  })
2452
2538
 
@@ -2459,21 +2545,23 @@ var propMap = {//属性名映射
2459
2545
  "http-equiv": "httpEquiv"
2460
2546
  }
2461
2547
 
2462
- var anomaly = "accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan," + "dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight," + "rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"
2463
- anomaly.replace(rword, function(name) {
2548
+ var anomaly = ["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan",
2549
+ "dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight",
2550
+ "rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",")
2551
+ anomaly.replace(rword, function (name) {
2464
2552
  propMap[name.toLowerCase()] = name
2465
2553
  })
2466
2554
 
2467
2555
  var rnoscripts = /<noscript.*?>(?:[\s\S]+?)<\/noscript>/img
2468
2556
  var rnoscriptText = /<noscript.*?>([\s\S]+?)<\/noscript>/im
2469
2557
 
2470
- var getXHR = function() {
2471
- return new (window.XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP")
2558
+ var getXHR = function () {
2559
+ return new (window.XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP")// jshint ignore:line
2472
2560
  }
2473
2561
 
2474
2562
  var cacheTmpls = avalon.templateCache = {}
2475
2563
 
2476
- bindingHandlers.attr = function(data, vmodels) {
2564
+ bindingHandlers.attr = function (data, vmodels) {
2477
2565
  var text = data.value.trim(),
2478
2566
  simple = true
2479
2567
  if (text.indexOf(openTag) > -1 && text.indexOf(closeTag) > 2) {
@@ -2487,7 +2575,10 @@ bindingHandlers.attr = function(data, vmodels) {
2487
2575
  var elem = data.element
2488
2576
  data.includeRendered = getBindingCallback(elem, "data-include-rendered", vmodels)
2489
2577
  data.includeLoaded = getBindingCallback(elem, "data-include-loaded", vmodels)
2490
- var outer = data.includeReplaced = !!avalon(elem).data("includeReplace")
2578
+ var outer = data.includeReplace = !!avalon(elem).data("includeReplace")
2579
+ if (avalon(elem).data("includeCache")) {
2580
+ data.templateCache = {}
2581
+ }
2491
2582
  data.startInclude = DOC.createComment("ms-include")
2492
2583
  data.endInclude = DOC.createComment("ms-include-end")
2493
2584
  if (outer) {
@@ -2503,7 +2594,7 @@ bindingHandlers.attr = function(data, vmodels) {
2503
2594
  parseExprProxy(text, vmodels, data, (simple ? 0 : scanExpr(data.value)))
2504
2595
  }
2505
2596
 
2506
- bindingExecutors.attr = function(val, elem, data) {
2597
+ bindingExecutors.attr = function (val, elem, data) {
2507
2598
  var method = data.type,
2508
2599
  attrName = data.param
2509
2600
  if (method === "css") {
@@ -2538,38 +2629,50 @@ bindingExecutors.attr = function(val, elem, data) {
2538
2629
  var vmodels = data.vmodels
2539
2630
  var rendered = data.includeRendered
2540
2631
  var loaded = data.includeLoaded
2541
- var replace = data.includeReplaced
2632
+ var replace = data.includeReplace
2542
2633
  var target = replace ? elem.parentNode : elem
2543
- var scanTemplate = function(text) {
2634
+ var scanTemplate = function (text) {
2544
2635
  if (loaded) {
2545
2636
  text = loaded.apply(target, [text].concat(vmodels))
2546
2637
  }
2547
2638
  if (rendered) {
2548
- checkScan(target, function() {
2639
+ checkScan(target, function () {
2549
2640
  rendered.call(target)
2550
2641
  }, NaN)
2551
2642
  }
2643
+ var lastID = data.includeLastID
2644
+ if (data.templateCache && lastID && lastID !== val) {
2645
+ var lastTemplate = data.templateCache[lastID]
2646
+ if (!lastTemplate) {
2647
+ lastTemplate = data.templateCache[lastID] = DOC.createElement("div")
2648
+ ifGroup.appendChild(lastTemplate)
2649
+ }
2650
+ }
2651
+ data.includeLastID = val
2552
2652
  while (true) {
2553
2653
  var node = data.startInclude.nextSibling
2554
2654
  if (node && node !== data.endInclude) {
2555
2655
  target.removeChild(node)
2656
+ if (lastTemplate)
2657
+ lastTemplate.appendChild(node)
2556
2658
  } else {
2557
2659
  break
2558
2660
  }
2559
2661
  }
2560
- var dom = avalon.parseHTML(text)
2662
+ var dom = getTemplateNodes(data, val, text)
2561
2663
  var nodes = avalon.slice(dom.childNodes)
2562
2664
  target.insertBefore(dom, data.endInclude)
2563
2665
  scanNodeArray(nodes, vmodels)
2564
2666
  }
2667
+
2565
2668
  if (data.param === "src") {
2566
2669
  if (cacheTmpls[val]) {
2567
- avalon.nextTick(function() {
2670
+ avalon.nextTick(function () {
2568
2671
  scanTemplate(cacheTmpls[val])
2569
2672
  })
2570
2673
  } else {
2571
2674
  var xhr = getXHR()
2572
- xhr.onreadystatechange = function() {
2675
+ xhr.onreadystatechange = function () {
2573
2676
  if (xhr.readyState === 4) {
2574
2677
  var s = xhr.status
2575
2678
  if (s >= 200 && s < 300 || s === 304 || s === 1223) {
@@ -2605,7 +2708,7 @@ bindingExecutors.attr = function(val, elem, data) {
2605
2708
  }
2606
2709
  }
2607
2710
  }
2608
- avalon.nextTick(function() {
2711
+ avalon.nextTick(function () {
2609
2712
  scanTemplate(el.fixIE78 || el.value || el.innerText || el.innerHTML)
2610
2713
  })
2611
2714
  }
@@ -2624,8 +2727,20 @@ bindingExecutors.attr = function(val, elem, data) {
2624
2727
  }
2625
2728
  }
2626
2729
 
2730
+ function getTemplateNodes(data, id, text) {
2731
+ var div = data.templateCache && data.templateCache[id]
2732
+ if (div) {
2733
+ var dom = DOC.createDocumentFragment(), firstChild
2734
+ while (firstChild = div.firstChild) {
2735
+ dom.appendChild(firstChild)
2736
+ }
2737
+ return dom
2738
+ }
2739
+ return avalon.parseHTML(text)
2740
+ }
2741
+
2627
2742
  //这几个指令都可以使用插值表达式,如ms-src="aaa/{{b}}/{{c}}.html"
2628
- "title,alt,src,value,css,include,href".replace(rword, function(name) {
2743
+ "title,alt,src,value,css,include,href".replace(rword, function (name) {
2629
2744
  bindingHandlers[name] = bindingHandlers.attr
2630
2745
  })
2631
2746
  //根据VM的属性值或表达式的值切换类名,ms-class="xxx yyy zzz:flag"
@@ -2733,7 +2848,7 @@ bindingExecutors.data = function(val, elem, data) {
2733
2848
  }
2734
2849
 
2735
2850
  //双工绑定
2736
- var duplexBinding = bindingHandlers.duplex = function(data, vmodels) {
2851
+ var duplexBinding = bindingHandlers.duplex = function (data, vmodels) {
2737
2852
  var elem = data.element,
2738
2853
  hasCast
2739
2854
  parseExprProxy(data.value, vmodels, data, 0, 1)
@@ -2748,7 +2863,7 @@ var duplexBinding = bindingHandlers.duplex = function(data, vmodels) {
2748
2863
  if (elem.msData) {
2749
2864
  elem.msData["ms-duplex"] = data.value
2750
2865
  }
2751
- data.param.replace(/\w+/g, function(name) {
2866
+ data.param.replace(/\w+/g, function (name) {
2752
2867
  if (/^(checkbox|radio)$/.test(elem.type) && /^(radio|checked)$/.test(name)) {
2753
2868
  if (name === "radio")
2754
2869
  log("ms-duplex-radio已经更名为ms-duplex-checked")
@@ -2771,14 +2886,14 @@ var duplexBinding = bindingHandlers.duplex = function(data, vmodels) {
2771
2886
  params.push("string")
2772
2887
  }
2773
2888
  data.param = params.join("-")
2774
- data.bound = function(type, callback) {
2889
+ data.bound = function (type, callback) {
2775
2890
  if (elem.addEventListener) {
2776
2891
  elem.addEventListener(type, callback, false)
2777
2892
  } else {
2778
2893
  elem.attachEvent("on" + type, callback)
2779
2894
  }
2780
2895
  var old = data.rollback
2781
- data.rollback = function() {
2896
+ data.rollback = function () {
2782
2897
  elem.avalonSetter = null
2783
2898
  avalon.unbind(elem, type, callback)
2784
2899
  old && old()
@@ -2800,32 +2915,44 @@ function fixNull(val) {
2800
2915
  }
2801
2916
  avalon.duplexHooks = {
2802
2917
  checked: {
2803
- get: function(val, data) {
2918
+ get: function (val, data) {
2804
2919
  return !data.element.oldValue
2805
2920
  }
2806
2921
  },
2807
2922
  string: {
2808
- get: function(val) { //同步到VM
2923
+ get: function (val) { //同步到VM
2809
2924
  return val
2810
2925
  },
2811
2926
  set: fixNull
2812
2927
  },
2813
2928
  "boolean": {
2814
- get: function(val) {
2929
+ get: function (val) {
2815
2930
  return val === "true"
2816
2931
  },
2817
2932
  set: fixNull
2818
2933
  },
2819
2934
  number: {
2820
- get: function(val) {
2821
- return isFinite(val) ? parseFloat(val) || 0 : val
2935
+ get: function (val, data) {
2936
+ var number = parseFloat(val)
2937
+ if (-val === -number) {
2938
+ return number
2939
+ }
2940
+ var arr = /strong|medium|weak/.exec(data.element.getAttribute("data-duplex-number")) || ["medium"]
2941
+ switch (arr[0]) {
2942
+ case "strong":
2943
+ return 0
2944
+ case "medium":
2945
+ return val === "" ? "" : 0
2946
+ case "weak":
2947
+ return val
2948
+ }
2822
2949
  },
2823
2950
  set: fixNull
2824
2951
  }
2825
2952
  }
2826
2953
 
2827
2954
  function pipe(val, data, action, e) {
2828
- data.param.replace(/\w+/g, function(name) {
2955
+ data.param.replace(/\w+/g, function (name) {
2829
2956
  var hook = avalon.duplexHooks[name]
2830
2957
  if (hook && typeof hook[action] === "function") {
2831
2958
  val = hook[action](val, data)
@@ -2835,18 +2962,8 @@ function pipe(val, data, action, e) {
2835
2962
  }
2836
2963
 
2837
2964
  var TimerID, ribbon = []
2838
- function W3CFire(el, name, detail) {
2839
- var event = DOC.createEvent("Events")
2840
- event.initEvent(name, true, true)
2841
- event.fireByAvalon = true//签名,标记事件是由avalon触发
2842
- //event.isTrusted = false 设置这个opera会报错
2843
- if (detail)
2844
- event.detail = detail
2845
- el.dispatchEvent(event)
2846
- }
2847
-
2848
2965
 
2849
- avalon.tick = function(fn) {
2966
+ avalon.tick = function (fn) {
2850
2967
  if (ribbon.push(fn) === 1) {
2851
2968
  TimerID = setInterval(ticker, 60)
2852
2969
  }
@@ -2865,15 +2982,18 @@ function ticker() {
2865
2982
  }
2866
2983
 
2867
2984
  var watchValueInTimer = noop
2868
- new function() {
2985
+ var rmsinput = /text|password|hidden/
2986
+ new function () {// jshint ignore:line
2869
2987
  try {//#272 IE9-IE11, firefox
2870
2988
  var setters = {}
2871
2989
  var aproto = HTMLInputElement.prototype
2872
2990
  var bproto = HTMLTextAreaElement.prototype
2873
- function newSetter(value) {
2991
+ function newSetter(value) {// jshint ignore:line
2874
2992
  if (avalon.contains(root, this)) {
2875
2993
  setters[this.tagName].call(this, value)
2876
- if (this.avalonSetter) {
2994
+ if (!rmsinput.test(this.type))
2995
+ return
2996
+ if (!this.msFocus && this.avalonSetter) {
2877
2997
  this.avalonSetter()
2878
2998
  }
2879
2999
  }
@@ -2891,12 +3011,12 @@ new function() {
2891
3011
  } catch (e) {
2892
3012
  watchValueInTimer = avalon.tick
2893
3013
  }
2894
- }
3014
+ }// jshint ignore:line
2895
3015
 
2896
3016
 
2897
3017
  //处理radio, checkbox, text, textarea, password
2898
- duplexBinding.INPUT = function(element, evaluator, data) {
2899
- var type = element.type,
3018
+ duplexBinding.INPUT = function (element, evaluator, data) {
3019
+ var $type = element.type,
2900
3020
  bound = data.bound,
2901
3021
  $elem = avalon(element),
2902
3022
  composing = false
@@ -2910,7 +3030,8 @@ duplexBinding.INPUT = function(element, evaluator, data) {
2910
3030
  composing = false
2911
3031
  }
2912
3032
  //当value变化时改变model的值
2913
- function updateVModel() {
3033
+
3034
+ var updateVModel = function () {
2914
3035
  if (composing)//处理中文输入法在minlengh下引发的BUG
2915
3036
  return
2916
3037
  var val = element.oldValue = element.value //防止递归调用形成死循环
@@ -2919,35 +3040,35 @@ duplexBinding.INPUT = function(element, evaluator, data) {
2919
3040
  evaluator(lastValue)
2920
3041
  callback.call(element, lastValue)
2921
3042
  if ($elem.data("duplex-focus")) {
2922
- avalon.nextTick(function() {
3043
+ avalon.nextTick(function () {
2923
3044
  element.focus()
2924
3045
  })
2925
3046
  }
2926
3047
  }
2927
3048
  }
2928
3049
  //当model变化时,它就会改变value的值
2929
- data.handler = function() {
3050
+ data.handler = function () {
2930
3051
  var val = data.pipe(evaluator(), data, "set") + ""
2931
3052
  if (val !== element.oldValue) {
2932
3053
  element.value = val
2933
3054
  }
2934
3055
  }
2935
- if (data.isChecked || element.type === "radio") {
2936
- updateVModel = function() {
3056
+ if (data.isChecked || $type === "radio") {
3057
+ updateVModel = function () {
2937
3058
  if ($elem.data("duplex-observe") !== false) {
2938
3059
  var lastValue = data.pipe(element.value, data, "get")
2939
3060
  evaluator(lastValue)
2940
3061
  callback.call(element, lastValue)
2941
3062
  }
2942
3063
  }
2943
- data.handler = function() {
3064
+ data.handler = function () {
2944
3065
  var val = evaluator()
2945
3066
  var checked = data.isChecked ? !!val : val + "" === element.value
2946
3067
  element.checked = element.oldValue = checked
2947
3068
  }
2948
3069
  bound("click", updateVModel)
2949
- } else if (type === "checkbox") {
2950
- updateVModel = function() {
3070
+ } else if ($type === "checkbox") {
3071
+ updateVModel = function () {
2951
3072
  if ($elem.data("duplex-observe") !== false) {
2952
3073
  var method = element.checked ? "ensure" : "remove"
2953
3074
  var array = evaluator()
@@ -2959,17 +3080,17 @@ duplexBinding.INPUT = function(element, evaluator, data) {
2959
3080
  callback.call(element, array)
2960
3081
  }
2961
3082
  }
2962
- data.handler = function() {
3083
+ data.handler = function () {
2963
3084
  var array = [].concat(evaluator()) //强制转换为数组
2964
3085
  element.checked = array.indexOf(data.pipe(element.value, data, "get")) > -1
2965
3086
  }
2966
3087
  bound("change", updateVModel)
2967
3088
  } else {
2968
- var events = element.getAttribute("data-duplex-event") || element.getAttribute("data-event") || "input"
3089
+ var events = element.getAttribute("data-duplex-event") || "input"
2969
3090
  if (element.attributes["data-event"]) {
2970
3091
  log("data-event指令已经废弃,请改用data-duplex-event")
2971
3092
  }
2972
- events.replace(rword, function(name) {
3093
+ events.replace(rword, function (name) {
2973
3094
  switch (name) {
2974
3095
  case "input":
2975
3096
  bound("input", updateVModel)
@@ -2984,21 +3105,27 @@ duplexBinding.INPUT = function(element, evaluator, data) {
2984
3105
  break
2985
3106
  }
2986
3107
  })
2987
- }
2988
-
2989
- if (/text|password/.test(element.type)) {
2990
- watchValueInTimer(function() {
2991
- if (root.contains(element)) {
2992
- if (element.value !== element.oldValue) {
2993
- updateVModel()
2994
- }
2995
- } else if (!element.msRetain) {
2996
- return false
2997
- }
3108
+ bound("focus", function () {
3109
+ element.msFocus = true
3110
+ })
3111
+ bound("blur", function () {
3112
+ element.msFocus = false
2998
3113
  })
3114
+ if (rmsinput.test($type)) {
3115
+ watchValueInTimer(function () {
3116
+ if (root.contains(element)) {
3117
+ if (!element.msFocus && element.oldValue !== element.value) {
3118
+ updateVModel()
3119
+ }
3120
+ } else if (!element.msRetain) {
3121
+ return false
3122
+ }
3123
+ })
3124
+ }
3125
+
3126
+ element.avalonSetter = updateVModel
2999
3127
  }
3000
3128
 
3001
- element.avalonSetter = updateVModel
3002
3129
  element.oldValue = element.value
3003
3130
  registerSubscriber(data)
3004
3131
  callback.call(element, element.value)
@@ -3188,11 +3315,10 @@ bindingHandlers.repeat = function(data, vmodels) {
3188
3315
  var xtype = avalon.type($repeat)
3189
3316
  if (xtype !== "object" && xtype !== "array") {
3190
3317
  freturn = true
3191
- avalon.log("warning:" + data.value + "对应类型不正确")
3318
+ avalon.log("warning:" + data.value + "只能是对象或数组")
3192
3319
  }
3193
3320
  } catch (e) {
3194
3321
  freturn = true
3195
- avalon.log("warning:" + data.value + "编译出错")
3196
3322
  }
3197
3323
 
3198
3324
  var arr = data.value.split(".") || []
@@ -3534,7 +3660,7 @@ function recycleProxies(proxies, type) {
3534
3660
  proxy.$events[i].forEach(function(data) {
3535
3661
  if (typeof data === "object")
3536
3662
  disposeData(data)
3537
- })
3663
+ })// jshint ignore:line
3538
3664
  proxy.$events[i].length = 0
3539
3665
  }
3540
3666
  }
@@ -3693,18 +3819,18 @@ var rsanitize = {
3693
3819
  var rsurrogate = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g
3694
3820
  var rnoalphanumeric = /([^\#-~| |!])/g;
3695
3821
 
3696
- function numberFormat(number, decimals, dec_point, thousands_sep) {
3822
+ function numberFormat(number, decimals, point, thousands) {
3697
3823
  //form http://phpjs.org/functions/number_format/
3698
3824
  //number 必需,要格式化的数字
3699
3825
  //decimals 可选,规定多少个小数位。
3700
- //dec_point 可选,规定用作小数点的字符串(默认为 . )。
3701
- //thousands_sep 可选,规定用作千位分隔符的字符串(默认为 , ),如果设置了该参数,那么所有其他参数都是必需的。
3826
+ //point 可选,规定用作小数点的字符串(默认为 . )。
3827
+ //thousands 可选,规定用作千位分隔符的字符串(默认为 , ),如果设置了该参数,那么所有其他参数都是必需的。
3702
3828
  number = (number + '')
3703
3829
  .replace(/[^0-9+\-Ee.]/g, '')
3704
3830
  var n = !isFinite(+number) ? 0 : +number,
3705
- prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
3706
- sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
3707
- dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
3831
+ prec = !isFinite(+decimals) ? 3 : Math.abs(decimals),
3832
+ sep = thousands || ",",
3833
+ dec = point || ".",
3708
3834
  s = '',
3709
3835
  toFixedFix = function(n, prec) {
3710
3836
  var k = Math.pow(10, prec)
@@ -3766,7 +3892,7 @@ var filters = avalon.filters = {
3766
3892
  if (reg) {
3767
3893
  a = a.replace(reg, function(s, name, value) {
3768
3894
  var quote = value.charAt(0)
3769
- return name + "=" + quote + "javascript:void(0)" + quote
3895
+ return name + "=" + quote + "javascript:void(0)" + quote// jshint ignore:line
3770
3896
  })
3771
3897
  }
3772
3898
  }
@@ -3791,9 +3917,7 @@ var filters = avalon.filters = {
3791
3917
  currency: function(amount, symbol, fractionSize) {
3792
3918
  return (symbol || "\uFFE5") + numberFormat(amount, isFinite(fractionSize) ? fractionSize : 2)
3793
3919
  },
3794
- number: function(number, fractionSize) {
3795
- return numberFormat(number, isFinite(fractionSize) ? fractionSize : 3)
3796
- }
3920
+ number: numberFormat
3797
3921
  }
3798
3922
  /*
3799
3923
  'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)
@@ -3828,7 +3952,7 @@ var filters = avalon.filters = {
3828
3952
  'mediumTime': equivalent to 'h:mm:ss a' for en_US locale (e.g. 12:05:08 pm)
3829
3953
  'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 pm)
3830
3954
  */
3831
- new function() {
3955
+ new function() {// jshint ignore:line
3832
3956
  function toInt(str) {
3833
3957
  return parseInt(str, 10) || 0
3834
3958
  }
@@ -4028,11 +4152,12 @@ new function() {
4028
4152
  }
4029
4153
  locate.SHORTMONTH = locate.MONTH
4030
4154
  filters.date.locate = locate
4031
- }
4155
+ }// jshint ignore:line
4032
4156
  /*********************************************************************
4033
4157
  * AMD加载器 *
4034
4158
  **********************************************************************/
4035
- //去掉getFullUrl 精简loadJS text!插件 baseUrl插件
4159
+ //https://www.devbridge.com/articles/understanding-amd-requirejs/
4160
+ //http://maxogden.com/nested-dependencies.html
4036
4161
  var modules = avalon.modules = {
4037
4162
  "domReady!": {
4038
4163
  exports: avalon,
@@ -4051,15 +4176,14 @@ var modules = avalon.modules = {
4051
4176
  // 4(execute) 其依赖也执行完毕, 值放到exports对象上,在这个阶段fireFactory方法会执行
4052
4177
  modules.exports = modules.avalon
4053
4178
 
4054
- new function() {
4179
+ new function () {// jshint ignore:line
4055
4180
  var loadings = [] //正在加载中的模块列表
4056
4181
  var factorys = [] //放置define方法的factory函数
4057
4182
  var rjsext = /\.js$/i
4058
- var name2url = {}
4059
4183
  function makeRequest(name, config) {
4060
- //1. 去掉资源前缀
4184
+ //1. 去掉资源前缀
4061
4185
  var res = "js"
4062
- name = name.replace(/^(\w+)\!/, function(a, b) {
4186
+ name = name.replace(/^(\w+)\!/, function (a, b) {
4063
4187
  res = b
4064
4188
  return ""
4065
4189
  })
@@ -4067,16 +4191,16 @@ new function() {
4067
4191
  log("debug: ready!已经被废弃,请使用domReady!")
4068
4192
  res = "domReady"
4069
4193
  }
4070
- //2. 去掉querystring, hash
4194
+ //2. 去掉querystring, hash
4071
4195
  var query = ""
4072
- name = name.replace(rquery, function(a) {
4196
+ name = name.replace(rquery, function (a) {
4073
4197
  query = a
4074
4198
  return ""
4075
4199
  })
4076
4200
  //3. 去掉扩展名
4077
4201
  var suffix = "." + res
4078
4202
  var ext = /js|css/.test(suffix) ? suffix : ""
4079
- name = name.replace(/\.[a-z0-9]+$/g, function(a) {
4203
+ name = name.replace(/\.[a-z0-9]+$/g, function (a) {
4080
4204
  if (a === suffix) {
4081
4205
  ext = a
4082
4206
  return ""
@@ -4101,8 +4225,7 @@ new function() {
4101
4225
  //1. 如果该模块已经发出请求,直接返回
4102
4226
  var module = modules[name]
4103
4227
  var urlNoQuery = name && req.urlNoQuery
4104
-
4105
- if (module && module.state >= 3) {
4228
+ if (module && module.state >= 1) {
4106
4229
  return name
4107
4230
  }
4108
4231
  module = modules[urlNoQuery]
@@ -4115,9 +4238,9 @@ new function() {
4115
4238
  id: urlNoQuery,
4116
4239
  state: 1 //send
4117
4240
  }
4118
- var wrap = function(obj) {
4241
+ var wrap = function (obj) {
4119
4242
  resources[res] = obj
4120
- obj.load(name, req, function(a) {
4243
+ obj.load(name, req, function (a) {
4121
4244
  if (arguments.length && a !== void 0) {
4122
4245
  module.exports = a
4123
4246
  }
@@ -4135,12 +4258,10 @@ new function() {
4135
4258
  return name ? urlNoQuery : res + "!"
4136
4259
  }
4137
4260
 
4138
-
4139
4261
  //核心API之一 require
4140
-
4141
4262
  var requireQueue = []
4142
4263
  var isUserFirstRequire = false
4143
- innerRequire = avalon.require = function(array, factory, parentUrl, defineConfig) {
4264
+ innerRequire = avalon.require = function (array, factory, parentUrl, defineConfig) {
4144
4265
  if (!isUserFirstRequire) {
4145
4266
  requireQueue.push(avalon.slice(arguments))
4146
4267
  if (arguments.length <= 2) {
@@ -4157,9 +4278,9 @@ new function() {
4157
4278
  avalon.error("require方法的第一个参数应为数组 " + array)
4158
4279
  }
4159
4280
  var deps = [] // 放置所有依赖项的完整路径
4160
- var uniq = {}
4161
- var id = parentUrl || "callback" + setTimeout("1")
4162
- defineConfig = defineConfig || {}
4281
+ var uniq = createMap()
4282
+ var id = parentUrl || "callback" + setTimeout("1")// jshint ignore:line
4283
+ defineConfig = defineConfig || createMap()
4163
4284
  defineConfig.baseUrl = kernel.baseUrl
4164
4285
  var isBuilt = !!defineConfig.built
4165
4286
  if (parentUrl) {
@@ -4167,10 +4288,10 @@ new function() {
4167
4288
  defineConfig.mapUrl = parentUrl.replace(rjsext, "")
4168
4289
  }
4169
4290
  if (isBuilt) {
4170
- var req = makeRequest(defineConfig.name, defineConfig)
4291
+ var req = makeRequest(defineConfig.defineName, defineConfig)
4171
4292
  id = req.urlNoQuery
4172
4293
  } else {
4173
- array.forEach(function(name) {
4294
+ array.forEach(function (name) {
4174
4295
  var req = makeRequest(name, defineConfig)
4175
4296
  var url = fireRequest(req) //加载资源,并返回该资源的完整地址
4176
4297
  if (url) {
@@ -4199,7 +4320,7 @@ new function() {
4199
4320
  }
4200
4321
 
4201
4322
  //核心API之二 require
4202
- innerRequire.define = function(name, deps, factory) { //模块名,依赖列表,模块本身
4323
+ innerRequire.define = function (name, deps, factory) { //模块名,依赖列表,模块本身
4203
4324
  if (typeof name !== "string") {
4204
4325
  factory = deps
4205
4326
  deps = name
@@ -4211,10 +4332,10 @@ new function() {
4211
4332
  }
4212
4333
  var config = {
4213
4334
  built: !isUserFirstRequire, //用r.js打包后,所有define会放到requirejs之前
4214
- name: name
4335
+ defineName: name
4215
4336
  }
4216
4337
  var args = [deps, factory, config]
4217
- factory.require = function(url) {
4338
+ factory.require = function (url) {
4218
4339
  args.splice(2, 0, url)
4219
4340
  if (modules[url]) {
4220
4341
  modules[url].state = 3 //loaded
@@ -4230,13 +4351,13 @@ new function() {
4230
4351
  delete factory.require //释放内存
4231
4352
  innerRequire.apply(null, args) //0,1,2 --> 1,2,0
4232
4353
  }
4233
- //根据标准,所有遵循W3C标准的浏览器,script标签会按标签的出现顺序执行。
4234
- //老的浏览器中,加载也是按顺序的:一个文件下载完成后,才开始下载下一个文件。
4235
- //较新的浏览器中(IE8+ 、FireFox3.5+ 、Chrome4+ 、Safari4+),为了减小请求时间以优化体验,
4236
- //下载可以是并行的,但是执行顺序还是按照标签出现的顺序。
4237
- //但如果script标签是动态插入的, 就未必按照先请求先执行的原则了,目测只有firefox遵守
4238
- //唯一比较一致的是,IE10+及其他标准浏览器,一旦开始解析脚本, 就会一直堵在那里,直接脚本解析完毕
4239
- //亦即,先进入loading阶段的script标签(模块)必然会先进入loaded阶段
4354
+ //根据标准,所有遵循W3C标准的浏览器,script标签会按标签的出现顺序执行。
4355
+ //老的浏览器中,加载也是按顺序的:一个文件下载完成后,才开始下载下一个文件。
4356
+ //较新的浏览器中(IE8+ 、FireFox3.5+ 、Chrome4+ 、Safari4+),为了减小请求时间以优化体验,
4357
+ //下载可以是并行的,但是执行顺序还是按照标签出现的顺序。
4358
+ //但如果script标签是动态插入的, 就未必按照先请求先执行的原则了,目测只有firefox遵守
4359
+ //唯一比较一致的是,IE10+及其他标准浏览器,一旦开始解析脚本, 就会一直堵在那里,直接脚本解析完毕
4360
+ //亦即,先进入loading阶段的script标签(模块)必然会先进入loaded阶段
4240
4361
  var url = config.built ? "unknown" : getCurrentScript()
4241
4362
  if (url) {
4242
4363
  var module = modules[url]
@@ -4250,30 +4371,30 @@ new function() {
4250
4371
  }
4251
4372
  //核心API之三 require.config(settings)
4252
4373
  innerRequire.config = kernel
4253
- //核心API之四 define.amd 标识其符合AMD规范
4374
+ //核心API之四 define.amd 标识其符合AMD规范
4254
4375
  innerRequire.define.amd = modules
4255
4376
 
4256
- //==========================对用户配置项进行再加工==========================
4257
- var allpaths = kernel["orig.paths"] = {}
4258
- var allmaps = kernel["orig.map"] = {}
4377
+ //==========================对用户配置项进行再加工==========================
4378
+ var allpaths = kernel["orig.paths"] = createMap()
4379
+ var allmaps = kernel["orig.map"] = createMap()
4259
4380
  var allpackages = kernel["packages"] = []
4260
- var allargs = kernel["orig.args"] = {}
4381
+ var allargs = kernel["orig.args"] = createMap()
4261
4382
  avalon.mix(plugins, {
4262
- paths: function(hash) {
4383
+ paths: function (hash) {
4263
4384
  avalon.mix(allpaths, hash)
4264
4385
  kernel.paths = makeIndexArray(allpaths)
4265
4386
  },
4266
- map: function(hash) {
4387
+ map: function (hash) {
4267
4388
  avalon.mix(allmaps, hash)
4268
4389
  var list = makeIndexArray(allmaps, 1, 1)
4269
- avalon.each(list, function(_, item) {
4390
+ avalon.each(list, function (_, item) {
4270
4391
  item.val = makeIndexArray(item.val)
4271
4392
  })
4272
4393
  kernel.map = list
4273
4394
  },
4274
- packages: function(array) {
4395
+ packages: function (array) {
4275
4396
  array = array.concat(allpackages)
4276
- var uniq = {}
4397
+ var uniq = createMap()
4277
4398
  var ret = []
4278
4399
  for (var i = 0, pkg; pkg = array[i++]; ) {
4279
4400
  pkg = typeof pkg === "string" ? {name: pkg} : pkg
@@ -4288,16 +4409,16 @@ new function() {
4288
4409
  }
4289
4410
  kernel.packages = ret.sort()
4290
4411
  },
4291
- urlArgs: function(hash) {
4412
+ urlArgs: function (hash) {
4292
4413
  if (typeof hash === "string") {
4293
4414
  hash = {"*": hash}
4294
4415
  }
4295
4416
  avalon.mix(allargs, hash)
4296
4417
  kernel.urlArgs = makeIndexArray(allargs, 1)
4297
4418
  },
4298
- baseUrl: function(url) {
4419
+ baseUrl: function (url) {
4299
4420
  if (!isAbsUrl(url)) {
4300
- var baseElement = head.querySelector("base")
4421
+ var baseElement = head.getElementsByTagName("base")[0]
4301
4422
  if (baseElement) {
4302
4423
  head.removeChild(baseElement)
4303
4424
  }
@@ -4311,7 +4432,7 @@ new function() {
4311
4432
  if (url.length > 3)
4312
4433
  kernel.baseUrl = url
4313
4434
  },
4314
- shim: function(obj) {
4435
+ shim: function (obj) {
4315
4436
  for (var i in obj) {
4316
4437
  var value = obj[i]
4317
4438
  if (Array.isArray(value)) {
@@ -4329,7 +4450,7 @@ new function() {
4329
4450
  })
4330
4451
 
4331
4452
 
4332
- //==============================内部方法=================================
4453
+ //==============================内部方法=================================
4333
4454
  function checkCycle(deps, nick) {
4334
4455
  //检测是否存在循环依赖
4335
4456
  for (var i = 0, id; id = deps[i++]; ) {
@@ -4344,7 +4465,7 @@ new function() {
4344
4465
  var id = trimQuery(node.src) //检测是否死链
4345
4466
  node.onload = node.onerror = null
4346
4467
  if (onError) {
4347
- setTimeout(function() {
4468
+ setTimeout(function () {
4348
4469
  head.removeChild(node)
4349
4470
  node = null // 处理旧式IE下的循环引用问题
4350
4471
  })
@@ -4362,10 +4483,6 @@ new function() {
4362
4483
  if (!deps)
4363
4484
  continue
4364
4485
  for (var j = 0, key; key = deps[j]; j++) {
4365
- var k = name2url[key]
4366
- if (k) {
4367
- key = deps[j] = k
4368
- }
4369
4486
  if (Object(modules[key]).state !== 4) {
4370
4487
  continue loop
4371
4488
  }
@@ -4378,11 +4495,12 @@ new function() {
4378
4495
  }
4379
4496
  }
4380
4497
  }
4498
+
4381
4499
  function loadJS(url, id, callback) {
4382
4500
  //通过script节点加载目标模块
4383
4501
  var node = DOC.createElement("script")
4384
4502
  node.className = subscribers //让getCurrentScript只处理类名为subscribers的script节点
4385
- node.onload = function() {
4503
+ node.onload = function () {
4386
4504
  var factory = factorys.pop()
4387
4505
  factory && factory.require(id)
4388
4506
  if (callback) {
@@ -4392,11 +4510,11 @@ new function() {
4392
4510
  id && loadings.push(id)
4393
4511
  checkDeps()
4394
4512
  }
4395
- node.onerror = function() {
4513
+ node.onerror = function () {
4396
4514
  checkFail(node, true)
4397
4515
  }
4398
4516
 
4399
- head.appendChild(node) //chrome下第二个参数不能为null
4517
+ head.insertBefore(node, head.firstChild) //chrome下第二个参数不能为null
4400
4518
  node.src = url //插入到head的第一个节点前,防止IE6下head标签没闭合前使用appendChild抛错
4401
4519
  log("debug: 正准备加载 " + url) //更重要的是IE6下可以收窄getCurrentScript的寻找范围
4402
4520
  }
@@ -4407,14 +4525,14 @@ new function() {
4407
4525
  load: noop
4408
4526
  },
4409
4527
  js: {
4410
- load: function(name, req, onLoad) {
4528
+ load: function (name, req, onLoad) {
4411
4529
  var url = req.url
4412
4530
  var id = req.urlNoQuery
4413
4531
  var shim = kernel.shim[name.replace(rjsext, "")]
4414
4532
  if (shim) { //shim机制
4415
- innerRequire(shim.deps || [], function() {
4533
+ innerRequire(shim.deps || [], function () {
4416
4534
  var args = avalon.slice(arguments)
4417
- loadJS(url, id, function() {
4535
+ loadJS(url, id, function () {
4418
4536
  onLoad(shim.exportsFn ? shim.exportsFn.apply(0, args) : void 0)
4419
4537
  })
4420
4538
  })
@@ -4424,25 +4542,23 @@ new function() {
4424
4542
  }
4425
4543
  },
4426
4544
  css: {
4427
- load: function(name, req, onLoad) {
4545
+ load: function (name, req, onLoad) {
4428
4546
  var url = req.url
4429
- var node = DOC.createElement("link")
4430
- node.rel = "stylesheet"
4431
- node.href = url
4432
- head.appendChild(node)
4547
+ head.insertAdjacentHTML("afterBegin", '<link rel="stylesheet" href="' + url + '">')
4433
4548
  log("debug: 已成功加载 " + url)
4434
4549
  onLoad()
4435
4550
  }
4436
4551
  },
4437
4552
  text: {
4438
- load: function(name, req, onLoad) {
4553
+ load: function (name, req, onLoad) {
4439
4554
  var url = req.url
4440
4555
  var xhr = getXHR()
4441
- xhr.onload = function() {
4556
+ xhr.onload = function () {
4442
4557
  var status = xhr.status;
4443
4558
  if (status > 399 && status < 600) {
4444
4559
  avalon.error(url + " 对应资源不存在或没有开启 CORS")
4445
4560
  } else {
4561
+ log("debug: 已成功加载 " + url)
4446
4562
  onLoad(xhr.responseText)
4447
4563
  }
4448
4564
  }
@@ -4468,6 +4584,7 @@ new function() {
4468
4584
  return /^(?:[a-z]+:)?\/\//i.test(String(path))
4469
4585
  }
4470
4586
 
4587
+
4471
4588
  function getCurrentScript() {
4472
4589
  // inspireb by https://github.com/samyk/jiagra/blob/master/jiagra.js
4473
4590
  var stack
@@ -4501,23 +4618,29 @@ new function() {
4501
4618
  }
4502
4619
  }
4503
4620
 
4504
-
4621
+ var rcallback = /^callback\d+$/
4505
4622
  function fireFactory(id, deps, factory) {
4506
4623
  var module = Object(modules[id])
4507
4624
  module.state = 4
4508
4625
  for (var i = 0, array = [], d; d = deps[i++]; ) {
4509
- d = name2url[d] || d
4510
4626
  if (d === "exports") {
4511
- var obj = module.exports || (module.exports = {})
4627
+ var obj = module.exports || (module.exports = createMap())
4512
4628
  array.push(obj)
4513
4629
  } else {
4514
4630
  array.push(modules[d].exports)
4515
4631
  }
4516
4632
  }
4517
- var ret = factory.apply(window, array)
4633
+ try {
4634
+ var ret = factory.apply(window, array)
4635
+ } catch (e) {
4636
+ log("执行[" + id + "]模块的factory抛错: " + e)
4637
+ }
4518
4638
  if (ret !== void 0) {
4519
4639
  module.exports = ret
4520
4640
  }
4641
+ if (rcallback.test(id)) {
4642
+ delete modules[id]
4643
+ }
4521
4644
  delete module.factory
4522
4645
  return ret
4523
4646
  }
@@ -4530,20 +4653,20 @@ new function() {
4530
4653
  var usePath = 0
4531
4654
  var baseUrl = this.baseUrl
4532
4655
  var rootUrl = this.parentUrl || baseUrl
4533
- eachIndexArray(id, kernel.paths, function(value, key) {
4656
+ eachIndexArray(id, kernel.paths, function (value, key) {
4534
4657
  url = url.replace(key, value)
4535
4658
  usePath = 1
4536
4659
  })
4537
4660
  //2. 是否命中packages配置项
4538
4661
  if (!usePath) {
4539
- eachIndexArray(id, kernel.packages, function(value, key, item) {
4662
+ eachIndexArray(id, kernel.packages, function (value, key, item) {
4540
4663
  url = url.replace(item.name, item.location)
4541
4664
  })
4542
4665
  }
4543
4666
  //3. 是否命中map配置项
4544
4667
  if (this.mapUrl) {
4545
- eachIndexArray(this.mapUrl, kernel.map, function(array) {
4546
- eachIndexArray(url, array, function(mdValue, mdKey) {
4668
+ eachIndexArray(this.mapUrl, kernel.map, function (array) {
4669
+ eachIndexArray(url, array, function (mdValue, mdKey) {
4547
4670
  url = url.replace(mdKey, mdValue)
4548
4671
  rootUrl = baseUrl
4549
4672
  })
@@ -4562,7 +4685,7 @@ new function() {
4562
4685
  var urlNoQuery = url + ext
4563
4686
  url = urlNoQuery + this.query
4564
4687
  //6. 处理urlArgs
4565
- eachIndexArray(id, kernel.urlArgs, function(value) {
4688
+ eachIndexArray(id, kernel.urlArgs, function (value) {
4566
4689
  url += (url.indexOf("?") === -1 ? "?" : "&") + value;
4567
4690
  })
4568
4691
  this.url = url
@@ -4581,7 +4704,7 @@ new function() {
4581
4704
  }
4582
4705
 
4583
4706
  function makeExports(value) {
4584
- return function() {
4707
+ return function () {
4585
4708
  var ret
4586
4709
  if (value.init) {
4587
4710
  ret = value.init.apply(window, arguments)
@@ -4594,17 +4717,17 @@ new function() {
4594
4717
  function hash2array(hash, useStar, part) {
4595
4718
  var array = [];
4596
4719
  for (var key in hash) {
4597
- if (hash.hasOwnProperty(key)) {
4598
- var item = {
4599
- name: key,
4600
- val: hash[key]
4601
- }
4602
- array.push(item)
4603
- item.reg = key === "*" && useStar ? /^/ : makeMatcher(key)
4604
- if (part && key !== "*") {
4605
- item.reg = new RegExp('\/' + key.replace(/^\//, "") + '(/|$)')
4606
- }
4720
+ // if (hash.hasOwnProperty(key)) {//hash是由createMap创建没有hasOwnProperty
4721
+ var item = {
4722
+ name: key,
4723
+ val: hash[key]
4607
4724
  }
4725
+ array.push(item)
4726
+ item.reg = key === "*" && useStar ? /^/ : makeMatcher(key)
4727
+ if (part && key !== "*") {
4728
+ item.reg = new RegExp('\/' + key.replace(/^\//, "") + '(/|$)')
4729
+ }
4730
+ // }
4608
4731
  }
4609
4732
  return array
4610
4733
  }
@@ -4618,7 +4741,7 @@ new function() {
4618
4741
  }
4619
4742
  }
4620
4743
  }
4621
- // 根据元素的name项进行数组字符数逆序的排序函数
4744
+ // 根据元素的name项进行数组字符数逆序的排序函数
4622
4745
  function descSorterByName(a, b) {
4623
4746
  var aaa = a.name
4624
4747
  var bbb = b.name
@@ -4657,7 +4780,7 @@ new function() {
4657
4780
  return value
4658
4781
  }
4659
4782
  var g = window
4660
- value.split(".").forEach(function(part) {
4783
+ value.split(".").forEach(function (part) {
4661
4784
  g = g[part]
4662
4785
  })
4663
4786
  return g
@@ -4674,43 +4797,45 @@ new function() {
4674
4797
  var loaderUrl = trimQuery(mainNode.src)
4675
4798
  kernel.baseUrl = loaderUrl.slice(0, loaderUrl.lastIndexOf("/") + 1)
4676
4799
  }
4677
- }
4800
+ }// jshint ignore:line
4678
4801
 
4679
4802
  /*********************************************************************
4680
4803
  * DOMReady *
4681
4804
  **********************************************************************/
4682
- var readyList = []
4683
- function fireReady() {
4805
+ var readyList = [], isReady
4806
+ var fireReady = function (fn) {
4807
+ isReady = true
4684
4808
  if (innerRequire) {
4685
4809
  modules["domReady!"].state = 4
4686
- innerRequire.checkDeps()//隋性函数,防止IE9二次调用_checkDeps
4810
+ innerRequire.checkDeps()
4811
+ }
4812
+ while (fn = readyList.shift()) {
4813
+ fn(avalon)
4687
4814
  }
4688
- readyList.forEach(function(a) {
4689
- a(avalon)
4690
- })
4691
- fireReady = noop //隋性函数,防止IE9二次调用_checkDeps
4692
4815
  }
4693
4816
 
4817
+
4694
4818
  if (DOC.readyState === "complete") {
4695
4819
  setTimeout(fireReady) //如果在domReady之外加载
4696
4820
  } else {
4697
4821
  DOC.addEventListener("DOMContentLoaded", fireReady)
4698
- window.addEventListener("load", fireReady)
4699
4822
  }
4700
- avalon.ready = function(fn) {
4701
- if (fireReady === noop) {
4702
- fn(avalon)
4703
- } else {
4823
+ window.addEventListener("load", fireReady)
4824
+ avalon.ready = function (fn) {
4825
+ if (!isReady) {
4704
4826
  readyList.push(fn)
4827
+ } else {
4828
+ fn(avalon)
4705
4829
  }
4706
4830
  }
4707
4831
  avalon.config({
4708
4832
  loader: true
4709
4833
  })
4710
- avalon.ready(function() {
4834
+ avalon.ready(function () {
4711
4835
  avalon.scan(DOC.body)
4712
4836
  })
4713
- new function() {
4837
+ new function() {// jshint ignore:line
4838
+ // http://www.cnblogs.com/yexiaochai/p/3462657.html
4714
4839
  var ua = navigator.userAgent
4715
4840
  var isAndroid = ua.indexOf("Android") > 0
4716
4841
  var isIOS = /iP(ad|hone|od)/.test(ua)
@@ -4745,83 +4870,15 @@ new function() {
4745
4870
  } else if (IE9_10touch) {
4746
4871
  touchNames = ["MSPointerDown", "MSPointerMove", "MSPointerUp", "MSPointerCancel"]
4747
4872
  }
4748
- var clickbuster = {
4749
- underFrame: null,
4750
- coordinates: [],
4751
- addUnderFrame: function(event) {
4752
- var underFrame = null
4753
- if(!clickbuster.underFrame) {
4754
- underFrame = document.createElement('div');
4755
- underFrame.style.cssText = [
4756
- "opacity: 0",
4757
- "display: none;",
4758
- "border-radius: 60px;",
4759
- "position: absolute;",
4760
- "z-index: 99999;",
4761
- "width: 60px;",
4762
- "height: 60px"
4763
- ].join("");
4764
- document.body.appendChild(underFrame)
4765
- }
4766
- clickbuster.underFrame = underFrame
4767
- underFrame.style.top = (event.changedTouches[0].clientY - 30) + "px"
4768
- underFrame.style.left = (event.changedTouches[0].clientX - 30) + "px"
4769
- underFrame.style.display = "block"
4770
- setTimeout(function(){
4771
- underFrame.style.display = "none"
4772
- }, 360)
4773
- },
4774
- preventGhostClick: function(x, y) {
4775
- clickbuster.coordinates.push(x, y);
4776
- window.setTimeout(clickbuster.pop, 2500)
4777
- },
4778
- pop: function() {
4779
- clickbuster.coordinates.splice(0, 2)
4780
- },
4781
- onClick: function(event) {
4782
- for (var i = 0; i < clickbuster.coordinates.length; i += 2) {
4783
- var x = clickbuster.coordinates[i]
4784
- var y = clickbuster.coordinates[i + 1]
4785
- if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
4786
- event.stopPropagation();
4787
- event.preventDefault();
4788
- }
4789
- }
4790
- }
4873
+ function isPrimaryTouch(event){
4874
+ return (event.pointerType === 'touch' || event.pointerType === event.MSPOINTER_TYPE_TOUCH) && event.isPrimary
4791
4875
  }
4792
4876
 
4793
- if (touchSupported) {
4794
- //我们经由ms-click, ms-on-tap绑定事件, 其实没有直接绑在元素,全部放到一个数组中
4795
- //当通过touchstart, touchend等事件混合计算得当前场景应该需要执行click, tap,那么
4796
- //直接执行el["msdispatch"]方法
4797
- "click,tap".replace(/\w+/g, function(method) {
4798
- avalon.eventHooks[method] = {
4799
- type: method,
4800
- deel: function(el, type, fn, isAdd) {
4801
- var listName = "ms" + method + "list"
4802
- var fns = el[listName] || (el[listName] = [])
4803
- if (!el["msdispatch"]) {
4804
- el["msdispatch"] = function(event) {
4805
- if (event.fireByAvalon) {
4806
- for (var i = 0, fn; fn = fns[i++]; ) {
4807
- fn.call(el, event)
4808
- }
4809
- }
4810
- }
4811
- el.addEventListener(type, el["msdispatch"])
4812
- }
4813
- if (isAdd) {
4814
- fns.push(fn)
4815
- } else {
4816
- avalon.Array.remove(fns, fn)
4817
- }
4818
- fn.unbind = true
4819
- return fn
4820
- }
4821
- }
4822
- })
4877
+ function isPointerEventType(e, type){
4878
+ return (e.type === 'pointer'+type || e.type.toLowerCase() === 'mspointer'+type)
4823
4879
  }
4824
4880
 
4881
+ var touchTimeout, longTapTimeout
4825
4882
  //判定滑动方向
4826
4883
  function swipeDirection(x1, x2, y1, y2) {
4827
4884
  return Math.abs(x1 - x2) >=
@@ -4835,31 +4892,95 @@ new function() {
4835
4892
  y: e.clientY
4836
4893
  }
4837
4894
  }
4838
-
4895
+ function fireEvent(el, name, detail) {
4896
+ var event = document.createEvent("Events")
4897
+ event.initEvent(name, true, true)
4898
+ event.fireByAvalon = true//签名,标记事件是由avalon触发
4899
+ //event.isTrusted = false 设置这个opera会报错
4900
+ if (detail)
4901
+ event.detail = detail
4902
+ el.dispatchEvent(event)
4903
+ }
4904
+ function onMouse(event) {
4905
+ if (event.fireByAvalon) {
4906
+ return true
4907
+ }
4908
+ if (event.stopImmediatePropagation) {
4909
+ event.stopImmediatePropagation()
4910
+ } else {
4911
+ event.propagationStopped = true
4912
+ }
4913
+ event.stopPropagation()
4914
+ event.preventDefault()
4915
+ }
4916
+ function cancelLongTap() {
4917
+ if (longTapTimeout) clearTimeout(longTapTimeout)
4918
+ longTapTimeout = null
4919
+ }
4920
+ function touchstart(event) {
4921
+ var _isPointerType = isPointerEventType(event, 'down'),
4922
+ firstTouch = _isPointerType ? event : event.touches[0],
4923
+ element = 'tagName' in firstTouch.target ? firstTouch.target: firstTouch.target.parentNode,
4924
+ now = Date.now(),
4925
+ delta = now - (touchProxy.last || now)
4926
+
4927
+ if (_isPointerType && !isPrimaryTouch(event)) return
4928
+
4929
+ avalon.mix(touchProxy, getCoordinates(event))
4930
+ touchProxy.mx = 0
4931
+ touchProxy.my = 0
4932
+ if (delta > 0 && delta <= 250) {
4933
+ touchProxy.isDoubleTap = true
4934
+ }
4935
+ touchProxy.last = now
4936
+ touchProxy.element = element
4937
+ /*
4938
+ 当触发hold和longtap事件时会触发touchcancel事件,从而阻止touchend事件的触发,继而保证在同时绑定tap和hold(longtap)事件时只触发其中一个事件
4939
+ */
4940
+ avalon(element).addClass(fastclick.activeClass)
4941
+ longTapTimeout = setTimeout(function() {
4942
+ longTapTimeout = null
4943
+ fireEvent(element, "hold")
4944
+ fireEvent(element, "longtap")
4945
+ touchProxy = {}
4946
+ avalon(element).removeClass(fastclick.activeClass)
4947
+ }, fastclick.clickDuration)
4948
+ return true
4949
+ }
4950
+ function touchmove(event) {
4951
+ var _isPointerType = isPointerEventType(event, 'down'),
4952
+ e = getCoordinates(event)
4953
+ if (_isPointerType && !isPrimaryTouch(event)) return
4954
+
4955
+ cancelLongTap()
4956
+ touchProxy.mx += Math.abs(touchProxy.x - e.x)
4957
+ touchProxy.my += Math.abs(touchProxy.y - e.y)
4958
+ }
4839
4959
  function touchend(event) {
4840
- var element = touchProxy.element
4841
- if (!element)
4960
+ var _isPointerType = isPointerEventType(event, 'down')
4961
+ element = touchProxy.element
4962
+
4963
+ if (_isPointerType && !isPrimaryTouch(event)) return
4964
+
4965
+ if (!element) {
4842
4966
  return
4967
+ }
4968
+ cancelLongTap()
4843
4969
  var e = getCoordinates(event)
4844
- var diff = Date.now() - touchProxy.startTime //经过时间
4845
4970
  var totalX = Math.abs(touchProxy.x - e.x)
4846
4971
  var totalY = Math.abs(touchProxy.y - e.y)
4847
- if (touchProxy.doubleIndex === 2 && avalon.config.stopZoom) {//如果已经点了两次,就可以触发dblclick 回调
4848
- event.preventDefault()
4849
- }
4850
4972
  if (totalX > 30 || totalY > 30) {
4851
4973
  //如果用户滑动的距离有点大,就认为是swipe事件
4852
4974
  var direction = swipeDirection(touchProxy.x, e.x, touchProxy.y, e.y)
4853
4975
  var details = {
4854
4976
  direction: direction
4855
4977
  }
4856
- W3CFire(element, "swipe", details)
4857
- W3CFire(element, "swipe" + direction, details)
4978
+ fireEvent(element, "swipe", details)
4979
+ fireEvent(element, "swipe" + direction, details)
4980
+ avalon(element).removeClass(fastclick.activeClass)
4981
+ touchProxy = {}
4858
4982
  } else {
4859
- //如果移动的距离太少,则认为是tap,click,hold,dblclick
4860
- if (fastclick.canClick(element) &&
4861
- touchProxy.mx < fastclick.dragDistance &&
4862
- touchProxy.my < fastclick.dragDistance) {
4983
+ if (fastclick.canClick(element) && touchProxy.mx < fastclick.dragDistance && touchProxy.my < fastclick.dragDistance) {
4863
4984
  // 失去焦点的处理
4864
4985
  if (document.activeElement && document.activeElement !== element) {
4865
4986
  document.activeElement.blur()
@@ -4874,92 +4995,39 @@ new function() {
4874
4995
  } else {
4875
4996
  fastclick.focus(element)
4876
4997
  }
4877
- avalon.fastclick.fireEvent(element, "click", event)//触发click事件
4878
- W3CFire(element, "tap")//触发tap事件
4879
- if (forElement) {
4880
- avalon.fastclick.fireEvent(forElement, "click", event)
4881
- W3CFire(element, "tap")//触发tap事件
4882
- }
4883
- if (diff < 250) {
4884
- if (touchProxy.doubleIndex == 2) {
4885
- avalon.fastclick.fireEvent(element, "dblclick", event)//触发dblclick事件
4886
- W3CFire(element, "doubletap")//触发doubletap事件
4887
- touchProxy.doubleIndex = 0
4888
- } else {
4889
- setTimeout(function() {
4890
- touchProxy.doubleIndex = 0
4891
- }, 250)
4892
- }
4893
- }
4894
-
4895
- if (diff > fastclick.clickDuration) {
4896
- W3CFire(element, "hold")
4897
- W3CFire(element, "longtap")
4898
- touchProxy.doubleIndex = 0
4998
+ event.preventDefault()
4999
+ fireEvent(element, 'tap')
5000
+ avalon.fastclick.fireEvent(element, "click", event)
5001
+ avalon(element).removeClass(fastclick.activeClass)
5002
+ if (touchProxy.isDoubleTap) {
5003
+ fireEvent(element, "doubletap")
5004
+ avalon.fastclick.fireEvent(element, "dblclick", event)
5005
+ touchProxy = {}
5006
+ avalon(element).removeClass(fastclick.activeClass)
5007
+ } else {
5008
+ touchTimeout = setTimeout(function() {
5009
+ clearTimeout(touchTimeout)
5010
+ touchTimeout = null
5011
+ touchProxy = {}
5012
+ avalon(element).removeClass(fastclick.activeClass)
5013
+ }, 250)
4899
5014
  }
4900
5015
  }
4901
5016
  }
4902
- avalon(element).removeClass(fastclick.activeClass)
4903
- touchProxy.element = null
4904
5017
  }
4905
- // 避免被点击的元素下有input、textarea时会触发其focus从而调出键盘
4906
- // http://hzxiaosheng.github.io/work/2014/09/13/click-event-300ms-delay-and-ghost-click-in-mobile-browser/
4907
- document.addEventListener('click', clickbuster.onClick, true)
4908
- document.addEventListener(touchNames[1], function(event) {
4909
- if (!touchProxy.element)
4910
- return
4911
- var e = getCoordinates(event)
4912
- touchProxy.mx += Math.abs(touchProxy.cx - e.x)
4913
- touchProxy.my += Math.abs(touchProxy.cy - e.y)
4914
- if (touchProxy.tapping && (touchProxy.mx > fastclick.dragDistance || touchProxy.my > fastclick.dragDistance)) {
4915
- touchProxy.element = null
4916
- }
4917
- })
4918
-
5018
+ document.addEventListener('mousedown', onMouse, true)
5019
+ document.addEventListener('click', onMouse, true)
5020
+ document.addEventListener(touchNames[0], touchstart)
5021
+ document.addEventListener(touchNames[1], touchmove)
4919
5022
  document.addEventListener(touchNames[2], touchend)
4920
5023
  if (touchNames[3]) {
4921
- document.addEventListener(touchNames[3], touchend)
4922
- }
4923
- me["clickHook"] = function(data) {
4924
- function touchstart(event) {
4925
- var element = data.element
4926
- avalon.mix(touchProxy, getCoordinates(event))
4927
- touchProxy.cx = touchProxy.x
4928
- touchProxy.cy = touchProxy.y
4929
- touchProxy.mx = 0 //计算总结移动了多少距离,指在移动距离重分
4930
- touchProxy.my = 0
4931
- // touchProxy.startTime = Date.now()
4932
- touchProxy.event = data.param
4933
- touchProxy.tapping = /click|tap|hold$/.test(touchProxy.event)
4934
-
4935
- //--------------处理双击事件--------------
4936
- if (!touchProxy.doubleIndex) {
4937
- touchProxy.doubleIndex = 1
4938
- touchProxy.startTime = Date.now()
4939
- } else {
4940
- touchProxy.doubleIndex = 2
4941
- }
4942
- touchProxy.element = element
4943
- if (touchProxy.tapping && avalon.fastclick.canClick(element)) {
4944
- avalon(element).addClass(fastclick.activeClass)
4945
- }
4946
- }
4947
- function needFixClick(type) {
4948
- return type === "click"
4949
- }
4950
- if (needFixClick(data.param) ? touchSupported : true) {
4951
- data.specialBind = function(element, callback) {
4952
- element.addEventListener(touchNames[0], touchstart)
4953
- data.msCallback = callback
4954
- avalon.bind(element, data.param, callback)
4955
- }
4956
- data.specialUnbind = function() {
4957
- element.removeEventListener(touchNames[0], touchstart)
4958
- avalon.bind(data.element, data.param, data.msCallback)
4959
- }
4960
- }
5024
+ document.addEventListener(touchNames[3], function(event) {
5025
+ if (longTapTimeout) clearTimeout(longTapTimeout)
5026
+ if (touchTimeout) clearTimeout(touchTimeout)
5027
+ longTapTimeout = touchTimeout = null
5028
+ touchProxy = {}
5029
+ })
4961
5030
  }
4962
-
4963
5031
  //fastclick只要是处理移动端点击存在300ms延迟的问题
4964
5032
  //这是苹果乱搞异致的,他们想在小屏幕设备上通过快速点击两次,将放大了的网页缩放至原始比例。
4965
5033
  var fastclick = avalon.fastclick = {
@@ -5027,29 +5095,9 @@ new function() {
5027
5095
  ["swipe", "swipeleft", "swiperight", "swipeup", "swipedown", "doubletap", "tap", "dblclick", "longtap", "hold"].forEach(function(method) {
5028
5096
  me[method + "Hook"] = me["clickHook"]
5029
5097
  })
5030
- if (touchSupported) {
5031
- me[touchNames[2] + "Hook"] = function(data) {
5032
- data.specialBind = function(element, callback) {
5033
- var _callback = callback
5034
- if (element.hasAttribute('avoidFocus')) {
5035
- _callback = function(event) {
5036
- var e = getCoordinates(event)
5037
- clickbuster.preventGhostClick(e.x, e.y)
5038
- clickbuster.addUnderFrame(event)
5039
- callback.apply(this, [].slice.call(arguments))
5040
- }
5041
- }
5042
- data.msCallback = _callback
5043
- avalon.bind(element, data.param, _callback)
5044
- }
5045
- data.specialUnbind = function() {
5046
- avalon.unbind(data.element, data.param, data.msCallback)
5047
- }
5048
- }
5049
- }
5050
- //各种摸屏事件的示意图 http://quojs.tapquo.com/ http://touch.code.baidu.com/
5051
- }
5052
5098
 
5099
+ //各种摸屏事件的示意图 http://quojs.tapquo.com/ http://touch.code.baidu.com/
5100
+ }// jshint ignore:line
5053
5101
 
5054
5102
  // Register as a named AMD module, since avalon can be concatenated with other
5055
5103
  // files that may use define, but not via a proper concatenation script that
@@ -5072,7 +5120,7 @@ new function() {
5072
5120
  var _avalon = window.avalon
5073
5121
  avalon.noConflict = function(deep) {
5074
5122
  if (deep && window.avalon === avalon) {
5075
- window.avalon = avalon
5123
+ window.avalon = _avalon
5076
5124
  }
5077
5125
  return avalon
5078
5126
  }