diff --git a/avalon.js b/avalon.js index 2eb28a712..d525e411a 100644 --- a/avalon.js +++ b/avalon.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.js 1.44 built in 2015.6.16 + avalon.js 1.44 built in 2015.6.25 support IE6+ and other browsers ==================================================*/ (function(global, factory) { @@ -70,7 +70,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -92,7 +92,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -106,12 +106,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -131,14 +137,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -146,13 +152,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -1096,9 +1102,8 @@ avalon.define = function (id, factory) { $watch: noop } factory(scope) //得到所有定义 - avalon.collectDependency = true + model = modelFactory(scope) //偷天换日,将scope换为model - avalon.collectDependency = false stopRepeatAssign = true factory(model) stopRepeatAssign = false @@ -1108,7 +1113,7 @@ avalon.define = function (id, factory) { } //一些不需要被监听的属性 -var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(rword) +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(rword) var defineProperty = Object.defineProperty var canHideOwn = true //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 @@ -1201,7 +1206,7 @@ function modelFactory(source, $special, $model) { } /* jshint ignore:end */ } - + $vmodel.$compute = function () { computed.forEach(function (accessor) { dependencyDetection.begin({ @@ -1249,7 +1254,7 @@ function makeComputedAccessor(name, options) { options.set = options.set || noop function accessor(value) {//计算属性 var oldValue = accessor._value - var init = "_value" in accessor + var init = "_value" in accessor if (arguments.length > 0) { if (stopRepeatAssign) { return this @@ -1261,7 +1266,7 @@ function makeComputedAccessor(name, options) { value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) - init && accessor.notify(this, value, oldValue) //触发$watch回调 + init && accessor.notify(this, value, oldValue) //触发$watch回调 } //将自己注入到低层访问器的订阅数组中 return value @@ -1306,10 +1311,11 @@ function makeComplexAccessor(name, initValue, valueType, list) { son.$events[subscribers] = observes son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) } @@ -1696,7 +1702,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1793,6 +1799,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1879,11 +1887,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1920,6 +1932,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -3367,6 +3381,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -3385,7 +3400,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3768,7 +3782,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3939,7 +3953,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -4008,7 +4022,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -4031,16 +4049,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -4245,11 +4263,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.js b/dist/avalon.js index 2eb28a712..d525e411a 100644 --- a/dist/avalon.js +++ b/dist/avalon.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.js 1.44 built in 2015.6.16 + avalon.js 1.44 built in 2015.6.25 support IE6+ and other browsers ==================================================*/ (function(global, factory) { @@ -70,7 +70,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -92,7 +92,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -106,12 +106,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -131,14 +137,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -146,13 +152,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -1096,9 +1102,8 @@ avalon.define = function (id, factory) { $watch: noop } factory(scope) //得到所有定义 - avalon.collectDependency = true + model = modelFactory(scope) //偷天换日,将scope换为model - avalon.collectDependency = false stopRepeatAssign = true factory(model) stopRepeatAssign = false @@ -1108,7 +1113,7 @@ avalon.define = function (id, factory) { } //一些不需要被监听的属性 -var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(rword) +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(rword) var defineProperty = Object.defineProperty var canHideOwn = true //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 @@ -1201,7 +1206,7 @@ function modelFactory(source, $special, $model) { } /* jshint ignore:end */ } - + $vmodel.$compute = function () { computed.forEach(function (accessor) { dependencyDetection.begin({ @@ -1249,7 +1254,7 @@ function makeComputedAccessor(name, options) { options.set = options.set || noop function accessor(value) {//计算属性 var oldValue = accessor._value - var init = "_value" in accessor + var init = "_value" in accessor if (arguments.length > 0) { if (stopRepeatAssign) { return this @@ -1261,7 +1266,7 @@ function makeComputedAccessor(name, options) { value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) - init && accessor.notify(this, value, oldValue) //触发$watch回调 + init && accessor.notify(this, value, oldValue) //触发$watch回调 } //将自己注入到低层访问器的订阅数组中 return value @@ -1306,10 +1311,11 @@ function makeComplexAccessor(name, initValue, valueType, list) { son.$events[subscribers] = observes son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) } @@ -1696,7 +1702,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1793,6 +1799,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1879,11 +1887,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1920,6 +1932,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -3367,6 +3381,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -3385,7 +3400,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3768,7 +3782,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3939,7 +3953,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -4008,7 +4022,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -4031,16 +4049,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -4245,11 +4263,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.min.js b/dist/avalon.min.js index b5bbc9533..faf740755 100644 --- a/dist/avalon.min.js +++ b/dist/avalon.min.js @@ -1,3 +1,3 @@ -!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("Avalon requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(){e.console&&avalon.config.debug&&Function.apply.call(console.log,console,arguments)}function r(){}function i(e,t){"string"==typeof e&&(e=e.match(Dt)||[]);for(var n={},r=void 0!==t?t:1,a=0,i=e.length;i>a;a++)n[e[a]]=r;return n}function o(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function l(e){return Bt.test(Vt.call(e))}function s(e,t){return e=Math.floor(e)||0,0>e?Math.max(t+e,0):Math.min(e,t)}function c(e){if(!e)return!1;var t=e.length;if(t===t>>>0){var n=Vt.call(e).slice(8,-1);if(/(?:regexp|string|function|window|global)$/i.test(n))return!1;if("Array"===n)return!0;try{return{}.propertyIsEnumerable.call(e,"length")===!1?/^\s?function/.test(e.item||e.callee):!0}catch(r){return!e.window}}return!1}function u(e,t,n){var r="for(var "+e+"i=0,n = this.length; i < n; i++){"+t.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+n;return Function("fn,scope",r)}function f(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}}function p(){return(new XMLSerializer).serializeToString(this)}function d(e,t){if(e&&e.childNodes)for(var n,r=e.childNodes,a=0;n=r[a++];)if(n.tagName){var i=_t.createElementNS(fn,n.tagName.toLowerCase());Ut.forEach.call(n.attributes,function(e){i.setAttribute(e.name,e.value)}),d(n,i),t.appendChild(i)}}function v(e){var t={};for(var n in e)t[n]=e[n];var r=t.target=e.srcElement;if(0===e.type.indexOf("key"))t.which=null!=e.charCode?e.charCode:e.keyCode;else if(dn.test(e.type)){var a=r.ownerDocument||_t,i="BackCompat"===a.compatMode?a.body:a.documentElement;t.pageX=e.clientX+(i.scrollLeft>>0)-(i.clientLeft>>0),t.pageY=e.clientY+(i.scrollTop>>0)-(i.clientTop>>0),t.wheelDeltaY=t.wheelDelta,t.wheelDeltaX=0}return t.timeStamp=new Date-0,t.originalEvent=e,t.preventDefault=function(){e.returnValue=!1},t.stopPropagation=function(){e.cancelBubble=!0},t}function h(e){for(var t in e)if(Rt.call(e,t)){var n=e[t];"function"==typeof h.plugins[t]?h.plugins[t](n):"object"==typeof h[t]?avalon.mix(h[t],n):h[t]=n}return this}function m(e){return(e+"").replace(wn,"\\$&")}function g(e,t,n){if(Array.isArray(e)){var r=e.concat();e.length=0;var a=_(e);return a.pushArray(r),a}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var i=Array.isArray(e.$skipArray)?e.$skipArray:[];i.$special=t||{};var o={};n=n||{};var l={},s={},c=[];An.forEach(function(t){delete e[t]});for(var u in e)!function(e,t,r){if(n[e]=t,E(e,t,i)){l[e]=[];var a=avalon.type(t);"object"===a&&Kt(t.get)&&Object.keys(t).length<=2?(r=b(e,t),c.push(r)):r=Pt.test(a)?x(e,t,a,l[e]):y(e,t),s[e]=r}}(u,e[u]);o=Nn(o,Ln(s),e);for(var f in e)s[f]||(o[f]=e[f]);o.$id=Zt(),o.$model=n,o.$events=l;for(u in kn){var p=kn[u];zt||(p=p.bind(o)),o[u]=p}return Mn?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},o.$compute=function(){c.forEach(function(e){Bn.begin({callback:function(t,n){var r=n._name;if(n!==e){var a=t.$events[r];e.vm=o,j(a,e.digest)}}});try{e.get.call(o)}finally{Bn.end()}})},o.$compute(),o}function y(e,t){function n(e){var t=n._value;return arguments.length>0?(Ht||jn(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(Bn.collectDependency(this,n),t)}return T(n,e),n._value=t,n}function b(e,t){function n(e){var t=n._value,r="_value"in n;return arguments.length>0?Ht?this:(n.set.call(this,e),this):(e=n.get.call(this),t!==e&&(n.updateValue(this,e),r&&n.notify(this,e,t)),e)}t.set=t.set||r,n.set=t.set||r,n.get=t.get,T(n,e);var a;return n.digest=function(){n.updateValue=w,n.notify=r,n.call(n.vm),clearTimeout(a),a=setTimeout(function(){T(n,n._name),n.call(n.vm)})},n}function x(e,t,n,r){function a(t){var r=a._value,i=a._vmodel;if(arguments.length>0){if(Ht)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=a._vmodel=g(t),i.$events[St]=s,i.$proxy=l,s.length&&s.forEach(function(e){e.rollback&&(e.rollback(),nn[e.type](e,e.vmodels))})}return a.updateValue(this,i.$model),a.notify(this,this._value,r),this}return Bn.collectDependency(this,a),i}T(a,e);var i=a._vmodel=g(t);return i.$events[St]=r,a}function $(e,t){e.$model[this._name]=this._value=t}function w(e,t){e.$model[this._name]=t}function C(e,t,n){var r=this._name,a=e.$events[r];a&&(L(a),kn.$fire.call(e,r,t,n))}function T(e,t){e._name=t,e.updateValue=$,e.notify=C}function E(e,t,n){if(Kt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var r=n.$special;return e&&"$"===e.charAt(0)&&!r[e]?!1:!0}function k(e,t,n,r){var a=t[n];return 4!==arguments.length?a.call(e):void a.call(e,r)}function _(e){var t=[];t.$id=Zt(),t.$model=e,t.$events={},t.$events[St]=[],t._=g({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in kn)t[n]=kn[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,Pn),t}function A(e,t,n,r,a,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return Pt.test(avalon.type(e))?e.$id?e:g(e,0,e):e});Dn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var p=S(f,this);this.$proxy.splice(f,0,p)}this._fire("add",t,n);break;case"del":var d=this._splice(t,n),v=this.$proxy.splice(t,n);$t(v,"each"),this._fire("del",t,n)}a&&(e=a,t=i,n=o,s=2,a=0)}return O(this.$proxy,r),this.length!==l&&(this._.length=this.length),d}function O(e,t){for(var n,r=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===r}function M(e,t){for(var n={},r=0,a=t.length;a>r;r++){n[r]=e[r];var i=t[r];i in n?(e[r]=n[i],delete n[i]):e[r]=e[i]}}function N(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=g(e,t);return n.$id=Zt("$proxy$each"),n}function S(e,t){var n=Fn.shift();n||(n=N());var r=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===r,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function j(e,t){t=t||Wt[kt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&D(t,e)}function L(e){if(e&&e.length){new Date-Un>444&&"object"==typeof e[0]&&P();for(var t,n=qt.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 H(e){return e.uniqueNumber||(e.uniqueNumber=++Rn)}function D(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+H(n.parentNode):e.name+"-"+H(n));var r=e.lists||(e.lists=[]);avalon.Array.ensure(r,t),t.$uuid=t.$uuid||Zt(),Vn[e.uuid]||(Vn[e.uuid]=1,Vn.push(e))}function P(e){for(var t=Vn.length,n=t,r=[],a={},i={};e=Vn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,r.push(o))}var l=!1;if(r.forEach(function(e){qn[e]!==i[e]&&(a[e]=1,l=!0)}),t=n,l)for(;e=Vn[--t];)if(e.element&&a[e.type]&&B(e.element)){Vn.splice(t,1),delete Vn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);F(e)}qn=i,Un=new Date}function F(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function B(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!Xt.contains(e):!avalon.contains(Xt,e)}function I(e){var t=e.nodeName;return t.toLowerCase()===t&&e.scopeName&&""===e.outerText}function R(e){"url(#default#VML)"!==e.currentStyle.behavior&&(e.style.behavior="url(#default#VML)",e.style.display="inline-block",e.style.zoom=1)}function V(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function U(e){return!e||e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function q(e){if(!("classList"in e)){e.classList={node:e};for(var t in Kn)e.classList[t.slice(1)]=Kn[t]}return e.classList}function W(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:er.test(e)?avalon.parseJSON(e):e}catch(t){}return e}function z(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}function X(e,t){if(e.offsetWidth<=0){if(hr.test(ir["@:get"](e,"display"))){var n={node:e};for(var r in vr)n[r]=e.style[r],e.style[r]=vr[r];t.push(n)}var a=e.parentNode;a&&1===a.nodeType&&X(a,t)}}function Y(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function G(e,t,n,r){for(var a,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;a=e[--s];){var c=l&&t.$map[a]?"el":a;t.hasOwnProperty(c)&&(i.push(a+o+c),r.vars.push(a),"duplex"===r.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function J(e){for(var t=[],n={},r=0;rd;d++)if(s.length){var h="vm"+kt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,G(s,t[d],h,a))}if(c.length||"duplex"!==i){"duplex"!==i&&(e.indexOf("||")>-1||e.indexOf("&&")>-1)&&a.vars.forEach(function(t){var n=new RegExp("\\b"+t+"(?:\\.\\w+|\\[\\w+\\])+","ig");e=e.replace(n,function(n){var r=n.charAt(t.length),a=Qt?e.slice(arguments[1]+n.length):RegExp.rightContext,i=/^\s*\(/.test(a);if("."===r||"["===r||i){var o="var"+String(Math.random()).replace(/^0\./,"");if(i){var l=n.split(".");if(l.length>2){var s=l.pop();return c.push(o+" = "+l.join(".")),o+"."+s}return n}return c.push(o+" = "+n),o}return n})}),a.args=f,delete a.vars;var m=Ar.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"+kt+" = "+e+";\r\n",e+=Z("ret"+kt,o)}else{if("duplex"===i){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Or.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(r,u.concat(g)),a.evaluator=Ar.put(l,m)}catch(y){n("debug: parse error,"+y.message)}return}if("on"===i){-1===e.indexOf("(")?e+=".call(this, $event)":e=e.replace("(",".call(this,"),u.push("$event"),e="\nreturn "+e+";";var b=e.lastIndexOf("\nreturn"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(r,u.concat("'use strict';\n"+p+e)),a.evaluator=Ar.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function K(e,t,n,r,a){Array.isArray(r)&&(e=r.map(function(e){return e.expr?"("+e.value+")":br(e.value)}).join(" + ")),Q(e,t,n),n.evaluator&&!a&&(n.handler=rn[n.handlerName||n.type],avalon.injectBinding(n))}function et(e,t,n){var r=setTimeout(function(){var a=e.innerHTML;clearTimeout(r),a===n?t():et(e,t,a)})}function tt(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function nt(e,t){for(var n,r=0;n=e[r++];)n.vmodels=t,nn[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function rt(e,t){return e.priority-t.priority}function at(e,t,r){var a=!0;if(t.length){for(var i,o=Jr?Jr(e):e.attributes,l=[],s=[],c={},u=0;i=o[u++];)if(i.specified&&(r=i.name.match(Br))){var f=r[1],p=r[2]||"",d=i.value,v=i.name;if(Rr[f]?(p=f,f="on"):Vr[f]&&("enabled"===f&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),f="disabled",d="!("+d+")"),p=f,f="attr",v="ms-"+f+"-"+p,s.push([i.name,v,d])),c[v]=d,"function"==typeof nn[f]){var h={type:f,param:p,element:e,name:v,value:d,priority:(Ir[f]||10*f.charCodeAt(0))+(Number(p.replace(/\D/g,""))||0)};if("html"===f||"text"===f){var m=ct(d);avalon.mix(h,m),h.filters=h.filters.replace(Zr,function(){return h.type="html",h.group=1,""})}else if("duplex"===f)var g=v;else"ms-if-loop"===v&&(h.priority+=100);l.push(h),"widget"===f&&(e.msData=e.msData||c)}}if(l.length){for(l.sort(rt),s.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])}),g&&(c["ms-attr-checked"]&&n("warning!一个控件不能同时定义ms-attr-checked与"+g),c["ms-attr-value"]&&n("warning!一个控件不能同时定义ms-attr-value与"+g)),u=0;h=l[u];u++){if(f=h.type,Ur.test(f))return nt(l.slice(0,u+1),t);a&&(a=!qr.test(f))}nt(l,t)}}a&&!Dr[e.tagName]&&$n.test(e.innerHTML.replace(Kr,"<").replace(ea,">"))&&(Fr&&Fr(e),it(e,t))}function it(e,t){var n=avalon.slice(e.childNodes);ot(n,t)}function ot(e,t){for(var n,r=0;n=e[r++];)lt(n,n.nodeType,t)}function lt(e,t,n){1===t?(st(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&bn.test(e.data)?ft(e,n):h.commentInterpolate&&8===t&&!bn.test(e.nodeValue)&&ft(e,n)}function st(e,t,r){var a=e.getAttribute("ms-skip");if(!e.getAttributeNode)return n("warning "+e.tagName+" no getAttributeNode method");var i=e.getAttributeNode("ms-important"),o=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(r=i||o){var l=avalon.vmodels[r.value];if(!l)return;t=r===i?[l]:[l].concat(t);var s=r.name;e.removeAttribute(s),avalon(e).removeClass(s),tt(e,l)}at(e,t)}}function ct(e,t){if(e.indexOf("|")>0){var n=e.replace(ta,function(e){return Array(e.length+1).join("1")}),r=n.replace(Qr,"ᄢ㍄").indexOf("|");if(r>-1)return{filters:e.slice(r),value:e.slice(0,r),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function ut(e){for(var t,n,r=[],a=0;;){if(n=e.indexOf(gn,a),-1===n)break;if(t=e.slice(a,n),t&&r.push({value:t,filters:"",expr:!1}),a=n+gn.length,n=e.indexOf(yn,a),-1===n)break;t=e.slice(a,n),t&&r.push(ct(t,a)),a=n+yn.length}return t=e.slice(a),t&&r.push({value:t,expr:!1,filters:""}),r}function ft(e,t){var n=[];if(8===e.nodeType)var r=ct(e.nodeValue),a=[r];else a=ut(e.data);if(a.length){for(var i=0;r=a[i++];){var o=_t.createTextNode(r.value);r.expr&&(r.type="text",r.element=o,r.filters=r.filters.replace(Zr,function(){return r.type="html",""}),n.push(r)),Yt.appendChild(o)}e.parentNode.replaceChild(Yt,e),n.length&&nt(n,t)}}function pt(e,t,n){var r=e.templateCache&&e.templateCache[t];if(r){for(var a,i=_t.createDocumentFragment();a=r.firstChild;)i.appendChild(a);return i}return avalon.parseHTML(n)}function dt(e){return null==e?"":e}function vt(e,t,n){return t.param.replace(/\w+/g,function(r){var a=avalon.duplexHooks[r];a&&"function"==typeof a[n]&&(e=a[n](e,t))}),e}function ht(){for(var e=pa.length-1;e>=0;e--){var t=pa[e];t()===!1&&pa.splice(e,1)}pa.length||clearInterval(fa)}function mt(e,t,n,r){var a=e.template.cloneNode(!0),i=avalon.slice(a.childNodes);e.$with||a.insertBefore(_t.createComment(e.signature),a.firstChild),t.appendChild(a);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};r.push(l)}function gt(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),r=t.previousSibling,a=[];r;)r.nodeValue===n&&a.unshift(r),r=r.previousSibling;return a}function yt(e,t,n){for(;;){var r=t.previousSibling;if(!r)break;if(r.parentNode.removeChild(r),n&&n.call(r),r===e)break}}function bt(){var e=g({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Zt("$proxy$with"),e}function xt(e,t,n){e=e||ma.pop(),e||(e=bt());var r=n.$repeat;return e.$key=t,e.$host=r,e.$outer=n.$outer,r.$events?e.$events.$val=r.$events[t]:e.$events={},e}function $t(e){e.forEach(function(e){wt(e,Fn)}),e.length=0}function wt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&F(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>h.maxRepeatSize&&t.pop()}function Ct(e,t){var n="_"+e;if(!Ct[n]){var r=_t.createElement(e);Xt.appendChild(r),t=zt?getComputedStyle(r,null).display:r.currentStyle.display,Xt.removeChild(r),Ct[n]=t}return Ct[n]}function Tt(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var a=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):3,o=r||",",l=n||".",s="",c=function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)};return s=(i?c(a,i):""+Math.round(a)).split("."),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(s[1]||"").length.avalonHide{ display: none!important }",Ot.setAttribute("ms-skip","1"),Ot.className="avalonHide";var Mt,Nt=/\[native code\]/,St="$"+kt,jt=e.require,Lt=e.define,Ht=!1,Dt=/[^, ]+/g,Pt=/^(?:object|array)$/,Ft=/^\[object SVG\w*Element\]$/,Bt=/^\[object (?:Window|DOMWindow|global)\]$/,It=Object.prototype,Rt=It.hasOwnProperty,Vt=It.toString,Ut=Array.prototype,qt=Ut.slice,Wt={},zt=e.dispatchEvent,Xt=_t.documentElement,Yt=_t.createDocumentFragment(),Gt=_t.createElement("div"),Jt={};"Boolean Number String Function Array Date RegExp Object Error".replace(Dt,function(e){Jt["[object "+e+"]"]=e.toLowerCase()});var Zt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Qt=o();avalon=function(e){return new avalon.init(e)},avalon.nextTick=new function(){function t(){for(var e=i.length,t=0;e>t;t++)i[t]();i=i.slice(e)}var n=e.setImmediate,r=e.MutationObserver,a=zt&&e.postMessage;if(n)return n.bind(e);var i=[];if(r){var o=document.createTextNode("avalon");return new r(t).observe(o,{characterData:!0}),function(e){i.push(e),o.data=Math.random()}}return a?(e.addEventListener("message",function(n){var r=n.source;r!==e&&null!==r||"process-tick"!==n.data||(n.stopPropagation(),t())}),function(t){i.push(t),e.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}},avalon.init=function(e){this[0]=this.element=e},avalon.fn=avalon.prototype=avalon.init.prototype,avalon.type=function(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?Jt[Vt.call(e)]||"object":typeof e};var Kt="object"==typeof alert?function(e){try{return/^\s*\bfunction\b/.test(e+"")}catch(t){return!1}}:function(e){return"[object Function]"===Vt.call(e)};avalon.isFunction=Kt,avalon.isWindow=function(e){return e?e==e.document&&e.document!=e:!1},l(e)&&(avalon.isWindow=l);var en;for(en in avalon({}))break;var tn="0"!==en;avalon.isPlainObject=function(e,t){if(!e||"object"!==avalon.type(e)||e.nodeType||avalon.isWindow(e))return!1;try{if(e.constructor&&!Rt.call(e,"constructor")&&!Rt.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(tn)for(t in e)return Rt.call(e,t);for(t in e);return void 0===t||Rt.call(e,t)},Nt.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(e){return"[object Object]"===Vt.call(e)&&Object.getPrototypeOf(e)===It}),avalon.mix=avalon.fn.mix=function(){var e,t,n,r,a,i,o=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[1]||{},l++),"object"==typeof o||Kt(o)||(o={}),l===s&&(o=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e){n=o[t];try{r=e[t]}catch(u){continue}o!==r&&(c&&r&&(avalon.isPlainObject(r)||(a=Array.isArray(r)))?(a?(a=!1,i=n&&Array.isArray(n)?n:[]):i=n&&avalon.isPlainObject(n)?n:{},o[t]=avalon.mix(c,i,r)):void 0!==r&&(o[t]=r))}return o},avalon.mix({rword:Dt,subscribers:St,version:1.44,ui:{},log:n,slice:zt?function(e,t,n){return qt.call(e,t,n)}:function(e,t,n){var r=[],a=e.length;if(void 0===n&&(n=a),"number"==typeof n&&isFinite(n)){t=s(t,a),n=s(n,a);for(var i=t;n>i;++i)r[i-t]=e[i]}return r},noop:r,error:function(e,t){throw(t||Error)(e)},oneObject:i,range:function(e,t,n){n||(n=1),null==t&&(t=e||0,e=0);for(var r=-1,a=Math.max(0,Math.ceil((t-e)/n)),i=new Array(a);++rn&&t(n,e[n])!==!1;n++);else for(n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)break}},getWidgetData:function(e,t){var n=avalon(e).data(),r={};for(var a in n)0===a.indexOf(t)&&(r[a.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[a]);return r},Array:{ensure:function(e,t){return-1===e.indexOf(t)?e.push(t):void 0},removeAt:function(e,t){return!!e.splice(t,1).length},remove:function(e,t){var n=e.indexOf(t);return~n?avalon.Array.removeAt(e,n):!1}}});var nn=avalon.bindingHandlers={},rn=avalon.bindingExecutors={},an=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}var t=e.prototype;return t.put=function(e,t){var n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){var e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0)},t.get=function(e){var t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(!"司徒正美".trim){var on=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(on,"")}}var ln=!{toString:null}.propertyIsEnumerable("toString"),sn=function(){}.propertyIsEnumerable("prototype"),cn=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],un=cn.length;if(Object.keys||(Object.keys=function(e){var t=[],n=sn&&"function"==typeof e;if("string"==typeof e||e&&e.callee)for(var r=0;rl;l++){var s=cn[l];o&&"constructor"===s||!Rt.call(e,s)||t.push(s)}return t}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Vt.call(e)}),r.bind||(Function.prototype.bind=function(e){if(arguments.length<2&&void 0===e)return this;var t=this,n=arguments;return function(){var r,a=[];for(r=1;rr&&(r+=n);n>r;r++)if(this[r]===e)return r;return-1},lastIndexOf:function(e,t){var n=this.length,r=null==t?n-1:t;for(0>r&&(r=Math.max(0,n+r));r>=0;r--)if(this[r]===e)return r;return-1},forEach:u("","_",""),filter:u("r=[],j=0,","if(_)r[j++]=this[i]","return r"),map:u("r=[],","r[i]=_","return r"),some:u("","if(_)return true","return false"),every:u("","if(!_)return false","return true")}),avalon.contains=f,_t.contains||(_t.contains=function(e){return f(_t,e)}),e.SVGElement){_t.createTextNode("x").contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))});var fn="http://www.w3.org/2000/svg",pn=_t.createElementNS(fn,"svg");pn.innerHTML='',Ft.test(pn.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:p,set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,r=avalon.parseHTML(e);if("svg"===t)n.insertBefore(r,this);else{var a=_t.createDocumentFragment();d(r,a),n.insertBefore(a,this)}n.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var e=this.outerHTML,t=new RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),n=new RegExp("$","i");return e.replace(t,"").replace(n,"")},set:function(e){if(avalon.clearHTML){avalon.clearHTML(this);var t=avalon.parseHTML(e);d(t,this)}}}})}!Xt.outerHTML&&e.HTMLElement&&HTMLElement.prototype.__defineGetter__("outerHTML",p);var dn=/^(?:mouse|contextmenu|drag)|click/,vn=avalon.eventHooks;if("onmouseenter"in Xt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){vn[e]={type:t,deel:function(t,n,r){return function(n){var a=n.relatedTarget;return a&&(a===t||16&t.compareDocumentPosition(a))?void 0:(delete n.type,n.type=e,r.call(t,n))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!vn.animationend&&(vn.animationend={type:n})}),"oninput"in _t.createElement("input")||(vn.input={type:"propertychange",deel:function(e,t,n){return function(t){return"value"===t.propertyName?(t.type="input",n.call(e,t)):void 0}}}),void 0===_t.onmousewheel){var hn=void 0!==_t.onwheel?"wheel":"DOMMouseScroll",mn="wheel"===hn?"deltaY":"detail";vn.mousewheel={type:hn,deel:function(e,t,n){return function(t){t.wheelDeltaY=t.wheelDelta=t[mn]>0?-120:120,t.wheelDeltaX=0,Object.defineProperty&&Object.defineProperty(t,"type",{value:"mousewheel"}),n.call(e,t)}}}}var gn,yn,bn,xn,$n,wn=/[-.*+?^${}()|[\]\/\\]/g,Cn={loader:function(t){var n=Mt&&t;e.require=n?Mt:jt,e.define=n?Mt.define:Lt},interpolate:function(e){if(gn=e[0],yn=e[1],gn===yn)throw new SyntaxError("openTag!==closeTag");if(e+""=="")h.commentInterpolate=!0;else{var t=gn+"test"+yn;if(Gt.innerHTML=t,Gt.innerHTML!==t&&Gt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Gt.innerHTML=""}var n=m(gn),r=m(yn);bn=new RegExp(n+"(.*?)"+r),xn=new RegExp(n+"(.*?)"+r,"g"),$n=new RegExp(n+".*?"+r+"|\\sms-")}};h.debug=!0,h.plugins=Cn,h.plugins.interpolate(["{{","}}"]),h.paths={},h.shim={},h.maxRepeatSize=100,avalon.config=h;var Tn=/(\w+)\[(avalonctrl)="(\S+)"\]/,En=_t.querySelectorAll?function(e){return _t.querySelectorAll(e)}:function(e){for(var t,n=e.match(Tn),r=_t.getElementsByTagName(n[1]),a=[],i=0;t=r[i++];)t.getAttribute(n[2])===n[3]&&a.push(t);return a},kn={$watch:function(e,t){if("function"==typeof t){var n=this.$events[e];n?n.push(t):this.$events[e]=[t]}else this.$events=this.$watch.backup;return this},$unwatch:function(e,t){var n=arguments.length;if(0===n)this.$watch.backup=this.$events,this.$events={};else if(1===n)this.$events[e]=[];else for(var r=this.$events[e]||[],a=r.length;~--a<0;)if(r[a]===t)return r.splice(a,1);return this},$fire:function(e){var t,n,r,a;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var i=this.$events;if(i){var o=qt.call(arguments,1),l=[e].concat(o);if("all"===t)for(n in avalon.vmodels)r=avalon.vmodels[n],r!==this&&r.$fire.apply(r,l);else if("up"===t||"down"===t){var s=i.expr?En(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(r=avalon.vmodels[n],r!==this&&r.$events.expr){var c=En(r.$events.expr);if(0===c.length)continue;Ut.forEach.call(c,function(e){Ut.forEach.call(s,function(n){var a="down"===t?n.contains(e):e.contains(n);a&&(e._avalon=r)})})}var u=_t.getElementsByTagName("*"),f=[];for(Ut.forEach.call(u,function(e){e._avalon&&(f.push(e._avalon),e._avalon="",e.removeAttribute("_avalon"))}),"up"===t&&f.reverse(),n=0;(a=f[n++])&&a.$fire.apply(a,l)!==!1;);}else{var p=i[e]||[],d=i.$all||[];for(n=0;a=p[n++];)Kt(a)&&a.apply(this,o);for(n=0;a=d[n++];)Kt(a)&&a.apply(this,arguments)}}}},_n=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),_n[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var i=g(e);else{var o={$watch:r};t(o),avalon.collectDependency=!0,i=g(o),avalon.collectDependency=!1,Ht=!0,t(i),Ht=!1}return i.$id=a,_n[a]=i};var An=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(Dt),On=Object.defineProperty,Mn=!0;try{On({},"_",{value:"x"});var Nn=Object.defineProperties}catch(Sn){Mn=!1}var jn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},Ln=zt?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};if(!Mn&&("__defineGetter__"in avalon&&(On=function(e,t,n){return"value"in n&&(e[t]=n.value),"get"in n&&e.__defineGetter__(t,n.get),"set"in n&&e.__defineSetter__(t,n.set),e},Nn=function(e,t){for(var n in t)t.hasOwnProperty(n)&&On(e,n,t[n]);return e}),Qt)){var Hn={};e.execScript(["Function parseVB(code)"," ExecuteGlobal(code)","End Function"].join("\n"),"VBScript"),Nn=function(t,n,r){var a=[];a.push("\r\n Private [__data__], [__proxy__]"," Public Default Function [__const__](d, p)"," Set [__data__] = d: set [__proxy__] = p"," Set [__const__] = Me"," End Function");for(t in r)n.hasOwnProperty(t)||a.push(" Public ["+t+"]");An.forEach(function(e){n.hasOwnProperty(e)||a.push(" Public ["+e+"]")}),a.push(" Public [hasOwnProperty]");for(t in n)a.push(" Public Property Let ["+t+"](val"+kt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+kt+")"," End Property"," Public Property Set ["+t+"](val"+kt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+kt+")"," End Property"," Public Property Get ["+t+"]"," On Error Resume Next"," Set["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," If Err.Number <> 0 Then"," ["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," End If"," On Error Goto 0"," End Property");a.push("End Class");var i=a.join("\r\n"),o=Hn[i];o||(o=Zt("VBClass"),e.parseVB("Class "+o+i),e.parseVB(["Function "+o+"Factory(a, b)"," Dim o"," Set o = (New "+o+")(a, b)"," Set "+o+"Factory = o","End Function"].join("\r\n")),Hn[i]=o);var l=e[o+"Factory"](n,k);return l}}var Dn=Ut.splice,Pn={_splice:Dn,_fire:function(e,t,n){L(this.$events[St],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Ut.push.apply(this.$model,e),A.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&&(Ut.unshift.apply(this.$model,arguments),A.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return A.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return A.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,r=[],a=Dn.apply(this.$model,arguments);return a.length&&(r.push("del",e,a.length,0),t=!0),n>2&&(t?r.splice(3,1,0,"add",e,n-2):r.push("add",e,n-2,0),t=!0),t?A.apply(this,r):[]},contains:function(e){return-1!==this.indexOf(e)},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>=0?(this.$model.splice(e,1),A.call(this,"del",e,1,0)):[]},clear:function(){return $t(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],t)&&this.removeAt(t);else this.clear()},ensure:function(e){return this.contains(e)||this.push(e),this},set:function(e,t){if(e>=0){var n=avalon.type(t);t&&t.$model&&(t=t.$model);var r=this[e];if("object"===n)for(var a in t)r.hasOwnProperty(a)&&(r[a]=t[a]);else if("array"===n)r.clear().push.apply(r,t);else if(r!==t){this[e]=t,this.$model[e]=t;var i=this.$proxy[e];i&&L(i.$events.el)}}return this}};"sort,reverse".replace(Dt,function(e){Pn[e]=function(){var t,n=this.$model,r=n.concat(),a=Math.random(),i=[]; -Ut[e].apply(n,arguments);for(var o=0,l=r.length;l>o;o++){var s=n[o],c=r[o];if(jn(s,c))i.push(o);else{var u=r.indexOf(s);i.push(u),r[u]=a,t=!0}}return t&&(M(this,i),M(this.$proxy,i),this._fire("move",i),O(this.$proxy,0)),this}});var Fn=[],Bn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),In=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){Bn.begin({callback:function(t,n){j(t.$events[n._name],e)}});try{var n=In.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(r){delete e.evaluator;var a=e.element;if(3===a.nodeType){var i=a.parentNode;h.commentInterpolate?i.replaceChild(_t.createComment(e.value),a):a.data=gn+e.value+yn}}finally{Bn.end()}}};var Rn=0,Vn=avalon.$$subscribers=[],Un=new Date,qn={},Wn={area:[1,"",""],param:[1,"",""],col:[2,"","
"],legend:[1,"
","
"],option:[1,""],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],g:[1,'',""],_default:zt?[0,"",""]:[1,"X
","
"]};Wn.th=Wn.td,Wn.optgroup=Wn.option,Wn.tbody=Wn.tfoot=Wn.colgroup=Wn.caption=Wn.thead,String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(Dt,function(e){Wn[e]=Wn.g});var zn=/<([\w:]+)/,Xn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Yn=zt?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/gi,Gn=i(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),Jn=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,Zn=_t.createElement("script"),Qn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Yt.cloneNode(!1);if("string"!=typeof e)return t;if(!Qn.test(e))return t.appendChild(_t.createTextNode(e)),t;e=e.replace(Xn,"<$1>").trim();var n,r,a=(zn.exec(e)||["",""])[1].toLowerCase(),i=Wn[a]||Wn._default,o=Gt;zt||(e=e.replace(Yn,"
$1")),o.innerHTML=i[1]+e+i[2];var l=o.getElementsByTagName("script");if(l.length)for(var s,c=0;s=l[c++];)Gn[s.type]&&(r=Zn.cloneNode(!1),Ut.forEach.call(s.attributes,function(e){e&&e.specified&&(r[e.name]=e.value,r.setAttribute(e.name,e.value))}),r.text=s.text,s.parentNode.replaceChild(r,s));if(!zt){var u="X
"===i[1]?o.lastChild.firstChild:o.lastChild;if(u&&"TABLE"===u.tagName&&"tbody"!==a)for(l=u.childNodes,c=0;s=l[c++];)if("TBODY"===s.tagName&&!s.innerHTML){u.removeChild(s);break}l=o.getElementsByTagName("br");for(var f=l.length;s=l[--f];)"msNoScope"===s.className&&s.parentNode.removeChild(s);for(l=o.all,c=0;s=l[c++];)I(s)&&R(s)}for(c=i[0];c--;o=o.lastChild);for(;n=o.firstChild;)t.appendChild(n);return t},avalon.innerHTML=function(e,t){if(!zt&&!Yn.test(t)&&!Jn.test(t))try{return void(e.innerHTML=t)}catch(n){}var r=this.parseHTML(t);this.clearHTML(e).appendChild(r)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e};var Kn={_toString:function(){var e=this.node,t=e.className,n="string"==typeof t?t:t.baseVal;return n.split(/\s+/).join(" ")},_contains:function(e){return(" "+this+" ").indexOf(" "+e+" ")>-1},_add:function(e){this.contains(e)||this._set(this+" "+e)},_remove:function(e){this._set((" "+this+" ").replace(" "+e+" "," "))},__set:function(e){e=e.trim();var t=this.node;Ft.test(t)?t.setAttribute("class",e):t.className=e}};"add,remove".replace(Dt,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){q(n)[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&q(t).contains(e)},toggleClass:function(e,t){for(var n,r=0,a=String(e).split(/\s+/),i="boolean"==typeof t;n=a[r++];){var o=i?t:!this.hasClass(n);this[o?"addClass":"removeClass"](n)}return this},attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){switch(e="data-"+V(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return W(n);case 0:var r={};return Ut.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=U(e.slice(5)),r[e]=W(t.value)))}),r}},removeData:function(e){return e="data-"+V(e),this[0].removeAttribute(e),this},css:function(e,t){if(avalon.isPlainObject(e))for(var n in e)avalon.css(this,n,e[n]);else var r=avalon.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=avalon.css(e[0],"borderTopWidth",!0),r.left+=avalon.css(e[0],"borderLeftWidth",!0),r.top-=e.scrollTop(),r.left-=e.scrollLeft()),{top:t.top-r.top-avalon.css(n,"marginTop",!0),left:t.left-r.left-avalon.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===avalon.css(e,"position");)e=e.offsetParent;return avalon(e||Xt)},bind:function(e,t,n){return this[0]?avalon.bind(this[0],e,t,n):void 0},unbind:function(e,t,n){return this[0]&&avalon.unbind(this[0],e,t,n),this},val:function(e){var t=this[0];if(t&&1===t.nodeType){var n=0===arguments.length,r=n?":get":":set",a=gr[Y(t)+r];if(a)var i=a(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?i:this}});var er=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,tr=/^[\],:{}\s]*$/,nr=/(?:^|:|,)(?:\s*\[)+/g,rr=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,ar=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g;avalon.parseJSON=e.JSON?JSON.parse:function(e){if("string"==typeof e){if(e=e.trim(),e&&tr.test(e.replace(rr,"@").replace(ar,"]").replace(nr,"")))return new Function("return "+e)();avalon.error("Invalid JSON: "+e)}return e},avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var r=this[0]||{},a=z(r),i="scrollTop"===e;return arguments.length?void(a?a.scrollTo(i?avalon(a).scrollLeft():n,i?n:avalon(a).scrollTop()):r[e]=n):a?t in a?a[t]:Xt[e]:r[e]}});var ir=avalon.cssHooks={},or=["","-webkit-","-o-","-moz-","-ms-"],lr={"float":zt?"cssFloat":"styleFloat"};if(avalon.cssNumber=i("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(lr[e])return lr[e];t=t||Xt.style;for(var r=0,a=or.length;a>r;r++)if(n=U(or[r]+e),n in t)return lr[e]=n;return null},ir["@:set"]=function(e,t,n){try{e.style[t]=n}catch(r){}},e.getComputedStyle)ir["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,r=getComputedStyle(e,null);return r&&(n="filter"===t?r.getPropertyValue(t):r[t],""===n&&(n=e.style[t])),n},ir["opacity:get"]=function(e){var t=ir["@:get"](e,"opacity");return""===t?"1":t};else{var sr=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,cr=/^(top|right|bottom|left)$/,ur=/alpha\([^)]*\)/i,fr=!!e.XDomainRequest,pr="DXImageTransform.Microsoft.Alpha",dr={thin:fr?"1px":"2px",medium:fr?"3px":"4px",thick:fr?"5px":"6px"};ir["@:get"]=function(e,t){var n=e.currentStyle,r=n[t];if(sr.test(r)&&!cr.test(r)){var a=e.style,i=a.left,o=e.runtimeStyle.left;e.runtimeStyle.left=n.left,a.left="fontSize"===t?"1em":r||0,r=a.pixelLeft+"px",a.left=i,e.runtimeStyle.left=o}return"medium"===r&&(t=t.replace("Width","Style"),"none"===n[t]&&(r="0px")),""===r?"auto":dr[r]||r},ir["opacity:set"]=function(e,t,n){var r=e.style,a=isFinite(n)&&1>=n?"alpha(opacity="+100*n+")":"",i=r.filter||"";r.zoom=1,r.filter=(ur.test(i)?i.replace(ur,a):i+" "+a).trim(),r.filter||r.removeAttribute("filter")},ir["opacity:get"]=function(e){var t=e.filters.alpha||e.filters[pr],n=t&&t.enabled?t.opacity:100;return n/100+""}}"top,left".replace(Dt,function(e){ir[e+":get"]=function(t){var n=ir["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var vr={position:"absolute",visibility:"hidden",display:"block"},hr=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(Dt,function(e){var t=e.toLowerCase(),n="client"+e,r="scroll"+e,a="offset"+e;ir[t+":get"]=function(t,n,r){var i=-4;"number"==typeof r&&(i=r),n="Width"===e?["Left","Right"]:["Top","Bottom"];var o=t[a];return 2===i?o+avalon.css(t,"margin"+n[0],!0)+avalon.css(t,"margin"+n[1],!0):(0>i&&(o=o-avalon.css(t,"border"+n[0]+"Width",!0)-avalon.css(t,"border"+n[1]+"Width",!0)),-4===i&&(o=o-avalon.css(t,"padding"+n[0],!0)-avalon.css(t,"padding"+n[1],!0)),o)},ir[t+"&get"]=function(e){var n=[];X(e,n);for(var r,a=ir[t+":get"](e),i=0;r=n[i++];){e=r.node;for(var o in r)"string"==typeof r[o]&&(e.style[o]=r[o])}return a},avalon.fn[t]=function(i){var o=this[0];if(0===arguments.length){if(o.setTimeout)return o["inner"+e]||o.document.documentElement[n];if(9===o.nodeType){var l=o.documentElement;return Math.max(o.body[r],l[r],o.body[a],l[a],l[n])}return ir[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return ir[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return ir[t+":get"](this[0],void 0,e===!0?2:0)}}),avalon.fn.offset=function(){var e=this[0],t={left:0,top:0};if(!e||!e.tagName||!e.ownerDocument)return t;var n=e.ownerDocument,r=n.body,a=n.documentElement,i=n.defaultView||n.parentWindow;if(!avalon.contains(a,e))return t;e.getBoundingClientRect&&(t=e.getBoundingClientRect());var o=a.clientTop||r.clientTop,l=a.clientLeft||r.clientLeft,s=Math.max(i.pageYOffset||0,a.scrollTop,r.scrollTop),c=Math.max(i.pageXOffset||0,a.scrollLeft,r.scrollLeft);return{top:t.top+s-o,left:t.left+c-l}};var mr=/^]+))?)*\s+value[\s=]/i,gr={"option:get":Qt?function(e){return mr.test(e.outerHTML)?e.value:e.text.trim()}:function(e){return e.value},"select:get":function(e,t){for(var n,r=e.options,a=e.selectedIndex,i=gr["option:get"],o="select-one"===e.type||0>a,l=o?null:[],s=o?a+1:r.length,c=0>a?s:o?a:0;s>c;c++)if(n=r[c],(n.selected||c===a)&&!n.disabled){if(t=i(n),o)return t;l.push(t)}return l},"select:set":function(e,t,n){t=[].concat(t);for(var r,a=gr["option:get"],i=0;r=e.options[i++];)(r.selected=t.indexOf(a(r))>-1)&&(n=!0);n||(e.selectedIndex=-1)}},yr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},br=e.JSON&&JSON.stringify||function(e){return'"'+e.replace(/[\\\"\x00-\x1f]/g,function(e){var t=yr[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'},xr=["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(","),$r=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,wr=/[^\w$]+/g,Cr=new RegExp(["\\b"+xr.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Tr=/\b\d[^,]*/g,Er=/^,+|,+$/g,kr=new an(512),_r=function(e){var t=","+e.trim(),n=kr.get(t);if(n)return n;var r=e.replace($r,"").replace(wr,",").replace(Cr,"").replace(Tr,"").replace(Er,"").split(/^$|,+/);return kr.put(t,J(r))},Ar=new an(128),Or=/\w\[.*\]|\w\.\w/,Mr=/(\$proxy\$[a-z]+)\d+$/,Nr=/\)\s*$/,Sr=/\)\s*\|/g,jr=/\|\s*([$\w]+)/g,Lr=/"\s*\["/g,Hr=/"\s*\(/g;avalon.parseExprProxy=K,avalon.scan=function(e,t){e=e||Xt;var n=t?[].concat(t):[];st(e,n)};var Dr=i("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),Pr=function(e,t,n){var r=e.getAttribute(t);if(r)for(var a,i=0;a=n[i++];)if(a.hasOwnProperty(r)&&"function"==typeof a[r])return a[r]},Fr=Qt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var r=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=r}}:0,Br=/ms-(\w+)-?(.*)/,Ir={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Rr=i("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),Vr=i("value,title,alt,checked,selected,disabled,readonly,enabled"),Ur=/^if|widget|repeat$/,qr=/^each|with|html|include$/;if(!"1"[0])var Wr=new an(512),zr=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Xr=/^['"]/,Yr=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,Gr=/&/g,Jr=function(e){var t=e.outerHTML;if("(?:[\s\S]+?)<\/noscript>/gim,la=/([\s\S]+?)<\/noscript>/im,sa=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},ca=avalon.templateCache={};nn.attr=function(e,t){var n=e.value.trim(),r=!0;if(n.indexOf(gn)>-1&&n.indexOf(yn)>2&&(r=!1,bn.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(r=!0,n=RegExp.$1)),"include"===e.type){var a=e.element;e.includeRendered=Pr(a,"data-include-rendered",t),e.includeLoaded=Pr(a,"data-include-loaded",t);var i=e.includeReplace=!!avalon(a).data("includeReplace");avalon(a).data("includeCache")&&(e.templateCache={}),e.startInclude=_t.createComment("ms-include"),e.endInclude=_t.createComment("ms-include-end"),i?(e.element=e.startInclude,a.parentNode.insertBefore(e.startInclude,a),a.parentNode.insertBefore(e.endInclude,a.nextSibling)):(a.insertBefore(e.startInclude,a.firstChild),a.appendChild(e.endInclude))}e.handlerName="attr",K(n,t,e,r?0:ut(e.value))},rn.attr=function(t,n,r){var a=r.type,i=r.param;if("css"===a)avalon(n).css(i,t);else if("attr"===a){var o=t===!1||null===t||void 0===t;!zt&&aa[i]&&(i=aa[i]);var l=ra[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=Ft.test(n)?!1:_t.namespaces&&I(n)?!0:i in n.cloneNode(!1);s?n[i]=t:n.setAttribute(i,t)}else if("include"===a&&t){var c=r.vmodels,u=r.includeRendered,f=r.includeLoaded,p=r.includeReplace,d=p?n.parentNode:n,v=function(e){if(f){var n=f.apply(d,[e].concat(c));"string"==typeof n&&(e=n)}u&&et(d,function(){u.call(d)},0/0);var a=r.includeLastID;if(r.templateCache&&a&&a!==t){var i=r.templateCache[a];i||(i=r.templateCache[a]=_t.createElement("div"),Ot.appendChild(i))}for(r.includeLastID=t;;){var o=r.startInclude.nextSibling;if(!o||o===r.endInclude)break;d.removeChild(o),i&&i.appendChild(o)}var l=pt(r,t,e),s=avalon.slice(l.childNodes);d.insertBefore(l,r.endInclude),ot(s,c)};if("src"===r.param)if("string"==typeof ca[t])avalon.nextTick(function(){v(ca[t])});else if(Array.isArray(ca[t]))ca[t].push(v);else{var h=sa();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,r=h.responseText,a=0;n=ca[t][a++];)n(r);ca[t]=r}}},ca[t]=[v],h.open("GET",t,!0),"withCredentials"in h&&(h.withCredentials=!0),h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.send(null)}else{var m=t&&1===t.nodeType?t:_t.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=sa(),h.open("GET",location,!1),h.send(null);for(var g=_t.getElementsByTagName("noscript"),y=(h.responseText||"").match(oa)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(la)||[""," "])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Xt.hasAttribute||"string"!=typeof t||"src"!==a&&"href"!==a||(t=t.replace(/&/g,"&")),n[a]=t,e.chrome&&"EMBED"===n.tagName){var w=n.parentNode,C=document.createComment("ms-src");w.replaceChild(C,n),w.replaceChild(n,C)}},"title,alt,src,value,css,include,href".replace(Dt,function(e){nn[e]=nn.attr}),nn["class"]=function(e,t){var r,a=e.param,i=e.value;if(e.handlerName="class",!a||isFinite(a)){e.param="";var o=i.replace(xn,function(e){return e.replace(/./g,"0")}),l=o.indexOf(":");if(-1===l)var s=i;else{if(s=i.slice(0,l),r=i.slice(l+1),Q(r,t,e),!e.evaluator)return n("debug: ms-class '"+(r||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=bn.test(s);c||(e.immobileClass=s),K("",t,e,c?ut(s):0)}else e.immobileClass=e.oldStyle=e.param,K(i,t,e)},rn["class"]=function(e,t,n){var r=avalon(t),a=n.type;if("class"===a&&n.oldStyle)r.toggleClass(n.oldStyle,!!e);else switch(n.toggleClass=n._evaluator?!!n._evaluator.apply(t,n._args):!0,n.newClass=n.immobileClass||e,n.oldClass&&n.newClass!==n.oldClass&&r.removeClass(n.oldClass),n.oldClass=n.newClass,a){case"class":r.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var i="mouseenter",o="mouseleave";if("active"===a){t.tabIndex=t.tabIndex||-1,i="mousedown",o="mouseup";var l=r.bind("mouseleave",function(){n.toggleClass&&r.removeClass(n.newClass)})}var s=r.bind(i,function(){n.toggleClass&&r.addClass(n.newClass)}),c=r.bind(o,function(){n.toggleClass&&r.removeClass(n.newClass)});n.rollback=function(){r.unbind("mouseleave",l),r.unbind(i,s),r.unbind(o,c)},n.hasBindEvent=!0}}},"hover,active".replace(Dt,function(e){nn[e]=nn["class"]}),rn.data=function(e,t,n){var r="data-"+n.param;e&&"object"==typeof e?t[r]=e:t.setAttribute(r,String(e))};var ua=nn.duplex=function(e,t){var a,o=e.element;if(K(e.value,t,e,0,1),e.changed=Pr(o,"data-duplex-changed",t)||r,e.evaluator&&e.args){var l=[],s=i("string,number,boolean,checked");"radio"===o.type&&""===e.param&&(e.param="checked"),o.msData&&(o.msData["ms-duplex"]=e.value),e.param.replace(/\w+/g,function(t){/^(checkbox|radio)$/.test(o.type)&&/^(radio|checked)$/.test(t)&&("radio"===t&&n("ms-duplex-radio已经更名为ms-duplex-checked"),t="checked",e.isChecked=!0),"bool"===t?(t="boolean",n("ms-duplex-bool已经更名为ms-duplex-boolean")):"text"===t&&(t="string",n("ms-duplex-text已经更名为ms-duplex-string")),s[t]&&(a=!0),avalon.Array.ensure(l,t)}),a||l.push("string"),e.param=l.join("-"),e.bound=function(t,n){o.addEventListener?o.addEventListener(t,n,!1):o.attachEvent("on"+t,n);var r=e.rollback;e.rollback=function(){o.avalonSetter=null,avalon.unbind(o,t,n),r&&r()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=vt);f(null,e,"init");var p=o.tagName;ua[p]&&ua[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:dt},"boolean":{get:function(e){return"true"===e},set:dt},number:{get:function(e,t){var n=parseFloat(e);if(-e===-n)return n;var r=/strong|medium|weak/.exec(t.element.getAttribute("data-duplex-number"))||["medium"];switch(r[0]){case"strong":return 0;case"medium":return""===e?"":0;case"weak":return e}},set:dt}};var fa,pa=[];avalon.tick=function(e){1===pa.push(e)&&(fa=setInterval(ht,60))};var da=r,va=/text|password|hidden/;!new function(){function e(e){if(avalon.contains(Xt,this)){if(t[this.tagName].call(this,e),!va.test(this.type))return;!this.msFocus&&this.avalonSetter&&this.avalonSetter()}}try{var t={},n=HTMLInputElement.prototype,r=HTMLTextAreaElement.prototype,a=HTMLInputElement.prototype;Object.getOwnPropertyNames(a),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(r,"value").set,Object.defineProperty(r,"value",{set:e})}catch(i){da=avalon.tick}},Qt&&avalon.bind(_t,"selectionchange",function(){var e=_t.activeElement;e&&"function"==typeof e.avalonSetter&&e.avalonSetter()}),ua.INPUT=function(e,t,r){function a(e){r.changed.call(this,e,r)}function i(){f=!0}function o(){f=!1}function l(e){setTimeout(function(){p(e)})}var s=e.type,c=r.bound,u=avalon(e),f=!1,p=function(){if(!f){var n=e.oldValue=e.value,i=r.pipe(n,r,"get");u.data("duplexObserve")!==!1&&(t(i),a.call(e,i),u.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}};if(r.handler=function(){var n=r.pipe(t(),r,"set")+"";n!==e.oldValue&&(e.value=n)},r.isChecked||"radio"===s){var d=6===Qt;p=function(){if(u.data("duplexObserve")!==!1){var n=r.pipe(e.value,r,"get");t(n),a.call(e,n)}},r.handler=function(){var n=t(),a=r.isChecked?!!n:n+""===e.value;e.oldValue=a,d?setTimeout(function(){e.defaultChecked=a,e.checked=a},31):e.checked=a},c("click",p)}else if("checkbox"===s)p=function(){if(u.data("duplexObserve")!==!1){var i=e.checked?"ensure":"remove",o=t();Array.isArray(o)||(n("ms-duplex应用于checkbox上要对应一个数组"),o=[o]),avalon.Array[i](o,r.pipe(e.value,r,"get")),a.call(e,o)}},r.handler=function(){var n=[].concat(t());e.checked=n.indexOf(r.pipe(e.value,r,"get"))>-1},c(zt?"change":"click",p);else{var v=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),v.replace(Dt,function(e){switch(e){case"input":Qt?(Qt>8?c("input",p):c("propertychange",function(e){"value"===e.propertyName&&p()}),c("dragend",l)):(c("input",p),c("compositionstart",i),c("compositionend",o),c("DOMAutoComplete",p));break;default:c(e,p)}}),c("focus",function(){e.msFocus=!0}),c("blur",function(){e.msFocus=!1}),va.test(s)&&da(function(){if(Xt.contains(e))e.msFocus||e.oldValue===e.value||p();else if(!e.msRetain)return!1}),e.avalonSetter=p}e.oldValue=e.value,avalon.injectBinding(r),a.call(e,e.value)},ua.TEXTAREA=ua.INPUT,ua.SELECT=function(e,t,r){function a(){if(i.data("duplexObserve")!==!1){var n=i.val();n=Array.isArray(n)?n.map(function(e){return r.pipe(e,r,"get")}):r.pipe(n,r,"get"),n+""!==e.oldValue&&t(n),r.changed.call(e,n,r)}}var i=avalon(e);r.handler=function(){var r=t();r=r&&r.$model||r,Array.isArray(r)?e.multiple||n("ms-duplex在不能对应一个数组"),r=Array.isArray(r)?r.map(String):r+"",r+""!==e.oldValue&&(i.val(r),e.oldValue=r+"")},r.bound("change",a),e.msCallback=function(){avalon.injectBinding(r),r.changed.call(e,t(),r)}},rn.html=function(e,t,n){var r=1!==t.nodeType,a=r?t.parentNode:t;if(a){if(e=null==e?"":e,3===t.nodeType){var i=Zt("html");a.insertBefore(_t.createComment(i),t),n.element=_t.createComment(i+":end"),a.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=Yt.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),r){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;a.removeChild(c)}a.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);ot(l,n.vmodels)}},nn["if"]=nn.data=nn.text=nn.html=function(e,t){K(e.value,t,e)},rn["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(r){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),at(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var a=n.element=_t.createComment("ms-if");t.parentNode.replaceChild(a,t),n.template=t,Ot.appendChild(t),n.rollback=function(){t.parentNode===Ot&&Ot.removeChild(t)}}};var ha=/\(([^)]*)\)/;nn.on=function(e,t){var n=e.value;e.type="on";var r=e.param.replace(/-\d+$/,"");if("function"==typeof nn.on[r+"Hook"]&&nn.on[r+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var a=(n.match(ha)||["",""])[1].trim();(""===a||"$event"===a)&&(n=n.replace(ha,""))}K(n,t,e)},rn.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)}},nn.repeat=function(e,t){var n=e.type;K(e.value,t,e,0,1);var r=!1;try{var a=e.$repeat=e.evaluator.apply(0,e.args||[]),i=avalon.type(a);"object"!==i&&"array"!==i&&(r=!0,avalon.log("warning:"+e.value+"只能是对象或数组"))}catch(o){r=!0}var l=e.value.split(".")||[];if(l.length>1){l.pop();for(var s,c=l[0],u=0;s=t[u++];)if(s&&s.hasOwnProperty(c)){var f=s[c].$events||{};f[St]=f[St]||[],f[St].push(e);break}}var p=e.element;if(1===p.nodeType){p.removeAttribute(e.name),e.sortedCallback=Pr(p,"data-with-sorted",t),e.renderedCallback=Pr(p,"data-"+n+"-rendered",t);var d=Zt(n),v=_t.createComment(d),h=_t.createComment(d+":end");if(e.signature=d,e.template=Yt.cloneNode(!1),"repeat"===n){var m=p.parentNode;m.replaceChild(h,p),m.insertBefore(v,h),e.template.appendChild(p)}else{for(;p.firstChild;)e.template.appendChild(p.firstChild);p.appendChild(v),p.appendChild(h)}e.element=h,e.handler=rn.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!r){e.$outer={};var g="$key",y="$val";if(Array.isArray(a)){if(!a.$map){a.$map={el:1};var b=a.length,x=[];for(u=0;b>u;u++)x.push(S(u,a));a.$proxy=x}a.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var $=a.$events,w=($||{})[St];j(w,e),"object"===i?(e.$with=!0,a.$proxy||(a.$proxy={}),e.handler("append",a)):a.length&&e.handler("add",0,a.length)}},rn.repeat=function(e,t,n){if(e){var a,i,o=this,l=o.element,s=gt(o),c=l.parentNode,u=Yt.cloneNode(!1);switch(e){case"add":for(var f=t+n,p=[],d=o.$repeat,v=t;f>v;v++){var h=d.$proxy[v];h.$outer=o.$outer,mt(o,u,h,p)}for(c.insertBefore(u,s[t]||l),v=0;i=p[v++];)ot(i.nodes,i.vmodels),i.nodes=i.vmodels=null;break;case"del":yt(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&yt(a,l);break;case"move":if(a=s[0]){var m,g=a.nodeValue,y=[],b=[];for(yt(a,l,function(){b.unshift(this),this.nodeValue===g&&(y.unshift(b),b=[])}),M(y,t);b=y.shift();)for(;m=b.shift();)u.appendChild(m);c.insertBefore(u,l)}break;case"append":var x=t,$=x.$proxy,w=[];p=[];for(var C in $)x.hasOwnProperty(C)||(wt($[C],ma),delete $[C]);for(C in x)x.hasOwnProperty(C)&&"hasOwnProperty"!==C&&"$proxy"!==C&&w.push(C);if(o.sortedCallback){var T=o.sortedCallback.call(c,w);T&&Array.isArray(T)&&T.length&&(w=T)}for(v=0;C=w[v++];)"hasOwnProperty"!==C&&($[C]=xt($[C],C,o),mt(o,u,$[C],p));for(c.insertBefore(u,l),v=0;i=p[v++];)ot(i.nodes,i.vmodels),i.nodes=i.vmodels=null}"clear"===e&&(e="del");var E=o.renderedCallback||r,k=arguments;et(c,function(){E.apply(c,k),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(Dt,function(e){nn[e]=nn.repeat}),avalon.pool=Fn;var ma=[];rn.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else"textContent"in t?t.textContent=e:t.innerText=e},avalon.parseDisplay=Ct,nn.visible=function(e,t){var n=avalon(e.element),r=n.css("display");if("none"===r){var a=n[0].style,i=/visibility/i.test(a.cssText),o=n.css("visibility");a.display="",a.visibility="hidden",r=n.css("display"),"none"===r&&(r=Ct(n[0].nodeName)),a.visibility=i?o:""}e.display=r,K(e.value,t,e)},rn.visible=function(e,t,n){t.style.display=e?n.display:"none"},nn.widget=function(t,a){var i=t.value.match(Dt),o=t.element,l=i[0],s=i[1];s&&"$"!==s||(s=Zt(l));var c=i[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,p=0;f=a[p++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var d=f[c];d=d.$model||d;break}if(d){var v=d[l+"Id"];"string"==typeof v&&(n("warning!不再支持"+l+"Id"),s=v)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=r,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,d||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,tt(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},D(t,ga),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(P)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var ga=[],ya=/]*>([\S\s]*?)<\/script\s*>/gim,ba=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,xa=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,$a={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},wa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ca=/([^\#-~| |!])/g,Ta=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof n?n:"...",e.length>t?e.slice(0,t-n.length)+n:String(e)},$filter:function(e){for(var t=1,n=arguments.length;n>t;t++){var r=arguments[t],a=avalon.filters[r.shift()];if("function"==typeof a){var i=[e].concat(r);e=a.apply(null,i)}}return e},camelize:U,sanitize:function(e){return e.replace(ya,"").replace(xa,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=$a[t[1]];n&&(e=e.replace(n,function(e,t,n){var r=n.charAt(0);return t+"="+r+"javascript:void(0)"+r}))}return e.replace(ba," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(wa,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Ca,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+Tt(e,isFinite(n)?n:2)},number:Tt};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var r="";for(0>e&&(r="-",e=-e),e=""+e;e.length0||o>-r)&&(o+=r),0===o&&-12===r&&(o=12),t(o,n,a)}}function r(e,t){return function(n,r){var a=n["get"+e](),i=(t?"SHORT"+e:e).toUpperCase();return r[i][a]}}function a(e){var n=-1*e.getTimezoneOffset(),r=n>=0?"+":"";return r+=t(Math[n>0?"floor":"ceil"](n/60),2)+t(Math.abs(n%60),2)}function i(e,t){return e.getHours()<12?t.AMPMS[0]:t.AMPMS[1]}var o={yyyy:n("FullYear",4),yy:n("FullYear",2,0,!0),y:n("FullYear",1),MMMM:r("Month"),MMM:r("Month",!0),MM:n("Month",2,1),M:n("Month",1,1),dd:n("Date",2),d:n("Date",1),HH:n("Hours",2),H:n("Hours",1),hh:n("Hours",2,-12),h:n("Hours",1,-12),mm:n("Minutes",2),m:n("Minutes",1),ss:n("Seconds",2),s:n("Seconds",1),sss:n("Milliseconds",3),EEEE:r("Day"),EEE:r("Day",!0),a:i,Z:a},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;Ta.date=function(t,n){var r,a,i=Ta.date.locate,c="",u=[];if(n=n||"mediumDate",n=i[n]||n,"string"==typeof t)if(/^\d+$/.test(t))t=e(t);else if(s.test(t))t=+RegExp.$1;else{var f=t.trim(),p=[0,0,0,0,0,0,0],d=new Date(0);f=f.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,r,a){var i=4===a.length?[a,n,r]:[n,r,a];return p[0]=e(i[0]),p[1]=e(i[1])-1,p[2]=e(i[2]),""});var v=d.setFullYear,h=d.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,r,a,i){return p[3]=e(n),p[4]=e(r),p[5]=e(a),i&&(p[6]=Math.round(1e3*parseFloat("0."+i))),""});var m=0,g=0;f=f.replace(/Z|([+-])(\d\d):?(\d\d)/,function(t,n,r,a){return v=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+r),g=e(n+a)),""}),p[3]-=m,p[4]-=g,v.apply(d,p.slice(0,3)),h.apply(d,p.slice(3)),t=d}if("number"==typeof t&&(t=new Date(t)),"date"===avalon.type(t)){for(;n;)a=l.exec(n),a?(u=u.concat(a.slice(1)),n=u.pop()):(u.push(n),n=null); -return u.forEach(function(e){r=o[e],c+=r?r(t,i):e.replace(/(^'|'$)/g,"").replace(/''/g,"'")}),c}};var c={AMPMS:{0:"上午",1:"下午"},DAY:{0:"星期日",1:"星期一",2:"星期二",3:"星期三",4:"星期四",5:"星期五",6:"星期六"},MONTH:{0:"1月",1:"2月",2:"3月",3:"4月",4:"5月",5:"6月",6:"7月",7:"8月",8:"9月",9:"10月",10:"11月",11:"12月"},SHORTDAY:{0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"},fullDate:"y年M月d日EEEE",longDate:"y年M月d日",medium:"yyyy-M-d H:mm:ss",mediumDate:"yyyy-M-d",mediumTime:"H:mm:ss","short":"yy-M-d ah:mm",shortDate:"yy-M-d",shortTime:"ah:mm"};c.SHORTMONTH=c.MONTH,Ta.date.locate=c};var Ea=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Ea.exports=Ea.avalon,new function(){function t(e,t){var r="js";e=e.replace(/^(\w+)\!/,function(e,t){return r=t,""}),"ready"===r&&(n("debug: ready!已经被废弃,请使用domReady!"),r="domReady");var a="";e=e.replace(D,function(e){return a=e,""});var i="."+r,o=/js|css/.test(i)?i:"";e=e.replace(/\.[a-z0-9]+$/g,function(e){return e===i?(o=e,""):e});var l=avalon.mix({query:a,ext:o,res:r,name:e,toUrl:m},t);return l.toUrl(e),l}function i(e){var t=e.name,n=e.res,r=Ea[t],a=t&&e.urlNoQuery;if(r&&r.state>=1)return t;if(r=Ea[a],r&&r.state>=3)return Mt(r.deps||[],r.factory,a),a;if(t&&!r){r=Ea[a]={id:a,state:1};var i=function(a){H[n]=a,a.load(t,e,function(e){arguments.length&&void 0!==e&&(r.exports=e),r.state=4,s()})};H[n]?i(H[n]):Mt([n],i)}return t?a:n+"!"}function o(e,t){for(var n,r=0;n=e[r++];)if(4!==Ea[n].state&&(n===t||o(Ea[n].deps,t)))return!0}function l(e,t,r){var a=u(e.src);return e.onload=e.onreadystatechange=e.onerror=null,t||r&&Ea[a]&&!Ea[a].state?(setTimeout(function(){At.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Ea[a].state)):!0}function s(){e:for(var e,t=E.length;e=E[--t];){var n=Ea[e],r=n.deps;if(r){for(var a,i=0;a=r[i];i++)if(4!==Object(Ea[a]).state)continue e;4!==n.state&&(E.splice(t,1),v(n.id,n.deps,n.factory),s())}}}function c(e,t,r){function a(){var a=k.pop();a&&a.require(t),r&&r(),l(i,!1,!c)&&(n("debug: 已成功加载 "+e),t&&E.push(t),s())}var i=_t.createElement("script");i.className=St;var o,c="onload"in i,u=c?"onload":"onreadystatechange",f=0;i[u]=c?a:function(){L.test(i.readyState)&&(++f,1===f?o=setTimeout(a,500):(clearTimeout(o),a()))},i.onerror=function(){l(i,!0)},At.insertBefore(i,At.firstChild),i.src=e,n("debug: 正准备加载 "+e)}function u(e){return(e||"").replace(D,"")}function f(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(e,t){return"1"[0]?e[t]:e.getAttribute(t,4)}function d(){var t;try{a.b.c()}catch(n){t=n.stack,!t&&e.opera&&(t=(String(n).match(/of linked script \S+/g)||[]).join(" "))}if(t)return t=t.split(/[@ ]/g).pop(),t="("===t[0]?t.slice(1,-1):t.replace(/\s/,""),u(t.replace(/(:\d+)?:\d+$/i,""));for(var r,i=At.getElementsByTagName("script"),o=i.length;r=i[--o];)if(r.className===St&&"interactive"===r.readyState){var l=p(r,"src");return r.className=u(l)}}function v(t,r,a){var i=Object(Ea[t]);i.state=4;for(var o,l=0,s=[];o=r[l++];)if("exports"===o){var c=i.exports||(i.exports={});s.push(c)}else s.push(Ea[o].exports);try{var u=a.apply(e,s)}catch(f){n("执行["+t+"]模块的factory抛错: "+f)}return void 0!==u&&(i.exports=u),P.test(t)&&delete Ea[t],delete i.factory,u}function m(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,r=this.baseUrl,a=this.parentUrl||r;$(e,h.paths,function(e,r){t=t.replace(r,e),n=1}),n||$(e,h.packages,function(e,n,r){t=t.replace(r.name,r.location)}),this.mapUrl&&$(this.mapUrl,h.map,function(e){$(t,e,function(e,n){t=t.replace(n,e),a=r})});var i=this.ext;i&&n&&t.slice(-i.length)===i&&(t=t.slice(0,-i.length)),f(t)||(a=this.built||/^\w/.test(t)?r:a,t=C(a,t));var o=t+i;return t=o+this.query,$(e,h.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=o}function g(e,t,n){var r=x(e,t,n);return r.sort(w),r}function y(e){return new RegExp("^"+e+"(/|$)")}function b(t){return function(){var n;return t.init&&(n=t.init.apply(e,arguments)),n||t.exports&&T(t.exports)}}function x(e,t,n){var r=[];for(var a in e)if(Rt.call(e,a)){var i={name:a,val:e[a]};r.push(i),i.reg="*"===a&&t?/^/:y(a),n&&"*"!==a&&(i.reg=new RegExp("/"+a.replace(/^\//,"")+"(/|$)"))}return r}function $(e,t,n){t=t||[];for(var r,a=0;r=t[a++];)if(r.reg.test(e))return n(r.val,r.name,r),!1}function w(e,t){var n=e.name,r=t.name;return"*"===r?-1:"*"===n?1:r.length-n.length}function C(e,t){if("/"!==e.charAt(e.length-1)&&(e+="/"),"./"===t.slice(0,2))return e+t.slice(2);if(".."===t.slice(0,2)){for(e+=t;F.test(e);)e=e.replace(F,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function T(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var E=[],k=[],_=/\.js$/i,A=[],O=!1;Mt=avalon.require=function(e,n,a,o){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var l=[],c={},u=a||"callback"+setTimeout("1");o=o||{},o.baseUrl=h.baseUrl;var f=!!o.built;if(a&&(o.parentUrl=a.substr(0,a.lastIndexOf("/")),o.mapUrl=a.replace(_,"")),f){var p=t(o.defineName,o);u=p.urlNoQuery}else e.forEach(function(e){var n=t(e,o),r=i(n);r&&(c[r]||(l.push(r),c[r]="司徒正美"))});var d=Ea[u];d&&4===d.state||(Ea[u]={id:u,deps:f?e.concat():l,factory:n||r,state:3}),d||E.push(u),s()}else if(A.push(avalon.slice(arguments)),arguments.length<=2){O=!0;for(var v,m=A.splice(0,A.length);v=m.shift();)Mt.apply(null,v)}},Mt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var r={built:!O,defineName:e},a=[t,n,r];n.require=function(e){if(a.splice(2,0,e),Ea[e]){Ea[e].state=3;var t=!1;try{t=o(Ea[e].deps,e)}catch(r){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,Mt.apply(null,a)};var i=r.built?"unknown":d();if(i){var l=Ea[i];l&&(l.state=2),n.require(i)}else k.push(n)},Mt.config=h,Mt.define.amd=Ea;var M=h["orig.paths"]={},N=h["orig.map"]={},S=h.packages=[],j=h["orig.args"]={};avalon.mix(Cn,{paths:function(e){avalon.mix(M,e),h.paths=g(M)},map:function(e){avalon.mix(N,e);var t=g(N,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),h.map=t},packages:function(e){e=e.concat(S);for(var t,n={},r=[],a=0;t=e[a++];){t="string"==typeof t?{name:t}:t;var i=t.name;if(!n[i]){var o=C(t.location||i,t.main||"main");o=o.replace(_,""),r.push(t),n[i]=t.location=o,t.reg=y(i)}}h.packages=r.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(j,e),h.urlArgs=g(j,1)},baseUrl:function(e){if(!f(e)){var t=At.getElementsByTagName("base")[0];t&&At.removeChild(t);var n=_t.createElement("a");n.href=e,e=p(n,"href"),t&&At.insertBefore(t,At.firstChild)}e.length>3&&(h.baseUrl=e)},shim:function(e){for(var t in e){var n=e[t];Array.isArray(n)&&(n=e[t]={deps:n}),n.exportsFn||!n.exports&&!n.init||(n.exportsFn=b(n))}h.shim=e}});var L=/complete|loaded/,H=Mt.plugins={ready:{load:r},js:{load:function(e,t,n){var r=t.url,a=t.urlNoQuery,i=h.shim[e.replace(_,"")];i?Mt(i.deps||[],function(){var e=avalon.slice(arguments);c(r,a,function(){n(i.exportsFn?i.exportsFn.apply(0,e):void 0)})}):c(r,a)}},css:{load:function(e,t,r){var a=t.url,i=_t.createElement("link");i.rel="stylesheet",i.href=a,At.insertBefore(i,At.firstChild),n("debug: 已成功加载 "+a),r()}},text:{load:function(e,t,r){var a=t.url,i=sa();i.onreadystatechange=function(){if(4===i.readyState){var e=i.status;e>399&&600>e?avalon.error(a+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+a),r(i.responseText))}};var o="_="+(new Date-0),l=-1===a.indexOf("?")?a+"?"+o:a+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+a)}}};Mt.checkDeps=s;var D=/(\?[^#]*)$/,P=/^callback\d+$/,F=/\/\w+\/\.\./,B=_t.scripts[_t.scripts.length-1],I=B.getAttribute("data-main");if(I){Cn.baseUrl(I);var R=h.baseUrl;h.baseUrl=R.slice(0,R.lastIndexOf("/")+1),c(R.replace(_,"")+".js")}else{var V=u(p(B,"src"));h.baseUrl=V.slice(0,V.lastIndexOf("/")+1)}};var ka,_a=[],Aa=function(e){for(ka=!0,Mt&&(Ea["domReady!"].state=4,Mt.checkDeps());e=_a.shift();)e(avalon)};if("complete"===_t.readyState)setTimeout(Aa);else if(zt)_t.addEventListener("DOMContentLoaded",Aa);else{_t.attachEvent("onreadystatechange",function(){"complete"===_t.readyState&&Aa()});try{var Oa=null===e.frameElement}catch(Sn){}Xt.doScroll&&Oa&&e.external&&Et()}avalon.bind(e,"load",Aa),avalon.ready=function(e){ka?e(avalon):_a.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(_t.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var Ma=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=Ma),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file +!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("Avalon requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(){e.console&&avalon.config.debug&&Function.apply.call(console.log,console,arguments)}function r(){}function i(e,t){"string"==typeof e&&(e=e.match(Dt)||[]);for(var n={},r=void 0!==t?t:1,a=0,i=e.length;i>a;a++)n[e[a]]=r;return n}function o(){if(e.VBArray){var t=document.documentMode;return t?t:e.XMLHttpRequest?7:6}return 0}function l(e){return Bt.test(Vt.call(e))}function s(e,t){return e=Math.floor(e)||0,0>e?Math.max(t+e,0):Math.min(e,t)}function c(e){if(!e)return!1;var t=e.length;if(t===t>>>0){var n=Vt.call(e).slice(8,-1);if(/(?:regexp|string|function|window|global)$/i.test(n))return!1;if("Array"===n)return!0;try{return{}.propertyIsEnumerable.call(e,"length")===!1?/^\s?function/.test(e.item||e.callee):!0}catch(r){return!e.window}}return!1}function u(e,t,n){var r="for(var "+e+"i=0,n = this.length; i < n; i++){"+t.replace("_","((i in this) && fn.call(scope,this[i],i,this))")+"}"+n;return Function("fn,scope",r)}function f(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(n){return!1}}function p(){return(new XMLSerializer).serializeToString(this)}function d(e,t){if(e&&e.childNodes)for(var n,r=e.childNodes,a=0;n=r[a++];)if(n.tagName){var i=_t.createElementNS(fn,n.tagName.toLowerCase());zt.forEach.call(n.attributes,function(e){i.setAttribute(e.name,e.value)}),d(n,i),t.appendChild(i)}}function v(e){var t={};for(var n in e)t[n]=e[n];var r=t.target=e.srcElement;if(0===e.type.indexOf("key"))t.which=null!=e.charCode?e.charCode:e.keyCode;else if(dn.test(e.type)){var a=r.ownerDocument||_t,i="BackCompat"===a.compatMode?a.body:a.documentElement;t.pageX=e.clientX+(i.scrollLeft>>0)-(i.clientLeft>>0),t.pageY=e.clientY+(i.scrollTop>>0)-(i.clientTop>>0),t.wheelDeltaY=t.wheelDelta,t.wheelDeltaX=0}return t.timeStamp=new Date-0,t.originalEvent=e,t.preventDefault=function(){e.returnValue=!1},t.stopPropagation=function(){e.cancelBubble=!0},t}function h(e){for(var t in e)if(Rt.call(e,t)){var n=e[t];"function"==typeof h.plugins[t]?h.plugins[t](n):"object"==typeof h[t]?avalon.mix(h[t],n):h[t]=n}return this}function m(e){return(e+"").replace(wn,"\\$&")}function g(e,t,n){if(Array.isArray(e)){var r=e.concat();e.length=0;var a=_(e);return a.pushArray(r),a}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var i=Array.isArray(e.$skipArray)?e.$skipArray:[];i.$special=t||{};var o={};n=n||{};var l={},s={},c=[];An.forEach(function(t){delete e[t]});for(var u in e)!function(e,t,r){if(n[e]=t,E(e,t,i)){l[e]=[];var a=avalon.type(t);"object"===a&&Kt(t.get)&&Object.keys(t).length<=2?(r=b(e,t),c.push(r)):r=Pt.test(a)?x(e,t,a,l[e]):y(e,t),s[e]=r}}(u,e[u]);o=Mn(o,Ln(s),e);for(var f in e)s[f]||(o[f]=e[f]);o.$id=Zt(),o.$model=n,o.$events=l;for(u in kn){var p=kn[u];Wt||(p=p.bind(o)),o[u]=p}return Nn?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},o.$compute=function(){c.forEach(function(e){Bn.begin({callback:function(t,n){var r=n._name;if(n!==e){var a=t.$events[r];e.vm=o,j(a,e.digest)}}});try{e.get.call(o)}finally{Bn.end()}})},o.$compute(),o}function y(e,t){function n(e){var t=n._value;return arguments.length>0?(Ht||jn(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(Bn.collectDependency(this,n),t)}return T(n,e),n._value=t,n}function b(e,t){function n(e){var t=n._value,r="_value"in n;return arguments.length>0?Ht?this:(n.set.call(this,e),this):(e=n.get.call(this),t!==e&&(n.updateValue(this,e),r&&n.notify(this,e,t)),e)}t.set=t.set||r,n.set=t.set||r,n.get=t.get,T(n,e);var a;return n.digest=function(){n.updateValue=w,n.notify=r,n.call(n.vm),clearTimeout(a),a=setTimeout(function(){T(n,n._name),n.call(n.vm)})},n}function x(e,t,n,r){function a(t){var r=a._value,i=a._vmodel;if(arguments.length>0){if(Ht)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=a._vmodel=g(t),i.$events[St]=s,i.$proxy=l,s.length&&s.forEach(function(e){var t=nn[e.type];t&&(e.rollback&&e.rollback(),t(e,e.vmodels))})}return a.updateValue(this,i.$model),a.notify(this,this._value,r),this}return Bn.collectDependency(this,a),i}T(a,e);var i=a._vmodel=g(t);return i.$events[St]=r,a}function $(e,t){e.$model[this._name]=this._value=t}function w(e,t){e.$model[this._name]=t}function C(e,t,n){var r=this._name,a=e.$events[r];a&&(L(a),kn.$fire.call(e,r,t,n))}function T(e,t){e._name=t,e.updateValue=$,e.notify=C}function E(e,t,n){if(Kt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var r=n.$special;return e&&"$"===e.charAt(0)&&!r[e]?!1:!0}function k(e,t,n,r){var a=t[n];return 4!==arguments.length?a.call(e):void a.call(e,r)}function _(e){var t=[];t.$id=Zt(),t.$model=e,t.$events={},t.$events[St]=[],t._=g({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in kn)t[n]=kn[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,Pn),t}function A(e,t,n,r,a,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return Pt.test(avalon.type(e))?e.$id?e:g(e,0,e):e});Dn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var p=S(f,this);this.$proxy.splice(f,0,p)}this._fire("add",t,n);break;case"del":var d=this._splice(t,n),v=this.$proxy.splice(t,n);$t(v,"each"),this._fire("del",t,n)}a&&(e=a,t=i,n=o,s=2,a=0)}return O(this.$proxy,r),this.length!==l&&(this._.length=this.length),d}function O(e,t){for(var n,r=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===r}function N(e,t){for(var n={},r=0,a=t.length;a>r;r++){n[r]=e[r];var i=t[r];i in n?(e[r]=n[i],delete n[i]):e[r]=e[i]}}function M(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=g(e,t);return n.$id=Zt("$proxy$each"),n}function S(e,t){var n=Fn.shift();n?n.$compute():n=M();var r=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===r,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function j(e,t){t=t||qt[kt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&D(t,e)}function L(e){if(e&&e.length){new Date-zn>444&&"object"==typeof e[0]&&P();for(var t,n=Ut.call(arguments,1),a=e.length;t=e[--a];){var i=t.element;if(i&&i.parentNode)try{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)}}catch(l){}}}}function H(e){return e.uniqueNumber||(e.uniqueNumber=++Rn)}function D(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+H(n.parentNode):e.name+"-"+H(n));var r=e.lists||(e.lists=[]);avalon.Array.ensure(r,t),t.$uuid=t.$uuid||Zt(),Vn[e.uuid]||(Vn[e.uuid]=1,Vn.push(e))}function P(e){if(!avalon.optimize){for(var t=Vn.length,n=t,r=[],a={},i={};e=Vn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,r.push(o))}var l=!1;if(r.forEach(function(e){Un[e]!==i[e]&&(a[e]=1,l=!0)}),t=n,l)for(;e=Vn[--t];)if(e.element&&a[e.type]&&B(e.element)){Vn.splice(t,1),delete Vn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);F(e)}Un=i,zn=new Date}}function F(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function B(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!Xt.contains(e):!avalon.contains(Xt,e)}function I(e){var t=e.nodeName;return t.toLowerCase()===t&&e.scopeName&&""===e.outerText}function R(e){"url(#default#VML)"!==e.currentStyle.behavior&&(e.style.behavior="url(#default#VML)",e.style.display="inline-block",e.style.zoom=1)}function V(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function z(e){return!e||e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function U(e){if(!("classList"in e)){e.classList={node:e};for(var t in Kn)e.classList[t.slice(1)]=Kn[t]}return e.classList}function q(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:er.test(e)?avalon.parseJSON(e):e}catch(t){}return e}function W(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}function X(e,t){if(e.offsetWidth<=0){if(hr.test(ir["@:get"](e,"display"))){var n={node:e};for(var r in vr)n[r]=e.style[r],e.style[r]=vr[r];t.push(n)}var a=e.parentNode;a&&1===a.nodeType&&X(a,t)}}function Y(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function G(e,t,n,r){for(var a,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;a=e[--s];){var c=l&&t.$map[a]?"el":a;t.hasOwnProperty(c)&&(i.push(a+o+c),r.vars.push(a),"duplex"===r.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function J(e){for(var t=[],n={},r=0;rd;d++)if(s.length){var h="vm"+kt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,G(s,t[d],h,a))}if(c.length||"duplex"!==i){"duplex"!==i&&(e.indexOf("||")>-1||e.indexOf("&&")>-1)&&a.vars.forEach(function(t){var n=new RegExp("\\b"+t+"(?:\\.\\w+|\\[\\w+\\])+","ig");e=e.replace(n,function(n){var r=n.charAt(t.length),a=Qt?e.slice(arguments[1]+n.length):RegExp.rightContext,i=/^\s*\(/.test(a);if("."===r||"["===r||i){var o="var"+String(Math.random()).replace(/^0\./,"");if(i){var l=n.split(".");if(l.length>2){var s=l.pop();return c.push(o+" = "+l.join(".")),o+"."+s}return n}return c.push(o+" = "+n),o}return n})}),a.args=f,delete a.vars;var m=Ar.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"+kt+" = "+e+";\r\n",e+=Z("ret"+kt,o)}else{if("duplex"===i){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Or.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(r,u.concat(g)),a.evaluator=Ar.put(l,m)}catch(y){n("debug: parse error,"+y.message)}return}if("on"===i){-1===e.indexOf("(")?e+=".call(this, $event)":e=e.replace("(",".call(this,"),u.push("$event"),e="\nreturn "+e+";";var b=e.lastIndexOf("\nreturn"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(r,u.concat("'use strict';\n"+p+e)),a.evaluator=Ar.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function K(e,t,n,r,a){Array.isArray(r)&&(e=r.map(function(e){return e.expr?"("+e.value+")":br(e.value)}).join(" + ")),Q(e,t,n),n.evaluator&&!a&&(n.handler=rn[n.handlerName||n.type],avalon.injectBinding(n))}function et(e,t,n){var r=setTimeout(function(){var a=e.innerHTML;clearTimeout(r),a===n?t():et(e,t,a)})}function tt(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function nt(e,t){for(var n,r=0;n=e[r++];)n.vmodels=t,nn[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function rt(e,t){return e.priority-t.priority}function at(e,t,r){var a=!0;if(t.length){for(var i,o=Jr?Jr(e):e.attributes,l=[],s=[],c={},u=0;i=o[u++];)if(i.specified&&(r=i.name.match(Br))){var f=r[1],p=r[2]||"",d=i.value,v=i.name;if(Rr[f]?(p=f,f="on"):Vr[f]&&("enabled"===f&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),f="disabled",d="!("+d+")"),p=f,f="attr",v="ms-"+f+"-"+p,s.push([i.name,v,d])),c[v]=d,"function"==typeof nn[f]){var h={type:f,param:p,element:e,name:v,value:d,priority:(Ir[f]||10*f.charCodeAt(0))+(Number(p.replace(/\D/g,""))||0)};if("html"===f||"text"===f){var m=ct(d);avalon.mix(h,m),h.filters=h.filters.replace(Zr,function(){return h.type="html",h.group=1,""})}else if("duplex"===f)var g=v;else"ms-if-loop"===v&&(h.priority+=100);l.push(h),"widget"===f&&(e.msData=e.msData||c)}}if(l.length){for(l.sort(rt),s.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])}),g&&(c["ms-attr-checked"]&&n("warning!一个控件不能同时定义ms-attr-checked与"+g),c["ms-attr-value"]&&n("warning!一个控件不能同时定义ms-attr-value与"+g)),u=0;h=l[u];u++){if(f=h.type,zr.test(f))return nt(l.slice(0,u+1),t);a&&(a=!Ur.test(f))}nt(l,t)}}a&&!Dr[e.tagName]&&$n.test(e.innerHTML.replace(Kr,"<").replace(ea,">"))&&(Fr&&Fr(e),it(e,t))}function it(e,t){var n=avalon.slice(e.childNodes);ot(n,t)}function ot(e,t){for(var n,r=0;n=e[r++];)lt(n,n.nodeType,t)}function lt(e,t,n){1===t?(st(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&bn.test(e.data)?ft(e,n):h.commentInterpolate&&8===t&&!bn.test(e.nodeValue)&&ft(e,n)}function st(e,t,r){var a=e.getAttribute("ms-skip");if(!e.getAttributeNode)return n("warning "+e.tagName+" no getAttributeNode method");var i=e.getAttributeNode("ms-important"),o=e.getAttributeNode("ms-controller");if("string"!=typeof a){if(r=i||o){var l=avalon.vmodels[r.value];if(!l)return;t=r===i?[l]:[l].concat(t);var s=r.name;e.removeAttribute(s),avalon(e).removeClass(s),tt(e,l)}at(e,t)}}function ct(e,t){if(e.indexOf("|")>0){var n=e.replace(ta,function(e){return Array(e.length+1).join("1")}),r=n.replace(Qr,"ᄢ㍄").indexOf("|");if(r>-1)return{filters:e.slice(r),value:e.slice(0,r),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function ut(e){for(var t,n,r=[],a=0;;){if(n=e.indexOf(gn,a),-1===n)break;if(t=e.slice(a,n),t&&r.push({value:t,filters:"",expr:!1}),a=n+gn.length,n=e.indexOf(yn,a),-1===n)break;t=e.slice(a,n),t&&r.push(ct(t,a)),a=n+yn.length}return t=e.slice(a),t&&r.push({value:t,expr:!1,filters:""}),r}function ft(e,t){var n=[];if(8===e.nodeType)var r=ct(e.nodeValue),a=[r];else a=ut(e.data);if(a.length){for(var i=0;r=a[i++];){var o=_t.createTextNode(r.value);r.expr&&(r.type="text",r.element=o,r.filters=r.filters.replace(Zr,function(){return r.type="html",""}),n.push(r)),Yt.appendChild(o)}e.parentNode.replaceChild(Yt,e),n.length&&nt(n,t)}}function pt(e,t,n){var r=e.templateCache&&e.templateCache[t];if(r){for(var a,i=_t.createDocumentFragment();a=r.firstChild;)i.appendChild(a);return i}return avalon.parseHTML(n)}function dt(e){return null==e?"":e}function vt(e,t,n){return t.param.replace(/\w+/g,function(r){var a=avalon.duplexHooks[r];a&&"function"==typeof a[n]&&(e=a[n](e,t))}),e}function ht(){for(var e=pa.length-1;e>=0;e--){var t=pa[e];t()===!1&&pa.splice(e,1)}pa.length||clearInterval(fa)}function mt(e,t,n,r){var a=e.template.cloneNode(!0),i=avalon.slice(a.childNodes);e.$with||a.insertBefore(_t.createComment(e.signature),a.firstChild),t.appendChild(a);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};r.push(l)}function gt(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),r=t.previousSibling,a=[];r;)r.nodeValue===n&&a.unshift(r),r=r.previousSibling;return a}function yt(e,t,n){for(;;){var r=t.previousSibling;if(!r)break;if(r.parentNode.removeChild(r),n&&n.call(r),r===e)break}}function bt(){var e=g({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Zt("$proxy$with"),e}function xt(e,t,n){e=e||ma.pop(),e||(e=bt());var r=n.$repeat;return e.$key=t,e.$host=r,e.$outer=n.$outer,r.$events?e.$events.$val=r.$events[t]:e.$events={},e}function $t(e){e.forEach(function(e){wt(e,Fn)}),e.length=0}function wt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&F(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>h.maxRepeatSize&&t.pop()}function Ct(e,t){var n="_"+e;if(!Ct[n]){var r=_t.createElement(e);Xt.appendChild(r),t=Wt?getComputedStyle(r,null).display:r.currentStyle.display,Xt.removeChild(r),Ct[n]=t}return Ct[n]}function Tt(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var a=isFinite(+e)?+e:0,i=isFinite(+t)?Math.abs(t):3,o=r||",",l=n||".",s="",c=function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)};return s=(i?c(a,i):""+Math.round(a)).split("."),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(s[1]||"").length.avalonHide{ display: none!important }",Ot.setAttribute("ms-skip","1"),Ot.className="avalonHide";var Nt,Mt=/\[native code\]/,St="$"+kt,jt=e.require,Lt=e.define,Ht=!1,Dt=/[^, ]+/g,Pt=/^(?:object|array)$/,Ft=/^\[object SVG\w*Element\]$/,Bt=/^\[object (?:Window|DOMWindow|global)\]$/,It=Object.prototype,Rt=It.hasOwnProperty,Vt=It.toString,zt=Array.prototype,Ut=zt.slice,qt={},Wt=e.dispatchEvent,Xt=_t.documentElement,Yt=_t.createDocumentFragment(),Gt=_t.createElement("div"),Jt={};"Boolean Number String Function Array Date RegExp Object Error".replace(Dt,function(e){Jt["[object "+e+"]"]=e.toLowerCase()});var Zt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Qt=o();avalon=function(e){return new avalon.init(e)},avalon.profile=function(){e.console&&avalon.config.profile&&Function.apply.call(console.log,console,arguments)},avalon.nextTick=new function(){function t(){for(var e=i.length,t=0;e>t;t++)i[t]();i=i.slice(e)}var n=e.setImmediate,r=e.MutationObserver,a=Wt&&e.postMessage;if(n)return n.bind(e);var i=[];if(r){var o=document.createTextNode("avalon");return new r(t).observe(o,{characterData:!0}),function(e){i.push(e),o.data=Math.random()}}return a?(e.addEventListener("message",function(n){var r=n.source;r!==e&&null!==r||"process-tick"!==n.data||(n.stopPropagation(),t())}),function(t){i.push(t),e.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}},avalon.init=function(e){this[0]=this.element=e},avalon.fn=avalon.prototype=avalon.init.prototype,avalon.type=function(e){return null==e?String(e):"object"==typeof e||"function"==typeof e?Jt[Vt.call(e)]||"object":typeof e};var Kt="object"==typeof alert?function(e){try{return/^\s*\bfunction\b/.test(e+"")}catch(t){return!1}}:function(e){return"[object Function]"===Vt.call(e)};avalon.isFunction=Kt,avalon.isWindow=function(e){return e?e==e.document&&e.document!=e:!1},l(e)&&(avalon.isWindow=l);var en;for(en in avalon({}))break;var tn="0"!==en;avalon.isPlainObject=function(e,t){if(!e||"object"!==avalon.type(e)||e.nodeType||avalon.isWindow(e))return!1;try{if(e.constructor&&!Rt.call(e,"constructor")&&!Rt.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(tn)for(t in e)return Rt.call(e,t);for(t in e);return void 0===t||Rt.call(e,t)},Mt.test(Object.getPrototypeOf)&&(avalon.isPlainObject=function(e){return"[object Object]"===Vt.call(e)&&Object.getPrototypeOf(e)===It}),avalon.mix=avalon.fn.mix=function(){var e,t,n,r,a,i,o=arguments[0]||{},l=1,s=arguments.length,c=!1;for("boolean"==typeof o&&(c=o,o=arguments[1]||{},l++),"object"==typeof o||Kt(o)||(o={}),l===s&&(o=this,l--);s>l;l++)if(null!=(e=arguments[l]))for(t in e){n=o[t];try{r=e[t]}catch(u){continue}o!==r&&(c&&r&&(avalon.isPlainObject(r)||(a=Array.isArray(r)))?(a?(a=!1,i=n&&Array.isArray(n)?n:[]):i=n&&avalon.isPlainObject(n)?n:{},o[t]=avalon.mix(c,i,r)):void 0!==r&&(o[t]=r))}return o},avalon.mix({rword:Dt,subscribers:St,version:1.44,ui:{},log:n,slice:Wt?function(e,t,n){return Ut.call(e,t,n)}:function(e,t,n){var r=[],a=e.length;if(void 0===n&&(n=a),"number"==typeof n&&isFinite(n)){t=s(t,a),n=s(n,a);for(var i=t;n>i;++i)r[i-t]=e[i]}return r},noop:r,error:function(e,t){throw(t||Error)(e)},oneObject:i,range:function(e,t,n){n||(n=1),null==t&&(t=e||0,e=0);for(var r=-1,a=Math.max(0,Math.ceil((t-e)/n)),i=new Array(a);++rn&&t(n,e[n])!==!1;n++);else for(n in e)if(e.hasOwnProperty(n)&&t(n,e[n])===!1)break}},getWidgetData:function(e,t){var n=avalon(e).data(),r={};for(var a in n)0===a.indexOf(t)&&(r[a.replace(t,"").replace(/\w/,function(e){return e.toLowerCase()})]=n[a]);return r},Array:{ensure:function(e,t){return-1===e.indexOf(t)?e.push(t):void 0},removeAt:function(e,t){return!!e.splice(t,1).length},remove:function(e,t){var n=e.indexOf(t);return~n?avalon.Array.removeAt(e,n):!1}}});var nn=avalon.bindingHandlers={},rn=avalon.bindingExecutors={},an=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}var t=e.prototype;return t.put=function(e,t){var n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){var e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0)},t.get=function(e){var t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(!"司徒正美".trim){var on=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(on,"")}}var ln=!{toString:null}.propertyIsEnumerable("toString"),sn=function(){}.propertyIsEnumerable("prototype"),cn=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],un=cn.length;if(Object.keys||(Object.keys=function(e){var t=[],n=sn&&"function"==typeof e;if("string"==typeof e||e&&e.callee)for(var r=0;rl;l++){var s=cn[l];o&&"constructor"===s||!Rt.call(e,s)||t.push(s)}return t}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Vt.call(e)}),r.bind||(Function.prototype.bind=function(e){if(arguments.length<2&&void 0===e)return this;var t=this,n=arguments;return function(){var r,a=[];for(r=1;rr&&(r+=n);n>r;r++)if(this[r]===e)return r;return-1},lastIndexOf:function(e,t){var n=this.length,r=null==t?n-1:t;for(0>r&&(r=Math.max(0,n+r));r>=0;r--)if(this[r]===e)return r;return-1},forEach:u("","_",""),filter:u("r=[],j=0,","if(_)r[j++]=this[i]","return r"),map:u("r=[],","r[i]=_","return r"),some:u("","if(_)return true","return false"),every:u("","if(!_)return false","return true")}),avalon.contains=f,_t.contains||(_t.contains=function(e){return f(_t,e)}),e.SVGElement){_t.createTextNode("x").contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))});var fn="http://www.w3.org/2000/svg",pn=_t.createElementNS(fn,"svg");pn.innerHTML='',Ft.test(pn.firstChild)||Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:p,set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,r=avalon.parseHTML(e);if("svg"===t)n.insertBefore(r,this);else{var a=_t.createDocumentFragment();d(r,a),n.insertBefore(a,this)}n.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){var e=this.outerHTML,t=new RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),n=new RegExp("$","i");return e.replace(t,"").replace(n,"")},set:function(e){if(avalon.clearHTML){avalon.clearHTML(this);var t=avalon.parseHTML(e);d(t,this)}}}})}!Xt.outerHTML&&e.HTMLElement&&HTMLElement.prototype.__defineGetter__("outerHTML",p);var dn=/^(?:mouse|contextmenu|drag)|click/,vn=avalon.eventHooks;if("onmouseenter"in Xt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){vn[e]={type:t,deel:function(t,n,r){return function(n){var a=n.relatedTarget;return a&&(a===t||16&t.compareDocumentPosition(a))?void 0:(delete n.type,n.type=e,r.call(t,n))}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!vn.animationend&&(vn.animationend={type:n})}),"oninput"in _t.createElement("input")||(vn.input={type:"propertychange",deel:function(e,t,n){return function(t){return"value"===t.propertyName?(t.type="input",n.call(e,t)):void 0}}}),void 0===_t.onmousewheel){var hn=void 0!==_t.onwheel?"wheel":"DOMMouseScroll",mn="wheel"===hn?"deltaY":"detail";vn.mousewheel={type:hn,deel:function(e,t,n){return function(t){t.wheelDeltaY=t.wheelDelta=t[mn]>0?-120:120,t.wheelDeltaX=0,Object.defineProperty&&Object.defineProperty(t,"type",{value:"mousewheel"}),n.call(e,t)}}}}var gn,yn,bn,xn,$n,wn=/[-.*+?^${}()|[\]\/\\]/g,Cn={loader:function(t){var n=Nt&&t;e.require=n?Nt:jt,e.define=n?Nt.define:Lt},interpolate:function(e){if(gn=e[0],yn=e[1],gn===yn)throw new SyntaxError("openTag!==closeTag");if(e+""=="")h.commentInterpolate=!0;else{var t=gn+"test"+yn;if(Gt.innerHTML=t,Gt.innerHTML!==t&&Gt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Gt.innerHTML=""}var n=m(gn),r=m(yn);bn=new RegExp(n+"(.*?)"+r),xn=new RegExp(n+"(.*?)"+r,"g"),$n=new RegExp(n+".*?"+r+"|\\sms-")}};h.debug=!0,h.plugins=Cn,h.plugins.interpolate(["{{","}}"]),h.paths={},h.shim={},h.maxRepeatSize=100,avalon.config=h;var Tn=/(\w+)\[(avalonctrl)="(\S+)"\]/,En=_t.querySelectorAll?function(e){return _t.querySelectorAll(e)}:function(e){for(var t,n=e.match(Tn),r=_t.getElementsByTagName(n[1]),a=[],i=0;t=r[i++];)t.getAttribute(n[2])===n[3]&&a.push(t);return a},kn={$watch:function(e,t){if("function"==typeof t){var n=this.$events[e];n?n.push(t):this.$events[e]=[t]}else this.$events=this.$watch.backup;return this},$unwatch:function(e,t){var n=arguments.length;if(0===n)this.$watch.backup=this.$events,this.$events={};else if(1===n)this.$events[e]=[];else for(var r=this.$events[e]||[],a=r.length;~--a<0;)if(r[a]===t)return r.splice(a,1);return this},$fire:function(e){var t,n,r,a;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var i=this.$events;if(i){var o=Ut.call(arguments,1),l=[e].concat(o);if("all"===t)for(n in avalon.vmodels)r=avalon.vmodels[n],r!==this&&r.$fire.apply(r,l);else if("up"===t||"down"===t){var s=i.expr?En(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(r=avalon.vmodels[n],r!==this&&r.$events.expr){var c=En(r.$events.expr);if(0===c.length)continue;zt.forEach.call(c,function(e){zt.forEach.call(s,function(n){var a="down"===t?n.contains(e):e.contains(n);a&&(e._avalon=r)})})}var u=_t.getElementsByTagName("*"),f=[];for(zt.forEach.call(u,function(e){e._avalon&&(f.push(e._avalon),e._avalon="",e.removeAttribute("_avalon"))}),"up"===t&&f.reverse(),n=0;(a=f[n++])&&a.$fire.apply(a,l)!==!1;);}else{var p=i[e]||[],d=i.$all||[];for(n=0;a=p[n++];)Kt(a)&&a.apply(this,o);for(n=0;a=d[n++];)Kt(a)&&a.apply(this,arguments)}}}},_n=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),_n[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var i=g(e);else{var o={$watch:r};t(o),i=g(o),Ht=!0,t(i),Ht=!1}return i.$id=a,_n[a]=i};var An=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(Dt),On=Object.defineProperty,Nn=!0;try{On({},"_",{value:"x"});var Mn=Object.defineProperties}catch(Sn){Nn=!1}var jn=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},Ln=Wt?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};if(!Nn&&("__defineGetter__"in avalon&&(On=function(e,t,n){return"value"in n&&(e[t]=n.value),"get"in n&&e.__defineGetter__(t,n.get),"set"in n&&e.__defineSetter__(t,n.set),e},Mn=function(e,t){for(var n in t)t.hasOwnProperty(n)&&On(e,n,t[n]);return e}),Qt)){var Hn={};e.execScript(["Function parseVB(code)"," ExecuteGlobal(code)","End Function"].join("\n"),"VBScript"),Mn=function(t,n,r){var a=[];a.push("\r\n Private [__data__], [__proxy__]"," Public Default Function [__const__](d, p)"," Set [__data__] = d: set [__proxy__] = p"," Set [__const__] = Me"," End Function");for(t in r)n.hasOwnProperty(t)||a.push(" Public ["+t+"]");An.forEach(function(e){n.hasOwnProperty(e)||a.push(" Public ["+e+"]")}),a.push(" Public [hasOwnProperty]");for(t in n)a.push(" Public Property Let ["+t+"](val"+kt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+kt+")"," End Property"," Public Property Set ["+t+"](val"+kt+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+kt+")"," End Property"," Public Property Get ["+t+"]"," On Error Resume Next"," Set["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," If Err.Number <> 0 Then"," ["+t+'] = [__proxy__](Me,[__data__],"'+t+'")'," End If"," On Error Goto 0"," End Property");a.push("End Class");var i=a.join("\r\n"),o=Hn[i];o||(o=Zt("VBClass"),e.parseVB("Class "+o+i),e.parseVB(["Function "+o+"Factory(a, b)"," Dim o"," Set o = (New "+o+")(a, b)"," Set "+o+"Factory = o","End Function"].join("\r\n")),Hn[i]=o);var l=e[o+"Factory"](n,k);return l}}var Dn=zt.splice,Pn={_splice:Dn,_fire:function(e,t,n){L(this.$events[St],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(zt.push.apply(this.$model,e),A.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&&(zt.unshift.apply(this.$model,arguments),A.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return A.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return A.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,r=[],a=Dn.apply(this.$model,arguments);return a.length&&(r.push("del",e,a.length,0),t=!0),n>2&&(t?r.splice(3,1,0,"add",e,n-2):r.push("add",e,n-2,0),t=!0),t?A.apply(this,r):[]},contains:function(e){return-1!==this.indexOf(e)},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>=0?(this.$model.splice(e,1),A.call(this,"del",e,1,0)):[]},clear:function(){return $t(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],t)&&this.removeAt(t);else this.clear()},ensure:function(e){return this.contains(e)||this.push(e),this},set:function(e,t){if(e>=0){var n=avalon.type(t);t&&t.$model&&(t=t.$model);var r=this[e];if("object"===n)for(var a in t)r.hasOwnProperty(a)&&(r[a]=t[a]);else if("array"===n)r.clear().push.apply(r,t);else if(r!==t){this[e]=t,this.$model[e]=t; +var i=this.$proxy[e];i&&L(i.$events.$index)}}return this}};"sort,reverse".replace(Dt,function(e){Pn[e]=function(){var t,n=this.$model,r=n.concat(),a=Math.random(),i=[];zt[e].apply(n,arguments);for(var o=0,l=r.length;l>o;o++){var s=n[o],c=r[o];if(jn(s,c))i.push(o);else{var u=r.indexOf(s);i.push(u),r[u]=a,t=!0}}return t&&(N(this,i),N(this.$proxy,i),this._fire("move",i),O(this.$proxy,0)),this}});var Fn=[],Bn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),In=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){Bn.begin({callback:function(t,n){j(t.$events[n._name],e)}});try{var n=In.test(e.type)?e:t.apply(0,e.args);e.handler(n,e.element,e)}catch(r){delete e.evaluator;var a=e.element;if(3===a.nodeType){var i=a.parentNode;h.commentInterpolate?i.replaceChild(_t.createComment(e.value),a):a.data=gn+e.value+yn}}finally{Bn.end()}}};var Rn=0,Vn=avalon.$$subscribers=[],zn=new Date,Un={},qn={area:[1,"",""],param:[1,"",""],col:[2,"","
"],legend:[1,"
","
"],option:[1,""],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],g:[1,'',""],_default:Wt?[0,"",""]:[1,"X
","
"]};qn.th=qn.td,qn.optgroup=qn.option,qn.tbody=qn.tfoot=qn.colgroup=qn.caption=qn.thead,String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(Dt,function(e){qn[e]=qn.g});var Wn=/<([\w:]+)/,Xn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Yn=Wt?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/gi,Gn=i(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),Jn=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,Zn=_t.createElement("script"),Qn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Yt.cloneNode(!1);if("string"!=typeof e)return t;if(!Qn.test(e))return t.appendChild(_t.createTextNode(e)),t;e=e.replace(Xn,"<$1>").trim();var n,r,a=(Wn.exec(e)||["",""])[1].toLowerCase(),i=qn[a]||qn._default,o=Gt;Wt||(e=e.replace(Yn,"
$1")),o.innerHTML=i[1]+e+i[2];var l=o.getElementsByTagName("script");if(l.length)for(var s,c=0;s=l[c++];)Gn[s.type]&&(r=Zn.cloneNode(!1),zt.forEach.call(s.attributes,function(e){e&&e.specified&&(r[e.name]=e.value,r.setAttribute(e.name,e.value))}),r.text=s.text,s.parentNode.replaceChild(r,s));if(!Wt){var u="X
"===i[1]?o.lastChild.firstChild:o.lastChild;if(u&&"TABLE"===u.tagName&&"tbody"!==a)for(l=u.childNodes,c=0;s=l[c++];)if("TBODY"===s.tagName&&!s.innerHTML){u.removeChild(s);break}l=o.getElementsByTagName("br");for(var f=l.length;s=l[--f];)"msNoScope"===s.className&&s.parentNode.removeChild(s);for(l=o.all,c=0;s=l[c++];)I(s)&&R(s)}for(c=i[0];c--;o=o.lastChild);for(;n=o.firstChild;)t.appendChild(n);return t},avalon.innerHTML=function(e,t){if(!Wt&&!Yn.test(t)&&!Jn.test(t))try{return void(e.innerHTML=t)}catch(n){}var r=this.parseHTML(t);this.clearHTML(e).appendChild(r)},avalon.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e};var Kn={_toString:function(){var e=this.node,t=e.className,n="string"==typeof t?t:t.baseVal;return n.split(/\s+/).join(" ")},_contains:function(e){return(" "+this+" ").indexOf(" "+e+" ")>-1},_add:function(e){this.contains(e)||this._set(this+" "+e)},_remove:function(e){this._set((" "+this+" ").replace(" "+e+" "," "))},__set:function(e){e=e.trim();var t=this.node;Ft.test(t)?t.setAttribute("class",e):t.className=e}};"add,remove".replace(Dt,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){U(n)[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&U(t).contains(e)},toggleClass:function(e,t){for(var n,r=0,a=String(e).split(/\s+/),i="boolean"==typeof t;n=a[r++];){var o=i?t:!this.hasClass(n);this[o?"addClass":"removeClass"](n)}return this},attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){switch(e="data-"+V(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return q(n);case 0:var r={};return zt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=z(e.slice(5)),r[e]=q(t.value)))}),r}},removeData:function(e){return e="data-"+V(e),this[0].removeAttribute(e),this},css:function(e,t){if(avalon.isPlainObject(e))for(var n in e)avalon.css(this,n,e[n]);else var r=avalon.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=avalon.css(e[0],"borderTopWidth",!0),r.left+=avalon.css(e[0],"borderLeftWidth",!0),r.top-=e.scrollTop(),r.left-=e.scrollLeft()),{top:t.top-r.top-avalon.css(n,"marginTop",!0),left:t.left-r.left-avalon.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===avalon.css(e,"position");)e=e.offsetParent;return avalon(e||Xt)},bind:function(e,t,n){return this[0]?avalon.bind(this[0],e,t,n):void 0},unbind:function(e,t,n){return this[0]&&avalon.unbind(this[0],e,t,n),this},val:function(e){var t=this[0];if(t&&1===t.nodeType){var n=0===arguments.length,r=n?":get":":set",a=gr[Y(t)+r];if(a)var i=a(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?i:this}});var er=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,tr=/^[\],:{}\s]*$/,nr=/(?:^|:|,)(?:\s*\[)+/g,rr=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,ar=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g;avalon.parseJSON=e.JSON?JSON.parse:function(e){if("string"==typeof e){if(e=e.trim(),e&&tr.test(e.replace(rr,"@").replace(ar,"]").replace(nr,"")))return new Function("return "+e)();avalon.error("Invalid JSON: "+e)}return e},avalon.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){avalon.fn[e]=function(n){var r=this[0]||{},a=W(r),i="scrollTop"===e;return arguments.length?void(a?a.scrollTo(i?avalon(a).scrollLeft():n,i?n:avalon(a).scrollTop()):r[e]=n):a?t in a?a[t]:Xt[e]:r[e]}});var ir=avalon.cssHooks={},or=["","-webkit-","-o-","-moz-","-ms-"],lr={"float":Wt?"cssFloat":"styleFloat"};if(avalon.cssNumber=i("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(lr[e])return lr[e];t=t||Xt.style;for(var r=0,a=or.length;a>r;r++)if(n=z(or[r]+e),n in t)return lr[e]=n;return null},ir["@:set"]=function(e,t,n){try{e.style[t]=n}catch(r){}},e.getComputedStyle)ir["@:get"]=function(e,t){if(!e||!e.style)throw new Error("getComputedStyle要求传入一个节点 "+e);var n,r=getComputedStyle(e,null);return r&&(n="filter"===t?r.getPropertyValue(t):r[t],""===n&&(n=e.style[t])),n},ir["opacity:get"]=function(e){var t=ir["@:get"](e,"opacity");return""===t?"1":t};else{var sr=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,cr=/^(top|right|bottom|left)$/,ur=/alpha\([^)]*\)/i,fr=!!e.XDomainRequest,pr="DXImageTransform.Microsoft.Alpha",dr={thin:fr?"1px":"2px",medium:fr?"3px":"4px",thick:fr?"5px":"6px"};ir["@:get"]=function(e,t){var n=e.currentStyle,r=n[t];if(sr.test(r)&&!cr.test(r)){var a=e.style,i=a.left,o=e.runtimeStyle.left;e.runtimeStyle.left=n.left,a.left="fontSize"===t?"1em":r||0,r=a.pixelLeft+"px",a.left=i,e.runtimeStyle.left=o}return"medium"===r&&(t=t.replace("Width","Style"),"none"===n[t]&&(r="0px")),""===r?"auto":dr[r]||r},ir["opacity:set"]=function(e,t,n){var r=e.style,a=isFinite(n)&&1>=n?"alpha(opacity="+100*n+")":"",i=r.filter||"";r.zoom=1,r.filter=(ur.test(i)?i.replace(ur,a):i+" "+a).trim(),r.filter||r.removeAttribute("filter")},ir["opacity:get"]=function(e){var t=e.filters.alpha||e.filters[pr],n=t&&t.enabled?t.opacity:100;return n/100+""}}"top,left".replace(Dt,function(e){ir[e+":get"]=function(t){var n=ir["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var vr={position:"absolute",visibility:"hidden",display:"block"},hr=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(Dt,function(e){var t=e.toLowerCase(),n="client"+e,r="scroll"+e,a="offset"+e;ir[t+":get"]=function(t,n,r){var i=-4;"number"==typeof r&&(i=r),n="Width"===e?["Left","Right"]:["Top","Bottom"];var o=t[a];return 2===i?o+avalon.css(t,"margin"+n[0],!0)+avalon.css(t,"margin"+n[1],!0):(0>i&&(o=o-avalon.css(t,"border"+n[0]+"Width",!0)-avalon.css(t,"border"+n[1]+"Width",!0)),-4===i&&(o=o-avalon.css(t,"padding"+n[0],!0)-avalon.css(t,"padding"+n[1],!0)),o)},ir[t+"&get"]=function(e){var n=[];X(e,n);for(var r,a=ir[t+":get"](e),i=0;r=n[i++];){e=r.node;for(var o in r)"string"==typeof r[o]&&(e.style[o]=r[o])}return a},avalon.fn[t]=function(i){var o=this[0];if(0===arguments.length){if(o.setTimeout)return o["inner"+e]||o.document.documentElement[n];if(9===o.nodeType){var l=o.documentElement;return Math.max(o.body[r],l[r],o.body[a],l[a],l[n])}return ir[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return ir[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return ir[t+":get"](this[0],void 0,e===!0?2:0)}}),avalon.fn.offset=function(){var e=this[0],t={left:0,top:0};if(!e||!e.tagName||!e.ownerDocument)return t;var n=e.ownerDocument,r=n.body,a=n.documentElement,i=n.defaultView||n.parentWindow;if(!avalon.contains(a,e))return t;e.getBoundingClientRect&&(t=e.getBoundingClientRect());var o=a.clientTop||r.clientTop,l=a.clientLeft||r.clientLeft,s=Math.max(i.pageYOffset||0,a.scrollTop,r.scrollTop),c=Math.max(i.pageXOffset||0,a.scrollLeft,r.scrollLeft);return{top:t.top+s-o,left:t.left+c-l}};var mr=/^]+))?)*\s+value[\s=]/i,gr={"option:get":Qt?function(e){return mr.test(e.outerHTML)?e.value:e.text.trim()}:function(e){return e.value},"select:get":function(e,t){for(var n,r=e.options,a=e.selectedIndex,i=gr["option:get"],o="select-one"===e.type||0>a,l=o?null:[],s=o?a+1:r.length,c=0>a?s:o?a:0;s>c;c++)if(n=r[c],(n.selected||c===a)&&!n.disabled){if(t=i(n),o)return t;l.push(t)}return l},"select:set":function(e,t,n){t=[].concat(t);for(var r,a=gr["option:get"],i=0;r=e.options[i++];)(r.selected=t.indexOf(a(r))>-1)&&(n=!0);n||(e.selectedIndex=-1)}},yr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},br=e.JSON&&JSON.stringify||function(e){return'"'+e.replace(/[\\\"\x00-\x1f]/g,function(e){var t=yr[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'},xr=["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(","),$r=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,wr=/[^\w$]+/g,Cr=new RegExp(["\\b"+xr.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Tr=/\b\d[^,]*/g,Er=/^,+|,+$/g,kr=new an(512),_r=function(e){var t=","+e.trim(),n=kr.get(t);if(n)return n;var r=e.replace($r,"").replace(wr,",").replace(Cr,"").replace(Tr,"").replace(Er,"").split(/^$|,+/);return kr.put(t,J(r))},Ar=new an(128),Or=/\w\[.*\]|\w\.\w/,Nr=/(\$proxy\$[a-z]+)\d+$/,Mr=/\)\s*$/,Sr=/\)\s*\|/g,jr=/\|\s*([$\w]+)/g,Lr=/"\s*\["/g,Hr=/"\s*\(/g;avalon.parseExprProxy=K,avalon.scan=function(e,t){e=e||Xt;var n=t?[].concat(t):[];st(e,n)};var Dr=i("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),Pr=function(e,t,n){var r=e.getAttribute(t);if(r)for(var a,i=0;a=n[i++];)if(a.hasOwnProperty(r)&&"function"==typeof a[r])return a[r]},Fr=Qt&&e.MutationObserver?function(e){for(var t,n=e.firstChild;n;){var r=n.nextSibling;3===n.nodeType?t?(t.nodeValue+=n.nodeValue,e.removeChild(n)):t=n:t=null,n=r}}:0,Br=/ms-(\w+)-?(.*)/,Ir={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Rr=i("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),Vr=i("value,title,alt,checked,selected,disabled,readonly,enabled"),zr=/^if|widget|repeat$/,Ur=/^each|with|html|include$/;if(!"1"[0])var qr=new an(512),Wr=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Xr=/^['"]/,Yr=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,Gr=/&/g,Jr=function(e){var t=e.outerHTML;if("(?:[\s\S]+?)<\/noscript>/gim,la=/([\s\S]+?)<\/noscript>/im,sa=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},ca=avalon.templateCache={};nn.attr=function(e,t){var n=e.value.trim(),r=!0;if(n.indexOf(gn)>-1&&n.indexOf(yn)>2&&(r=!1,bn.test(n)&&""===RegExp.rightContext&&""===RegExp.leftContext&&(r=!0,n=RegExp.$1)),"include"===e.type){var a=e.element;e.includeRendered=Pr(a,"data-include-rendered",t),e.includeLoaded=Pr(a,"data-include-loaded",t);var i=e.includeReplace=!!avalon(a).data("includeReplace");avalon(a).data("includeCache")&&(e.templateCache={}),e.startInclude=_t.createComment("ms-include"),e.endInclude=_t.createComment("ms-include-end"),i?(e.element=e.startInclude,a.parentNode.insertBefore(e.startInclude,a),a.parentNode.insertBefore(e.endInclude,a.nextSibling)):(a.insertBefore(e.startInclude,a.firstChild),a.appendChild(e.endInclude))}e.handlerName="attr",K(n,t,e,r?0:ut(e.value))},rn.attr=function(t,n,r){var a=r.type,i=r.param;if("css"===a)avalon(n).css(i,t);else if("attr"===a){var o=t===!1||null===t||void 0===t;!Wt&&aa[i]&&(i=aa[i]);var l=ra[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=Ft.test(n)?!1:_t.namespaces&&I(n)?!0:i in n.cloneNode(!1);s?n[i]=t:n.setAttribute(i,t)}else if("include"===a&&t){var c=r.vmodels,u=r.includeRendered,f=r.includeLoaded,p=r.includeReplace,d=p?n.parentNode:n,v=function(e){if(f){var n=f.apply(d,[e].concat(c));"string"==typeof n&&(e=n)}u&&et(d,function(){u.call(d)},0/0);var a=r.includeLastID;if(r.templateCache&&a&&a!==t){var i=r.templateCache[a];i||(i=r.templateCache[a]=_t.createElement("div"),Ot.appendChild(i))}for(r.includeLastID=t;;){var o=r.startInclude.nextSibling;if(!o||o===r.endInclude)break;d.removeChild(o),i&&i.appendChild(o)}var l=pt(r,t,e),s=avalon.slice(l.childNodes);d.insertBefore(l,r.endInclude),ot(s,c)};if("src"===r.param)if("string"==typeof ca[t])avalon.nextTick(function(){v(ca[t])});else if(Array.isArray(ca[t]))ca[t].push(v);else{var h=sa();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,r=h.responseText,a=0;n=ca[t][a++];)n(r);ca[t]=r}}},ca[t]=[v],h.open("GET",t,!0),"withCredentials"in h&&(h.withCredentials=!0),h.setRequestHeader("X-Requested-With","XMLHttpRequest"),h.send(null)}else{var m=t&&1===t.nodeType?t:_t.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=sa(),h.open("GET",location,!1),h.send(null);for(var g=_t.getElementsByTagName("noscript"),y=(h.responseText||"").match(oa)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(la)||[""," "])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Xt.hasAttribute||"string"!=typeof t||"src"!==a&&"href"!==a||(t=t.replace(/&/g,"&")),n[a]=t,e.chrome&&"EMBED"===n.tagName){var w=n.parentNode,C=document.createComment("ms-src");w.replaceChild(C,n),w.replaceChild(n,C)}},"title,alt,src,value,css,include,href".replace(Dt,function(e){nn[e]=nn.attr}),nn["class"]=function(e,t){var r,a=e.param,i=e.value;if(e.handlerName="class",!a||isFinite(a)){e.param="";var o=i.replace(xn,function(e){return e.replace(/./g,"0")}),l=o.indexOf(":");if(-1===l)var s=i;else{if(s=i.slice(0,l),r=i.slice(l+1),Q(r,t,e),!e.evaluator)return n("debug: ms-class '"+(r||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=bn.test(s);c||(e.immobileClass=s),K("",t,e,c?ut(s):0)}else e.immobileClass=e.oldStyle=e.param,K(i,t,e)},rn["class"]=function(e,t,n){var r=avalon(t),a=n.type;if("class"===a&&n.oldStyle)r.toggleClass(n.oldStyle,!!e);else switch(n.toggleClass=n._evaluator?!!n._evaluator.apply(t,n._args):!0,n.newClass=n.immobileClass||e,n.oldClass&&n.newClass!==n.oldClass&&r.removeClass(n.oldClass),n.oldClass=n.newClass,a){case"class":r.toggleClass(n.newClass,n.toggleClass);break;case"hover":case"active":if(!n.hasBindEvent){var i="mouseenter",o="mouseleave";if("active"===a){t.tabIndex=t.tabIndex||-1,i="mousedown",o="mouseup";var l=r.bind("mouseleave",function(){n.toggleClass&&r.removeClass(n.newClass)})}var s=r.bind(i,function(){n.toggleClass&&r.addClass(n.newClass)}),c=r.bind(o,function(){n.toggleClass&&r.removeClass(n.newClass)});n.rollback=function(){r.unbind("mouseleave",l),r.unbind(i,s),r.unbind(o,c)},n.hasBindEvent=!0}}},"hover,active".replace(Dt,function(e){nn[e]=nn["class"]}),rn.data=function(e,t,n){var r="data-"+n.param;e&&"object"==typeof e?t[r]=e:t.setAttribute(r,String(e))};var ua=nn.duplex=function(e,t){var a,o=e.element;if(K(e.value,t,e,0,1),e.changed=Pr(o,"data-duplex-changed",t)||r,e.evaluator&&e.args){var l=[],s=i("string,number,boolean,checked");"radio"===o.type&&""===e.param&&(e.param="checked"),o.msData&&(o.msData["ms-duplex"]=e.value),e.param.replace(/\w+/g,function(t){/^(checkbox|radio)$/.test(o.type)&&/^(radio|checked)$/.test(t)&&("radio"===t&&n("ms-duplex-radio已经更名为ms-duplex-checked"),t="checked",e.isChecked=!0),"bool"===t?(t="boolean",n("ms-duplex-bool已经更名为ms-duplex-boolean")):"text"===t&&(t="string",n("ms-duplex-text已经更名为ms-duplex-string")),s[t]&&(a=!0),avalon.Array.ensure(l,t)}),a||l.push("string"),e.param=l.join("-"),e.bound=function(t,n){o.addEventListener?o.addEventListener(t,n,!1):o.attachEvent("on"+t,n);var r=e.rollback;e.rollback=function(){o.avalonSetter=null,avalon.unbind(o,t,n),r&&r()}};for(var c in avalon.vmodels){var u=avalon.vmodels[c];u.$fire("avalon-ms-duplex-init",e)}var f=e.pipe||(e.pipe=vt);f(null,e,"init");var p=o.tagName;ua[p]&&ua[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:dt},"boolean":{get:function(e){return"true"===e},set:dt},number:{get:function(e,t){var n=parseFloat(e);if(-e===-n)return n;var r=/strong|medium|weak/.exec(t.element.getAttribute("data-duplex-number"))||["medium"];switch(r[0]){case"strong":return 0;case"medium":return""===e?"":0;case"weak":return e}},set:dt}};var fa,pa=[];avalon.tick=function(e){1===pa.push(e)&&(fa=setInterval(ht,60))};var da=r,va=/text|password|hidden/;!new function(){function e(e){if(avalon.optimize||this.parentNode){if(t[this.tagName].call(this,e),!va.test(this.type))return;!this.msFocus&&this.avalonSetter&&this.avalonSetter()}}try{var t={},n=HTMLInputElement.prototype,r=HTMLTextAreaElement.prototype,a=HTMLInputElement.prototype;Object.getOwnPropertyNames(a),t.INPUT=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:e}),t.TEXTAREA=Object.getOwnPropertyDescriptor(r,"value").set,Object.defineProperty(r,"value",{set:e})}catch(i){da=avalon.tick}},Qt&&avalon.bind(_t,"selectionchange",function(){var e=_t.activeElement;e&&"function"==typeof e.avalonSetter&&e.avalonSetter()}),ua.INPUT=function(e,t,r){function a(e){r.changed.call(this,e,r)}function i(){f=!0}function o(){f=!1}function l(e){setTimeout(function(){p(e)})}var s=e.type,c=r.bound,u=avalon(e),f=!1,p=function(){if(!f){var n=e.oldValue=e.value,i=r.pipe(n,r,"get");u.data("duplexObserve")!==!1&&(t(i),a.call(e,i),u.data("duplex-focus")&&avalon.nextTick(function(){e.focus()}))}};if(r.handler=function(){var n=r.pipe(t(),r,"set")+"";n!==e.oldValue&&(e.value=n)},r.isChecked||"radio"===s){var d=6===Qt;p=function(){if(u.data("duplexObserve")!==!1){var n=r.pipe(e.value,r,"get");t(n),a.call(e,n)}},r.handler=function(){var n=t(),a=r.isChecked?!!n:n+""===e.value;e.oldValue=a,d?setTimeout(function(){e.defaultChecked=a,e.checked=a},31):e.checked=a},c("click",p)}else if("checkbox"===s)p=function(){if(u.data("duplexObserve")!==!1){var i=e.checked?"ensure":"remove",o=t();Array.isArray(o)||(n("ms-duplex应用于checkbox上要对应一个数组"),o=[o]),avalon.Array[i](o,r.pipe(e.value,r,"get")),a.call(e,o)}},r.handler=function(){var n=[].concat(t());e.checked=n.indexOf(r.pipe(e.value,r,"get"))>-1},c(Wt?"change":"click",p);else{var v=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),v.replace(Dt,function(e){switch(e){case"input":Qt?(Qt>8?c("input",p):c("propertychange",function(e){"value"===e.propertyName&&p()}),c("dragend",l)):(c("input",p),c("compositionstart",i),c("compositionend",o),c("DOMAutoComplete",p));break;default:c(e,p)}}),c("focus",function(){e.msFocus=!0}),c("blur",function(){e.msFocus=!1}),va.test(s)&&da(function(){if(avalon.optimize||e.parentNode)e.msFocus||e.oldValue===e.value||p();else if(!e.msRetain)return!1}),e.avalonSetter=p}e.oldValue=e.value,avalon.injectBinding(r),a.call(e,e.value)},ua.TEXTAREA=ua.INPUT,ua.SELECT=function(e,t,r){function a(){if(i.data("duplexObserve")!==!1){var n=i.val();n=Array.isArray(n)?n.map(function(e){return r.pipe(e,r,"get")}):r.pipe(n,r,"get"),n+""!==e.oldValue&&t(n),r.changed.call(e,n,r)}}var i=avalon(e);r.handler=function(){var r=t();r=r&&r.$model||r,Array.isArray(r)?e.multiple||n("ms-duplex在不能对应一个数组"),r=Array.isArray(r)?r.map(String):r+"",r+""!==e.oldValue&&(i.val(r),e.oldValue=r+"")},r.bound("change",a),e.msCallback=function(){avalon.injectBinding(r),r.changed.call(e,t(),r)}},rn.html=function(e,t,n){var r=1!==t.nodeType,a=r?t.parentNode:t;if(a&&(e=null==e?"":e,n.oldText!==e)){if(n.oldText=e,3===t.nodeType){var i=Zt("html");a.insertBefore(_t.createComment(i),t),n.element=_t.createComment(i+":end"),a.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=Yt.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),r){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;a.removeChild(c)}a.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);ot(l,n.vmodels)}},nn["if"]=nn.data=nn.text=nn.html=function(e,t){K(e.value,t,e)},rn["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(r){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),at(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var a=n.element=_t.createComment("ms-if");t.parentNode.replaceChild(a,t),n.template=t,Ot.appendChild(t),n.rollback=function(){t.parentNode===Ot&&Ot.removeChild(t)}}};var ha=/\(([^)]*)\)/;nn.on=function(e,t){var n=e.value;e.type="on";var r=e.param.replace(/-\d+$/,"");if("function"==typeof nn.on[r+"Hook"]&&nn.on[r+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var a=(n.match(ha)||["",""])[1].trim();(""===a||"$event"===a)&&(n=n.replace(ha,""))}K(n,t,e)},rn.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)}},nn.repeat=function(e,t){var n=e.type;K(e.value,t,e,0,1);var r=!1;try{var a=e.$repeat=e.evaluator.apply(0,e.args||[]),i=avalon.type(a);"object"!==i&&"array"!==i&&(r=!0,avalon.log("warning:"+e.value+"只能是对象或数组"))}catch(o){r=!0}var l=e.value.split(".")||[];if(l.length>1){l.pop();for(var s,c=l[0],u=0;s=t[u++];)if(s&&s.hasOwnProperty(c)){var f=s[c].$events||{};f[St]=f[St]||[],f[St].push(e);break}}var p=e.element;if(1===p.nodeType){p.removeAttribute(e.name),e.sortedCallback=Pr(p,"data-with-sorted",t),e.renderedCallback=Pr(p,"data-"+n+"-rendered",t);var d=Zt(n),v=_t.createComment(d),h=_t.createComment(d+":end");if(e.signature=d,e.template=Yt.cloneNode(!1),"repeat"===n){var m=p.parentNode;m.replaceChild(h,p),m.insertBefore(v,h),e.template.appendChild(p)}else{for(;p.firstChild;)e.template.appendChild(p.firstChild);p.appendChild(v),p.appendChild(h)}e.element=h,e.handler=rn.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!r){e.$outer={};var g="$key",y="$val";if(Array.isArray(a)){if(!a.$map){a.$map={el:1};var b=a.length,x=[];for(u=0;b>u;u++)x.push(S(u,a));a.$proxy=x}a.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var $=a.$events,w=($||{})[St];j(w,e),"object"===i?(e.$with=!0,a.$proxy||(a.$proxy={}),e.handler("append",a)):a.length&&e.handler("add",0,a.length)}},rn.repeat=function(e,t,n){if(e){var a,i,o=this,l=o.element,s=gt(o),c=l.parentNode,u=Yt.cloneNode(!1);switch(e){case"add":for(var f=t+n,p=[],d=o.$repeat,v=t;f>v;v++){var h=d.$proxy[v];h.$outer=o.$outer,mt(o,u,h,p)}var m=new Date-0;for(avalon.optimize=avalon.optimize||m,v=0;i=p[v++];)ot(i.nodes,i.vmodels),i.nodes=i.vmodels=null;avalon.optimize===m&&delete avalon.optimize,c.insertBefore(u,s[t]||l),avalon.profile("插入操作花费了 "+(new Date-m));break;case"del":yt(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&yt(a,l);break;case"move":if(a=s[0]){var g,y=a.nodeValue,b=[],x=[];for(yt(a,l,function(){x.unshift(this),this.nodeValue===y&&(b.unshift(x),x=[])}),N(b,t);x=b.shift();)for(;g=x.shift();)u.appendChild(g);c.insertBefore(u,l)}break;case"append":var $=t,w=$.$proxy,C=[];p=[];for(var T in w)$.hasOwnProperty(T)||(wt(w[T],ma),delete w[T]);for(T in $)$.hasOwnProperty(T)&&"hasOwnProperty"!==T&&"$proxy"!==T&&C.push(T);if(o.sortedCallback){var E=o.sortedCallback.call(c,C);E&&Array.isArray(E)&&E.length&&(C=E)}for(v=0;T=C[v++];)"hasOwnProperty"!==T&&(w[T]=xt(w[T],T,o),mt(o,u,w[T],p));for(c.insertBefore(u,l),v=0;i=p[v++];)ot(i.nodes,i.vmodels),i.nodes=i.vmodels=null}"clear"===e&&(e="del");var k=o.renderedCallback||r,_=arguments;et(c,function(){k.apply(c,_),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(Dt,function(e){nn[e]=nn.repeat}),avalon.pool=Fn;var ma=[];rn.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else"textContent"in t?t.textContent=e:t.innerText=e},avalon.parseDisplay=Ct,nn.visible=function(e,t){var n=avalon(e.element),r=n.css("display");if("none"===r){var a=n[0].style,i=/visibility/i.test(a.cssText),o=n.css("visibility");a.display="",a.visibility="hidden",r=n.css("display"),"none"===r&&(r=Ct(n[0].nodeName)),a.visibility=i?o:""}e.display=r,K(e.value,t,e)},rn.visible=function(e,t,n){t.style.display=e?n.display:"none"},nn.widget=function(t,a){var i=t.value.match(Dt),o=t.element,l=i[0],s=i[1];s&&"$"!==s||(s=Zt(l));var c=i[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,p=0;f=a[p++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var d=f[c];d=d.$model||d;break}if(d){var v=d[l+"Id"];"string"==typeof v&&(n("warning!不再支持"+l+"Id"),s=v)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=r,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,d||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,tt(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},D(t,ga),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(P)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var ga=[],ya=/]*>([\S\s]*?)<\/script\s*>/gim,ba=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,xa=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,$a={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},wa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ca=/([^\#-~| |!])/g,Ta=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof n?n:"...",e.length>t?e.slice(0,t-n.length)+n:String(e)},$filter:function(e){for(var t=1,n=arguments.length;n>t;t++){var r=arguments[t],a=avalon.filters[r.shift()];if("function"==typeof a){var i=[e].concat(r);e=a.apply(null,i)}}return e},camelize:z,sanitize:function(e){return e.replace(ya,"").replace(xa,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=$a[t[1]];n&&(e=e.replace(n,function(e,t,n){var r=n.charAt(0);return t+"="+r+"javascript:void(0)"+r}))}return e.replace(ba," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(wa,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Ca,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+Tt(e,isFinite(n)?n:2)},number:Tt};!new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var r="";for(0>e&&(r="-",e=-e),e=""+e;e.length0||o>-r)&&(o+=r),0===o&&-12===r&&(o=12),t(o,n,a)}}function r(e,t){return function(n,r){var a=n["get"+e](),i=(t?"SHORT"+e:e).toUpperCase();return r[i][a]}}function a(e){var n=-1*e.getTimezoneOffset(),r=n>=0?"+":"";return r+=t(Math[n>0?"floor":"ceil"](n/60),2)+t(Math.abs(n%60),2)}function i(e,t){return e.getHours()<12?t.AMPMS[0]:t.AMPMS[1]}var o={yyyy:n("FullYear",4),yy:n("FullYear",2,0,!0),y:n("FullYear",1),MMMM:r("Month"),MMM:r("Month",!0),MM:n("Month",2,1),M:n("Month",1,1),dd:n("Date",2),d:n("Date",1),HH:n("Hours",2),H:n("Hours",1),hh:n("Hours",2,-12),h:n("Hours",1,-12),mm:n("Minutes",2),m:n("Minutes",1),ss:n("Seconds",2),s:n("Seconds",1),sss:n("Milliseconds",3),EEEE:r("Day"),EEE:r("Day",!0),a:i,Z:a},l=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,s=/^\/Date\((\d+)\)\/$/;Ta.date=function(t,n){var r,a,i=Ta.date.locate,c="",u=[];if(n=n||"mediumDate",n=i[n]||n,"string"==typeof t)if(/^\d+$/.test(t))t=e(t);else if(s.test(t))t=+RegExp.$1;else{var f=t.trim(),p=[0,0,0,0,0,0,0],d=new Date(0);f=f.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,r,a){var i=4===a.length?[a,n,r]:[n,r,a];return p[0]=e(i[0]),p[1]=e(i[1])-1,p[2]=e(i[2]),""});var v=d.setFullYear,h=d.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,r,a,i){return p[3]=e(n),p[4]=e(r),p[5]=e(a),i&&(p[6]=Math.round(1e3*parseFloat("0."+i))),"" +});var m=0,g=0;f=f.replace(/Z|([+-])(\d\d):?(\d\d)/,function(t,n,r,a){return v=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+r),g=e(n+a)),""}),p[3]-=m,p[4]-=g,v.apply(d,p.slice(0,3)),h.apply(d,p.slice(3)),t=d}if("number"==typeof t&&(t=new Date(t)),"date"===avalon.type(t)){for(;n;)a=l.exec(n),a?(u=u.concat(a.slice(1)),n=u.pop()):(u.push(n),n=null);return u.forEach(function(e){r=o[e],c+=r?r(t,i):e.replace(/(^'|'$)/g,"").replace(/''/g,"'")}),c}};var c={AMPMS:{0:"上午",1:"下午"},DAY:{0:"星期日",1:"星期一",2:"星期二",3:"星期三",4:"星期四",5:"星期五",6:"星期六"},MONTH:{0:"1月",1:"2月",2:"3月",3:"4月",4:"5月",5:"6月",6:"7月",7:"8月",8:"9月",9:"10月",10:"11月",11:"12月"},SHORTDAY:{0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"},fullDate:"y年M月d日EEEE",longDate:"y年M月d日",medium:"yyyy-M-d H:mm:ss",mediumDate:"yyyy-M-d",mediumTime:"H:mm:ss","short":"yy-M-d ah:mm",shortDate:"yy-M-d",shortTime:"ah:mm"};c.SHORTMONTH=c.MONTH,Ta.date.locate=c};var Ea=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Ea.exports=Ea.avalon,new function(){function t(e,t){var r="js";e=e.replace(/^(\w+)\!/,function(e,t){return r=t,""}),"ready"===r&&(n("debug: ready!已经被废弃,请使用domReady!"),r="domReady");var a="";e=e.replace(D,function(e){return a=e,""});var i="."+r,o=/js|css/.test(i)?i:"";e=e.replace(/\.[a-z0-9]+$/g,function(e){return e===i?(o=e,""):e});var l=avalon.mix({query:a,ext:o,res:r,name:e,toUrl:m},t);return l.toUrl(e),l}function i(e){var t=e.name,n=e.res,r=Ea[t],a=t&&e.urlNoQuery;if(r&&r.state>=1)return t;if(r=Ea[a],r&&r.state>=3)return Nt(r.deps||[],r.factory,a),a;if(t&&!r){r=Ea[a]={id:a,state:1};var i=function(a){H[n]=a,a.load(t,e,function(e){arguments.length&&void 0!==e&&(r.exports=e),r.state=4,s()})};H[n]?i(H[n]):Nt([n],i)}return t?a:n+"!"}function o(e,t){for(var n,r=0;n=e[r++];)if(4!==Ea[n].state&&(n===t||o(Ea[n].deps,t)))return!0}function l(e,t,r){var a=u(e.src);return e.onload=e.onreadystatechange=e.onerror=null,t||r&&Ea[a]&&!Ea[a].state?(setTimeout(function(){At.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Ea[a].state)):!0}function s(){e:for(var e,t=E.length;e=E[--t];){var n=Ea[e],r=n.deps;if(r){for(var a,i=0;a=r[i];i++)if(4!==Object(Ea[a]).state)continue e;4!==n.state&&(E.splice(t,1),v(n.id,n.deps,n.factory),s())}}}function c(e,t,r){function a(){var a=k.pop();a&&a.require(t),r&&r(),l(i,!1,!c)&&(n("debug: 已成功加载 "+e),t&&E.push(t),s())}var i=_t.createElement("script");i.className=St;var o,c="onload"in i,u=c?"onload":"onreadystatechange",f=0;i[u]=c?a:function(){L.test(i.readyState)&&(++f,1===f?o=setTimeout(a,500):(clearTimeout(o),a()))},i.onerror=function(){l(i,!0)},At.insertBefore(i,At.firstChild),i.src=e,n("debug: 正准备加载 "+e)}function u(e){return(e||"").replace(D,"")}function f(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(e,t){return"1"[0]?e[t]:e.getAttribute(t,4)}function d(){var t;try{a.b.c()}catch(n){t=n.stack,!t&&e.opera&&(t=(String(n).match(/of linked script \S+/g)||[]).join(" "))}if(t)return t=t.split(/[@ ]/g).pop(),t="("===t[0]?t.slice(1,-1):t.replace(/\s/,""),u(t.replace(/(:\d+)?:\d+$/i,""));for(var r,i=At.getElementsByTagName("script"),o=i.length;r=i[--o];)if(r.className===St&&"interactive"===r.readyState){var l=p(r,"src");return r.className=u(l)}}function v(t,r,a){var i=Object(Ea[t]);i.state=4;for(var o,l=0,s=[];o=r[l++];)if("exports"===o){var c=i.exports||(i.exports={});s.push(c)}else s.push(Ea[o].exports);try{var u=a.apply(e,s)}catch(f){n("执行["+t+"]模块的factory抛错: "+f)}return void 0!==u&&(i.exports=u),P.test(t)&&delete Ea[t],delete i.factory,u}function m(e){0===e.indexOf(this.res+"!")&&(e=e.slice(this.res.length+1));var t=e,n=0,r=this.baseUrl,a=this.parentUrl||r;$(e,h.paths,function(e,r){t=t.replace(r,e),n=1}),n||$(e,h.packages,function(e,n,r){t=t.replace(r.name,r.location)}),this.mapUrl&&$(this.mapUrl,h.map,function(e){$(t,e,function(e,n){t=t.replace(n,e),a=r})});var i=this.ext;i&&n&&t.slice(-i.length)===i&&(t=t.slice(0,-i.length)),f(t)||(a=this.built||/^\w/.test(t)?r:a,t=C(a,t));var o=t+i;return t=o+this.query,$(e,h.urlArgs,function(e){t+=(-1===t.indexOf("?")?"?":"&")+e}),this.url=t,this.urlNoQuery=o}function g(e,t,n){var r=x(e,t,n);return r.sort(w),r}function y(e){return new RegExp("^"+e+"(/|$)")}function b(t){return function(){var n;return t.init&&(n=t.init.apply(e,arguments)),n||t.exports&&T(t.exports)}}function x(e,t,n){var r=[];for(var a in e)if(Rt.call(e,a)){var i={name:a,val:e[a]};r.push(i),i.reg="*"===a&&t?/^/:y(a),n&&"*"!==a&&(i.reg=new RegExp("/"+a.replace(/^\//,"")+"(/|$)"))}return r}function $(e,t,n){t=t||[];for(var r,a=0;r=t[a++];)if(r.reg.test(e))return n(r.val,r.name,r),!1}function w(e,t){var n=e.name,r=t.name;return"*"===r?-1:"*"===n?1:r.length-n.length}function C(e,t){if("/"!==e.charAt(e.length-1)&&(e+="/"),"./"===t.slice(0,2))return e+t.slice(2);if(".."===t.slice(0,2)){for(e+=t;F.test(e);)e=e.replace(F,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function T(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var E=[],k=[],_=/\.js$/i,A=[],O=!1;Nt=avalon.require=function(e,n,a,o){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var l=[],c={},u=a||"callback"+setTimeout("1");o=o||{},o.baseUrl=h.baseUrl;var f=!!o.built;if(a&&(o.parentUrl=a.substr(0,a.lastIndexOf("/")),o.mapUrl=a.replace(_,"")),f){var p=t(o.defineName,o);u=p.urlNoQuery}else e.forEach(function(e){var n=t(e,o),r=i(n);r&&(c[r]||(l.push(r),c[r]="司徒正美"))});var d=Ea[u];d&&4===d.state||(Ea[u]={id:u,deps:f?e.concat():l,factory:n||r,state:3}),d||E.push(u),s()}else if(A.push(avalon.slice(arguments)),arguments.length<=2){O=!0;for(var v,m=A.splice(0,A.length);v=m.shift();)Nt.apply(null,v)}},Nt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var r={built:!O,defineName:e},a=[t,n,r];n.require=function(e){if(a.splice(2,0,e),Ea[e]){Ea[e].state=3;var t=!1;try{t=o(Ea[e].deps,e)}catch(r){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,Nt.apply(null,a)};var i=r.built?"unknown":d();if(i){var l=Ea[i];l&&(l.state=2),n.require(i)}else k.push(n)},Nt.config=h,Nt.define.amd=Ea;var N=h["orig.paths"]={},M=h["orig.map"]={},S=h.packages=[],j=h["orig.args"]={};avalon.mix(Cn,{paths:function(e){avalon.mix(N,e),h.paths=g(N)},map:function(e){avalon.mix(M,e);var t=g(M,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),h.map=t},packages:function(e){e=e.concat(S);for(var t,n={},r=[],a=0;t=e[a++];){t="string"==typeof t?{name:t}:t;var i=t.name;if(!n[i]){var o=C(t.location||i,t.main||"main");o=o.replace(_,""),r.push(t),n[i]=t.location=o,t.reg=y(i)}}h.packages=r.sort()},urlArgs:function(e){"string"==typeof e&&(e={"*":e}),avalon.mix(j,e),h.urlArgs=g(j,1)},baseUrl:function(e){if(!f(e)){var t=At.getElementsByTagName("base")[0];t&&At.removeChild(t);var n=_t.createElement("a");n.href=e,e=p(n,"href"),t&&At.insertBefore(t,At.firstChild)}e.length>3&&(h.baseUrl=e)},shim:function(e){for(var t in e){var n=e[t];Array.isArray(n)&&(n=e[t]={deps:n}),n.exportsFn||!n.exports&&!n.init||(n.exportsFn=b(n))}h.shim=e}});var L=/complete|loaded/,H=Nt.plugins={ready:{load:r},js:{load:function(e,t,n){var r=t.url,a=t.urlNoQuery,i=h.shim[e.replace(_,"")];i?Nt(i.deps||[],function(){var e=avalon.slice(arguments);c(r,a,function(){n(i.exportsFn?i.exportsFn.apply(0,e):void 0)})}):c(r,a)}},css:{load:function(e,t,r){var a=t.url,i=_t.createElement("link");i.rel="stylesheet",i.href=a,At.insertBefore(i,At.firstChild),n("debug: 已成功加载 "+a),r()}},text:{load:function(e,t,r){var a=t.url,i=sa();i.onreadystatechange=function(){if(4===i.readyState){var e=i.status;e>399&&600>e?avalon.error(a+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+a),r(i.responseText))}};var o="_="+(new Date-0),l=-1===a.indexOf("?")?a+"?"+o:a+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+a)}}};Nt.checkDeps=s;var D=/(\?[^#]*)$/,P=/^callback\d+$/,F=/\/\w+\/\.\./,B=_t.scripts[_t.scripts.length-1],I=B.getAttribute("data-main");if(I){Cn.baseUrl(I);var R=h.baseUrl;h.baseUrl=R.slice(0,R.lastIndexOf("/")+1),c(R.replace(_,"")+".js")}else{var V=u(p(B,"src"));h.baseUrl=V.slice(0,V.lastIndexOf("/")+1)}};var ka,_a=[],Aa=function(e){for(ka=!0,Nt&&(Ea["domReady!"].state=4,Nt.checkDeps());e=_a.shift();)e(avalon)};if("complete"===_t.readyState)setTimeout(Aa);else if(Wt)_t.addEventListener("DOMContentLoaded",Aa);else{_t.attachEvent("onreadystatechange",function(){"complete"===_t.readyState&&Aa()});try{var Oa=null===e.frameElement}catch(Sn){}Xt.doScroll&&Oa&&e.external&&Et()}avalon.bind(e,"load",Aa),avalon.ready=function(e){ka?e(avalon):_a.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(_t.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var Na=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=Na),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file diff --git a/dist/avalon.mobile.js b/dist/avalon.mobile.js index 04e94f9d1..8c4da593a 100644 --- a/dist/avalon.mobile.js +++ b/dist/avalon.mobile.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.mobile.js 1.44 built in 2015.6.16 + avalon.mobile.js 1.44 built in 2015.6.25 support IE10+ and other browsers ==================================================*/ (function(global, factory) { @@ -79,7 +79,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -101,7 +101,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -115,12 +115,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -140,14 +146,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -155,13 +161,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -872,12 +878,10 @@ function modelFactory(source, $special, $model) { $model = $model || {} //vmodels.$model属性 var $events = createMap() //vmodel.$events属性 var accessors = createMap() //监控属性 - var initCallbacks = [] //初始化才执行的函数 - + var computed = [] $$skipArray.forEach(function (name) { delete source[name] }) - for (var i in source) { (function (name, val, accessor) { $model[name] = val @@ -890,13 +894,9 @@ function modelFactory(source, $special, $model) { //总共产生三种accessor if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { accessor = makeComputedAccessor(name, val) - initCallbacks.push(accessor) + computed.push(accessor) } else if (rcomplexType.test(valueType)) { - accessor = makeComplexAccessor(name, val, valueType) - initCallbacks.push(function () { - var son = accessor._vmodel - son.$events[subscribers] = this.$events[name] - }) + accessor = makeComplexAccessor(name, val, valueType, $events[name]) } else { accessor = makeSimpleAccessor(name, val) } @@ -926,10 +926,26 @@ function modelFactory(source, $special, $model) { enumerable: false, configurable: true }) - - initCallbacks.forEach(function (cb) { //收集依赖 - cb.call($vmodel) - }) + $vmodel.$compute = function () { + computed.forEach(function (accessor) { + dependencyDetection.begin({ + callback: function (vm, dependency) {//dependency为一个accessor + var name = dependency._name + if (dependency !== accessor) { + var list = vm.$events[name] + accessor.vm = $vmodel + injectDependency(list, accessor.digest) + } + } + }) + try { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$compute() return $vmodel } @@ -938,10 +954,7 @@ function makeSimpleAccessor(name, value) { function accessor(value) { var oldValue = accessor._value if (arguments.length > 0) { - if (stopRepeatAssign) { - return this - } - if (!isEqual(value, oldValue)) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { accessor.updateValue(this, value) accessor.notify(this, value, oldValue) } @@ -970,35 +983,7 @@ function makeComputedAccessor(name, options) { return this } else { //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 - dependencyDetection.collectDependency(this, accessor) - if (!accessor.digest) { - var vm = this - var id - accessor.digest = function () { - accessor.updateValue = globalUpdateModelValue - accessor.notify = noop - accessor.call(vm) - clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 - id = setTimeout(function () { - accessorFactory(accessor, accessor._name) - accessor.call(vm) - }) - } - } - dependencyDetection.begin({ - callback: function (vm, dependency) {//dependency为一个accessor - var name = dependency._name - if (dependency !== accessor) { - var list = vm.$events[name] - injectDependency(list, accessor.digest) - } - } - }) - try { - value = accessor.get.call(this) - } finally { - dependencyDetection.end() - } + value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) init && accessor.notify(this, value, oldValue) //触发$watch回调 @@ -1006,15 +991,27 @@ function makeComputedAccessor(name, options) { //将自己注入到低层访问器的订阅数组中 return value } + } accessor.set = options.set || noop accessor.get = options.get accessorFactory(accessor, name) + var id + accessor.digest = function () { + accessor.updateValue = globalUpdateModelValue + accessor.notify = noop + accessor.call(accessor.vm) + clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 + id = setTimeout(function () { + accessorFactory(accessor, accessor._name) + accessor.call(accessor.vm) + }) + } return accessor } //创建一个复杂访问器 -function makeComplexAccessor(name, initValue, valueType) { +function makeComplexAccessor(name, initValue, valueType, list) { function accessor(value) { var oldValue = accessor._value var son = accessor._vmodel @@ -1034,10 +1031,11 @@ function makeComplexAccessor(name, initValue, valueType) { son = accessor._vmodel = modelFactory(value) son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) son.$events[name] = observes @@ -1052,7 +1050,8 @@ function makeComplexAccessor(name, initValue, valueType) { } } accessorFactory(accessor, name) - accessor._vmodel = modelFactory(initValue) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list return accessor } @@ -1319,7 +1318,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1416,6 +1415,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1502,11 +1503,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1543,6 +1548,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -2735,6 +2742,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -2753,7 +2761,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3136,7 +3143,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3264,7 +3271,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { }) if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -3333,7 +3340,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -3356,16 +3367,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -3570,11 +3581,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.mobile.min.js b/dist/avalon.mobile.min.js index 34be5e5cb..30dc9109f 100644 --- a/dist/avalon.mobile.min.js +++ b/dist/avalon.mobile.min.js @@ -1,3 +1,3 @@ -!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(kt)||[]);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=St.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=gt.createElementNS(Wt,n.tagName.toLowerCase());Lt.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(Nt.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(en,"\\$&")}function d(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=$(e);return i.pushArray(a),i}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var o=Array.isArray(e.$skipArray)?e.$skipArray:[];o.$special=t||r();var l={};n=n||{};var s=r(),c=r(),u=[];on.forEach(function(t){delete e[t]});for(var f in e)!function(e,t,a){if(n[e]=t,x(e,t,o)){s[e]=[];var r=avalon.type(t);"object"===r&&Vt(t.get)&&Object.keys(t).length<=2?(a=p(e,t),u.push(a)):Tt.test(r)?(a=h(e,t,r),u.push(function(){var t=a._vmodel;t.$events[$t]=this.$events[e]})):a=v(e,t),c[e]=a}}(f,e[f]);l=Object.defineProperties(l,sn(c));for(var d in e)c[d]||(l[d]=e[d]);l.$id=Bt(),l.$model=n,l.$events=s;for(f in an)l[f]=an[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.call(l)}),l}function v(e,t){function n(e){var t=n._value;return arguments.length>0?Et?this:(ln(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(dn.collectDependency(this,n),t)}return b(n,e),n._value=t,n}function p(e,t){function n(e){var t=n._value,a="_value"in n;if(arguments.length>0)return Et?this:(n.set.call(this,e),this);if(dn.collectDependency(this,n),!n.digest){var r,o=this;n.digest=function(){n.updateValue=g,n.notify=i,n.call(o),clearTimeout(r),r=setTimeout(function(){b(n,n._name),n.call(o)})}}dn.begin({callback:function(e,t){var a=t._name;if(t!==n){var r=e.$events[a];A(r,n.digest)}}});try{e=n.get.call(this)}finally{dn.end()}return t!==e&&(n.updateValue(this,e),a&&n.notify(this,e,t)),e}return t.set=t.set||i,n.set=t.set||i,n.get=t.get,b(n,e),n}function h(e,t,n){function a(t){var r=a._value,i=a._vmodel;if(arguments.length>0){if(Et)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=a._vmodel=d(t),i.$proxy=l,s.length&&(s.forEach(function(e){e.rollback&&(e.rollback(),Ut[e.type](e,e.vmodels))}),i.$events[e]=s)}return a.updateValue(this,i.$model),a.notify(this,this._value,r),this}return dn.collectDependency(this,a),i}return b(a,e),a._vmodel=d(t),a}function m(e,t){e.$model[this._name]=this._value=t}function g(e,t){e.$model[this._name]=t}function y(e,t,n){var a=this._name,r=e.$events[a];r&&(M(r),an.$fire.call(e,a,t,n))}function b(e,t){e._name=t,e.updateValue=m,e.notify=y}function x(e,t,n){if(Vt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function $(e){var t=[];t.$id=Bt(),t.$model=e,t.$events={},t.$events[$t]=[],t._=d({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in an)t[n]=an[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,un),t}function w(e,t,n,a,r,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return Tt.test(avalon.type(e))?e.$id?e:d(e,0,e):e});cn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var v=T(f,this);this.$proxy.splice(f,0,v)}this._fire("add",t,n);break;case"del":var p=this._splice(t,n),h=this.$proxy.splice(t,n);dt(h,"each"),this._fire("del",t,n)}r&&(e=r,t=i,n=o,s=2,r=0)}return C(this.$proxy,a),this.length!==l&&(this._.length=this.length),p}function C(e,t){for(var n,a=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===a}function E(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 k(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=d(e,t);return n.$id=Bt("$proxy$each"),n}function T(e,t){var n=fn.shift();n||(n=k());var a=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===a,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function A(e,t){t=t||Ht[mt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&N(t,e)}function M(e){if(e&&e.length){new Date-mn>444&&"object"==typeof e[0]&&S();for(var t,n=jt.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 O(e){return e.uniqueNumber||(e.uniqueNumber=++pn)}function N(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+O(n.parentNode):e.name+"-"+O(n));var a=e.lists||(e.lists=[]);avalon.Array.ensure(a,t),t.$uuid=t.$uuid||Bt(),hn[e.uuid]||(hn[e.uuid]=1,hn.push(e))}function S(e){for(var t=hn.length,n=t,a=[],r={},i={};e=hn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,a.push(o))}var l=!1;if(a.forEach(function(e){gn[e]!==i[e]&&(r[e]=1,l=!0)}),t=n,l)for(;e=hn[--t];)if(e.element&&r[e.type]&&j(e.element)){hn.splice(t,1),delete hn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);L(e)}gn=i,mn=new Date}function L(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function j(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!Pt.contains(e):!avalon.contains(Pt,e)}function H(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function D(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function P(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 _(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function R(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(On.test(n.display)){var a={node:e};for(var r in Mn)a[r]=n[r],e.style[r]=Mn[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&R(i,t)}}function I(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function B(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;r=e[--s];){var c=l&&t.$map[r]?"el":r;t.hasOwnProperty(c)&&(i.push(r+o+c),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function F(e){for(var t=[],n={},a=0;av;v++)if(s.length){var h="vm"+mt+"_"+v;u.push(h),f.push(t[v]),c.push.apply(c,B(s,t[v],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=Ft?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,delete a.vars;var m=Bn.get(l);if(m)return void(a.evaluator=m);if(d=c.join(", "),d&&(d="var "+d),/\S/.test(o)){if(!/text|html/.test(a.type))throw Error("ms-"+a.type+"不支持过滤器");e="\nvar ret"+mt+" = "+e+";\r\n",e+=V("ret"+mt,o)}else{if("duplex"===r){var g="'use strict';\nreturn function(vvv){\n "+d+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Fn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(i,u.concat(g)),a.evaluator=Bn.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"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(i,u.concat("'use strict';\n"+d+e)),a.evaluator=Bn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function q(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":Sn(e.value)}).join(" + ")),U(e,t,n),n.evaluator&&!r&&(n.handler=qt[n.handlerName||n.type],avalon.injectBinding(n))}function z(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():z(e,t,r)})}function W(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function X(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,Ut[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function Y(e,t){return e.priority-t.priority}function G(e,t,a){var i=!0;if(t.length){for(var o,l=e.attributes,s=[],c=[],u=r(),f=0;o=l[f++];)if(o.specified&&(a=o.name.match(Jn))){var d=a[1],v=a[2]||"",p=o.value,h=o.name;if(Kn[d]?(v=d,d="on"):ea[d]&&("enabled"===d&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),d="disabled",p="!("+p+")"),v=d,d="attr",h="ms-"+d+"-"+v,c.push([o.name,h,p])),u[h]=p,"function"==typeof Ut[d]){var m={type:d,param:v,element:e,name:h,value:p,priority:(Qn[d]||10*d.charCodeAt(0))+(Number(v.replace(/\D/g,""))||0)};if("html"===d||"text"===d){var g=et(p);avalon.mix(m,g),m.filters=m.filters.replace(aa,function(){return m.type="html",m.group=1,""})}else if("duplex"===d)var y=h;else"ms-if-loop"===h&&(m.priority+=100);s.push(m),"widget"===d&&(e.msData=e.msData||u)}}if(s.length){s.sort(Y),c.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])});var b=e.type;for(b&&y&&(u["ms-attr-checked"]&&n("warning!"+b+"控件不能同时定义ms-attr-checked与"+y),u["ms-attr-value"]&&n("warning!"+b+"控件不能同时定义ms-attr-value与"+y)),f=0;m=s[f];f++){if(d=m.type,ta.test(d))return X(s.slice(0,f+1),t);i&&(i=!na.test(d))}X(s,t)}}i&&!Yn[e.tagName]&&Kt.test(e.innerHTML+e.textContent)&&(Zn&&Zn(e),Z(e,t))}function Z(e,t){var n=avalon.slice(e.childNodes);J(n,t)}function J(e,t){for(var n,a=0;n=e[a++];)Q(n,n.nodeType,t)}function Q(e,t,n){1===t?(K(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&Jt.test(e.data)?nt(e,n):u.commentInterpolate&&8===t&&!Jt.test(e.nodeValue)&&nt(e,n)}function K(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),W(e,o)}G(e,t)}}function et(e,t){if(e.indexOf("|")>0){var n=e.replace(ia,function(e){return Array(e.length+1).join("1")}),a=n.replace(ra,"ᄢ㍄").indexOf("|");if(a>-1)return{filters:e.slice(a),value:e.slice(0,a),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function tt(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Gt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Gt.length,n=e.indexOf(Zt,r),-1===n)break;t=e.slice(r,n),t&&a.push(et(t,r)),r=n+Zt.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function nt(e,t){var n=[];if(8===e.nodeType)var a=et(e.nodeValue),r=[a];else r=tt(e.data);if(r.length){for(var i=0;a=r[i++];){var o=gt.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(aa,function(){return a.type="html",""}),n.push(a)),_t.appendChild(o)}e.parentNode.replaceChild(_t,e),n.length&&X(n,t)}}function at(e,t,n){var a=e.templateCache&&e.templateCache[t];if(a){for(var r,i=gt.createDocumentFragment();r=a.firstChild;)i.appendChild(r);return i}return avalon.parseHTML(n)}function rt(e){return null==e?"":e}function it(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 ot(){for(var e=ma.length-1;e>=0;e--){var t=ma[e];t()===!1&&ma.splice(e,1)}ma.length||clearInterval(ha)}function lt(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);e.$with||r.insertBefore(gt.createComment(e.signature),r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function st(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),a=t.previousSibling,r=[];a;)a.nodeValue===n&&r.unshift(a),a=a.previousSibling;return r}function ct(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function ut(){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=Bt("$proxy$with"),e}function ft(e,t,n){e=e||xa.pop(),e||(e=ut());var a=n.$repeat;return e.$key=t,e.$host=a,e.$outer=n.$outer,a.$events?e.$events.$val=a.$events[t]:e.$events={},e}function dt(e){e.forEach(function(e){vt(e,fn)}),e.length=0}function vt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&L(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>u.maxRepeatSize&&t.pop()}function pt(e,t){var n="_"+e;if(!pt[n]){var a=gt.createElement(e);Pt.appendChild(a),t=Dt?getComputedStyle(a,null).display:a.currentStyle.display,Pt.removeChild(a),pt[n]=t}return pt[n]}function ht(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');var bt,xt=yt.firstChild,$t="$"+mt,wt=e.require,Ct=e.define,Et=!1,kt=/[^, ]+/g,Tt=/^(?:object|array)$/,At=/^\[object SVG\w*Element\]$/,Mt=/^\[object (?:Window|DOMWindow|global)\]$/,Ot=Object.prototype,Nt=Ot.hasOwnProperty,St=Ot.toString,Lt=Array.prototype,jt=Lt.slice,Ht={},Dt=e.dispatchEvent,Pt=gt.documentElement,_t=gt.createDocumentFragment(),Rt=gt.createElement("div"),It={};"Boolean Number String Function Array Date RegExp Object Error".replace(kt,function(e){It["[object "+e+"]"]=e.toLowerCase()});var Bt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Ft=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=Dt&&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?It[St.call(e)]||"object":typeof e};var Vt=function(e){return"[object Function]"===St.call(e)};avalon.isFunction=Vt,avalon.isWindow=function(e){return Mt.test(St.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===St.call(e)&&Object.getPrototypeOf(e)===Ot},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||Vt(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:kt,subscribers:$t,version:1.44,ui:{},log:n,slice:function(e,t,n){return jt.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);++an&&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 Ut=avalon.bindingHandlers={},qt=avalon.bindingExecutors={},zt=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(gt.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 Wt="http://www.w3.org/2000/svg",Xt=gt.createElementNS(Wt,"svg");Xt.innerHTML='',At.test(Xt.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=gt.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("$","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 Yt=avalon.eventHooks;"onmouseenter"in Pt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Yt[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]&&!Yt.animationend&&(Yt.animationend={type:n})}),void 0===gt.onmousewheel&&(Yt.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 Gt,Zt,Jt,Qt,Kt,en=/[-.*+?^${}()|[\]\/\\]/g,tn={loader:function(t){var n=bt&&t;e.require=n?bt:wt,e.define=n?bt.define:Ct},interpolate:function(e){if(Gt=e[0],Zt=e[1],Gt===Zt)throw new SyntaxError("openTag!==closeTag");if(e+""=="")u.commentInterpolate=!0;else{var t=Gt+"test"+Zt;if(Rt.innerHTML=t,Rt.innerHTML!==t&&Rt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Rt.innerHTML=""}var n=f(Gt),a=f(Zt);Jt=new RegExp(n+"(.*?)"+a),Qt=new RegExp(n+"(.*?)"+a,"g"),Kt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=tn,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var nn=function(e){return gt.querySelectorAll(e)},an={$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=jt.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?nn(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=nn(a.$events.expr);if(0===c.length)continue;Lt.forEach.call(c,function(e){Lt.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=gt.getElementsByTagName("*"),f=[];for(Lt.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 d=i[e]||[],v=i.$all||[];for(n=0;r=d[n++];)Vt(r)&&r.apply(this,o);for(n=0;r=v[n++];)Vt(r)&&r.apply(this,arguments)}}}},rn=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),rn[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var r=d(e);else{var o={$watch:i};t(o),r=d(o),Et=!0,t(r),Et=!1}return r.$id=a,rn[a]=r};var on=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(kt),ln=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},sn=function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t},cn=Lt.splice,un={_splice:cn,_fire:function(e,t,n){M(this.$events[$t],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Lt.push.apply(this.$model,e),w.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&&(Lt.unshift.apply(this.$model,arguments),w.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return w.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return w.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=cn.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?w.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),w.call(this,"del",e,1,0)):[]},clear:function(){return dt(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],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 if("array"===n)a.clear().push.apply(a,t);else if(a!==t){this[e]=t,this.$model[e]=t;var i=this.$proxy[e];i&&M(i.$events.el)}}return this}};"sort,reverse".replace(kt,function(e){un[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];Lt[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(ln(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(E(this,i),E(this.$proxy,i),this._fire("move",i),C(this.$proxy,0)),this}});var fn=[],dn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),vn=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){dn.begin({callback:function(t,n){A(t.$events[n._name],e)}});try{var n=vn.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(gt.createComment(e.value),r):r.data=Gt+e.value+Zt}}finally{dn.end()}}};var pn=0,hn=avalon.$$subscribers=[],mn=new Date,gn={},yn=new function(){avalon.mix(this,{option:gt.createElement("select"),thead:gt.createElement("table"),td:gt.createElement("tr"),area:gt.createElement("map"),tr:gt.createElement("tbody"),col:gt.createElement("colgroup"),legend:gt.createElement("fieldset"),_default:gt.createElement("div"),g:gt.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(kt,function(e){yn[e]=yn.g});var bn=/<([\w:]+)/,xn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,$n=o(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),wn=gt.createElement("script"),Cn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=_t.cloneNode(!1);if("string"!=typeof e)return t;if(!Cn.test(e))return t.appendChild(gt.createTextNode(e)),t;e=e.replace(xn,"<$1>").trim();var n,a=(bn.exec(e)||["",""])[1].toLowerCase(),r=yn[a]||yn._default;r.innerHTML=e;var i=r.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if($n[o.type]){var s=wn.cloneNode(!1);Lt.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},"add,remove".replace(kt,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=String(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-"+H(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return P(n);case 0:var a={};return Lt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=D(e.slice(5)),a[e]=P(t.value)))}),a}},removeData:function(e){return e="data-"+H(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),a.top-=e.scrollTop(),a.left-=e.scrollLeft()),{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||Pt)},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=Nn[I(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}}),Pt.dataset&&(avalon.fn.data=function(e,t){e=e&&D(e);var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],P(t);case 0:var a=r();for(e in n)a[e]=P(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=_(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 kn=avalon.cssHooks=r(),Tn=["","-webkit-","-moz-","-ms-"],An={"float":"cssFloat"};avalon.cssNumber=o("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(An[e])return An[e];t=t||Pt.style;for(var a=0,r=Tn.length;r>a;a++)if(n=D(Tn[a]+e),n in t)return An[e]=n;return null},kn["@:set"]=function(e,t,n){e.style[t]=n},kn["@: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},kn["opacity:get"]=function(e){var t=kn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(kt,function(e){kn[e+":get"]=function(t){var n=kn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Mn={position:"absolute",visibility:"hidden",display:"block"},On=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(kt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;kn[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)},kn[t+"&get"]=function(e){var n=[];R(e,n);for(var a,r=kn[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 kn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return kn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return kn[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 Nn={"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,Ln=["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(","),jn=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Hn=/[^\w$]+/g,Dn=new RegExp(["\\b"+Ln.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Pn=/\b\d[^,]*/g,_n=/^,+|,+$/g,Rn=new zt(512),In=function(e){var t=","+e.trim(),n=Rn.get(t);if(n)return n;var a=e.replace(jn,"").replace(Hn,",").replace(Dn,"").replace(Pn,"").replace(_n,"").split(/^$|,+/);return Rn.put(t,F(a))},Bn=new zt(128),Fn=/\w\[.*\]|\w\.\w/,Vn=/(\$proxy\$[a-z]+)\d+$/,Un=/\)\s*$/,qn=/\)\s*\|/g,zn=/\|\s*([$\w]+)/g,Wn=/"\s*\["/g,Xn=/"\s*\(/g;avalon.parseExprProxy=q,avalon.scan=function(e,t){e=e||Pt;var n=t?[].concat(t):[];K(e,n)};var Yn=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]},Zn=Ft&&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,Jn=/ms-(\w+)-?(.*)/,Qn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Kn=o("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),ea=o("value,title,alt,checked,selected,disabled,readonly,enabled"),ta=/^if|widget|repeat$/,na=/^each|with|html|include$/,aa=/\|\s*html\s*/,ra=/\|\|/g,ia=/(['"])(\\\1|.)+?\1/g,oa=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),la={};oa.replace(kt,function(e){la[e.toLowerCase()]=e});var sa={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},ca=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");ca.replace(kt,function(e){sa[e.toLowerCase()]=e});var ua=/(?:[\s\S]+?)<\/noscript>/gim,fa=/([\s\S]+?)<\/noscript>/im,da=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},va=avalon.templateCache={};Ut.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Gt)>-1&&n.indexOf(Zt)>2&&(a=!1,Jt.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=gt.createComment("ms-include"),e.endInclude=gt.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",q(n,t,e,a?0:tt(e.value))},qt.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){var o=t===!1||null===t||void 0===t;!Dt&&sa[i]&&(i=sa[i]);var l=la[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=At.test(n)?!1:gt.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,d=a.includeReplace,v=d?n.parentNode:n,p=function(e){if(f){var n=f.apply(v,[e].concat(c));"string"==typeof n&&(e=n)}u&&z(v,function(){u.call(v)},0/0);var r=a.includeLastID;if(a.templateCache&&r&&r!==t){var i=a.templateCache[r];i||(i=a.templateCache[r]=gt.createElement("div"),xt.appendChild(i))}for(a.includeLastID=t;;){var o=a.startInclude.nextSibling;if(!o||o===a.endInclude)break;v.removeChild(o),i&&i.appendChild(o)}var l=at(a,t,e),s=avalon.slice(l.childNodes);v.insertBefore(l,a.endInclude),J(s,c)};if("src"===a.param)if("string"==typeof va[t])avalon.nextTick(function(){p(va[t])});else if(Array.isArray(va[t]))va[t].push(p);else{var h=da();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,a=h.responseText,r=0;n=va[t][r++];)n(a);va[t]=a}}},va[t]=[p],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:gt.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=da(),h.open("GET",location,!1),h.send(null);for(var g=gt.getElementsByTagName("noscript"),y=(h.responseText||"").match(ua)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(fa)||[""," "])[1])}}avalon.nextTick(function(){p(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Pt.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&/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(kt,function(e){Ut[e]=Ut.attr}),Ut["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),U(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=Jt.test(s);c||(e.immobileClass=s),q("",t,e,c?tt(s):0)}else e.immobileClass=e.oldStyle=e.param,q(i,t,e)},qt["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(kt,function(e){Ut[e]=Ut["class"]}),qt.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var pa=Ut.duplex=function(e,t){var a,r=e.element;if(q(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=it);f(null,e,"init");var d=r.tagName;pa[d]&&pa[d](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:rt},"boolean":{get:function(e){return"true"===e},set:rt},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:rt}};var ha,ma=[];avalon.tick=function(e){1===ma.push(e)&&(ha=setInterval(ot,60))};var ga=i,ya=/text|password|hidden/;!new function(){function e(e){if(avalon.contains(Pt,this)){if(t[this.tagName].call(this,e),!ya.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){ga=avalon.tick}},pa.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("duplexObserve")!==!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("duplexObserve")!==!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("duplexObserve")!==!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 d=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),d.replace(kt,function(e){switch(e){case"input":s("input",f),s("DOMAutoComplete",f),Ft||(s("compositionstart",i),s("compositionend",o));break;default:s(e,f)}}),s("focus",function(){e.msFocus=!0}),s("blur",function(){e.msFocus=!1}),ya.test(l)&&ga(function(){if(Pt.contains(e))e.msFocus||e.oldValue===e.value||f();else if(!e.msRetain)return!1}),e.avalonSetter=f}e.oldValue=e.value,avalon.injectBinding(a),r.call(e,e.value)},pa.TEXTAREA=pa.INPUT,pa.SELECT=function(e,t,a){function r(){if(i.data("duplexObserve")!==!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在不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),e.msCallback=function(){avalon.injectBinding(a),a.changed.call(e,t(),a)}},qt.html=function(e,t,n){var a=1!==t.nodeType,r=a?t.parentNode:t;if(r){if(e=null==e?"":e,3===t.nodeType){var i=Bt("html");r.insertBefore(gt.createComment(i),t),n.element=gt.createComment(i+":end"),r.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=_t.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),a){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;r.removeChild(c)}r.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);J(l,n.vmodels)}},Ut["if"]=Ut.data=Ut.text=Ut.html=function(e,t){q(e.value,t,e)},qt["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(a){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),G(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=gt.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,xt.appendChild(t),n.rollback=function(){t.parentNode===xt&&xt.removeChild(t)}}};var ba=/\(([^)]*)\)/;Ut.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof Ut.on[a+"Hook"]&&Ut.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(ba)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(ba,""))}q(n,t,e)},qt.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)}},Ut.repeat=function(e,t){var n=e.type;q(e.value,t,e,0,1);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[$t]=f[$t]||[],f[$t].push(e);break}}var d=e.element;if(1===d.nodeType){d.removeAttribute(e.name),e.sortedCallback=Gn(d,"data-with-sorted",t),e.renderedCallback=Gn(d,"data-"+n+"-rendered",t);var v=Bt(n),p=gt.createComment(v),h=gt.createComment(v+":end");if(e.signature=v,e.template=_t.cloneNode(!1),"repeat"===n){var m=d.parentNode;m.replaceChild(h,d),m.insertBefore(p,h),e.template.appendChild(d)}else{for(;d.firstChild;)e.template.appendChild(d.firstChild);d.appendChild(p),d.appendChild(h)}e.element=h,e.handler=qt.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!a){e.$outer={};var g="$key",y="$val";if(Array.isArray(r)){if(!r.$map){r.$map={el:1};var b=r.length,x=[];for(u=0;b>u;u++)x.push(T(u,r));r.$proxy=x}r.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var $=r.$events,w=($||{})[$t];A(w,e),"object"===i?(e.$with=!0,r.$proxy||(r.$proxy={}),e.handler("append",r)):r.length&&e.handler("add",0,r.length)}},qt.repeat=function(e,t,n){if(e){var a,r,o=this,l=o.element,s=st(o),c=l.parentNode,u=_t.cloneNode(!1);switch(e){case"add":for(var f=t+n,d=[],v=o.$repeat,p=t;f>p;p++){var h=v.$proxy[p];h.$outer=o.$outer,lt(o,u,h,d)}for(c.insertBefore(u,s[t]||l),p=0;r=d[p++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null;break;case"del":ct(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&ct(a,l);break;case"move":if(a=s[0]){var m,g=a.nodeValue,y=[],b=[];for(ct(a,l,function(){b.unshift(this),this.nodeValue===g&&(y.unshift(b),b=[])}),E(y,t);b=y.shift();)for(;m=b.shift();)u.appendChild(m);c.insertBefore(u,l)}break;case"append":var x=t,$=x.$proxy,w=[];d=[];for(var C in $)x.hasOwnProperty(C)||(vt($[C],xa),delete $[C]);for(C in x)x.hasOwnProperty(C)&&"hasOwnProperty"!==C&&"$proxy"!==C&&w.push(C);if(o.sortedCallback){var k=o.sortedCallback.call(c,w);k&&Array.isArray(k)&&k.length&&(w=k)}for(p=0;C=w[p++];)"hasOwnProperty"!==C&&($[C]=ft($[C],C,o),lt(o,u,$[C],d));for(c.insertBefore(u,l),p=0;r=d[p++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null}"clear"===e&&(e="del");var T=o.renderedCallback||i,A=arguments;z(c,function(){T.apply(c,A),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(kt,function(e){Ut[e]=Ut.repeat}),avalon.pool=fn;var xa=[];qt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=pt,Ut.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=pt(n[0].nodeName)),r.visibility=i?o:""}e.display=a,q(e.value,t,e)},qt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Ut.widget=function(t,a){var r=t.value.match(kt),o=t.element,l=r[0],s=r[1];s&&"$"!==s||(s=Bt(l));var c=r[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,d=0;f=a[d++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var v=f[c];v=v.$model||v;break}if(v){var p=v[l+"Id"];"string"==typeof p&&(n("warning!不再支持"+l+"Id"),s=p)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=i,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,v||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,W(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},N(t,$a),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(S)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var $a=[],wa=/]*>([\S\s]*?)<\/script\s*>/gim,Ca=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Ea=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,ka={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},Ta=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Aa=/([^\#-~| |!])/g,Ma=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof 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:D,sanitize:function(e){return e.replace(wa,"").replace(Ea,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=ka[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(Ca," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(Ta,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Aa,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+ht(e,isFinite(n)?n:2)},number:ht};!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.length0||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+)\)\/$/;Ma.date=function(t,n){var a,r,i=Ma.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(),d=[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 d[0]=e(i[0]),d[1]=e(i[1])-1,d[2]=e(i[2]),""});var p=v.setFullYear,h=v.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,a,r,i){return d[3]=e(n),d[4]=e(a),d[5]=e(r),i&&(d[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 p=v.setUTCFullYear,h=v.setUTCHours,n&&(m=e(n+a),g=e(n+r)),""}),d[3]-=m,d[4]-=g,p.apply(v,d.slice(0,3)),h.apply(v,d.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,Ma.date.locate=c};var Oa=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Oa.exports=Oa.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=Oa[t],r=t&&e.urlNoQuery;if(a&&a.state>=1)return t;if(a=Oa[r],a&&a.state>=3)return bt(a.deps||[],a.factory,r),r;if(t&&!a){a=Oa[r]={id:r,state:1};var i=function(r){H[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,c()})};H[n]?i(H[n]):bt([n],i)}return t?r:n+"!"}function l(e,t){for(var n,a=0;n=e[a++];)if(4!==Oa[n].state&&(n===t||l(Oa[n].deps,t)))return!0}function s(e,t){var a=d(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){yt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Oa[a].state)):!0}function c(){e:for(var e,t=k.length;e=k[--t];){var n=Oa[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++)if(4!==Object(Oa[r]).state)continue e;4!==n.state&&(k.splice(t,1),h(n.id,n.deps,n.factory),c())}}}function f(e,t,a){var r=gt.createElement("script");r.className=$t,r.onload=function(){var r=T.pop();r&&r.require(t),a&&a(),n("debug: 已成功加载 "+e),t&&k.push(t),c()},r.onerror=function(){s(r,!0)},yt.insertBefore(r,yt.firstChild),r.src=e,n("debug: 正准备加载 "+e)}function d(e){return(e||"").replace(D,"")}function v(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(){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/,""),d(e.replace(/(:\d+)?:\d+$/i,""));for(var n,r=yt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===$t&&"interactive"===n.readyState){var o=n.src;return n.className=d(o)}}function h(t,a,i){var o=Object(Oa[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(Oa[l].exports);try{var f=i.apply(e,c)}catch(d){n("执行["+t+"]模块的factory抛错: "+d)}return void 0!==f&&(o.exports=f),P.test(t)&&delete Oa[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;$(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)),v(t)||(r=this.built||/^\w/.test(t)?a:r,t=C(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 g(e,t,n){var a=x(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&&E(t.exports)}}function x(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 $(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;_.test(e);)e=e.replace(_,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function E(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var k=[],T=[],A=/\.js$/i,M=[],O=!1;bt=avalon.require=function(e,n,a,l){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var s=[],f=r(),d=a||"callback"+setTimeout("1");l=l||r(),l.baseUrl=u.baseUrl;var v=!!l.built;if(a&&(l.parentUrl=a.substr(0,a.lastIndexOf("/")),l.mapUrl=a.replace(A,"")),v){var p=t(l.defineName,l);d=p.urlNoQuery}else e.forEach(function(e){var n=t(e,l),a=o(n);a&&(f[a]||(s.push(a),f[a]="司徒正美"))});var h=Oa[d];h&&4===h.state||(Oa[d]={id:d,deps:v?e.concat():s,factory:n||i,state:3}),h||k.push(d),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();)bt.apply(null,m)}},bt.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),Oa[e]){Oa[e].state=3;var t=!1;try{t=l(Oa[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,bt.apply(null,r)};var i=a.built?"unknown":p();if(i){var o=Oa[i];o&&(o.state=2),n.require(i)}else T.push(n)},bt.config=u,bt.define.amd=Oa;var N=u["orig.paths"]=r(),S=u["orig.map"]=r(),L=u.packages=[],j=u["orig.args"]=r();avalon.mix(tn,{paths:function(e){avalon.mix(N,e),u.paths=g(N)},map:function(e){avalon.mix(S,e);var t=g(S,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),u.map=t},packages:function(e){e=e.concat(L);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=C(t.location||o,t.main||"main");l=l.replace(A,""),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(j,e),u.urlArgs=g(j,1)},baseUrl:function(e){if(!v(e)){var t=yt.getElementsByTagName("base")[0];t&&yt.removeChild(t);var n=gt.createElement("a");n.href=e,e=n.href,t&&yt.insertBefore(t,yt.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 H=bt.plugins={ready:{load:i},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(A,"")];i?bt(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;yt.insertAdjacentHTML("afterBegin",''),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=da();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+r),a(i.responseText))};var o="_="+(new Date-0),l=-1===r.indexOf("?")?r+"?"+o:r+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};bt.checkDeps=c;var D=/(\?[^#]*)$/,P=/^callback\d+$/,_=/\/\w+\/\.\./,R=gt.scripts[gt.scripts.length-1],I=R.getAttribute("data-main");if(I){tn.baseUrl(I);var B=u.baseUrl;u.baseUrl=B.slice(0,B.lastIndexOf("/")+1),f(B.replace(A,"")+".js")}else{var F=d(R.src);u.baseUrl=F.slice(0,F.lastIndexOf("/")+1)}};var Na,Sa=[],La=function(e){for(Na=!0,bt&&(Oa["domReady!"].state=4,bt.checkDeps());e=Sa.shift();)e(avalon)};"complete"===gt.readyState?setTimeout(La):gt.addEventListener("DOMContentLoaded",La),e.addEventListener("load",La),avalon.ready=function(e){Na?e(avalon):Sa.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(gt.body)}),new function(){function t(e){return("touch"===e.pointerType||e.pointerType===e.MSPOINTER_TYPE_TOUCH)&&e.isPrimary}function n(e,t){return e.type==="pointer"+t||e.type.toLowerCase()==="mspointer"+t}function a(e,t,n,a){return Math.abs(e-t)>=Math.abs(n-a)?e-t>0?"left":"right":n-a>0?"up":"down"}function r(e){var t=e.touches&&e.touches.length?e.touches:[e],n=e.changedTouches?e.changedTouches[0]:t[0];return{x:n.clientX,y:n.clientY}}function i(e,t,n){var a=document.createEvent("Events");a.initEvent(t,!0,!0),a.fireByAvalon=!0,n&&(a.detail=n),e.dispatchEvent(a)}function o(e){return e.fireByAvalon?!0:void(h.element&&"select"!==e.target.tagName.toLowerCase()&&(e.stopImmediatePropagation?e.stopImmediatePropagation():e.propagationStopped=!0,e.stopPropagation(),e.preventDefault(),"click"===e.type&&(h.element=null)))}function l(){$&&clearTimeout($),$=null}function s(e){var a=n(e,"down"),o=a?e:e.touches&&e.touches[0]||e,l="tagName"in o.target?o.target:o.target.parentNode,s=Date.now(),c=s-(h.last||s);if(!a||t(e))return avalon.mix(h,r(e)),h.mx=0,h.my=0,c>0&&250>=c&&(h.isDoubleTap=!0),h.last=s,h.element=l,avalon(l).addClass(w.activeClass),$=setTimeout(function(){$=null,i(l,"hold"),i(l,"longtap"),h={},avalon(l).removeClass(w.activeClass)},w.clickDuration),!0}function c(e){var a=n(e,"down"),i=r(e);d&&Math.abs(h.x-i.x)>10&&e.preventDefault(),(!a||t(e))&&(l(),h.mx+=Math.abs(h.x-i.x),h.my+=Math.abs(h.y-i.y))}function u(e){var o=n(e,"down");if(element=h.element,(!o||t(e))&&element){l();var s=r(e),c=Math.abs(h.x-s.x),u=Math.abs(h.y-s.y);if(c>30||u>30){var f=a(h.x,s.x,h.y,s.y),d={direction:f};i(element,"swipe",d),i(element,"swipe"+f,d),avalon(element).removeClass(w.activeClass),h={},h.element=element}else if(w.canClick(element)&&h.mx0,v=/iP(ad|hone|od)/.test(f),p=Ut.on,h={},m=navigator.pointerEnabled,g=navigator.msPointerEnabled,y=function(){var e=v||!1; -try{var t=document.createElement("div");t.ontouchstart=function(){e=!0};var n=document.createEvent("TouchEvent");n.initUIEvent("touchstart",!0,!0),t.dispatchEvent(n)}catch(a){}return t=t.ontouchstart=null,e}(),b=["mousedown","mousemove","mouseup",""];y?b=["touchstart","touchmove","touchend","touchcancel"]:m?b=["pointerdown","pointermove","pointerup","pointercancel"]:g&&(b=["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"]);var x,$;document.addEventListener("mousedown",o,!0),document.addEventListener("click",o,!0),document.addEventListener(b[0],s),document.addEventListener(b[1],c),document.addEventListener(b[2],u),b[3]&&document.addEventListener(b[3],function(){$&&clearTimeout($),x&&clearTimeout(x),$=x=null,h={}});var w=avalon.fastclick={activeClass:"ms-click-active",clickDuration:750,dragDistance:30,fireEvent:function(t,n,a){var r=document.createEvent("MouseEvents");r.initMouseEvent(n,!0,!0,e,1,a.screenX,a.screenY,a.clientX,a.clientY,!1,!1,!1,!1,0,null),Object.defineProperty(r,"fireByAvalon",{value:!0}),t.dispatchEvent(r)},focus:function(e){if(this.canFocus(e)){var t=e.value;if(e.value=t,v&&e.setSelectionRange&&0!==e.type.indexOf("date")&&"time"!==e.type){var n=t.length;e.setSelectionRange(n,n)}else e.focus()}},canClick:function(e){switch(e.nodeName.toLowerCase()){case"textarea":case"select":case"input":return!e.disabled;default:return!0}},canFocus:function(e){switch(e.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!d;case"input":switch(e.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!e.disabled&&!e.readOnly;default:return!1}}};["swipe","swipeleft","swiperight","swipeup","swipedown","doubletap","tap","dblclick","longtap","hold"].forEach(function(e){p[e+"Hook"]=p.clickHook})},"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var ja=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=ja),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file +!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(Tt)||[]);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=St.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=gt.createElementNS(Wt,n.tagName.toLowerCase());Lt.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(Nt.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(en,"\\$&")}function v(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=$(e);return i.pushArray(a),i}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var o=Array.isArray(e.$skipArray)?e.$skipArray:[];o.$special=t||r();var l={};n=n||{};var s=r(),c=r(),u=[];on.forEach(function(t){delete e[t]});for(var f in e)!function(e,t,a){if(n[e]=t,x(e,t,o)){s[e]=[];var r=avalon.type(t);"object"===r&&Vt(t.get)&&Object.keys(t).length<=2?(a=p(e,t),u.push(a)):a=kt.test(r)?h(e,t,r,s[e]):d(e,t),c[e]=a}}(f,e[f]);l=Object.defineProperties(l,sn(c));for(var v in e)c[v]||(l[v]=e[v]);l.$id=Bt(),l.$model=n,l.$events=s;for(f in an)l[f]=an[f];return Object.defineProperty(l,"hasOwnProperty",{value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0}),l.$compute=function(){u.forEach(function(e){vn.begin({callback:function(t,n){var a=n._name;if(n!==e){var r=t.$events[a];e.vm=l,A(r,e.digest)}}});try{e.get.call(l)}finally{vn.end()}})},l.$compute(),l}function d(e,t){function n(e){var t=n._value;return arguments.length>0?(Et||ln(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(vn.collectDependency(this,n),t)}return b(n,e),n._value=t,n}function p(e,t){function n(e){var t=n._value,a="_value"in n;return arguments.length>0?Et?this:(n.set.call(this,e),this):(e=n.get.call(this),t!==e&&(n.updateValue(this,e),a&&n.notify(this,e,t)),e)}t.set=t.set||i,n.set=t.set||i,n.get=t.get,b(n,e);var a;return n.digest=function(){n.updateValue=g,n.notify=i,n.call(n.vm),clearTimeout(a),a=setTimeout(function(){b(n,n._name),n.call(n.vm)})},n}function h(e,t,n,a){function r(t){var a=r._value,i=r._vmodel;if(arguments.length>0){if(Et)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=r._vmodel=v(t),i.$proxy=l,s.length&&(s.forEach(function(e){var t=Ut[e.type];t&&(e.rollback&&e.rollback(),t(e,e.vmodels))}),i.$events[e]=s)}return r.updateValue(this,i.$model),r.notify(this,this._value,a),this}return vn.collectDependency(this,r),i}b(r,e);var i=r._vmodel=v(t);return i.$events[$t]=a,r}function m(e,t){e.$model[this._name]=this._value=t}function g(e,t){e.$model[this._name]=t}function y(e,t,n){var a=this._name,r=e.$events[a];r&&(M(r),an.$fire.call(e,a,t,n))}function b(e,t){e._name=t,e.updateValue=m,e.notify=y}function x(e,t,n){if(Vt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function $(e){var t=[];t.$id=Bt(),t.$model=e,t.$events={},t.$events[$t]=[],t._=v({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in an)t[n]=an[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,un),t}function w(e,t,n,a,r,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return kt.test(avalon.type(e))?e.$id?e:v(e,0,e):e});cn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var d=k(f,this);this.$proxy.splice(f,0,d)}this._fire("add",t,n);break;case"del":var p=this._splice(t,n),h=this.$proxy.splice(t,n);vt(h,"each"),this._fire("del",t,n)}r&&(e=r,t=i,n=o,s=2,r=0)}return C(this.$proxy,a),this.length!==l&&(this._.length=this.length),p}function C(e,t){for(var n,a=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===a}function E(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 T(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=v(e,t);return n.$id=Bt("$proxy$each"),n}function k(e,t){var n=fn.shift();n?n.$compute():n=T();var a=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===a,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function A(e,t){t=t||Dt[mt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&N(t,e)}function M(e){if(e&&e.length){new Date-mn>444&&"object"==typeof e[0]&&S();for(var t,n=jt.call(arguments,1),a=e.length;t=e[--a];){var r=t.element;if(r&&r.parentNode)try{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)}}catch(l){}}}}function O(e){return e.uniqueNumber||(e.uniqueNumber=++pn)}function N(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+O(n.parentNode):e.name+"-"+O(n));var a=e.lists||(e.lists=[]);avalon.Array.ensure(a,t),t.$uuid=t.$uuid||Bt(),hn[e.uuid]||(hn[e.uuid]=1,hn.push(e))}function S(e){if(!avalon.optimize){for(var t=hn.length,n=t,a=[],r={},i={};e=hn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,a.push(o))}var l=!1;if(a.forEach(function(e){gn[e]!==i[e]&&(r[e]=1,l=!0)}),t=n,l)for(;e=hn[--t];)if(e.element&&r[e.type]&&j(e.element)){hn.splice(t,1),delete hn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);L(e)}gn=i,mn=new Date}}function L(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function j(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!Pt.contains(e):!avalon.contains(Pt,e)}function D(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function H(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function P(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 _(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function R(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(On.test(n.display)){var a={node:e};for(var r in Mn)a[r]=n[r],e.style[r]=Mn[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&R(i,t)}}function I(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function B(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;r=e[--s];){var c=l&&t.$map[r]?"el":r;t.hasOwnProperty(c)&&(i.push(r+o+c),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function F(e){for(var t=[],n={},a=0;ad;d++)if(s.length){var h="vm"+mt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,B(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=Ft?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,delete a.vars;var m=Bn.get(l);if(m)return void(a.evaluator=m);if(v=c.join(", "),v&&(v="var "+v),/\S/.test(o)){if(!/text|html/.test(a.type))throw Error("ms-"+a.type+"不支持过滤器");e="\nvar ret"+mt+" = "+e+";\r\n",e+=V("ret"+mt,o)}else{if("duplex"===r){var g="'use strict';\nreturn function(vvv){\n "+v+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Fn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(i,u.concat(g)),a.evaluator=Bn.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"),x=e.slice(0,b),$=e.slice(b);e=x+"\n"+$}else e="\nreturn "+e+";"}try{m=Function.apply(i,u.concat("'use strict';\n"+v+e)),a.evaluator=Bn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function z(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":Sn(e.value)}).join(" + ")),U(e,t,n),n.evaluator&&!r&&(n.handler=zt[n.handlerName||n.type],avalon.injectBinding(n))}function q(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():q(e,t,r)})}function W(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function X(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,Ut[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function Y(e,t){return e.priority-t.priority}function G(e,t,a){var i=!0;if(t.length){for(var o,l=e.attributes,s=[],c=[],u=r(),f=0;o=l[f++];)if(o.specified&&(a=o.name.match(Jn))){var v=a[1],d=a[2]||"",p=o.value,h=o.name;if(Kn[v]?(d=v,v="on"):ea[v]&&("enabled"===v&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),v="disabled",p="!("+p+")"),d=v,v="attr",h="ms-"+v+"-"+d,c.push([o.name,h,p])),u[h]=p,"function"==typeof Ut[v]){var m={type:v,param:d,element:e,name:h,value:p,priority:(Qn[v]||10*v.charCodeAt(0))+(Number(d.replace(/\D/g,""))||0)};if("html"===v||"text"===v){var g=et(p);avalon.mix(m,g),m.filters=m.filters.replace(aa,function(){return m.type="html",m.group=1,""})}else if("duplex"===v)var y=h;else"ms-if-loop"===h&&(m.priority+=100);s.push(m),"widget"===v&&(e.msData=e.msData||u)}}if(s.length){s.sort(Y),c.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])});var b=e.type;for(b&&y&&(u["ms-attr-checked"]&&n("warning!"+b+"控件不能同时定义ms-attr-checked与"+y),u["ms-attr-value"]&&n("warning!"+b+"控件不能同时定义ms-attr-value与"+y)),f=0;m=s[f];f++){if(v=m.type,ta.test(v))return X(s.slice(0,f+1),t);i&&(i=!na.test(v))}X(s,t)}}i&&!Yn[e.tagName]&&Kt.test(e.innerHTML+e.textContent)&&(Zn&&Zn(e),Z(e,t))}function Z(e,t){var n=avalon.slice(e.childNodes);J(n,t)}function J(e,t){for(var n,a=0;n=e[a++];)Q(n,n.nodeType,t)}function Q(e,t,n){1===t?(K(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&Jt.test(e.data)?nt(e,n):u.commentInterpolate&&8===t&&!Jt.test(e.nodeValue)&&nt(e,n)}function K(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),W(e,o)}G(e,t)}}function et(e,t){if(e.indexOf("|")>0){var n=e.replace(ia,function(e){return Array(e.length+1).join("1")}),a=n.replace(ra,"ᄢ㍄").indexOf("|");if(a>-1)return{filters:e.slice(a),value:e.slice(0,a),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function tt(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Gt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Gt.length,n=e.indexOf(Zt,r),-1===n)break;t=e.slice(r,n),t&&a.push(et(t,r)),r=n+Zt.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function nt(e,t){var n=[];if(8===e.nodeType)var a=et(e.nodeValue),r=[a];else r=tt(e.data);if(r.length){for(var i=0;a=r[i++];){var o=gt.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(aa,function(){return a.type="html",""}),n.push(a)),_t.appendChild(o)}e.parentNode.replaceChild(_t,e),n.length&&X(n,t)}}function at(e,t,n){var a=e.templateCache&&e.templateCache[t];if(a){for(var r,i=gt.createDocumentFragment();r=a.firstChild;)i.appendChild(r);return i}return avalon.parseHTML(n)}function rt(e){return null==e?"":e}function it(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 ot(){for(var e=ma.length-1;e>=0;e--){var t=ma[e];t()===!1&&ma.splice(e,1)}ma.length||clearInterval(ha)}function lt(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);e.$with||r.insertBefore(gt.createComment(e.signature),r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function st(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),a=t.previousSibling,r=[];a;)a.nodeValue===n&&r.unshift(a),a=a.previousSibling;return r}function ct(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function ut(){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=Bt("$proxy$with"),e}function ft(e,t,n){e=e||xa.pop(),e||(e=ut());var a=n.$repeat;return e.$key=t,e.$host=a,e.$outer=n.$outer,a.$events?e.$events.$val=a.$events[t]:e.$events={},e}function vt(e){e.forEach(function(e){dt(e,fn)}),e.length=0}function dt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&L(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>u.maxRepeatSize&&t.pop()}function pt(e,t){var n="_"+e;if(!pt[n]){var a=gt.createElement(e);Pt.appendChild(a),t=Ht?getComputedStyle(a,null).display:a.currentStyle.display,Pt.removeChild(a),pt[n]=t}return pt[n]}function ht(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');var bt,xt=yt.firstChild,$t="$"+mt,wt=e.require,Ct=e.define,Et=!1,Tt=/[^, ]+/g,kt=/^(?:object|array)$/,At=/^\[object SVG\w*Element\]$/,Mt=/^\[object (?:Window|DOMWindow|global)\]$/,Ot=Object.prototype,Nt=Ot.hasOwnProperty,St=Ot.toString,Lt=Array.prototype,jt=Lt.slice,Dt={},Ht=e.dispatchEvent,Pt=gt.documentElement,_t=gt.createDocumentFragment(),Rt=gt.createElement("div"),It={};"Boolean Number String Function Array Date RegExp Object Error".replace(Tt,function(e){It["[object "+e+"]"]=e.toLowerCase()});var Bt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Ft=l();avalon=function(e){return new avalon.init(e)},avalon.profile=function(){e.console&&avalon.config.profile&&Function.apply.call(console.log,console,arguments)},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=Ht&&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?It[St.call(e)]||"object":typeof e};var Vt=function(e){return"[object Function]"===St.call(e)};avalon.isFunction=Vt,avalon.isWindow=function(e){return Mt.test(St.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===St.call(e)&&Object.getPrototypeOf(e)===Ot},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||Vt(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:Tt,subscribers:$t,version:1.44,ui:{},log:n,slice:function(e,t,n){return jt.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);++an&&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 Ut=avalon.bindingHandlers={},zt=avalon.bindingExecutors={},qt=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}var t=e.prototype;return t.put=function(e,t){var n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){var e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0)},t.get=function(e){var t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(gt.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 Wt="http://www.w3.org/2000/svg",Xt=gt.createElementNS(Wt,"svg");Xt.innerHTML='',At.test(Xt.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=gt.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("$","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 Yt=avalon.eventHooks;"onmouseenter"in Pt||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Yt[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]&&!Yt.animationend&&(Yt.animationend={type:n})}),void 0===gt.onmousewheel&&(Yt.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 Gt,Zt,Jt,Qt,Kt,en=/[-.*+?^${}()|[\]\/\\]/g,tn={loader:function(t){var n=bt&&t;e.require=n?bt:wt,e.define=n?bt.define:Ct},interpolate:function(e){if(Gt=e[0],Zt=e[1],Gt===Zt)throw new SyntaxError("openTag!==closeTag");if(e+""=="")u.commentInterpolate=!0;else{var t=Gt+"test"+Zt;if(Rt.innerHTML=t,Rt.innerHTML!==t&&Rt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Rt.innerHTML=""}var n=f(Gt),a=f(Zt);Jt=new RegExp(n+"(.*?)"+a),Qt=new RegExp(n+"(.*?)"+a,"g"),Kt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=tn,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var nn=function(e){return gt.querySelectorAll(e)},an={$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=jt.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?nn(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=nn(a.$events.expr);if(0===c.length)continue;Lt.forEach.call(c,function(e){Lt.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=gt.getElementsByTagName("*"),f=[];for(Lt.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 v=i[e]||[],d=i.$all||[];for(n=0;r=v[n++];)Vt(r)&&r.apply(this,o);for(n=0;r=d[n++];)Vt(r)&&r.apply(this,arguments)}}}},rn=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),rn[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var r=v(e);else{var o={$watch:i};t(o),r=v(o),Et=!0,t(r),Et=!1}return r.$id=a,rn[a]=r};var on=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(Tt),ln=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},sn=function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t},cn=Lt.splice,un={_splice:cn,_fire:function(e,t,n){M(this.$events[$t],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(Lt.push.apply(this.$model,e),w.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&&(Lt.unshift.apply(this.$model,arguments),w.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return w.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return w.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=cn.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?w.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),w.call(this,"del",e,1,0)):[]},clear:function(){return vt(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],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 if("array"===n)a.clear().push.apply(a,t);else if(a!==t){this[e]=t,this.$model[e]=t;var i=this.$proxy[e];i&&M(i.$events.$index)}}return this}};"sort,reverse".replace(Tt,function(e){un[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];Lt[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(ln(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(E(this,i),E(this.$proxy,i),this._fire("move",i),C(this.$proxy,0)),this}});var fn=[],vn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),dn=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){vn.begin({callback:function(t,n){A(t.$events[n._name],e)}});try{var n=dn.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(gt.createComment(e.value),r):r.data=Gt+e.value+Zt}}finally{vn.end()}}};var pn=0,hn=avalon.$$subscribers=[],mn=new Date,gn={},yn=new function(){avalon.mix(this,{option:gt.createElement("select"),thead:gt.createElement("table"),td:gt.createElement("tr"),area:gt.createElement("map"),tr:gt.createElement("tbody"),col:gt.createElement("colgroup"),legend:gt.createElement("fieldset"),_default:gt.createElement("div"),g:gt.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(Tt,function(e){yn[e]=yn.g});var bn=/<([\w:]+)/,xn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,$n=o(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),wn=gt.createElement("script"),Cn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=_t.cloneNode(!1);if("string"!=typeof e)return t;if(!Cn.test(e))return t.appendChild(gt.createTextNode(e)),t;e=e.replace(xn,"<$1>").trim();var n,a=(bn.exec(e)||["",""])[1].toLowerCase(),r=yn[a]||yn._default;r.innerHTML=e;var i=r.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if($n[o.type]){var s=wn.cloneNode(!1);Lt.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},"add,remove".replace(Tt,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=String(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-"+D(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return P(n);case 0:var a={};return Lt.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=H(e.slice(5)),a[e]=P(t.value)))}),a}},removeData:function(e){return e="data-"+D(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),a.top-=e.scrollTop(),a.left-=e.scrollLeft()),{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||Pt)},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=Nn[I(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}}),Pt.dataset&&(avalon.fn.data=function(e,t){e=e&&H(e);var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],P(t);case 0:var a=r();for(e in n)a[e]=P(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=_(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 Tn=avalon.cssHooks=r(),kn=["","-webkit-","-moz-","-ms-"],An={"float":"cssFloat"};avalon.cssNumber=o("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(An[e])return An[e];t=t||Pt.style;for(var a=0,r=kn.length;r>a;a++)if(n=H(kn[a]+e),n in t)return An[e]=n;return null},Tn["@:set"]=function(e,t,n){e.style[t]=n},Tn["@: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},Tn["opacity:get"]=function(e){var t=Tn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(Tt,function(e){Tn[e+":get"]=function(t){var n=Tn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var Mn={position:"absolute",visibility:"hidden",display:"block"},On=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(Tt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;Tn[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) +},Tn[t+"&get"]=function(e){var n=[];R(e,n);for(var a,r=Tn[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 Tn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return Tn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return Tn[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 Nn={"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,Ln=["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(","),jn=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Dn=/[^\w$]+/g,Hn=new RegExp(["\\b"+Ln.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Pn=/\b\d[^,]*/g,_n=/^,+|,+$/g,Rn=new qt(512),In=function(e){var t=","+e.trim(),n=Rn.get(t);if(n)return n;var a=e.replace(jn,"").replace(Dn,",").replace(Hn,"").replace(Pn,"").replace(_n,"").split(/^$|,+/);return Rn.put(t,F(a))},Bn=new qt(128),Fn=/\w\[.*\]|\w\.\w/,Vn=/(\$proxy\$[a-z]+)\d+$/,Un=/\)\s*$/,zn=/\)\s*\|/g,qn=/\|\s*([$\w]+)/g,Wn=/"\s*\["/g,Xn=/"\s*\(/g;avalon.parseExprProxy=z,avalon.scan=function(e,t){e=e||Pt;var n=t?[].concat(t):[];K(e,n)};var Yn=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]},Zn=Ft&&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,Jn=/ms-(\w+)-?(.*)/,Qn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Kn=o("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),ea=o("value,title,alt,checked,selected,disabled,readonly,enabled"),ta=/^if|widget|repeat$/,na=/^each|with|html|include$/,aa=/\|\s*html\s*/,ra=/\|\|/g,ia=/(['"])(\\\1|.)+?\1/g,oa=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),la={};oa.replace(Tt,function(e){la[e.toLowerCase()]=e});var sa={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},ca=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");ca.replace(Tt,function(e){sa[e.toLowerCase()]=e});var ua=/(?:[\s\S]+?)<\/noscript>/gim,fa=/([\s\S]+?)<\/noscript>/im,va=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},da=avalon.templateCache={};Ut.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Gt)>-1&&n.indexOf(Zt)>2&&(a=!1,Jt.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=gt.createComment("ms-include"),e.endInclude=gt.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",z(n,t,e,a?0:tt(e.value))},zt.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){var o=t===!1||null===t||void 0===t;!Ht&&sa[i]&&(i=sa[i]);var l=la[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=At.test(n)?!1:gt.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,v=a.includeReplace,d=v?n.parentNode:n,p=function(e){if(f){var n=f.apply(d,[e].concat(c));"string"==typeof n&&(e=n)}u&&q(d,function(){u.call(d)},0/0);var r=a.includeLastID;if(a.templateCache&&r&&r!==t){var i=a.templateCache[r];i||(i=a.templateCache[r]=gt.createElement("div"),xt.appendChild(i))}for(a.includeLastID=t;;){var o=a.startInclude.nextSibling;if(!o||o===a.endInclude)break;d.removeChild(o),i&&i.appendChild(o)}var l=at(a,t,e),s=avalon.slice(l.childNodes);d.insertBefore(l,a.endInclude),J(s,c)};if("src"===a.param)if("string"==typeof da[t])avalon.nextTick(function(){p(da[t])});else if(Array.isArray(da[t]))da[t].push(p);else{var h=va();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,a=h.responseText,r=0;n=da[t][r++];)n(a);da[t]=a}}},da[t]=[p],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:gt.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=va(),h.open("GET",location,!1),h.send(null);for(var g=gt.getElementsByTagName("noscript"),y=(h.responseText||"").match(ua)||[],b=y.length,x=0;b>x;x++){var $=g[x];$&&($.style.display="none",$.fixIE78=(y[x].match(fa)||[""," "])[1])}}avalon.nextTick(function(){p(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(Pt.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&/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(Tt,function(e){Ut[e]=Ut.attr}),Ut["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),U(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=Jt.test(s);c||(e.immobileClass=s),z("",t,e,c?tt(s):0)}else e.immobileClass=e.oldStyle=e.param,z(i,t,e)},zt["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(Tt,function(e){Ut[e]=Ut["class"]}),zt.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var pa=Ut.duplex=function(e,t){var a,r=e.element;if(z(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=it);f(null,e,"init");var v=r.tagName;pa[v]&&pa[v](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:rt},"boolean":{get:function(e){return"true"===e},set:rt},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:rt}};var ha,ma=[];avalon.tick=function(e){1===ma.push(e)&&(ha=setInterval(ot,60))};var ga=i,ya=/text|password|hidden/;!new function(){function e(e){if(avalon.optimize||this.parentNode){if(t[this.tagName].call(this,e),!ya.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){ga=avalon.tick}},pa.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("duplexObserve")!==!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("duplexObserve")!==!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("duplexObserve")!==!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 v=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&n("data-event指令已经废弃,请改用data-duplex-event"),v.replace(Tt,function(e){switch(e){case"input":s("input",f),s("DOMAutoComplete",f),Ft||(s("compositionstart",i),s("compositionend",o));break;default:s(e,f)}}),s("focus",function(){e.msFocus=!0}),s("blur",function(){e.msFocus=!1}),ya.test(l)&&ga(function(){if(avalon.optimize||e.parentNode)e.msFocus||e.oldValue===e.value||f();else if(!e.msRetain)return!1}),e.avalonSetter=f}e.oldValue=e.value,avalon.injectBinding(a),r.call(e,e.value)},pa.TEXTAREA=pa.INPUT,pa.SELECT=function(e,t,a){function r(){if(i.data("duplexObserve")!==!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在不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),e.msCallback=function(){avalon.injectBinding(a),a.changed.call(e,t(),a)}},zt.html=function(e,t,n){var a=1!==t.nodeType,r=a?t.parentNode:t;if(r&&(e=null==e?"":e,n.oldText!==e)){if(n.oldText=e,3===t.nodeType){var i=Bt("html");r.insertBefore(gt.createComment(i),t),n.element=gt.createComment(i+":end"),r.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=_t.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),a){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;r.removeChild(c)}r.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);J(l,n.vmodels)}},Ut["if"]=Ut.data=Ut.text=Ut.html=function(e,t){z(e.value,t,e)},zt["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(a){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),G(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=gt.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,xt.appendChild(t),n.rollback=function(){t.parentNode===xt&&xt.removeChild(t)}}};var ba=/\(([^)]*)\)/;Ut.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof Ut.on[a+"Hook"]&&Ut.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(ba)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(ba,""))}z(n,t,e)},zt.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)}},Ut.repeat=function(e,t){var n=e.type;z(e.value,t,e,0,1);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[$t]=f[$t]||[],f[$t].push(e);break}}var v=e.element;if(1===v.nodeType){v.removeAttribute(e.name),e.sortedCallback=Gn(v,"data-with-sorted",t),e.renderedCallback=Gn(v,"data-"+n+"-rendered",t);var d=Bt(n),p=gt.createComment(d),h=gt.createComment(d+":end");if(e.signature=d,e.template=_t.cloneNode(!1),"repeat"===n){var m=v.parentNode;m.replaceChild(h,v),m.insertBefore(p,h),e.template.appendChild(v)}else{for(;v.firstChild;)e.template.appendChild(v.firstChild);v.appendChild(p),v.appendChild(h)}e.element=h,e.handler=zt.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!a){e.$outer={};var g="$key",y="$val";if(Array.isArray(r)){if(!r.$map){r.$map={el:1};var b=r.length,x=[];for(u=0;b>u;u++)x.push(k(u,r));r.$proxy=x}r.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var $=r.$events,w=($||{})[$t];A(w,e),"object"===i?(e.$with=!0,r.$proxy||(r.$proxy={}),e.handler("append",r)):r.length&&e.handler("add",0,r.length)}},zt.repeat=function(e,t,n){if(e){var a,r,o=this,l=o.element,s=st(o),c=l.parentNode,u=_t.cloneNode(!1);switch(e){case"add":for(var f=t+n,v=[],d=o.$repeat,p=t;f>p;p++){var h=d.$proxy[p];h.$outer=o.$outer,lt(o,u,h,v)}var m=new Date-0;for(avalon.optimize=avalon.optimize||m,p=0;r=v[p++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null;avalon.optimize===m&&delete avalon.optimize,c.insertBefore(u,s[t]||l),avalon.profile("插入操作花费了 "+(new Date-m));break;case"del":ct(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&ct(a,l);break;case"move":if(a=s[0]){var g,y=a.nodeValue,b=[],x=[];for(ct(a,l,function(){x.unshift(this),this.nodeValue===y&&(b.unshift(x),x=[])}),E(b,t);x=b.shift();)for(;g=x.shift();)u.appendChild(g);c.insertBefore(u,l)}break;case"append":var $=t,w=$.$proxy,C=[];v=[];for(var T in w)$.hasOwnProperty(T)||(dt(w[T],xa),delete w[T]);for(T in $)$.hasOwnProperty(T)&&"hasOwnProperty"!==T&&"$proxy"!==T&&C.push(T);if(o.sortedCallback){var k=o.sortedCallback.call(c,C);k&&Array.isArray(k)&&k.length&&(C=k)}for(p=0;T=C[p++];)"hasOwnProperty"!==T&&(w[T]=ft(w[T],T,o),lt(o,u,w[T],v));for(c.insertBefore(u,l),p=0;r=v[p++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null}"clear"===e&&(e="del");var A=o.renderedCallback||i,M=arguments;q(c,function(){A.apply(c,M),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(Tt,function(e){Ut[e]=Ut.repeat}),avalon.pool=fn;var xa=[];zt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=pt,Ut.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=pt(n[0].nodeName)),r.visibility=i?o:""}e.display=a,z(e.value,t,e)},zt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Ut.widget=function(t,a){var r=t.value.match(Tt),o=t.element,l=r[0],s=r[1];s&&"$"!==s||(s=Bt(l));var c=r[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,v=0;f=a[v++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var d=f[c];d=d.$model||d;break}if(d){var p=d[l+"Id"];"string"==typeof p&&(n("warning!不再支持"+l+"Id"),s=p)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=i,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,d||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,W(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},N(t,$a),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(S)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var $a=[],wa=/]*>([\S\s]*?)<\/script\s*>/gim,Ca=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Ea=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,Ta={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},ka=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Aa=/([^\#-~| |!])/g,Ma=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof 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:H,sanitize:function(e){return e.replace(wa,"").replace(Ea,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=Ta[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(Ca," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(ka,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Aa,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+ht(e,isFinite(n)?n:2)},number:ht};!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.length0||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+)\)\/$/;Ma.date=function(t,n){var a,r,i=Ma.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(),v=[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 v[0]=e(i[0]),v[1]=e(i[1])-1,v[2]=e(i[2]),""});var p=d.setFullYear,h=d.setHours;f=f.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,a,r,i){return v[3]=e(n),v[4]=e(a),v[5]=e(r),i&&(v[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 p=d.setUTCFullYear,h=d.setUTCHours,n&&(m=e(n+a),g=e(n+r)),""}),v[3]-=m,v[4]-=g,p.apply(d,v.slice(0,3)),h.apply(d,v.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,Ma.date.locate=c};var Oa=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Oa.exports=Oa.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(H,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=Oa[t],r=t&&e.urlNoQuery;if(a&&a.state>=1)return t;if(a=Oa[r],a&&a.state>=3)return bt(a.deps||[],a.factory,r),r;if(t&&!a){a=Oa[r]={id:r,state:1};var i=function(r){D[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,c()})};D[n]?i(D[n]):bt([n],i)}return t?r:n+"!"}function l(e,t){for(var n,a=0;n=e[a++];)if(4!==Oa[n].state&&(n===t||l(Oa[n].deps,t)))return!0}function s(e,t){var a=v(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){yt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Oa[a].state)):!0}function c(){e:for(var e,t=T.length;e=T[--t];){var n=Oa[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++)if(4!==Object(Oa[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=gt.createElement("script");r.className=$t,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)},yt.insertBefore(r,yt.firstChild),r.src=e,n("debug: 正准备加载 "+e)}function v(e){return(e||"").replace(H,"")}function d(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function p(){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/,""),v(e.replace(/(:\d+)?:\d+$/i,""));for(var n,r=yt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===$t&&"interactive"===n.readyState){var o=n.src;return n.className=v(o)}}function h(t,a,i){var o=Object(Oa[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(Oa[l].exports);try{var f=i.apply(e,c)}catch(v){n("执行["+t+"]模块的factory抛错: "+v)}return void 0!==f&&(o.exports=f),P.test(t)&&delete Oa[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;$(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)),d(t)||(r=this.built||/^\w/.test(t)?a:r,t=C(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 g(e,t,n){var a=x(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&&E(t.exports)}}function x(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 $(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;_.test(e);)e=e.replace(_,"");return e}return"/"===t.slice(0,1)?e+t.slice(1):e+t}function E(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var T=[],k=[],A=/\.js$/i,M=[],O=!1;bt=avalon.require=function(e,n,a,l){if(O){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var s=[],f=r(),v=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(A,"")),d){var p=t(l.defineName,l);v=p.urlNoQuery}else e.forEach(function(e){var n=t(e,l),a=o(n);a&&(f[a]||(s.push(a),f[a]="司徒正美"))});var h=Oa[v];h&&4===h.state||(Oa[v]={id:v,deps:d?e.concat():s,factory:n||i,state:3}),h||T.push(v),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();)bt.apply(null,m)}},bt.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),Oa[e]){Oa[e].state=3;var t=!1;try{t=l(Oa[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,bt.apply(null,r)};var i=a.built?"unknown":p();if(i){var o=Oa[i];o&&(o.state=2),n.require(i)}else k.push(n)},bt.config=u,bt.define.amd=Oa;var N=u["orig.paths"]=r(),S=u["orig.map"]=r(),L=u.packages=[],j=u["orig.args"]=r();avalon.mix(tn,{paths:function(e){avalon.mix(N,e),u.paths=g(N)},map:function(e){avalon.mix(S,e);var t=g(S,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),u.map=t},packages:function(e){e=e.concat(L);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=C(t.location||o,t.main||"main");l=l.replace(A,""),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(j,e),u.urlArgs=g(j,1)},baseUrl:function(e){if(!d(e)){var t=yt.getElementsByTagName("base")[0];t&&yt.removeChild(t);var n=gt.createElement("a");n.href=e,e=n.href,t&&yt.insertBefore(t,yt.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 D=bt.plugins={ready:{load:i},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(A,"")];i?bt(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;yt.insertAdjacentHTML("afterBegin",''),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=va();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+r),a(i.responseText))};var o="_="+(new Date-0),l=-1===r.indexOf("?")?r+"?"+o:r+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};bt.checkDeps=c;var H=/(\?[^#]*)$/,P=/^callback\d+$/,_=/\/\w+\/\.\./,R=gt.scripts[gt.scripts.length-1],I=R.getAttribute("data-main");if(I){tn.baseUrl(I);var B=u.baseUrl;u.baseUrl=B.slice(0,B.lastIndexOf("/")+1),f(B.replace(A,"")+".js")}else{var F=v(R.src);u.baseUrl=F.slice(0,F.lastIndexOf("/")+1)}};var Na,Sa=[],La=function(e){for(Na=!0,bt&&(Oa["domReady!"].state=4,bt.checkDeps());e=Sa.shift();)e(avalon)};"complete"===gt.readyState?setTimeout(La):gt.addEventListener("DOMContentLoaded",La),e.addEventListener("load",La),avalon.ready=function(e){Na?e(avalon):Sa.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(gt.body)}),new function(){function t(e){return("touch"===e.pointerType||e.pointerType===e.MSPOINTER_TYPE_TOUCH)&&e.isPrimary}function n(e,t){return e.type==="pointer"+t||e.type.toLowerCase()==="mspointer"+t}function a(e,t,n,a){return Math.abs(e-t)>=Math.abs(n-a)?e-t>0?"left":"right":n-a>0?"up":"down"}function r(e){var t=e.touches&&e.touches.length?e.touches:[e],n=e.changedTouches?e.changedTouches[0]:t[0];return{x:n.clientX,y:n.clientY}}function i(e,t,n){var a=document.createEvent("Events");a.initEvent(t,!0,!0),a.fireByAvalon=!0,n&&(a.detail=n),e.dispatchEvent(a)}function o(e){return e.fireByAvalon?!0:void(h.element&&"select"!==e.target.tagName.toLowerCase()&&(e.stopImmediatePropagation?e.stopImmediatePropagation():e.propagationStopped=!0,e.stopPropagation(),e.preventDefault(),"click"===e.type&&(h.element=null)))}function l(){$&&clearTimeout($),$=null}function s(e){var a=n(e,"down"),o=a?e:e.touches&&e.touches[0]||e,l="tagName"in o.target?o.target:o.target.parentNode,s=Date.now(),c=s-(h.last||s);if(!a||t(e))return avalon.mix(h,r(e)),h.mx=0,h.my=0,c>0&&250>=c&&(h.isDoubleTap=!0),h.last=s,h.element=l,avalon(l).addClass(w.activeClass),$=setTimeout(function(){$=null,i(l,"hold"),i(l,"longtap"),h={},avalon(l).removeClass(w.activeClass)},w.clickDuration),!0}function c(e){var a=n(e,"down"),i=r(e);v&&Math.abs(h.x-i.x)>10&&e.preventDefault(),(!a||t(e))&&(l(),h.mx+=Math.abs(h.x-i.x),h.my+=Math.abs(h.y-i.y))}function u(e){var o=n(e,"down");if(element=h.element,(!o||t(e))&&element){l();var s=r(e),c=Math.abs(h.x-s.x),u=Math.abs(h.y-s.y);if(c>30||u>30){var f=a(h.x,s.x,h.y,s.y),v={direction:f};i(element,"swipe",v),i(element,"swipe"+f,v),avalon(element).removeClass(w.activeClass),h={},h.element=element}else if(w.canClick(element)&&h.mx0,d=/iP(ad|hone|od)/.test(f),p=Ut.on,h={},m=navigator.pointerEnabled,g=navigator.msPointerEnabled,y=function(){var e=d||!1;try{var t=document.createElement("div");t.ontouchstart=function(){e=!0};var n=document.createEvent("TouchEvent");n.initUIEvent("touchstart",!0,!0),t.dispatchEvent(n)}catch(a){}return t=t.ontouchstart=null,e}(),b=["mousedown","mousemove","mouseup",""];y?b=["touchstart","touchmove","touchend","touchcancel"]:m?b=["pointerdown","pointermove","pointerup","pointercancel"]:g&&(b=["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerCancel"]);var x,$;document.addEventListener("mousedown",o,!0),document.addEventListener("click",o,!0),document.addEventListener(b[0],s),document.addEventListener(b[1],c),document.addEventListener(b[2],u),b[3]&&document.addEventListener(b[3],function(){$&&clearTimeout($),x&&clearTimeout(x),$=x=null,h={}});var w=avalon.fastclick={activeClass:"ms-click-active",clickDuration:750,dragDistance:30,fireEvent:function(t,n,a){var r=document.createEvent("MouseEvents");r.initMouseEvent(n,!0,!0,e,1,a.screenX,a.screenY,a.clientX,a.clientY,!1,!1,!1,!1,0,null),Object.defineProperty(r,"fireByAvalon",{value:!0}),t.dispatchEvent(r)},focus:function(e){if(this.canFocus(e)){var t=e.value;if(e.value=t,d&&e.setSelectionRange&&0!==e.type.indexOf("date")&&"time"!==e.type){var n=t.length;e.setSelectionRange(n,n)}else e.focus()}},canClick:function(e){switch(e.nodeName.toLowerCase()){case"textarea":case"select":case"input":return!e.disabled;default:return!0}},canFocus:function(e){switch(e.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!v;case"input":switch(e.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!e.disabled&&!e.readOnly;default:return!1}}};["swipe","swipeleft","swiperight","swipeup","swipedown","doubletap","tap","dblclick","longtap","hold"].forEach(function(e){p[e+"Hook"]=p.clickHook})},"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var ja=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=ja),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file diff --git a/dist/avalon.mobile.old.js b/dist/avalon.mobile.old.js index d7023fb75..798950d82 100644 --- a/dist/avalon.mobile.old.js +++ b/dist/avalon.mobile.old.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.mobile.old.js 1.44 built in 2015.6.16 + avalon.mobile.old.js 1.44 built in 2015.6.25 support IE8 and other browsers ==================================================*/ (function(global, factory) { @@ -70,7 +70,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -92,7 +92,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -106,12 +106,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -131,14 +137,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -146,13 +152,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -1096,9 +1102,8 @@ avalon.define = function (id, factory) { $watch: noop } factory(scope) //得到所有定义 - avalon.collectDependency = true + model = modelFactory(scope) //偷天换日,将scope换为model - avalon.collectDependency = false stopRepeatAssign = true factory(model) stopRepeatAssign = false @@ -1108,7 +1113,7 @@ avalon.define = function (id, factory) { } //一些不需要被监听的属性 -var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(rword) +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(rword) var defineProperty = Object.defineProperty var canHideOwn = true //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 @@ -1201,7 +1206,7 @@ function modelFactory(source, $special, $model) { } /* jshint ignore:end */ } - + $vmodel.$compute = function () { computed.forEach(function (accessor) { dependencyDetection.begin({ @@ -1249,7 +1254,7 @@ function makeComputedAccessor(name, options) { options.set = options.set || noop function accessor(value) {//计算属性 var oldValue = accessor._value - var init = "_value" in accessor + var init = "_value" in accessor if (arguments.length > 0) { if (stopRepeatAssign) { return this @@ -1261,7 +1266,7 @@ function makeComputedAccessor(name, options) { value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) - init && accessor.notify(this, value, oldValue) //触发$watch回调 + init && accessor.notify(this, value, oldValue) //触发$watch回调 } //将自己注入到低层访问器的订阅数组中 return value @@ -1306,10 +1311,11 @@ function makeComplexAccessor(name, initValue, valueType, list) { son.$events[subscribers] = observes son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) } @@ -1696,7 +1702,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1793,6 +1799,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1879,11 +1887,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1920,6 +1932,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -3367,6 +3381,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -3385,7 +3400,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3768,7 +3782,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3939,7 +3953,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -4008,7 +4022,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -4031,16 +4049,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -4245,11 +4263,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.mobile.shim.js b/dist/avalon.mobile.shim.js index 6db9a5019..90938bf15 100644 --- a/dist/avalon.mobile.shim.js +++ b/dist/avalon.mobile.shim.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.mobile.shim.js 1.44 built in 2015.6.16 + avalon.mobile.shim.js 1.44 built in 2015.6.25 ==================================================*/ (function(global, factory) { @@ -78,7 +78,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -100,7 +100,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -114,12 +114,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -139,14 +145,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -154,13 +160,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -871,12 +877,10 @@ function modelFactory(source, $special, $model) { $model = $model || {} //vmodels.$model属性 var $events = createMap() //vmodel.$events属性 var accessors = createMap() //监控属性 - var initCallbacks = [] //初始化才执行的函数 - + var computed = [] $$skipArray.forEach(function (name) { delete source[name] }) - for (var i in source) { (function (name, val, accessor) { $model[name] = val @@ -889,13 +893,9 @@ function modelFactory(source, $special, $model) { //总共产生三种accessor if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { accessor = makeComputedAccessor(name, val) - initCallbacks.push(accessor) + computed.push(accessor) } else if (rcomplexType.test(valueType)) { - accessor = makeComplexAccessor(name, val, valueType) - initCallbacks.push(function () { - var son = accessor._vmodel - son.$events[subscribers] = this.$events[name] - }) + accessor = makeComplexAccessor(name, val, valueType, $events[name]) } else { accessor = makeSimpleAccessor(name, val) } @@ -925,10 +925,26 @@ function modelFactory(source, $special, $model) { enumerable: false, configurable: true }) - - initCallbacks.forEach(function (cb) { //收集依赖 - cb.call($vmodel) - }) + $vmodel.$compute = function () { + computed.forEach(function (accessor) { + dependencyDetection.begin({ + callback: function (vm, dependency) {//dependency为一个accessor + var name = dependency._name + if (dependency !== accessor) { + var list = vm.$events[name] + accessor.vm = $vmodel + injectDependency(list, accessor.digest) + } + } + }) + try { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$compute() return $vmodel } @@ -937,10 +953,7 @@ function makeSimpleAccessor(name, value) { function accessor(value) { var oldValue = accessor._value if (arguments.length > 0) { - if (stopRepeatAssign) { - return this - } - if (!isEqual(value, oldValue)) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { accessor.updateValue(this, value) accessor.notify(this, value, oldValue) } @@ -969,35 +982,7 @@ function makeComputedAccessor(name, options) { return this } else { //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 - dependencyDetection.collectDependency(this, accessor) - if (!accessor.digest) { - var vm = this - var id - accessor.digest = function () { - accessor.updateValue = globalUpdateModelValue - accessor.notify = noop - accessor.call(vm) - clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 - id = setTimeout(function () { - accessorFactory(accessor, accessor._name) - accessor.call(vm) - }) - } - } - dependencyDetection.begin({ - callback: function (vm, dependency) {//dependency为一个accessor - var name = dependency._name - if (dependency !== accessor) { - var list = vm.$events[name] - injectDependency(list, accessor.digest) - } - } - }) - try { - value = accessor.get.call(this) - } finally { - dependencyDetection.end() - } + value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) init && accessor.notify(this, value, oldValue) //触发$watch回调 @@ -1005,15 +990,27 @@ function makeComputedAccessor(name, options) { //将自己注入到低层访问器的订阅数组中 return value } + } accessor.set = options.set || noop accessor.get = options.get accessorFactory(accessor, name) + var id + accessor.digest = function () { + accessor.updateValue = globalUpdateModelValue + accessor.notify = noop + accessor.call(accessor.vm) + clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 + id = setTimeout(function () { + accessorFactory(accessor, accessor._name) + accessor.call(accessor.vm) + }) + } return accessor } //创建一个复杂访问器 -function makeComplexAccessor(name, initValue, valueType) { +function makeComplexAccessor(name, initValue, valueType, list) { function accessor(value) { var oldValue = accessor._value var son = accessor._vmodel @@ -1033,10 +1030,11 @@ function makeComplexAccessor(name, initValue, valueType) { son = accessor._vmodel = modelFactory(value) son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) son.$events[name] = observes @@ -1051,7 +1049,8 @@ function makeComplexAccessor(name, initValue, valueType) { } } accessorFactory(accessor, name) - accessor._vmodel = modelFactory(initValue) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list return accessor } @@ -1318,7 +1317,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1415,6 +1414,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1501,11 +1502,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1542,6 +1547,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -2734,6 +2741,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -2752,7 +2760,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3135,7 +3142,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3263,7 +3270,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { }) if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -3332,7 +3339,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -3355,16 +3366,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -3569,11 +3580,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.modern.js b/dist/avalon.modern.js index 1166c1c35..b15aacd2f 100644 --- a/dist/avalon.modern.js +++ b/dist/avalon.modern.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.modern.js 1.44 built in 2015.6.16 + avalon.modern.js 1.44 built in 2015.6.25 support IE10+ and other browsers ==================================================*/ (function(global, factory) { @@ -79,7 +79,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -101,7 +101,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -115,12 +115,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -140,14 +146,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -155,13 +161,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -872,12 +878,10 @@ function modelFactory(source, $special, $model) { $model = $model || {} //vmodels.$model属性 var $events = createMap() //vmodel.$events属性 var accessors = createMap() //监控属性 - var initCallbacks = [] //初始化才执行的函数 - + var computed = [] $$skipArray.forEach(function (name) { delete source[name] }) - for (var i in source) { (function (name, val, accessor) { $model[name] = val @@ -890,13 +894,9 @@ function modelFactory(source, $special, $model) { //总共产生三种accessor if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { accessor = makeComputedAccessor(name, val) - initCallbacks.push(accessor) + computed.push(accessor) } else if (rcomplexType.test(valueType)) { - accessor = makeComplexAccessor(name, val, valueType) - initCallbacks.push(function () { - var son = accessor._vmodel - son.$events[subscribers] = this.$events[name] - }) + accessor = makeComplexAccessor(name, val, valueType, $events[name]) } else { accessor = makeSimpleAccessor(name, val) } @@ -926,10 +926,26 @@ function modelFactory(source, $special, $model) { enumerable: false, configurable: true }) - - initCallbacks.forEach(function (cb) { //收集依赖 - cb.call($vmodel) - }) + $vmodel.$compute = function () { + computed.forEach(function (accessor) { + dependencyDetection.begin({ + callback: function (vm, dependency) {//dependency为一个accessor + var name = dependency._name + if (dependency !== accessor) { + var list = vm.$events[name] + accessor.vm = $vmodel + injectDependency(list, accessor.digest) + } + } + }) + try { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$compute() return $vmodel } @@ -938,10 +954,7 @@ function makeSimpleAccessor(name, value) { function accessor(value) { var oldValue = accessor._value if (arguments.length > 0) { - if (stopRepeatAssign) { - return this - } - if (!isEqual(value, oldValue)) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { accessor.updateValue(this, value) accessor.notify(this, value, oldValue) } @@ -970,35 +983,7 @@ function makeComputedAccessor(name, options) { return this } else { //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 - dependencyDetection.collectDependency(this, accessor) - if (!accessor.digest) { - var vm = this - var id - accessor.digest = function () { - accessor.updateValue = globalUpdateModelValue - accessor.notify = noop - accessor.call(vm) - clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 - id = setTimeout(function () { - accessorFactory(accessor, accessor._name) - accessor.call(vm) - }) - } - } - dependencyDetection.begin({ - callback: function (vm, dependency) {//dependency为一个accessor - var name = dependency._name - if (dependency !== accessor) { - var list = vm.$events[name] - injectDependency(list, accessor.digest) - } - } - }) - try { - value = accessor.get.call(this) - } finally { - dependencyDetection.end() - } + value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) init && accessor.notify(this, value, oldValue) //触发$watch回调 @@ -1006,15 +991,27 @@ function makeComputedAccessor(name, options) { //将自己注入到低层访问器的订阅数组中 return value } + } accessor.set = options.set || noop accessor.get = options.get accessorFactory(accessor, name) + var id + accessor.digest = function () { + accessor.updateValue = globalUpdateModelValue + accessor.notify = noop + accessor.call(accessor.vm) + clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 + id = setTimeout(function () { + accessorFactory(accessor, accessor._name) + accessor.call(accessor.vm) + }) + } return accessor } //创建一个复杂访问器 -function makeComplexAccessor(name, initValue, valueType) { +function makeComplexAccessor(name, initValue, valueType, list) { function accessor(value) { var oldValue = accessor._value var son = accessor._vmodel @@ -1034,10 +1031,11 @@ function makeComplexAccessor(name, initValue, valueType) { son = accessor._vmodel = modelFactory(value) son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) son.$events[name] = observes @@ -1052,7 +1050,8 @@ function makeComplexAccessor(name, initValue, valueType) { } } accessorFactory(accessor, name) - accessor._vmodel = modelFactory(initValue) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list return accessor } @@ -1319,7 +1318,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1416,6 +1415,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1502,11 +1503,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1543,6 +1548,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -2735,6 +2742,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -2753,7 +2761,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3136,7 +3143,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3264,7 +3271,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { }) if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -3333,7 +3340,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -3356,16 +3367,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -3570,11 +3581,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.modern.min.js b/dist/avalon.modern.min.js index 380291e5c..b3eac2742 100644 --- a/dist/avalon.modern.min.js +++ b/dist/avalon.modern.min.js @@ -1,2 +1,2 @@ -!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(Tt)||[]);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=jt.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=gt.createElementNS(Wt,n.tagName.toLowerCase());St.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(Nt.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(en,"\\$&")}function p(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=x(e);return i.pushArray(a),i}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var o=Array.isArray(e.$skipArray)?e.$skipArray:[];o.$special=t||r();var l={};n=n||{};var s=r(),c=r(),u=[];on.forEach(function(t){delete e[t]});for(var f in e)!function(e,t,a){if(n[e]=t,$(e,t,o)){s[e]=[];var r=avalon.type(t);"object"===r&&Vt(t.get)&&Object.keys(t).length<=2?(a=v(e,t),u.push(a)):At.test(r)?(a=h(e,t,r),u.push(function(){var t=a._vmodel;t.$events[xt]=this.$events[e]})):a=d(e,t),c[e]=a}}(f,e[f]);l=Object.defineProperties(l,sn(c));for(var p in e)c[p]||(l[p]=e[p]);l.$id=Bt(),l.$model=n,l.$events=s;for(f in an)l[f]=an[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.call(l)}),l}function d(e,t){function n(e){var t=n._value;return arguments.length>0?kt?this:(ln(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(pn.collectDependency(this,n),t)}return b(n,e),n._value=t,n}function v(e,t){function n(e){var t=n._value,a="_value"in n;if(arguments.length>0)return kt?this:(n.set.call(this,e),this);if(pn.collectDependency(this,n),!n.digest){var r,o=this;n.digest=function(){n.updateValue=g,n.notify=i,n.call(o),clearTimeout(r),r=setTimeout(function(){b(n,n._name),n.call(o)})}}pn.begin({callback:function(e,t){var a=t._name;if(t!==n){var r=e.$events[a];E(r,n.digest)}}});try{e=n.get.call(this)}finally{pn.end()}return t!==e&&(n.updateValue(this,e),a&&n.notify(this,e,t)),e}return t.set=t.set||i,n.set=t.set||i,n.get=t.get,b(n,e),n}function h(e,t,n){function a(t){var r=a._value,i=a._vmodel;if(arguments.length>0){if(kt)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=a._vmodel=p(t),i.$proxy=l,s.length&&(s.forEach(function(e){e.rollback&&(e.rollback(),Ut[e.type](e,e.vmodels))}),i.$events[e]=s)}return a.updateValue(this,i.$model),a.notify(this,this._value,r),this}return pn.collectDependency(this,a),i}return b(a,e),a._vmodel=p(t),a}function m(e,t){e.$model[this._name]=this._value=t}function g(e,t){e.$model[this._name]=t}function y(e,t,n){var a=this._name,r=e.$events[a];r&&(O(r),an.$fire.call(e,a,t,n))}function b(e,t){e._name=t,e.updateValue=m,e.notify=y}function $(e,t,n){if(Vt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function x(e){var t=[];t.$id=Bt(),t.$model=e,t.$events={},t.$events[xt]=[],t._=p({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in an)t[n]=an[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,un),t}function w(e,t,n,a,r,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return At.test(avalon.type(e))?e.$id?e:p(e,0,e):e});cn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var d=A(f,this);this.$proxy.splice(f,0,d)}this._fire("add",t,n);break;case"del":var v=this._splice(t,n),h=this.$proxy.splice(t,n);pt(h,"each"),this._fire("del",t,n)}r&&(e=r,t=i,n=o,s=2,r=0)}return C(this.$proxy,a),this.length!==l&&(this._.length=this.length),v}function C(e,t){for(var n,a=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===a}function k(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 T(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=p(e,t);return n.$id=Bt("$proxy$each"),n}function A(e,t){var n=fn.shift();n||(n=T());var a=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===a,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function E(e,t){t=t||Ht[mt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&N(t,e)}function O(e){if(e&&e.length){new Date-mn>444&&"object"==typeof e[0]&&j();for(var t,n=Lt.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 M(e){return e.uniqueNumber||(e.uniqueNumber=++vn)}function N(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+M(n.parentNode):e.name+"-"+M(n));var a=e.lists||(e.lists=[]);avalon.Array.ensure(a,t),t.$uuid=t.$uuid||Bt(),hn[e.uuid]||(hn[e.uuid]=1,hn.push(e))}function j(e){for(var t=hn.length,n=t,a=[],r={},i={};e=hn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,a.push(o))}var l=!1;if(a.forEach(function(e){gn[e]!==i[e]&&(r[e]=1,l=!0)}),t=n,l)for(;e=hn[--t];)if(e.element&&r[e.type]&&L(e.element)){hn.splice(t,1),delete hn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);S(e)}gn=i,mn=new Date}function S(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function L(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!_t.contains(e):!avalon.contains(_t,e)}function H(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function D(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function _(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:kn.test(e)?JSON.parse(e):e}catch(t){}return e}function R(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function P(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(Mn.test(n.display)){var a={node:e};for(var r in On)a[r]=n[r],e.style[r]=On[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&P(i,t)}}function I(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function B(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;r=e[--s];){var c=l&&t.$map[r]?"el":r;t.hasOwnProperty(c)&&(i.push(r+o+c),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function F(e){for(var t=[],n={},a=0;ad;d++)if(s.length){var h="vm"+mt+"_"+d;u.push(h),f.push(t[d]),c.push.apply(c,B(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=Ft?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,delete a.vars;var m=Bn.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"+mt+" = "+e+";\r\n",e+=V("ret"+mt,o)}else{if("duplex"===r){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Fn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(i,u.concat(g)),a.evaluator=Bn.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=Bn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function q(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":jn(e.value)}).join(" + ")),U(e,t,n),n.evaluator&&!r&&(n.handler=qt[n.handlerName||n.type],avalon.injectBinding(n))}function z(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():z(e,t,r)})}function W(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function X(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,Ut[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function Y(e,t){return e.priority-t.priority}function G(e,t,a){var i=!0;if(t.length){for(var o,l=e.attributes,s=[],c=[],u=r(),f=0;o=l[f++];)if(o.specified&&(a=o.name.match(Jn))){var p=a[1],d=a[2]||"",v=o.value,h=o.name;if(Kn[p]?(d=p,p="on"):ea[p]&&("enabled"===p&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),p="disabled",v="!("+v+")"),d=p,p="attr",h="ms-"+p+"-"+d,c.push([o.name,h,v])),u[h]=v,"function"==typeof Ut[p]){var m={type:p,param:d,element:e,name:h,value:v,priority:(Qn[p]||10*p.charCodeAt(0))+(Number(d.replace(/\D/g,""))||0)};if("html"===p||"text"===p){var g=et(v);avalon.mix(m,g),m.filters=m.filters.replace(aa,function(){return m.type="html",m.group=1,""})}else if("duplex"===p)var y=h;else"ms-if-loop"===h&&(m.priority+=100);s.push(m),"widget"===p&&(e.msData=e.msData||u)}}if(s.length){s.sort(Y),c.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])});var b=e.type;for(b&&y&&(u["ms-attr-checked"]&&n("warning!"+b+"控件不能同时定义ms-attr-checked与"+y),u["ms-attr-value"]&&n("warning!"+b+"控件不能同时定义ms-attr-value与"+y)),f=0;m=s[f];f++){if(p=m.type,ta.test(p))return X(s.slice(0,f+1),t);i&&(i=!na.test(p))}X(s,t)}}i&&!Yn[e.tagName]&&Kt.test(e.innerHTML+e.textContent)&&(Zn&&Zn(e),Z(e,t))}function Z(e,t){var n=avalon.slice(e.childNodes);J(n,t)}function J(e,t){for(var n,a=0;n=e[a++];)Q(n,n.nodeType,t)}function Q(e,t,n){1===t?(K(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&Jt.test(e.data)?nt(e,n):u.commentInterpolate&&8===t&&!Jt.test(e.nodeValue)&&nt(e,n)}function K(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),W(e,o)}G(e,t)}}function et(e,t){if(e.indexOf("|")>0){var n=e.replace(ia,function(e){return Array(e.length+1).join("1")}),a=n.replace(ra,"ᄢ㍄").indexOf("|");if(a>-1)return{filters:e.slice(a),value:e.slice(0,a),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function tt(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Gt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Gt.length,n=e.indexOf(Zt,r),-1===n)break;t=e.slice(r,n),t&&a.push(et(t,r)),r=n+Zt.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function nt(e,t){var n=[];if(8===e.nodeType)var a=et(e.nodeValue),r=[a];else r=tt(e.data);if(r.length){for(var i=0;a=r[i++];){var o=gt.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(aa,function(){return a.type="html",""}),n.push(a)),Rt.appendChild(o)}e.parentNode.replaceChild(Rt,e),n.length&&X(n,t)}}function at(e,t,n){var a=e.templateCache&&e.templateCache[t];if(a){for(var r,i=gt.createDocumentFragment();r=a.firstChild;)i.appendChild(r);return i}return avalon.parseHTML(n)}function rt(e){return null==e?"":e}function it(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 ot(){for(var e=ma.length-1;e>=0;e--){var t=ma[e];t()===!1&&ma.splice(e,1)}ma.length||clearInterval(ha)}function lt(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);e.$with||r.insertBefore(gt.createComment(e.signature),r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function st(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),a=t.previousSibling,r=[];a;)a.nodeValue===n&&r.unshift(a),a=a.previousSibling;return r}function ct(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function ut(){var e=p({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Bt("$proxy$with"),e}function ft(e,t,n){e=e||$a.pop(),e||(e=ut());var a=n.$repeat;return e.$key=t,e.$host=a,e.$outer=n.$outer,a.$events?e.$events.$val=a.$events[t]:e.$events={},e}function pt(e){e.forEach(function(e){dt(e,fn)}),e.length=0}function dt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&S(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>u.maxRepeatSize&&t.pop()}function vt(e,t){var n="_"+e;if(!vt[n]){var a=gt.createElement(e);_t.appendChild(a),t=Dt?getComputedStyle(a,null).display:a.currentStyle.display,_t.removeChild(a),vt[n]=t}return vt[n]}function ht(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');var bt,$t=yt.firstChild,xt="$"+mt,wt=e.require,Ct=e.define,kt=!1,Tt=/[^, ]+/g,At=/^(?:object|array)$/,Et=/^\[object SVG\w*Element\]$/,Ot=/^\[object (?:Window|DOMWindow|global)\]$/,Mt=Object.prototype,Nt=Mt.hasOwnProperty,jt=Mt.toString,St=Array.prototype,Lt=St.slice,Ht={},Dt=e.dispatchEvent,_t=gt.documentElement,Rt=gt.createDocumentFragment(),Pt=gt.createElement("div"),It={};"Boolean Number String Function Array Date RegExp Object Error".replace(Tt,function(e){It["[object "+e+"]"]=e.toLowerCase()});var Bt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Ft=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=Dt&&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?It[jt.call(e)]||"object":typeof e};var Vt=function(e){return"[object Function]"===jt.call(e)};avalon.isFunction=Vt,avalon.isWindow=function(e){return Ot.test(jt.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===jt.call(e)&&Object.getPrototypeOf(e)===Mt},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||Vt(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:Tt,subscribers:xt,version:1.44,ui:{},log:n,slice:function(e,t,n){return Lt.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);++an&&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 Ut=avalon.bindingHandlers={},qt=avalon.bindingExecutors={},zt=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(gt.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 Wt="http://www.w3.org/2000/svg",Xt=gt.createElementNS(Wt,"svg");Xt.innerHTML='',Et.test(Xt.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=gt.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("$","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 Yt=avalon.eventHooks;"onmouseenter"in _t||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Yt[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]&&!Yt.animationend&&(Yt.animationend={type:n})}),void 0===gt.onmousewheel&&(Yt.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 Gt,Zt,Jt,Qt,Kt,en=/[-.*+?^${}()|[\]\/\\]/g,tn={loader:function(t){var n=bt&&t;e.require=n?bt:wt,e.define=n?bt.define:Ct},interpolate:function(e){if(Gt=e[0],Zt=e[1],Gt===Zt)throw new SyntaxError("openTag!==closeTag");if(e+""=="")u.commentInterpolate=!0;else{var t=Gt+"test"+Zt;if(Pt.innerHTML=t,Pt.innerHTML!==t&&Pt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Pt.innerHTML=""}var n=f(Gt),a=f(Zt);Jt=new RegExp(n+"(.*?)"+a),Qt=new RegExp(n+"(.*?)"+a,"g"),Kt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=tn,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var nn=function(e){return gt.querySelectorAll(e)},an={$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=Lt.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?nn(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=nn(a.$events.expr);if(0===c.length)continue;St.forEach.call(c,function(e){St.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=gt.getElementsByTagName("*"),f=[];for(St.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++];)Vt(r)&&r.apply(this,o);for(n=0;r=d[n++];)Vt(r)&&r.apply(this,arguments)}}}},rn=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),rn[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var r=p(e);else{var o={$watch:i};t(o),r=p(o),kt=!0,t(r),kt=!1}return r.$id=a,rn[a]=r};var on=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(Tt),ln=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},sn=function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t},cn=St.splice,un={_splice:cn,_fire:function(e,t,n){O(this.$events[xt],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(St.push.apply(this.$model,e),w.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&&(St.unshift.apply(this.$model,arguments),w.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return w.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return w.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=cn.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?w.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),w.call(this,"del",e,1,0)):[]},clear:function(){return pt(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],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 if("array"===n)a.clear().push.apply(a,t);else if(a!==t){this[e]=t,this.$model[e]=t;var i=this.$proxy[e];i&&O(i.$events.el)}}return this}};"sort,reverse".replace(Tt,function(e){un[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];St[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(ln(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(k(this,i),k(this.$proxy,i),this._fire("move",i),C(this.$proxy,0)),this}});var fn=[],pn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),dn=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){pn.begin({callback:function(t,n){E(t.$events[n._name],e)}});try{var n=dn.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(gt.createComment(e.value),r):r.data=Gt+e.value+Zt}}finally{pn.end()}}};var vn=0,hn=avalon.$$subscribers=[],mn=new Date,gn={},yn=new function(){avalon.mix(this,{option:gt.createElement("select"),thead:gt.createElement("table"),td:gt.createElement("tr"),area:gt.createElement("map"),tr:gt.createElement("tbody"),col:gt.createElement("colgroup"),legend:gt.createElement("fieldset"),_default:gt.createElement("div"),g:gt.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(Tt,function(e){yn[e]=yn.g});var bn=/<([\w:]+)/,$n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,xn=o(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),wn=gt.createElement("script"),Cn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Rt.cloneNode(!1);if("string"!=typeof e)return t;if(!Cn.test(e))return t.appendChild(gt.createTextNode(e)),t;e=e.replace($n,"<$1>").trim();var n,a=(bn.exec(e)||["",""])[1].toLowerCase(),r=yn[a]||yn._default;r.innerHTML=e;var i=r.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if(xn[o.type]){var s=wn.cloneNode(!1);St.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},"add,remove".replace(Tt,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=String(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-"+H(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return _(n);case 0:var a={};return St.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=D(e.slice(5)),a[e]=_(t.value)))}),a}},removeData:function(e){return e="data-"+H(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),a.top-=e.scrollTop(),a.left-=e.scrollLeft()),{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||_t)},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=Nn[I(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}}),_t.dataset&&(avalon.fn.data=function(e,t){e=e&&D(e);var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],_(t);case 0:var a=r();for(e in n)a[e]=_(n[e]);return a}});var kn=/(?:\{[\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=R(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 Tn=avalon.cssHooks=r(),An=["","-webkit-","-moz-","-ms-"],En={"float":"cssFloat"};avalon.cssNumber=o("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(En[e])return En[e];t=t||_t.style;for(var a=0,r=An.length;r>a;a++)if(n=D(An[a]+e),n in t)return En[e]=n;return null},Tn["@:set"]=function(e,t,n){e.style[t]=n},Tn["@: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},Tn["opacity:get"]=function(e){var t=Tn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(Tt,function(e){Tn[e+":get"]=function(t){var n=Tn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var On={position:"absolute",visibility:"hidden",display:"block"},Mn=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(Tt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;Tn[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)},Tn[t+"&get"]=function(e){var n=[];P(e,n);for(var a,r=Tn[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 Tn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return Tn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return Tn[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 Nn={"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)}},jn=JSON.stringify,Sn=["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(","),Ln=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Hn=/[^\w$]+/g,Dn=new RegExp(["\\b"+Sn.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),_n=/\b\d[^,]*/g,Rn=/^,+|,+$/g,Pn=new zt(512),In=function(e){var t=","+e.trim(),n=Pn.get(t);if(n)return n;var a=e.replace(Ln,"").replace(Hn,",").replace(Dn,"").replace(_n,"").replace(Rn,"").split(/^$|,+/);return Pn.put(t,F(a))},Bn=new zt(128),Fn=/\w\[.*\]|\w\.\w/,Vn=/(\$proxy\$[a-z]+)\d+$/,Un=/\)\s*$/,qn=/\)\s*\|/g,zn=/\|\s*([$\w]+)/g,Wn=/"\s*\["/g,Xn=/"\s*\(/g;avalon.parseExprProxy=q,avalon.scan=function(e,t){e=e||_t;var n=t?[].concat(t):[];K(e,n)};var Yn=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]},Zn=Ft&&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,Jn=/ms-(\w+)-?(.*)/,Qn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Kn=o("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),ea=o("value,title,alt,checked,selected,disabled,readonly,enabled"),ta=/^if|widget|repeat$/,na=/^each|with|html|include$/,aa=/\|\s*html\s*/,ra=/\|\|/g,ia=/(['"])(\\\1|.)+?\1/g,oa=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),la={};oa.replace(Tt,function(e){la[e.toLowerCase()]=e});var sa={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},ca=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");ca.replace(Tt,function(e){sa[e.toLowerCase()]=e});var ua=/(?:[\s\S]+?)<\/noscript>/gim,fa=/([\s\S]+?)<\/noscript>/im,pa=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},da=avalon.templateCache={};Ut.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Gt)>-1&&n.indexOf(Zt)>2&&(a=!1,Jt.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=gt.createComment("ms-include"),e.endInclude=gt.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",q(n,t,e,a?0:tt(e.value))},qt.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){var o=t===!1||null===t||void 0===t;!Dt&&sa[i]&&(i=sa[i]);var l=la[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=Et.test(n)?!1:gt.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){if(f){var n=f.apply(d,[e].concat(c));"string"==typeof n&&(e=n)}u&&z(d,function(){u.call(d)},0/0);var r=a.includeLastID;if(a.templateCache&&r&&r!==t){var i=a.templateCache[r];i||(i=a.templateCache[r]=gt.createElement("div"),$t.appendChild(i))}for(a.includeLastID=t;;){var o=a.startInclude.nextSibling;if(!o||o===a.endInclude)break;d.removeChild(o),i&&i.appendChild(o)}var l=at(a,t,e),s=avalon.slice(l.childNodes);d.insertBefore(l,a.endInclude),J(s,c)};if("src"===a.param)if("string"==typeof da[t])avalon.nextTick(function(){v(da[t])});else if(Array.isArray(da[t]))da[t].push(v);else{var h=pa();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,a=h.responseText,r=0;n=da[t][r++];)n(a);da[t]=a}}},da[t]=[v],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:gt.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=pa(),h.open("GET",location,!1),h.send(null);for(var g=gt.getElementsByTagName("noscript"),y=(h.responseText||"").match(ua)||[],b=y.length,$=0;b>$;$++){var x=g[$];x&&(x.style.display="none",x.fixIE78=(y[$].match(fa)||[""," "])[1])}}avalon.nextTick(function(){v(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(_t.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&/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(Tt,function(e){Ut[e]=Ut.attr}),Ut["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),U(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=Jt.test(s);c||(e.immobileClass=s),q("",t,e,c?tt(s):0)}else e.immobileClass=e.oldStyle=e.param,q(i,t,e)},qt["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(Tt,function(e){Ut[e]=Ut["class"]}),qt.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var va=Ut.duplex=function(e,t){var a,r=e.element;if(q(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=it);f(null,e,"init");var p=r.tagName;va[p]&&va[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:rt},"boolean":{get:function(e){return"true"===e},set:rt},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:rt}};var ha,ma=[];avalon.tick=function(e){1===ma.push(e)&&(ha=setInterval(ot,60))};var ga=i,ya=/text|password|hidden/;!new function(){function e(e){if(avalon.contains(_t,this)){if(t[this.tagName].call(this,e),!ya.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){ga=avalon.tick}},va.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("duplexObserve")!==!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("duplexObserve")!==!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("duplexObserve")!==!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(Tt,function(e){switch(e){case"input":s("input",f),s("DOMAutoComplete",f),Ft||(s("compositionstart",i),s("compositionend",o));break;default:s(e,f)}}),s("focus",function(){e.msFocus=!0}),s("blur",function(){e.msFocus=!1}),ya.test(l)&&ga(function(){if(_t.contains(e))e.msFocus||e.oldValue===e.value||f();else if(!e.msRetain)return!1}),e.avalonSetter=f}e.oldValue=e.value,avalon.injectBinding(a),r.call(e,e.value)},va.TEXTAREA=va.INPUT,va.SELECT=function(e,t,a){function r(){if(i.data("duplexObserve")!==!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在不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),e.msCallback=function(){avalon.injectBinding(a),a.changed.call(e,t(),a)}},qt.html=function(e,t,n){var a=1!==t.nodeType,r=a?t.parentNode:t;if(r){if(e=null==e?"":e,3===t.nodeType){var i=Bt("html");r.insertBefore(gt.createComment(i),t),n.element=gt.createComment(i+":end"),r.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=Rt.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),a){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;r.removeChild(c)}r.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);J(l,n.vmodels)}},Ut["if"]=Ut.data=Ut.text=Ut.html=function(e,t){q(e.value,t,e)},qt["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(a){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),G(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=gt.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,$t.appendChild(t),n.rollback=function(){t.parentNode===$t&&$t.removeChild(t)}}};var ba=/\(([^)]*)\)/;Ut.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof Ut.on[a+"Hook"]&&Ut.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(ba)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(ba,""))}q(n,t,e)},qt.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)}},Ut.repeat=function(e,t){var n=e.type;q(e.value,t,e,0,1);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[xt]=f[xt]||[],f[xt].push(e);break}}var p=e.element;if(1===p.nodeType){p.removeAttribute(e.name),e.sortedCallback=Gn(p,"data-with-sorted",t),e.renderedCallback=Gn(p,"data-"+n+"-rendered",t);var d=Bt(n),v=gt.createComment(d),h=gt.createComment(d+":end");if(e.signature=d,e.template=Rt.cloneNode(!1),"repeat"===n){var m=p.parentNode;m.replaceChild(h,p),m.insertBefore(v,h),e.template.appendChild(p)}else{for(;p.firstChild;)e.template.appendChild(p.firstChild);p.appendChild(v),p.appendChild(h)}e.element=h,e.handler=qt.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!a){e.$outer={};var g="$key",y="$val";if(Array.isArray(r)){if(!r.$map){r.$map={el:1};var b=r.length,$=[];for(u=0;b>u;u++)$.push(A(u,r));r.$proxy=$}r.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var x=r.$events,w=(x||{})[xt];E(w,e),"object"===i?(e.$with=!0,r.$proxy||(r.$proxy={}),e.handler("append",r)):r.length&&e.handler("add",0,r.length)}},qt.repeat=function(e,t,n){if(e){var a,r,o=this,l=o.element,s=st(o),c=l.parentNode,u=Rt.cloneNode(!1);switch(e){case"add":for(var f=t+n,p=[],d=o.$repeat,v=t;f>v;v++){var h=d.$proxy[v];h.$outer=o.$outer,lt(o,u,h,p)}for(c.insertBefore(u,s[t]||l),v=0;r=p[v++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null;break;case"del":ct(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&ct(a,l);break;case"move":if(a=s[0]){var m,g=a.nodeValue,y=[],b=[];for(ct(a,l,function(){b.unshift(this),this.nodeValue===g&&(y.unshift(b),b=[])}),k(y,t);b=y.shift();)for(;m=b.shift();)u.appendChild(m);c.insertBefore(u,l)}break;case"append":var $=t,x=$.$proxy,w=[];p=[];for(var C in x)$.hasOwnProperty(C)||(dt(x[C],$a),delete x[C]);for(C in $)$.hasOwnProperty(C)&&"hasOwnProperty"!==C&&"$proxy"!==C&&w.push(C);if(o.sortedCallback){var T=o.sortedCallback.call(c,w);T&&Array.isArray(T)&&T.length&&(w=T)}for(v=0;C=w[v++];)"hasOwnProperty"!==C&&(x[C]=ft(x[C],C,o),lt(o,u,x[C],p));for(c.insertBefore(u,l),v=0;r=p[v++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null}"clear"===e&&(e="del");var A=o.renderedCallback||i,E=arguments;z(c,function(){A.apply(c,E),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(Tt,function(e){Ut[e]=Ut.repeat}),avalon.pool=fn;var $a=[];qt.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=vt,Ut.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=vt(n[0].nodeName)),r.visibility=i?o:""}e.display=a,q(e.value,t,e)},qt.visible=function(e,t,n){t.style.display=e?n.display:"none"},Ut.widget=function(t,a){var r=t.value.match(Tt),o=t.element,l=r[0],s=r[1];s&&"$"!==s||(s=Bt(l));var c=r[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,p=0;f=a[p++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var d=f[c];d=d.$model||d;break}if(d){var v=d[l+"Id"];"string"==typeof v&&(n("warning!不再支持"+l+"Id"),s=v)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=i,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,d||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,W(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},N(t,xa),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(j)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var xa=[],wa=/]*>([\S\s]*?)<\/script\s*>/gim,Ca=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,ka=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,Ta={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},Aa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ea=/([^\#-~| |!])/g,Oa=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof 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:D,sanitize:function(e){return e.replace(wa,"").replace(ka,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=Ta[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(Ca," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(Aa,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Ea,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+ht(e,isFinite(n)?n:2)},number:ht};!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.length0||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+)\)\/$/;Oa.date=function(t,n){var a,r,i=Oa.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,Oa.date.locate=c};var Ma=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Ma.exports=Ma.avalon,new function(){function t(e,t){var 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=Ma[t],r=t&&e.urlNoQuery;if(a&&a.state>=1)return t;if(a=Ma[r],a&&a.state>=3)return bt(a.deps||[],a.factory,r),r;if(t&&!a){a=Ma[r]={id:r,state:1};var i=function(r){H[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,c()})};H[n]?i(H[n]):bt([n],i)}return t?r:n+"!"}function l(e,t){for(var n,a=0;n=e[a++];)if(4!==Ma[n].state&&(n===t||l(Ma[n].deps,t)))return!0}function s(e,t){var a=p(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){yt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Ma[a].state)):!0}function c(){e:for(var e,t=T.length;e=T[--t];){var n=Ma[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++)if(4!==Object(Ma[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=gt.createElement("script");r.className=xt,r.onload=function(){var r=A.pop();r&&r.require(t),a&&a(),n("debug: 已成功加载 "+e),t&&T.push(t),c()},r.onerror=function(){s(r,!0)},yt.insertBefore(r,yt.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=yt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===xt&&"interactive"===n.readyState){var o=n.src;return n.className=p(o)}}function h(t,a,i){var o=Object(Ma[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(Ma[l].exports);try{var f=i.apply(e,c)}catch(p){n("执行["+t+"]模块的factory抛错: "+p)}return void 0!==f&&(o.exports=f),_.test(t)&&delete Ma[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&&k(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 k(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var T=[],A=[],E=/\.js$/i,O=[],M=!1;bt=avalon.require=function(e,n,a,l){if(M){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=Ma[p];h&&4===h.state||(Ma[p]={id:p,deps:d?e.concat():s,factory:n||i,state:3}),h||T.push(p),c()}else if(O.push(avalon.slice(arguments)),arguments.length<=2){M=!0;for(var m,g=O.splice(0,O.length);m=g.shift();)bt.apply(null,m)}},bt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var a={built:!M,defineName:e},r=[t,n,a];n.require=function(e){if(r.splice(2,0,e),Ma[e]){Ma[e].state=3;var t=!1;try{t=l(Ma[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,bt.apply(null,r)};var i=a.built?"unknown":v();if(i){var o=Ma[i];o&&(o.state=2),n.require(i)}else A.push(n)},bt.config=u,bt.define.amd=Ma;var N=u["orig.paths"]=r(),j=u["orig.map"]=r(),S=u.packages=[],L=u["orig.args"]=r();avalon.mix(tn,{paths:function(e){avalon.mix(N,e),u.paths=g(N)},map:function(e){avalon.mix(j,e);var t=g(j,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),u.map=t},packages:function(e){e=e.concat(S);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=C(t.location||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(L,e),u.urlArgs=g(L,1)},baseUrl:function(e){if(!d(e)){var t=yt.getElementsByTagName("base")[0];t&&yt.removeChild(t);var n=gt.createElement("a");n.href=e,e=n.href,t&&yt.insertBefore(t,yt.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 H=bt.plugins={ready:{load:i},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(E,"")];i?bt(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;yt.insertAdjacentHTML("afterBegin",''),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=pa();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+r),a(i.responseText))};var o="_="+(new Date-0),l=-1===r.indexOf("?")?r+"?"+o:r+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};bt.checkDeps=c;var D=/(\?[^#]*)$/,_=/^callback\d+$/,R=/\/\w+\/\.\./,P=gt.scripts[gt.scripts.length-1],I=P.getAttribute("data-main");if(I){tn.baseUrl(I);var B=u.baseUrl;u.baseUrl=B.slice(0,B.lastIndexOf("/")+1),f(B.replace(E,"")+".js")}else{var F=p(P.src);u.baseUrl=F.slice(0,F.lastIndexOf("/")+1)}};var Na,ja=[],Sa=function(e){for(Na=!0,bt&&(Ma["domReady!"].state=4,bt.checkDeps());e=ja.shift();)e(avalon)};"complete"===gt.readyState?setTimeout(Sa):gt.addEventListener("DOMContentLoaded",Sa),e.addEventListener("load",Sa),avalon.ready=function(e){Na?e(avalon):ja.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(gt.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var La=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=La),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file +!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(kt)||[]);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=jt.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=gt.createElementNS(Wt,n.tagName.toLowerCase());St.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(Nt.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(en,"\\$&")}function p(e,t,n){if(Array.isArray(e)){var a=e.concat();e.length=0;var i=x(e);return i.pushArray(a),i}if(!e||e.nodeType>0||e.$id&&e.$events)return e;var o=Array.isArray(e.$skipArray)?e.$skipArray:[];o.$special=t||r();var l={};n=n||{};var s=r(),c=r(),u=[];on.forEach(function(t){delete e[t]});for(var f in e)!function(e,t,a){if(n[e]=t,$(e,t,o)){s[e]=[];var r=avalon.type(t);"object"===r&&Vt(t.get)&&Object.keys(t).length<=2?(a=d(e,t),u.push(a)):a=At.test(r)?h(e,t,r,s[e]):v(e,t),c[e]=a}}(f,e[f]);l=Object.defineProperties(l,sn(c));for(var p in e)c[p]||(l[p]=e[p]);l.$id=Bt(),l.$model=n,l.$events=s;for(f in an)l[f]=an[f];return Object.defineProperty(l,"hasOwnProperty",{value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0}),l.$compute=function(){u.forEach(function(e){pn.begin({callback:function(t,n){var a=n._name;if(n!==e){var r=t.$events[a];e.vm=l,E(r,e.digest)}}});try{e.get.call(l)}finally{pn.end()}})},l.$compute(),l}function v(e,t){function n(e){var t=n._value;return arguments.length>0?(Tt||ln(e,t)||(n.updateValue(this,e),n.notify(this,e,t)),this):(pn.collectDependency(this,n),t)}return b(n,e),n._value=t,n}function d(e,t){function n(e){var t=n._value,a="_value"in n;return arguments.length>0?Tt?this:(n.set.call(this,e),this):(e=n.get.call(this),t!==e&&(n.updateValue(this,e),a&&n.notify(this,e,t)),e)}t.set=t.set||i,n.set=t.set||i,n.get=t.get,b(n,e);var a;return n.digest=function(){n.updateValue=g,n.notify=i,n.call(n.vm),clearTimeout(a),a=setTimeout(function(){b(n,n._name),n.call(n.vm)})},n}function h(e,t,n,a){function r(t){var a=r._value,i=r._vmodel;if(arguments.length>0){if(Tt)return this;if("array"===n){var o=i._;i._=[],i.clear(),i._=o,i.pushArray(t)}else if("object"===n){var l=i.$proxy,s=this.$events[e]||[];i=r._vmodel=p(t),i.$proxy=l,s.length&&(s.forEach(function(e){var t=zt[e.type];t&&(e.rollback&&e.rollback(),t(e,e.vmodels))}),i.$events[e]=s)}return r.updateValue(this,i.$model),r.notify(this,this._value,a),this}return pn.collectDependency(this,r),i}b(r,e);var i=r._vmodel=p(t);return i.$events[xt]=a,r}function m(e,t){e.$model[this._name]=this._value=t}function g(e,t){e.$model[this._name]=t}function y(e,t,n){var a=this._name,r=e.$events[a];r&&(O(r),an.$fire.call(e,a,t,n))}function b(e,t){e._name=t,e.updateValue=m,e.notify=y}function $(e,t,n){if(Vt(t)||t&&t.nodeType)return!1;if(-1!==n.indexOf(e))return!1;var a=n.$special;return e&&"$"===e.charAt(0)&&!a[e]?!1:!0}function x(e){var t=[];t.$id=Bt(),t.$model=e,t.$events={},t.$events[xt]=[],t._=p({length:e.length}),t._.$watch("length",function(e,n){t.$fire("length",e,n)});for(var n in an)t[n]=an[n];return t.$map={el:1},t.$proxy=[],avalon.mix(t,un),t}function w(e,t,n,a,r,i,o){for(var l=this.length,s=2;--s;){switch(e){case"add":var c=t+n,u=this.$model.slice(t,c).map(function(e){return At.test(avalon.type(e))?e.$id?e:p(e,0,e):e});cn.apply(this,[t,0].concat(u));for(var f=t;c>f;f++){var v=A(f,this);this.$proxy.splice(f,0,v)}this._fire("add",t,n);break;case"del":var d=this._splice(t,n),h=this.$proxy.splice(t,n);pt(h,"each"),this._fire("del",t,n)}r&&(e=r,t=i,n=o,s=2,r=0)}return C(this.$proxy,a),this.length!==l&&(this._.length=this.length),d}function C(e,t){for(var n,a=e.length-1;n=e[t];t++)n.$index=t,n.$first=0===t,n.$last=t===a}function T(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 k(){var e={$index:0/0,$first:0/0,$last:0/0,$map:{},$host:{},$outer:{},$remove:avalon.noop,el:{get:function(){return this.$host[this.$index]},set:function(e){this.$host.set(this.$index,e)}}},t={$last:1,$first:1,$index:1},n=p(e,t);return n.$id=Bt("$proxy$each"),n}function A(e,t){var n=fn.shift();n?n.$compute():n=k();var a=t.length-1;return n.$host=t,n.$index=e,n.$first=0===e,n.$last=e===a,n.$map=t.$map,n.$remove=function(){return t.removeAt(n.$index)},n}function E(e,t){t=t||Ht[mt],e&&t&&avalon.Array.ensure(e,t)&&t.element&&N(t,e)}function O(e){if(e&&e.length){new Date-mn>444&&"object"==typeof e[0]&&j();for(var t,n=Lt.call(arguments,1),a=e.length;t=e[--a];){var r=t.element;if(r&&r.parentNode)try{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)}}catch(l){}}}}function M(e){return e.uniqueNumber||(e.uniqueNumber=++dn)}function N(e,t){var n=e.element;e.uuid||(e.uuid=1!==n.nodeType?e.type+(e.pos||0)+"-"+M(n.parentNode):e.name+"-"+M(n));var a=e.lists||(e.lists=[]);avalon.Array.ensure(a,t),t.$uuid=t.$uuid||Bt(),hn[e.uuid]||(hn[e.uuid]=1,hn.push(e))}function j(e){if(!avalon.optimize){for(var t=hn.length,n=t,a=[],r={},i={};e=hn[--t];){var o=e.type;i[o]?i[o]++:(i[o]=1,a.push(o))}var l=!1;if(a.forEach(function(e){gn[e]!==i[e]&&(r[e]=1,l=!0)}),t=n,l)for(;e=hn[--t];)if(e.element&&r[e.type]&&L(e.element)){hn.splice(t,1),delete hn[e.uuid];for(var s,c=e.lists,u=0;s=c[u++];)avalon.Array.remove(c,s),avalon.Array.remove(s,e);S(e)}gn=i,mn=new Date}}function S(e){e.element=null,e.rollback&&e.rollback();for(var t in e)e[t]=null}function L(e){try{if(!e.parentNode)return!0}catch(t){return!0}return e.msRetain?0:1===e.nodeType?!_t.contains(e):!avalon.contains(_t,e)}function H(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function D(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}function _(e){try{if("object"==typeof e)return e;e="true"===e?!0:"false"===e?!1:"null"===e?null:+e+""===e?+e:Tn.test(e)?JSON.parse(e):e}catch(t){}return e}function R(e){return e.window&&e.document?e:9===e.nodeType?e.defaultView:!1}function P(e,t){if(e.offsetWidth<=0){var n=getComputedStyle(e,null);if(Mn.test(n.display)){var a={node:e};for(var r in On)a[r]=n[r],e.style[r]=On[r];t.push(a)}var i=e.parentNode;i&&1===i.nodeType&&P(i,t)}}function I(e){var t=e.tagName.toLowerCase();return"input"===t&&/checkbox|radio/.test(e.type)?"checked":t}function B(e,t,n,a){for(var r,i=[],o=" = "+n+".",l=/\$proxy\$each/.test(t.$id),s=e.length;r=e[--s];){var c=l&&t.$map[r]?"el":r;t.hasOwnProperty(c)&&(i.push(r+o+c),a.vars.push(r),"duplex"===a.type&&(e.get=n+"."+c),e.splice(s,1))}return i}function F(e){for(var t=[],n={},a=0;av;v++)if(s.length){var h="vm"+mt+"_"+v;u.push(h),f.push(t[v]),c.push.apply(c,B(s,t[v],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=Ft?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,delete a.vars;var m=Bn.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"+mt+" = "+e+";\r\n",e+=V("ret"+mt,o)}else{if("duplex"===r){var g="'use strict';\nreturn function(vvv){\n "+p+";\n if(!arguments.length){\n return "+e+"\n }\n "+(Fn.test(e)?e:s.get)+"= vvv;\n} ";try{m=Function.apply(i,u.concat(g)),a.evaluator=Bn.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=Bn.put(l,m)}catch(y){n("debug: parse error,"+y.message)}finally{s=c=u=null}}}function U(e,t,n,a,r){Array.isArray(a)&&(e=a.map(function(e){return e.expr?"("+e.value+")":jn(e.value)}).join(" + ")),z(e,t,n),n.evaluator&&!r&&(n.handler=Ut[n.handlerName||n.type],avalon.injectBinding(n))}function q(e,t,n){var a=setTimeout(function(){var r=e.innerHTML;clearTimeout(a),r===n?t():q(e,t,r)})}function W(e,t){var n=e.getAttribute("avalonctrl")||t.$id;e.setAttribute("avalonctrl",n),t.$events.expr=e.tagName+'[avalonctrl="'+n+'"]'}function X(e,t){for(var n,a=0;n=e[a++];)n.vmodels=t,zt[n.type](n,t),n.evaluator&&n.element&&1===n.element.nodeType&&n.element.removeAttribute(n.name);e.length=0}function Y(e,t){return e.priority-t.priority}function G(e,t,a){var i=!0;if(t.length){for(var o,l=e.attributes,s=[],c=[],u=r(),f=0;o=l[f++];)if(o.specified&&(a=o.name.match(Jn))){var p=a[1],v=a[2]||"",d=o.value,h=o.name;if(Kn[p]?(v=p,p="on"):ea[p]&&("enabled"===p&&(n("warning!ms-enabled或ms-attr-enabled已经被废弃"),p="disabled",d="!("+d+")"),v=p,p="attr",h="ms-"+p+"-"+v,c.push([o.name,h,d])),u[h]=d,"function"==typeof zt[p]){var m={type:p,param:v,element:e,name:h,value:d,priority:(Qn[p]||10*p.charCodeAt(0))+(Number(v.replace(/\D/g,""))||0)};if("html"===p||"text"===p){var g=et(d);avalon.mix(m,g),m.filters=m.filters.replace(aa,function(){return m.type="html",m.group=1,""})}else if("duplex"===p)var y=h;else"ms-if-loop"===h&&(m.priority+=100);s.push(m),"widget"===p&&(e.msData=e.msData||u)}}if(s.length){s.sort(Y),c.forEach(function(t){n("warning!请改用"+t[1]+"代替"+t[0]+"!"),e.removeAttribute(t[0]),e.setAttribute(t[1],t[2])});var b=e.type;for(b&&y&&(u["ms-attr-checked"]&&n("warning!"+b+"控件不能同时定义ms-attr-checked与"+y),u["ms-attr-value"]&&n("warning!"+b+"控件不能同时定义ms-attr-value与"+y)),f=0;m=s[f];f++){if(p=m.type,ta.test(p))return X(s.slice(0,f+1),t);i&&(i=!na.test(p))}X(s,t)}}i&&!Yn[e.tagName]&&Kt.test(e.innerHTML+e.textContent)&&(Zn&&Zn(e),Z(e,t))}function Z(e,t){var n=avalon.slice(e.childNodes);J(n,t)}function J(e,t){for(var n,a=0;n=e[a++];)Q(n,n.nodeType,t)}function Q(e,t,n){1===t?(K(e,n),e.msCallback&&(e.msCallback(),e.msCallback=void 0)):3===t&&Jt.test(e.data)?nt(e,n):u.commentInterpolate&&8===t&&!Jt.test(e.nodeValue)&&nt(e,n)}function K(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),W(e,o)}G(e,t)}}function et(e,t){if(e.indexOf("|")>0){var n=e.replace(ia,function(e){return Array(e.length+1).join("1")}),a=n.replace(ra,"ᄢ㍄").indexOf("|");if(a>-1)return{filters:e.slice(a),value:e.slice(0,a),pos:t||0,expr:!0}}return{value:e,filters:"",expr:!0}}function tt(e){for(var t,n,a=[],r=0;;){if(n=e.indexOf(Gt,r),-1===n)break;if(t=e.slice(r,n),t&&a.push({value:t,filters:"",expr:!1}),r=n+Gt.length,n=e.indexOf(Zt,r),-1===n)break;t=e.slice(r,n),t&&a.push(et(t,r)),r=n+Zt.length}return t=e.slice(r),t&&a.push({value:t,expr:!1,filters:""}),a}function nt(e,t){var n=[];if(8===e.nodeType)var a=et(e.nodeValue),r=[a];else r=tt(e.data);if(r.length){for(var i=0;a=r[i++];){var o=gt.createTextNode(a.value);a.expr&&(a.type="text",a.element=o,a.filters=a.filters.replace(aa,function(){return a.type="html",""}),n.push(a)),Rt.appendChild(o)}e.parentNode.replaceChild(Rt,e),n.length&&X(n,t)}}function at(e,t,n){var a=e.templateCache&&e.templateCache[t];if(a){for(var r,i=gt.createDocumentFragment();r=a.firstChild;)i.appendChild(r);return i}return avalon.parseHTML(n)}function rt(e){return null==e?"":e}function it(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 ot(){for(var e=ma.length-1;e>=0;e--){var t=ma[e];t()===!1&&ma.splice(e,1)}ma.length||clearInterval(ha)}function lt(e,t,n,a){var r=e.template.cloneNode(!0),i=avalon.slice(r.childNodes);e.$with||r.insertBefore(gt.createComment(e.signature),r.firstChild),t.appendChild(r);var o=[n].concat(e.vmodels),l={nodes:i,vmodels:o};a.push(l)}function st(e){for(var t=e.element,n=t.nodeValue.replace(":end",""),a=t.previousSibling,r=[];a;)a.nodeValue===n&&r.unshift(a),a=a.previousSibling;return r}function ct(e,t,n){for(;;){var a=t.previousSibling;if(!a)break;if(a.parentNode.removeChild(a),n&&n.call(a),a===e)break}}function ut(){var e=p({$key:"",$outer:{},$host:{},$val:{get:function(){return this.$host[this.$key]},set:function(e){this.$host[this.$key]=e}}},{$val:1});return e.$id=Bt("$proxy$with"),e}function ft(e,t,n){e=e||$a.pop(),e||(e=ut());var a=n.$repeat;return e.$key=t,e.$host=a,e.$outer=n.$outer,a.$events?e.$events.$val=a.$events[t]:e.$events={},e}function pt(e){e.forEach(function(e){vt(e,fn)}),e.length=0}function vt(e,t){for(var n in e.$events)Array.isArray(e.$events[n])&&(e.$events[n].forEach(function(e){"object"==typeof e&&S(e)}),e.$events[n].length=0);e.$host=e.$outer={},t.unshift(e)>u.maxRepeatSize&&t.pop()}function dt(e,t){var n="_"+e;if(!dt[n]){var a=gt.createElement(e);_t.appendChild(a),t=Dt?getComputedStyle(a,null).display:a.currentStyle.display,_t.removeChild(a),dt[n]=t}return dt[n]}function ht(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');var bt,$t=yt.firstChild,xt="$"+mt,wt=e.require,Ct=e.define,Tt=!1,kt=/[^, ]+/g,At=/^(?:object|array)$/,Et=/^\[object SVG\w*Element\]$/,Ot=/^\[object (?:Window|DOMWindow|global)\]$/,Mt=Object.prototype,Nt=Mt.hasOwnProperty,jt=Mt.toString,St=Array.prototype,Lt=St.slice,Ht={},Dt=e.dispatchEvent,_t=gt.documentElement,Rt=gt.createDocumentFragment(),Pt=gt.createElement("div"),It={};"Boolean Number String Function Array Date RegExp Object Error".replace(kt,function(e){It["[object "+e+"]"]=e.toLowerCase()});var Bt=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},Ft=l();avalon=function(e){return new avalon.init(e)},avalon.profile=function(){e.console&&avalon.config.profile&&Function.apply.call(console.log,console,arguments)},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=Dt&&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?It[jt.call(e)]||"object":typeof e};var Vt=function(e){return"[object Function]"===jt.call(e)};avalon.isFunction=Vt,avalon.isWindow=function(e){return Ot.test(jt.call(e))},avalon.isPlainObject=function(e){return"[object Object]"===jt.call(e)&&Object.getPrototypeOf(e)===Mt},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||Vt(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:kt,subscribers:xt,version:1.44,ui:{},log:n,slice:function(e,t,n){return Lt.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);++an&&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 zt=avalon.bindingHandlers={},Ut=avalon.bindingExecutors={},qt=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}var t=e.prototype;return t.put=function(e,t){var n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){var e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0)},t.get=function(e){var t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(gt.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 Wt="http://www.w3.org/2000/svg",Xt=gt.createElementNS(Wt,"svg");Xt.innerHTML='',Et.test(Xt.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=gt.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("$","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 Yt=avalon.eventHooks;"onmouseenter"in _t||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){Yt[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]&&!Yt.animationend&&(Yt.animationend={type:n})}),void 0===gt.onmousewheel&&(Yt.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 Gt,Zt,Jt,Qt,Kt,en=/[-.*+?^${}()|[\]\/\\]/g,tn={loader:function(t){var n=bt&&t;e.require=n?bt:wt,e.define=n?bt.define:Ct},interpolate:function(e){if(Gt=e[0],Zt=e[1],Gt===Zt)throw new SyntaxError("openTag!==closeTag");if(e+""=="")u.commentInterpolate=!0;else{var t=Gt+"test"+Zt;if(Pt.innerHTML=t,Pt.innerHTML!==t&&Pt.innerHTML.indexOf("<")>-1)throw new SyntaxError("此定界符不合法");Pt.innerHTML=""}var n=f(Gt),a=f(Zt);Jt=new RegExp(n+"(.*?)"+a),Qt=new RegExp(n+"(.*?)"+a,"g"),Kt=new RegExp(n+".*?"+a+"|\\sms-")}};u.debug=!0,u.plugins=tn,u.plugins.interpolate(["{{","}}"]),u.paths={},u.shim={},u.maxRepeatSize=100,avalon.config=u;var nn=function(e){return gt.querySelectorAll(e)},an={$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=Lt.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?nn(i.expr):[];if(0===s.length)return;for(n in avalon.vmodels)if(a=avalon.vmodels[n],a!==this&&a.$events.expr){var c=nn(a.$events.expr);if(0===c.length)continue;St.forEach.call(c,function(e){St.forEach.call(s,function(n){var r="down"===t?n.contains(e):e.contains(n);r&&(e._avalon=a)})})}var u=gt.getElementsByTagName("*"),f=[];for(St.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++];)Vt(r)&&r.apply(this,o);for(n=0;r=v[n++];)Vt(r)&&r.apply(this,arguments)}}}},rn=avalon.vmodels={};avalon.define=function(e,t){var a=e.$id||e;if(a||n("warning: vm必须指定$id"),rn[a]&&n("warning: "+a+" 已经存在于avalon.vmodels中"),"object"==typeof e)var r=p(e);else{var o={$watch:i};t(o),r=p(o),Tt=!0,t(r),Tt=!1}return r.$id=a,rn[a]=r};var on=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(kt),ln=Object.is||function(e,t){return 0===e&&0===t?1/e===1/t:e!==e?t!==t:e===t},sn=function(e){var t={};for(var n in e)t[n]={get:e[n],set:e[n],enumerable:!0,configurable:!0};return t},cn=St.splice,un={_splice:cn,_fire:function(e,t,n){O(this.$events[xt],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(St.push.apply(this.$model,e),w.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&&(St.unshift.apply(this.$model,arguments),w.call(this,"add",0,e,0)),e+t},shift:function(){if(this.length){var e=this.$model.shift();return w.call(this,"del",0,1,0),e}},pop:function(){var e=this.length;if(e){var t=this.$model.pop();return w.call(this,"del",e-1,1,Math.max(0,e-2)),t}},splice:function(e){var t,n=arguments.length,a=[],r=cn.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?w.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),w.call(this,"del",e,1,0)):[]},clear:function(){return pt(this.$proxy,"each"),this.$model.length=this.$proxy.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&this.removeAt(t);else if("function"==typeof e)for(t=this.length-1;t>=0;t--)e(this[t],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 if("array"===n)a.clear().push.apply(a,t);else if(a!==t){this[e]=t,this.$model[e]=t;var i=this.$proxy[e];i&&O(i.$events.$index)}}return this}};"sort,reverse".replace(kt,function(e){un[e]=function(){var t,n=this.$model,a=n.concat(),r=Math.random(),i=[];St[e].apply(n,arguments);for(var o=0,l=a.length;l>o;o++){var s=n[o],c=a[o];if(ln(s,c))i.push(o);else{var u=a.indexOf(s);i.push(u),a[u]=r,t=!0}}return t&&(T(this,i),T(this.$proxy,i),this._fire("move",i),C(this.$proxy,0)),this}});var fn=[],pn=function(){var e,t=[];return{begin:function(n){t.push(e),e=n},end:function(){e=t.pop()},collectDependency:function(t,n){e&&e.callback(t,n)}}}(),vn=/^(duplex|on)$/;avalon.injectBinding=function(e){var t=e.evaluator;if(t){pn.begin({callback:function(t,n){E(t.$events[n._name],e)}});try{var n=vn.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(gt.createComment(e.value),r):r.data=Gt+e.value+Zt}}finally{pn.end()}}};var dn=0,hn=avalon.$$subscribers=[],mn=new Date,gn={},yn=new function(){avalon.mix(this,{option:gt.createElement("select"),thead:gt.createElement("table"),td:gt.createElement("tr"),area:gt.createElement("map"),tr:gt.createElement("tbody"),col:gt.createElement("colgroup"),legend:gt.createElement("fieldset"),_default:gt.createElement("div"),g:gt.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(kt,function(e){yn[e]=yn.g});var bn=/<([\w:]+)/,$n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,xn=o(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),wn=gt.createElement("script"),Cn=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=Rt.cloneNode(!1);if("string"!=typeof e)return t;if(!Cn.test(e))return t.appendChild(gt.createTextNode(e)),t;e=e.replace($n,"<$1>").trim();var n,a=(bn.exec(e)||["",""])[1].toLowerCase(),r=yn[a]||yn._default;r.innerHTML=e;var i=r.getElementsByTagName("script");if(i.length)for(var o,l=0;o=i[l++];)if(xn[o.type]){var s=wn.cloneNode(!1);St.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},"add,remove".replace(kt,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=String(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-"+H(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return _(n);case 0:var a={};return St.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=D(e.slice(5)),a[e]=_(t.value)))}),a}},removeData:function(e){return e="data-"+H(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),a.top-=e.scrollTop(),a.left-=e.scrollLeft()),{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||_t)},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=Nn[I(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}}),_t.dataset&&(avalon.fn.data=function(e,t){e=e&&D(e);var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return t=n[e],_(t);case 0:var a=r();for(e in n)a[e]=_(n[e]);return a}});var Tn=/(?:\{[\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=R(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 kn=avalon.cssHooks=r(),An=["","-webkit-","-moz-","-ms-"],En={"float":"cssFloat"};avalon.cssNumber=o("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(En[e])return En[e];t=t||_t.style;for(var a=0,r=An.length;r>a;a++)if(n=D(An[a]+e),n in t)return En[e]=n;return null},kn["@:set"]=function(e,t,n){e.style[t]=n},kn["@: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},kn["opacity:get"]=function(e){var t=kn["@:get"](e,"opacity");return""===t?"1":t},"top,left".replace(kt,function(e){kn[e+":get"]=function(t){var n=kn["@:get"](t,e);return/px$/.test(n)?n:avalon(t).position()[e]+"px"}});var On={position:"absolute",visibility:"hidden",display:"block"},Mn=/^(none|table(?!-c[ea]).+)/;"Width,Height".replace(kt,function(e){var t=e.toLowerCase(),n="client"+e,a="scroll"+e,r="offset"+e;kn[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) +},kn[t+"&get"]=function(e){var n=[];P(e,n);for(var a,r=kn[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 kn[t+"&get"](o)}return this.css(t,i)},avalon.fn["inner"+e]=function(){return kn[t+":get"](this[0],void 0,-2)},avalon.fn["outer"+e]=function(e){return kn[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 Nn={"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)}},jn=JSON.stringify,Sn=["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(","),Ln=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,Hn=/[^\w$]+/g,Dn=new RegExp(["\\b"+Sn.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),_n=/\b\d[^,]*/g,Rn=/^,+|,+$/g,Pn=new qt(512),In=function(e){var t=","+e.trim(),n=Pn.get(t);if(n)return n;var a=e.replace(Ln,"").replace(Hn,",").replace(Dn,"").replace(_n,"").replace(Rn,"").split(/^$|,+/);return Pn.put(t,F(a))},Bn=new qt(128),Fn=/\w\[.*\]|\w\.\w/,Vn=/(\$proxy\$[a-z]+)\d+$/,zn=/\)\s*$/,Un=/\)\s*\|/g,qn=/\|\s*([$\w]+)/g,Wn=/"\s*\["/g,Xn=/"\s*\(/g;avalon.parseExprProxy=U,avalon.scan=function(e,t){e=e||_t;var n=t?[].concat(t):[];K(e,n)};var Yn=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]},Zn=Ft&&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,Jn=/ms-(\w+)-?(.*)/,Qn={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},Kn=o("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),ea=o("value,title,alt,checked,selected,disabled,readonly,enabled"),ta=/^if|widget|repeat$/,na=/^each|with|html|include$/,aa=/\|\s*html\s*/,ra=/\|\|/g,ia=/(['"])(\\\1|.)+?\1/g,oa=["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(","),la={};oa.replace(kt,function(e){la[e.toLowerCase()]=e});var sa={"accept-charset":"acceptCharset","char":"ch",charoff:"chOff","class":"className","for":"htmlFor","http-equiv":"httpEquiv"},ca=["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",");ca.replace(kt,function(e){sa[e.toLowerCase()]=e});var ua=/(?:[\s\S]+?)<\/noscript>/gim,fa=/([\s\S]+?)<\/noscript>/im,pa=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},va=avalon.templateCache={};zt.attr=function(e,t){var n=e.value.trim(),a=!0;if(n.indexOf(Gt)>-1&&n.indexOf(Zt)>2&&(a=!1,Jt.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=gt.createComment("ms-include"),e.endInclude=gt.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",U(n,t,e,a?0:tt(e.value))},Ut.attr=function(t,n,a){var r=a.type,i=a.param;if("css"===r)avalon(n).css(i,t);else if("attr"===r){var o=t===!1||null===t||void 0===t;!Dt&&sa[i]&&(i=sa[i]);var l=la[i];if("boolean"==typeof n[l]&&(n[l]=!!t,t||(o=!0)),o)return n.removeAttribute(i);var s=Et.test(n)?!1:gt.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,v=p?n.parentNode:n,d=function(e){if(f){var n=f.apply(v,[e].concat(c));"string"==typeof n&&(e=n)}u&&q(v,function(){u.call(v)},0/0);var r=a.includeLastID;if(a.templateCache&&r&&r!==t){var i=a.templateCache[r];i||(i=a.templateCache[r]=gt.createElement("div"),$t.appendChild(i))}for(a.includeLastID=t;;){var o=a.startInclude.nextSibling;if(!o||o===a.endInclude)break;v.removeChild(o),i&&i.appendChild(o)}var l=at(a,t,e),s=avalon.slice(l.childNodes);v.insertBefore(l,a.endInclude),J(s,c)};if("src"===a.param)if("string"==typeof va[t])avalon.nextTick(function(){d(va[t])});else if(Array.isArray(va[t]))va[t].push(d);else{var h=pa();h.onreadystatechange=function(){if(4===h.readyState){var e=h.status;if(e>=200&&300>e||304===e||1223===e){for(var n,a=h.responseText,r=0;n=va[t][r++];)n(a);va[t]=a}}},va[t]=[d],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:gt.getElementById(t);if(m){if("NOSCRIPT"===m.tagName&&!m.innerHTML&&!m.fixIE78){h=pa(),h.open("GET",location,!1),h.send(null);for(var g=gt.getElementsByTagName("noscript"),y=(h.responseText||"").match(ua)||[],b=y.length,$=0;b>$;$++){var x=g[$];x&&(x.style.display="none",x.fixIE78=(y[$].match(fa)||[""," "])[1])}}avalon.nextTick(function(){d(m.fixIE78||m.value||m.innerText||m.innerHTML)})}}}else if(_t.hasAttribute||"string"!=typeof t||"src"!==r&&"href"!==r||(t=t.replace(/&/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(kt,function(e){zt[e]=zt.attr}),zt["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),z(a,t,e),!e.evaluator)return n("debug: ms-class '"+(a||"").trim()+"' 不存在于VM中"),!1;e._evaluator=e.evaluator,e._args=e.args}var c=Jt.test(s);c||(e.immobileClass=s),U("",t,e,c?tt(s):0)}else e.immobileClass=e.oldStyle=e.param,U(i,t,e)},Ut["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(kt,function(e){zt[e]=zt["class"]}),Ut.data=function(e,t,n){var a="data-"+n.param;e&&"object"==typeof e?t[a]=e:t.setAttribute(a,String(e))};var da=zt.duplex=function(e,t){var a,r=e.element;if(U(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=it);f(null,e,"init");var p=r.tagName;da[p]&&da[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:rt},"boolean":{get:function(e){return"true"===e},set:rt},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:rt}};var ha,ma=[];avalon.tick=function(e){1===ma.push(e)&&(ha=setInterval(ot,60))};var ga=i,ya=/text|password|hidden/;!new function(){function e(e){if(avalon.optimize||this.parentNode){if(t[this.tagName].call(this,e),!ya.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){ga=avalon.tick}},da.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("duplexObserve")!==!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("duplexObserve")!==!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("duplexObserve")!==!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(kt,function(e){switch(e){case"input":s("input",f),s("DOMAutoComplete",f),Ft||(s("compositionstart",i),s("compositionend",o));break;default:s(e,f)}}),s("focus",function(){e.msFocus=!0}),s("blur",function(){e.msFocus=!1}),ya.test(l)&&ga(function(){if(avalon.optimize||e.parentNode)e.msFocus||e.oldValue===e.value||f();else if(!e.msRetain)return!1}),e.avalonSetter=f}e.oldValue=e.value,avalon.injectBinding(a),r.call(e,e.value)},da.TEXTAREA=da.INPUT,da.SELECT=function(e,t,a){function r(){if(i.data("duplexObserve")!==!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在不能对应一个数组"),a=Array.isArray(a)?a.map(String):a+"",a+""!==e.oldValue&&(i.val(a),e.oldValue=a+"")},a.bound("change",r),e.msCallback=function(){avalon.injectBinding(a),a.changed.call(e,t(),a)}},Ut.html=function(e,t,n){var a=1!==t.nodeType,r=a?t.parentNode:t;if(r&&(e=null==e?"":e,n.oldText!==e)){if(n.oldText=e,3===t.nodeType){var i=Bt("html");r.insertBefore(gt.createComment(i),t),n.element=gt.createComment(i+":end"),r.replaceChild(n.element,t),t=n.element}if("object"!=typeof e)var o=avalon.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var l=1===e.nodeType?e.childNodes:e.item;for(o=Rt.cloneNode(!0);l[0];)o.appendChild(l[0])}if(l=avalon.slice(o.childNodes),a){for(var s=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===s)break;r.removeChild(c)}r.insertBefore(o,t)}else avalon.clearHTML(t).appendChild(o);J(l,n.vmodels)}},zt["if"]=zt.data=zt.text=zt.html=function(e,t){U(e.value,t,e)},Ut["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(a){return}if(e)8===t.nodeType&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),G(t,n.vmodels)),n.rollback=null;else if(1===t.nodeType){var r=n.element=gt.createComment("ms-if");t.parentNode.replaceChild(r,t),n.template=t,$t.appendChild(t),n.rollback=function(){t.parentNode===$t&&$t.removeChild(t)}}};var ba=/\(([^)]*)\)/;zt.on=function(e,t){var n=e.value;e.type="on";var a=e.param.replace(/-\d+$/,"");if("function"==typeof zt.on[a+"Hook"]&&zt.on[a+"Hook"](e),n.indexOf("(")>0&&n.indexOf(")")>-1){var r=(n.match(ba)||["",""])[1].trim();(""===r||"$event"===r)&&(n=n.replace(ba,""))}U(n,t,e)},Ut.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)}},zt.repeat=function(e,t){var n=e.type;U(e.value,t,e,0,1);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[xt]=f[xt]||[],f[xt].push(e);break}}var p=e.element;if(1===p.nodeType){p.removeAttribute(e.name),e.sortedCallback=Gn(p,"data-with-sorted",t),e.renderedCallback=Gn(p,"data-"+n+"-rendered",t);var v=Bt(n),d=gt.createComment(v),h=gt.createComment(v+":end");if(e.signature=v,e.template=Rt.cloneNode(!1),"repeat"===n){var m=p.parentNode;m.replaceChild(h,p),m.insertBefore(d,h),e.template.appendChild(p)}else{for(;p.firstChild;)e.template.appendChild(p.firstChild);p.appendChild(d),p.appendChild(h)}e.element=h,e.handler=Ut.repeat,e.rollback=function(){var t=e.element;t&&e.handler("clear")}}if(!a){e.$outer={};var g="$key",y="$val";if(Array.isArray(r)){if(!r.$map){r.$map={el:1};var b=r.length,$=[];for(u=0;b>u;u++)$.push(A(u,r));r.$proxy=$}r.$map[e.param||"el"]=1,g="$first",y="$last"}for(u=0;s=t[u++];)if(s.hasOwnProperty(g)&&s.hasOwnProperty(y)){e.$outer=s;break}var x=r.$events,w=(x||{})[xt];E(w,e),"object"===i?(e.$with=!0,r.$proxy||(r.$proxy={}),e.handler("append",r)):r.length&&e.handler("add",0,r.length)}},Ut.repeat=function(e,t,n){if(e){var a,r,o=this,l=o.element,s=st(o),c=l.parentNode,u=Rt.cloneNode(!1);switch(e){case"add":for(var f=t+n,p=[],v=o.$repeat,d=t;f>d;d++){var h=v.$proxy[d];h.$outer=o.$outer,lt(o,u,h,p)}var m=new Date-0;for(avalon.optimize=avalon.optimize||m,d=0;r=p[d++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null;avalon.optimize===m&&delete avalon.optimize,c.insertBefore(u,s[t]||l),avalon.profile("插入操作花费了 "+(new Date-m));break;case"del":ct(s[t],s[t+n]||l);break;case"clear":a=s[0],a&&ct(a,l);break;case"move":if(a=s[0]){var g,y=a.nodeValue,b=[],$=[];for(ct(a,l,function(){$.unshift(this),this.nodeValue===y&&(b.unshift($),$=[])}),T(b,t);$=b.shift();)for(;g=$.shift();)u.appendChild(g);c.insertBefore(u,l)}break;case"append":var x=t,w=x.$proxy,C=[];p=[];for(var k in w)x.hasOwnProperty(k)||(vt(w[k],$a),delete w[k]);for(k in x)x.hasOwnProperty(k)&&"hasOwnProperty"!==k&&"$proxy"!==k&&C.push(k);if(o.sortedCallback){var A=o.sortedCallback.call(c,C);A&&Array.isArray(A)&&A.length&&(C=A)}for(d=0;k=C[d++];)"hasOwnProperty"!==k&&(w[k]=ft(w[k],k,o),lt(o,u,w[k],p));for(c.insertBefore(u,l),d=0;r=p[d++];)J(r.nodes,r.vmodels),r.nodes=r.vmodels=null}"clear"===e&&(e="del");var E=o.renderedCallback||i,O=arguments;q(c,function(){E.apply(c,O),c.oldValue&&"SELECT"===c.tagName&&avalon(c).val(c.oldValue.split(","))},0/0)}},"with,each".replace(kt,function(e){zt[e]=zt.repeat}),avalon.pool=fn;var $a=[];Ut.text=function(e,t){if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(n){}else t.textContent=e},avalon.parseDisplay=dt,zt.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=dt(n[0].nodeName)),r.visibility=i?o:""}e.display=a,U(e.value,t,e)},Ut.visible=function(e,t,n){t.style.display=e?n.display:"none"},zt.widget=function(t,a){var r=t.value.match(kt),o=t.element,l=r[0],s=r[1];s&&"$"!==s||(s=Bt(l));var c=r[2]||l,u=avalon.ui[l];if("function"==typeof u){a=o.vmodels||a;for(var f,p=0;f=a[p++];)if(f.hasOwnProperty(c)&&"object"==typeof f[c]){var v=f[c];v=v.$model||v;break}if(v){var d=v[l+"Id"];"string"==typeof d&&(n("warning!不再支持"+l+"Id"),s=d)}var h=avalon.getWidgetData(o,l);t.value=[l,s,c].join(","),t[l+"Id"]=s,t.evaluator=i,o.msData["ms-widget-id"]=s;var m=t[l+"Options"]=avalon.mix({},u.defaults,v||{},h);o.removeAttribute("ms-widget");var g=u(o,t,a)||{};if(g.$id){avalon.vmodels[s]=g,W(o,g);try{g.$init(function(){avalon.scan(o,[g].concat(a)),"function"==typeof m.onInit&&m.onInit.call(o,g,m,a)})}catch(y){}t.rollback=function(){try{g.widgetElement=null,g.$remove()}catch(e){}o.msData={},delete avalon.vmodels[g.$id]},N(t,xa),e.chrome&&o.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(j)})}else avalon.scan(o,a)}else a.length&&(o.vmodels=a)};var xa=[],wa=/]*>([\S\s]*?)<\/script\s*>/gim,Ca=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Ta=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,ka={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},Aa=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ea=/([^\#-~| |!])/g,Oa=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n="string"==typeof 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:D,sanitize:function(e){return e.replace(wa,"").replace(Ta,function(e){var t=e.toLowerCase().match(/<(\w+)\s/);if(t){var n=ka[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(Ca," ").replace(/\s+/g," ")})},escape:function(e){return String(e).replace(/&/g,"&").replace(Aa,function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1);return"&#"+(1024*(t-55296)+(n-56320)+65536)+";"}).replace(Ea,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(//g,">")},currency:function(e,t,n){return(t||"¥")+ht(e,isFinite(n)?n:2)},number:ht};!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.length0||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+)\)\/$/;Oa.date=function(t,n){var a,r,i=Oa.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,Oa.date.locate=c};var Ma=avalon.modules={"domReady!":{exports:avalon,state:3},avalon:{exports:avalon,state:4}};Ma.exports=Ma.avalon,new function(){function t(e,t){var 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=Ma[t],r=t&&e.urlNoQuery;if(a&&a.state>=1)return t;if(a=Ma[r],a&&a.state>=3)return bt(a.deps||[],a.factory,r),r;if(t&&!a){a=Ma[r]={id:r,state:1};var i=function(r){H[n]=r,r.load(t,e,function(e){arguments.length&&void 0!==e&&(a.exports=e),a.state=4,c()})};H[n]?i(H[n]):bt([n],i)}return t?r:n+"!"}function l(e,t){for(var n,a=0;n=e[a++];)if(4!==Ma[n].state&&(n===t||l(Ma[n].deps,t)))return!0}function s(e,t){var a=p(e.src);return e.onload=e.onerror=null,t?(setTimeout(function(){yt.removeChild(e),e=null}),void n("debug: 加载 "+a+" 失败"+t+" "+!Ma[a].state)):!0}function c(){e:for(var e,t=k.length;e=k[--t];){var n=Ma[e],a=n.deps;if(a){for(var r,i=0;r=a[i];i++)if(4!==Object(Ma[r]).state)continue e;4!==n.state&&(k.splice(t,1),h(n.id,n.deps,n.factory),c())}}}function f(e,t,a){var r=gt.createElement("script");r.className=xt,r.onload=function(){var r=A.pop();r&&r.require(t),a&&a(),n("debug: 已成功加载 "+e),t&&k.push(t),c()},r.onerror=function(){s(r,!0)},yt.insertBefore(r,yt.firstChild),r.src=e,n("debug: 正准备加载 "+e)}function p(e){return(e||"").replace(D,"")}function v(e){return/^(?:[a-z]+:)?\/\//i.test(String(e))}function d(){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=yt.getElementsByTagName("script"),i=r.length;n=r[--i];)if(n.className===xt&&"interactive"===n.readyState){var o=n.src;return n.className=p(o)}}function h(t,a,i){var o=Object(Ma[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(Ma[l].exports);try{var f=i.apply(e,c)}catch(p){n("执行["+t+"]模块的factory抛错: "+p)}return void 0!==f&&(o.exports=f),_.test(t)&&delete Ma[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)),v(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&&T(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 T(t){if(!t)return t;var n=e;return t.split(".").forEach(function(e){n=n[e]}),n}var k=[],A=[],E=/\.js$/i,O=[],M=!1;bt=avalon.require=function(e,n,a,l){if(M){Array.isArray(e)||avalon.error("require方法的第一个参数应为数组 "+e);var s=[],f=r(),p=a||"callback"+setTimeout("1");l=l||r(),l.baseUrl=u.baseUrl;var v=!!l.built;if(a&&(l.parentUrl=a.substr(0,a.lastIndexOf("/")),l.mapUrl=a.replace(E,"")),v){var d=t(l.defineName,l);p=d.urlNoQuery}else e.forEach(function(e){var n=t(e,l),a=o(n);a&&(f[a]||(s.push(a),f[a]="司徒正美"))});var h=Ma[p];h&&4===h.state||(Ma[p]={id:p,deps:v?e.concat():s,factory:n||i,state:3}),h||k.push(p),c()}else if(O.push(avalon.slice(arguments)),arguments.length<=2){M=!0;for(var m,g=O.splice(0,O.length);m=g.shift();)bt.apply(null,m)}},bt.define=function(e,t,n){"string"!=typeof e&&(n=t,t=e,e="anonymous"),Array.isArray(t)||(n=t,t=[]);var a={built:!M,defineName:e},r=[t,n,a];n.require=function(e){if(r.splice(2,0,e),Ma[e]){Ma[e].state=3;var t=!1;try{t=l(Ma[e].deps,e)}catch(a){}t&&avalon.error(e+"模块与之前的模块存在循环依赖,请不要直接用script标签引入"+e+"模块")}delete n.require,bt.apply(null,r)};var i=a.built?"unknown":d();if(i){var o=Ma[i];o&&(o.state=2),n.require(i)}else A.push(n)},bt.config=u,bt.define.amd=Ma;var N=u["orig.paths"]=r(),j=u["orig.map"]=r(),S=u.packages=[],L=u["orig.args"]=r();avalon.mix(tn,{paths:function(e){avalon.mix(N,e),u.paths=g(N)},map:function(e){avalon.mix(j,e);var t=g(j,1,1);avalon.each(t,function(e,t){t.val=g(t.val)}),u.map=t},packages:function(e){e=e.concat(S);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=C(t.location||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(L,e),u.urlArgs=g(L,1)},baseUrl:function(e){if(!v(e)){var t=yt.getElementsByTagName("base")[0];t&&yt.removeChild(t);var n=gt.createElement("a");n.href=e,e=n.href,t&&yt.insertBefore(t,yt.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 H=bt.plugins={ready:{load:i},js:{load:function(e,t,n){var a=t.url,r=t.urlNoQuery,i=u.shim[e.replace(E,"")];i?bt(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;yt.insertAdjacentHTML("afterBegin",''),n("debug: 已成功加载 "+r),a()}},text:{load:function(e,t,a){var r=t.url,i=pa();i.onload=function(){var e=i.status;e>399&&600>e?avalon.error(r+" 对应资源不存在或没有开启 CORS"):(n("debug: 已成功加载 "+r),a(i.responseText))};var o="_="+(new Date-0),l=-1===r.indexOf("?")?r+"?"+o:r+"&"+o;i.open("GET",l,!0),"withCredentials"in i&&(i.withCredentials=!0),i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.send(),n("debug: 正准备加载 "+r)}}};bt.checkDeps=c;var D=/(\?[^#]*)$/,_=/^callback\d+$/,R=/\/\w+\/\.\./,P=gt.scripts[gt.scripts.length-1],I=P.getAttribute("data-main");if(I){tn.baseUrl(I);var B=u.baseUrl;u.baseUrl=B.slice(0,B.lastIndexOf("/")+1),f(B.replace(E,"")+".js")}else{var F=p(P.src);u.baseUrl=F.slice(0,F.lastIndexOf("/")+1)}};var Na,ja=[],Sa=function(e){for(Na=!0,bt&&(Ma["domReady!"].state=4,bt.checkDeps());e=ja.shift();)e(avalon)};"complete"===gt.readyState?setTimeout(Sa):gt.addEventListener("DOMContentLoaded",Sa),e.addEventListener("load",Sa),avalon.ready=function(e){Na?e(avalon):ja.push(e)},avalon.config({loader:!0}),avalon.ready(function(){avalon.scan(gt.body)}),"function"==typeof define&&define.amd&&define("avalon",[],function(){return avalon});var La=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=La),avalon},void 0===t&&(e.avalon=avalon),avalon}); \ No newline at end of file diff --git a/dist/avalon.modern.shim.js b/dist/avalon.modern.shim.js index 1eccb6da1..d00771664 100644 --- a/dist/avalon.modern.shim.js +++ b/dist/avalon.modern.shim.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.modern.shim.js(无加载器版本) 1.44 built in 2015.6.16 + avalon.modern.shim.js(无加载器版本) 1.44 built in 2015.6.25 support IE10+ and other browsers ==================================================*/ (function(global, factory) { @@ -79,7 +79,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -101,7 +101,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -115,12 +115,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -140,14 +146,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -155,13 +161,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -872,12 +878,10 @@ function modelFactory(source, $special, $model) { $model = $model || {} //vmodels.$model属性 var $events = createMap() //vmodel.$events属性 var accessors = createMap() //监控属性 - var initCallbacks = [] //初始化才执行的函数 - + var computed = [] $$skipArray.forEach(function (name) { delete source[name] }) - for (var i in source) { (function (name, val, accessor) { $model[name] = val @@ -890,13 +894,9 @@ function modelFactory(source, $special, $model) { //总共产生三种accessor if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { accessor = makeComputedAccessor(name, val) - initCallbacks.push(accessor) + computed.push(accessor) } else if (rcomplexType.test(valueType)) { - accessor = makeComplexAccessor(name, val, valueType) - initCallbacks.push(function () { - var son = accessor._vmodel - son.$events[subscribers] = this.$events[name] - }) + accessor = makeComplexAccessor(name, val, valueType, $events[name]) } else { accessor = makeSimpleAccessor(name, val) } @@ -926,10 +926,26 @@ function modelFactory(source, $special, $model) { enumerable: false, configurable: true }) - - initCallbacks.forEach(function (cb) { //收集依赖 - cb.call($vmodel) - }) + $vmodel.$compute = function () { + computed.forEach(function (accessor) { + dependencyDetection.begin({ + callback: function (vm, dependency) {//dependency为一个accessor + var name = dependency._name + if (dependency !== accessor) { + var list = vm.$events[name] + accessor.vm = $vmodel + injectDependency(list, accessor.digest) + } + } + }) + try { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$compute() return $vmodel } @@ -938,10 +954,7 @@ function makeSimpleAccessor(name, value) { function accessor(value) { var oldValue = accessor._value if (arguments.length > 0) { - if (stopRepeatAssign) { - return this - } - if (!isEqual(value, oldValue)) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { accessor.updateValue(this, value) accessor.notify(this, value, oldValue) } @@ -970,35 +983,7 @@ function makeComputedAccessor(name, options) { return this } else { //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 - dependencyDetection.collectDependency(this, accessor) - if (!accessor.digest) { - var vm = this - var id - accessor.digest = function () { - accessor.updateValue = globalUpdateModelValue - accessor.notify = noop - accessor.call(vm) - clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 - id = setTimeout(function () { - accessorFactory(accessor, accessor._name) - accessor.call(vm) - }) - } - } - dependencyDetection.begin({ - callback: function (vm, dependency) {//dependency为一个accessor - var name = dependency._name - if (dependency !== accessor) { - var list = vm.$events[name] - injectDependency(list, accessor.digest) - } - } - }) - try { - value = accessor.get.call(this) - } finally { - dependencyDetection.end() - } + value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) init && accessor.notify(this, value, oldValue) //触发$watch回调 @@ -1006,15 +991,27 @@ function makeComputedAccessor(name, options) { //将自己注入到低层访问器的订阅数组中 return value } + } accessor.set = options.set || noop accessor.get = options.get accessorFactory(accessor, name) + var id + accessor.digest = function () { + accessor.updateValue = globalUpdateModelValue + accessor.notify = noop + accessor.call(accessor.vm) + clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 + id = setTimeout(function () { + accessorFactory(accessor, accessor._name) + accessor.call(accessor.vm) + }) + } return accessor } //创建一个复杂访问器 -function makeComplexAccessor(name, initValue, valueType) { +function makeComplexAccessor(name, initValue, valueType, list) { function accessor(value) { var oldValue = accessor._value var son = accessor._vmodel @@ -1034,10 +1031,11 @@ function makeComplexAccessor(name, initValue, valueType) { son = accessor._vmodel = modelFactory(value) son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) son.$events[name] = observes @@ -1052,7 +1050,8 @@ function makeComplexAccessor(name, initValue, valueType) { } } accessorFactory(accessor, name) - accessor._vmodel = modelFactory(initValue) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list return accessor } @@ -1319,7 +1318,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1416,6 +1415,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1502,11 +1503,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1543,6 +1548,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -2735,6 +2742,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -2753,7 +2761,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3136,7 +3143,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3264,7 +3271,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { }) if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -3333,7 +3340,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -3356,16 +3367,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -3570,11 +3581,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/dist/avalon.shim.js b/dist/avalon.shim.js index 29d4eb51a..43b53dfcb 100644 --- a/dist/avalon.shim.js +++ b/dist/avalon.shim.js @@ -5,7 +5,7 @@ http://weibo.com/jslouvre/ Released under the MIT license - avalon.shim.js(无加载器版本) 1.44 built in 2015.6.16 + avalon.shim.js(无加载器版本) 1.44 built in 2015.6.25 support IE6+ and other browsers ==================================================*/ (function(global, factory) { @@ -70,7 +70,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -92,7 +92,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -106,12 +106,18 @@ function IE() { } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -131,14 +137,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -146,13 +152,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line @@ -1096,9 +1102,8 @@ avalon.define = function (id, factory) { $watch: noop } factory(scope) //得到所有定义 - avalon.collectDependency = true + model = modelFactory(scope) //偷天换日,将scope换为model - avalon.collectDependency = false stopRepeatAssign = true factory(model) stopRepeatAssign = false @@ -1108,7 +1113,7 @@ avalon.define = function (id, factory) { } //一些不需要被监听的属性 -var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(rword) +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(rword) var defineProperty = Object.defineProperty var canHideOwn = true //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 @@ -1201,7 +1206,7 @@ function modelFactory(source, $special, $model) { } /* jshint ignore:end */ } - + $vmodel.$compute = function () { computed.forEach(function (accessor) { dependencyDetection.begin({ @@ -1249,7 +1254,7 @@ function makeComputedAccessor(name, options) { options.set = options.set || noop function accessor(value) {//计算属性 var oldValue = accessor._value - var init = "_value" in accessor + var init = "_value" in accessor if (arguments.length > 0) { if (stopRepeatAssign) { return this @@ -1261,7 +1266,7 @@ function makeComputedAccessor(name, options) { value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) - init && accessor.notify(this, value, oldValue) //触发$watch回调 + init && accessor.notify(this, value, oldValue) //触发$watch回调 } //将自己注入到低层访问器的订阅数组中 return value @@ -1306,10 +1311,11 @@ function makeComplexAccessor(name, initValue, valueType, list) { son.$events[subscribers] = observes son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) } @@ -1696,7 +1702,7 @@ var arrayPrototype = { this.$model[index] = val var proxy = this.$proxy[index] if (proxy) { - fireDependencies(proxy.$events.el) + fireDependencies(proxy.$events.$index) } } } @@ -1793,6 +1799,8 @@ function eachProxyAgent(index, host) { var proxy = eachProxyPool.shift() if (!proxy) { proxy = eachProxyFactory( ) + }else{ + proxy.$compute() } var last = host.length - 1 proxy.$host = host @@ -1879,11 +1887,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } @@ -1920,6 +1932,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if(avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -3367,6 +3381,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -3385,7 +3400,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { @@ -3768,7 +3782,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -3939,7 +3953,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } @@ -4008,7 +4022,11 @@ bindingExecutors.html = function (val, elem, data) { if (!parent) return val = val == null ? "" : val - + if (data.oldText !== val) { + data.oldText = val + } else { + return + } if (elem.nodeType === 3) { var signature = generateID("html") parent.insertBefore(DOC.createComment(signature), elem) @@ -4031,16 +4049,16 @@ bindingExecutors.html = function (val, elem, data) { nodes = avalon.slice(fragment.childNodes) //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 if (isHtmlFilter) { - var endValue = elem.nodeValue.slice(0,-4) - while (true) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { var node = elem.previousSibling if (!node || node.nodeType === 8 && node.nodeValue === endValue) { break } else { parent.removeChild(node) } - } - parent.insertBefore(fragment, elem) + } + parent.insertBefore(fragment, elem) } else { avalon.clearHTML(elem).appendChild(fragment) } @@ -4245,11 +4263,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/examples/event-args.html b/examples/event-args.html new file mode 100644 index 000000000..26ac1c744 --- /dev/null +++ b/examples/event-args.html @@ -0,0 +1,53 @@ + + + + ms-on + + + + + + +

ms-on-*

+
+ 有关事件回调传参 +
{{status}}
+ {{field}} +
+
点我
+
+

{{el}}

+
+ +
+ + \ No newline at end of file diff --git a/examples/event-change.html b/examples/event-change.html new file mode 100644 index 000000000..e609d480e --- /dev/null +++ b/examples/event-change.html @@ -0,0 +1,43 @@ + + + + + + + + + + + +
+

+

+

+

+

+

+

+
+ + \ No newline at end of file diff --git a/examples/event-click.html b/examples/event-click.html new file mode 100644 index 000000000..b5b791e10 --- /dev/null +++ b/examples/event-click.html @@ -0,0 +1,46 @@ + + + + TODO supply a title + + + + + + + +
+
+
+
+ 点我 +
+
+
+
+ + diff --git a/examples/event-focus.html b/examples/event-focus.html new file mode 100644 index 000000000..94fe272ab --- /dev/null +++ b/examples/event-focus.html @@ -0,0 +1,28 @@ + + + + ms-on + + + + + + + +
+

+

{{text}}

+ +
+ + + + diff --git a/examples/event-input.html b/examples/event-input.html new file mode 100644 index 000000000..fe5cd77fc --- /dev/null +++ b/examples/event-input.html @@ -0,0 +1,48 @@ + + + + + + + + + + + +
+

+

+

+

+
+ + \ No newline at end of file diff --git a/examples/event-key.html b/examples/event-key.html new file mode 100644 index 000000000..7f8c8b756 --- /dev/null +++ b/examples/event-key.html @@ -0,0 +1,23 @@ + + + + TODO supply a title + + + + + + + + + + + + diff --git a/examples/event-mouse.html b/examples/event-mouse.html new file mode 100644 index 000000000..1d0d48c82 --- /dev/null +++ b/examples/event-mouse.html @@ -0,0 +1,59 @@ + + + + TODO supply a title + + + + + + + +
+
+ Outer +
+

Inner

+
move
+
+ Outer +
+
+ + \ No newline at end of file diff --git a/examples/on5.html b/examples/event-mousewheel.html similarity index 64% rename from examples/on5.html rename to examples/event-mousewheel.html index fab474e54..aadce9327 100644 --- a/examples/on5.html +++ b/examples/event-mousewheel.html @@ -6,20 +6,20 @@ -
- {{text}} +
+

请使用鼠标滚轮

+ {{text}}
\ No newline at end of file diff --git a/examples/on1.html b/examples/event-multi-click.html similarity index 63% rename from examples/on1.html rename to examples/event-multi-click.html index eabf65985..8218a9567 100644 --- a/examples/on1.html +++ b/examples/event-multi-click.html @@ -7,28 +7,35 @@ +
一个元素绑定多个同种事件的回调
-
请点我
+
请点我
{{str1}}
{{str2}}
{{str3}}
diff --git a/examples/event-native-submit.html b/examples/event-native-submit.html new file mode 100644 index 000000000..76d74a213 --- /dev/null +++ b/examples/event-native-submit.html @@ -0,0 +1,20 @@ + + + + + + 事件冒泡 by司徒正美 + + + +
+
+ + +
+
+ + \ No newline at end of file diff --git a/examples/event-submit.html b/examples/event-submit.html new file mode 100644 index 000000000..de0dcc597 --- /dev/null +++ b/examples/event-submit.html @@ -0,0 +1,53 @@ + + + + TODO supply a title + + + + + + + +
+
+
+ +
+
+
+ + diff --git a/examples/index.html b/examples/index.html index c7fb4d6ae..6b623d277 100644 --- a/examples/index.html +++ b/examples/index.html @@ -27,12 +27,6 @@
  • ms-css-* 1
  • ms-css-* 2
  • ms-css-* 3
  • -
  • ms-on-* 0
  • -
  • ms-on-* 1
  • -
  • ms-on-* 2
  • -
  • ms-on-* 3
  • -
  • ms-on-* 4
  • -
  • ms-on-* 5
  • ms-href
  • ms-visible
  • ms-include
  • diff --git a/examples/on2.html b/examples/on2.html deleted file mode 100644 index 083d311ac..000000000 --- a/examples/on2.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - ms-on - - - - - - -
    -
    - - diff --git a/examples/on3.html b/examples/on3.html deleted file mode 100644 index 7b8fc6874..000000000 --- a/examples/on3.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - ms-mouseenter, ms-mouseleave - - - - - - - - {{a}} - - \ No newline at end of file diff --git a/examples/on4.html b/examples/on4.html deleted file mode 100644 index 7a8f2b01d..000000000 --- a/examples/on4.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - ms-mouseenter, ms-mouseleave - - - - - - - -
    -
    -
    - - \ No newline at end of file diff --git a/index2.html b/index2.html new file mode 100644 index 000000000..c168e59a1 --- /dev/null +++ b/index2.html @@ -0,0 +1,47 @@ + + + + ms-on + + + + + + + +
    +
    +
    {{el}}
    +
    + + +

    +
    + + + + diff --git a/on2.js b/on2.js new file mode 100644 index 000000000..7ef7df298 --- /dev/null +++ b/on2.js @@ -0,0 +1,1035 @@ +var rdash = /\(([^)]*)\)/ +bindingHandlers.on = function (data, vmodels) { + var value = data.value + data.type = "on" + if (value.indexOf("(") > 0 && value.indexOf(")") > -1) { + var matched = (value.match(rdash) || ["", ""])[1].trim() + if (matched === "" || matched === "$event") { // aaa() aaa($event)当成aaa处理 + value = value.replace(rdash, "") + } + } + parseExprProxy(value, vmodels, data) +} + +bindingExecutors.on = function (_, elem, data) { + var eventType = data.param.replace(/-\d+$/, "") + // avalon.log("绑定" + eventType + "事件!") + var uuid = getUid(elem) + try { + listenTo(eventType, document) + } catch (e) { + avalon.log(e) + } + EventPluginHub.addListener(uuid, eventType, data) + data.rollback = function () { + EventPluginHub.removeListener(uuid, eventType, data) + } +} + +function isEventSupported(eventNameSuffix, capture) { + if (capture && !('addEventListener' in document)) { + return false + } + + var eventName = 'on' + eventNameSuffix; + var isSupported = eventName in document; + if (!isSupported) { + var element = document.createElement('div'); + element.setAttribute(eventName, 'return;'); + isSupported = typeof element[eventName] === 'function'; + } + + if (!isSupported && eventNameSuffix === 'wheel') { + isSupported = !!window.WheelEvent + } + + return isSupported; +} + +function getEventCharCode(nativeEvent) { + var charCode; + var keyCode = nativeEvent.keyCode; + if ('charCode' in nativeEvent) { + charCode = nativeEvent.charCode; + // FF does not set `charCode` for the Enter-key, check against `keyCode`. + if (charCode === 0 && keyCode === 13) { + charCode = 13; + } + } else { + // IE8 does not implement `charCode`, but `keyCode` has the correct value. + charCode = keyCode; + } + // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. + // Must not discard the (non-)printable Enter-key. + if (charCode >= 32 || charCode === 13) { + return charCode; + } + return 0; +} + +var isListening = {} + +function listenTo(eventType, mountAt) { + //通过事件名得到对应的插件 + var plugin = getPluginByEventType(eventType) + if (!plugin) { + avalon.log(eventType + " 事件不存在对应的插件模块 !") + } + //得到对应的依赖 + var dependencies = plugin ? plugin.eventTypes[eventType].dependencies : [eventType] + //IE6-8下`keyup`/`keypress`/`keydown` 只能冒泡到 document + for (var i = 0; i < dependencies.length; i++) { + var dependency = dependencies[i]; + if (isListening[dependency] !== true) { + if (dependency === "scroll") { + addCapturedEvent("scroll", 'scroll', mountAt) + } else if (dependency === "focus" || dependency === "blur") { + addCapturedEvent("focus", 'focus', mountAt); + addCapturedEvent("blur", 'blur', mountAt); + isListening.focus = true + isListening.blur = true + } else { + addBubbledEvent(eventType, dependency, mountAt); + } + isListening[dependency] = true; + } + } +} + +var addBubbledEvent = function (topLevelType, type, element) { + return addEventListener(element, type, function (nativeEvent) { + topEventListener(nativeEvent, topLevelType) + }) +} +var addCapturedEvent = function (topLevelType, type, element) { + return addEventListener(element, type, function (nativeEvent) { + topEventListener(nativeEvent, topLevelType) + }, true) +} + +function addEventListener(target, eventType, callback, capture) { + target.addEventListener(eventType, callback, !!capture) + return { + remove: function () { + target.removeEventListener(eventType, callback, !!capture) + } + } +} +//顶层事件监听器 + +function topEventListener(nativeEvent, topLevelType) { + var topLevelTarget = nativeEvent.target + var ancestors = [] + var ancestor = topLevelTarget + while (ancestor && ancestor.nodeType) { + ancestors.push(ancestor) + ancestor = ancestor.parentNode + } + var uuids = [] + while (ancestor = ancestors.shift()) { + uuids.push(getUid(ancestor)) + } + //收集事件 + var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, nativeEvent, uuids) + //执行所有回调 + events.forEach(executeDispatchesAndRelease) +} + + +function executeDispatchesAndRelease(event) { + if (event) { + var callback = executeDispatch; + var PluginModule = getPluginByEventType(event.type); + if (PluginModule && PluginModule.executeDispatch) { + callback = PluginModule.executeDispatch; + } + var dispatchListeners = event._dispatchListeners + var dispatchIDs = event._dispatchIDs + // avalon.log("执行所有回调" + event.type) + for (var i = 0; i < dispatchListeners.length; i++) { + if (event.isPropagationStopped) { + break + } + callback(event, dispatchListeners[i], dispatchIDs[i]) + } + // eventFactory.release(event) + } +} + +//执行单个事件回调 +function executeDispatch(event, fn, domID) { + var elem = event.currentTarget = getNode(domID); + if (typeof fn === "function") { + var returnValue = fn.call(elem, event) + } else if (fn.args) { + var callback = fn.evaluator || noop + returnValue = callback.apply(elem, fn.args.concat(event)) + } + event.currentTarget = null; + return returnValue; +} + + +//=================事件工厂=================== +var eventFactory = (function () { + var eventPool = [] + + function eventFactory(nativeEvent, type) { + var event = eventPool.shift() + if (!event) { + event = new SyntheticEvent() + } + event.timeStamp = new Date() - 0 + event.nativeEvent = nativeEvent + event.type = type + var target = nativeEvent.target || window + if (target.nodeType === 3) { + target = target.parentNode + } + event.target = target + return event + } + eventFactory.release = function (event) { + for (var i in event) { + if (event.hasOwnProperty(i)) { + event[i] = null + } + } + if (eventPool.length < 20) { + eventPool.push(event) + } + } + + function SyntheticEvent() { + } + var ep = SyntheticEvent.prototype + //阻止默认行为 + ep.preventDefault = function () { + if (this.nativeEvent) { + this.nativeEvent.preventDefault(); + } + } + //阻止事件往上下传播 + ep.stopPropagation = function () { + this.isPropagationStopped = true; + if (this.nativeEvent) { + this.nativeEvent.stopPropagation(); + } + } + + //阻止事件往上下传播 + ep.stopImmediatePropagation = function () { + //阻止事件在一个元素的同种事件的回调中传播 + this.isImmediatePropagationStopped = true + this.stopPropagation() + } + return eventFactory +})() + + + +//==================================================== +var callbackPool = {}; +var EventPluginHub = { + //添加事件回调到 回调池 中 + addListener: function (id, type, callback) { + var pool = callbackPool[type] || (callbackPool[type] = {}); + if (pool[id]) { + pool[id].push(callback) + } else { + pool[id] = [callback] + } + var plugin = getPluginByEventType(type) + if (plugin && plugin.didPutListener) { + plugin.didPutListener(id, type, callback); + } + }, + getListener: function (id, eventType) { + var pool = callbackPool[eventType] + return pool && pool[id] || [] + }, + removeListener: function (id, type, fn) { + var plugin = getPluginByEventType(type) + if (plugin && plugin.willDeleteListener) { + plugin.willDeleteListener(id, type); + } + var pool = callbackPool[type] + if (pool) { + if (fn) { + avalon.Array.remove(pool[id], fn) + } else { + delete pool[id] + } + } + }, + extractEvents: function (topLevelType, topLevelTarget, nativeEvent, uuids) { + var events = [] + if (!topLevelTarget) { + return events + } + var plugins = EventPluginRegistry.plugins; + for (var i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; + if (possiblePlugin) { + + var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, nativeEvent, uuids) + if (extractedEvents) { + extractedEvents.plugn = possiblePlugin.name + events = events.concat(extractedEvents); + } + } + } + return events; + } +} + +function collectDispatches(event, uuids) { + //收集事件回调 + var _dispatchListeners = [] + var _dispatchIDs = [] + for (var i = 0, n = uuids.length; i < n; i++) { + var id = uuids[i] + //从事件仓库中取得回调数组 + var listener = EventPluginHub.getListener(id, event.type) + var node = getNode(id) + //从元素上取得直接用onxxx绑定的回调 + var onFn = node && node["on" + event.type] + if (typeof onFn === "function") { + listener.push(onFn) + } + var jn = listener.length + if (jn) { + for (var j = 0; j < jn; j++) { + _dispatchListeners.push(listener[j]) + _dispatchIDs.push(id) + } + } + } + event._dispatchListeners = _dispatchListeners + event._dispatchIDs = _dispatchIDs +} + +//-------------------------------- +// SimpleEventPlugin +var SimpleEventPlugin = (function () { + var EventTypes = {} + var onClickListeners = {} + String("click,contextmenu,doubleclick,keydown,keypress,keyup,focus,blur,copy,cut,paste," + //键盘点击 + "drag,dragend,dragenter,dragexit,dragleave,touchcancel,touchend,touchstart,touchmove," + //拖放触摸 + "mousedown,mousemove,mouseout,mouseover,mouseup," + //鼠标操作 + "change," + //来自ChangeEventPlugin插件 + "submit," + //来自SubmitEventPlugin插件 + "load,error,reset,scroll").toLowerCase().replace(rword, function (eventName) { + EventTypes[eventName] = { + dependencies: [eventName] + } + }) + var EventPlugin = { + name: "SimpleEventPlugin", + eventTypes: EventTypes, + executeDispatch: function (event, listener, domID) { + var returnValue = executeDispatch(event, listener, domID); + if (returnValue === false) { + event.stopPropagation() + event.preventDefault() + } + }, + extractEvents: function (topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!EventTypes[topLevelType]) { + return null; + } + var eventDecorator; + switch (topLevelType) { + case "load": + case "error": + case "reset": + eventDecorator = SyntheticHTMLEvent; + break; + case "keypress": + // FireFox creates a keypress event for function keys too. This removes + // the unwanted keypress events. Enter is however both printable and + // non-printable. One would expect Tab to be as well (but it isn't). + if (getEventCharCode(nativeEvent) === 0) { + return null; + } + + case "keydown": + case "keyup": + eventDecorator = SyntheticKeyboardEvent; + break; + case "blur": + case "focus": + eventDecorator = SyntheticFocusEvent; + break; + case "click": + // Firefox creates a click event on right mouse clicks. This removes the + // unwanted click events. + if (nativeEvent.button === 2) { + return null; + } + case "contextenu": + case "doubleclick": + case "mousedown": + case "mousemove": + case "mouseout": + case "mouseover": + case "mouseup": + eventDecorator = SyntheticMouseEvent; + break; + case "drag": + case "dragend": + case "dragenter": + case "dragexit": + case "dragleave": + case "dragover": + case "dragstart": + case "drop": + eventDecorator = SyntheticDragEvent; + break; + case "touchcancel": + case "touchend": + case "touchmove": + case "touchstart": + eventDecorator = SyntheticTouchEvent; + break; + case "scroll": + eventDecorator = SyntheticUIEvent; + break; + case "copy": + case "cut": + case "paste": + eventDecorator = SyntheticClipboardEvent; + break; + } + if (eventDecorator) { + var event = eventFactory(nativeEvent, topLevelType) + eventDecorator(event, nativeEvent) + collectDispatches(event, uuids) //收集回调 + return event + } + }, + didPutListener: function (id, type) { + // Mobile Safari does not fire properly bubble click events on + // non-interactive elements, which means delegated click listeners do not + // fire. The workaround for this bug involves attaching an empty click + // listener on the target node. + if (type === "click") { + if (!onClickListeners[id]) { + onClickListeners[id] = addEventListener(getNode(id), 'click', noop); + } + } + }, + willDeleteListener: function (id, type) { + if (type === "click") { + onClickListeners[id].remove(); + delete onClickListeners[id]; + } + } + } +// 各类型事件的装饰器 +// http://www.w3.org/TR/html5/index.html#events-0 + + function SyntheticHTMLEvent(event, nativeEvent) { + var _interface = "eventPhase,cancelable,bubbles" + _interface.replace(rword, function (name) { + event[name] = nativeEvent[name] + }) + } + + function SyntheticUIEvent(event, nativeEvent) { + SyntheticHTMLEvent(event, nativeEvent) + event.view = nativeEvent.view || window + event.detail = nativeEvent.detail || 0 + } + + function SyntheticTouchEvent(event, nativeEvent) { + SyntheticUIEvent(event, nativeEvent) + var _interface = "touches,targetTouches,changedTouches,ctrlKey,shiftKey,metaKey,altKey" + _interface.replace(rword, function (name) { + event[name] = nativeEvent[name] + }) + } + +//http://www.w3.org/TR/DOM-Level-3-Events/ + + function SyntheticFocusEvent(event, nativeEvent) { + SyntheticUIEvent(event, nativeEvent) + event.relatedTarget = nativeEvent.relatedTarget + } + + + function SyntheticClipboardEvent(event, nativeEvent) { + SyntheticEvent(event, nativeEvent) + event.clipboardData = 'clipboardData' in nativeEvent ? nativeEvent.clipboardData : window.clipboardData + } + + + function SyntheticKeyboardEvent(event, nativeEvent) { + SyntheticUIEvent(event, nativeEvent) + var _interface = "ctrlKey,shiftKey,metaKey,altKey,repeat,locale,location" + _interface.replace(rword, function (name) { + event[name] = nativeEvent[name] + }) + if (event.type === 'keypress') { + event.charCode = getEventCharCode(event) + event.keyCode = 0 + } else if (event.type === 'keydown' || event.type === 'keyup') { + event.charCode = 0 + event.keyCode = nativeEvent.keyCode + } + event.which = event.type === 'keypress' ? event.charCode : event.keyCode + } + + function SyntheticMouseEvent(event, nativeEvent) { + SyntheticUIEvent(event, nativeEvent) + var _interface = "screenX,screenY,clientX,clientY,ctrlKey,shiftKey,altKey,metaKey" + _interface.replace(rword, function (name) { + event[name] = nativeEvent[name] + }) + // Webkit, Firefox, IE9+ + // which: 1 2 3 + // button: 0 1 2 (standard) + event.which = nativeEvent.button //判定是左、中、右键触发 + } + + function SyntheticDragEvent(event, nativeEvent) { + SyntheticMouseEvent(event, nativeEvent) + event.dataTransfer = nativeEvent.dataTransfer + } + return EventPlugin +})() +//https://github.com/jquery/jquery-mousewheel/blob/master/jquery.mousewheel.js +var WheelEventPlugin = (function () { + var dependencies = ('onwheel' in document || document.documentMode >= 9) ? ['wheel'] : + isEventSupported("mousewheel") ? ['mousewheel'] : + ['DomMouseScroll', 'MozMousePixelScroll'] + + function ajusetNumber(delta) { + return delta === 0 ? 0 : delta > 0 ? 120 : -120 + } + var EventPlugin = { + name: "WheelEventPlugin", + eventTypes: { + mousewheel: { + dependencies: dependencies + }, + wheel: { + dependencies: dependencies + } + }, + extractEvents: function (topLevelType, topLevelTarget, orgEvent, uuids) { + if (dependencies.indexOf(topLevelType) === -1) { + return + } + var delta = 0 + var deltaX = 0 + var deltaY = 0 + //从原始事件对象抽取有用信息 + if ('detail' in orgEvent) { + deltaY = orgEvent.detail * -1; + } + if ('wheelDelta' in orgEvent) { + deltaY = orgEvent.wheelDelta; + } + if ('wheelDeltaY' in orgEvent) { + deltaY = orgEvent.wheelDeltaY; + } + if ('wheelDeltaX' in orgEvent) { + deltaX = orgEvent.wheelDeltaX * -1; + } + + // Firefox < 17 horizontal scrolling related to DOMMouseScroll event + if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) { + deltaX = deltaY * -1; + deltaY = 0; + } + + // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy + delta = deltaY === 0 ? deltaX : deltaY; + + // 如果是wheel事件 + if ('deltaY' in orgEvent) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ('deltaX' in orgEvent) { + deltaX = orgEvent.deltaX; + if (deltaY === 0) { + delta = deltaX * -1; + } + } + // 如果没有移动过,就立即返回 + if (deltaY === 0 && deltaX === 0) { + return; + } + + var event = eventFactory(orgEvent, topLevelType) + + event.deltaX = ajusetNumber(deltaX) + event.deltaY = ajusetNumber(deltaY) + event.delta = ajusetNumber(delta) + + collectDispatches(event, uuids) //收集回调 + return event + } + } + return EventPlugin +})() + +var ResponderEventPlugin = { + extractEvents: noop +} +var TapEventPlugin = (function () { + function isEndish(topLevelType) { + return topLevelType === "mouseup" || + topLevelType === "touchend" || + topLevelType === "touchcancel"; + } + + function isMoveish(topLevelType) { + return topLevelType === "mousemove" || + topLevelType === "touchmove"; + } + function isStartish(topLevelType) { + return topLevelType === "mousedown" || + topLevelType === "touchstart"; + } + var touchEvents = [ + "touchstart", + "touchcanel", + "touchend", + "touchmove" + ] + /** + * Number of pixels that are tolerated in between a `touchStart` and `touchEnd` + * in order to still be considered a 'tap' event. + */ + var tapMoveThreshold = 10; + var startCoords = {x: null, y: null}; + var Axis = { + x: {page: 'pageX', client: 'clientX', envScroll: 'scrollLeft'}, + y: {page: 'pageY', client: 'clientY', envScroll: 'scrollTop'} + }; + var extractSingleTouch = function (nativeEvent) { + var touches = nativeEvent.touches; + var changedTouches = nativeEvent.changedTouches; + var hasTouches = touches && touches.length > 0; + var hasChangedTouches = changedTouches && changedTouches.length > 0; + + return !hasTouches && hasChangedTouches ? changedTouches[0] : + hasTouches ? touches[0] : + nativeEvent; + } + function getAxisCoordOfEvent(axis, nativeEvent) { + var singleTouch = extractSingleTouch(nativeEvent); + if (singleTouch) { + return singleTouch[axis.page]; + } + return axis.page in nativeEvent ? + nativeEvent[axis.page] : + nativeEvent[axis.client] + root[axis.envScroll]; + } + + function getDistance(coords, nativeEvent) { + var pageX = getAxisCoordOfEvent(Axis.x, nativeEvent); + var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent); + return Math.pow( + Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2), + 0.5 + ); + } + var usedTouch = false; + var usedTouchTime = 0; + var TOUCH_DELAY = 1000; + var EventPlugin = { + name: "TapEventPlugin", + tapMoveThreshold: tapMoveThreshold, + eventTypes: { + tap: { + dependencies: touchEvents.concat("mousedown", "mouseup", "mouseup") + } + }, + extractEvents: function (topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!isStartish(topLevelType) && !isEndish(topLevelType)) { + return null; + } + // on ios, there is a delay after touch event and synthetic + // mouse events, so that user can perform double tap + // solution: ignore mouse events following touchevent within small timeframe + if (touchEvents.indexOf(topLevelType) !== -1) { + usedTouch = true; + usedTouchTime = new Date() - 0; + } else { + if (usedTouch && (new Date() - usedTouchTime < TOUCH_DELAY)) { + return null; + } + } + var event = null; + var distance = getDistance(startCoords, nativeEvent); + if (isEndish(topLevelType) && distance < tapMoveThreshold) { + event = eventFactory(nativeEvent, "tap") + } + if (isStartish(topLevelType)) { + startCoords.x = getAxisCoordOfEvent(Axis.x, nativeEvent); + startCoords.y = getAxisCoordOfEvent(Axis.y, nativeEvent); + } else if (isEndish(topLevelType)) { + startCoords.x = 0; + startCoords.y = 0; + } + event && collectDispatches(event, uuids) + + return event; + } + } + return EventPlugin +})() +var EnterLeaveEventPlugin = { + name: "EnterLeaveEventPlugin", + eventTypes: { + mouseenter: { + dependencies: [ + "mouseout", + "mouseover" + ] + }, + mouseleave: { + dependencies: [ + "mouseout", + "mouseover" + ] + } + }, + extractEvents: function (topLevelType, topLevelTarget, nativeEvent) { + if (topLevelType === "mouseout" || topLevelType === "mouseover") { + //https://developer.mozilla.org/en-US/docs/Web/Events/mouseout + // W3C的mouseout, mouseover是使用relatedTarget代替IE下的fromElement,toElement + var related = nativeEvent.relatedTarget + if (!related || (related !== topLevelTarget && !avalon.contains(topLevelTarget, related))) { + var type = topLevelType === "mouseout" ? "mouseleave" : "mouseenter" + var id = getUid(topLevelTarget) + var listener = EventPluginHub.getListener(id, type) + if (listener && listener.length) { + var event = eventFactory(nativeEvent, type) + event._dispatchIDs = [id] + event._dispatchListeners = listener + return event + } + } + } + } +} + +/** + * Same as document.activeElement but wraps in a try-catch block. In IE it is + * not safe to call document.activeElement if there is nothing focused. + * + * The activeElement will be null only if the document body is not yet defined. + */ +function getActiveElement() /*?DOMElement*/ { + try { + return document.activeElement || document.body; + } catch (e) { + return document.body; + } +} + +var SelectEventPlugin = (function () { + var activeElement = null; + var lastSelection = null; + var mouseDown = false; +// Track whether a listener exists for this plugin. If none exist, we do +// not extract events. + var hasListener = false; + function getSelection(node) { + if ('selectionStart' in node) { + return { + start: node.selectionStart, + end: node.selectionEnd + }; + } else if (window.getSelection) { + var selection = window.getSelection(); + return { + anchorNode: selection.anchorNode, + anchorOffset: selection.anchorOffset, + focusNode: selection.focusNode, + focusOffset: selection.focusOffset + }; + } //去掉IE6-8的逻辑 + } + function shallowEqual(objA, objB) { + if (objA === objB) { + return true; + } + var key; + // Test for A's keys different from B. + for (key in objA) { + if (objA.hasOwnProperty(key) && + (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) { + return false; + } + } + // Test for B's keys missing from A. + for (key in objB) { + if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) { + return false; + } + } + return true; + } + function selectEventFactory(nativeEvent, uuids) { + // Ensure we have the right element, and that the user is not dragging a + // selection (this matches native `select` event behavior). In HTML5, select + // fires only on input and textarea thus if there's no focused element we + // won't dispatch. + if (mouseDown || activeElement == null || activeElement !== getActiveElement()) { + return null; + } + + // Only fire when selection has actually changed. + var currentSelection = getSelection(activeElement); + if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { + lastSelection = currentSelection + var event = eventFactory(nativeEvent, 'select') + event.target = activeElement; + collectDispatches(event, uuids) + return event + } + } + var EventPlugin = { + name: "SelectEventPlugin", + eventTypes: { + select: { + dependencies: [ + "blur", + "contextmenu", + "focus", + "keydown", + "mousedown", + "mouseup", + "select"//W3C + ] + } + }, + extractEvents: function (topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!hasListener) { + return null; + } + switch (topLevelType) { + // Track the input node that has focus. + case "focus": + var canSelected = topLevelTarget.contentEditable === 'true' || + isTextInputElement(topLevelTarget) + if (canSelected) { + activeElement = topLevelTarget + lastSelection = null + } + break; + case "blur": + activeElement = null + lastSelection = null + break; + // Don't fire the event while the user is dragging. This matches the + // semantics of the native select event. + case "mousedown": + mouseDown = true; + break; + case "contextmenu": + case "mouseup": + mouseDown = false + return selectEventFactory(nativeEvent, uuids) + // Chrome and IE fire non-standard event when selection is changed (and + // sometimes when it hasn't). + // Firefox doesn't support selectionchange, so check selection status + // after each key entry. The selection changes after keydown and before + // keyup, but we check on keydown as well in the case of holding down a + // key, when multiple keydown events are fired but only one keyup is. + case "selectionchange": + case "select": + return selectEventFactory(nativeEvent, uuids) + } + }, + didPutListener: function (id, type) { + if (type === "select") { + hasListener = true; + } + } + } + return EventPlugin +})() + +var supportedInputTypes = { + 'color': true, + 'date': true, + 'datetime': true, + 'datetime-local': true, + 'email': true, + 'month': true, + 'number': true, + 'password': true, + 'range': true, + 'search': true, + 'tel': true, + 'text': true, + 'time': true, + 'url': true, + 'week': true +}; +function isTextInputElement(elem) { + return elem && ((elem.nodeName === 'INPUT' ? supportedInputTypes[elem.type] : elem.nodeName === 'TEXTAREA')); +} + + +var InputEventPlugin = (function () { + var setters = {} + var useTicker + function newSetter(val) { + setters[this.tagName].call(this, val) + if (this.msInputHack && val !== this.oldValue) { + fireDatasetChanged(this) + } + } + + function msInputHack() { + if (this.parentNode) { + if (this.oldValue !== this.value) { + fireDatasetChanged(this) + } + } else if (!this.msRetain) { + this.msInputHack = null + return false + } + } + + if (Object.getOwnPropertyDescriptor) { + try { + var aproto = HTMLInputElement.prototype + Object.getOwnPropertyNames(aproto) //故意引发IE6-8等浏览器报错 + setters["INPUT"] = Object.getOwnPropertyDescriptor(aproto, "value").set + Object.defineProperty(aproto, "value", { + set: newSetter + }) + var bproto = HTMLTextAreaElement.prototype + setters["TEXTAREA"] = Object.getOwnPropertyDescriptor(bproto, "value").set + Object.defineProperty(bproto, "value", { + set: newSetter + }) + } catch (e) { + avalon.log(e) + useTicker = true + } + } + var activeElement + + function fireDatasetChanged(elem) { + if (elem.oldValue === elem.value) + return + var hackEvent = DOC.createEvent("Events"); + hackEvent.initEvent("datasetchanged", true, true, {}) + hackEvent.isInputEvent = true + elem.dispatchEvent(hackEvent) + } + var composing = false + var EventPlugin = { + name: "InputEventPlugin", + eventTypes: { + input: { + dependencies: [ + "compositionstart", + "compositionend", + "input", + "DOMAutoComplete", + "datasetchanged" + ] + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (isTextInputElement(topLevelTarget)) { + var isValueChange = false + activeElement = topLevelTarget + switch (topLevelType) { + case "compositionstart": + composing = false + break + case "compositionend": + composing = true + break + case "input": + case "DOMAutoComplete": + if (!composing) { + isValueChange = topLevelTarget.oldValue !== topLevelTarget.value + } + break + case "datasetchanged": + isValueChange = nativeEvent.isInputEvent + break + } + if (isValueChange) { + var event = eventFactory(nativeEvent, "input") + collectDispatches(event, uuids) + topLevelTarget.oldValue = topLevelTarget.value + return event + } + } + }, + didPutListener: function(id) { + var element = getNode(id) + if (isTextInputElement(element)) { + if (useTicker) { + element.oldValue = element.value + element.msInputHack = msInputHack + avalon.tick(element.msInputHack) + } else {//IE9+ chrome43+ firefox30+ + // http://updates.html5rocks.com/2015/04/DOM-attributes-now-on-the-prototype + // https://docs.google.com/document/d/1jwA8mtClwxI-QJuHT7872Z0pxpZz8PBkf2bGAbsUtqs/edit?pli=1 + element.msInputHack = true + avalon.log("使用Object.defineProperty重写element.value") + } + } + }, + willDeleteListener: function(id, type, fn) { + var pool = callbackPool[type] + var arr = pool && pool[id] + if (!fn || !arr || (arr.length === 1 && pool[0] === fn)) { + var element = getNode(id) || {} + if (element.msInputHack === true) { + delete element.msInputHack + } else if (element.msInputHack === msInputHack) { + avalon.Array.remove(ribbon, msInputHack) + element.msInputHack = void 0 + } + } + } + } + + return EventPlugin +})() +var AnalyticsEventPlugin = ResponderEventPlugin + +var EventPluginRegistry = { + registrationNameModules: {}, + plugins: [ + ResponderEventPlugin, + SimpleEventPlugin, + SubmitEventPlugin, + WheelEventPlugin, + TapEventPlugin, + EnterLeaveEventPlugin, + SelectEventPlugin, + InputEventPlugin, + AnalyticsEventPlugin + ] +} + +var getPluginByEventType = (function () { + var type2plugin = {} + for (var i = 0, plugin; plugin = EventPluginRegistry.plugins[i++]; ) { + for (var e in plugin.eventTypes) { + type2plugin[e] = plugin + } + } + avalon.log(type2plugin) + return function (type) { + return type2plugin[type] + } +})() + diff --git a/src/01 variable.share.js b/src/01 variable.share.js index e644475a3..349c21275 100644 --- a/src/01 variable.share.js +++ b/src/01 variable.share.js @@ -19,7 +19,7 @@ var root = DOC.documentElement var avalonFragment = DOC.createDocumentFragment() var cinerator = DOC.createElement("div") var class2type = {} -"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function(name) { +"Boolean Number String Function Array Date RegExp Object Error".replace(rword, function (name) { class2type["[object " + name + "]"] = name.toLowerCase() }) @@ -41,7 +41,7 @@ function oneObject(array, val) { } //生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript -var generateID = function(prefix) { +var generateID = function (prefix) { prefix = prefix || "avalon" return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) } @@ -50,17 +50,23 @@ function IE() { var mode = document.documentMode return mode ? mode : window.XMLHttpRequest ? 7 : 6 } else { - return 0 + return NaN } } var IEVersion = IE() -avalon = function(el) { //创建jQuery式的无new 实例化结构 +avalon = function (el) { //创建jQuery式的无new 实例化结构 return new avalon.init(el) } +avalon.profile = function () { + if (window.console && avalon.config.profile) { + Function.apply.call(console.log, console, arguments) + } +} + /*视浏览器情况采用最快的异步回调*/ -avalon.nextTick = new function() {// jshint ignore:line +avalon.nextTick = new function () {// jshint ignore:line var tickImmediate = window.setImmediate var tickObserver = window.MutationObserver var tickPost = W3C && window.postMessage @@ -80,14 +86,14 @@ avalon.nextTick = new function() {// jshint ignore:line if (tickObserver) { var node = document.createTextNode("avalon") new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line - return function(fn) { + return function (fn) { queue.push(fn) node.data = Math.random() } } if (tickPost) { - window.addEventListener("message", function(e) { + window.addEventListener("message", function (e) { var source = e.source if ((source === window || source === null) && e.data === "process-tick") { e.stopPropagation() @@ -95,13 +101,13 @@ avalon.nextTick = new function() {// jshint ignore:line } }) - return function(fn) { + return function (fn) { queue.push(fn) window.postMessage('process-tick', '*') } } - return function(fn) { + return function (fn) { setTimeout(fn, 0) } }// jshint ignore:line \ No newline at end of file diff --git a/src/02 core.js b/src/02 core.js index 5650014d8..0389d3834 100644 --- a/src/02 core.js +++ b/src/02 core.js @@ -1,12 +1,12 @@ /********************************************************************* * avalon的静态方法定义区 * **********************************************************************/ -avalon.init = function(el) { +avalon.init = function (el) { this[0] = this.element = el } avalon.fn = avalon.prototype = avalon.init.prototype -avalon.type = function(obj) { //取得目标的类型 +avalon.type = function (obj) { //取得目标的类型 if (obj == null) { return String(obj) } @@ -16,18 +16,18 @@ avalon.type = function(obj) { //取得目标的类型 typeof obj } -var isFunction = typeof alert === "object" ? function(fn) { +var isFunction = typeof alert === "object" ? function (fn) { try { return /^\s*\bfunction\b/.test(fn + "") } catch (e) { return false } -} : function(fn) { +} : function (fn) { return serialize.call(fn) === "[object Function]" } avalon.isFunction = isFunction -avalon.isWindow = function(obj) { +avalon.isWindow = function (obj) { if (!obj) return false // 利用IE678 window == document为true,document == window竟然为false的神奇特性 @@ -47,7 +47,7 @@ for (enu in avalon({})) { } var enumerateBUG = enu !== "0" //IE6下为true, 其他为false /*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/ -avalon.isPlainObject = function(obj, key) { +avalon.isPlainObject = function (obj, key) { if (!obj || avalon.type(obj) !== "object" || obj.nodeType || avalon.isWindow(obj)) { return false; } @@ -68,13 +68,13 @@ avalon.isPlainObject = function(obj, key) { return key === void 0 || ohasOwn.call(obj, key) } if (rnative.test(Object.getPrototypeOf)) { - avalon.isPlainObject = function(obj) { + avalon.isPlainObject = function (obj) { // 简单的 typeof obj === "object"检测,会致使用isPlainObject(window)在opera下通不过 return serialize.call(obj) === "[object Object]" && Object.getPrototypeOf(obj) === oproto } } //与jQuery.extend方法,可用于浅拷贝,深拷贝 -avalon.mix = avalon.fn.mix = function() { +avalon.mix = avalon.fn.mix = function () { var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, @@ -144,9 +144,9 @@ avalon.mix({ version: 1.4, ui: {}, log: log, - slice: W3C ? function(nodes, start, end) { + slice: W3C ? function (nodes, start, end) { return aslice.call(nodes, start, end) - } : function(nodes, start, end) { + } : function (nodes, start, end) { var ret = [] var len = nodes.length if (end === void 0) @@ -162,7 +162,7 @@ avalon.mix({ }, noop: noop, /*如果不用Error对象封装一下,str在控制台下可能会乱码*/ - error: function(str, e) { + error: function (str, e) { throw (e || Error)(str) }, /*将一个以空格或逗号隔开的字符串或数组,转换成一个键值都为1的对象*/ @@ -177,7 +177,7 @@ avalon.mix({ => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] avalon.range(0) => []*/ - range: function(start, end, step) { // 用于生成整数数组 + range: function (start, end, step) { // 用于生成整数数组 step || (step = 1) if (end == null) { end = start || 0 @@ -192,46 +192,52 @@ avalon.mix({ } return result }, - eventHooks: {}, + eventHooks: [], /*绑定事件*/ - bind: function(el, type, fn, phase) { + bind: function (el, type, fn, phase) { var hooks = avalon.eventHooks - var hook = hooks[type] - if (typeof hook === "object") { - type = hook.type - if (hook.deel) { - fn = hook.deel(el, type, fn, phase) - } + var data = { + el: el, + type: type, + origType: type, + fn: fn, + phase: !!phase } - var callback = W3C ? fn : function(e) { - fn.call(el, fixEvent(e)); + for (var i = 0, hook; hook = hooks[i++]; ) { + if (hook.match(type) && hook.on) { + hook.on(data) + } } if (W3C) { - el.addEventListener(type, callback, !!phase) + el.addEventListener(data.type, data.fn, data.phase) } else { - el.attachEvent("on" + type, callback) + el.attachEvent("on" + data.type, data.fn) } - return callback + return data.fn }, /*卸载事件*/ - unbind: function(el, type, fn, phase) { + unbind: function (el, type, fn, phase) { var hooks = avalon.eventHooks - var hook = hooks[type] - var callback = fn || noop - if (typeof hook === "object") { - type = hook.type - if (hook.deel) { - fn = hook.deel(el, type, fn, false) + var data = { + el: el, + type: type, + origType: type, + fn: fn || noop, + phase: !!phase + } + for (var i = 0, hook; hook = hooks[i++]; ) { + if (hook.match(type) && hook.off) { + hook.off(data) } } if (W3C) { - el.removeEventListener(type, callback, !!phase) + el.removeEventListener(data.type, data.fn, data.phase) } else { - el.detachEvent("on" + type, callback) + el.detachEvent("on" + data.type, data.fn) } }, /*读写删除元素节点的样式*/ - css: function(node, name, value) { + css: function (node, name, value) { if (node instanceof avalon) { node = node[0] } @@ -258,7 +264,7 @@ avalon.mix({ } }, /*遍历数组与对象,回调的第一个参数为索引或键名,第二个或元素或键值*/ - each: function(obj, fn) { + each: function (obj, fn) { if (obj) { //排除null, undefined var i = 0 if (isArrayLike(obj)) { @@ -276,12 +282,12 @@ avalon.mix({ } }, //收集元素的data-{{prefix}}-*属性,并转换为对象 - getWidgetData: function(elem, prefix) { + getWidgetData: function (elem, prefix) { var raw = avalon(elem).data() var result = {} for (var i in raw) { if (i.indexOf(prefix) === 0) { - result[i.replace(prefix, "").replace(/\w/, function(a) { + result[i.replace(prefix, "").replace(/\w/, function (a) { return a.toLowerCase() })] = raw[i] } @@ -290,17 +296,17 @@ avalon.mix({ }, Array: { /*只有当前数组不存在此元素时只添加它*/ - ensure: function(target, item) { + ensure: function (target, item) { if (target.indexOf(item) === -1) { return target.push(item) } }, /*移除数组中指定位置的元素,返回布尔表示成功与否*/ - removeAt: function(target, index) { + removeAt: function (target, index) { return !!target.splice(index, 1).length }, /*移除数组中第一个匹配传参的那个元素,返回布尔表示成功与否*/ - remove: function(target, item) { + remove: function (target, item) { var index = target.indexOf(item) if (~index) return avalon.Array.removeAt(target, index) diff --git a/src/05 dom.polyfill.js b/src/05 dom.polyfill.js index 11ba58351..67f2d351e 100644 --- a/src/05 dom.polyfill.js +++ b/src/05 dom.polyfill.js @@ -97,104 +97,5 @@ if (!root.outerHTML && window.HTMLElement) { //firefox 到11时才有outerHTML HTMLElement.prototype.__defineGetter__("outerHTML", outerHTML); } -//============================= event binding ======================= -var rmouseEvent = /^(?:mouse|contextmenu|drag)|click/ -function fixEvent(event) { - var ret = {} - for (var i in event) { - ret[i] = event[i] - } - var target = ret.target = event.srcElement - if (event.type.indexOf("key") === 0) { - ret.which = event.charCode != null ? event.charCode : event.keyCode - } else if (rmouseEvent.test(event.type)) { - var doc = target.ownerDocument || DOC - var box = doc.compatMode === "BackCompat" ? doc.body : doc.documentElement - ret.pageX = event.clientX + (box.scrollLeft >> 0) - (box.clientLeft >> 0) - ret.pageY = event.clientY + (box.scrollTop >> 0) - (box.clientTop >> 0) - ret.wheelDeltaY = ret.wheelDelta - ret.wheelDeltaX = 0 - } - ret.timeStamp = new Date() - 0 - ret.originalEvent = event - ret.preventDefault = function () { //阻止默认行为 - event.returnValue = false - } - ret.stopPropagation = function () { //阻止事件在DOM树中的传播 - event.cancelBubble = true - } - return ret -} -var eventHooks = avalon.eventHooks -//针对firefox, chrome修正mouseenter, mouseleave -if (!("onmouseenter" in root)) { - avalon.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" - }, function (origType, fixType) { - eventHooks[origType] = { - type: fixType, - deel: function (elem, _, fn) { - return function (e) { - var t = e.relatedTarget - if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) { - delete e.type - e.type = origType - return fn.call(elem, e) - } - } - } - } - }) -} -//针对IE9+, w3c修正animationend -avalon.each({ - AnimationEvent: "animationend", - WebKitAnimationEvent: "webkitAnimationEnd" -}, function (construct, fixType) { - if (window[construct] && !eventHooks.animationend) { - eventHooks.animationend = { - type: fixType - } - } -}) -//针对IE6-8修正input -if (!("oninput" in DOC.createElement("input"))) { - eventHooks.input = { - type: "propertychange", - deel: function (elem, _, fn) { - return function (e) { - if (e.propertyName === "value") { - e.type = "input" - return fn.call(elem, e) - } - } - } - } -} -if (DOC.onmousewheel === void 0) { - /* IE6-11 chrome mousewheel wheelDetla 下 -120 上 120 - firefox DOMMouseScroll detail 下3 上-3 - firefox wheel detlaY 下3 上-3 - IE9-11 wheel deltaY 下40 上-40 - chrome wheel deltaY 下100 上-100 */ - var fixWheelType = DOC.onwheel !== void 0 ? "wheel" : "DOMMouseScroll" - var fixWheelDelta = fixWheelType === "wheel" ? "deltaY" : "detail" - eventHooks.mousewheel = { - type: fixWheelType, - deel: function (elem, _, fn) { - return function (e) { - e.wheelDeltaY = e.wheelDelta = e[fixWheelDelta] > 0 ? -120 : 120 - e.wheelDeltaX = 0 - if (Object.defineProperty) { - Object.defineProperty(e, "type", { - value: "mousewheel" - }) - } - fn.call(elem, e) - } - } - } -} diff --git a/src/05 dom.polyfill.modern.js b/src/05 dom.polyfill.modern.js index 75d06ed99..4c8ac9347 100644 --- a/src/05 dom.polyfill.modern.js +++ b/src/05 dom.polyfill.modern.js @@ -86,58 +86,3 @@ if (window.SVGElement) { }) } } -//========================= event binding ==================== -var eventHooks = avalon.eventHooks -//针对firefox, chrome修正mouseenter, mouseleave(chrome30+) -if (!("onmouseenter" in root)) { - avalon.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" - }, function (origType, fixType) { - eventHooks[origType] = { - type: fixType, - deel: function (elem, _, fn) { - return function (e) { - var t = e.relatedTarget - if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) { - delete e.type - e.type = origType - return fn.call(elem, e) - } - } - } - } - }) -} -//针对IE9+, w3c修正animationend -avalon.each({ - AnimationEvent: "animationend", - WebKitAnimationEvent: "webkitAnimationEnd" -}, function (construct, fixType) { - if (window[construct] && !eventHooks.animationend) { - eventHooks.animationend = { - type: fixType - } - } -}) - -if (DOC.onmousewheel === void 0) { - /* IE6-11 chrome mousewheel wheelDetla 下 -120 上 120 - firefox DOMMouseScroll detail 下3 上-3 - firefox wheel detlaY 下3 上-3 - IE9-11 wheel deltaY 下40 上-40 - chrome wheel deltaY 下100 上-100 */ - eventHooks.mousewheel = { - type: "wheel", - deel: function (elem, _, fn) { - return function (e) { - e.wheelDeltaY = e.wheelDelta = e.deltaY > 0 ? -120 : 120 - e.wheelDeltaX = 0 - Object.defineProperty(e, "type", { - value: "mousewheel" - }) - fn.call(elem, e) - } - } - } -} diff --git a/src/08 modelFactory.js b/src/08 modelFactory.js index c1c70fbdf..34ff77031 100644 --- a/src/08 modelFactory.js +++ b/src/08 modelFactory.js @@ -18,7 +18,7 @@ avalon.define = function (id, factory) { $watch: noop } factory(scope) //得到所有定义 - + model = modelFactory(scope) //偷天换日,将scope换为model stopRepeatAssign = true factory(model) @@ -29,7 +29,7 @@ avalon.define = function (id, factory) { } //一些不需要被监听的属性 -var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy").match(rword) +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$compute").match(rword) var defineProperty = Object.defineProperty var canHideOwn = true //如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 @@ -122,7 +122,7 @@ function modelFactory(source, $special, $model) { } /* jshint ignore:end */ } - + $vmodel.$compute = function () { computed.forEach(function (accessor) { dependencyDetection.begin({ @@ -170,7 +170,7 @@ function makeComputedAccessor(name, options) { options.set = options.set || noop function accessor(value) {//计算属性 var oldValue = accessor._value - var init = "_value" in accessor + var init = "_value" in accessor if (arguments.length > 0) { if (stopRepeatAssign) { return this @@ -182,7 +182,7 @@ function makeComputedAccessor(name, options) { value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) - init && accessor.notify(this, value, oldValue) //触发$watch回调 + init && accessor.notify(this, value, oldValue) //触发$watch回调 } //将自己注入到低层访问器的订阅数组中 return value @@ -227,10 +227,11 @@ function makeComplexAccessor(name, initValue, valueType, list) { son.$events[subscribers] = observes son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) } diff --git a/src/08 modelFactory.modern.js b/src/08 modelFactory.modern.js index 10e66a98f..1c34c645d 100644 --- a/src/08 modelFactory.modern.js +++ b/src/08 modelFactory.modern.js @@ -48,12 +48,10 @@ function modelFactory(source, $special, $model) { $model = $model || {} //vmodels.$model属性 var $events = createMap() //vmodel.$events属性 var accessors = createMap() //监控属性 - var initCallbacks = [] //初始化才执行的函数 - + var computed = [] $$skipArray.forEach(function (name) { delete source[name] }) - for (var i in source) { (function (name, val, accessor) { $model[name] = val @@ -66,13 +64,9 @@ function modelFactory(source, $special, $model) { //总共产生三种accessor if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { accessor = makeComputedAccessor(name, val) - initCallbacks.push(accessor) + computed.push(accessor) } else if (rcomplexType.test(valueType)) { - accessor = makeComplexAccessor(name, val, valueType) - initCallbacks.push(function () { - var son = accessor._vmodel - son.$events[subscribers] = this.$events[name] - }) + accessor = makeComplexAccessor(name, val, valueType, $events[name]) } else { accessor = makeSimpleAccessor(name, val) } @@ -102,10 +96,26 @@ function modelFactory(source, $special, $model) { enumerable: false, configurable: true }) - - initCallbacks.forEach(function (cb) { //收集依赖 - cb.call($vmodel) - }) + $vmodel.$compute = function () { + computed.forEach(function (accessor) { + dependencyDetection.begin({ + callback: function (vm, dependency) {//dependency为一个accessor + var name = dependency._name + if (dependency !== accessor) { + var list = vm.$events[name] + accessor.vm = $vmodel + injectDependency(list, accessor.digest) + } + } + }) + try { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$compute() return $vmodel } @@ -114,10 +124,7 @@ function makeSimpleAccessor(name, value) { function accessor(value) { var oldValue = accessor._value if (arguments.length > 0) { - if (stopRepeatAssign) { - return this - } - if (!isEqual(value, oldValue)) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { accessor.updateValue(this, value) accessor.notify(this, value, oldValue) } @@ -146,35 +153,7 @@ function makeComputedAccessor(name, options) { return this } else { //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 - dependencyDetection.collectDependency(this, accessor) - if (!accessor.digest) { - var vm = this - var id - accessor.digest = function () { - accessor.updateValue = globalUpdateModelValue - accessor.notify = noop - accessor.call(vm) - clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 - id = setTimeout(function () { - accessorFactory(accessor, accessor._name) - accessor.call(vm) - }) - } - } - dependencyDetection.begin({ - callback: function (vm, dependency) {//dependency为一个accessor - var name = dependency._name - if (dependency !== accessor) { - var list = vm.$events[name] - injectDependency(list, accessor.digest) - } - } - }) - try { - value = accessor.get.call(this) - } finally { - dependencyDetection.end() - } + value = accessor.get.call(this) if (oldValue !== value) { accessor.updateValue(this, value) init && accessor.notify(this, value, oldValue) //触发$watch回调 @@ -182,15 +161,27 @@ function makeComputedAccessor(name, options) { //将自己注入到低层访问器的订阅数组中 return value } + } accessor.set = options.set || noop accessor.get = options.get accessorFactory(accessor, name) + var id + accessor.digest = function () { + accessor.updateValue = globalUpdateModelValue + accessor.notify = noop + accessor.call(accessor.vm) + clearTimeout(id)//如果计算属性存在多个依赖项,那么等它们都更新了才更新视图 + id = setTimeout(function () { + accessorFactory(accessor, accessor._name) + accessor.call(accessor.vm) + }) + } return accessor } //创建一个复杂访问器 -function makeComplexAccessor(name, initValue, valueType) { +function makeComplexAccessor(name, initValue, valueType, list) { function accessor(value) { var oldValue = accessor._value var son = accessor._vmodel @@ -210,10 +201,11 @@ function makeComplexAccessor(name, initValue, valueType) { son = accessor._vmodel = modelFactory(value) son.$proxy = $proxy if (observes.length) { - observes.forEach(function (data) { - if (data.rollback) { - data.rollback() //还原 ms-with ms-on - bindingHandlers[data.type](data, data.vmodels) + observes.forEach(function (el) { + var fn = bindingHandlers[el.type] + if (fn) { //#753 + el.rollback && el.rollback() //还原 ms-with ms-on + fn(el, el.vmodels) } }) son.$events[name] = observes @@ -228,7 +220,8 @@ function makeComplexAccessor(name, initValue, valueType) { } } accessorFactory(accessor, name) - accessor._vmodel = modelFactory(initValue) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list return accessor } diff --git a/src/10 dependency.js b/src/10 dependency.js index e11daffe1..9f4e0d677 100644 --- a/src/10 dependency.js +++ b/src/10 dependency.js @@ -71,11 +71,15 @@ function fireDependencies(list) { for (var i = list.length, fn; fn = list[--i]; ) { var el = fn.element if (el && el.parentNode) { - if (fn.$repeat) { - fn.handler.apply(fn, args) //处理监控数组的方法 - } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 - var fun = fn.evaluator || noop - fn.handler(fun.apply(0, fn.args || []), el, fn) + try { + if (fn.$repeat) { + fn.handler.apply(fn, args) //处理监控数组的方法 + } else if (fn.type !== "on") { //事件绑定只能由用户触发,不能由程序触发 + var fun = fn.evaluator || noop + fn.handler(fun.apply(0, fn.args || []), el, fn) + + } + } catch (e) { } } } diff --git a/src/11 gc.js b/src/11 gc.js index 78a5ba310..27d63f0e7 100644 --- a/src/11 gc.js +++ b/src/11 gc.js @@ -5,10 +5,17 @@ var disposeCount = 0 var disposeQueue = avalon.$$subscribers = [] var beginTime = new Date() var oldInfo = {} -function getUid(obj) { //IE9+,标准浏览器 - return obj.uniqueNumber || (obj.uniqueNumber = ++disposeCount) +var uuid2Node = {} +function getUid(obj, makeID) { //IE9+,标准浏览器 + if (!obj.uuid && !makeID) { + obj.uuid = ++disposeCount + uuid2Node[obj.uuid] = obj + } + return obj.uuid +} +function getNode(uuid) { + return uuid2Node[uuid] } - //添加到回收列队中 function injectDisposeQueue(data, list) { var elem = data.element @@ -29,6 +36,8 @@ function injectDisposeQueue(data, list) { } function rejectDisposeQueue(data) { + if (avalon.optimize) + return var i = disposeQueue.length var n = i var allTypes = [] @@ -59,6 +68,7 @@ function rejectDisposeQueue(data) { if (iffishTypes[data.type] && shouldDispose(data.element)) { //如果它没有在DOM树 disposeQueue.splice(i, 1) delete disposeQueue[data.uuid] + delete uuid2Node[data.element.uuid] var lists = data.lists for (var k = 0, list; list = lists[k++]; ) { avalon.Array.remove(lists, list) diff --git a/src/19 directive/attr.js b/src/19 directive/attr.js index 5c92af00a..4c3731aa2 100644 --- a/src/19 directive/attr.js +++ b/src/19 directive/attr.js @@ -73,6 +73,7 @@ bindingExecutors.attr = function(val, elem, data) { if (method === "css") { avalon(elem).css(attrName, val) } else if (method === "attr") { + // ms-attr-class="xxx" vm.xxx="aaa bbb ccc"将元素的className设置为aaa bbb ccc // ms-attr-class="xxx" vm.xxx=false 清空元素的所有类名 // ms-attr-name="yyy" vm.yyy="ooo" 为元素设置name属性 @@ -91,7 +92,6 @@ bindingExecutors.attr = function(val, elem, data) { if (toRemove) { return elem.removeAttribute(attrName) } - //SVG只能使用setAttribute(xxx, yyy), VML只能使用elem.xxx = yyy ,HTML的固有属性必须elem.xxx = yyy var isInnate = rsvg.test(elem) ? false : (DOC.namespaces && isVML(elem)) ? true : attrName in elem.cloneNode(false) if (isInnate) { diff --git a/src/19 directive/duplex.1.js b/src/19 directive/duplex.1.js index 14eceef10..e2245b735 100644 --- a/src/19 directive/duplex.1.js +++ b/src/19 directive/duplex.1.js @@ -142,7 +142,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (avalon.optimize || this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return @@ -151,16 +151,16 @@ new function() { // jshint ignore:line } } } - var inputProto = HTMLInputElement.prototype - Object.getOwnPropertyNames(inputProto) //故意引发IE6-8等浏览器报错 - setters["INPUT"] = Object.getOwnPropertyDescriptor(aproto, "value").set - Object.defineProperty(aproto, "value", { - set: newSetter - }) - setters["TEXTAREA"] = Object.getOwnPropertyDescriptor(bproto, "value").set - Object.defineProperty(bproto, "value", { - set: newSetter - }) +// var inputProto = HTMLInputElement.prototype +// Object.getOwnPropertyNames(inputProto) //故意引发IE6-8等浏览器报错 +// setters["INPUT"] = Object.getOwnPropertyDescriptor(aproto, "value").set +// Object.defineProperty(aproto, "value", { +// set: newSetter +// }) +// setters["TEXTAREA"] = Object.getOwnPropertyDescriptor(bproto, "value").set +// Object.defineProperty(bproto, "value", { +// set: newSetter +// }) } catch (e) { //在chrome 43中 ms-duplex终于不需要使用定时器实现双向绑定了 // http://updates.html5rocks.com/2015/04/DOM-attributes-now-on-the-prototype diff --git a/src/19 directive/duplex.1.next.js b/src/19 directive/duplex.1.next.js index 96e398025..c953aca67 100644 --- a/src/19 directive/duplex.1.next.js +++ b/src/19 directive/duplex.1.next.js @@ -133,7 +133,7 @@ new function() { // jshint ignore:line var bproto = HTMLTextAreaElement.prototype function newSetter(value) { // jshint ignore:line - if (avalon.contains(root, this)) { + if (this.parentNode) { setters[this.tagName].call(this, value) if (!rmsinput.test(this.type)) return diff --git a/src/19 directive/duplex.2.js b/src/19 directive/duplex.2.js index 810e8a1d6..d035d0312 100644 --- a/src/19 directive/duplex.2.js +++ b/src/19 directive/duplex.2.js @@ -143,7 +143,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } diff --git a/src/19 directive/duplex.2.modern.js b/src/19 directive/duplex.2.modern.js index e0d182242..cf8a7019c 100644 --- a/src/19 directive/duplex.2.modern.js +++ b/src/19 directive/duplex.2.modern.js @@ -100,7 +100,7 @@ duplexBinding.INPUT = function(element, evaluator, data) { }) if (rmsinput.test($type)) { watchValueInTimer(function() { - if (root.contains(element)) { + if (avalon.optimize || element.parentNode) { if (!element.msFocus && element.oldValue !== element.value) { updateVModel() } diff --git a/src/19 directive/on.js b/src/19 directive/on.js index c32e6d739..2490dc326 100644 --- a/src/19 directive/on.js +++ b/src/19 directive/on.js @@ -2,10 +2,6 @@ var rdash = /\(([^)]*)\)/ bindingHandlers.on = function(data, vmodels) { var value = data.value data.type = "on" - var eventType = data.param.replace(/-\d+$/, "") // ms-on-mousemove-10 - if (typeof bindingHandlers.on[eventType + "Hook"] === "function") { - bindingHandlers.on[eventType + "Hook"](data) - } if (value.indexOf("(") > 0 && value.indexOf(")") > -1) { var matched = (value.match(rdash) || ["", ""])[1].trim() if (matched === "" || matched === "$event") { // aaa() aaa($event)当成aaa处理 @@ -15,26 +11,1301 @@ bindingHandlers.on = function(data, vmodels) { parseExprProxy(value, vmodels, data) } -bindingExecutors.on = function(callback, elem, data) { - callback = function(e) { - var fn = data.evaluator || noop - return fn.apply(this, data.args.concat(e)) +bindingExecutors.on = function(_, elem, data) { + var eventType = data.param.replace(/-\d+$/, "") + // avalon.log("绑定" + eventType + "事件!") + var uuid = getUid(elem) + try { + listenTo(eventType, document) + } catch (e) { + avalon.log(e) + } + EventPluginHub.addListener(uuid, eventType, data) + data.rollback = function() { + EventPluginHub.removeListener(uuid, eventType, data) + } +} + +function isEventSupported(eventNameSuffix, capture) { + if (capture && !('addEventListener' in document)) { + return false } - var eventType = data.param.replace(/-\d+$/, "") // ms-on-mousemove-10 - if (eventType === "scan") { - callback.call(elem, { - type: eventType - }) - } else if (typeof data.specialBind === "function") { - data.specialBind(elem, callback) + + var eventName = 'on' + eventNameSuffix; + var isSupported = eventName in document; + if (!isSupported) { + var element = document.createElement('div'); + element.setAttribute(eventName, 'return;'); + isSupported = typeof element[eventName] === 'function'; + } + + if (!isSupported && eventNameSuffix === 'wheel') { + isSupported = !! window.WheelEvent + } + + return isSupported; +} + +function getEventCharCode(nativeEvent) { + var charCode; + var keyCode = nativeEvent.keyCode; + if ('charCode' in nativeEvent) { + charCode = nativeEvent.charCode; + // FF does not set `charCode` for the Enter-key, check against `keyCode`. + if (charCode === 0 && keyCode === 13) { + charCode = 13; + } } else { - var removeFn = avalon.bind(elem, eventType, callback) + // IE8 does not implement `charCode`, but `keyCode` has the correct value. + charCode = keyCode; } - data.rollback = function() { - if (typeof data.specialUnbind === "function") { - data.specialUnbind() + // Some non-printable keys are reported in `charCode`/`keyCode`, discard them. + // Must not discard the (non-)printable Enter-key. + if (charCode >= 32 || charCode === 13) { + return charCode; + } + return 0; +} + +var isListening = {} + + function listenTo(eventType, mountAt) { + //通过事件名得到对应的插件 + var plugin = getPluginByEventType(eventType) + if (!plugin) { + avalon.log(eventType + " 事件不存在对应的插件模块 !") + } + //得到对应的依赖 + var dependencies = plugin ? plugin.eventTypes[eventType].dependencies : [eventType] + //IE6-8下`keyup`/`keypress`/`keydown` 只能冒泡到 document + for (var i = 0; i < dependencies.length; i++) { + var dependency = dependencies[i]; + if (isListening[dependency] !== true) { + if (dependency === "scroll") { + if (W3C) { + addCapturedEvent("scroll", 'scroll', mountAt) + } else { + addBubbledEvent("scroll", 'scroll', window) + } + } else if (dependency === "select" && W3C) { + addBubbledEvent("select", 'select', mountAt) + } else if (dependency === "focus" || dependency === "blur") { + if (W3C) { + addCapturedEvent("focus", 'focus', mountAt); + addCapturedEvent("blur", 'blur', mountAt); + } else if (isEventSupported("focusin")) { + addBubbledEvent("focus", 'focusin', mountAt); + addBubbledEvent("blur", 'focusout', mountAt); + } + isListening.focus = true + isListening.blur = true + } else { + addBubbledEvent(eventType, dependency, mountAt); + } + isListening[dependency] = true; + } + } + } + +var addBubbledEvent = function(topLevelType, type, element) { + return addEventListener(element, type, function(nativeEvent) { + topEventListener(nativeEvent, topLevelType) + }) +} +var addCapturedEvent = function(topLevelType, type, element) { + return addEventListener(element, type, function(nativeEvent) { + topEventListener(nativeEvent, topLevelType) + }, true) +} + + function addEventListener(target, eventType, callback, capture) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, !! capture) + return { + remove: function() { + target.removeEventListener(eventType, callback, !! capture) + } + } + } else if (target.attachEvent) { + target.attachEvent('on' + eventType, callback) + return { + remove: function() { + target.detachEvent('on' + eventType, callback) + } + } + } + } + //顶层事件监听器 + + function topEventListener(nativeEvent, topLevelType) { + var topLevelTarget = nativeEvent.target || nativeEvent.srcElement + var ancestors = [] + var ancestor = topLevelTarget + while (ancestor && ancestor.nodeType) { + ancestors.push(ancestor) + ancestor = ancestor.parentNode + } + var uuids = [] + while (ancestor = ancestors.shift()) { + uuids.push(getUid(ancestor)) + } + //收集事件 + var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, nativeEvent, uuids) + //执行所有回调 + events.forEach(executeDispatchesAndRelease) + } + + + function executeDispatchesAndRelease(event) { + if (event) { + var callback = executeDispatch; + var PluginModule = getPluginByEventType(event.type); + if (PluginModule && PluginModule.executeDispatch) { + callback = PluginModule.executeDispatch; + } + var dispatchListeners = event._dispatchListeners + var dispatchIDs = event._dispatchIDs + // avalon.log("执行所有回调" + event.type) + for (var i = 0; i < dispatchListeners.length; i++) { + if (event.isPropagationStopped) { + break + } + callback(event, dispatchListeners[i], dispatchIDs[i]) + } + // eventFactory.release(event) + } + } + + //执行单个事件回调 + + function executeDispatch(event, fn, domID) { + var elem = event.currentTarget = getNode(domID); + if (typeof fn === "function") { + var returnValue = fn.call(elem, event) + } else if (fn.args) { + var callback = fn.evaluator || noop + returnValue = callback.apply(elem, fn.args.concat(event)) + } + event.currentTarget = null; + return returnValue; + } + + + //=================事件工厂=================== +var eventFactory = (function() { + var eventPool = [] + + function eventFactory(nativeEvent, type) { + var event = eventPool.shift() + if (!event) { + event = new SyntheticEvent() + } + event.timeStamp = new Date() - 0 + event.nativeEvent = nativeEvent + event.type = type + var target = nativeEvent.target || nativeEvent.srcElement || window + if (target.nodeType === 3) { + target = target.parentNode + } + event.target = target + return event + } + eventFactory.release = function(event) { + for (var i in event) { + if (event.hasOwnProperty(i)) { + event[i] = null + } + } + if (eventPool.length < 20) { + eventPool.push(event) + } + } + + function SyntheticEvent() {} + var ep = SyntheticEvent.prototype + //阻止默认行为 + ep.preventDefault = function() { + if (this.nativeEvent.preventDefault) { + this.nativeEvent.preventDefault(); } else { - avalon.unbind(elem, eventType, removeFn) + this.nativeEvent.returnValue = false; + } + } + //阻止事件往上下传播 + ep.stopPropagation = function() { + this.isPropagationStopped = true; + if (this.nativeEvent.stopPropagation) { + this.nativeEvent.stopPropagation(); + } + this.nativeEvent.cancelBubble = true; + } + + //阻止事件往上下传播 + ep.stopImmediatePropagation = function() { + //阻止事件在一个元素的同种事件的回调中传播 + this.isImmediatePropagationStopped = true + this.stopPropagation() + } + return eventFactory +})() + + + +//==================================================== +var callbackPool = {}; +var EventPluginHub = { + //添加事件回调到 回调池 中 + addListener: function(id, type, callback) { + var pool = callbackPool[type] || (callbackPool[type] = {}); + if (pool[id]) { + pool[id].push(callback) + } else { + pool[id] = [callback] + } + var plugin = getPluginByEventType(type) + if (plugin && plugin.didPutListener) { + plugin.didPutListener(id, type, callback); + } + }, + getListener: function(id, eventType) { + var pool = callbackPool[eventType] + return pool && pool[id] || [] + }, + removeListener: function(id, type, fn) { + var plugin = getPluginByEventType(type) + if (plugin && plugin.willDeleteListener) { + plugin.willDeleteListener(id, type); + } + var pool = callbackPool[type] + if (pool) { + if (fn) { + avalon.Array.remove(pool[id], fn) + } else { + delete pool[id] + } + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + var events = [] + if (!topLevelTarget) { + return events + } + var plugins = EventPluginRegistry.plugins; + for (var i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; + if (possiblePlugin) { + + var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, nativeEvent, uuids) + if (extractedEvents) { + extractedEvents.plugn = possiblePlugin.name + events = events.concat(extractedEvents); + } + } + } + return events; + } +} + + function collectDispatches(event, uuids) { + //收集事件回调 + var _dispatchListeners = [] + var _dispatchIDs = [] + for (var i = 0, n = uuids.length; i < n; i++) { + var id = uuids[i] + //从事件仓库中取得回调数组 + var listener = EventPluginHub.getListener(id, event.type) + var node = getNode(id) + //从元素上取得直接用onxxx绑定的回调 + var onFn = node && node["on" + event.type] + if (typeof onFn === "function") { + listener.push(onFn) + } + var jn = listener.length + if (jn) { + for (var j = 0; j < jn; j++) { + _dispatchListeners.push(listener[j]) + _dispatchIDs.push(id) + } + } + } + event._dispatchListeners = _dispatchListeners + event._dispatchIDs = _dispatchIDs + } + + //-------------------------------- + // SimpleEventPlugin +var SimpleEventPlugin = (function() { + var EventTypes = {} + var onClickListeners = {} + String("click,contextmenu,doubleclick,keydown,keypress,keyup,focus,blur,copy,cut,paste," + //键盘点击 + "drag,dragend,dragenter,dragexit,dragleave,touchcancel,touchend,touchstart,touchmove," + //拖放触摸 + "mousedown,mousemove,mouseout,mouseover,mouseup," + //鼠标操作 + "load,error,reset,scroll").toLowerCase().replace(rword, function(eventName) { + EventTypes[eventName] = { + dependencies: [eventName] + } + }) + var EventPlugin = { + name: "SimpleEventPlugin", + eventTypes: EventTypes, + executeDispatch: function(event, listener, domID) { + var returnValue = executeDispatch(event, listener, domID); + if (returnValue === false) { + event.stopPropagation() + event.preventDefault() + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!EventTypes[topLevelType]) { + return null; + } + var eventDecorator; + switch (topLevelType) { + case "load": + case "error": + case "reset": + eventDecorator = simulateHTMLEvent + break + /* jshint ignore:start */ + case "keypress": + // FireFox creates a keypress event for function keys too. This removes + // the unwanted keypress events. Enter is however both printable and + // non-printable. One would expect Tab to be as well (but it isn't). + if (getEventCharCode(nativeEvent) === 0) { + return null; + } + + case "keydown": + case "keyup": + eventDecorator = simulateKeyboardEvent + break + /* jshint ignore:end */ + case "blur": + case "focus": + eventDecorator = simulateFocusEvent; + break + /* jshint ignore:start */ + case "click": + // Firefox creates a click event on right mouse clicks. This removes the + // unwanted click events. + if (nativeEvent.button === 2) { + return null; + } + case "contextenu": + /* jshint ignore:end */ + case "doubleclick": + case "mousedown": + case "mousemove": + case "mouseout": + case "mouseover": + case "mouseup": + eventDecorator = simulateMouseEvent; + break; + case "drag": + case "dragend": + case "dragenter": + case "dragexit": + case "dragleave": + case "dragover": + case "dragstart": + case "drop": + eventDecorator = simulateDragEvent; + break; + case "touchcancel": + case "touchend": + case "touchmove": + case "touchstart": + eventDecorator = simulateTouchEvent; + break; + case "scroll": + eventDecorator = simulateUIEvent; + break; + case "copy": + case "cut": + case "paste": + eventDecorator = simulateClipboardEvent; + break; + } + if (eventDecorator) { + var event = eventFactory(nativeEvent, topLevelType) + eventDecorator(event, nativeEvent) + collectDispatches(event, uuids) //收集回调 + return event + } + }, + didPutListener: function(id, type) { + // Mobile Safari does not fire properly bubble click events on + // non-interactive elements, which means delegated click listeners do not + // fire. The workaround for this bug involves attaching an empty click + // listener on the target node. + if (type === "click") { + if (!onClickListeners[id]) { + onClickListeners[id] = addEventListener(getNode(id), 'click', noop); + } + } + }, + willDeleteListener: function(id, type) { + if (type === "click") { + onClickListeners[id].remove(); + delete onClickListeners[id]; + } + } + } + // 各类型事件的装饰器 + // http://www.w3.org/TR/html5/index.html#events-0 + + function simulateHTMLEvent(event, nativeEvent) { + var _interface = "eventPhase,cancelable,bubbles" + _interface.replace(rword, function(name) { + event[name] = nativeEvent[name] + }) + } + + function simulateUIEvent(event, nativeEvent) { + simulateHTMLEvent(event, nativeEvent) + event.view = nativeEvent.view || window + event.detail = nativeEvent.detail || 0 + } + + function simulateTouchEvent(event, nativeEvent) { + simulateUIEvent(event, nativeEvent) + var _interface = "touches,targetTouches,changedTouches,ctrlKey,shiftKey,metaKey,altKey" + _interface.replace(rword, function(name) { + event[name] = nativeEvent[name] + }) + } + + //http://www.w3.org/TR/DOM-Level-3-Events/ + + function simulateFocusEvent(event, nativeEvent) { + simulateUIEvent(event, nativeEvent) + event.relatedTarget = nativeEvent.relatedTarget + } + + + function simulateClipboardEvent(event, nativeEvent) { + simulateHTMLEvent(event, nativeEvent) + event.clipboardData = 'clipboardData' in nativeEvent ? nativeEvent.clipboardData : window.clipboardData + } + + + function simulateKeyboardEvent(event, nativeEvent) { + simulateUIEvent(event, nativeEvent) + var _interface = "ctrlKey,shiftKey,metaKey,altKey,repeat,locale,location" + _interface.replace(rword, function(name) { + event[name] = nativeEvent[name] + }) + if (event.type === 'keypress') { + event.charCode = getEventCharCode(event) + event.keyCode = 0 + } else if (event.type === 'keydown' || event.type === 'keyup') { + event.charCode = 0 + event.keyCode = nativeEvent.keyCode + } + event.which = event.type === 'keypress' ? event.charCode : event.keyCode + } + + function simulateMouseEvent(event, nativeEvent) { + simulateUIEvent(event, nativeEvent) + var _interface = "screenX,screenY,clientX,clientY,ctrlKey,shiftKey,altKey,metaKey" + _interface.replace(rword, function(name) { + event[name] = nativeEvent[name] + }) + // Webkit, Firefox, IE9+ + // which: 1 2 3 + // button: 0 1 2 (standard) + var button = nativeEvent.button; + if ('which' in nativeEvent) { + event.which = button + } else { + // IE<9 + // which: undefined + // button: 0 0 0 + // button: 1 4 2 (onmouseup) + event.which = button === 2 ? 2 : button === 4 ? 1 : 0; + } + if (!isFinite(event.pageX)) { + var target = event.target + var doc = target.ownerDocument || DOC + var box = doc.compatMode === "BackCompat" ? doc.body : doc.documentElement + event.pageX = event.clientX + (box.scrollLeft >> 0) - (box.clientLeft >> 0) + event.pageY = event.clientY + (box.scrollTop >> 0) - (box.clientTop >> 0) + } + } + + function simulateDragEvent(event, nativeEvent) { + simulateMouseEvent(event, nativeEvent) + event.dataTransfer = nativeEvent.dataTransfer + } + return EventPlugin +})() +//https://github.com/jquery/jquery-mousewheel/blob/master/jquery.mousewheel.js +var WheelEventPlugin = (function() { + var dependencies = ('onwheel' in document || document.documentMode >= 9) ? ['wheel'] : + isEventSupported("mousewheel") ? ['mousewheel'] : + ['DomMouseScroll', 'MozMousePixelScroll'] + + function ajusetNumber(delta) { + return delta === 0 ? 0 : delta > 0 ? 120 : -120 } + var EventPlugin = { + name: "WheelEventPlugin", + eventTypes: { + mousewheel: { + dependencies: dependencies + }, + wheel: { + dependencies: dependencies + } + }, + extractEvents: function(topLevelType, topLevelTarget, orgEvent, uuids) { + if (dependencies.indexOf(topLevelType) === -1) { + return + } + var delta = 0 + var deltaX = 0 + var deltaY = 0 + //从原始事件对象抽取有用信息 + if ('detail' in orgEvent) { + deltaY = orgEvent.detail * -1; + } + if ('wheelDelta' in orgEvent) { + deltaY = orgEvent.wheelDelta; + } + if ('wheelDeltaY' in orgEvent) { + deltaY = orgEvent.wheelDeltaY; + } + if ('wheelDeltaX' in orgEvent) { + deltaX = orgEvent.wheelDeltaX * -1; + } + + // Firefox < 17 horizontal scrolling related to DOMMouseScroll event + if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) { + deltaX = deltaY * -1; + deltaY = 0; + } + + // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy + delta = deltaY === 0 ? deltaX : deltaY; + + // 如果是wheel事件 + if ('deltaY' in orgEvent) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ('deltaX' in orgEvent) { + deltaX = orgEvent.deltaX; + if (deltaY === 0) { + delta = deltaX * -1; + } + } + // 如果没有移动过,就立即返回 + if (deltaY === 0 && deltaX === 0) { + return; + } + + var event = eventFactory(orgEvent, topLevelType) + + event.deltaX = ajusetNumber(deltaX) + event.deltaY = ajusetNumber(deltaY) + event.delta = ajusetNumber(delta) + + collectDispatches(event, uuids) //收集回调 + return event + } + } + return EventPlugin +})() + +var ResponderEventPlugin = { + extractEvents: noop +} +var TapEventPlugin = (function() { + function isEndish(topLevelType) { + return topLevelType === "mouseup" || + topLevelType === "touchend" || + topLevelType === "touchcancel"; + } + + function isMoveish(topLevelType) { + return topLevelType === "mousemove" || + topLevelType === "touchmove"; + } + + function isStartish(topLevelType) { + return topLevelType === "mousedown" || + topLevelType === "touchstart"; + } + var touchEvents = [ + "touchstart", + "touchcanel", + "touchend", + "touchmove" + ] + /** + * Number of pixels that are tolerated in between a `touchStart` and `touchEnd` + * in order to still be considered a 'tap' event. + */ + var tapMoveThreshold = 10; + var startCoords = { + x: null, + y: null + }; + var Axis = { + x: { + page: 'pageX', + client: 'clientX', + envScroll: 'scrollLeft' + }, + y: { + page: 'pageY', + client: 'clientY', + envScroll: 'scrollTop' + } + }; + var extractSingleTouch = function(nativeEvent) { + var touches = nativeEvent.touches; + var changedTouches = nativeEvent.changedTouches; + var hasTouches = touches && touches.length > 0; + var hasChangedTouches = changedTouches && changedTouches.length > 0; + + return !hasTouches && hasChangedTouches ? changedTouches[0] : + hasTouches ? touches[0] : + nativeEvent; + } + + function getAxisCoordOfEvent(axis, nativeEvent) { + var singleTouch = extractSingleTouch(nativeEvent); + if (singleTouch) { + return singleTouch[axis.page]; + } + return axis.page in nativeEvent ? + nativeEvent[axis.page] : + nativeEvent[axis.client] + root[axis.envScroll]; + } + + function getDistance(coords, nativeEvent) { + var pageX = getAxisCoordOfEvent(Axis.x, nativeEvent); + var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent); + return Math.pow( + Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2), + 0.5 + ); + } + var usedTouch = false; + var usedTouchTime = 0; + var TOUCH_DELAY = 1000; + var EventPlugin = { + name: "TapEventPlugin", + tapMoveThreshold: tapMoveThreshold, + eventTypes: { + tap: { + dependencies: touchEvents.concat("mousedown", "mouseup", "mouseup") + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!isStartish(topLevelType) && !isEndish(topLevelType)) { + return null; + } + // on ios, there is a delay after touch event and synthetic + // mouse events, so that user can perform double tap + // solution: ignore mouse events following touchevent within small timeframe + if (touchEvents.indexOf(topLevelType) !== -1) { + usedTouch = true; + usedTouchTime = new Date() - 0; + } else { + if (usedTouch && (new Date() - usedTouchTime < TOUCH_DELAY)) { + return null; + } + } + var event = null; + var distance = getDistance(startCoords, nativeEvent); + if (isEndish(topLevelType) && distance < tapMoveThreshold) { + event = eventFactory(nativeEvent, "tap") + } + if (isStartish(topLevelType)) { + startCoords.x = getAxisCoordOfEvent(Axis.x, nativeEvent); + startCoords.y = getAxisCoordOfEvent(Axis.y, nativeEvent); + } else if (isEndish(topLevelType)) { + startCoords.x = 0; + startCoords.y = 0; + } + event && collectDispatches(event, uuids) + + return event; + } + } + return EventPlugin +})() +var EnterLeaveEventPlugin = { + name: "EnterLeaveEventPlugin", + eventTypes: { + mouseenter: { + dependencies: [ + "mouseout", + "mouseover" + ] + }, + mouseleave: { + dependencies: [ + "mouseout", + "mouseover" + ] + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent) { + if (topLevelType === "mouseout" || topLevelType === "mouseover") { + + var related = nativeEvent.relatedTarget || (topLevelType === "mouseover" ? + nativeEvent.fromElement : nativeEvent.toElement) + + if (!related || (related !== topLevelTarget && !avalon.contains(topLevelTarget, related))) { + var type = topLevelType === "mouseout" ? "mouseleave" : "mouseenter" + var id = getUid(topLevelTarget) + var listener = EventPluginHub.getListener(id, type) + if (listener && listener.length) { + var event = eventFactory(nativeEvent, type) + event._dispatchIDs = [id] + event._dispatchListeners = listener + return event + } + } + } + } +} +//================================== +var SubmitEventPlugin = (function() { + //IE6-8, submit事件只能冒泡到form元素 + var dependencies = ["submit"] + if (IEVersion < 9) { + dependencies.push("click", "keypress") + } + var EventPlugin = { + name: "SubmitEventPlugin", + eventTypes: { + submit: { + dependencies: dependencies + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (dependencies.indexOf(topLevelType) === -1) { + return + } + + var elementType = topLevelTarget.nodeName.toLowerCase() + if (elementType === 'input' || elementType === 'button') { + if (!topLevelTarget.form) { + return + } + elementType = topLevelTarget.type + } else if (elementType !== "form") { + return + } + + switch (elementType) { + case "reset": + case "hidden": + case "radio": + case "checkbox": + return + case "button": //IE8-11 点击[button]可以触发submit,IE6,7不可以 + case "submit": + if (topLevelType === "keypress") { + return + } + break + default: + if (topLevelType !== "submit") { + var which = nativeEvent.which || nativeEvent.keyCode + if (which !== 13) { + return + } + } + } + var event = eventFactory(nativeEvent, "submit") + collectDispatches(event, uuids) //收集回调 + return event + } + } + return EventPlugin +})() +//================================== +var ChangeEventPlugin = (function() { + var activeElement + + function startWatchingForChangeEventIE(target) { + activeElement = target + activeElement.attachEvent('onchange', isChange); + } + + function stopWatchingForChangeEventIE() { + if (!activeElement) { + return; + } + activeElement.detachEvent('onchange', isChange) + } + + function isChange() { + if (activeElement) { + var hackEvent = DOC.createEventObject() + hackEvent.isChangeEvent = true + activeElement.fireEvent("ondatasetchanged", hackEvent) + } + } + + + var EventPlugin = { + name: "ChangeEventPlugin", + eventTypes: { + change: { + dependencies: [ + "blur", + "change", + "click", + "focus", + "datasetchanged" + ] + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + var elementType = topLevelTarget.nodeName.toLowerCase() + if (elementType === "select" || elementType === "textarea" || elementType === "input") { + if (elementType === "input") { + elementType = topLevelTarget.type + } + var nativeType = nativeEvent.type + var isChange = false + switch (elementType) { + case "button": + case "submit": + case "reset": + return + case "select": + case "file": + if (W3C) { //如果支持change事件冒泡 + isChange = nativeType === "change" + } else { + if (nativeType === "datasetchanged") { + isChange = nativeEvent.isChangeEvent === true + } + // 这里的事件依次是 focus change click blur + if (nativeType === "click") { + stopWatchingForChangeEventIE() + startWatchingForChangeEventIE(topLevelTarget) + } else if (nativeType === "focusout") { + stopWatchingForChangeEventIE() + } + } + break + case "radio": + case "checkbox": + if (nativeType === "focus" || nativeType === "focusin") { + topLevelTarget.oldChecked = topLevelTarget.checked + } else if (nativeType === "click") { + if (topLevelTarget.oldChecked !== topLevelTarget.checked) { + isChange = true + topLevelTarget.oldChecked = topLevelTarget.checked + } + } + break + default: //其他控件的change事件需要在失去焦点时才触发 + if (W3C) { //如果支持change事件冒泡 + isChange = nativeType === "change" + } else { + if (topLevelType === "focus") { + topLevelTarget.oldValue = topLevelTarget.value + } else if (topLevelType === "blur") { + if (topLevelTarget.oldValue !== topLevelTarget.value) { + isChange = topLevelTarget.oldValue !== void 0 + topLevelTarget.oldValue = topLevelTarget.value + } + } + } + break + } + if (isChange) { + var event = eventFactory(nativeEvent, "change") + collectDispatches(event, uuids) + return event + } + } + } + } + return EventPlugin +})() + + + +/** + * Same as document.activeElement but wraps in a try-catch block. In IE it is + * not safe to call document.activeElement if there is nothing focused. + * + * The activeElement will be null only if the document body is not yet defined. + */ + + function getActiveElement() /*?DOMElement*/ { + try { + return document.activeElement || document.body; + } catch (e) { + return document.body; + } + } + +var SelectEventPlugin = (function() { + var activeElement = null; + var lastSelection = null; + var mouseDown = false; + // Track whether a listener exists for this plugin. If none exist, we do + // not extract events. + var hasListener = false; + + function getSelection(node) { + if ('selectionStart' in node) { + return { + start: node.selectionStart, + end: node.selectionEnd + }; + } else if (window.getSelection) { //W3C + var selection = window.getSelection(); + return { + anchorNode: selection.anchorNode, + anchorOffset: selection.anchorOffset, + focusNode: selection.focusNode, + focusOffset: selection.focusOffset + }; + } else if (document.selection) { //IE6-8 + var range = document.selection.createRange(); + return { + parentElement: range.parentElement(), + text: range.text, + top: range.boundingTop, + left: range.boundingLeft + }; + } + } + + function shallowEqual(objA, objB) { + if (objA === objB) { + return true; + } + var key; + // Test for A's keys different from B. + for (key in objA) { + if (objA.hasOwnProperty(key) && + (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) { + return false; + } + } + // Test for B's keys missing from A. + for (key in objB) { + if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) { + return false; + } + } + return true; + } + + function selectEventFactory(nativeEvent, uuids) { + // Ensure we have the right element, and that the user is not dragging a + // selection (this matches native `select` event behavior). In HTML5, select + // fires only on input and textarea thus if there's no focused element we + // won't dispatch. + if (mouseDown || activeElement == null || activeElement !== getActiveElement()) { + return null; + } + console.log(mouseDown) + // Only fire when selection has actually changed. + var currentSelection = getSelection(activeElement); + if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) { + lastSelection = currentSelection + var event = eventFactory(nativeEvent, 'select') + event.target = activeElement; + collectDispatches(event, uuids) + return event + } + } + var EventPlugin = { + name: "SelectEventPlugin", + eventTypes: { + select: { + dependencies: [ + "blur", + "contextmenu", + "focus", + "keydown", + "mousedown", + "mouseup", + "dragend" + ] + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (!hasListener) { + return null; + } + switch (topLevelType) { + // Track the input node that has focus. + case "focus": + var canSelected = topLevelTarget.contentEditable === 'true' || + isTextInputElement(topLevelTarget) + if (canSelected) { + activeElement = topLevelTarget + lastSelection = null + } + break; + case "blur": + activeElement = null + lastSelection = null + break; + // Don't fire the event while the user is dragging. This matches the + // semantics of the native select event. + case "mousedown": + mouseDown = true; + break; + case "contextmenu": + case "mouseup": + mouseDown = false + console.log("======") + return selectEventFactory(nativeEvent, uuids) + case "dragend": + return selectEventFactory(nativeEvent, uuids) + } + }, + didPutListener: function(id, type) { + if (type === "select") { + hasListener = true; + } + } + } + return EventPlugin +})() + +var supportedInputTypes = { + 'color': true, + 'date': true, + 'datetime': true, + 'datetime-local': true, + 'email': true, + 'month': true, + 'number': true, + 'password': true, + 'range': true, + 'search': true, + 'tel': true, + 'text': true, + 'time': true, + 'url': true, + 'week': true +}; + +function isTextInputElement(elem) { + return elem && ((elem.nodeName === 'INPUT' ? supportedInputTypes[elem.type] : elem.nodeName === 'TEXTAREA')); +} + + +var InputEventPlugin = (function() { + + + var setters = {} + var useTicker + function newSetter(val) { + setters[this.tagName].call(this, val) + if (this.msInputHack && val !== this.oldValue) { + fireDatasetChanged(this) + } + } + + function msInputHack() { + if (this.parentNode) { + if (this.oldValue !== this.value) { + fireDatasetChanged(this) + } + } else if (!this.msRetain) { + this.msInputHack = null + return false + } + } + + if (Object.getOwnPropertyDescriptor) { + try { + var aproto = HTMLInputElement.prototype + Object.getOwnPropertyNames(aproto) //故意引发IE6-8等浏览器报错 + setters["INPUT"] = Object.getOwnPropertyDescriptor(aproto, "value").set + Object.defineProperty(aproto, "value", { + set: newSetter + }) + var bproto = HTMLTextAreaElement.prototype + setters["TEXTAREA"] = Object.getOwnPropertyDescriptor(bproto, "value").set + Object.defineProperty(bproto, "value", { + set: newSetter + }) + } catch (e) { + avalon.log(e) + useTicker = true + } + } + var activeElement + function valueChange(e) { + if (e.propertyName === "value") { + fireDatasetChanged(activeElement) + } + } + + function selectionChange() { + fireDatasetChanged(activeElement) + } + + function fireDatasetChanged(elem) { + if (elem.oldValue === elem.value) + return + if (DOC.createEvent) { + var hackEvent = DOC.createEvent("Events"); + hackEvent.initEvent("datasetchanged", true, true, {}) + hackEvent.isInputEvent = true + elem.dispatchEvent(hackEvent) + } else { + hackEvent = DOC.createEventObject() + hackEvent.isInputEvent = true + elem.fireEvent("ondatasetchanged", hackEvent) + } + } + var composing = false + var EventPlugin = { + name: "InputEventPlugin", + eventTypes: { + input: { + dependencies: [ + "compositionstart", + "compositionend", + "input", + "DOMAutoComplete", + "focus", + "blur", + "keyup", + "datasetchanged" + ] + } + }, + extractEvents: function(topLevelType, topLevelTarget, nativeEvent, uuids) { + if (isTextInputElement(topLevelTarget)) { + var isValueChange = false + activeElement = topLevelTarget + switch (topLevelType) { + case "compositionstart": + composing = false + break + case "compositionend": + composing = true + break + case "input": + case "DOMAutoComplete": + if (!composing) { + isValueChange = topLevelTarget.oldValue !== topLevelTarget.value + } + break + case "datasetchanged": + isValueChange = nativeEvent.isInputEvent + case "keyup": //fix IE6-8 + isValueChange = topLevelTarget.oldValue !== topLevelTarget.value + break + case "focus": + case "blur": + if (IEVersion < 9) { + //IE6-8下的onpropertychange近乎无敌,可以监听用户或程序做出的任何修改 + //但好像第一次修改时不会触发, 我们可以用keyup事件进行修正 + topLevelTarget.detachEvent("onpropertychange", valueChange) + if (topLevelTarget.msFocus) { + topLevelTarget.attachEvent("onpropertychange", valueChange) + } + } else if (IEVersion === 9) { + //* 改变输入框内容的行为有多种,主要有: + //1.键盘输入(可通过keyup事件处理,但有按键不一定有改变输入的行为) + //2.鼠标拖拽(可通过dragend / drop事件处理) + //3.剪切(可通过cut事件处理,剪切可以通过快捷键也可以通过浏览器菜单,所以keydown/keyup靠不住) + //4.粘贴(可通过paste事件处理,粘贴可以通过快捷键也可以通过浏览器菜单,所以keydown/keyup靠不住) + //5.删除(悲催,并没有一个delete事件,如果是按键来删除还好办,如果是通过上下文菜单来删除,IE9下,propertychange和input都不会触发) + //* IE9的问题在于: + //1. 按键BackSpace / 按键Delete / 拖拽 / 剪切 / 删除,不会触发propertychange和input事件 + //2. addEventListener绑定的propertychange事件无法监听任何改动 + //3. 无法监听中文输入改动 + //* 解决方法 + //1. 使用attachEvent绑定propertychange事件,但还是个残缺品,依然无法处理问题1, 3 + //2. 使用document的selectionchange事件,注意它的target, srcElement永远是document + // 因此需要在focus时绑定,blur时移除,才能区分该selectionchange事件是当前元素触发的 + DOC.removeEventListener("selectionchange", selectionChange, false) + if (topLevelTarget.msFocus) { + DOC.addEventListener("selectionchange", selectionChange, false) + } + } + break + } + if (isValueChange) { + var event = eventFactory(nativeEvent, "input") + collectDispatches(event, uuids) + topLevelTarget.oldValue = topLevelTarget.value + return event + } + } + }, + didPutListener: function(id) { + var element = getNode(id) + if (isTextInputElement(element)) { + if (useTicker) { + element.oldValue = element.value + element.msInputHack = msInputHack + avalon.tick(element.msInputHack) + } else {//IE9+ chrome43+ firefox30+ + // http://updates.html5rocks.com/2015/04/DOM-attributes-now-on-the-prototype + // https://docs.google.com/document/d/1jwA8mtClwxI-QJuHT7872Z0pxpZz8PBkf2bGAbsUtqs/edit?pli=1 + element.msInputHack = true + avalon.log("使用Object.defineProperty重写element.value") + } + } + }, + willDeleteListener: function(id, type, fn) { + var pool = callbackPool[type] + var arr = pool && pool[id] + if (!fn || !arr || (arr.length === 1 && pool[0] === fn)) { + var element = getNode(id) || {} + if (element.msInputHack === true) { + delete element.msInputHack + } else if (element.msInputHack === msInputHack) { + avalon.Array.remove(ribbon, msInputHack) + element.msInputHack = void 0 + } + } + } + } + + return EventPlugin +})() +var AnalyticsEventPlugin = ResponderEventPlugin + +var EventPluginRegistry = { + registrationNameModules: {}, + plugins: [ + ResponderEventPlugin, + SimpleEventPlugin, + SubmitEventPlugin, + WheelEventPlugin, + TapEventPlugin, + EnterLeaveEventPlugin, + ChangeEventPlugin, + SelectEventPlugin, + InputEventPlugin, + AnalyticsEventPlugin + ] +} + +var getPluginByEventType = (function() { + var type2plugin = {} + for (var i = 0, plugin; plugin = EventPluginRegistry.plugins[i++];) { + for (var e in plugin.eventTypes) { + type2plugin[e] = plugin + } + } + avalon.log(type2plugin) + return function(type) { + return type2plugin[type] } -} \ No newline at end of file +})() \ No newline at end of file diff --git a/src/19 directive/repeat.js b/src/19 directive/repeat.js index 535691b9c..eab90ef4e 100644 --- a/src/19 directive/repeat.js +++ b/src/19 directive/repeat.js @@ -116,11 +116,17 @@ bindingExecutors.repeat = function (method, pos, el) { proxy.$outer = data.$outer shimController(data, transation, proxy, fragments) } - parent.insertBefore(transation, comments[pos] || end) + var now = new Date() - 0 + avalon.optimize = avalon.optimize || now for (i = 0; fragment = fragments[i++]; ) { scanNodeArray(fragment.nodes, fragment.vmodels) fragment.nodes = fragment.vmodels = null } + if(avalon.optimize === now){ + delete avalon.optimize + } + parent.insertBefore(transation, comments[pos] || end) + avalon.profile("插入操作花费了 "+ (new Date - now)) break case "del": //将pos后的el个元素删掉(pos, el都是数字) sweepNodes(comments[pos], comments[pos + el] || end) diff --git a/src/21 loader.js b/src/21 loader.js index c3eb1cb1e..581982fde 100644 --- a/src/21 loader.js +++ b/src/21 loader.js @@ -509,7 +509,7 @@ new function () {// jshint ignore:line try { var ret = factory.apply(window, array) } catch (e) { - log("执行[" + id + "]模块的factory抛错: " + e) + log("执行[" + id + "]模块的factory抛错: ", e) } if (ret !== void 0) { module.exports = ret diff --git a/src/21 loader.modern.js b/src/21 loader.modern.js index e9a8d3b00..595693c27 100644 --- a/src/21 loader.modern.js +++ b/src/21 loader.modern.js @@ -480,7 +480,7 @@ new function () {// jshint ignore:line try { var ret = factory.apply(window, array) } catch (e) { - log("执行[" + id + "]模块的factory抛错: " + e) + log("执行[" + id + "]模块的factory抛错: ", e) } if (ret !== void 0) { module.exports = ret