diff --git a/avalon.js b/avalon.js index 779592744..ce444d720 100644 --- a/avalon.js +++ b/avalon.js @@ -2471,8 +2471,19 @@ var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig") code = code.replace(reg, function(_) { var c = _.charAt(v.length) - if (c === "." || c === "[") { + var method = /^\s*\(/.test(RegExp.rightContext) + if (c === "." || c === "[" || method) {//比如v为aa,我们只匹配aa.bb,aa[cc],不匹配aaa.xxx var name = "var" + String(Math.random()).replace(/^0\./, "") + if (method) {//array.size() + var array = _.split(".") + if (array.length > 2) { + var last = array.pop() + assigns.push(name + " = " + array.join(".")) + return name + "." + last + } else { + return _ + } + } assigns.push(name + " = " + _) return name } else { @@ -3810,9 +3821,6 @@ for (var i in EventManager) { array[i] = EventManager[i] } - array.size = function() { //取得数组长度,这个函数可以同步视图,length不能 - return array._.length - } avalon.mix(array, CollectionPrototype) return array } @@ -3852,6 +3860,9 @@ this._fire("index", n > 2 ? n - 2 : 0) return n }, + size: function() { //取得数组长度,这个函数可以同步视图,length不能 + return this._.length + }, pushArray: function(array) { return this.push.apply(this, array) }, diff --git a/avalon.min.js b/avalon.min.js index 81a540627..3c286466f 100644 --- a/avalon.min.js +++ b/avalon.min.js @@ -6,35 +6,36 @@ d;f.$events=g;for(e in R)c=R[e],w||(c=c.bind(f)),f[e]=c;f.hasOwnProperty=functio return h}function Z(b,c,d){b="for(var "+b+"i=0,n = this.length; i < n; i++){"+c.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+d;return Function("fn,scope",b)}function Za(b,c){try{for(;c=c.parentNode;)if(c===b)return!0;return!1}catch(d){return!1}}function $a(){return(new XMLSerializer).serializeToString(this)}function u(b){for(var c in b)if(O.call(b,c)){var d=b[c];if("function"===typeof u.plugins[c])u.plugins[c](d);else"object"===typeof u[c]?avalon.mix(u[c],d):u[c]=d}return this} function ab(b){return b.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function oa(b){return 0>b.indexOf("-")&&0>b.indexOf("_")?b:b.replace(/[-_][^-_]/g,function(b){return b.charAt(1).toUpperCase()})}function bb(b){if(!("classList"in b)){b.classList={node:b};for(var c in cb)b.classList[c.slice(1)]=cb[c]}return b.classList}function db(b){try{b="true"===b?!0:"false"===b?!1:"null"===b?null:+b+""===b?+b:$b.test(b)?avalon.parseJSON(b):b}catch(c){}return b}function eb(b,c){if(0>=b.offsetWidth){if(ac.test(x["@:get"](b, "display"))){var d={node:b},e;for(e in fb)d[e]=b.style[e],b.style[e]=fb[e];c.push(d)}(d=b.parentNode)&&1===d.nodeType&&eb(d,c)}}function gb(b){var c=b.nodeName;return c.toLowerCase()===c&&b.scopeName&&""===b.outerText}function bc(b){"url(#default#VML)"!==b.currentStyle.behavior&&(b.style.behavior="url(#default#VML)",b.style.display="inline-block",b.style.zoom=1)}function ya(b){Y[A]=b;avalon.openComputedCollect=!0;var c=b.evaluator;if(c)try{var d=cc.test(b.type)?b:c.apply(0,b.args);b.handler(d,b.element, -b)}catch(e){v("warning:exception throwed in [registerSubscriber] "+e),delete b.evaluator,c=b.element,3===c.nodeType&&(d=c.parentNode,u.commentInterpolate?d.replaceChild(p.createComment(b.value),c):c.data=P+b.value+Q)}avalon.openComputedCollect=!1;delete Y[A]}function ka(b){var c=Y[A];b&&(c&&avalon.Array.ensure(b,c)&&c.element)&&hb(c,b)}function hb(b,c){b.$uuid=b.$uuid||ha();c.$uuid=c.$uuid||ha();var d={data:b,list:c,toString:function(){return b.$uuid+" "+c.$uuid}};S[d]||(S[d]=1,S.push(d))}function ib(){for(var b= -za,c=za+dc;b"))&&ob(b,c)}}function Ca(b,c){b.length&&c.cb(b.length);for(var d=0,e;e=b[d++];)e.vmodels=c,C[e.type](e,c),e.evaluator&&(e.element&&1===e.element.nodeType)&&e.element.removeAttribute(e.name);b.length=0}function rb(b,c){0b&&delete c[d.shift()];return c[e]=f}var d=[];return c}function xb(b,c,d){var e=d.type,f=d.filters?d.filters.join(""):"",g=c.map(function(b){return String(b.$id).replace(oc,"$1")})+b+e+f,h=pc(b).concat(),k=[],l=[],m=[],n="";c=wb(c);d.vars=[];for(var q=0,n=c.length;q>0)-(d.clientLeft>>0),c.pageY=b.clientY+(d.scrollTop>>0)-(d.clientTop>> -0),c.wheelDeltaY=c.wheelDelta,c.wheelDeltaX=0);c.timeStamp=new Date-0;c.originalEvent=b;c.preventDefault=function(){b.returnValue=!1};c.stopPropagation=function(){b.cancelBubble=!0};return c}function Xb(b){var c=[];c.$id=ha();c.$model=b;c.$events={};c.$events[G]=[];c._=N({length:b.length});c._.$watch("length",function(b,d){c.$fire("length",b,d)});for(var d in R)c[d]=R[d];avalon.mix(c,Ab);return c}function Bb(b,c,d,e){var f=avalon.parseHTML(b.template),g=avalon.slice(f.childNodes);c.appendChild(f); -d.$outer=b.$outer;b=b.vmodels;d=[d].concat(b);d.cb=b.cb;e.push({nodes:g,vmodels:d})}function Ha(b,c){var d=b.endRepeat,e=[],f=b.element.nextSibling;if(f!==d){do if(f!==d)e.push(f);else break;while(f=f.nextSibling)}return e[b.group*c]||d}function Cb(b,c,d){c*=d||1;d=[b];for(var e=1,f=I;eu.maxRepeatSize&&da.pop()}b.length=0}function T(){p.body&&(D?(s["ready!"].state=2,D.checkDeps()):Fb.forEach(function(b){b(avalon)}),T=y)}function Gb(){try{B.doScroll("left"),T()}catch(b){setTimeout(Gb)}}var A=new Date- -0,G="$"+A,r=Function("return this")(),Ac=r.require,Bc=r.define,ja=!1,z=/[^, ]+/g,Hb=/\[native code\]/,wa=/^(?:object|array)$/,Ib=/^\[object SVG\w*Element\]$/,Vb=/^\[object (?:Window|DOMWindow|global)\]$/,Ia=Object.prototype,O=Ia.hasOwnProperty,ia=Ia.toString,L=Array.prototype,$=L.slice,Y={},w=r.dispatchEvent,B=p.documentElement,J=p.getElementsByTagName("head")[0],I=p.createDocumentFragment(),ea=p.createElement("div"),Jb={};"Boolean Number String Function Array Date RegExp Object Error".replace(z, -function(b){Jb["[object "+b+"]"]=b.toLowerCase()});avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"===typeof b?Jb[ia.call(b)]||"object":typeof b};var V="object"===typeof alert?function(b){try{return/^\s*\bfunction\b/.test(b+"")}catch(c){return!1}}:function(b){return"[object Function]"==ia.call(b)};avalon.isFunction=V;avalon.isWindow= -function(b){return!b?!1:b==b.document&&b.document!=b};Ya(r)&&(avalon.isWindow=Ya);for(var Cc in avalon({}))break;var Dc="0"!==Cc;avalon.isPlainObject=function(b,c){if(!b||"object"!==avalon.type(b)||b.nodeType||avalon.isWindow(b))return!1;try{if(b.constructor&&!O.call(b,"constructor")&&!O.call(b.constructor.prototype,"isPrototypeOf"))return!1}catch(d){return!1}if(Dc)for(c in b)return O.call(b,c);for(c in b);return void 0===c||O.call(b,c)};Hb.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(b){return!!b&& -"object"===typeof b&&Object.getPrototypeOf(b)===Ia});avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h>0)-(d.clientLeft>>0),c.pageY=b.clientY+(d.scrollTop>>0)-(d.clientTop>>0),c.wheelDeltaY=c.wheelDelta,c.wheelDeltaX=0);c.timeStamp=new Date-0;c.originalEvent=b;c.preventDefault=function(){b.returnValue=!1};c.stopPropagation=function(){b.cancelBubble=!0};return c}function Xb(b){var c=[];c.$id=ha();c.$model=b;c.$events={};c.$events[G]=[];c._=N({length:b.length});c._.$watch("length",function(b,d){c.$fire("length",b,d)});for(var d in R)c[d]=R[d]; +avalon.mix(c,Ab);return c}function Bb(b,c,d,e){var f=avalon.parseHTML(b.template),g=avalon.slice(f.childNodes);c.appendChild(f);d.$outer=b.$outer;b=b.vmodels;d=[d].concat(b);d.cb=b.cb;e.push({nodes:g,vmodels:d})}function Ha(b,c){var d=b.endRepeat,e=[],f=b.element.nextSibling;if(f!==d){do if(f!==d)e.push(f);else break;while(f=f.nextSibling)}return e[b.group*c]||d}function Cb(b,c,d){c*=d||1;d=[b];for(var e=1,f=I;eu.maxRepeatSize&&da.pop()}b.length=0}function T(){p.body&&(D?(s["ready!"].state=2,D.checkDeps()):Fb.forEach(function(b){b(avalon)}), +T=y)}function Gb(){try{B.doScroll("left"),T()}catch(b){setTimeout(Gb)}}var A=new Date-0,G="$"+A,r=Function("return this")(),Ac=r.require,Bc=r.define,ja=!1,z=/[^, ]+/g,Hb=/\[native code\]/,wa=/^(?:object|array)$/,Ib=/^\[object SVG\w*Element\]$/,Vb=/^\[object (?:Window|DOMWindow|global)\]$/,Ia=Object.prototype,O=Ia.hasOwnProperty,ia=Ia.toString,L=Array.prototype,$=L.slice,Y={},w=r.dispatchEvent,B=p.documentElement,J=p.getElementsByTagName("head")[0],I=p.createDocumentFragment(),ea=p.createElement("div"), +Jb={};"Boolean Number String Function Array Date RegExp Object Error".replace(z,function(b){Jb["[object "+b+"]"]=b.toLowerCase()});avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"===typeof b?Jb[ia.call(b)]||"object":typeof b};var V="object"===typeof alert?function(b){try{return/^\s*\bfunction\b/.test(b+"")}catch(c){return!1}}: +function(b){return"[object Function]"==ia.call(b)};avalon.isFunction=V;avalon.isWindow=function(b){return!b?!1:b==b.document&&b.document!=b};Ya(r)&&(avalon.isWindow=Ya);for(var Cc in avalon({}))break;var Dc="0"!==Cc;avalon.isPlainObject=function(b,c){if(!b||"object"!==avalon.type(b)||b.nodeType||avalon.isWindow(b))return!1;try{if(b.constructor&&!O.call(b,"constructor")&&!O.call(b.constructor.prototype,"isPrototypeOf"))return!1}catch(d){return!1}if(Dc)for(c in b)return O.call(b,c);for(c in b);return void 0=== +c||O.call(b,c)};Hb.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Ia});avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h 0 Then","\t\t["+b+'] = [__proxy__]([__data__],"'+b+'")',"\tEnd If","\tOn Error Goto 0","\tEnd Property");f.push("End Class");b=f.join("\r\n"); b=r.findOrDefineVBClass(e,b);b===e&&r.parseVB(["Function "+e+"Factory(a, b)","\tDim o","\tSet o = (New "+e+")(a, b)","\tSet "+e+"Factory = o","End Function"].join("\r\n"));return r[b+"Factory"](c,Ec)}}if(!"\u53f8\u5f92\u6b63\u7f8e".trim){var Fc=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(Fc,"")}}var Gc=!{toString:null}.propertyIsEnumerable("toString"),Hc=function(){}.propertyIsEnumerable("prototype"),Kb="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "), @@ -101,9 +102,9 @@ HTMLInputElement.prototype;Object.getOwnPropertyNames(Va);var vc=Object.getOwnPr Array.isArray(d)?d.map(String):d+"";d+""!==b.oldValue&&(e.val(d),b.oldValue=d+"")};d.bound("change",function(){if(!1!==e.data("duplex-observe")){var f=e.val(),f=Array.isArray(f)?f.map(function(b){return d.pipe(b,d,"get")}):d.pipe(f,d,"get");f+""!==b.oldValue&&c(f);d.changed.call(b,f,d)}});qa(b,function(){ya(d);d.changed.call(b,c(),d)},NaN)};X.TEXTAREA=X.INPUT;var ga=avalon.eventHooks;"onmouseenter"in B||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(b,c){ga[b]={type:c,deel:function(c, e){return function(f){var g=f.relatedTarget;if(!g||g!==c&&!(c.compareDocumentPosition(g)&16))return delete f.type,f.type=b,e.call(c,f)}}}});avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(b,c){r[b]&&!ga.animationend&&(ga.animationend={type:c})});"oninput"in p.createElement("input")||(ga.input={type:"propertychange",deel:function(b,c){return function(d){if("value"===d.propertyName)return d.type="input",c.call(b,d)}}});if(void 0===p.onmousewheel){var Ub= void 0!==p.onwheel?"wheel":"DOMMouseScroll",id="wheel"===Ub?"deltaY":"detail";ga.mousewheel={type:Ub,deel:function(b,c){return function(d){d.wheelDeltaY=d.wheelDelta=0]*>([\S\s]*?)<\/script\s*>/gim,kd=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,ld=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/ig,md={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/ig,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/ig,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/ig}, nd=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,od=/([^\#-~| |!])/g,Xa=avalon.filters={uppercase:function(b){return b.toUpperCase()},lowercase:function(b){return b.toLowerCase()},truncate:function(b,c,d){c=c||30;d=void 0===d?"...":d;return b.length>c?b.slice(0,c-d.length)+d:String(b)},camelize:oa,sanitize:function(b){return b.replace(jd,"").replace(ld,function(b,d){var e=b.toLowerCase().match(/<(\w+)\s/);e&&(e=md[e[1]])&&(b=b.replace(e,function(b,c,d){b=d.charAt(0);return c+"="+b+"javascript:void(0)"+b}));return b.replace(kd, diff --git a/avalon.modern.js b/avalon.modern.js index f86459373..aee5ce66b 100644 --- a/avalon.modern.js +++ b/avalon.modern.js @@ -1870,8 +1870,19 @@ var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig") code = code.replace(reg, function(_) { var c = _.charAt(v.length) - if (c === "." || c === "[") { + var method = /^\s*\(/.test(RegExp.rightContext) + if (c === "." || c === "[" || method) {//比如v为aa,我们只匹配aa.bb,aa[cc],不匹配aaa.xxx var name = "var" + String(Math.random()).replace(/^0\./, "") + if (method) {//array.size() + var array = _.split(".") + if (array.length > 2) { + var last = array.pop() + assigns.push(name + " = " + array.join(".")) + return name + "." + last + } else { + return _ + } + } assigns.push(name + " = " + _) return name } else { @@ -3024,9 +3035,7 @@ for (var i in EventManager) { array[i] = EventManager[i] } - array.size = function() { //取得数组长度,这个函数可以同步视图,length不能 - return array._.length - } + avalon.mix(array, CollectionPrototype) return array } @@ -3038,6 +3047,9 @@ _fire: function(method, a, b) { notifySubscribers(this.$events[subscribers], method, a, b) }, + size: function() { //取得数组长度,这个函数可以同步视图,length不能 + return this._.length + }, _add: function(arr, pos) { var oldLength = this.length pos = typeof pos === "number" ? pos : oldLength diff --git a/avalon.modern.min.js b/avalon.modern.min.js index 9faf998ce..0a851449a 100644 --- a/avalon.modern.min.js +++ b/avalon.modern.min.js @@ -14,39 +14,39 @@ e)};e.length&&(f.filters=e);e=[f]}else e=ua(b.data);if(e.length){for(var g=0;f=e l&&(b.msData=b.msData||f)))}f["ms-checked"]&&f["ms-duplex"]&&u("warning!\u4e00\u4e2a\u5143\u7d20\u4e0a\u4e0d\u80fd\u540c\u65f6\u5b9a\u4e49ms-checked\u4e0ems-duplex");e.sort(function(b,c){return b.priority-c.priority});d=e[0]||{};switch(d.type){case "if":case "repeat":case "widget":va([d],c);break;default:va(e,c),!Gb[b.tagName]&&bb.test(b.innerHTML+b.textContent)&&Xa(b,c)}}function va(b,c){b.length&&c.cb(b.length);for(var d=0,e;e=b[d++];)e.vmodels=c,y[e.type](e,c),e.evaluator&&(e.element&&1===e.element.nodeType)&& e.element.removeAttribute(e.name);b.length=0}function $a(b,c){0b&&delete c[d.shift()];return c[e]=f}var d=[];return c}function eb(b,c,d){var e=d.type,f="duplex"===e,g=d.filters?d.filters.join(""): -"",h=c.map(function(b){return b.$id.replace(Lb,"$1")})+b+e+g,k=Mb(b).concat(),l=[],m=[],q=[],n="";d.vars=[];c=cb(c);for(var t=0,n=c.length;ts.maxRepeatSize&&$.pop()}b.length=0}function aa(){A?(r["ready!"].state=2,A.checkDeps()):lb.forEach(function(b){b(avalon)});aa=v}var B=Date.now(),F="$"+B,x=Function("return this")(),Wb=x.require,Xb=x.define,da=!1,w=/[^, ]+/g,La=/^(?:object|array)$/,mb=/^\[object SVG\w*Element\]$/,Yb=/^\[object (Window|DOMWindow|global)\]$/,Aa=Object.prototype,Ma=Aa.hasOwnProperty,Ba=Aa.toString,N=Array.prototype,ja=N.slice,W={},G=p.head,D=p.documentElement,H=p.createDocumentFragment(),ma=p.createElement("div"), -nb={};"Boolean Number String Function Array Date RegExp Object Error".replace(w,function(b){nb["[object "+b+"]"]=b.toLowerCase()});x.avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.isFunction=S;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"===typeof b?nb[Ba.call(b)]||"object":typeof b};avalon.isWindow=function(b){return Yb.test(Ba.call(b))};avalon.isPlainObject=function(b){return!!b&& -"object"===typeof b&&Object.getPrototypeOf(b)===Aa};avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h$","i");return this.outerHTML.replace(RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),"").replace(b,"")},set:function(b){avalon.clearHTML&&(avalon.clearHTML(this),b=avalon.parseHTML(b),Ca(b, -this))}}})}}var la=avalon.vmodels={};avalon.define=function(b,c){var d=b.$id||b;d||u("warning: \u5fc5\u987b\u6307\u5b9a$id");la[d]&&u("warning: "+d+" \u5df2\u7ecf\u5b58\u5728\u4e8eavalon.vmodels\u4e2d");if("object"===typeof b)var e=K(b);else e={$watch:v},c(e),e=K(e),da=!0,c(e),da=!1;e.$id=d;return la[d]=e};var Ka="$id,$watch,$unwatch,$fire,$events,$model,$skipArray".match(w),fa=Object.is||function(b,c){return 0===b&&0===c?1/b===1/c:b!==b?c!==c:b===c},T={},ga=0,pa={},L,M,X,pb,bb,qb=/[-.*+?^${}()|[\]\/\\]/g, -A=v,O={loader:function(b){x.define=b?A.define:Xb;x.require=b?A:Wb},interpolate:function(b){L=b[0];M=b[1];L===M?avalon.error("openTag!==closeTag",SyntaxError):"\x3c!--,--\x3e"===b+""?s.commentInterpolate=!0:(b=L+"test"+M,ma.innerHTML=b,ma.innerHTML!==b&&0<=ma.innerHTML.indexOf("<")&&avalon.error("\u6b64\u5b9a\u754c\u7b26\u4e0d\u5408\u6cd5",SyntaxError),ma.innerHTML="");b=(L+"").replace(qb,"\\$&");var c=(M+"").replace(qb,"\\$&");X=RegExp(b+"(.*?)"+c);pb=RegExp(b+"(.*?)"+c,"g");bb=RegExp(b+".*?"+ -c+"|\\sms-")}};s.debug=!0;s.plugins=O;s.plugins.interpolate(["{{","}}"]);s.paths={};s.shim={};s.maxRepeatSize=100;avalon.config=s;"add,remove".replace(w,function(b){avalon.fn[b+"Class"]=function(c){var d=this[0];c&&("string"===typeof c&&d&&1===d.nodeType)&&c.replace(/\S+/g,function(c){d.classList[b](c)});return this}});avalon.fn.mix({hasClass:function(b){var c=this[0]||{};return 1===c.nodeType&&c.classList.contains(b)},toggleClass:function(b,c){for(var d,e=0,f=b.split(/\s+/),g="boolean"===typeof c;d= -f[e++];)this[(g?c:!this.hasClass(d))?"addClass":"removeClass"](d);return this},attr:function(b,c){return 2===arguments.length?(this[0].setAttribute(b,c),this):this[0].getAttribute(b)},data:function(b,c){b="data-"+Na(b||"");switch(arguments.length){case 2:return this.attr(b,c),this;case 1:var d=this.attr(b);return ia(d);case 0:var e={};N.forEach.call(this[0].attributes,function(c){c&&(b=c.name,b.indexOf("data-")||(b=ha(b.slice(5)),e[b]=ia(c.value)))});return e}},removeData:function(b){b="data-"+Na(b); -this[0].removeAttribute(b);return this},css:function(b,c){if(avalon.isPlainObject(b))for(var d in b)avalon.css(this,d,b[d]);else var e=avalon.css(this,b,c);return void 0!==e?e:this},position:function(){var b,c,d=this[0],e={top:0,left:0};if(d)return"fixed"===this.css("position")?c=d.getBoundingClientRect():(b=this.offsetParent(),c=this.offset(),"HTML"!==b[0].tagName&&(e=b.offset()),e.top+=avalon.css(b[0],"borderTopWidth",!0),e.left+=avalon.css(b[0],"borderLeftWidth",!0)),{top:c.top-e.top-avalon.css(d, -"marginTop",!0),left:c.left-e.left-avalon.css(d,"marginLeft",!0)}},offsetParent:function(){for(var b=this[0].offsetParent||D;b&&"HTML"!==b.tagName&&"static"===avalon.css(b,"position");)b=b.offsetParent;return avalon(b||D)},bind:function(b,c,d){if(this[0])return avalon.bind(this[0],b,c,d)},unbind:function(b,c,d){this[0]&&avalon.unbind(this[0],b,c,d);return this},val:function(b){var c=this[0];if(c&&1===c.nodeType){var d=0===arguments.length,e=d?":get":":set",f=Zb,g;g=c.tagName.toLowerCase();g="input"=== -g&&/checkbox|radio/.test(c.type)?"checked":g;if(e=f[g+e])var h=e(c,b);else{if(d)return(c.value||"").replace(/\r/g,"");c.value=b}}return d?h:this}});D.dataset&&(avalon.fn.data=function(b,c){var d=this[0].dataset;switch(arguments.length){case 2:return d[b]=c,this;case 1:return c=d[b],ia(c);case 0:var e={};for(b in d)e[b]=ia(d[b]);return e}});var zb=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){avalon.fn[b]=function(d){var e=this[0]||{},f= -e.window&&e.document?e:9===e.nodeType?e.defaultView:!1,g="scrollTop"===b;if(arguments.length)f?f.scrollTo(!g?d:avalon(f).scrollLeft(),g?d:avalon(f).scrollTop()):e[b]=d;else return f?f[c]:e[b]}});var z=avalon.cssHooks={},rb=["","-webkit-","-moz-","-ms-"],Da={"float":"cssFloat"};avalon.cssNumber=J("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom");avalon.cssName=function(b,c,d){if(Da[b])return Da[b];c=c||D.style;for(var e=0,f=rb.length;el&&(e=e-avalon.css(c,"border"+d[0]+"Width",!0)-avalon.css(c,"border"+d[1]+"Width",!0));-4===l&&(e= -e-avalon.css(c,"padding"+d[0],!0)-avalon.css(c,"padding"+d[1],!0));return e};z[c+"&get"]=function(b){var d=[];Oa(b,d);for(var e=z[c+":get"](b),f=0,m;m=d[f++];){b=m.node;for(var q in m)"string"===typeof m[q]&&(b.style[q]=m[q])}return e};avalon.fn[c]=function(g){var h=this[0];if(0===arguments.length){if(h.setTimeout)return h["inner"+b]||h.document.documentElement[d];if(9===h.nodeType){var k=h.documentElement;return Math.max(h.body[e],k[e],h.body[f],k[f],k[d])}return z[c+"&get"](h)}return this.css(c, -g)};avalon.fn["inner"+b]=function(){return z[c+":get"](this[0],void 0,-2)};avalon.fn["outer"+b]=function(b){return z[c+":get"](this[0],void 0,!0===b?2:0)}});avalon.fn.offset=function(){var b=this[0],c={left:0,top:0};if(!b||!b.tagName||!b.ownerDocument)return c;var d=b.ownerDocument,e=d.documentElement,d=d.defaultView;if(!e.contains(b))return c;void 0!==b.getBoundingClientRect&&(c=b.getBoundingClientRect());return{top:c.top+d.pageYOffset-e.clientTop,left:c.left+d.pageXOffset-e.clientLeft}};var Zb= -{"select:get":function(b,c){for(var d,e=b.options,f=b.selectedIndex,g="select-one"===b.type||0>f,h=g?null:[],k=g?f+1:e.length,l=0>f?k:g?f:0;l]*)\/>/ig,bc=J(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),cc=p.createElement("script");avalon.parseHTML=function(b){"string"!==typeof b&&(b+="");b=b.replace(ac,"<$1>").trim();var c=($b.exec(b)||["",""])[1].toLowerCase(),c=C[c]||C._default,d=H.cloneNode(!1);c.innerHTML=b;b=c.getElementsByTagName("script");if(b.length)for(var e=0,f;f=b[e++];)if(bc[f.type]){var g=cc.cloneNode(!1); -N.forEach.call(f.attributes,function(b){g.setAttribute(b.name,b.value)});g.text=f.text;f.parentNode.replaceChild(g,f)}for(;b=c.firstChild;)d.appendChild(b);return d};avalon.innerHTML=function(b,c){var d=this.parseHTML(c);this.clearHTML(b).appendChild(d)};avalon.clearHTML=function(b){for(b.textContent="";b.firstChild;)b.removeChild(b.firstChild);return b};var Q={$watch:function(b,c){if("function"===typeof c){var d=this.$events[b];d?d.push(c):this.$events[b]=[c]}else this.$events=this.$watch.backup; +"",h=c.map(function(b){return b.$id.replace(Lb,"$1")})+b+e+g,k=Mb(b).concat(),l=[],m=[],q=[],n="";d.vars=[];c=cb(c);for(var t=0,n=c.length;ts.maxRepeatSize&&$.pop()}b.length=0}function aa(){A?(r["ready!"].state=2,A.checkDeps()):lb.forEach(function(b){b(avalon)});aa=v}var B=Date.now(),F="$"+B,x=Function("return this")(),Wb=x.require,Xb=x.define,da=!1,w=/[^, ]+/g,La=/^(?:object|array)$/,mb=/^\[object SVG\w*Element\]$/,Yb=/^\[object (Window|DOMWindow|global)\]$/,Aa=Object.prototype,Ma=Aa.hasOwnProperty, +Ba=Aa.toString,N=Array.prototype,ja=N.slice,W={},G=p.head,D=p.documentElement,H=p.createDocumentFragment(),ma=p.createElement("div"),nb={};"Boolean Number String Function Array Date RegExp Object Error".replace(w,function(b){nb["[object "+b+"]"]=b.toLowerCase()});x.avalon=function(b){return new avalon.init(b)};avalon.init=function(b){this[0]=this.element=b};avalon.fn=avalon.prototype=avalon.init.prototype;avalon.isFunction=S;avalon.type=function(b){return null==b?String(b):"object"===typeof b||"function"=== +typeof b?nb[Ba.call(b)]||"object":typeof b};avalon.isWindow=function(b){return Yb.test(Ba.call(b))};avalon.isPlainObject=function(b){return!!b&&"object"===typeof b&&Object.getPrototypeOf(b)===Aa};avalon.mix=avalon.fn.mix=function(){var b,c,d,e,f,g=arguments[0]||{},h=1,k=arguments.length,l=!1;"boolean"===typeof g&&(l=g,g=arguments[1]||{},h++);"object"!==typeof g&&"function"!==avalon.type(g)&&(g={});h===k&&(g=this,h--);for(;h';if(!mb.test(ob.firstChild)){var Ca=function(b,c){if(b&&b.childNodes)for(var d=b.childNodes,e=0,f;f=d[e++];)if(f.tagName){var g=p.createElementNS("http://www.w3.org/2000/svg",f.tagName.toLowerCase());N.forEach.call(f.attributes,function(b){g.setAttribute(b.name,b.value)});Ca(f, +g);c.appendChild(g)}};Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(b){var c=this.tagName.toLowerCase(),d=this.parentNode;b=avalon.parseHTML(b);"svg"===c?d.insertBefore(b,this):(c=p.createDocumentFragment(),Ca(b,c),d.insertBefore(c,this));d.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var b=RegExp("$","i");return this.outerHTML.replace(RegExp("<"+ +this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),"").replace(b,"")},set:function(b){avalon.clearHTML&&(avalon.clearHTML(this),b=avalon.parseHTML(b),Ca(b,this))}}})}}var la=avalon.vmodels={};avalon.define=function(b,c){var d=b.$id||b;d||u("warning: \u5fc5\u987b\u6307\u5b9a$id");la[d]&&u("warning: "+d+" \u5df2\u7ecf\u5b58\u5728\u4e8eavalon.vmodels\u4e2d");if("object"===typeof b)var e=K(b);else e={$watch:v},c(e),e=K(e),da=!0,c(e),da=!1;e.$id=d;return la[d]=e};var Ka="$id,$watch,$unwatch,$fire,$events,$model,$skipArray".match(w), +fa=Object.is||function(b,c){return 0===b&&0===c?1/b===1/c:b!==b?c!==c:b===c},T={},ga=0,pa={},L,M,X,pb,bb,qb=/[-.*+?^${}()|[\]\/\\]/g,A=v,O={loader:function(b){x.define=b?A.define:Xb;x.require=b?A:Wb},interpolate:function(b){L=b[0];M=b[1];L===M?avalon.error("openTag!==closeTag",SyntaxError):"\x3c!--,--\x3e"===b+""?s.commentInterpolate=!0:(b=L+"test"+M,ma.innerHTML=b,ma.innerHTML!==b&&0<=ma.innerHTML.indexOf("<")&&avalon.error("\u6b64\u5b9a\u754c\u7b26\u4e0d\u5408\u6cd5",SyntaxError),ma.innerHTML= +"");b=(L+"").replace(qb,"\\$&");var c=(M+"").replace(qb,"\\$&");X=RegExp(b+"(.*?)"+c);pb=RegExp(b+"(.*?)"+c,"g");bb=RegExp(b+".*?"+c+"|\\sms-")}};s.debug=!0;s.plugins=O;s.plugins.interpolate(["{{","}}"]);s.paths={};s.shim={};s.maxRepeatSize=100;avalon.config=s;"add,remove".replace(w,function(b){avalon.fn[b+"Class"]=function(c){var d=this[0];c&&("string"===typeof c&&d&&1===d.nodeType)&&c.replace(/\S+/g,function(c){d.classList[b](c)});return this}});avalon.fn.mix({hasClass:function(b){var c=this[0]|| +{};return 1===c.nodeType&&c.classList.contains(b)},toggleClass:function(b,c){for(var d,e=0,f=b.split(/\s+/),g="boolean"===typeof c;d=f[e++];)this[(g?c:!this.hasClass(d))?"addClass":"removeClass"](d);return this},attr:function(b,c){return 2===arguments.length?(this[0].setAttribute(b,c),this):this[0].getAttribute(b)},data:function(b,c){b="data-"+Na(b||"");switch(arguments.length){case 2:return this.attr(b,c),this;case 1:var d=this.attr(b);return ia(d);case 0:var e={};N.forEach.call(this[0].attributes, +function(c){c&&(b=c.name,b.indexOf("data-")||(b=ha(b.slice(5)),e[b]=ia(c.value)))});return e}},removeData:function(b){b="data-"+Na(b);this[0].removeAttribute(b);return this},css:function(b,c){if(avalon.isPlainObject(b))for(var d in b)avalon.css(this,d,b[d]);else var e=avalon.css(this,b,c);return void 0!==e?e:this},position:function(){var b,c,d=this[0],e={top:0,left:0};if(d)return"fixed"===this.css("position")?c=d.getBoundingClientRect():(b=this.offsetParent(),c=this.offset(),"HTML"!==b[0].tagName&& +(e=b.offset()),e.top+=avalon.css(b[0],"borderTopWidth",!0),e.left+=avalon.css(b[0],"borderLeftWidth",!0)),{top:c.top-e.top-avalon.css(d,"marginTop",!0),left:c.left-e.left-avalon.css(d,"marginLeft",!0)}},offsetParent:function(){for(var b=this[0].offsetParent||D;b&&"HTML"!==b.tagName&&"static"===avalon.css(b,"position");)b=b.offsetParent;return avalon(b||D)},bind:function(b,c,d){if(this[0])return avalon.bind(this[0],b,c,d)},unbind:function(b,c,d){this[0]&&avalon.unbind(this[0],b,c,d);return this},val:function(b){var c= +this[0];if(c&&1===c.nodeType){var d=0===arguments.length,e=d?":get":":set",f=Zb,g;g=c.tagName.toLowerCase();g="input"===g&&/checkbox|radio/.test(c.type)?"checked":g;if(e=f[g+e])var h=e(c,b);else{if(d)return(c.value||"").replace(/\r/g,"");c.value=b}}return d?h:this}});D.dataset&&(avalon.fn.data=function(b,c){var d=this[0].dataset;switch(arguments.length){case 2:return d[b]=c,this;case 1:return c=d[b],ia(c);case 0:var e={};for(b in d)e[b]=ia(d[b]);return e}});var zb=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;avalon.each({scrollLeft:"pageXOffset", +scrollTop:"pageYOffset"},function(b,c){avalon.fn[b]=function(d){var e=this[0]||{},f=e.window&&e.document?e:9===e.nodeType?e.defaultView:!1,g="scrollTop"===b;if(arguments.length)f?f.scrollTo(!g?d:avalon(f).scrollLeft(),g?d:avalon(f).scrollTop()):e[b]=d;else return f?f[c]:e[b]}});var z=avalon.cssHooks={},rb=["","-webkit-","-moz-","-ms-"],Da={"float":"cssFloat"};avalon.cssNumber=J("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom");avalon.cssName=function(b,c,d){if(Da[b])return Da[b]; +c=c||D.style;for(var e=0,f=rb.length;el&&(e=e-avalon.css(c,"border"+d[0]+"Width", +!0)-avalon.css(c,"border"+d[1]+"Width",!0));-4===l&&(e=e-avalon.css(c,"padding"+d[0],!0)-avalon.css(c,"padding"+d[1],!0));return e};z[c+"&get"]=function(b){var d=[];Oa(b,d);for(var e=z[c+":get"](b),f=0,m;m=d[f++];){b=m.node;for(var q in m)"string"===typeof m[q]&&(b.style[q]=m[q])}return e};avalon.fn[c]=function(g){var h=this[0];if(0===arguments.length){if(h.setTimeout)return h["inner"+b]||h.document.documentElement[d];if(9===h.nodeType){var k=h.documentElement;return Math.max(h.body[e],k[e],h.body[f], +k[f],k[d])}return z[c+"&get"](h)}return this.css(c,g)};avalon.fn["inner"+b]=function(){return z[c+":get"](this[0],void 0,-2)};avalon.fn["outer"+b]=function(b){return z[c+":get"](this[0],void 0,!0===b?2:0)}});avalon.fn.offset=function(){var b=this[0],c={left:0,top:0};if(!b||!b.tagName||!b.ownerDocument)return c;var d=b.ownerDocument,e=d.documentElement,d=d.defaultView;if(!e.contains(b))return c;void 0!==b.getBoundingClientRect&&(c=b.getBoundingClientRect());return{top:c.top+d.pageYOffset-e.clientTop, +left:c.left+d.pageXOffset-e.clientLeft}};var Zb={"select:get":function(b,c){for(var d,e=b.options,f=b.selectedIndex,g="select-one"===b.type||0>f,h=g?null:[],k=g?f+1:e.length,l=0>f?k:g?f:0;l]*)\/>/ig,bc=J(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),cc=p.createElement("script");avalon.parseHTML=function(b){"string"!==typeof b&&(b+="");b=b.replace(ac,"<$1>").trim();var c=($b.exec(b)||["",""])[1].toLowerCase(),c=C[c]||C._default,d=H.cloneNode(!1);c.innerHTML=b;b=c.getElementsByTagName("script");if(b.length)for(var e=0,f;f=b[e++];)if(bc[f.type]){var g= +cc.cloneNode(!1);N.forEach.call(f.attributes,function(b){g.setAttribute(b.name,b.value)});g.text=f.text;f.parentNode.replaceChild(g,f)}for(;b=c.firstChild;)d.appendChild(b);return d};avalon.innerHTML=function(b,c){var d=this.parseHTML(c);this.clearHTML(b).appendChild(d)};avalon.clearHTML=function(b){for(b.textContent="";b.firstChild;)b.removeChild(b.firstChild);return b};var Q={$watch:function(b,c){if("function"===typeof c){var d=this.$events[b];d?d.push(c):this.$events[b]=[c]}else this.$events=this.$watch.backup; return this},$unwatch:function(b,c){var d=arguments.length;if(0===d)this.$watch.backup=this.$events,this.$events={};else if(1===d)this.$events[b]=[];else for(var d=this.$events[b]||[],e=d.length;0>~--e;)if(d[e]===c)return d.splice(e,1);return this},$fire:function(b){var c;/^(\w+)!(\S+)$/.test(b)&&(c=RegExp.$1,b=RegExp.$2);var d=this.$events,e=ja.call(arguments,1),f=[b].concat(e);if("all"===c)for(var g in avalon.vmodels)e=avalon.vmodels[g],e!==this&&e.$fire.apply(e,f);else if("up"===c||"down"===c){if(d= d.expr&&p.querySelector(d.expr)){for(g in avalon.vmodels)if(e=avalon.vmodels[g],e!==this&&e.$events.expr){var h=p.querySelector(e.$events.expr);if(h&&("down"===c?d.contains(h):h.contains(d)))h._avalon=e}g=p.getElementsByTagName("*");var k=[];Array.prototype.forEach.call(g,function(b){b._avalon&&(k.push(b._avalon),b._avalon="",b.removeAttribute("_avalon"))});"up"===c&&k.reverse();for(g=0;(c=k[g++])&&!1!==c.$fire.apply(c,f););}}else{f=d[b]||[];c=d.$all||[];for(g=0;d=f[g++];)S(d)&&d.apply(this,e);for(g= 0;d=c[g++];)S(d)&&d.apply(this,arguments)}}},Bb=/^(duplex|on)$/,R=[],ra=0,Cb=200,Sa=Date.now(),Ta,Ea={};avalon.scanCallback=function(b,c){c=c||"$all";(Ea[c]||(Ea[c]=[])).push(b)};avalon.scan=function(b,c,d){b=b||D;var e=Ea[d||"$all"]||[];c=c?[].concat(c):[];var f=0,g=!1,h,k=!1;c.cb=function(b){f+=b;k=!0;setTimeout(function(){if(0>=f&&!g)for(g=!0;h=e.shift();)h()})};Ua(b,c);if(!k)for(;h=e.shift();)h()};var Gb=J("AREA,BASE,BASEFONT,BR,COL,COMMAND,EMBED,HR,IMG,INPUT,LINK,META,PARAM,SOURCE,TRACK,WBR,NOSCRIPT,NOSCRIPT,SCRIPT,STYLE,TEXTAREA"), @@ -80,10 +80,10 @@ b.checked?"ensure":"remove",g=c();Array.isArray(g)||(u("ms-duplex\u5e94\u7528\u4 k.replace(w,function(b){switch(b){case "input":l("input",h);l("compositionstart",f);l("compositionend",g);break;default:l(b,h)}}));b.oldValue=b.value;tb(function(){if(avalon.contains(D,b))fb.call(b);else if(!b.msRetain)return!1});qa(d);e.call(b,b.value)};var gb,Z=[],tb=v;avalon.tick=function(b){1===Z.push(b)&&(gb=setInterval(Pb,60))};try{var ub=HTMLInputElement.prototype,Rb=Object.getOwnPropertyDescriptor(ub,"value").set;Object.defineProperty(ub,"value",{set:Qb,configurable:!0})}catch(oc){tb=avalon.tick}U.SELECT= function(b,c,d){var e=avalon(b);d.handler=function(){var d=c(),d=d&&d.$model||d;Array.isArray(d)?b.multiple||u("ms-duplex\u5728\u4e0d\u80fd\u5bf9\u5e94\u4e00\u4e2a\u6570\u7ec4");d=Array.isArray(d)?d.map(String):d+"";d+""!==b.oldValue&&(e.val(d),b.oldValue=d+"")};d.bound("change",function(){if(!1!==e.data("duplex-observe")){var f=e.val(),f=Array.isArray(f)?f.map(function(b){return d.pipe(b, d,"get")}):d.pipe(f,d,"get");f+""!==b.oldValue&&c(f);d.changed.call(b,f,d)}});ka(b,function(){qa(d);d.changed.call(b,c(),d)},NaN)};U.TEXTAREA=U.INPUT;var na=avalon.eventHooks;"onmouseenter"in D||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(b,c){na[b]={type:c,deel:function(c,e){return function(f){var g=f.relatedTarget;if(!g||g!==c&&!(c.compareDocumentPosition(g)&16))return delete f.type,f.type=b,e.call(c,f)}}}});avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"}, -function(b,c){x[b]&&!na.animationend&&(na.animationend={type:c})});void 0===p.onmousewheel&&(na.mousewheel={type:"wheel",deel:function(b,c){return function(d){d.wheelDeltaY=d.wheelDelta=0b?Math.max(d+b,0):Math.min(b,d);var d=Ia.apply(this.$model,arguments),e=[],f;this._stopFireLength=!0;d.length&&(e=this._del(b,d.length),f=!0);2b?Math.max(d+b,0):Math.min(b,d);var d=Ia.apply(this.$model,arguments),e=[],f;this._stopFireLength=!0;d.length&&(e=this._del(b,d.length), +f=!0);2]*>([\S\s]*?)<\/script\s*>/gim,jc=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,kc=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/ig,lc={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/ig,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/ig, form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/ig},mc=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,nc=/([^\#-~| |!])/g,Ja=avalon.filters={uppercase:function(b){return b.toUpperCase()},lowercase:function(b){return b.toLowerCase()},truncate:function(b,c,d){c=c||30;d=void 0===d?"...":d;return b.length>c?b.slice(0,c-d.length)+d:String(b)},sanitize:x.toStaticHTML?toStaticHTML.bind(x):function(b){return b.replace(ic,"").replace(kc,function(b,d){var e=b.toLowerCase().match(/<(\w+)\s/);e&&(e=lc[e[1]])&&(b=