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,2 +1,2 @@
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(){avalon.config.debug&&console.log.apply(console,arguments)}function r(){}function i(e,t){"string"==typeof e&&(e=e.match(yt)||[]);for(var n={},a=void 0!==t?t:1,r=0,i=e.length;i>r;r++)n[e[r]]=a;return n}function o(e){function t(a,r){return n.push(a)>e&&delete t[n.shift()],t[a]=r}var n=[];return t}function l(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function s(e){if(e&&"object"==typeof e){var t=e.length,n=At.call(e);if(/(Array|List|Collection|Map|Arguments)\]$/.test(n))return!0;if("[object Object]"===n&&t===t>>>0)return!0}return!1}function c(e,t){if(e&&e.childNodes)for(var n,a=e.childNodes,r=0;n=a[r++];)if(n.tagName){var i=ft.createElementNS(It,n.tagName.toLowerCase());Tt.forEach.call(n.attributes,function(e){i.setAttribute(e.name,e.value)}),c(n,i),t.appendChild(i)}}function u(e){for(var t in e)if(Ct.call(e,t)){var n=e[t];"function"==typeof u.plugins[t]?u.plugins[t](n):"object"==typeof u[t]?avalon.mix(u[t],n):u[t]=n}return this}function f(e){return(e+"").replace(zt,"\\$&")}function p(e,t,n){if(Pt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;if(-1!==Qt.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function v(e,t,n,a){switch(e.type){case 0:var r=e.get,i=e.set;if(Pt(i)){var o=a.$events,l=o[t];o[t]=[],i.call(a,n),o[t]=l}return r.call(a);case 1:return n;case 2:if(n!==a.$model[t]){var s=e.svmodel=m(a,t,n,e.valueType);n=s.$model;var c=Kt[s.$id];c&&c()}return n}}function d(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=g(e);return i.pushArray(a),i}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 o={};n=n||{};var l={},s={},c=[];for(var u in e)!function(t,a){if(n[t]=a,p(t,a,e.$skipArray)){l[t]=[];var i=avalon.type(a),u=function(e){var t=u._name,n=this,a=n.$model,r=a[t],i=n.$events;return arguments.length?void(gt||(1===u.type||(e=v(u,t,e,n),u.type))&&(rn(r,e)||(a[t]=e,i.$digest?u.pedding||(u.pedding=!0,setTimeout(function(){E(i[t]),h(n,t,a[t],r),u.pedding=!1})):(E(i[t]),h(n,t,e,r))))):0===u.type?(e=u.get.call(n),r!==e&&(a[t]=e,i.$digest?u.pedding||(u.pedding=!0,setTimeout(function(){h(n,t,a[t],r),u.pedding=!1})):h(n,t,e,r)),e):(x(i[t]),u.svmodel||r)};"object"===i&&Pt(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:pt,type:Math.random(),handler:r,args:[]};kt[ut]=e,u.call(o),delete kt[ut]})):bt.test(i)?(u.type=2,u.valueType=i,c.push(function(){var e=d(a,0,n[t]);u.svmodel=e,e.$events[dt]=l[t]})):u.type=1,u._name=t,s[t]=u}}(u,e[u]);Qt.forEach(function(t){delete e[t],delete n[t]}),o=nn(o,on(s),e);for(var f in e)s[f]||(o[f]=e[f]);o.$id=Ht(),o.$model=n,o.$events=l;for(u in Gt){var m=Gt[u];Mt||(m=m.bind(o)),o[u]=m}return tn?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 h(e,t,n,a){e.$events&&Gt.$fire.call(e,t,n,a)}function m(e,t,n,a){var r=e[t];if("array"===a)return Array.isArray(n)&&r!==n?(r._.$unwatch(),r.clear(),r._.$watch(),r.pushArray(n.concat()),r):r;var i=e.$events[t],o=r.$events.$withProxyPool;o&&(ot(o,"with"),r.$events.$withProxyPool=null);var l=d(n);return l.$events[dt]=i,Kt[l.$id]=function(e){for(;e=i.shift();)!function(e){avalon.nextTick(function(){e.type&&(e.rollback&&e.rollback(),Dt[e.type](e,e.vmodels))})}(e);delete Kt[l.$id]},l}function g(e){var t=[];t.$id=Ht(),t.$model=e,t.$events={},t.$events[dt]=[],t._=d({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in Gt)t[n]=Gt[n];return avalon.mix(t,sn),t}function y(e,t,n,a,r,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 bt.test(avalon.type(e))?e.$id?e:d(e,0,e):e});ln.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)}r&&(e=r,t=i,n=o,s=2,r=0)}return this._fire("index",a),this.length!==l&&(this._.length=this.length),u}function b(e,t){for(var n={},a=0,r=t.length;r>a;a++){n[a]=e[a];var i=t[a];i in n?(e[a]=n[i],delete n[i]):e[a]=e[i]}}function $(e){kt[ut]=e,avalon.openComputedCollect=!0;var t=e.evaluator;if(t)try{var n=cn.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(a){delete e.evaluator;var r=e.element;if(3===r.nodeType){var i=r.parentNode;u.commentInterpolate?i.replaceChild(ft.createComment(e.value),r):r.data=Bt+e.value+Ut}}avalon.openComputedCollect=!1,delete kt[ut]}function x(e){var t=kt[ut];e&&t&&avalon.Array.ensure(e,t)&&t.element&&w(t,e)}function w(e,t){e.$uuid=e.$uuid||Ht(),t.$uuid=t.$uuid||Ht();var n={data:e,list:t,$$uuid:e.$uuid+t.$uuid};un[n.$$uuid]||(un[n.$$uuid]=1,un.push(n))}function C(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function A(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:!Ot.contains(e):!avalon.contains(Ot,e)}function T(){for(var e,t=un.length,n=t,a=0,r=[],i={},o={};e=un[--t];){var l=e.data,s=l.type;i[s]?i[s]++:(i[s]=1,r.push(s))}var c=!1;if(r.forEach(function(e){pn[e]!==i[e]&&(o[e]=1,c=!0)}),t=n,c)for(;e=un[--t];)l=e.data,void 0!==l.element&&o[l.type]&&A(l.element)&&(a++,un.splice(t,1),delete un[e.$$uuid],avalon.Array.remove(e.list,l),C(l),e.data=e.list=null);pn=i,fn=new Date}function E(e){if(e&&e.length){new Date-fn>444&&"object"==typeof e[0]&&T();for(var t,n=Et.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 k(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():k(e,t,r)})}function M(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function O(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,Dt[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function N(e,t){return e.priority-t.priority}function L(e,t){for(var a,r,i=e.hasAttributes()?avalon.slice(e.attributes):[],o=[],l={},s=0;r=i[s++];)if(r.specified&&(a=r.name.match(xn))){var c=a[1],u=a[2]||"",f=r.value,p=r.name;if(l[p]=f,Cn[c]?(u=c,c="on"):An[c]&&(n("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),a=[p],l[p]=f),"function"==typeof Dt[c]){var v={type:c,param:u,element:e,name:a[0],value:f,priority:c in wn?wn[c]:10*c.charCodeAt(0)+(Number(u)||0)};if("html"===c||"text"===c){var d=D(f);avalon.mix(v,d),v.filters=v.filters.replace(kn,function(){return v.type="html",v.group=1,""})}"ms-if-loop"===p&&(v.priority+=100),t.length&&(o.push(v),"widget"===c&&(e.msData=e.msData||l))}}l["ms-attr-checked"]&&l["ms-duplex"]&&n("warning!一个元素上不能同时定义ms-attr-checked与ms-duplex"),o.sort(N);var h=!0;for(s=0;v=o[s];s++){if(c=v.type,Tn.test(c))return O(o.slice(0,s+1),t);h&&(h=!En.test(c))}O(o,t),h&&!yn[e.tagName]&&Wt.test(e.innerHTML+e.textContent)&&($n&&$n(e),S(e,t))}function S(e,t){for(var n=e.firstChild;n;){var a=n.nextSibling;j(n,n.nodeType,t),n=a}}function H(e,t){for(var n,a=0;n=e[a++];)j(n,n.nodeType,t)}function j(e,t,n){1===t?P(e,n):3===t&&Vt.test(e.data)?I(e,n):u.commentInterpolate&&8===t&&!Vt.test(e.nodeValue)&&I(e,n)}function P(e,t,n){var a=e.getAttribute("ms-skip"),r=e.getAttributeNode("ms-important"),i=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(n=r||i){var o=avalon.vmodels[n.value];if(!o)return;t=n===r?[o]:[o].concat(t),e.removeAttribute(n.name),e.classList.remove(n.name),M(e,o)}L(e,t)}}function D(e){if(e.indexOf("|")>0){var t=e.replace(rstringLiteral,function(e){return Math.pow(10,e.length)}),n=t.replace(Mn,"ᄢ㍄").indexOf("|");if(n>-1)return{filters:e.slice(n),value:e.slice(0,n),expr:!0}}return{value:e,filters:"",expr:!0}}function R(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Bt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Bt.length,n=e.indexOf(Ut,r),-1===n)break;t=e.slice(r,n),t&&a.push(D(t)),r=n+Ut.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function I(e,t){var n=[];if(8===e.nodeType)var a=D(e.nodeValue),r=[a];else r=R(e.data);if(r.length){for(var i=0;a=r[i++];){var o=ft.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(kn,function(){return a.type="html",a.group=1,""}),n.push(a)),Nt.appendChild(o)}e.parentNode.replaceChild(Nt,e),n.length&&O(n,t)}}function _(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function F(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function B(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:On.test(e)?JSON.parse(e):e}catch(t){}return e}function U(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function V(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(jn.test(n.display)){var a={node:e};for(var r in Hn)a[r]=n[r],e.style[r]=Hn[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&V(i,t)}}function q(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function W(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=e.length;r=e[--l];)t.hasOwnProperty(r)&&(i.push(r+o+r),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+r),e.splice(l,1));return i}function z(e){for(var t=[],n={},a=0;a<e.length;a++){var r=e[a],i=r&&"string"==typeof r.$id?r.$id:r;n[i]||(n[i]=t.push(r))}return t}function X(e,t){return t=t.replace(Yn,"").replace(Gn,function(){return"],|"}).replace(Zn,function(e,t){return"["+Dn(t)}).replace(Jn,function(){return'"],["'}).replace(Qn,function(){return'",'})+"]","return avalon.filters.$filter("+e+", "+t+")"}function Y(e,t,a){var i=a.type,o=a.filters||"",l=t.map(function(e){return String(e.$id).replace(Xn,"$1")})+e+i+o,s=qn(e).concat(),c=[],u=[],f=[],p="";t=z(t),a.vars=[];for(var v=0,d=t.length;d>v;v++)if(s.length){var h="vm"+ut+"_"+v;u.push(h),f.push(t[v]),c.push.apply(c,W(s,t[v],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 a=n.charAt(t.length),r=jt?e.slice(arguments[1]+n.length):RegExp.rightContext,i=/^\s*\(/.test(r);if("."===a||"["===a||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=Wn[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"+ut+" = "+e+";\r\n",e+=X("ret"+ut,o)}else{if("duplex"===i){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(zn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(r,u.concat(g)),a.evaluator=Wn(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"),$=e.slice(0,b),x=e.slice(b);e=$+"\n"+x}else e="\nreturn "+e+";"}try{m=Function.apply(r,u.concat("'use strict';\n"+p+e)),a.evaluator=Wn(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=textBuffer=u=null}}}function G(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":Dn(e.value)}).join(" + ")),Y(e,t,n),n.evaluator&&!r&&(n.handler=Rt[n.handlerName||n.type],$(n))}function Z(e){return null==e?"":e}function J(e,t,n){return t.param.replace(/\w+/g,function(a){var r=avalon.duplexHooks[a];r&&"function"==typeof r[n]&&(e=r[n](e,t))}),e}function Q(){for(var e=ca.length-1;e>=0;e--){var t=ca[e];t()===!1&&ca.splice(e,1)}ca.length||clearInterval(sa)}function K(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);n.$stamp&&r.insertBefore(n.$stamp,r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function et(e,t){var n=e.proxies[t];return n?n.$stamp:e.element}function tt(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function nt(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},a=d(t,n),r=a.$events;return r[e]=r.$first=r.$last=r.$index,a.$id=Ht("$proxy$each"),a}function at(e,t){for(var n,a=t.param||"el",r=0,i=pa.length;i>r;r++){var o=pa[r];o&&o.hasOwnProperty(a)&&(n=o,pa.splice(r,1))}n||(n=nt(a));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 rt(){var e=d({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Ht("$proxy$with"),e}function it(e,t){var n=va.pop();n||(n=rt());var a=t.$repeat;return n.$key=e,n.$host=a,n.$outer=t.$outer,a.$events?n.$events.$val=a.$events[e]:n.$events={},n}function ot(e,t){var n="each"===t?pa:va;avalon.each(e,function(e,t){if(t.$events){for(var a in t.$events)Array.isArray(t.$events[a])&&(t.$events[a].forEach(function(e){"object"==typeof e&&C(e)}),t.$events[a].length=0);t.$host=t.$outer={},n.unshift(t)>u.maxRepeatSize&&n.pop()}}),"each"===t&&(e.length=0)}function lt(e,t){var n="_"+e;if(!lt[n]){var a=ft.createElement(e);Ot.appendChild(a),t=Mt?getComputedStyle(a,null).display:a.currentStyle.display,Ot.removeChild(a),lt[n]=t}return lt[n]}function st(e,t,n,a){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var r=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):0,o="undefined"==typeof a?",":a,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=(i?c(r,i):""+Math.round(r)).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 ct(){Xt&&(wa["domReady!"].state=4,Xt.checkDeps()),Ca.forEach(function(e){e(avalon)}),ct=r}var ut=Date.now(),ft=e.document,pt=ft.head;pt.insertAdjacentHTML("afterBegin",'<avalon ms-skip class="avalonHide"><style id="avalonStyle">.avalonHide{ display: none!important }</style></avalon>');var vt=pt.firstChild,dt="$"+ut,ht=e.require,mt=e.define,gt=!1,yt=/[^, ]+/g,bt=/^(?:object|array)$/,$t=/^\[object SVG\w*Element\]$/,xt=/^\[object (?:Window|DOMWindow|global)\]$/,wt=Object.prototype,Ct=wt.hasOwnProperty,At=wt.toString,Tt=Array.prototype,Et=Tt.slice,kt={},Mt=e.dispatchEvent,Ot=ft.documentElement,Nt=ft.createDocumentFragment(),Lt=ft.createElement("div"),St={};"Boolean Number String Function Array Date RegExp Object Error".replace(yt,function(e){St["[object "+e+"]"]=e.toLowerCase()});var Ht=function(e){return e=e||"avalon",(e+Math.random()+Math.random()).replace(/0\./g,"")},jt=l();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?St[At.call(e)]||"object":typeof e};var Pt=function(e){return"[object Function]"===At.call(e)};avalon.isFunction=Pt,avalon.isWindow=function(e){return xt.test(At.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===At.call(e)&&Object.getPrototypeOf(e)===wt},avalon.mix=avalon.fn.mix=function(){var e,t,n,a,r,i,o=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[1]||{},l++),"object"==typeof o||Pt(o)||(o={}),l===s&&(o=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e)n=o[t],a=e[t],o!==a&&(c&&a&&(avalon.isPlainObject(a)||(r=Array.isArray(a)))?(r?(r=!1,i=n&&Array.isArray(n)?n:[]):i=n&&avalon.isPlainObject(n)?n:{},o[t]=avalon.mix(c,i,a)):void 0!==a&&(o[t]=a));return o},avalon.mix({rword:yt,subscribers:dt,version:1.391,ui:{},log:n,slice:function(e,t,n){return Et.call(e,t,n)},noop:r,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 a=-1,r=Math.max(0,Math.ceil((t-e)/n)),i=new Array(r);++a<r;)i[a]=e,e+=n;return i},eventHooks:{},bind:function(e,t,n,a){var r=avalon.eventHooks,i=r[t];return"object"==typeof i&&(t=i.type,i.deel&&(n=i.deel(e,t,n,!0))),n.unbind||e.addEventListener(t,n,!!a),n},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))),e.removeEventListener(t,l,!!a)},css:function(e,t,n){e instanceof avalon&&(e=e[0]);var a,r=/[_-]/.test(t)?F(t):t;if(t=avalon.cssName(r)||r,void 0===n||"boolean"==typeof n){a=Nn[r+":get"]||Nn["@:get"],"background"===t&&(t="backgroundColor");var i=a(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[r]&&(n+="px"),a=Nn[r+":set"]||Nn["@:set"],a(e,t,n)}},each:function(e,t){if(e){var n=0;if(s(e))for(var a=e.length;a>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(),a={};for(var r in n)0===r.indexOf(t)&&(a[r.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[r]);return a},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 Dt=avalon.bindingHandlers={},Rt=avalon.bindingExecutors={};if(avalon.nextTick=e.setImmediate?setImmediate.bind(e):function(e){setTimeout(e,0)},Ot.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),avalon.contains=function(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}},e.SVGElement){var It="http://www.w3.org/2000/svg",_t=ft.createElementNS(It,"svg");_t.innerHTML='<circle cx="50" cy="50" r="40" fill="red" />',$t.test(_t.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,a=avalon.parseHTML(e);if("svg"===t)n.insertBefore(a,this);else{var r=ft.createDocumentFragment();c(a,r),n.insertBefore(r,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);c(t,this)}}}})}var Ft=avalon.eventHooks;"onmouseenter"in Ot||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Ft[e]={type:t,deel:function(t,n){return function(a){var r=a.relatedTarget;return r&&(r===t||16&t.compareDocumentPosition(r))?void 0:(delete a.type,a.type=e,n.call(t,a))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!Ft.animationend&&(Ft.animationend={type:n})}),void 0===ft.onmousewheel&&(Ft.mousewheel={type:"wheel",deel:function(e,t){return function(n){n.wheelDeltaY=n.wheelDelta=n.deltaY>0?-120:120,n.wheelDeltaX=0,Object.defineProperty(n,"type",{value:"mousewheel"}),t.call(e,n)}}});var Bt,Ut,Vt,qt,Wt,zt=/[-.*+?^${}()|[\]\/\\]/g,Xt=r,Yt={loader:function(t){e.define=t?Xt.define:mt,e.require=t?Xt:ht},interpolate:function(e){if(Bt=e[0],Ut=e[1],Bt===Ut)throw new SyntaxError("openTag!==closeTag");if(e+""=="<!--,-->")u.commentInterpolate=!0;else{var t=Bt+"test"+Ut;if(Lt.innerHTML=t,Lt.innerHTML!==t&&Lt.innerHTML.indexOf("&lt;")>-1)throw new SyntaxError("此定界符不合法");Lt.innerHTML=""}var n=f(Bt),a=f(Ut);Vt=new RegExp(n+"(.*?)"+a),qt=new RegExp(n+"(.*?)"+a,"g"),Wt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=Yt,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var Gt={$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 a=this.$events[e]||[],r=a.length;~--r<0;)if(a[r]===t)return a.splice(r,1);return this},$fire:function(e){var t,n,a,r;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var i=this.$events,o=Et.call(arguments,1),l=[e].concat(o);if("all"===t)for(n in avalon.vmodels)a=avalon.vmodels[n],a!==this&&a.$fire.apply(a,l);else if("up"===t||"down"===t){var s=i.expr?Zt(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=Zt(a.$events.expr);if(0===c.length)continue;Array.prototype.forEach.call(c,function(e){Array.prototype.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=ft.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;(r=f[n++])&&r.$fire.apply(r,l)!==!1;);}else{var p=i[e]||[],v=i.$all||[];for(n=0;r=p[n++];)Pt(r)&&r.apply(this,o);for(n=0;r=v[n++];)Pt(r)&&r.apply(this,arguments)}}},Zt=function(e){return ft.querySelectorAll(e)},Jt=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),Jt[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var i=d(e);else{var o={$watch:r};t(o),i=d(o),gt=!0,t(i),gt=!1}return i.$id=a,Jt[a]=i};var Qt=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray").match(yt),Kt={},en=Object.defineProperty,tn=!0;try{en({},"_",{value:"x"});var nn=Object.defineProperties}catch(an){tn=!1}var rn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},on=Mt?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},ln=Tt.splice,sn={_splice:ln,_fire:function(e,t,n){E(this.$events[dt],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Tt.push.apply(this.$model,e),y.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&&(Tt.unshift.apply(this.$model,arguments),y.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return y.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return y.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=ln.apply(this.$model,arguments);return r.length&&(a.push("del",e,r.length,0),t=!0),n>2&&(t?a.splice(3,1,0,"add",e,n-2):a.push("add",e,n-2,0),t=!0),t?y.apply(this,a):[]},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),y.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 a=this[e];if("object"===n)for(var r in t)a.hasOwnProperty(r)&&(a[r]=t[r]);else"array"===n?a.clear().push.apply(a,t):a!==t&&(this[e]=t,this.$model[e]=t,this._fire("set",e,t))}return this}};"sort,reverse".replace(yt,function(e){sn[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];Tt[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(rn(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(b(this,i),this._fire("move",i),this._fire("index",0)),this}});var cn=/^(duplex|on)$/,un=avalon.$$subscribers=[],fn=new Date,pn={},vn=new function(){avalon.mix(this,{option:ft.createElement("select"),thead:ft.createElement("table"),td:ft.createElement("tr"),area:ft.createElement("map"),tr:ft.createElement("tbody"),col:ft.createElement("colgroup"),legend:ft.createElement("fieldset"),_default:ft.createElement("div"),g:ft.createElementNS("http://www.w3.org/2000/svg","svg")}),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td};String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(yt,function(e){vn[e]=vn.g});var dn=/<([\w:]+)/,hn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,mn=i(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),gn=ft.createElement("script");avalon.parseHTML=function(e){if("string"!=typeof e)return ft.createDocumentFragment();e=e.replace(hn,"<$1></$2>").trim();var t,n=(dn.exec(e)||["",""])[1].toLowerCase(),a=vn[n]||vn._default,r=Nt.cloneNode(!1);a.innerHTML=e;var i=a.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if(mn[o.type]){var s=gn.cloneNode(!1);Tt.forEach.call(o.attributes,function(e){s.setAttribute(e.name,e.value)}),s.text=o.text,o.parentNode.replaceChild(s,o)}for(;t=a.firstChild;)r.appendChild(t);return r},avalon.innerHTML=function(e,t){var n=this.parseHTML(t);this.clearHTML(e).appendChild(n)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},avalon.scan=function(e,t){e=e||Ot;var n=t?[].concat(t):[];P(e,n)};var yn=i("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),bn=function(e,t,n){var a=e.getAttribute(t);if(a)for(var r,i=0;r=n[i++];)if(r.hasOwnProperty(a)&&"function"==typeof r[a])return r[a]},$n=jt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var a=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=a}}:0,xn=/ms-(\w+)-?(.*)/,wn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Cn=i("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),An=i("value,title,alt,checked,selected,disabled,readonly,enabled"),Tn=/^if|widget|repeat$/,En=/^each|with|html|include$/,kn=/\|\s*html\s*/,Mn=/\|\|/g;rstringLiteral=/(['"])(\\\1|.)+?\1/g,"add,remove".replace(yt,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){n.classList[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&t.classList.contains(e)},toggleClass:function(e,t){for(var n,a=0,r=e.split(/\s+/),i="boolean"==typeof t;n=r[a++];){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-"+_(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return B(n);case 0:var a={};return Tt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=F(e.slice(5)),a[e]=B(t.value)))}),a}},removeData:function(e){return e="data-"+_(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 a=avalon.css(this,e,t);return void 0!==a?a:this},position:function(){var e,t,n=this[0],a={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(a=e.offset()),a.top+=avalon.css(e[0],"borderTopWidth",!0),a.left+=avalon.css(e[0],"borderLeftWidth",!0)),{top:t.top-a.top-avalon.css(n,"marginTop",!0),left:t.left-a.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,a=n?":get":":set",r=Pn[q(t)+a];if(r)var i=r(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?i:this}}),Ot.dataset&&(avalon.fn.data=function(e,t){var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],B(t);case 0:var a={};for(var e in n)a[e]=B(n[e]);return a}});var On=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;avalon.parseJSON=JSON.parse,avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var a=this[0]||{},r=U(a),i="scrollTop"===e;return arguments.length?void(r?r.scrollTo(i?avalon(r).scrollLeft():n,i?n:avalon(r).scrollTop()):a[e]=n):r?r[t]:a[e]}});var Nn=avalon.cssHooks={},Ln=["","-webkit-","-moz-","-ms-"],Sn={"float":"cssFloat"};avalon.cssNumber=i("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(Sn[e])return Sn[e];t=t||Ot.style;for(var a=0,r=Ln.length;r>a;a++)if(n=F(Ln[a]+e),n in t)return Sn[e]=n;return null},Nn["@:set"]=function(e,t,n){e.style[t]=n},Nn["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,a=getComputedStyle(e,null);return a&&(n="filter"===t?a.getPropertyValue(t):a[t],""===n&&(n=e.style[t])),n},Nn["opacity:get"]=function(e){var t=Nn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(yt,function(e){Nn[e+":get"]=function(t){var n=Nn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Hn={position:"absolute",visibility:"hidden",display:"block"},jn=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(yt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;Nn[t+":get"]=function(t,n,a){var i=-4;"number"==typeof a&&(i=a),n="Width"===e?["Left","Right"]:["Top","Bottom"];var o=t[r];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)},Nn[t+"&get"]=function(e){var n=[];V(e,n);for(var a,r=Nn[t+":get"](e),i=0;a=n[i++];){e=a.node;for(var o in a)"string"==typeof a[o]&&(e.style[o]=a[o])}return r},avalon.fn[t]=function(i){var o=this[0];if(0===arguments.length){if(o.setTimeout)return o["inner"+e];if(9===o.nodeType){var l=o.documentElement;return Math.max(o.body[a],l[a],o.body[r],l[r],l[n])}return Nn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return Nn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return Nn[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,a=n.documentElement,r=n.defaultView;return a.contains(e)?(void 0!==e.getBoundingClientRect&&(t=e.getBoundingClientRect()),{top:t.top+r.pageYOffset-a.clientTop,left:t.left+r.pageXOffset-a.clientLeft}):t};var Pn={"select:get":function(e,t){for(var n,a=e.options,r=e.selectedIndex,i="select-one"===e.type||0>r,o=i?null:[],l=i?r+1:a.length,s=0>r?l:i?r:0;l>s;s++)if(n=a[s],(n.selected||s===r)&&!n.disabled){if(t=n.value,i)return t;
2
- o.push(t)}return o},"select:set":function(e,t,n){t=[].concat(t);for(var a,r=0;a=e.options[r++];)(a.selected=t.indexOf(a.value)>-1)&&(n=!0);n||(e.selectedIndex=-1)}},Dn=JSON.stringify,Rn="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",In=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,_n=/[^\w$]+/g,Fn=new RegExp(["\\b"+Rn.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Bn=/\b\d[^,]*/g,Un=/^,+|,+$/g,Vn=o(512),qn=function(e){var t=","+e.trim();if(Vn[t])return Vn[t];var n=e.replace(In,"").replace(_n,",").replace(Fn,"").replace(Bn,"").replace(Un,"").split(/^$|,+/);return Vn(t,z(n))},Wn=o(128),zn=/\w\[.*\]|\w\.\w/,Xn=/(\$proxy\$[a-z]+)\d+$/,Yn=/\)\s*$/,Gn=/\)\s*\|/g,Zn=/\|\s*([$\w]+)/g,Jn=/"\s*\["/g,Qn=/"\s*\(/g;avalon.parseExprProxy=G;var Kn="autofocus,autoplay,async,allowTransparency,checked,controls,declare,disabled,defer,defaultChecked,defaultSelectedcontentEditable,isMap,loop,multiple,noHref,noResize,noShade,open,readOnly,selected",ea={};Kn.replace(yt,function(e){ea[e.toLowerCase()]=e});var ta={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},na="accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan,dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight,rowSpan,tabIndex,useMap,vSpace,valueType,vAlign";na.replace(yt,function(e){ta[e.toLowerCase()]=e});var aa=/<noscript.*?>(?:[\s\S]+?)<\/noscript>/gim,ra=/<noscript.*?>([\s\S]+?)<\/noscript>/im,ia=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},oa=avalon.templateCache={};Dt.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Bt)>-1&&n.indexOf(Ut)>2&&(a=!1,Vt.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(a=!0,n=RegExp.$1)),"include"===e.type){var r=e.element;e.includeRendered=bn(r,"data-include-rendered",t),e.includeLoaded=bn(r,"data-include-loaded",t);var i=e.includeReplaced=!!avalon(r).data("includeReplace");e.startInclude=ft.createComment("ms-include"),e.endInclude=ft.createComment("ms-include-end"),i?(e.element=e.startInclude,r.parentNode.insertBefore(e.startInclude,r),r.parentNode.insertBefore(e.endInclude,r.nextSibling)):(r.insertBefore(e.startInclude,r.firstChild),r.appendChild(e.endInclude))}e.handlerName="attr",G(n,t,e,a?0:R(e.value))},Rt.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){if(ea[i]){var o=ea[i];if("boolean"==typeof n[o])return n[o]=!!t}var l=t===!1||null===t||void 0===t;if(!Mt&&ta[i]&&(i=ta[i]),l)return n.removeAttribute(i);var s=$t.test(n)?!1:ft.namespaces&&isVML(n)?!0:i in n.cloneNode(!1);s?n[i]=t:n.setAttribute(i,t)}else if("include"===r&&t){var c=a.vmodels,u=a.includeRendered,f=a.includeLoaded,p=a.includeReplaced,v=p?n.parentNode:n,d=function(e){for(f&&(e=f.apply(v,[e].concat(c))),u&&k(v,function(){u.call(v)},0/0);;){var t=a.startInclude.nextSibling;if(!t||t===a.endInclude)break;v.removeChild(t)}var n=avalon.parseHTML(e),r=avalon.slice(n.childNodes);v.insertBefore(n,a.endInclude),H(r,c)};if("src"===a.param)if(oa[t])avalon.nextTick(function(){d(oa[t])});else{var h=ia();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;(e>=200&&300>e||304===e||1223===e)&&d(oa[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:ft.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=ia(),h.open("GET",location,!1),h.send(null);for(var g=ft.getElementsByTagName("noscript"),y=(h.responseText||"").match(aa)||[],b=y.length,$=0;b>$;$++){var x=g[$];x&&(x.style.display="none",x.fixIE78=(y[$].match(ra)||["","&nbsp;"])[1])}}avalon.nextTick(function(){d(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Ot.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&amp;/g,"&")),n[r]=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(yt,function(e){Dt[e]=Dt.attr}),Dt["class"]=function(e,t){var a,r=e.param,i=e.value;if(e.handlerName="class",!r||isFinite(r)){e.param="";var o=i.replace(qt,function(e){return e.replace(/./g,"0")}),l=o.indexOf(":");if(-1===l)var s=i;else{if(s=i.slice(0,l),a=i.slice(l+1),Y(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=Vt.test(s);c||(e.immobileClass=s),G("",t,e,c?R(s):0)}else e.immobileClass=e.oldStyle=e.param,G(i,t,e)},Rt["class"]=function(e,t,n){var a=avalon(t),r=n.type;if("class"===r&&n.oldStyle)a.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&&a.removeClass(n.oldClass),n.oldClass=n.newClass,r){case"class":a.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var i="mouseenter",o="mouseleave";if("active"===r){t.tabIndex=t.tabIndex||-1,i="mousedown",o="mouseup";var l=a.bind("mouseleave",function(){n.toggleClass&&a.removeClass(n.newClass)})}var s=a.bind(i,function(){n.toggleClass&&a.addClass(n.newClass)}),c=a.bind(o,function(){n.toggleClass&&a.removeClass(n.newClass)});n.rollback=function(){a.unbind("mouseleave",l),a.unbind(i,s),a.unbind(o,c)},n.hasBindEvent=!0}}},"hover,active".replace(yt,function(e){Dt[e]=Dt["class"]}),Rt.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var la=Dt.duplex=function(e,t){var a,o=e.element;if(G(e.value,t,e,0,1),e.changed=bn(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 a=e.rollback;e.rollback=function(){o.avalonSetter=null,avalon.unbind(o,t,n),a&&a()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=J);f(null,e,"init");var p=o.tagName;la[p]&&la[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:Z},"boolean":{get:function(e){return"true"===e},set:Z},number:{get:function(e){return isFinite(e)?parseFloat(e)||0:e},set:Z}};var sa,ca=[];avalon.tick=function(e){1===ca.push(e)&&(sa=setInterval(Q,60))};var ua=r;!new function(){function e(e){avalon.contains(Ot,this)&&(t[this.tagName].call(this,e),this.avalonSetter&&this.avalonSetter())}try{var t={},n=HTMLInputElement.prototype,a=HTMLTextAreaElement.prototype,r=HTMLInputElement.prototype;Object.getOwnPropertyNames(r),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(a,"value").set,Object.defineProperty(a,"value",{set:e})}catch(i){ua=avalon.tick}},la.INPUT=function(e,t,a){function r(e){a.changed.call(this,e,a)}function i(){f=!0}function o(){f=!1}function l(){if(!f){var n=e.oldValue=e.value,i=a.pipe(n,a,"get");u.data("duplex-observe")!==!1&&(t(i),r.call(e,i),u.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}}var s=e.type,c=a.bound,u=avalon(e),f=!1;if(a.handler=function(){var n=a.pipe(t(),a,"set")+"";n!==e.oldValue&&(e.value=n)},a.isChecked||"radio"===e.type)l=function(){if(u.data("duplex-observe")!==!1){var n=a.pipe(e.value,a,"get");t(n),r.call(e,n)}},a.handler=function(){var n=t(),r=a.isChecked?!!n:n+""===e.value;e.checked=e.oldValue=r},c("click",l);else if("checkbox"===s)l=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,a.pipe(e.value,a,"get")),r.call(e,o)}},a.handler=function(){var n=[].concat(t());e.checked=n.indexOf(a.pipe(e.value,a,"get"))>-1},c("change",l);else{var p=e.getAttribute("data-duplex-event")||e.getAttribute("data-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),p.replace(yt,function(e){switch(e){case"input":c("input",l),c("DOMAutoComplete",l),jt||(c("compositionstart",i),c("compositionend",o));break;default:c(e,l)}})}/text|password/.test(e.type)&&ua(function(){if(Ot.contains(e))e.value!==e.oldValue&&l();else if(!e.msRetain)return!1}),e.avalonSetter=l,e.oldValue=e.value,$(a),r.call(e,e.value)},la.TEXTAREA=la.INPUT,la.SELECT=function(e,t,a){function r(){if(i.data("duplex-observe")!==!1){var n=i.val();n=Array.isArray(n)?n.map(function(e){return a.pipe(e,a,"get")}):a.pipe(n,a,"get"),n+""!==e.oldValue&&t(n),a.changed.call(e,n,a)}}var i=avalon(e);a.handler=function(){var a=t();a=a&&a.$model||a,Array.isArray(a)?e.multiple||n("ms-duplex在<select multiple=true>上要求对应一个数组"):e.multiple&&n("ms-duplex在<select multiple=false>不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),k(e,function(){$(a),a.changed.call(e,t(),a)},0/0)},Rt.html=function(e,t,n){e=null==e?"":e;var a="group"in n,r=a?t.parentNode:t;if(r){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=Nt.cloneNode(!0);o[0];)i.appendChild(o[0])}else i=avalon.parseHTML(e);var l=ft.createComment("ms-html");if(a){r.insertBefore(l,t);for(var s=n.group,c=1;s>c;){var u=t.nextSibling;u&&(r.removeChild(u),c++)}r.removeChild(t),n.element=l}else avalon.clearHTML(r).appendChild(l);a&&(n.group=i.childNodes.length||1),o=avalon.slice(i.childNodes),o[0]&&(l.parentNode&&l.parentNode.replaceChild(i,l),a&&(n.element=o[0])),H(o,n.vmodels)}},Dt["if"]=Dt.data=Dt.text=Dt.html=function(e,t){G(e.value,t,e)},Rt["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),L(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var a=n.element=ft.createComment("ms-if");t.parentNode.replaceChild(a,t),n.template=t,vt.appendChild(t),n.rollback=function(){t.parentNode===vt&&vt.removeChild(t)}}};var fa=/\(([^)]*)\)/;Dt.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof Dt.on[a+"Hook"]&&Dt.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(fa)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(fa,""))}G(n,t,e)},Rt.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)}},Dt.repeat=function(e,t){var n=e.type;G(e.value,t,e,0,1),e.proxies=[];var a=!1;try{var r=e.$repeat=e.evaluator.apply(0,e.args||[]),i=avalon.type(r);"object"!==i&&"array"!==i&&(a=!0,avalon.log("warning:"+e.value+"对应类型不正确"))}catch(o){a=!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[dt]=f[dt]||[],f[dt].push(e);break}}var p=e.element;p.removeAttribute(e.name),e.sortedCallback=bn(p,"data-with-sorted",t),e.renderedCallback=bn(p,"data-"+n+"-rendered",t);var v=Ht(n),d=e.element=ft.createComment(v+":end");if(e.clone=ft.createComment(v),Nt.appendChild(d),"each"===n||"with"===n?(e.template=p.innerHTML.trim(),avalon.clearHTML(p).appendChild(d)):(e.template=p.outerHTML.trim(),p.parentNode.replaceChild(d,p)),e.template=avalon.parseHTML(e.template),e.rollback=function(){var t=e.element;if(t){Rt.repeat.call(e,"clear");var n=t.parentNode,a=e.template,r=a.firstChild;n.replaceChild(a,t);var i=e.$stamp;i&&i.parentNode&&i.parentNode.removeChild(i),r=e.element="repeat"===e.type?r:n}},!a){e.handler=Rt.repeat,e.$outer={};var h="$key",m="$val";for(Array.isArray(r)&&(h="$first",m="$last"),u=0;s=t[u++];)if(s.hasOwnProperty(h)&&s.hasOwnProperty(m)){e.$outer=s;break}var g=r.$events,y=(g||{})[dt];if(y&&avalon.Array.ensure(y,e)&&w(e,y),"object"===i){e.$with=!0;var b=g?g.$withProxyPool||(g.$withProxyPool={}):{};e.handler("append",r,b)}else r.length&&e.handler("add",0,r.length)}},Rt.repeat=function(e,t,n){if(e){var a=this,i=a.element,o=i.parentNode,l=a.proxies,s=Nt.cloneNode(!1);switch(e){case"add":for(var c,u=t+n,f=a.$repeat,p=f.length-1,v=[],d=et(a,t),h=t;u>h;h++){var m=at(h,a);l.splice(h,0,m),K(a,s,m,v)}for(o.insertBefore(s,d),h=0;c=v[h++];)H(c.nodes,c.vmodels),c.nodes=c.vmodels=null;break;case"del":d=l[t].$stamp,i=et(a,t+n),tt(d,i);var g=l.splice(t,n);ot(g,"each");break;case"clear":var y=a.$stamp||l[0];y&&(d=y.$stamp||y,tt(d,i)),ot(l,"each");break;case"move":d=l[0].$stamp;var $,x=d.nodeValue,w=[],C=[];for(tt(d,i,function(){C.unshift(this),this.nodeValue===x&&(w.unshift(C),C=[])}),b(l,t),b(w,t);C=w.shift();)for(;$=C.shift();)s.appendChild($);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&&E(m.$events.$index));case"append":var A=n,T=[];v=[];for(var M in t)t.hasOwnProperty(M)&&"hasOwnProperty"!==M&&T.push(M);if(a.sortedCallback){var O=a.sortedCallback.call(o,T);O&&Array.isArray(O)&&O.length&&(T=O)}for(h=0;M=T[h++];)"hasOwnProperty"!==M&&(A[M]||(A[M]=it(M,a)),K(a,s,A[M],v));var N=a.$stamp=a.clone;for(o.insertBefore(N,i),o.insertBefore(s,i),h=0;c=v[h++];)H(c.nodes,c.vmodels),c.nodes=c.vmodels=null}"clear"===e&&(e="del");var L=a.renderedCallback||r,S=arguments;k(o,function(){L.apply(o,S),o.oldValue&&"SELECT"===o.tagName&&avalon(o).val(o.oldValue.split(","))},0/0)}},"with,each".replace(yt,function(e){Dt[e]=Dt.repeat});var pa=[],va=[];Rt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=lt,Dt.visible=function(e,t){var n=avalon(e.element),a=n.css("display");if("none"===a){var r=n[0].style,i=/visibility/i.test(r.cssText),o=n.css("visibility");r.display="",r.visibility="hidden",a=n.css("display"),"none"===a&&(a=lt(n[0].nodeName)),r.visibility=i?o:""}e.display=a,G(e.value,t,e)},Rt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Dt.widget=function(t,n){var a=t.value.match(yt),i=t.element,o=a[0],l=a[1];l&&"$"!==l||(l=Ht(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 v=p[o+"Id"];"string"==typeof v&&(l=v)}var d=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||{},d);i.removeAttribute("ms-widget");var m=c(i,t,n)||{};m.$id?(avalon.vmodels[l]=m,M(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]},w(t,da),e.chrome&&i.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(T)})):avalon.scan(i,n)}else n.length&&(i.vmodels=n)};var da=[],ha=/<script[^>]*>([\S\s]*?)<\/script\s*>/gim,ma=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,ga=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,ya={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},ba=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,$a=/([^\#-~| |!])/g,xa=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 a=arguments[t],r=avalon.filters[a.shift()];if("function"==typeof r){var i=[e].concat(a);e=r.apply(null,i)}}return e},camelize:F,sanitize:function(e){return e.replace(ha,"").replace(ga,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=ya[t[1]];n&&(e=e.replace(n,function(e,t,n){var a=n.charAt(0);return t+"="+a+"javascript:void(0)"+a}))}return e.replace(ma," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&amp;").replace(ba,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace($a,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},currency:function(e,t,n){return(t||"¥")+st(e,isFinite(n)?n:2)},number:function(e,t){return st(e,isFinite(t)?t:3)}};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var a="";for(0>e&&(a="-",e=-e),e=""+e;e.length<t;)e="0"+e;return n&&(e=e.substr(e.length-t)),a+e}function n(e,n,a,r){return function(i){var o=i["get"+e]();return(a>0||o>-a)&&(o+=a),0===o&&-12===a&&(o=12),t(o,n,r)}}function a(e,t){return function(n,a){var r=n["get"+e](),i=(t?"SHORT"+e:e).toUpperCase();return a[i][r]}}function r(e){var n=-1*e.getTimezoneOffset(),a=n>=0?"+":"";return a+=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:a("Month"),MMM:a("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:a("Day"),EEE:a("Day",!0),a:i,Z:r},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;xa.date=function(t,n){var a,r,i=xa.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],v=new Date(0);f=f.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,a,r){var i=4===r.length?[r,n,a]:[n,a,r];return p[0]=e(i[0]),p[1]=e(i[1])-1,p[2]=e(i[2]),""});var d=v.setFullYear,h=v.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,a,r,i){return p[3]=e(n),p[4]=e(a),p[5]=e(r),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,a,r){return d=v.setUTCFullYear,h=v.setUTCHours,n&&(m=e(n+a),g=e(n+r)),""}),p[3]-=m,p[4]-=g,d.apply(v,p.slice(0,3)),h.apply(v,p.slice(3)),t=v}if("number"==typeof t&&(t=new Date(t)),"date"===avalon.type(t)){for(;n;)r=l.exec(n),r?(u=u.concat(r.slice(1)),n=u.pop()):(u.push(n),n=null);return u.forEach(function(e){a=o[e],c+=a?a(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"};c.SHORTMONTH=c.MONTH,xa.date.locate=c};var wa=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};wa.exports=wa.avalon,new function(){function t(e,t){var a="js";e=e.replace(/^(\w+)\!/,function(e,t){return a=t,""}),"ready"===a&&(n("debug: ready!已经被废弃,请使用domReady!"),a="domReady");var r="";e=e.replace(P,function(e){return r=e,""});var i="."+a,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:r,ext:o,res:a,name:e,toUrl:h},t);return l.toUrl(e),l}function i(e){var t=e.name,n=e.res,a=wa[t],r=t&&e.urlNoQuery;if(a&&a.state>=3)return t;if(a=wa[r],a&&a.state>=3)return Xt(a.deps||[],a.factory,r),r;if(t&&!a){a=wa[r]={id:r,state:1};var i=function(r){j[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,s()})};j[n]?i(j[n]):Xt([n],i)}return t?r:n+"!"}function o(e,t){for(var n,a=0;n=e[a++];)if(4!==wa[n].state&&(n===t||o(wa[n].deps,t)))return!0}function l(e,t){var a=f(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){pt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!wa[a].state)):!0}function s(){e:for(var e,t=A.length;e=A[--t];){var n=wa[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++){var o=k[r];if(o&&(r=a[i]=o),4!==Object(wa[r]).state)continue e}4!==n.state&&(A.splice(t,1),d(n.id,n.deps,n.factory),s())}}}function c(e,t,a){var r=ft.createElement("script");r.className=dt,r.onload=function(){var r=T.pop();r&&r.require(t),a&&a(),n("debug: 已成功加载 "+e),t&&A.push(t),s()},r.onerror=function(){l(r,!0)},pt.appendChild(r),r.src=e,n("debug: 正准备加载 "+e)}function f(e){return(e||"").replace(P,"")}function p(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function v(){var e;try{a.b.c()}catch(t){e=t.stack}if(e)return e=e.split(/[@ ]/g).pop(),e="("===e[0]?e.slice(1,-1):e.replace(/\s/,""),f(e.replace(/(:\d+)?:\d+$/i,""));for(var n,r=pt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===dt&&"interactive"===n.readyState){var o=n.src;return n.className=f(o)}}function d(t,n,a){var r=Object(wa[t]);r.state=4;for(var i,o=0,l=[];i=n[o++];)if(i=k[i]||i,"exports"===i){var s=r.exports||(r.exports={});l.push(s)}else l.push(wa[i].exports);var c=a.apply(e,l);return void 0!==c&&(r.exports=c),delete r.factory,c}function h(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,a=this.baseUrl,r=this.parentUrl||a;$(e,u.paths,function(e,a){t=t.replace(a,e),n=1}),n||$(e,u.packages,function(e,n,a){t=t.replace(a.name,a.location)}),this.mapUrl&&$(this.mapUrl,u.map,function(e){$(t,e,function(e,n){t=t.replace(n,e),r=a})});var i=this.ext;i&&n&&t.slice(-i.length)===i&&(t=t.slice(0,-i.length)),p(t)||(r=this.built||/^\w/.test(t)?a:r,t=w(r,t));var o=t+i;return t=o+this.query,$(e,u.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=o}function m(e,t,n){var a=b(e,t,n);return a.sort(x),a}function g(e){return new RegExp("^"+e+"(/|$)")}function y(t){return function(){var n;return t.init&&(n=t.init.apply(e,arguments)),n||t.exports&&C(t.exports)}}function b(e,t,n){var a=[];for(var r in e)if(e.hasOwnProperty(r)){var i={name:r,val:e[r]};a.push(i),i.reg="*"===r&&t?/^/:g(r),n&&"*"!==r&&(i.reg=new RegExp("/"+r.replace(/^\//,"")+"(/|$)"))}return a}function $(e,t,n){t=t||[];for(var a,r=0;a=t[r++];)if(a.reg.test(e))return n(a.val,a.name,a),!1}function x(e,t){var n=e.name,a=t.name;return"*"===a?-1:"*"===n?1:a.length-n.length}function w(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;D.test(e);)e=e.replace(D,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function C(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var A=[],T=[],E=/\.js$/i,k={},M=[],O=!1;Xt=avalon.require=function(e,n,a,o){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var l=[],c={},f=a||"callback"+setTimeout("1");o=o||{},o.baseUrl=u.baseUrl;var p=!!o.built;if(a&&(o.parentUrl=a.substr(0,a.lastIndexOf("/")),o.mapUrl=a.replace(E,"")),p){var v=t(o.name,o);f=v.urlNoQuery}else e.forEach(function(e){var n=t(e,o),a=i(n);a&&(c[a]||(l.push(a),c[a]="司徒正美"))});var d=wa[f];d&&4===d.state||(wa[f]={id:f,deps:p?e.concat():l,factory:n||r,state:3}),d||A.push(f),s()}else if(M.push(avalon.slice(arguments)),arguments.length<=2){O=!0;for(var h,m=M.splice(0,M.length);h=m.shift();)Xt.apply(null,h)}},Xt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var a={built:!O,name:e},r=[t,n,a];n.require=function(e){if(r.splice(2,0,e),wa[e]){wa[e].state=3;var t=!1;try{t=o(wa[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,Xt.apply(null,r)};var i=a.built?"unknown":v();if(i){var l=wa[i];l&&(l.state=2),n.require(i)}else T.push(n)},Xt.config=u,Xt.define.amd=wa;var N=u["orig.paths"]={},L=u["orig.map"]={},S=u.packages=[],H=u["orig.args"]={};avalon.mix(Yt,{paths:function(e){avalon.mix(N,e),u.paths=m(N)},map:function(e){avalon.mix(L,e);var t=m(L,1,1);avalon.each(t,function(e,t){t.val=m(t.val)}),u.map=t},packages:function(e){e=e.concat(S);for(var t,n={},a=[],r=0;t=e[r++];){t="string"==typeof t?{name:t}:t;var i=t.name;if(!n[i]){var o=t.location?t.location:w(i,t.main||"main");o=o.replace(E,""),a.push(t),n[i]=t.location=o,t.reg=g(i)}}u.packages=a.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(H,e),u.urlArgs=m(H,1)},baseUrl:function(e){if(!p(e)){var t=pt.querySelector("base");t&&pt.removeChild(t);var n=ft.createElement("a");n.href=e,e=n.href,t&&pt.insertBefore(t,pt.firstChild)}e.length>3&&(u.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=y(n))}u.shim=e}});var j=Xt.plugins={ready:{load:r},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(E,"")];i?Xt(i.deps||[],function(){var e=avalon.slice(arguments);c(a,r,function(){n(i.exportsFn?i.exportsFn.apply(0,e):void 0)})}):c(a,r)}},css:{load:function(e,t,a){var r=t.url,i=ft.createElement("link");i.rel="stylesheet",i.href=r,pt.appendChild(i),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=ia();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):a(i.responseText)},i.open("GET",r,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};Xt.checkDeps=s;var P=/(\?[^#]*)$/,D=/\/\w+\/\.\./,R=ft.scripts[ft.scripts.length-1],I=R.getAttribute("data-main");if(I){Yt.baseUrl(I);var _=u.baseUrl;u.baseUrl=_.slice(0,_.lastIndexOf("/")+1),c(_.replace(E,"")+".js")}else{var F=f(R.src);u.baseUrl=F.slice(0,F.lastIndexOf("/")+1)}};var Ca=[];"complete"===ft.readyState?setTimeout(ct):(ft.addEventListener("DOMContentLoaded",ct),e.addEventListener("load",ct)),avalon.ready=function(e){ct===r?e(avalon):Ca.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(ft.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(){avalon.config.debug&&console.log.apply(console,arguments)}function r(){return Object.create(null)}function i(){}function o(e,t){"string"==typeof e&&(e=e.match(bt)||[]);for(var n={},a=void 0!==t?t:1,r=0,i=e.length;i>r;r++)n[e[r]]=a;return n}function l(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function s(e){if(e&&"object"==typeof e){var t=e.length,n=Tt.call(e);if(/(Array|List|Collection|Map|Arguments)\]$/.test(n))return!0;if("[object Object]"===n&&t===t>>>0)return!0}return!1}function c(e,t){if(e&&e.childNodes)for(var n,a=e.childNodes,r=0;n=a[r++];)if(n.tagName){var i=ft.createElementNS(Ft,n.tagName.toLowerCase());kt.forEach.call(n.attributes,function(e){i.setAttribute(e.name,e.value)}),c(n,i),t.appendChild(i)}}function u(e){for(var t in e)if(At.call(e,t)){var n=e[t];"function"==typeof u.plugins[t]?u.plugins[t](n):"object"==typeof u[t]?avalon.mix(u[t],n):u[t]=n}return this}function f(e){return(e+"").replace(Yt,"\\$&")}function p(e,t,n){if(Pt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;if(-1!==Kt.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function d(e,t,n,a){switch(e.type){case 0:var r=e.get,i=e.set;if(Pt(i)){var o=a.$events,l=o[t];o[t]=[],i.call(a,n),o[t]=l}return r.call(a);case 1:return n;case 2:if(n!==a.$model[t]){var s=e.svmodel=m(a,t,n,e.valueType);n=s.$model;var c=en[s.$id];c&&c()}return n}}function v(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var o=g(e);return o.pushArray(a),o}if(!e||e.nodeType>0||e.$id&&e.$events)return e;Array.isArray(e.$skipArray)||(e.$skipArray=[]),e.$skipArray.$special=t||r();var l={};n=n||{};var s=r(),c=r(),u=[];for(var f in e)!function(t,a){if(n[t]=a,p(t,a,e.$skipArray)){s[t]=[];var r=avalon.type(a),o=function(e){var t=o._name,n=this,a=n.$model,r=a[t],i=n.$events;return arguments.length?void(yt||(1===o.type||(e=d(o,t,e,n),o.type))&&(tn(r,e)||(a[t]=e,k(i[t]),h(n,t,e,r)))):0===o.type?(e=o.get.call(n),r!==e&&(a[t]=e,h(n,t,e,r)),e):(x(i[t]),o.svmodel||r)};"object"===r&&Pt(a.get)&&Object.keys(a).length<=2?(o.set=a.set,o.get=a.get,o.type=0,u.push(function(){var e={evaluator:function(){e.type=Math.random(),e.element=null,n[t]=o.get.call(l)},element:pt,type:Math.random(),handler:i,args:[]};Mt[ut]=e,o.call(l),delete Mt[ut]})):$t.test(r)?(o.type=2,o.valueType=r,u.push(function(){var e=v(a,0,n[t]);o.svmodel=e,e.$events[ht]=s[t]})):o.type=1,o._name=t,c[t]=o}}(f,e[f]);Kt.forEach(function(t){delete e[t],delete n[t]}),l=Object.defineProperties(l,nn(c),e);for(var m in e)c[m]||(l[m]=e[m]);l.$id=St(),l.$model=n,l.$events=s;for(f in Jt)l[f]=Jt[f];return Object.defineProperty(l,"hasOwnProperty",{value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0}),u.forEach(function(e){e()}),l}function h(e,t,n,a){e.$events&&Jt.$fire.call(e,t,n,a)}function m(e,t,n,a){var r=e[t];if("array"===a)return Array.isArray(n)&&r!==n?(r._.$unwatch(),r.clear(),r._.$watch(),r.pushArray(n.concat()),r):r;var i=e.$events[t],o=r.$events.$withProxyPool;o&&(lt(o,"with"),r.$events.$withProxyPool=null);var l=v(n);return l.$events[ht]=i,en[l.$id]=function(e){for(;e=i.shift();)!function(e){avalon.nextTick(function(){var t=e.type;t&&Rt[t]&&(e.rollback&&e.rollback(),Rt[t](e,e.vmodels))})}(e);delete en[l.$id]},l}function g(e){var t=[];t.$id=St(),t.$model=e,t.$events={},t.$events[ht]=[],t._=v({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in Jt)t[n]=Jt[n];return avalon.mix(t,rn),t}function y(e,t,n,a,r,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 $t.test(avalon.type(e))?e.$id?e:v(e,0,e):e});an.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)}r&&(e=r,t=i,n=o,s=2,r=0)}return this._fire("index",a),this.length!==l&&(this._.length=this.length),u}function b(e,t){for(var n={},a=0,r=t.length;r>a;a++){n[a]=e[a];var i=t[a];i in n?(e[a]=n[i],delete n[i]):e[a]=e[i]}}function $(e){Mt[ut]=e,avalon.openComputedCollect=!0;var t=e.evaluator;if(t)try{var n=on.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(a){delete e.evaluator;var r=e.element;if(3===r.nodeType){var i=r.parentNode;u.commentInterpolate?i.replaceChild(ft.createComment(e.value),r):r.data=Vt+e.value+qt}}avalon.openComputedCollect=!1,delete Mt[ut]}function x(e){var t=Mt[ut];e&&t&&avalon.Array.ensure(e,t)&&t.element&&w(t,e)}function w(e,t){e.$uuid=e.$uuid||St(),t.$uuid=t.$uuid||St();var n={data:e,list:t,$$uuid:e.$uuid+t.$uuid};ln[n.$$uuid]||(ln[n.$$uuid]=1,ln.push(n))}function C(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function A(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:!Nt.contains(e):!avalon.contains(Nt,e)}function T(){for(var e,t=ln.length,n=t,a=0,r=[],i={},o={};e=ln[--t];){var l=e.data,s=l.type;i[s]?i[s]++:(i[s]=1,r.push(s))}var c=!1;if(r.forEach(function(e){cn[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]&&A(l.element)&&(a++,ln.splice(t,1),delete ln[e.$$uuid],avalon.Array.remove(e.list,l),C(l),e.data=e.list=null);cn=i,sn=new Date}function k(e){if(e&&e.length){new Date-sn>444&&"object"==typeof e[0]&&T();for(var t,n=Et.call(arguments,1),a=e.length;t=e[--a];){var r=t.element;if(r&&r.parentNode)if(t.$repeat)t.handler.apply(t,n);else if("on"!==t.type){var o=t.evaluator||i;t.handler(o.apply(0,t.args||[]),r,t)}}}}function E(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():E(e,t,r)})}function M(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function O(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,Rt[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function N(e,t){return e.priority-t.priority}function L(e,t){for(var a,i,o=e.hasAttributes()?avalon.slice(e.attributes):[],l=[],s=r(),c=0;i=o[c++];)if(i.specified&&(a=i.name.match(bn))){var u=a[1],f=a[2]||"",p=i.value,d=i.name;if(s[d]=p,xn[u]?(f=u,u="on"):wn[u]&&(n("warning!请改用ms-attr-"+u+"代替ms-"+u+"!"),"enabled"===u&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),u="disabled",p="!("+p+")"),f=u,u="attr",e.removeAttribute(d),d="ms-attr-"+f,e.setAttribute(d,p),a=[d],s[d]=p),"function"==typeof Rt[u]){var v={type:u,param:f,element:e,name:a[0],value:p,priority:u in $n?$n[u]:10*u.charCodeAt(0)+(Number(f)||0)};if("html"===u||"text"===u){var h=P(p);avalon.mix(v,h),v.filters=v.filters.replace(Tn,function(){return v.type="html",v.group=1,""})}"ms-if-loop"===d&&(v.priority+=100),t.length&&(l.push(v),"widget"===u&&(e.msData=e.msData||s))}}var m=e.type;m&&s["ms-duplex"]&&(s["ms-attr-checked"]&&/radio|checkbox/.test(m)&&n("warning!"+m+"控件不能同时定义ms-attr-checked与ms-duplex"),s["ms-attr-value"]&&/text|password/.test(m)&&n("warning!"+m+"控件不能同时定义ms-attr-value与ms-duplex")),l.sort(N);var g=!0;for(c=0;v=l[c];c++){if(u=v.type,Cn.test(u))return O(l.slice(0,c+1),t);g&&(g=!An.test(u))}O(l,t),g&&!mn[e.tagName]&&Xt.test(e.innerHTML+e.textContent)&&(yn&&yn(e),j(e,t))}function j(e,t){for(var n=e.firstChild;n;){var a=n.nextSibling;S(n,n.nodeType,t),n=a}}function H(e,t){for(var n,a=0;n=e[a++];)S(n,n.nodeType,t)}function S(e,t,n){1===t?D(e,n):3===t&&zt.test(e.data)?I(e,n):u.commentInterpolate&&8===t&&!zt.test(e.nodeValue)&&I(e,n)}function D(e,t,n){var a=e.getAttribute("ms-skip"),r=e.getAttributeNode("ms-important"),i=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(n=r||i){var o=avalon.vmodels[n.value];if(!o)return;t=n===r?[o]:[o].concat(t),e.removeAttribute(n.name),e.classList.remove(n.name),M(e,o)}L(e,t)}}function P(e){if(e.indexOf("|")>0){var t=e.replace(rstringLiteral,function(e){return Array(e.length+1).join("1")}),n=t.replace(kn,"ᄢ㍄").indexOf("|");if(n>-1)return{filters:e.slice(n),value:e.slice(0,n),expr:!0}}return{value:e,filters:"",expr:!0}}function R(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Vt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Vt.length,n=e.indexOf(qt,r),-1===n)break;t=e.slice(r,n),t&&a.push(P(t)),r=n+qt.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function I(e,t){var n=[];if(8===e.nodeType)var a=P(e.nodeValue),r=[a];else r=R(e.data);if(r.length){for(var i=0;a=r[i++];){var o=ft.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(Tn,function(){return a.type="html",a.group=1,""}),n.push(a)),Lt.appendChild(o)}e.parentNode.replaceChild(Lt,e),n.length&&O(n,t)}}function _(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function F(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function B(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:En.test(e)?JSON.parse(e):e}catch(t){}return e}function U(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function V(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(jn.test(n.display)){var a={node:e};for(var r in Ln)a[r]=n[r],e.style[r]=Ln[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&V(i,t)}}function q(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function z(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=e.length;r=e[--l];)t.hasOwnProperty(r)&&(i.push(r+o+r),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+r),e.splice(l,1));return i}function W(e){for(var t=[],n={},a=0;a<e.length;a++){var r=e[a],i=r&&"string"==typeof r.$id?r.$id:r;n[i]||(n[i]=t.push(r))}return t}function X(e,t){return t=t.replace(Wn,"").replace(Xn,function(){return"],|"}).replace(Yn,function(e,t){return"["+Sn(t)}).replace(Gn,function(){return'"],["'}).replace(Zn,function(){return'",'})+"]","return avalon.filters.$filter("+e+", "+t+")"}function Y(e,t,a){var r=a.type,o=a.filters||"",l=t.map(function(e){return String(e.$id).replace(zn,"$1")})+e+r+o,s=Un(e).concat(),c=[],u=[],f=[],p="";t=W(t),a.vars=[];for(var d=0,v=t.length;v>d;d++)if(s.length){var h="vm"+ut+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,z(s,t[d],h,a))}if(c.length||"duplex"!==r){"duplex"!==r&&(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 a=n.charAt(t.length),r=Dt?e.slice(arguments[1]+n.length):RegExp.rightContext,i=/^\s*\(/.test(r);if("."===a||"["===a||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=Vn.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"+ut+" = "+e+";\r\n",e+=X("ret"+ut,o)}else{if("duplex"===r){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(qn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(i,u.concat(g)),a.evaluator=Vn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}return}if("on"===r){-1===e.indexOf("(")?e+=".call(this, $event)":e=e.replace("(",".call(this,"),u.push("$event"),e="\nreturn "+e+";";var b=e.lastIndexOf("\nreturn"),$=e.slice(0,b),x=e.slice(b);e=$+"\n"+x}else e="\nreturn "+e+";"}try{m=Function.apply(i,u.concat("'use strict';\n"+p+e)),a.evaluator=Vn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function G(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":Sn(e.value)}).join(" + ")),Y(e,t,n),n.evaluator&&!r&&(n.handler=It[n.handlerName||n.type],$(n))}function Z(e,t,n){var a=e.templateCache&&e.templateCache[t];if(a){for(var r,i=ft.createDocumentFragment();r=a.firstChild;)i.appendChild(r);return i}return avalon.parseHTML(n)}function J(e){return null==e?"":e}function Q(e,t,n){return t.param.replace(/\w+/g,function(a){var r=avalon.duplexHooks[a];r&&"function"==typeof r[n]&&(e=r[n](e,t))}),e}function K(){for(var e=la.length-1;e>=0;e--){var t=la[e];t()===!1&&la.splice(e,1)}la.length||clearInterval(oa)}function et(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);n.$stamp&&r.insertBefore(n.$stamp,r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function tt(e,t){var n=e.proxies[t];return n?n.$stamp:e.element}function nt(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function at(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},a=v(t,n),r=a.$events;return r[e]=r.$first=r.$last=r.$index,a.$id=St("$proxy$each"),a}function rt(e,t){for(var n,a=t.param||"el",r=0,i=fa.length;i>r;r++){var o=fa[r];o&&o.hasOwnProperty(a)&&(n=o,fa.splice(r,1))}n||(n=at(a));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 it(){var e=v({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=St("$proxy$with"),e}function ot(e,t){var n=pa.pop();n||(n=it());var a=t.$repeat;return n.$key=e,n.$host=a,n.$outer=t.$outer,a.$events?n.$events.$val=a.$events[e]:n.$events={},n}function lt(e,t){var n="each"===t?fa:pa;avalon.each(e,function(e,t){if(t.$events){for(var a in t.$events)Array.isArray(t.$events[a])&&(t.$events[a].forEach(function(e){"object"==typeof e&&C(e)}),t.$events[a].length=0);t.$host=t.$outer={},n.unshift(t)>u.maxRepeatSize&&n.pop()}}),"each"===t&&(e.length=0)}function st(e,t){var n="_"+e;if(!st[n]){var a=ft.createElement(e);Nt.appendChild(a),t=Ot?getComputedStyle(a,null).display:a.currentStyle.display,Nt.removeChild(a),st[n]=t}return st[n]}function ct(e,t,n,a){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var r=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):3,o=a||",",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(r,i):""+Math.round(r)).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)}var ut=Date.now(),ft=e.document,pt=ft.head;pt.insertAdjacentHTML("afterBegin",'<avalon ms-skip class="avalonHide"><style id="avalonStyle">.avalonHide{ display: none!important }</style></avalon>');var dt,vt=pt.firstChild,ht="$"+ut,mt=e.require,gt=e.define,yt=!1,bt=/[^, ]+/g,$t=/^(?:object|array)$/,xt=/^\[object SVG\w*Element\]$/,wt=/^\[object (?:Window|DOMWindow|global)\]$/,Ct=Object.prototype,At=Ct.hasOwnProperty,Tt=Ct.toString,kt=Array.prototype,Et=kt.slice,Mt={},Ot=e.dispatchEvent,Nt=ft.documentElement,Lt=ft.createDocumentFragment(),jt=ft.createElement("div"),Ht={};"Boolean Number String Function Array Date RegExp Object Error".replace(bt,function(e){Ht["[object "+e+"]"]=e.toLowerCase()});var St=function(e){return e=e||"avalon",(e+Math.random()+Math.random()).replace(/0\./g,"")},Dt=l();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,a=e.MutationObserver,r=Ot&&e.postMessage;if(n)return n.bind(e);var i=[];if(a){var o=document.createTextNode("avalon");return new a(t).observe(o,{characterData:!0}),function(e){i.push(e),o.data=Math.random()}}return r?(e.addEventListener("message",function(n){var a=n.source;a!==e&&null!==a||"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?Ht[Tt.call(e)]||"object":typeof e};var Pt=function(e){return"[object Function]"===Tt.call(e)};avalon.isFunction=Pt,avalon.isWindow=function(e){return wt.test(Tt.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===Tt.call(e)&&Object.getPrototypeOf(e)===Ct},avalon.mix=avalon.fn.mix=function(){var e,t,n,a,r,i,o=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[1]||{},l++),"object"==typeof o||Pt(o)||(o={}),l===s&&(o=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e)n=o[t],a=e[t],o!==a&&(c&&a&&(avalon.isPlainObject(a)||(r=Array.isArray(a)))?(r?(r=!1,i=n&&Array.isArray(n)?n:[]):i=n&&avalon.isPlainObject(n)?n:{},o[t]=avalon.mix(c,i,a)):void 0!==a&&(o[t]=a));return o},avalon.mix({rword:bt,subscribers:ht,version:1.41,ui:{},log:n,slice:function(e,t,n){return Et.call(e,t,n)},noop:i,error:function(e,t){throw new(t||Error)(e)},oneObject:o,range:function(e,t,n){n||(n=1),null==t&&(t=e||0,e=0);for(var a=-1,r=Math.max(0,Math.ceil((t-e)/n)),i=new Array(r);++a<r;)i[a]=e,e+=n;return i},eventHooks:{},bind:function(e,t,n,a){var r=avalon.eventHooks,i=r[t];return"object"==typeof i&&(t=i.type,i.deel&&(n=i.deel(e,t,n,a))),n.unbind||e.addEventListener(t,n,!!a),n},unbind:function(e,t,n,a){var r=avalon.eventHooks,o=r[t],l=n||i;"object"==typeof o&&(t=o.type,o.deel&&(n=o.deel(e,t,n,!1))),e.removeEventListener(t,l,!!a)},css:function(e,t,n){e instanceof avalon&&(e=e[0]);var a,r=/[_-]/.test(t)?F(t):t;if(t=avalon.cssName(r)||r,void 0===n||"boolean"==typeof n){a=Mn[r+":get"]||Mn["@:get"],"background"===t&&(t="backgroundColor");var i=a(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[r]&&(n+="px"),a=Mn[r+":set"]||Mn["@:set"],a(e,t,n)}},each:function(e,t){if(e){var n=0;if(s(e))for(var a=e.length;a>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(),a={};for(var r in n)0===r.indexOf(t)&&(a[r.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[r]);return a},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 Rt=avalon.bindingHandlers={},It=avalon.bindingExecutors={},_t=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(ft.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),avalon.contains=function(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}},e.SVGElement){var Ft="http://www.w3.org/2000/svg",Bt=ft.createElementNS(Ft,"svg");Bt.innerHTML='<circle cx="50" cy="50" r="40" fill="red" />',xt.test(Bt.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,a=avalon.parseHTML(e);if("svg"===t)n.insertBefore(a,this);else{var r=ft.createDocumentFragment();c(a,r),n.insertBefore(r,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);c(t,this)}}}})}var Ut=avalon.eventHooks;"onmouseenter"in Nt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Ut[e]={type:t,deel:function(t,n,a){return function(n){var r=n.relatedTarget;return r&&(r===t||16&t.compareDocumentPosition(r))?void 0:(delete n.type,n.type=e,a.call(t,n))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!Ut.animationend&&(Ut.animationend={type:n})}),void 0===ft.onmousewheel&&(Ut.mousewheel={type:"wheel",deel:function(e,t,n){return function(t){t.wheelDeltaY=t.wheelDelta=t.deltaY>0?-120:120,t.wheelDeltaX=0,Object.defineProperty(t,"type",{value:"mousewheel"}),n.call(e,t)}}});var Vt,qt,zt,Wt,Xt,Yt=/[-.*+?^${}()|[\]\/\\]/g,Gt={loader:function(t){var n=dt&&t;e.require=n?dt:mt,e.define=n?dt.define:gt},interpolate:function(e){if(Vt=e[0],qt=e[1],Vt===qt)throw new SyntaxError("openTag!==closeTag");if(e+""=="<!--,-->")u.commentInterpolate=!0;else{var t=Vt+"test"+qt;if(jt.innerHTML=t,jt.innerHTML!==t&&jt.innerHTML.indexOf("&lt;")>-1)throw new SyntaxError("此定界符不合法");jt.innerHTML=""}var n=f(Vt),a=f(qt);zt=new RegExp(n+"(.*?)"+a),Wt=new RegExp(n+"(.*?)"+a,"g"),Xt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=Gt,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var Zt=function(e){return ft.querySelectorAll(e)},Jt={$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 a=this.$events[e]||[],r=a.length;~--r<0;)if(a[r]===t)return a.splice(r,1);return this},$fire:function(e){var t,n,a,r;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var i=this.$events;if(i){var o=Et.call(arguments,1),l=[e].concat(o);if("all"===t)for(n in avalon.vmodels)a=avalon.vmodels[n],a!==this&&a.$fire.apply(a,l);else if("up"===t||"down"===t){var s=i.expr?Zt(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=Zt(a.$events.expr);if(0===c.length)continue;Array.prototype.forEach.call(c,function(e){Array.prototype.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=ft.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;(r=f[n++])&&r.$fire.apply(r,l)!==!1;);}else{var p=i[e]||[],d=i.$all||[];for(n=0;r=p[n++];)Pt(r)&&r.apply(this,o);for(n=0;r=d[n++];)Pt(r)&&r.apply(this,arguments)}}}},Qt=avalon.vmodels=r();avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),Qt[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var r=v(e);else{var o={$watch:i};t(o),r=v(o),yt=!0,t(r),yt=!1}return r.$id=a,Qt[a]=r};var Kt=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray").match(bt),en=r(),tn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},nn=function(e){var t=r();for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t},an=kt.splice,rn={_splice:an,_fire:function(e,t,n){k(this.$events[ht],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(kt.push.apply(this.$model,e),y.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&&(kt.unshift.apply(this.$model,arguments),y.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return y.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return y.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=an.apply(this.$model,arguments);return r.length&&(a.push("del",e,r.length,0),t=!0),n>2&&(t?a.splice(3,1,0,"add",e,n-2):a.push("add",e,n-2,0),t=!0),t?y.apply(this,a):[]},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),y.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 a=this[e];if("object"===n)for(var r in t)a.hasOwnProperty(r)&&(a[r]=t[r]);else"array"===n?a.clear().push.apply(a,t):a!==t&&(this[e]=t,this.$model[e]=t,this._fire("set",e,t))}return this}};"sort,reverse".replace(bt,function(e){rn[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];kt[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(tn(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(b(this,i),this._fire("move",i),this._fire("index",0)),this}});var on=/^(duplex|on)$/,ln=avalon.$$subscribers=[],sn=new Date,cn={},un=new function(){avalon.mix(this,{option:ft.createElement("select"),thead:ft.createElement("table"),td:ft.createElement("tr"),area:ft.createElement("map"),tr:ft.createElement("tbody"),col:ft.createElement("colgroup"),legend:ft.createElement("fieldset"),_default:ft.createElement("div"),g:ft.createElementNS("http://www.w3.org/2000/svg","svg")}),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td};String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(bt,function(e){un[e]=un.g});var fn=/<([\w:]+)/,pn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,dn=o(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),vn=ft.createElement("script"),hn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Lt.cloneNode(!1);if("string"!=typeof e)return t;if(!hn.test(e))return t.appendChild(ft.createTextNode(e)),t;e=e.replace(pn,"<$1></$2>").trim();var n,a=(fn.exec(e)||["",""])[1].toLowerCase(),r=un[a]||un._default;r.innerHTML=e;var i=r.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if(dn[o.type]){var s=vn.cloneNode(!1);kt.forEach.call(o.attributes,function(e){s.setAttribute(e.name,e.value)}),s.text=o.text,o.parentNode.replaceChild(s,o)}for(;n=r.firstChild;)t.appendChild(n);return t},avalon.innerHTML=function(e,t){var n=this.parseHTML(t);this.clearHTML(e).appendChild(n)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},avalon.scan=function(e,t){e=e||Nt;var n=t?[].concat(t):[];D(e,n)};var mn=o("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),gn=function(e,t,n){var a=e.getAttribute(t);if(a)for(var r,i=0;r=n[i++];)if(r.hasOwnProperty(a)&&"function"==typeof r[a])return r[a]},yn=Dt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var a=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=a}}:0,bn=/ms-(\w+)-?(.*)/,$n={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},xn=o("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),wn=o("value,title,alt,checked,selected,disabled,readonly,enabled"),Cn=/^if|widget|repeat$/,An=/^each|with|html|include$/,Tn=/\|\s*html\s*/,kn=/\|\|/g;rstringLiteral=/(['"])(\\\1|.)+?\1/g,"add,remove".replace(bt,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){n.classList[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&t.classList.contains(e)},toggleClass:function(e,t){for(var n,a=0,r=e.split(/\s+/),i="boolean"==typeof t;n=r[a++];){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-"+_(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return B(n);case 0:var a={};return kt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=F(e.slice(5)),a[e]=B(t.value)))}),a}},removeData:function(e){return e="data-"+_(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 a=avalon.css(this,e,t);return void 0!==a?a:this},position:function(){var e,t,n=this[0],a={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(a=e.offset()),a.top+=avalon.css(e[0],"borderTopWidth",!0),a.left+=avalon.css(e[0],"borderLeftWidth",!0)),{top:t.top-a.top-avalon.css(n,"marginTop",!0),left:t.left-a.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||Nt)},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,a=n?":get":":set",r=Hn[q(t)+a];if(r)var i=r(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?i:this}}),Nt.dataset&&(avalon.fn.data=function(e,t){var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],B(t);case 0:var a=r();for(e in n)a[e]=B(n[e]);return a}});var En=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;avalon.parseJSON=JSON.parse,avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var a=this[0]||{},r=U(a),i="scrollTop"===e;return arguments.length?void(r?r.scrollTo(i?r[t]:n,i?n:r[t]):a[e]=n):r?r[t]:a[e]}});var Mn=avalon.cssHooks=r(),On=["","-webkit-","-moz-","-ms-"],Nn={"float":"cssFloat"};avalon.cssNumber=o("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(Nn[e])return Nn[e];t=t||Nt.style;for(var a=0,r=On.length;r>a;a++)if(n=F(On[a]+e),n in t)return Nn[e]=n;return null},Mn["@:set"]=function(e,t,n){e.style[t]=n},Mn["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,a=getComputedStyle(e);return a&&(n="filter"===t?a.getPropertyValue(t):a[t],""===n&&(n=e.style[t])),n},Mn["opacity:get"]=function(e){var t=Mn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(bt,function(e){Mn[e+":get"]=function(t){var n=Mn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Ln={position:"absolute",visibility:"hidden",display:"block"},jn=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(bt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;Mn[t+":get"]=function(t,n,a){var i=-4;"number"==typeof a&&(i=a),n="Width"===e?["Left","Right"]:["Top","Bottom"];var o=t[r];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)
2
+ },Mn[t+"&get"]=function(e){var n=[];V(e,n);for(var a,r=Mn[t+":get"](e),i=0;a=n[i++];){e=a.node;for(var o in a)"string"==typeof a[o]&&(e.style[o]=a[o])}return r},avalon.fn[t]=function(i){var o=this[0];if(0===arguments.length){if(o.setTimeout)return o["inner"+e];if(9===o.nodeType){var l=o.documentElement;return Math.max(o.body[a],l[a],o.body[r],l[r],l[n])}return Mn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return Mn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return Mn[t+":get"](this[0],void 0,e===!0?2:0)}}),avalon.fn.offset=function(){var e=this[0];try{var t=e.getBoundingClientRect();if(t.width||t.height||e.getClientRects().length){var n=e.ownerDocument,a=n.documentElement,r=n.defaultView;return{top:t.top+r.pageYOffset-a.clientTop,left:t.left+r.pageXOffset-a.clientLeft}}}catch(i){return{left:0,top:0}}};var Hn={"select:get":function(e,t){for(var n,a=e.options,r=e.selectedIndex,i="select-one"===e.type||0>r,o=i?null:[],l=i?r+1:a.length,s=0>r?l:i?r:0;l>s;s++)if(n=a[s],(n.selected||s===r)&&!n.disabled){if(t=n.value,i)return t;o.push(t)}return o},"select:set":function(e,t,n){t=[].concat(t);for(var a,r=0;a=e.options[r++];)(a.selected=t.indexOf(a.value)>-1)&&(n=!0);n||(e.selectedIndex=-1)}},Sn=JSON.stringify,Dn=["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(","),Pn=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Rn=/[^\w$]+/g,In=new RegExp(["\\b"+Dn.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),_n=/\b\d[^,]*/g,Fn=/^,+|,+$/g,Bn=new _t(512),Un=function(e){var t=","+e.trim(),n=Bn.get(t);if(n)return n;var a=e.replace(Pn,"").replace(Rn,",").replace(In,"").replace(_n,"").replace(Fn,"").split(/^$|,+/);return Bn.put(t,W(a))},Vn=new _t(128),qn=/\w\[.*\]|\w\.\w/,zn=/(\$proxy\$[a-z]+)\d+$/,Wn=/\)\s*$/,Xn=/\)\s*\|/g,Yn=/\|\s*([$\w]+)/g,Gn=/"\s*\["/g,Zn=/"\s*\(/g;avalon.parseExprProxy=G;var Jn=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),Qn={};Jn.replace(bt,function(e){Qn[e.toLowerCase()]=e});var Kn={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},ea=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");ea.replace(bt,function(e){Kn[e.toLowerCase()]=e});var ta=/<noscript.*?>(?:[\s\S]+?)<\/noscript>/gim,na=/<noscript.*?>([\s\S]+?)<\/noscript>/im,aa=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},ra=avalon.templateCache={};Rt.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Vt)>-1&&n.indexOf(qt)>2&&(a=!1,zt.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(a=!0,n=RegExp.$1)),"include"===e.type){var r=e.element;e.includeRendered=gn(r,"data-include-rendered",t),e.includeLoaded=gn(r,"data-include-loaded",t);var i=e.includeReplace=!!avalon(r).data("includeReplace");avalon(r).data("includeCache")&&(e.templateCache={}),e.startInclude=ft.createComment("ms-include"),e.endInclude=ft.createComment("ms-include-end"),i?(e.element=e.startInclude,r.parentNode.insertBefore(e.startInclude,r),r.parentNode.insertBefore(e.endInclude,r.nextSibling)):(r.insertBefore(e.startInclude,r.firstChild),r.appendChild(e.endInclude))}e.handlerName="attr",G(n,t,e,a?0:R(e.value))},It.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){if(Qn[i]){var o=Qn[i];if("boolean"==typeof n[o])return n[o]=!!t}var l=t===!1||null===t||void 0===t;if(!Ot&&Kn[i]&&(i=Kn[i]),l)return n.removeAttribute(i);var s=xt.test(n)?!1:ft.namespaces&&isVML(n)?!0:i in n.cloneNode(!1);s?n[i]=t:n.setAttribute(i,t)}else if("include"===r&&t){var c=a.vmodels,u=a.includeRendered,f=a.includeLoaded,p=a.includeReplace,d=p?n.parentNode:n,v=function(e){f&&(e=f.apply(d,[e].concat(c))),u&&E(d,function(){u.call(d)},0/0);var n=a.includeLastID;if(a.templateCache&&n&&n!==t){var r=a.templateCache[n];r||(r=a.templateCache[n]=ft.createElement("div"),vt.appendChild(r))}for(a.includeLastID=t;;){var i=a.startInclude.nextSibling;if(!i||i===a.endInclude)break;d.removeChild(i),r&&r.appendChild(i)}var o=Z(a,t,e),l=avalon.slice(o.childNodes);d.insertBefore(o,a.endInclude),H(l,c)};if("src"===a.param)if(ra[t])avalon.nextTick(function(){v(ra[t])});else{var h=aa();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;(e>=200&&300>e||304===e||1223===e)&&v(ra[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:ft.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=aa(),h.open("GET",location,!1),h.send(null);for(var g=ft.getElementsByTagName("noscript"),y=(h.responseText||"").match(ta)||[],b=y.length,$=0;b>$;$++){var x=g[$];x&&(x.style.display="none",x.fixIE78=(y[$].match(na)||["","&nbsp;"])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Nt.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&amp;/g,"&")),n[r]=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(bt,function(e){Rt[e]=Rt.attr}),Rt["class"]=function(e,t){var a,r=e.param,i=e.value;if(e.handlerName="class",!r||isFinite(r)){e.param="";var o=i.replace(Wt,function(e){return e.replace(/./g,"0")}),l=o.indexOf(":");if(-1===l)var s=i;else{if(s=i.slice(0,l),a=i.slice(l+1),Y(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=zt.test(s);c||(e.immobileClass=s),G("",t,e,c?R(s):0)}else e.immobileClass=e.oldStyle=e.param,G(i,t,e)},It["class"]=function(e,t,n){var a=avalon(t),r=n.type;if("class"===r&&n.oldStyle)a.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&&a.removeClass(n.oldClass),n.oldClass=n.newClass,r){case"class":a.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var i="mouseenter",o="mouseleave";if("active"===r){t.tabIndex=t.tabIndex||-1,i="mousedown",o="mouseup";var l=a.bind("mouseleave",function(){n.toggleClass&&a.removeClass(n.newClass)})}var s=a.bind(i,function(){n.toggleClass&&a.addClass(n.newClass)}),c=a.bind(o,function(){n.toggleClass&&a.removeClass(n.newClass)});n.rollback=function(){a.unbind("mouseleave",l),a.unbind(i,s),a.unbind(o,c)},n.hasBindEvent=!0}}},"hover,active".replace(bt,function(e){Rt[e]=Rt["class"]}),It.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var ia=Rt.duplex=function(e,t){var a,r=e.element;if(G(e.value,t,e,0,1),e.changed=gn(r,"data-duplex-changed",t)||i,e.evaluator&&e.args){var l=[],s=o("string,number,boolean,checked");"radio"===r.type&&""===e.param&&(e.param="checked"),r.msData&&(r.msData["ms-duplex"]=e.value),e.param.replace(/\w+/g,function(t){/^(checkbox|radio)$/.test(r.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){r.addEventListener?r.addEventListener(t,n,!1):r.attachEvent("on"+t,n);var a=e.rollback;e.rollback=function(){r.avalonSetter=null,avalon.unbind(r,t,n),a&&a()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=Q);f(null,e,"init");var p=r.tagName;ia[p]&&ia[p](r,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:J},"boolean":{get:function(e){return"true"===e},set:J},number:{get:function(e,t){var n=parseFloat(e);if(-e===-n)return n;var a=/strong|medium|weak/.exec(t.element.getAttribute("data-duplex-number"))||["medium"];switch(a[0]){case"strong":return 0;case"medium":return""===e?"":0;case"weak":return e}},set:J}};var oa,la=[];avalon.tick=function(e){1===la.push(e)&&(oa=setInterval(K,60))};var sa=i,ca=/text|password|hidden/;!new function(){function e(e){if(avalon.contains(Nt,this)){if(t[this.tagName].call(this,e),!ca.test(this.type))return;!this.msFocus&&this.avalonSetter&&this.avalonSetter()}}try{var t={},n=HTMLInputElement.prototype,a=HTMLTextAreaElement.prototype,r=HTMLInputElement.prototype;Object.getOwnPropertyNames(r),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(a,"value").set,Object.defineProperty(a,"value",{set:e})}catch(i){sa=avalon.tick}},ia.INPUT=function(e,t,a){function r(e){a.changed.call(this,e,a)}function i(){u=!0}function o(){u=!1}var l=e.type,s=a.bound,c=avalon(e),u=!1,f=function(){if(!u){var n=e.oldValue=e.value,i=a.pipe(n,a,"get");c.data("duplex-observe")!==!1&&(t(i),r.call(e,i),c.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}};if(a.handler=function(){var n=a.pipe(t(),a,"set")+"";n!==e.oldValue&&(e.value=n)},a.isChecked||"radio"===l)f=function(){if(c.data("duplex-observe")!==!1){var n=a.pipe(e.value,a,"get");t(n),r.call(e,n)}},a.handler=function(){var n=t(),r=a.isChecked?!!n:n+""===e.value;e.checked=e.oldValue=r},s("click",f);else if("checkbox"===l)f=function(){if(c.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,a.pipe(e.value,a,"get")),r.call(e,o)}},a.handler=function(){var n=[].concat(t());e.checked=n.indexOf(a.pipe(e.value,a,"get"))>-1},s("change",f);else{var p=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),p.replace(bt,function(e){switch(e){case"input":s("input",f),s("DOMAutoComplete",f),Dt||(s("compositionstart",i),s("compositionend",o));break;default:s(e,f)}}),s("focus",function(){e.msFocus=!0}),s("blur",function(){e.msFocus=!1}),ca.test(l)&&sa(function(){if(Nt.contains(e))e.msFocus||e.oldValue===e.value||f();else if(!e.msRetain)return!1}),e.avalonSetter=f}e.oldValue=e.value,$(a),r.call(e,e.value)},ia.TEXTAREA=ia.INPUT,ia.SELECT=function(e,t,a){function r(){if(i.data("duplex-observe")!==!1){var n=i.val();n=Array.isArray(n)?n.map(function(e){return a.pipe(e,a,"get")}):a.pipe(n,a,"get"),n+""!==e.oldValue&&t(n),a.changed.call(e,n,a)}}var i=avalon(e);a.handler=function(){var a=t();a=a&&a.$model||a,Array.isArray(a)?e.multiple||n("ms-duplex在<select multiple=true>上要求对应一个数组"):e.multiple&&n("ms-duplex在<select multiple=false>不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),E(e,function(){$(a),a.changed.call(e,t(),a)},0/0)},It.html=function(e,t,n){e=null==e?"":e;var a="group"in n,r=a?t.parentNode:t;if(r){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=Lt.cloneNode(!0);o[0];)i.appendChild(o[0])}else i=avalon.parseHTML(e);var l=ft.createComment("ms-html");if(a){r.insertBefore(l,t);for(var s=n.group,c=1;s>c;){var u=t.nextSibling;u&&(r.removeChild(u),c++)}r.removeChild(t),n.element=l}else avalon.clearHTML(r).appendChild(l);a&&(n.group=i.childNodes.length||1),o=avalon.slice(i.childNodes),o[0]&&(l.parentNode&&l.parentNode.replaceChild(i,l),a&&(n.element=o[0])),H(o,n.vmodels)}},Rt["if"]=Rt.data=Rt.text=Rt.html=function(e,t){G(e.value,t,e)},It["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),L(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var a=n.element=ft.createComment("ms-if");t.parentNode.replaceChild(a,t),n.template=t,vt.appendChild(t),n.rollback=function(){t.parentNode===vt&&vt.removeChild(t)}}};var ua=/\(([^)]*)\)/;Rt.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof Rt.on[a+"Hook"]&&Rt.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(ua)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(ua,""))}G(n,t,e)},It.on=function(e,t,n){e=function(e){var t=n.evaluator||i;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 r=avalon.bind(t,a,e);n.rollback=function(){"function"==typeof n.specialUnbind?n.specialUnbind():avalon.unbind(t,a,r)}},Rt.repeat=function(e,t){var n=e.type;G(e.value,t,e,0,1),e.proxies=[];var a=!1;try{var r=e.$repeat=e.evaluator.apply(0,e.args||[]),i=avalon.type(r);"object"!==i&&"array"!==i&&(a=!0,avalon.log("warning:"+e.value+"只能是对象或数组"))}catch(o){a=!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[ht]=f[ht]||[],f[ht].push(e);break}}var p=e.element;p.removeAttribute(e.name),e.sortedCallback=gn(p,"data-with-sorted",t),e.renderedCallback=gn(p,"data-"+n+"-rendered",t);var d=St(n),v=e.element=ft.createComment(d+":end");if(e.clone=ft.createComment(d),Lt.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){It.repeat.call(e,"clear");var n=t.parentNode,a=e.template,r=a.firstChild;n.replaceChild(a,t);var i=e.$stamp;i&&i.parentNode&&i.parentNode.removeChild(i),r=e.element="repeat"===e.type?r:n}},!a){e.handler=It.repeat,e.$outer={};var h="$key",m="$val";for(Array.isArray(r)&&(h="$first",m="$last"),u=0;s=t[u++];)if(s.hasOwnProperty(h)&&s.hasOwnProperty(m)){e.$outer=s;break}var g=r.$events,y=(g||{})[ht];if(y&&avalon.Array.ensure(y,e)&&w(e,y),"object"===i){e.$with=!0;var b=g?g.$withProxyPool||(g.$withProxyPool={}):{};e.handler("append",r,b)}else r.length&&e.handler("add",0,r.length)}},It.repeat=function(e,t,n){if(e){var a=this,r=a.element,o=r.parentNode,l=a.proxies,s=Lt.cloneNode(!1);switch(e){case"add":for(var c,u=t+n,f=a.$repeat,p=f.length-1,d=[],v=tt(a,t),h=t;u>h;h++){var m=rt(h,a);l.splice(h,0,m),et(a,s,m,d)}for(o.insertBefore(s,v),h=0;c=d[h++];)H(c.nodes,c.vmodels),c.nodes=c.vmodels=null;break;case"del":v=l[t].$stamp,r=tt(a,t+n),nt(v,r);var g=l.splice(t,n);lt(g,"each");break;case"clear":var y=a.$stamp||l[0];y&&(v=y.$stamp||y,nt(v,r)),lt(l,"each");break;case"move":v=l[0].$stamp;var $,x=v.nodeValue,w=[],C=[];for(nt(v,r,function(){C.unshift(this),this.nodeValue===x&&(w.unshift(C),C=[])}),b(l,t),b(w,t);C=w.shift();)for(;$=C.shift();)s.appendChild($);o.insertBefore(s,r);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&&k(m.$events.$index));case"append":var A=n,T=[];d=[];for(var M in t)t.hasOwnProperty(M)&&"hasOwnProperty"!==M&&T.push(M);if(a.sortedCallback){var O=a.sortedCallback.call(o,T);O&&Array.isArray(O)&&O.length&&(T=O)}for(h=0;M=T[h++];)"hasOwnProperty"!==M&&(A[M]||(A[M]=ot(M,a)),et(a,s,A[M],d));var N=a.$stamp=a.clone;for(o.insertBefore(N,r),o.insertBefore(s,r),h=0;c=d[h++];)H(c.nodes,c.vmodels),c.nodes=c.vmodels=null}"clear"===e&&(e="del");var L=a.renderedCallback||i,j=arguments;E(o,function(){L.apply(o,j),o.oldValue&&"SELECT"===o.tagName&&avalon(o).val(o.oldValue.split(","))},0/0)}},"with,each".replace(bt,function(e){Rt[e]=Rt.repeat});var fa=[],pa=[];It.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=st,Rt.visible=function(e,t){var n=avalon(e.element),a=n.css("display");if("none"===a){var r=n[0].style,i=/visibility/i.test(r.cssText),o=n.css("visibility");r.display="",r.visibility="hidden",a=n.css("display"),"none"===a&&(a=st(n[0].nodeName)),r.visibility=i?o:""}e.display=a,G(e.value,t,e)},It.visible=function(e,t,n){t.style.display=e?n.display:"none"},Rt.widget=function(t,n){var a=t.value.match(bt),r=t.element,o=a[0],l=a[1];l&&"$"!==l||(l=St(o));var s=a[2]||o,c=avalon.ui[o];if("function"==typeof c){n=r.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(r,o);t.value=[o,l,s].join(","),t[o+"Id"]=l,t.evaluator=i,r.msData["ms-widget-id"]=l;var h=t[o+"Options"]=avalon.mix({},c.defaults,p||{},v);r.removeAttribute("ms-widget");var m=c(r,t,n)||{};m.$id?(avalon.vmodels[l]=m,M(r,m),m.hasOwnProperty("$init")&&m.$init(function(){avalon.scan(r,[m].concat(n)),"function"==typeof h.onInit&&h.onInit.call(r,m,h,n)}),t.rollback=function(){try{m.widgetElement=null,m.$remove()}catch(e){}r.msData={},delete avalon.vmodels[m.$id]},w(t,da),e.chrome&&r.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(T)})):avalon.scan(r,n)}else n.length&&(r.vmodels=n)};var da=[],va=/<script[^>]*>([\S\s]*?)<\/script\s*>/gim,ha=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,ma=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,ga={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},ya=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ba=/([^\#-~| |!])/g,$a=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 a=arguments[t],r=avalon.filters[a.shift()];if("function"==typeof r){var i=[e].concat(a);e=r.apply(null,i)}}return e},camelize:F,sanitize:function(e){return e.replace(va,"").replace(ma,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=ga[t[1]];n&&(e=e.replace(n,function(e,t,n){var a=n.charAt(0);return t+"="+a+"javascript:void(0)"+a}))}return e.replace(ha," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&amp;").replace(ya,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(ba,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")},currency:function(e,t,n){return(t||"¥")+ct(e,isFinite(n)?n:2)},number:ct};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var a="";for(0>e&&(a="-",e=-e),e=""+e;e.length<t;)e="0"+e;return n&&(e=e.substr(e.length-t)),a+e}function n(e,n,a,r){return function(i){var o=i["get"+e]();return(a>0||o>-a)&&(o+=a),0===o&&-12===a&&(o=12),t(o,n,r)}}function a(e,t){return function(n,a){var r=n["get"+e](),i=(t?"SHORT"+e:e).toUpperCase();return a[i][r]}}function r(e){var n=-1*e.getTimezoneOffset(),a=n>=0?"+":"";return a+=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:a("Month"),MMM:a("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:a("Day"),EEE:a("Day",!0),a:i,Z:r},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;$a.date=function(t,n){var a,r,i=$a.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,a,r){var i=4===r.length?[r,n,a]:[n,a,r];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,a,r,i){return p[3]=e(n),p[4]=e(a),p[5]=e(r),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,a,r){return v=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+a),g=e(n+r)),""}),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;)r=l.exec(n),r?(u=u.concat(r.slice(1)),n=u.pop()):(u.push(n),n=null);return u.forEach(function(e){a=o[e],c+=a?a(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"};c.SHORTMONTH=c.MONTH,$a.date.locate=c};var xa=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};xa.exports=xa.avalon,new function(){function t(e,t){var a="js";e=e.replace(/^(\w+)\!/,function(e,t){return a=t,""}),"ready"===a&&(n("debug: ready!已经被废弃,请使用domReady!"),a="domReady");var r="";e=e.replace(D,function(e){return r=e,""});var i="."+a,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:r,ext:o,res:a,name:e,toUrl:m},t);return l.toUrl(e),l}function o(e){var t=e.name,n=e.res,a=xa[t],r=t&&e.urlNoQuery;if(a&&a.state>=1)return t;if(a=xa[r],a&&a.state>=3)return dt(a.deps||[],a.factory,r),r;if(t&&!a){a=xa[r]={id:r,state:1};var i=function(r){S[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,c()})};S[n]?i(S[n]):dt([n],i)}return t?r:n+"!"}function l(e,t){for(var n,a=0;n=e[a++];)if(4!==xa[n].state&&(n===t||l(xa[n].deps,t)))return!0}function s(e,t){var a=p(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){pt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!xa[a].state)):!0}function c(){e:for(var e,t=T.length;e=T[--t];){var n=xa[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++)if(4!==Object(xa[r]).state)continue e;4!==n.state&&(T.splice(t,1),h(n.id,n.deps,n.factory),c())}}}function f(e,t,a){var r=ft.createElement("script");r.className=ht,r.onload=function(){var r=k.pop();r&&r.require(t),a&&a(),n("debug: 已成功加载 "+e),t&&T.push(t),c()},r.onerror=function(){s(r,!0)},pt.insertBefore(r,pt.firstChild),r.src=e,n("debug: 正准备加载 "+e)}function p(e){return(e||"").replace(D,"")}function d(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function v(){var e;try{a.b.c()}catch(t){e=t.stack}if(e)return e=e.split(/[@ ]/g).pop(),e="("===e[0]?e.slice(1,-1):e.replace(/\s/,""),p(e.replace(/(:\d+)?:\d+$/i,""));for(var n,r=pt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===ht&&"interactive"===n.readyState){var o=n.src;return n.className=p(o)}}function h(t,a,i){var o=Object(xa[t]);o.state=4;for(var l,s=0,c=[];l=a[s++];)if("exports"===l){var u=o.exports||(o.exports=r());c.push(u)}else c.push(xa[l].exports);try{var f=i.apply(e,c)}catch(p){n("执行["+t+"]模块的factory抛错: "+p)}return void 0!==f&&(o.exports=f),P.test(t)&&delete xa[t],delete o.factory,f}function m(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,a=this.baseUrl,r=this.parentUrl||a;x(e,u.paths,function(e,a){t=t.replace(a,e),n=1}),n||x(e,u.packages,function(e,n,a){t=t.replace(a.name,a.location)}),this.mapUrl&&x(this.mapUrl,u.map,function(e){x(t,e,function(e,n){t=t.replace(n,e),r=a})});var i=this.ext;i&&n&&t.slice(-i.length)===i&&(t=t.slice(0,-i.length)),d(t)||(r=this.built||/^\w/.test(t)?a:r,t=C(r,t));var o=t+i;return t=o+this.query,x(e,u.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=o}function g(e,t,n){var a=$(e,t,n);return a.sort(w),a}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&&A(t.exports)}}function $(e,t,n){var a=[];for(var r in e){var i={name:r,val:e[r]};a.push(i),i.reg="*"===r&&t?/^/:y(r),n&&"*"!==r&&(i.reg=new RegExp("/"+r.replace(/^\//,"")+"(/|$)"))}return a}function x(e,t,n){t=t||[];for(var a,r=0;a=t[r++];)if(a.reg.test(e))return n(a.val,a.name,a),!1}function w(e,t){var n=e.name,a=t.name;return"*"===a?-1:"*"===n?1:a.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;R.test(e);)e=e.replace(R,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function A(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var T=[],k=[],E=/\.js$/i,M=[],O=!1;dt=avalon.require=function(e,n,a,l){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var s=[],f=r(),p=a||"callback"+setTimeout("1");l=l||r(),l.baseUrl=u.baseUrl;var d=!!l.built;if(a&&(l.parentUrl=a.substr(0,a.lastIndexOf("/")),l.mapUrl=a.replace(E,"")),d){var v=t(l.defineName,l);p=v.urlNoQuery}else e.forEach(function(e){var n=t(e,l),a=o(n);a&&(f[a]||(s.push(a),f[a]="司徒正美"))});var h=xa[p];h&&4===h.state||(xa[p]={id:p,deps:d?e.concat():s,factory:n||i,state:3}),h||T.push(p),c()}else if(M.push(avalon.slice(arguments)),arguments.length<=2){O=!0;for(var m,g=M.splice(0,M.length);m=g.shift();)dt.apply(null,m)}},dt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var a={built:!O,defineName:e},r=[t,n,a];n.require=function(e){if(r.splice(2,0,e),xa[e]){xa[e].state=3;var t=!1;try{t=l(xa[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,dt.apply(null,r)};var i=a.built?"unknown":v();if(i){var o=xa[i];o&&(o.state=2),n.require(i)}else k.push(n)},dt.config=u,dt.define.amd=xa;var N=u["orig.paths"]=r(),L=u["orig.map"]=r(),j=u.packages=[],H=u["orig.args"]=r();avalon.mix(Gt,{paths:function(e){avalon.mix(N,e),u.paths=g(N)},map:function(e){avalon.mix(L,e);var t=g(L,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),u.map=t},packages:function(e){e=e.concat(j);for(var t,n=r(),a=[],i=0;t=e[i++];){t="string"==typeof t?{name:t}:t;var o=t.name;if(!n[o]){var l=t.location?t.location:C(o,t.main||"main");l=l.replace(E,""),a.push(t),n[o]=t.location=l,t.reg=y(o)}}u.packages=a.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(H,e),u.urlArgs=g(H,1)},baseUrl:function(e){if(!d(e)){var t=pt.getElementsByTagName("base")[0];t&&pt.removeChild(t);var n=ft.createElement("a");n.href=e,e=n.href,t&&pt.insertBefore(t,pt.firstChild)}e.length>3&&(u.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))}u.shim=e}});var S=dt.plugins={ready:{load:i},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(E,"")];i?dt(i.deps||[],function(){var e=avalon.slice(arguments);f(a,r,function(){n(i.exportsFn?i.exportsFn.apply(0,e):void 0)})}):f(a,r)}},css:{load:function(e,t,a){var r=t.url;pt.insertAdjacentHTML("afterBegin",'<link rel="stylesheet" href="'+r+'">'),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=aa();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+r),a(i.responseText))},i.open("GET",r,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};dt.checkDeps=c;var D=/(\?[^#]*)$/,P=/^callback\d+$/,R=/\/\w+\/\.\./,I=ft.scripts[ft.scripts.length-1],_=I.getAttribute("data-main");if(_){Gt.baseUrl(_);var F=u.baseUrl;u.baseUrl=F.slice(0,F.lastIndexOf("/")+1),f(F.replace(E,"")+".js")}else{var B=p(I.src);u.baseUrl=B.slice(0,B.lastIndexOf("/")+1)}};var wa,Ca=[],Aa=function(e){for(wa=!0,dt&&(xa["domReady!"].state=4,dt.checkDeps());e=Ca.shift();)e(avalon)};"complete"===ft.readyState?setTimeout(Aa):ft.addEventListener("DOMContentLoaded",Aa),e.addEventListener("load",Aa),avalon.ready=function(e){wa?e(avalon):Ca.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(ft.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var Ta=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=Ta),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.modern.shim.js(无加载器版本) 1.391 built in 2015.2.12
8
+ avalon.modern.shim.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
2965
 
2848
-
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
2998
3110
  })
3111
+ bound("blur", function () {
3112
+ element.msFocus = false
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,7 +4152,7 @@ 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
  * END *
4034
4158
  **********************************************************************/
@@ -4085,7 +4209,7 @@ new function() {
4085
4209
  var _avalon = window.avalon
4086
4210
  avalon.noConflict = function(deep) {
4087
4211
  if (deep && window.avalon === avalon) {
4088
- window.avalon = avalon
4212
+ window.avalon = _avalon
4089
4213
  }
4090
4214
  return avalon
4091
4215
  }