From 32c3629eeee2146c6740f9fa7670321431ac8488 Mon Sep 17 00:00:00 2001 From: "qincheng.zhong" Date: Mon, 13 Jul 2015 19:04:55 +0800 Subject: [PATCH] update --- README.md | 27 +- build.html | 1 + build.js | 6 +- main-built.js | 10759 +++++++++++++++++++++++++++++++++++++++++++++++- main.js | 64 +- 5 files changed, 10831 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index d0a646d3..4e634f18 100644 --- a/README.md +++ b/README.md @@ -187,11 +187,11 @@ main.js是你的入口文件,作用类似于C语言的main函数 require([ "avalon", "domReady!", - "avalon.tab.js", - "avalon.pager.js", - "avalon.datepicker.js" + "./tab/avalon.tab", + "./pager/avalon.pager", + "./datepicker/avalon.datepicker" ], function (avalon) { - avalon.log("domReady完成1") + avalon.log("domReady完成") var vm = avalon.define({$id: "demo"}) avalon.scan(document.body, vm); //你们的业务代码 @@ -201,7 +201,7 @@ require([ 现在除了回调里面的代码是你们写的,其他都是oniui或avalon的文件,如果你们的同事又写一个业务代码,如 ```javascript //aaa.js -require(["avalon.dropdown"], function(){ +require(["./dropdown/avalon.dropdown"], function(){ //你们的业务代码 }) ``` @@ -210,12 +210,12 @@ require(["avalon.dropdown"], function(){ require([ "avalon", "domReady!", - "avalon.tab", - "avalon.pager", - "avalon.datepicker", + "./tab/avalon.tab", + "./pager/avalon.pager", + "./datepicker/avalon.datepicker" "./aaa" ], function (avalon) { - avalon.log("domReady完成1") + avalon.log("domReady完成") var vm = avalon.define({$id: "demo"}) avalon.scan(document.body, vm); //你们的业务代码 @@ -237,10 +237,8 @@ require([ "css-builder": "./combo/css-builder", "normalize": "./combo/normalize", domReady: "./combo/domReady", - "avalon.tab": "./tab/avalon.tab", - "avalon.pager": "./pager/avalon.pager", - "avalon.datepicker": "./datepicker/avalon.datepicker" }, + //optimize: "none",//如果要调试就不压缩 name: "main", //如果从哪一个文件开始合并 out: "./main-built.js" //确定要生成的文件路径及名字 }) @@ -253,11 +251,6 @@ require([ - - - - - 如何为OniUI贡献一套新的皮肤 ========================== chameleon是OniUI的皮肤生成系统,基于sass的compass框架改写而成. diff --git a/build.html b/build.html index 6d7140ee..7b47f6ff 100644 --- a/build.html +++ b/build.html @@ -10,6 +10,7 @@
+
diff --git a/build.js b/build.js index b76c431f..7c2d75bf 100644 --- a/build.js +++ b/build.js @@ -1,4 +1,5 @@ ({ + baseUrl: "./", //找到main.js文件的目录 paths: { avalon: "./avalon.shim", @@ -7,10 +8,9 @@ "css-builder": "./combo/css-builder", "normalize": "./combo/normalize", domReady: "./combo/domReady", - "avalon.tab": "./tab/avalon.tab", - "avalon.pager": "./pager/avalon.pager", - "avalon.datepicker": "./datepicker/avalon.datepicker" }, + + //optimize: "none",//如果要调试就不压缩 name: "main", //如果从哪一个文件开始合并 out: "./main-built.js" //确定要生成的文件路径及名字 }) diff --git a/main-built.js b/main-built.js index e1836354..2d642304 100644 --- a/main-built.js +++ b/main-built.js @@ -8,17 +8,10774 @@ avalon.shim.js(无加载器版本) 1.45 built in 2015.7.13 support IE6+ and other browsers ==================================================*/ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") { + // For CommonJS and CommonJS-like environments where a proper `window` + // is present, execute the factory and get avalon. + // For environments that do not have a `window` with a `document` + // (such as Node.js), expose a factory as module.exports. + // This accentuates the need for the creation of a real `window`. + // e.g. var avalon = require("avalon")(window); + module.exports = global.document ? factory(global, true) : function(w) { + if (!w.document) { + throw new Error("Avalon requires a window with a document") + } + return factory(w) + } + } else { + factory(global) + } + +// Pass this if window is not defined yet +}(typeof window !== "undefined" ? window : this, function(window, noGlobal){ + +/********************************************************************* + * 全局变量及方法 * + **********************************************************************/ +var expose = new Date() - 0 +//http://stackoverflow.com/questions/7290086/javascript-use-strict-and-nicks-find-global-function +var DOC = window.document +var head = DOC.getElementsByTagName("head")[0] //HEAD元素 +var ifGroup = head.insertBefore(document.createElement("avalon"), head.firstChild) //避免IE6 base标签BUG +ifGroup.innerHTML = "X" +ifGroup.setAttribute("ms-skip", "1") +ifGroup.className = "avalonHide" +var rnative = /\[native code\]/ //判定是否原生函数 +function log() { + if (window.console && avalon.config.debug) { + // http://stackoverflow.com/questions/8785624/how-to-safely-wrap-console-log + Function.apply.call(console.log, console, arguments) + } +} + + +var subscribers = "$" + expose +var otherRequire = window.require +var otherDefine = window.define +var innerRequire +var stopRepeatAssign = false +var rword = /[^, ]+/g //切割字符串为一个个小块,以空格或豆号分开它们,结合replace实现字符串的forEach +var rcomplexType = /^(?:object|array)$/ +var rsvg = /^\[object SVG\w*Element\]$/ +var rwindow = /^\[object (?:Window|DOMWindow|global)\]$/ +var oproto = Object.prototype +var ohasOwn = oproto.hasOwnProperty +var serialize = oproto.toString +var ap = Array.prototype +var aslice = ap.slice +var Registry = {} //将函数曝光到此对象上,方便访问器收集依赖 +var W3C = window.dispatchEvent +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) { + class2type["[object " + name + "]"] = name.toLowerCase() +}) + + +function noop() { +} + + +function oneObject(array, val) { + if (typeof array === "string") { + array = array.match(rword) || [] + } + var result = {}, + value = val !== void 0 ? val : 1 + for (var i = 0, n = array.length; i < n; i++) { + result[array[i]] = value + } + return result +} + +//生成UUID http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript +var generateID = function (prefix) { + prefix = prefix || "avalon" + return String(Math.random() + Math.random()).replace(/\d\.\d{4}/, prefix) +} +function IE() { + if (window.VBArray) { + var mode = document.documentMode + return mode ? mode : window.XMLHttpRequest ? 7 : 6 + } else { + return NaN + } +} +var IEVersion = IE() + +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 + var tickImmediate = window.setImmediate + var tickObserver = window.MutationObserver + var tickPost = W3C && window.postMessage + if (tickImmediate) { + return tickImmediate.bind(window) + } + + var queue = [] + function callback() { + var n = queue.length + for (var i = 0; i < n; i++) { + queue[i]() + } + queue = queue.slice(n) + } + + if (tickObserver) { + var node = document.createTextNode("avalon") + new tickObserver(callback).observe(node, {characterData: true})// jshint ignore:line + return function (fn) { + queue.push(fn) + node.data = Math.random() + } + } + + if (tickPost) { + window.addEventListener("message", function (e) { + var source = e.source + if ((source === window || source === null) && e.data === "process-tick") { + e.stopPropagation() + callback() + } + }) + + return function (fn) { + queue.push(fn) + window.postMessage('process-tick', '*') + } + } + + return function (fn) { + setTimeout(fn, 0) + } +}// jshint ignore:line +/********************************************************************* + * avalon的静态方法定义区 * + **********************************************************************/ +avalon.init = function (el) { + this[0] = this.element = el +} +avalon.fn = avalon.prototype = avalon.init.prototype + +avalon.type = function (obj) { //取得目标的类型 + if (obj == null) { + return String(obj) + } + // 早期的webkit内核浏览器实现了已废弃的ecma262v4标准,可以将正则字面量当作函数使用,因此typeof在判定正则时会返回function + return typeof obj === "object" || typeof obj === "function" ? + class2type[serialize.call(obj)] || "object" : + typeof obj +} + +var isFunction = typeof alert === "object" ? function (fn) { + try { + return /^\s*\bfunction\b/.test(fn + "") + } catch (e) { + return false + } +} : function (fn) { + return serialize.call(fn) === "[object Function]" +} +avalon.isFunction = isFunction + +avalon.isWindow = function (obj) { + if (!obj) + return false + // 利用IE678 window == document为true,document == window竟然为false的神奇特性 + // 标准浏览器及IE9,IE10等使用 正则检测 + return obj == obj.document && obj.document != obj //jshint ignore:line +} + +function isWindow(obj) { + return rwindow.test(serialize.call(obj)) +} +if (isWindow(window)) { + avalon.isWindow = isWindow +} +var enu +for (enu in avalon({})) { + break +} +var enumerateBUG = enu !== "0" //IE6下为true, 其他为false +/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/ +avalon.isPlainObject = function (obj, key) { + if (!obj || avalon.type(obj) !== "object" || obj.nodeType || avalon.isWindow(obj)) { + return false; + } + try { //IE内置对象没有constructor + if (obj.constructor && !ohasOwn.call(obj, "constructor") && !ohasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { + return false; + } + } catch (e) { //IE8 9会在这里抛错 + return false; + } + if (enumerateBUG) { + for (key in obj) { + return ohasOwn.call(obj, key) + } + } + for (key in obj) { + } + return key === void 0 || ohasOwn.call(obj, key) +} +if (rnative.test(Object.getPrototypeOf)) { + 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 () { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false + + // 如果第一个参数为布尔,判定是否深拷贝 + if (typeof target === "boolean") { + deep = target + target = arguments[1] || {} + i++ + } + + //确保接受方为一个复杂的数据类型 + if (typeof target !== "object" && !isFunction(target)) { + target = {} + } + + //如果只有一个参数,那么新成员添加于mix所在的对象上 + if (i === length) { + target = this + i-- + } + + for (; i < length; i++) { + //只处理非空参数 + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name] + try { + copy = options[name] //当options为VBS对象时报错 + } catch (e) { + continue + } + + // 防止环引用 + if (target === copy) { + continue + } + if (deep && copy && (avalon.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) { + + if (copyIsArray) { + copyIsArray = false + clone = src && Array.isArray(src) ? src : [] + + } else { + clone = src && avalon.isPlainObject(src) ? src : {} + } + + target[name] = avalon.mix(deep, clone, copy) + } else if (copy !== void 0) { + target[name] = copy + } + } + } + } + return target +} + +function _number(a, len) { //用于模拟slice, splice的效果 + a = Math.floor(a) || 0 + return a < 0 ? Math.max(len + a, 0) : Math.min(a, len); +} +avalon.mix({ + rword: rword, + subscribers: subscribers, + version: 1.45, + ui: {}, + log: log, + slice: W3C ? function (nodes, start, end) { + return aslice.call(nodes, start, end) + } : function (nodes, start, end) { + var ret = [] + var len = nodes.length + if (end === void 0) + end = len + if (typeof end === "number" && isFinite(end)) { + start = _number(start, len) + end = _number(end, len) + for (var i = start; i < end; ++i) { + ret[i - start] = nodes[i] + } + } + return ret + }, + noop: noop, + /*如果不用Error对象封装一下,str在控制台下可能会乱码*/ + error: function (str, e) { + throw (e || Error)(str) + }, + /*将一个以空格或逗号隔开的字符串或数组,转换成一个键值都为1的对象*/ + oneObject: oneObject, + /* avalon.range(10) + => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + avalon.range(1, 11) + => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + avalon.range(0, 30, 5) + => [0, 5, 10, 15, 20, 25] + avalon.range(0, -10, -1) + => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] + avalon.range(0) + => []*/ + range: function (start, end, step) { // 用于生成整数数组 + step || (step = 1) + if (end == null) { + end = start || 0 + start = 0 + } + var index = -1, + length = Math.max(0, Math.ceil((end - start) / step)), + result = new Array(length) + while (++index < length) { + result[index] = start + start += step + } + return result + }, + eventHooks: [], + /*绑定事件*/ + 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 callback = W3C ? fn : function(e) { + fn.call(el, fixEvent(e)); + } + if (W3C) { + el.addEventListener(type, callback, !!phase) + } else { + el.attachEvent("on" + type, callback) + } + return callback + }, + /*卸载事件*/ + 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) + } + } + if (W3C) { + el.removeEventListener(type, callback, !!phase) + } else { + el.detachEvent("on" + type, callback) + } + }, + /*读写删除元素节点的样式*/ + css: function (node, name, value) { + if (node instanceof avalon) { + node = node[0] + } + var prop = /[_-]/.test(name) ? camelize(name) : name, fn + name = avalon.cssName(prop) || prop + if (value === void 0 || typeof value === "boolean") { //获取样式 + fn = cssHooks[prop + ":get"] || cssHooks["@:get"] + if (name === "background") { + name = "backgroundColor" + } + var val = fn(node, name) + return value === true ? parseFloat(val) || 0 : val + } else if (value === "") { //请除样式 + node.style[name] = "" + } else { //设置样式 + if (value == null || value !== value) { + return + } + if (isFinite(value) && !avalon.cssNumber[prop]) { + value += "px" + } + fn = cssHooks[prop + ":set"] || cssHooks["@:set"] + fn(node, name, value) + } + }, + /*遍历数组与对象,回调的第一个参数为索引或键名,第二个或元素或键值*/ + each: function (obj, fn) { + if (obj) { //排除null, undefined + var i = 0 + if (isArrayLike(obj)) { + for (var n = obj.length; i < n; i++) { + if (fn(i, obj[i]) === false) + break + } + } else { + for (i in obj) { + if (obj.hasOwnProperty(i) && fn(i, obj[i]) === false) { + break + } + } + } + } + }, + //收集元素的data-{{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) { + return a.toLowerCase() + })] = raw[i] + } + } + return result + }, + Array: { + /*只有当前数组不存在此元素时只添加它*/ + ensure: function (target, item) { + if (target.indexOf(item) === -1) { + return target.push(item) + } + }, + /*移除数组中指定位置的元素,返回布尔表示成功与否*/ + removeAt: function (target, index) { + return !!target.splice(index, 1).length + }, + /*移除数组中第一个匹配传参的那个元素,返回布尔表示成功与否*/ + remove: function (target, item) { + var index = target.indexOf(item) + if (~index) + return avalon.Array.removeAt(target, index) + return false + } + } +}) + +var bindingHandlers = avalon.bindingHandlers = {} +var bindingExecutors = avalon.bindingExecutors = {} + +/*判定是否类数组,如节点集合,纯数组,arguments与拥有非负整数的length属性的纯JS对象*/ +function isArrayLike(obj) { + if (!obj) + return false + var n = obj.length + if (n === (n >>> 0)) { //检测length属性是否为非负整数 + var type = serialize.call(obj).slice(8, -1) + if (/(?:regexp|string|function|window|global)$/i.test(type)) + return false + if (type === "Array") + return true + try { + if ({}.propertyIsEnumerable.call(obj, "length") === false) { //如果是原生对象 + return /^\s?function/.test(obj.item || obj.callee) + } + return true + } catch (e) { //IE的NodeList直接抛错 + return !obj.window //IE6-8 window + } + } + return false +} + + +// https://github.com/rsms/js-lru +var Cache = new function() {// jshint ignore:line + function LRU(maxLength) { + this.size = 0 + this.limit = maxLength + this.head = this.tail = void 0 + this._keymap = {} + } + + var p = LRU.prototype + + p.put = function(key, value) { + var entry = { + key: key, + value: value + } + this._keymap[key] = entry + if (this.tail) { + this.tail.newer = entry + entry.older = this.tail + } else { + this.head = entry + } + this.tail = entry + if (this.size === this.limit) { + this.shift() + } else { + this.size++ + } + return value + } + + p.shift = function() { + var entry = this.head + if (entry) { + this.head = this.head.newer + this.head.older = + entry.newer = + entry.older = + this._keymap[entry.key] = void 0 + } + } + p.get = function(key) { + var entry = this._keymap[key] + if (entry === void 0) + return + if (entry === this.tail) { + return entry.value + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) { + this.head = entry.newer + } + entry.newer.older = entry.older // C <-- E. + } + if (entry.older) { + entry.older.newer = entry.newer // C. --> E + } + entry.newer = void 0 // D --x + entry.older = this.tail // D. --> E + if (this.tail) { + this.tail.newer = entry // E. <-- D + } + this.tail = entry + return entry.value + } + return LRU +}// jshint ignore:line + +/********************************************************************* + * javascript 底层补丁 * + **********************************************************************/ +if (!"司徒正美".trim) { + var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g + String.prototype.trim = function () { + return this.replace(rtrim, "") + } +} +var hasDontEnumBug = !({ + 'toString': null +}).propertyIsEnumerable('toString'), + hasProtoEnumBug = (function () { + }).propertyIsEnumerable('prototype'), + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; +if (!Object.keys) { + Object.keys = function (object) { //ecma262v5 15.2.3.14 + var theKeys = [] + var skipProto = hasProtoEnumBug && typeof object === "function" + if (typeof object === "string" || (object && object.callee)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)) + } + } else { + for (var name in object) { + if (!(skipProto && name === "prototype") && ohasOwn.call(object, name)) { + theKeys.push(String(name)) + } + } + } + + if (hasDontEnumBug) { + var ctor = object.constructor, + skipConstructor = ctor && ctor.prototype === object + for (var j = 0; j < dontEnumsLength; j++) { + var dontEnum = dontEnums[j] + if (!(skipConstructor && dontEnum === "constructor") && ohasOwn.call(object, dontEnum)) { + theKeys.push(dontEnum) + } + } + } + return theKeys + } +} +if (!Array.isArray) { + Array.isArray = function (a) { + return serialize.call(a) === "[object Array]" + } +} + +if (!noop.bind) { + Function.prototype.bind = function (scope) { + if (arguments.length < 2 && scope === void 0) + return this + var fn = this, + argv = arguments + return function () { + var args = [], + i + for (i = 1; i < argv.length; i++) + args.push(argv[i]) + for (i = 0; i < arguments.length; i++) + args.push(arguments[i]) + return fn.apply(scope, args) + } + } +} + +function iterator(vars, body, ret) { + var fun = 'for(var ' + vars + 'i=0,n = this.length; i < n; i++){' + body.replace('_', '((i in this) && fn.call(scope,this[i],i,this))') + '}' + ret + /* jshint ignore:start */ + return Function("fn,scope", fun) + /* jshint ignore:end */ +} +if (!rnative.test([].map)) { + avalon.mix(ap, { + //定位操作,返回数组中第一个等于给定参数的元素的索引值。 + indexOf: function (item, index) { + var n = this.length, + i = ~~index + if (i < 0) + i += n + for (; i < n; i++) + if (this[i] === item) + return i + return -1 + }, + //定位操作,同上,不过是从后遍历。 + lastIndexOf: function (item, index) { + var n = this.length, + i = index == null ? n - 1 : index + if (i < 0) + i = Math.max(0, n + i) + for (; i >= 0; i--) + if (this[i] === item) + return i + return -1 + }, + //迭代操作,将数组的元素挨个儿传入一个函数中执行。Prototype.js的对应名字为each。 + forEach: iterator("", '_', ""), + //迭代类 在数组中的每个项上运行一个函数,如果此函数的值为真,则此元素作为新数组的元素收集起来,并返回新数组 + filter: iterator('r=[],j=0,', 'if(_)r[j++]=this[i]', 'return r'), + //收集操作,将数组的元素挨个儿传入一个函数中执行,然后把它们的返回值组成一个新数组返回。Prototype.js的对应名字为collect。 + map: iterator('r=[],', 'r[i]=_', 'return r'), + //只要数组中有一个元素满足条件(放进给定函数返回true),那么它就返回true。Prototype.js的对应名字为any。 + some: iterator("", 'if(_)return true', 'return false'), + //只有数组中的元素都满足条件(放进给定函数返回true),它才返回true。Prototype.js的对应名字为all。 + every: iterator("", 'if(!_)return false', 'return true') + }) +} +/********************************************************************* + * DOM 底层补丁 * + **********************************************************************/ + +function fixContains(root, el) { + try { //IE6-8,游离于DOM树外的文本节点,访问parentNode有时会抛错 + while ((el = el.parentNode)) + if (el === root) + return true + return false + } catch (e) { + return false + } +} +avalon.contains = fixContains +//IE6-11的文档对象没有contains +if (!DOC.contains) { + DOC.contains = function (b) { + return fixContains(DOC, b) + } +} + +function outerHTML() { + return new XMLSerializer().serializeToString(this) +} + +if (window.SVGElement) { + //safari5+是把contains方法放在Element.prototype上而不是Node.prototype + if (!DOC.createTextNode("x").contains) { + Node.prototype.contains = function (arg) {//IE6-8没有Node对象 + return !!(this.compareDocumentPosition(arg) & 16) + } + } + var svgns = "http://www.w3.org/2000/svg" + var svg = DOC.createElementNS(svgns, "svg") + svg.innerHTML = '' + if (!rsvg.test(svg.firstChild)) { // #409 + function enumerateNode(node, targetNode) {// jshint ignore:line + if (node && node.childNodes) { + var nodes = node.childNodes + for (var i = 0, el; el = nodes[i++]; ) { + if (el.tagName) { + var svg = DOC.createElementNS(svgns, + el.tagName.toLowerCase()) + ap.forEach.call(el.attributes, function (attr) { + svg.setAttribute(attr.name, attr.value) //复制属性 + })// jshint ignore:line + // 递归处理子节点 + enumerateNode(el, svg) + targetNode.appendChild(svg) + } + } + } + } + Object.defineProperties(SVGElement.prototype, { + "outerHTML": {//IE9-11,firefox不支持SVG元素的innerHTML,outerHTML属性 + enumerable: true, + configurable: true, + get: outerHTML, + set: function (html) { + var tagName = this.tagName.toLowerCase(), + par = this.parentNode, + frag = avalon.parseHTML(html) + // 操作的svg,直接插入 + if (tagName === "svg") { + par.insertBefore(frag, this) + // svg节点的子节点类似 + } else { + var newFrag = DOC.createDocumentFragment() + enumerateNode(frag, newFrag) + par.insertBefore(newFrag, this) + } + par.removeChild(this) + } + }, + "innerHTML": { + enumerable: true, + configurable: true, + get: function () { + var s = this.outerHTML + var ropen = new RegExp("<" + this.nodeName + '\\b(?:(["\'])[^"]*?(\\1)|[^>])*>', "i") + var rclose = new RegExp("<\/" + this.nodeName + ">$", "i") + return s.replace(ropen, "").replace(rclose, "") + }, + set: function (html) { + if (avalon.clearHTML) { + avalon.clearHTML(this) + var frag = avalon.parseHTML(html) + enumerateNode(frag, this) + } + } + } + }) + } +} +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) + } + } + } +} + + + +/********************************************************************* + * 配置系统 * + **********************************************************************/ + +function kernel(settings) { + for (var p in settings) { + if (!ohasOwn.call(settings, p)) + continue + var val = settings[p] + if (typeof kernel.plugins[p] === "function") { + kernel.plugins[p](val) + } else if (typeof kernel[p] === "object") { + avalon.mix(kernel[p], val) + } else { + kernel[p] = val + } + } + return this +} +var openTag, closeTag, rexpr, rexprg, rbind, rregexp = /[-.*+?^${}()|[\]\/\\]/g + +function escapeRegExp(target) { + //http://stevenlevithan.com/regex/xregexp/ + //将字符串安全格式化为正则表达式的源码 + return (target + "").replace(rregexp, "\\$&") +} + +var plugins = { + loader: function (builtin) { + var flag = innerRequire && builtin + window.require = flag ? innerRequire : otherRequire + window.define = flag ? innerRequire.define : otherDefine + }, + interpolate: function (array) { + openTag = array[0] + closeTag = array[1] + if (openTag === closeTag) { + throw new SyntaxError("openTag!==closeTag") + var test = openTag + "test" + closeTag + cinerator.innerHTML = test + if (cinerator.innerHTML !== test && cinerator.innerHTML.indexOf("<") > -1) { + throw new SyntaxError("此定界符不合法") + } + cinerator.innerHTML = "" + } + var o = escapeRegExp(openTag), + c = escapeRegExp(closeTag) + rexpr = new RegExp(o + "(.*?)" + c) + rexprg = new RegExp(o + "(.*?)" + c, "g") + rbind = new RegExp(o + ".*?" + c + "|\\sms-") + } +} + +kernel.debug = true +kernel.plugins = plugins +kernel.plugins['interpolate'](["{{", "}}"]) +kernel.paths = {} +kernel.shim = {} +kernel.maxRepeatSize = 100 +avalon.config = kernel +var ravalon = /(\w+)\[(avalonctrl)="(\S+)"\]/ +var findNodes = DOC.querySelectorAll ? function(str) { + return DOC.querySelectorAll(str) +} : function(str) { + var match = str.match(ravalon) + var all = DOC.getElementsByTagName(match[1]) + var nodes = [] + for (var i = 0, el; el = all[i++]; ) { + if (el.getAttribute(match[2]) === match[3]) { + nodes.push(el) + } + } + return nodes +} +/********************************************************************* + * 事件总线 * + **********************************************************************/ +var EventBus = { + $watch: function (type, callback) { + if (typeof callback === "function") { + var callbacks = this.$events[type] + if (callbacks) { + callbacks.push(callback) + } else { + this.$events[type] = [callback] + } + } else { //重新开始监听此VM的第一重简单属性的变动 + this.$events = this.$watch.backup + } + return this + }, + $unwatch: function (type, callback) { + var n = arguments.length + if (n === 0) { //让此VM的所有$watch回调无效化 + this.$watch.backup = this.$events + this.$events = {} + } else if (n === 1) { + this.$events[type] = [] + } else { + var callbacks = this.$events[type] || [] + var i = callbacks.length + while (~--i < 0) { + if (callbacks[i] === callback) { + return callbacks.splice(i, 1) + } + } + } + return this + }, + $fire: function (type) { + var special, i, v, callback + if (/^(\w+)!(\S+)$/.test(type)) { + special = RegExp.$1 + type = RegExp.$2 + } + var events = this.$events + if (!events) + return + var args = aslice.call(arguments, 1) + var detail = [type].concat(args) + if (special === "all") { + for (i in avalon.vmodels) { + v = avalon.vmodels[i] + if (v !== this) { + v.$fire.apply(v, detail) + } + } + } else if (special === "up" || special === "down") { + var elements = events.expr ? findNodes(events.expr) : [] + if (elements.length === 0) + return + for (i in avalon.vmodels) { + v = avalon.vmodels[i] + if (v !== this) { + if (v.$events.expr) { + var eventNodes = findNodes(v.$events.expr) + if (eventNodes.length === 0) { + continue + } + //循环两个vmodel中的节点,查找匹配(向上匹配或者向下匹配)的节点并设置标识 + /* jshint ignore:start */ + ap.forEach.call(eventNodes, function (node) { + ap.forEach.call(elements, function (element) { + var ok = special === "down" ? element.contains(node) : //向下捕获 + node.contains(element) //向上冒泡 + if (ok) { + node._avalon = v //符合条件的加一个标识 + } + }); + }) + /* jshint ignore:end */ + } + } + } + var nodes = DOC.getElementsByTagName("*") //实现节点排序 + var alls = [] + ap.forEach.call(nodes, function (el) { + if (el._avalon) { + alls.push(el._avalon) + el._avalon = "" + el.removeAttribute("_avalon") + } + }) + if (special === "up") { + alls.reverse() + } + for (i = 0; callback = alls[i++]; ) { + if (callback.$fire.apply(callback, detail) === false) { + break + } + } + } else { + var callbacks = events[type] || [] + var all = events.$all || [] + for (i = 0; callback = callbacks[i++]; ) { + if (isFunction(callback)) + callback.apply(this, args) + } + for (i = 0; callback = all[i++]; ) { + if (isFunction(callback)) + callback.apply(this, arguments) + } + } + } +} + +/********************************************************************* + * modelFactory * + **********************************************************************/ +//avalon最核心的方法的两个方法之一(另一个是avalon.scan),返回一个ViewModel(VM) +var VMODELS = avalon.vmodels = {} //所有vmodel都储存在这里 +avalon.define = function (id, factory) { + var $id = id.$id || id + if (!$id) { + log("warning: vm必须指定$id") + } + if (VMODELS[$id]) { + log("warning: " + $id + " 已经存在于avalon.vmodels中") + } + if (typeof id === "object") { + var model = modelFactory(id) + } else { + var scope = { + $watch: noop + } + factory(scope) //得到所有定义 + + model = modelFactory(scope) //偷天换日,将scope换为model + stopRepeatAssign = true + factory(model) + stopRepeatAssign = false + } + model.$id = $id + return VMODELS[$id] = model +} + +//一些不需要被监听的属性 +var $$skipArray = String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$reinitialize,$propertyNames").match(rword) +var defineProperty = Object.defineProperty +var canHideOwn = true +//如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 +//标准浏览器使用__defineGetter__, __defineSetter__实现 +try { + defineProperty({}, "_", { + value: "x" + }) + var defineProperties = Object.defineProperties +} catch (e) { + canHideOwn = false +} + +function modelFactory(source, $special, $model) { + if (Array.isArray(source)) { + var arr = source.concat() + source.length = 0 + var collection = arrayFactory(source) + collection.pushArray(arr) + return collection + } + //0 null undefined || Node || VModel(fix IE6-8 createWithProxy $val: val引发的BUG) + if (!source || source.nodeType > 0 || (source.$id && source.$events)) { + return source + } + var $skipArray = Array.isArray(source.$skipArray) ? source.$skipArray : [] + $skipArray.$special = $special || {} //强制要监听的属性 + var $vmodel = {} //要返回的对象, 它在IE6-8下可能被偷龙转凤 + $model = $model || {} //vmodels.$model属性 + var $events = {} //vmodel.$events属性 + var accessors = {} //监控属性 + var computed = [] + $$skipArray.forEach(function (name) { + delete source[name] + }) + var names = Object.keys(source) + /* jshint ignore:start */ + names.forEach(function (name, accessor) { + var val = source[name] + $model[name] = val + if (isObservable(name, val, $skipArray)) { + //总共产生三种accessor + $events[name] = [] + var valueType = avalon.type(val) + //总共产生三种accessor + if (valueType === "object" && isFunction(val.get) && Object.keys(val).length <= 2) { + accessor = makeComputedAccessor(name, val) + computed.push(accessor) + } else if (rcomplexType.test(valueType)) { + accessor = makeComplexAccessor(name, val, valueType, $events[name]) + } else { + accessor = makeSimpleAccessor(name, val) + } + accessors[name] = accessor + } + }) + /* jshint ignore:end */ + + $vmodel = defineProperties($vmodel, descriptorFactory(accessors), source) //生成一个空的ViewModel + for (var i = 0; i < names.length; i++) { + var name = names[i] + if (!accessors[name]) { + $vmodel[name] = source[name] + } + } + //添加$id, $model, $events, $watch, $unwatch, $fire + $vmodel.$propertyNames = names.sort().join("­") + $vmodel.$id = generateID() + $vmodel.$model = $model + $vmodel.$events = $events + for (i in EventBus) { + var fn = EventBus[i] + if (!W3C) { //在IE6-8下,VB对象的方法里的this并不指向自身,需要用bind处理一下 + fn = fn.bind($vmodel) + } + $vmodel[i] = fn + } + if (canHideOwn) { + Object.defineProperty($vmodel, "hasOwnProperty", hasOwnDescriptor) + } else { + /* jshint ignore:start */ + $vmodel.hasOwnProperty = function (name) { + return name in $vmodel.$model + } + /* jshint ignore:end */ + } + + $vmodel.$reinitialize = function () { + computed.forEach(function (accessor) { + delete accessor._value + delete accessor.oldArgs + accessor.digest = function () { + accessor.call($vmodel) + } + 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 { + accessor.get.call($vmodel) + } finally { + dependencyDetection.end() + } + }) + } + $vmodel.$reinitialize() + return $vmodel +} + +var hasOwnDescriptor = { + value: function (name) { + return name in this.$model + }, + writable: false, + enumerable: false, + configurable: true +} +//创建一个简单访问器 +function makeSimpleAccessor(name, value) { + function accessor(value) { + var oldValue = accessor._value + if (arguments.length > 0) { + if (!stopRepeatAssign && !isEqual(value, oldValue)) { + accessor.updateValue(this, value) + accessor.notify(this, value, oldValue) + } + return this + } else { + dependencyDetection.collectDependency(this, accessor) + return oldValue + } + } + accessorFactory(accessor, name) + accessor._value = value + return accessor; +} + +//创建一个计算访问器 +function makeComputedAccessor(name, options) { + function accessor(value) {//计算属性 + var oldValue = accessor._value + var init = ("_value" in accessor) + if (arguments.length > 0) { + if (stopRepeatAssign) { + return this + } + if (typeof accessor.set === "function") { + if (accessor.oldArgs !== value) { + accessor.oldArgs = value + var $events = this.$events + var lock = $events[name] + $events[name] = [] //清空回调,防止内部冒泡而触发多次$fire + accessor.set.call(this, value) + $events[name] = lock + value = accessor.get.call(this) + if (value !== oldValue) { + accessor.updateValue(this, value) + accessor.notify(this, value, oldValue) //触发$watch回调 + } + } + } + return this + } else { + //将依赖于自己的高层访问器或视图刷新函数(以绑定对象形式)放到自己的订阅数组中 + //将自己注入到低层访问器的订阅数组中 + value = accessor.get.call(this) + accessor.updateValue(this, value) + if (init && oldValue !== value) { + accessor.notify(this, value, oldValue) //触发$watch回调 + } + return value + } + } + accessor.set = options.set + accessor.get = options.get + accessorFactory(accessor, name) + return accessor +} + +//创建一个复杂访问器 +function makeComplexAccessor(name, initValue, valueType, list) { + function accessor(value) { + var oldValue = accessor._value + + var son = accessor._vmodel + if (arguments.length > 0) { + if (stopRepeatAssign) { + return this + } + if (valueType === "array") { + var a = son, b = value, + an = a.length, + bn = b.length + a.$lock = true + if (an > bn) { + a.splice(bn, an - bn) + } else if (bn > an) { + a.push.apply(a, b.slice(an)) + } + var n = Math.min(an, bn) + for (var i = 0; i < n; i++) { + a.set(i, b[i]) + } + delete a.$lock + a._fire("set") + } else if (valueType === "object") { + var newPropertyNames = Object.keys(value).sort().join("­") + if (son.$propertyNames === newPropertyNames) { + for (i in value) { + son[i] = value[i] + } + } else if(W3C){ + var a = accessor._vmodel = modelFactory(value) + a.$events = son.$events + } else{ + var $proxy = son.$proxy + son = accessor._vmodel = modelFactory(value) + var observes = son.$events[subscribers] = this.$events[name] || [] + var iterators = observes.concat() + observes.length = 0 + son.$proxy = $proxy + while (a = iterators.shift()) { + var fn = bindingHandlers[a.type] + if (fn) { //#753 + a.rollback && a.rollback() //还原 ms-with ms-on + fn(a, a.vmodels) + } + } + } + } + accessor.updateValue(this, son.$model) + accessor.notify(this, this._value, oldValue) + return this + } else { + dependencyDetection.collectDependency(this, accessor) + return son + } + } + accessorFactory(accessor, name) + var son = accessor._vmodel = modelFactory(initValue) + son.$events[subscribers] = list + return accessor +} + +function globalUpdateValue(vmodel, value) { + vmodel.$model[this._name] = this._value = value +} + +function globalNotify(vmodel, value, oldValue) { + var name = this._name + var array = vmodel.$events[name] //刷新值 + if (array) { + fireDependencies(array) //同步视图 + EventBus.$fire.call(vmodel, name, value, oldValue) //触发$watch回调 + } +} + +function accessorFactory(accessor, name) { + accessor._name = name + //同时更新_value与model + accessor.updateValue = globalUpdateValue + accessor.notify = globalNotify +} + +//比较两个值是否相等 +var isEqual = Object.is || function (v1, v2) { + if (v1 === 0 && v2 === 0) { + return 1 / v1 === 1 / v2 + } else if (v1 !== v1) { + return v2 !== v2 + } else { + return v1 === v2 + } +} + +function isObservable(name, value, $skipArray) { + if (isFunction(value) || value && value.nodeType) { + return false + } + if ($skipArray.indexOf(name) !== -1) { + return false + } + var $special = $skipArray.$special + if (name && name.charAt(0) === "$" && !$special[name]) { + return false + } + return true +} + +var descriptorFactory = W3C ? function (obj) { + var descriptors = {} + for (var i in obj) { + descriptors[i] = { + get: obj[i], + set: obj[i], + enumerable: true, + configurable: true + } + } + return descriptors +} : function (a) { + return a +} + +// function diff(newObject, oldObject) { +// var added = [] +// for (var i in newObject) { +// if (newObject.hasOwnProperty(i)) { +// if (!oldObject.hasOwnerProperty(i)) { +// added.push({ +// name: i, +// value: newObject[i] +// }) +// } +// } +// } +// var deleted = [] +// for (var i in newObject) { +// if (oldObject.hasOwnProperty(i)) { +// if (!newObject.hasOwnerProperty(i)) { +// deleted.push( Object.getOwnPropertyDescriptor(oldObject, i).get) +// } +// } +// } +// for(var i = 0; i < added.length; i++){ +// var a = added[i] +// var fn = deleted.shift() +// fn._name = a.name +// fn._value = a.value +// } +// } +//===================修复浏览器对Object.defineProperties的支持================= +if (!canHideOwn) { + if ("__defineGetter__" in avalon) { + defineProperty = function (obj, prop, desc) { + if ('value' in desc) { + obj[prop] = desc.value + } + if ("get" in desc) { + obj.__defineGetter__(prop, desc.get) + } + if ('set' in desc) { + obj.__defineSetter__(prop, desc.set) + } + return obj + } + defineProperties = function (obj, descs) { + for (var prop in descs) { + if (descs.hasOwnProperty(prop)) { + defineProperty(obj, prop, descs[prop]) + } + } + return obj + } + } + if (IEVersion) { + var VBClassPool = {} + window.execScript([// jshint ignore:line + "Function parseVB(code)", + "\tExecuteGlobal(code)", + "End Function" //转换一段文本为VB代码 + ].join("\n"), "VBScript") + function VBMediator(instance, accessors, name, value) {// jshint ignore:line + var accessor = accessors[name] + if (arguments.length === 4) { + accessor.call(instance, value) + } else { + return accessor.call(instance) + } + } + defineProperties = function (name, accessors, properties) { + // jshint ignore:line + var buffer = [] + buffer.push( + "\r\n\tPrivate [__data__], [__proxy__]", + "\tPublic Default Function [__const__](d, p)", + "\t\tSet [__data__] = d: set [__proxy__] = p", + "\t\tSet [__const__] = Me", //链式调用 + "\tEnd Function") + //添加普通属性,因为VBScript对象不能像JS那样随意增删属性,必须在这里预先定义好 + for (name in properties) { + if (!accessors.hasOwnProperty(name)) { + buffer.push("\tPublic [" + name + "]") + } + } + $$skipArray.forEach(function (name) { + if (!accessors.hasOwnProperty(name)) { + buffer.push("\tPublic [" + name + "]") + } + }) + buffer.push("\tPublic [" + 'hasOwnProperty' + "]") + //添加访问器属性 + for (name in accessors) { + buffer.push( + //由于不知对方会传入什么,因此set, let都用上 + "\tPublic Property Let [" + name + "](val" + expose + ")", //setter + "\t\tCall [__proxy__](Me,[__data__], \"" + name + "\", val" + expose + ")", + "\tEnd Property", + "\tPublic Property Set [" + name + "](val" + expose + ")", //setter + "\t\tCall [__proxy__](Me,[__data__], \"" + name + "\", val" + expose + ")", + "\tEnd Property", + "\tPublic Property Get [" + name + "]", //getter + "\tOn Error Resume Next", //必须优先使用set语句,否则它会误将数组当字符串返回 + "\t\tSet[" + name + "] = [__proxy__](Me,[__data__],\"" + name + "\")", + "\tIf Err.Number <> 0 Then", + "\t\t[" + name + "] = [__proxy__](Me,[__data__],\"" + name + "\")", + "\tEnd If", + "\tOn Error Goto 0", + "\tEnd Property") + + } + + buffer.push("End Class") + var body = buffer.join("\r\n") + var className =VBClassPool[body] + if (!className) { + className = generateID("VBClass") + window.parseVB("Class " + className + body) + window.parseVB([ + "Function " + className + "Factory(a, b)", //创建实例并传入两个关键的参数 + "\tDim o", + "\tSet o = (New " + className + ")(a, b)", + "\tSet " + className + "Factory = o", + "End Function" + ].join("\r\n")) + VBClassPool[body] = className + } + var ret = window[className + "Factory"](accessors, VBMediator) //得到其产品 + return ret //得到其产品 + } + } +} + +/********************************************************************* + * 监控数组(与ms-each, ms-repeat配合使用) * + **********************************************************************/ + +function arrayFactory(model) { + var array = [] + array.$id = generateID() + array.$model = model //数据模型 + array.$events = {} + array.$events[subscribers] = [] + array._ = modelFactory({ + length: model.length + }) + array._.$watch("length", function (a, b) { + array.$fire("length", a, b) + }) + for (var i in EventBus) { + array[i] = EventBus[i] + } + avalon.mix(array, arrayPrototype) + return array +} + +function mutateArray(method, pos, n, index, method2, pos2, n2) { + var oldLen = this.length, loop = 2 + while (--loop) { + switch (method) { + case "add": + /* jshint ignore:start */ + var array = this.$model.slice(pos, pos + n).map(function (el) { + if (rcomplexType.test(avalon.type(el))) { + return el.$id ? el : modelFactory(el, 0, el) + } else { + return el + } + }) + /* jshint ignore:end */ + _splice.apply(this, [pos, 0].concat(array)) + this._fire("add", pos, n) + break + case "del": + var ret = this._splice(pos, n) + this._fire("del", pos, n) + break + } + if (method2) { + method = method2 + pos = pos2 + n = n2 + loop = 2 + method2 = 0 + } + } + this._fire("index", index) + if (this.length !== oldLen) { + this._.length = this.length + } + return ret +} + +var _splice = ap.splice +var arrayPrototype = { + _splice: _splice, + _fire: function (method, a, b) { + fireDependencies(this.$events[subscribers], method, a, b) + }, + size: function () { //取得数组长度,这个函数可以同步视图,length不能 + return this._.length + }, + pushArray: function (array) { + var m = array.length, n = this.length + if (m) { + ap.push.apply(this.$model, array) + mutateArray.call(this, "add", n, m, Math.max(0, n - 1)) + } + return m + n + }, + push: function () { + //http://jsperf.com/closure-with-arguments + var array = [] + var i, n = arguments.length + for (i = 0; i < n; i++) { + array[i] = arguments[i] + } + return this.pushArray(array) + }, + unshift: function () { + var m = arguments.length, n = this.length + if (m) { + ap.unshift.apply(this.$model, arguments) + mutateArray.call(this, "add", 0, m, 0) + } + return m + n //IE67的unshift不会返回长度 + }, + shift: function () { + if (this.length) { + var el = this.$model.shift() + mutateArray.call(this, "del", 0, 1, 0) + return el //返回被移除的元素 + } + }, + pop: function () { + var n = this.length + if (n) { + var el = this.$model.pop() + mutateArray.call(this, "del", n - 1, 1, Math.max(0, n - 2)) + return el //返回被移除的元素 + } + }, + splice: function (start) { + var m = arguments.length, args = [], change + var removed = _splice.apply(this.$model, arguments) + if (removed.length) { //如果用户删掉了元素 + args.push("del", start, removed.length, 0) + change = true + } + if (m > 2) { //如果用户添加了元素 + if (change) { + args.splice(3, 1, 0, "add", start, m - 2) + } else { + args.push("add", start, m - 2, 0) + } + change = true + } + if (change) { //返回被移除的元素 + return mutateArray.apply(this, args) + } else { + return [] + } + }, + contains: function (el) { //判定是否包含 + return this.indexOf(el) !== -1 + }, + remove: function (el) { //移除第一个等于给定值的元素 + return this.removeAt(this.indexOf(el)) + }, + removeAt: function (index) { //移除指定索引上的元素 + if (index >= 0) { + this.$model.splice(index, 1) + return mutateArray.call(this, "del", index, 1, 0) + } + return [] + }, + clear: function () { + this.$model.length = this.length = this._.length = 0 //清空数组 + this._fire("clear", 0) + return this + }, + removeAll: function (all) { //移除N个元素 + if (Array.isArray(all)) { + for (var i = this.length - 1; i >= 0; i--) { + if (all.indexOf(this[i]) !== -1) { + this.removeAt(i) + } + } + } else if (typeof all === "function") { + for ( i = this.length - 1; i >= 0; i--) { + var el = this[i] + if (all(el, i)) { + this.removeAt(i) + } + } + } else { + this.clear() + } + }, + ensure: function (el) { + if (!this.contains(el)) { //只有不存在才push + this.push(el) + } + return this + }, + set: function (index, val) { + if (index >= 0) { + var valueType = avalon.type(val) + if (val && val.$model) { + val = val.$model + } + var target = this[index] + if (valueType === "object") { + for (var i in val) { + if (target.hasOwnProperty(i)) { + target[i] = val[i] + } + } + } else if (valueType === "array") { + target.clear().push.apply(target, val) + } else if (target !== val) { + this[index] = val + this.$model[index] = val + this._fire("set", index, val) + } + } + return this + } +} +//相当于原来bindingExecutors.repeat 的index分支 +function resetIndex(array, pos) { + var last = array.length - 1 + for (var el; el = array[pos]; pos++) { + el.$index = pos + el.$first = pos === 0 + el.$last = pos === last + } +} + +function sortByIndex(array, indexes) { + var map = {}; + for (var i = 0, n = indexes.length; i < n; i++) { + map[i] = array[i] // preserve + var j = indexes[i] + if (j in map) { + array[i] = map[j] + delete map[j] + } else { + array[i] = array[j] + } + } +} + +"sort,reverse".replace(rword, function (method) { + arrayPrototype[method] = function () { + var newArray = this.$model//这是要排序的新数组 + var oldArray = newArray.concat() //保持原来状态的旧数组 + var mask = Math.random() + var indexes = [] + var hasSort + ap[method].apply(newArray, arguments) //排序 + for (var i = 0, n = oldArray.length; i < n; i++) { + var neo = newArray[i] + var old = oldArray[i] + if (isEqual(neo, old)) { + indexes.push(i) + } else { + var index = oldArray.indexOf(neo) + indexes.push(index)//得到新数组的每个元素在旧数组对应的位置 + oldArray[index] = mask //屏蔽已经找过的元素 + hasSort = true + } + } + if (hasSort) { + sortByIndex(this, indexes) + // sortByIndex(this.$proxy, indexes) + this._fire("move", indexes) + this._fire("index", 0) + } + return this + } +}) + + +/********************************************************************* + * 依赖调度系统 * + **********************************************************************/ +//检测两个对象间的依赖关系 +var dependencyDetection = (function () { + var outerFrames = [] + var currentFrame + return { + begin: function (accessorObject) { + //accessorObject为一个拥有callback的对象 + outerFrames.push(currentFrame) + currentFrame = accessorObject + }, + end: function () { + currentFrame = outerFrames.pop() + }, + collectDependency: function (vmodel, accessor) { + if (currentFrame) { + //被dependencyDetection.begin调用 + currentFrame.callback(vmodel, accessor); + } + } + }; +})() +//将绑定对象注入到其依赖项的订阅数组中 +var ronduplex = /^(duplex|on)$/ +avalon.injectBinding = function (data) { + var fn = data.evaluator + if (fn) { //如果是求值函数 + dependencyDetection.begin({ + callback: function (vmodel, dependency) { + injectDependency(vmodel.$events[dependency._name], data) + } + }) + try { + var c = ronduplex.test(data.type) ? data : fn.apply(0, data.args) + data.handler(c, data.element, data) + } catch (e) { + //log("warning:exception throwed in [avalon.injectBinding] " + e) + delete data.evaluator + var node = data.element + if (node.nodeType === 3) { + var parent = node.parentNode + if (kernel.commentInterpolate) { + parent.replaceChild(DOC.createComment(data.value), node) + } else { + node.data = openTag + (data.oneTime ? "::" : "") + data.value + closeTag + } + } + } finally { + dependencyDetection.end() + } + } +} + +//将依赖项(比它高层的访问器或构建视图刷新函数的绑定对象)注入到订阅者数组 +function injectDependency(list, data) { + if (data.oneTime) + return + if (list && avalon.Array.ensure(list, data) && data.element) { + injectDisposeQueue(data, list) + } +} + +//通知依赖于这个访问器的订阅者更新自身 +function fireDependencies(list) { + if (list && list.length) { + if (new Date() - beginTime > 444 && typeof list[0] === "object") { + rejectDisposeQueue() + } + var args = aslice.call(arguments, 1) + for (var i = list.length, fn; fn = list[--i]; ) { + var el = fn.element + if (el && el.parentNode) { + 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) { + } + } + } + } +} +/********************************************************************* + * 定时GC回收机制 * + **********************************************************************/ +var disposeCount = 0 +var disposeQueue = avalon.$$subscribers = [] +var beginTime = new Date() +var oldInfo = {} +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 + if (!data.uuid) { + if (elem.nodeType !== 1) { + data.uuid = data.type + (data.pos || 0) + "-" + getUid(elem.parentNode) + } else { + data.uuid = data.name + "-" + getUid(elem) + } + } + var lists = data.lists || (data.lists = []) + avalon.Array.ensure(lists, list) + list.$uuid = list.$uuid || generateID() + if (!disposeQueue[data.uuid]) { + disposeQueue[data.uuid] = 1 + disposeQueue.push(data) + } +} + +function rejectDisposeQueue(data) { + if (avalon.optimize) + return + var i = disposeQueue.length + var n = i + var allTypes = [] + var iffishTypes = {} + var newInfo = {} + //对页面上所有绑定对象进行分门别类, 只检测个数发生变化的类型 + while (data = disposeQueue[--i]) { + var type = data.type + if (newInfo[type]) { + newInfo[type]++ + } else { + newInfo[type] = 1 + allTypes.push(type) + } + } + var diff = false + allTypes.forEach(function (type) { + if (oldInfo[type] !== newInfo[type]) { + iffishTypes[type] = 1 + diff = true + } + }) + i = n + if (diff) { + while (data = disposeQueue[--i]) { + if (!data.element) + continue + 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) + avalon.Array.remove(list, data) + } + disposeData(data) + } + } + } + oldInfo = newInfo + beginTime = new Date() +} + +function disposeData(data) { + data.element = null + data.rollback && data.rollback() + for (var key in data) { + data[key] = null + } +} + +function shouldDispose(el) { + try {//IE下,如果文本节点脱离DOM树,访问parentNode会报错 + if (!el.parentNode) { + return true + } + } catch (e) { + return true + } + + return el.msRetain ? 0 : (el.nodeType === 1 ? !root.contains(el) : !avalon.contains(root, el)) +} + +/************************************************************************ + * HTML处理(parseHTML, innerHTML, clearHTML) * + ************************************************************************/ +// We have to close these tags to support XHTML +var tagHooks = { + area: [1, "", ""], + param: [1, "", ""], + col: [2, "", "
"], + legend: [1, "
", "
"], + option: [1, ""], + thead: [1, "", "
"], + tr: [2, "", "
"], + td: [3, "", "
"], + g: [1, '', ''], + //IE6-8在用innerHTML生成节点时,不能直接创建no-scope元素与HTML5的新标签 + _default: W3C ? [0, "", ""] : [1, "X
", "
"] //div可以不用闭合 +} +tagHooks.th = tagHooks.td +tagHooks.optgroup = tagHooks.option +tagHooks.tbody = tagHooks.tfoot = tagHooks.colgroup = tagHooks.caption = tagHooks.thead +String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(rword, function (tag) { + tagHooks[tag] = tagHooks.g //处理SVG +}) +var rtagName = /<([\w:]+)/ //取得其tagName +var rxhtml = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig +var rcreate = W3C ? /[^\d\D]/ : /(<(?:script|link|style|meta|noscript))/ig +var scriptTypes = oneObject(["", "text/javascript", "text/ecmascript", "application/ecmascript", "application/javascript"]) +var rnest = /<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/ //需要处理套嵌关系的标签 +var script = DOC.createElement("script") +var rhtml = /<|&#?\w+;/ +avalon.parseHTML = function (html) { + var fragment = avalonFragment.cloneNode(false) + if (typeof html !== "string") { + return fragment + } + if (!rhtml.test(html)) { + fragment.appendChild(DOC.createTextNode(html)) + return fragment + } + html = html.replace(rxhtml, "<$1>").trim() + var tag = (rtagName.exec(html) || ["", ""])[1].toLowerCase(), + //取得其标签名 + wrap = tagHooks[tag] || tagHooks._default, + wrapper = cinerator, + firstChild, neo + if (!W3C) { //fix IE + html = html.replace(rcreate, "
$1") //在link style script等标签之前添加一个补丁 + } + wrapper.innerHTML = wrap[1] + html + wrap[2] + var els = wrapper.getElementsByTagName("script") + if (els.length) { //使用innerHTML生成的script节点不会发出请求与执行text属性 + for (var i = 0, el; el = els[i++]; ) { + if (scriptTypes[el.type]) { + //以偷龙转凤方式恢复执行脚本功能 + neo = script.cloneNode(false) //FF不能省略参数 + ap.forEach.call(el.attributes, function (attr) { + if (attr && attr.specified) { + neo[attr.name] = attr.value //复制其属性 + neo.setAttribute(attr.name, attr.value) + } + }) // jshint ignore:line + neo.text = el.text + el.parentNode.replaceChild(neo, el) //替换节点 + } + } + } + if (!W3C) { //fix IE + var target = wrap[1] === "X
" ? wrapper.lastChild.firstChild : wrapper.lastChild + if (target && target.tagName === "TABLE" && tag !== "tbody") { + //IE6-7处理 --> , + // --> , + // -->
+ for (els = target.childNodes, i = 0; el = els[i++]; ) { + if (el.tagName === "TBODY" && !el.innerHTML) { + target.removeChild(el) + break + } + } + } + els = wrapper.getElementsByTagName("br") + var n = els.length + while (el = els[--n]) { + if (el.className === "msNoScope") { + el.parentNode.removeChild(el) + } + } + for (els = wrapper.all, i = 0; el = els[i++]; ) { //fix VML + if (isVML(el)) { + fixVML(el) + } + } + } + //移除我们为了符合套嵌关系而添加的标签 + for (i = wrap[0]; i--; wrapper = wrapper.lastChild) { + } + while (firstChild = wrapper.firstChild) { // 将wrapper上的节点转移到文档碎片上! + fragment.appendChild(firstChild) + } + return fragment +} + +function isVML(src) { + var nodeName = src.nodeName + return nodeName.toLowerCase() === nodeName && src.scopeName && src.outerText === "" +} + +function fixVML(node) { + if (node.currentStyle.behavior !== "url(#default#VML)") { + node.style.behavior = "url(#default#VML)" + node.style.display = "inline-block" + node.style.zoom = 1 //hasLayout + } +} +avalon.innerHTML = function (node, html) { + if (!W3C && (!rcreate.test(html) && !rnest.test(html))) { + try { + node.innerHTML = html + return + } catch (e) { + } + } + var a = this.parseHTML(html) + this.clearHTML(node).appendChild(a) +} +avalon.clearHTML = function (node) { + node.textContent = "" + while (node.firstChild) { + node.removeChild(node.firstChild) + } + return node +} + +/********************************************************************* + * avalon的原型方法定义区 * + **********************************************************************/ + +function hyphen(target) { + //转换为连字符线风格 + return target.replace(/([a-z\d])([A-Z]+)/g, "$1-$2").toLowerCase() +} + +function camelize(target) { + //提前判断,提高getStyle等的效率 + if (!target || target.indexOf("-") < 0 && target.indexOf("_") < 0) { + return target + } + //转换为驼峰风格 + return target.replace(/[-_][^-_]/g, function(match) { + return match.charAt(1).toUpperCase() + }) +} + +var fakeClassListMethods = { + _toString: function() { + var node = this.node + var cls = node.className + var str = typeof cls === "string" ? cls : cls.baseVal + return str.split(/\s+/).join(" ") + }, + _contains: function(cls) { + return (" " + this + " ").indexOf(" " + cls + " ") > -1 + }, + _add: function(cls) { + if (!this.contains(cls)) { + this._set(this + " " + cls) + } + }, + _remove: function(cls) { + this._set((" " + this + " ").replace(" " + cls + " ", " ")) + }, + __set: function(cls) { + cls = cls.trim() + var node = this.node + if (rsvg.test(node)) { + //SVG元素的className是一个对象 SVGAnimatedString { baseVal="", animVal=""},只能通过set/getAttribute操作 + node.setAttribute("class", cls) + } else { + node.className = cls + } + } //toggle存在版本差异,因此不使用它 +} + + function fakeClassList(node) { + if (!("classList" in node)) { + node.classList = { + node: node + } + for (var k in fakeClassListMethods) { + node.classList[k.slice(1)] = fakeClassListMethods[k] + } + } + return node.classList + } + + + "add,remove".replace(rword, function(method) { + avalon.fn[method + "Class"] = function(cls) { + var el = this[0] + //https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/26 + if (cls && typeof cls === "string" && el && el.nodeType === 1) { + cls.replace(/\S+/g, function(c) { + fakeClassList(el)[method](c) + }) + } + return this + } + }) + avalon.fn.mix({ + hasClass: function(cls) { + var el = this[0] || {} + return el.nodeType === 1 && fakeClassList(el).contains(cls) + }, + toggleClass: function(value, stateVal) { + var className, i = 0 + var classNames = String(value).split(/\s+/) + var isBool = typeof stateVal === "boolean" + while ((className = classNames[i++])) { + var state = isBool ? stateVal : !this.hasClass(className) + this[state ? "addClass" : "removeClass"](className) + } + return this + }, + attr: function(name, value) { + if (arguments.length === 2) { + this[0].setAttribute(name, value) + return this + } else { + return this[0].getAttribute(name) + } + }, + data: function(name, value) { + name = "data-" + hyphen(name || "") + switch (arguments.length) { + case 2: + this.attr(name, value) + return this + case 1: + var val = this.attr(name) + return parseData(val) + case 0: + var ret = {} + ap.forEach.call(this[0].attributes, function(attr) { + if (attr) { + name = attr.name + if (!name.indexOf("data-")) { + name = camelize(name.slice(5)) + ret[name] = parseData(attr.value) + } + } + }) + return ret + } + }, + removeData: function(name) { + name = "data-" + hyphen(name) + this[0].removeAttribute(name) + return this + }, + css: function(name, value) { + if (avalon.isPlainObject(name)) { + for (var i in name) { + avalon.css(this, i, name[i]) + } + } else { + var ret = avalon.css(this, name, value) + } + return ret !== void 0 ? ret : this + }, + position: function() { + var offsetParent, offset, + elem = this[0], + parentOffset = { + top: 0, + left: 0 + } + if (!elem) { + return + } + if (this.css("position") === "fixed") { + offset = elem.getBoundingClientRect() + } else { + offsetParent = this.offsetParent() //得到真正的offsetParent + offset = this.offset() // 得到正确的offsetParent + if (offsetParent[0].tagName !== "HTML") { + parentOffset = offsetParent.offset() + } + parentOffset.top += avalon.css(offsetParent[0], "borderTopWidth", true) + parentOffset.left += avalon.css(offsetParent[0], "borderLeftWidth", true) + + // Subtract offsetParent scroll positions + parentOffset.top -= offsetParent.scrollTop() + parentOffset.left -= offsetParent.scrollLeft() + } + return { + top: offset.top - parentOffset.top - avalon.css(elem, "marginTop", true), + left: offset.left - parentOffset.left - avalon.css(elem, "marginLeft", true) + } + }, + offsetParent: function() { + var offsetParent = this[0].offsetParent + while (offsetParent && avalon.css(offsetParent, "position") === "static") { + offsetParent = offsetParent.offsetParent; + } + return avalon(offsetParent || root) + }, + bind: function(type, fn, phase) { + if (this[0]) { //此方法不会链 + return avalon.bind(this[0], type, fn, phase) + } + }, + unbind: function(type, fn, phase) { + if (this[0]) { + avalon.unbind(this[0], type, fn, phase) + } + return this + }, + val: function(value) { + var node = this[0] + if (node && node.nodeType === 1) { + var get = arguments.length === 0 + var access = get ? ":get" : ":set" + var fn = valHooks[getValType(node) + access] + if (fn) { + var val = fn(node, value) + } else if (get) { + return (node.value || "").replace(/\r/g, "") + } else { + node.value = value + } + } + return get ? val : this + } + }) + + function parseData(data) { + try { + if (typeof data === "object") + return data + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : +data + "" === data ? +data : rbrace.test(data) ? avalon.parseJSON(data) : data + } catch (e) {} + return data + } +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, + rvalidchars = /^[\],:{}\s]*$/, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, + rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g +avalon.parseJSON = window.JSON ? JSON.parse : function(data) { + if (typeof data === "string") { + data = data.trim(); + if (data) { + if (rvalidchars.test(data.replace(rvalidescape, "@") + .replace(rvalidtokens, "]") + .replace(rvalidbraces, ""))) { + return (new Function("return " + data))() // jshint ignore:line + } + } + avalon.error("Invalid JSON: " + data) + } + return data +} + +//生成avalon.fn.scrollLeft, avalon.fn.scrollTop方法 +avalon.each({ + scrollLeft: "pageXOffset", + scrollTop: "pageYOffset" +}, function(method, prop) { + avalon.fn[method] = function(val) { + var node = this[0] || {}, win = getWindow(node), + top = method === "scrollTop" + if (!arguments.length) { + return win ? (prop in win) ? win[prop] : root[method] : node[method] + } else { + if (win) { + win.scrollTo(!top ? val : avalon(win).scrollLeft(), top ? val : avalon(win).scrollTop()) + } else { + node[method] = val + } + } + } +}) + +function getWindow(node) { + return node.window && node.document ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; +} +//=============================css相关======================= +var cssHooks = avalon.cssHooks = {} +var prefixes = ["", "-webkit-", "-o-", "-moz-", "-ms-"] +var cssMap = { + "float": W3C ? "cssFloat" : "styleFloat" +} +avalon.cssNumber = oneObject("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom") + +avalon.cssName = function(name, host, camelCase) { + if (cssMap[name]) { + return cssMap[name] + } + host = host || root.style + for (var i = 0, n = prefixes.length; i < n; i++) { + camelCase = camelize(prefixes[i] + name) + if (camelCase in host) { + return (cssMap[name] = camelCase) + } + } + return null +} +cssHooks["@:set"] = function(node, name, value) { + try { //node.style.width = NaN;node.style.width = "xxxxxxx";node.style.width = undefine 在旧式IE下会抛异常 + node.style[name] = value + } catch (e) {} +} +if (window.getComputedStyle) { + cssHooks["@:get"] = function(node, name) { + if (!node || !node.style) { + throw new Error("getComputedStyle要求传入一个节点 " + node) + } + var ret, styles = getComputedStyle(node, null) + if (styles) { + ret = name === "filter" ? styles.getPropertyValue(name) : styles[name] + if (ret === "") { + ret = node.style[name] //其他浏览器需要我们手动取内联样式 + } + } + return ret + } + cssHooks["opacity:get"] = function(node) { + var ret = cssHooks["@:get"](node, "opacity") + return ret === "" ? "1" : ret + } +} else { + var rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i + var rposition = /^(top|right|bottom|left)$/ + var ralpha = /alpha\([^)]*\)/i + var ie8 = !! window.XDomainRequest + var salpha = "DXImageTransform.Microsoft.Alpha" + var border = { + thin: ie8 ? '1px' : '2px', + medium: ie8 ? '3px' : '4px', + thick: ie8 ? '5px' : '6px' + } + cssHooks["@:get"] = function(node, name) { + //取得精确值,不过它有可能是带em,pc,mm,pt,%等单位 + var currentStyle = node.currentStyle + var ret = currentStyle[name] + if ((rnumnonpx.test(ret) && !rposition.test(ret))) { + //①,保存原有的style.left, runtimeStyle.left, + var style = node.style, + left = style.left, + rsLeft = node.runtimeStyle.left + //②由于③处的style.left = xxx会影响到currentStyle.left, + //因此把它currentStyle.left放到runtimeStyle.left, + //runtimeStyle.left拥有最高优先级,不会style.left影响 + node.runtimeStyle.left = currentStyle.left + //③将精确值赋给到style.left,然后通过IE的另一个私有属性 style.pixelLeft + //得到单位为px的结果;fontSize的分支见http://bugs.jquery.com/ticket/760 + style.left = name === 'fontSize' ? '1em' : (ret || 0) + ret = style.pixelLeft + "px" + //④还原 style.left,runtimeStyle.left + style.left = left + node.runtimeStyle.left = rsLeft + } + if (ret === "medium") { + name = name.replace("Width", "Style") + //border width 默认值为medium,即使其为0" + if (currentStyle[name] === "none") { + ret = "0px" + } + } + return ret === "" ? "auto" : border[ret] || ret + } + cssHooks["opacity:set"] = function(node, name, value) { + var style = node.style + var opacity = isFinite(value) && value <= 1 ? "alpha(opacity=" + value * 100 + ")" : "" + var filter = style.filter || ""; + style.zoom = 1 + //不能使用以下方式设置透明度 + //node.filters.alpha.opacity = value * 100 + style.filter = (ralpha.test(filter) ? + filter.replace(ralpha, opacity) : + filter + " " + opacity).trim() + if (!style.filter) { + style.removeAttribute("filter") + } + } + cssHooks["opacity:get"] = function(node) { + //这是最快的获取IE透明值的方式,不需要动用正则了! + var alpha = node.filters.alpha || node.filters[salpha], + op = alpha && alpha.enabled ? alpha.opacity : 100 + return (op / 100) + "" //确保返回的是字符串 + } +} + +"top,left".replace(rword, function(name) { + cssHooks[name + ":get"] = function(node) { + var computed = cssHooks["@:get"](node, name) + return /px$/.test(computed) ? computed : + avalon(node).position()[name] + "px" + } +}) + +var cssShow = { + position: "absolute", + visibility: "hidden", + display: "block" +} + +var rdisplayswap = /^(none|table(?!-c[ea]).+)/ + + function showHidden(node, array) { + //http://www.cnblogs.com/rubylouvre/archive/2012/10/27/2742529.html + if (node.offsetWidth <= 0) { //opera.offsetWidth可能小于0 + if (rdisplayswap.test(cssHooks["@:get"](node, "display"))) { + var obj = { + node: node + } + for (var name in cssShow) { + obj[name] = node.style[name] + node.style[name] = cssShow[name] + } + array.push(obj) + } + var parent = node.parentNode + if (parent && parent.nodeType === 1) { + showHidden(parent, array) + } + } + } + "Width,Height".replace(rword, function(name) { //fix 481 + var method = name.toLowerCase(), + clientProp = "client" + name, + scrollProp = "scroll" + name, + offsetProp = "offset" + name + cssHooks[method + ":get"] = function(node, which, override) { + var boxSizing = -4 + if (typeof override === "number") { + boxSizing = override + } + which = name === "Width" ? ["Left", "Right"] : ["Top", "Bottom"] + var ret = node[offsetProp] // border-box 0 + if (boxSizing === 2) { // margin-box 2 + return ret + avalon.css(node, "margin" + which[0], true) + avalon.css(node, "margin" + which[1], true) + } + if (boxSizing < 0) { // padding-box -2 + ret = ret - avalon.css(node, "border" + which[0] + "Width", true) - avalon.css(node, "border" + which[1] + "Width", true) + } + if (boxSizing === -4) { // content-box -4 + ret = ret - avalon.css(node, "padding" + which[0], true) - avalon.css(node, "padding" + which[1], true) + } + return ret + } + cssHooks[method + "&get"] = function(node) { + var hidden = []; + showHidden(node, hidden); + var val = cssHooks[method + ":get"](node) + for (var i = 0, obj; obj = hidden[i++];) { + node = obj.node + for (var n in obj) { + if (typeof obj[n] === "string") { + node.style[n] = obj[n] + } + } + } + return val; + } + avalon.fn[method] = function(value) { //会忽视其display + var node = this[0] + if (arguments.length === 0) { + if (node.setTimeout) { //取得窗口尺寸,IE9后可以用node.innerWidth /innerHeight代替 + return node["inner" + name] || node.document.documentElement[clientProp] + } + if (node.nodeType === 9) { //取得页面尺寸 + var doc = node.documentElement + //FF chrome html.scrollHeight< body.scrollHeight + //IE 标准模式 : html.scrollHeight> body.scrollHeight + //IE 怪异模式 : html.scrollHeight 最大等于可视窗口多一点? + return Math.max(node.body[scrollProp], doc[scrollProp], node.body[offsetProp], doc[offsetProp], doc[clientProp]) + } + return cssHooks[method + "&get"](node) + } else { + return this.css(method, value) + } + } + avalon.fn["inner" + name] = function() { + return cssHooks[method + ":get"](this[0], void 0, -2) + } + avalon.fn["outer" + name] = function(includeMargin) { + return cssHooks[method + ":get"](this[0], void 0, includeMargin === true ? 2 : 0) + } + }) + avalon.fn.offset = function() { //取得距离页面左右角的坐标 + var node = this[0], + box = { + left: 0, + top: 0 + } + if (!node || !node.tagName || !node.ownerDocument) { + return box + } + var doc = node.ownerDocument, + body = doc.body, + root = doc.documentElement, + win = doc.defaultView || doc.parentWindow + if (!avalon.contains(root, node)) { + return box + } + //http://hkom.blog1.fc2.com/?mode=m&no=750 body的偏移量是不包含margin的 + //我们可以通过getBoundingClientRect来获得元素相对于client的rect. + //http://msdn.microsoft.com/en-us/library/ms536433.aspx + if (node.getBoundingClientRect) { + box = node.getBoundingClientRect() // BlackBerry 5, iOS 3 (original iPhone) + } + //chrome/IE6: body.scrollTop, firefox/other: root.scrollTop + var clientTop = root.clientTop || body.clientTop, + clientLeft = root.clientLeft || body.clientLeft, + scrollTop = Math.max(win.pageYOffset || 0, root.scrollTop, body.scrollTop), + scrollLeft = Math.max(win.pageXOffset || 0, root.scrollLeft, body.scrollLeft) + // 把滚动距离加到left,top中去。 + // IE一些版本中会自动为HTML元素加上2px的border,我们需要去掉它 + // http://msdn.microsoft.com/en-us/library/ms533564(VS.85).aspx + return { + top: box.top + scrollTop - clientTop, + left: box.left + scrollLeft - clientLeft + } + } + + //==================================val相关============================ + + function getValType(elem) { + var ret = elem.tagName.toLowerCase() + return ret === "input" && /checkbox|radio/.test(elem.type) ? "checked" : ret + } +var roption = /^]+))?)*\s+value[\s=]/i +var valHooks = { + "option:get": IEVersion ? function(node) { + //在IE11及W3C,如果没有指定value,那么node.value默认为node.text(存在trim作),但IE9-10则是取innerHTML(没trim操作) + //specified并不可靠,因此通过分析outerHTML判定用户有没有显示定义value + return roption.test(node.outerHTML) ? node.value : node.text.trim() + } : function(node) { + return node.value + }, + "select:get": function(node, value) { + var option, options = node.options, + index = node.selectedIndex, + getter = valHooks["option:get"], + one = node.type === "select-one" || index < 0, + values = one ? null : [], + max = one ? index + 1 : options.length, + i = index < 0 ? max : one ? index : 0 + for (; i < max; i++) { + option = options[i] + //旧式IE在reset后不会改变selected,需要改用i === index判定 + //我们过滤所有disabled的option元素,但在safari5下,如果设置select为disable,那么其所有孩子都disable + //因此当一个元素为disable,需要检测其是否显式设置了disable及其父节点的disable情况 + if ((option.selected || i === index) && !option.disabled) { + value = getter(option) + if (one) { + return value + } + //收集所有selected值组成数组返回 + values.push(value) + } + } + return values + }, + "select:set": function(node, values, optionSet) { + values = [].concat(values) //强制转换为数组 + var getter = valHooks["option:get"] + for (var i = 0, el; el = node.options[i++];) { + if ((el.selected = values.indexOf(getter(el)) > -1)) { + optionSet = true + } + } + if (!optionSet) { + node.selectedIndex = -1 + } + } +} + +/********************************************************************* + * 编译系统 * + **********************************************************************/ +var meta = { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"': '\\"', + '\\': '\\\\' +} +var quote = window.JSON && JSON.stringify || function(str) { + return '"' + str.replace(/[\\\"\x00-\x1f]/g, function(a) { + var c = meta[a]; + return typeof c === 'string' ? c : + '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); + }) + '"' +} + +var keywords = [ + "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" /* ECMA 5 - use strict*/].join(",") +var rrexpstr = /\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g +var rsplit = /[^\w$]+/g +var rkeywords = new RegExp(["\\b" + keywords.replace(/,/g, '\\b|\\b') + "\\b"].join('|'), 'g') +var rnumber = /\b\d[^,]*/g +var rcomma = /^,+|,+$/g +var variablePool = new Cache(512) +var getVariables = function (code) { + var key = "," + code.trim() + var ret = variablePool.get(key) + if (ret) { + return ret + } + var match = code + .replace(rrexpstr, "") + .replace(rsplit, ",") + .replace(rkeywords, "") + .replace(rnumber, "") + .replace(rcomma, "") + .split(/^$|,+/) + return variablePool.put(key, uniqSet(match)) +} +/*添加赋值语句*/ + +function addAssign(vars, scope, name, data) { + var ret = [], + prefix = " = " + name + "." + for (var i = vars.length, prop; prop = vars[--i]; ) { + if (scope.hasOwnProperty(prop)) { + ret.push(prop + prefix + prop) + data.vars.push(prop) + if (data.type === "duplex") { + vars.get = name + "." + prop + } + vars.splice(i, 1) + } + } + return ret +} + +function uniqSet(array) { + var ret = [], + unique = {} + for (var i = 0; i < array.length; i++) { + var el = array[i] + var id = el && typeof el.$id === "string" ? el.$id : el + if (!unique[id]) { + unique[id] = ret.push(el) + } + } + return ret +} +//缓存求值函数,以便多次利用 +var evaluatorPool = new Cache(128) +//取得求值函数及其传参 +var rduplex = /\w\[.*\]|\w\.\w/ +var rproxy = /(\$proxy\$[a-z]+)\d+$/ +var rthimRightParentheses = /\)\s*$/ +var rthimOtherParentheses = /\)\s*\|/g +var rquoteFilterName = /\|\s*([$\w]+)/g +var rpatchBracket = /"\s*\["/g +var rthimLeftParentheses = /"\s*\(/g +function parseFilter(val, filters) { + filters = filters + .replace(rthimRightParentheses, "")//处理最后的小括号 + .replace(rthimOtherParentheses, function () {//处理其他小括号 + return "],|" + }) + .replace(rquoteFilterName, function (a, b) { //处理|及它后面的过滤器的名字 + return "[" + quote(b) + }) + .replace(rpatchBracket, function () { + return '"],["' + }) + .replace(rthimLeftParentheses, function () { + return '",' + }) + "]" + return "return avalon.filters.$filter(" + val + ", " + filters + ")" +} + +function parseExpr(code, scopes, data) { + var dataType = data.type + var filters = data.filters || "" + var exprId = scopes.map(function (el) { + return String(el.$id).replace(rproxy, "$1") + }) + code + dataType + filters + var vars = getVariables(code).concat(), + assigns = [], + names = [], + args = [], + prefix = "" + //args 是一个对象数组, names 是将要生成的求值函数的参数 + scopes = uniqSet(scopes) + data.vars = [] + for (var i = 0, sn = scopes.length; i < sn; i++) { + if (vars.length) { + var name = "vm" + expose + "_" + i + names.push(name) + args.push(scopes[i]) + assigns.push.apply(assigns, addAssign(vars, scopes[i], name, data)) + } + } + if (!assigns.length && dataType === "duplex") { + return + } + if (dataType !== "duplex" && (code.indexOf("||") > -1 || code.indexOf("&&") > -1)) { + //https://github.com/RubyLouvre/avalon/issues/583 + data.vars.forEach(function (v) { + var reg = new RegExp("\\b" + v + "(?:\\.\\w+|\\[\\w+\\])+", "ig") + code = code.replace(reg, function (_) { + var c = _.charAt(v.length) + var r = IEVersion ? code.slice(arguments[1] + _.length) : RegExp.rightContext + var method = /^\s*\(/.test(r) + if (c === "." || c === "[" || method) {//比如v为aa,我们只匹配aa.bb,aa[cc],不匹配aaa.xxx + var name = "var" + String(Math.random()).replace(/^0\./, "") + if (method) {//array.size() + var array = _.split(".") + if (array.length > 2) { + var last = array.pop() + assigns.push(name + " = " + array.join(".")) + return name + "." + last + } else { + return _ + } + } + assigns.push(name + " = " + _) + return name + } else { + return _ + } + }) + }) + } + //---------------args---------------- + data.args = args + //---------------cache---------------- + delete data.vars + var fn = evaluatorPool.get(exprId) //直接从缓存,免得重复生成 + if (fn) { + data.evaluator = fn + return + } + prefix = assigns.join(", ") + if (prefix) { + prefix = "var " + prefix + } + if (/\S/.test(filters)) { //文本绑定,双工绑定才有过滤器 + if (!/text|html/.test(data.type)) { + throw Error("ms-" + data.type + "不支持过滤器") + } + code = "\nvar ret" + expose + " = " + code + ";\r\n" + code += parseFilter("ret" + expose, filters) + } else if (dataType === "duplex") { //双工绑定 + var _body = "\nreturn function(vvv){\n\t" + + prefix + + ";\n\tif(!arguments.length){\n\t\treturn " + + code + + "\n\t}\n\t" + (!rduplex.test(code) ? vars.get : code) + + "= vvv;\n} " + try { + fn = Function.apply(noop, names.concat(_body)) + data.evaluator = evaluatorPool.put(exprId, fn) + } catch (e) { + log("debug: parse error," + e.message) + } + return + } else if (dataType === "on") { //事件绑定 + if (code.indexOf("(") === -1) { + code += ".call(this, $event)" + } else { + code = code.replace("(", ".call(this,") + } + names.push("$event") + code = "\nreturn " + code + ";" //IE全家 Function("return ")出错,需要Function("return ;") + var lastIndex = code.lastIndexOf("\nreturn") + var header = code.slice(0, lastIndex) + var footer = code.slice(lastIndex) + code = header + "\n" + footer + } else { //其他绑定 + code = "\nreturn " + code + ";" //IE全家 Function("return ")出错,需要Function("return ;") + } + try { + fn = Function.apply(noop, names.concat("\n" + prefix + code)) + data.evaluator = evaluatorPool.put(exprId, fn) + } catch (e) { + log("debug: parse error," + e.message) + } finally { + vars = assigns = names = null //释放内存 + } +} + + +//parseExpr的智能引用代理 + +function parseExprProxy(code, scopes, data, tokens, noRegister) { + if (Array.isArray(tokens)) { + code = tokens.map(function (el) { + return el.expr ? "(" + el.value + ")" : quote(el.value) + }).join(" + ") + } + parseExpr(code, scopes, data) + if (data.evaluator && !noRegister) { + data.handler = bindingExecutors[data.handlerName || data.type] + //方便调试 + //这里非常重要,我们通过判定视图刷新函数的element是否在DOM树决定 + //将它移出订阅者列表 + avalon.injectBinding(data) + } +} +avalon.parseExprProxy = parseExprProxy +/********************************************************************* + * 扫描系统 * + **********************************************************************/ + +avalon.scan = function(elem, vmodel) { + elem = elem || root + var vmodels = vmodel ? [].concat(vmodel) : [] + scanTag(elem, vmodels) +} + +//http://www.w3.org/TR/html5/syntax.html#void-elements +var stopScan = oneObject("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()) + +function checkScan(elem, callback, innerHTML) { + var id = setTimeout(function() { + var currHTML = elem.innerHTML + clearTimeout(id) + if (currHTML === innerHTML) { + callback() + } else { + checkScan(elem, callback, currHTML) + } + }) +} + + +function createSignalTower(elem, vmodel) { + var id = elem.getAttribute("avalonctrl") || vmodel.$id + elem.setAttribute("avalonctrl", id) + vmodel.$events.expr = elem.tagName + '[avalonctrl="' + id + '"]' +} + +var getBindingCallback = function(elem, name, vmodels) { + var callback = elem.getAttribute(name) + if (callback) { + for (var i = 0, vm; vm = vmodels[i++]; ) { + if (vm.hasOwnProperty(callback) && typeof vm[callback] === "function") { + return vm[callback] + } + } + } +} + +function executeBindings(bindings, vmodels) { + for (var i = 0, data; data = bindings[i++]; ) { + data.vmodels = vmodels + bindingHandlers[data.type](data, vmodels) + if (data.evaluator && data.element && data.element.nodeType === 1) { //移除数据绑定,防止被二次解析 + //chrome使用removeAttributeNode移除不存在的特性节点时会报错 https://github.com/RubyLouvre/avalon/issues/99 + data.element.removeAttribute(data.name) + } + } + bindings.length = 0 +} + +//https://github.com/RubyLouvre/avalon/issues/636 +var mergeTextNodes = IEVersion && window.MutationObserver ? function (elem) { + var node = elem.firstChild, text + while (node) { + var aaa = node.nextSibling + if (node.nodeType === 3) { + if (text) { + text.nodeValue += node.nodeValue + elem.removeChild(node) + } else { + text = node + } + } else { + text = null + } + node = aaa + } +} : 0 +var roneTime = /^\s*::/ +var rmsAttr = /ms-(\w+)-?(.*)/ +var priorityMap = { + "if": 10, + "repeat": 90, + "data": 100, + "widget": 110, + "each": 1400, + "with": 1500, + "duplex": 2000, + "on": 3000 +} + +var events = oneObject("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit") +var obsoleteAttrs = oneObject("value,title,alt,checked,selected,disabled,readonly,enabled") +function bindingSorter(a, b) { + return a.priority - b.priority +} + +function scanAttr(elem, vmodels, match) { + var scanNode = true + if (vmodels.length) { + var attributes = getAttributes ? getAttributes(elem) : elem.attributes + var bindings = [] + var fixAttrs = [] + var msData = {} + for (var i = 0, attr; attr = attributes[i++]; ) { + if (attr.specified) { + if (match = attr.name.match(rmsAttr)) { + //如果是以指定前缀命名的 + var type = match[1] + var param = match[2] || "" + var value = attr.value + var name = attr.name + if (events[type]) { + param = type + type = "on" + } else if (obsoleteAttrs[type]) { + if (type === "enabled") {//吃掉ms-enabled绑定,用ms-disabled代替 + log("warning!ms-enabled或ms-attr-enabled已经被废弃") + type = "disabled" + value = "!(" + value + ")" + } + param = type + type = "attr" + name = "ms-" + type + "-"+ param + fixAttrs.push([attr.name, name, value]) + } + msData[name] = value + if (typeof bindingHandlers[type] === "function") { + var newValue = value.replace(roneTime, "") + var oneTime = value !== newValue + var binding = { + type: type, + param: param, + element: elem, + name: name, + value: newValue, + oneTime: oneTime, + uuid: name+"-"+getUid(elem), + //chrome与firefox下Number(param)得到的值不一样 #855 + priority: (priorityMap[type] || type.charCodeAt(0) * 10 )+ (Number(param.replace(/\D/g, "")) || 0) + } + if (type === "html" || type === "text") { + var token = getToken(value) + avalon.mix(binding, token) + binding.filters = binding.filters.replace(rhasHtml, function () { + binding.type = "html" + binding.group = 1 + return "" + })// jshint ignore:line + } else if (type === "duplex") { + var hasDuplex = name + } else if (name === "ms-if-loop") { + binding.priority += 100 + } + bindings.push(binding) + if (type === "widget") { + elem.msData = elem.msData || msData + } + } + } + } + } + if (bindings.length) { + bindings.sort(bindingSorter) + fixAttrs.forEach(function (arr) { + log("warning!请改用" + arr[1] + "代替" + arr[0] + "!") + elem.removeAttribute(arr[0]) + elem.setAttribute(arr[1], arr[2]) + }) + //http://bugs.jquery.com/ticket/7071 + //在IE下对VML读取type属性,会让此元素所有属性都变成 + if (hasDuplex) { + if (msData["ms-attr-checked"]) { + log("warning!一个控件不能同时定义ms-attr-checked与" + hasDuplex) + } + if (msData["ms-attr-value"]) { + log("warning!一个控件不能同时定义ms-attr-value与" + hasDuplex) + } + } + for (i = 0; binding = bindings[i]; i++) { + type = binding.type + if (rnoscanAttrBinding.test(type)) { + return executeBindings(bindings.slice(0, i + 1), vmodels) + } else if (scanNode) { + scanNode = !rnoscanNodeBinding.test(type) + } + } + executeBindings(bindings, vmodels) + } + } + if (scanNode && !stopScan[elem.tagName] && rbind.test(elem.innerHTML.replace(rlt, "<").replace(rgt, ">"))) { + mergeTextNodes && mergeTextNodes(elem) + scanNodeList(elem, vmodels) //扫描子孙元素 + } +} +var rnoscanAttrBinding = /^if|widget|repeat$/ +var rnoscanNodeBinding = /^each|with|html|include$/ +//IE67下,在循环绑定中,一个节点如果是通过cloneNode得到,自定义属性的specified为false,无法进入里面的分支, +//但如果我们去掉scanAttr中的attr.specified检测,一个元素会有80+个特性节点(因为它不区分固有属性与自定义属性),很容易卡死页面 +if (!"1" [0]) { + var attrPool = new Cache(512) + var rattrs = /\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g, + rquote = /^['"]/, + rtag = /<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i, + ramp = /&/g + //IE6-8解析HTML5新标签,会将它分解两个元素节点与一个文本节点 + //
ddd
+ // window.onload = function() { + // var body = document.body + // for (var i = 0, el; el = body.children[i++]; ) { + // avalon.log(el.outerHTML) + // } + // } + //依次输出
,
+ var getAttributes = function (elem) { + var html = elem.outerHTML + //处理IE6-8解析HTML5新标签的情况,及
等半闭合标签outerHTML为空的情况 + if (html.slice(0, 2) === " ms-important(1) --> ms-controller(2) --> ms-if(10) --> ms-repeat(100) + //--> ms-if-loop(110) --> ms-attr(970) ...--> ms-each(1400)-->ms-with(1500)--〉ms-duplex(2000)垫后 + var a = elem.getAttribute("ms-skip") + //#360 在旧式IE中 Object标签在引入Flash等资源时,可能出现没有getAttributeNode,innerHTML的情形 + if (!elem.getAttributeNode) { + return log("warning " + elem.tagName + " no getAttributeNode method") + } + var b = elem.getAttributeNode("ms-important") + var c = elem.getAttributeNode("ms-controller") + if (typeof a === "string") { + return + } else if (node = b || c) { + var newVmodel = avalon.vmodels[node.value] + if (!newVmodel) { + return + } + //ms-important不包含父VM,ms-controller相反 + vmodels = node === b ? [newVmodel] : [newVmodel].concat(vmodels) + var name = node.name + elem.removeAttribute(name) //removeAttributeNode不会刷新[ms-controller]样式规则 + avalon(elem).removeClass(name) + createSignalTower(elem, newVmodel) + } + scanAttr(elem, vmodels) //扫描特性节点 +} +var rhasHtml = /\|\s*html\s*/, + r11a = /\|\|/g, + rlt = /</g, + rgt = />/g, + rstringLiteral = /(['"])(\\\1|.)+?\1/g +function getToken(value) { + if (value.indexOf("|") > 0) { + var scapegoat = value.replace(rstringLiteral, function (_) { + return Array(_.length + 1).join("1")// jshint ignore:line + }) + var index = scapegoat.replace(r11a, "\u1122\u3344").indexOf("|") //干掉所有短路或 + if (index > -1) { + return { + filters: value.slice(index), + value: value.slice(0, index), + expr: true + } + } + } + return { + value: value, + filters: "", + expr: true + } +} + +function scanExpr(str) { + var tokens = [], + value, start = 0, + stop + do { + stop = str.indexOf(openTag, start) + if (stop === -1) { + break + } + value = str.slice(start, stop) + if (value) { // {{ 左边的文本 + tokens.push({ + value: value, + filters: "", + expr: false + }) + } + start = stop + openTag.length + stop = str.indexOf(closeTag, start) + if (stop === -1) { + break + } + value = str.slice(start, stop) + if (value) { //处理{{ }}插值表达式 + tokens.push(getToken(value, start)) + } + start = stop + closeTag.length + } while (1) + value = str.slice(start) + if (value) { //}} 右边的文本 + tokens.push({ + value: value, + expr: false, + filters: "" + }) + } + return tokens +} + +function scanText(textNode, vmodels, index) { + var bindings = [] + tokens = scanExpr(textNode.data) + if (tokens.length) { + for (var i = 0; token = tokens[i++]; ) { + var node = DOC.createTextNode(token.value) //将文本转换为文本节点,并替换原来的文本节点 + if (token.expr) { + token.value = token.value.replace(roneTime, function () { + token.oneTime = true + return "" + }) + token.type = "text" + token.element = node + token.filters = token.filters.replace(rhasHtml, function () { + token.type = "html" + return "" + })// jshint ignore:line + token.pos = index * 1000 + i + bindings.push(token) //收集带有插值表达式的文本 + } + avalonFragment.appendChild(node) + } + textNode.parentNode.replaceChild(avalonFragment, textNode) + if (bindings.length) + executeBindings(bindings, vmodels) + } +} + +var bools = ["autofocus,autoplay,async,allowTransparency,checked,controls", + "declare,disabled,defer,defaultChecked,defaultSelected", + "contentEditable,isMap,loop,multiple,noHref,noResize,noShade", + "open,readOnly,selected" +].join(",") +var boolMap = {} +bools.replace(rword, function(name) { + boolMap[name.toLowerCase()] = name +}) + +var propMap = { //属性名映射 + "accept-charset": "acceptCharset", + "char": "ch", + "charoff": "chOff", + "class": "className", + "for": "htmlFor", + "http-equiv": "httpEquiv" +} + +var anomaly = ["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan", + "dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight", + "rowSpan,tabIndex,useMap,vSpace,valueType,vAlign" +].join(",") +anomaly.replace(rword, function(name) { + propMap[name.toLowerCase()] = name +}) + +var rnoscripts = /(?:[\s\S]+?)<\/noscript>/img +var rnoscriptText = /([\s\S]+?)<\/noscript>/im + +var getXHR = function() { + return new(window.XMLHttpRequest || ActiveXObject)("Microsoft.XMLHTTP") // jshint ignore:line +} + +var templatePool = avalon.templateCache = {} + +bindingHandlers.attr = function(data, vmodels) { + var text = data.value.trim(), + simple = true + if (text.indexOf(openTag) > -1 && text.indexOf(closeTag) > 2) { + simple = false + if (rexpr.test(text) && RegExp.rightContext === "" && RegExp.leftContext === "") { + simple = true + text = RegExp.$1 + } + } + if (data.type === "include") { + var elem = data.element + data.includeRendered = getBindingCallback(elem, "data-include-rendered", vmodels) + data.includeLoaded = getBindingCallback(elem, "data-include-loaded", vmodels) + var outer = data.includeReplace = !! avalon(elem).data("includeReplace") + if (avalon(elem).data("includeCache")) { + data.templateCache = {} + } + data.startInclude = DOC.createComment("ms-include") + data.endInclude = DOC.createComment("ms-include-end") + if (outer) { + data.element = data.startInclude + elem.parentNode.insertBefore(data.startInclude, elem) + elem.parentNode.insertBefore(data.endInclude, elem.nextSibling) + } else { + elem.insertBefore(data.startInclude, elem.firstChild) + elem.appendChild(data.endInclude) + } + } + data.handlerName = "attr" //handleName用于处理多种绑定共用同一种bindingExecutor的情况 + parseExprProxy(text, vmodels, data, (simple ? 0 : scanExpr(data.value))) +} + +bindingExecutors.attr = function(val, elem, data) { + var method = data.type, + attrName = data.param + 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属性 + var toRemove = (val === false) || (val === null) || (val === void 0) + + if (!W3C && propMap[attrName]) { //旧式IE下需要进行名字映射 + attrName = propMap[attrName] + } + var bool = boolMap[attrName] + if (typeof elem[bool] === "boolean") { + elem[bool] = !! val //布尔属性必须使用el.xxx = true|false方式设值 + if (!val) { //如果为false, IE全系列下相当于setAttribute(xxx,''),会影响到样式,需要进一步处理 + toRemove = true + } + } + 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) { + elem[attrName] = val+"" + } else { + elem.setAttribute(attrName, val) + } + } else if (method === "include" && val) { + var vmodels = data.vmodels + var rendered = data.includeRendered + var loaded = data.includeLoaded + var replace = data.includeReplace + var target = replace ? elem.parentNode : elem + var scanTemplate = function(text) { + if (loaded) { + var newText = loaded.apply(target, [text].concat(vmodels)) + if (typeof newText === "string") + text = newText + } + if (rendered) { + checkScan(target, function() { + rendered.call(target) + }, NaN) + } + var lastID = data.includeLastID + if (data.templateCache && lastID && lastID !== val) { + var lastTemplate = data.templateCache[lastID] + if (!lastTemplate) { + lastTemplate = data.templateCache[lastID] = DOC.createElement("div") + ifGroup.appendChild(lastTemplate) + } + } + data.includeLastID = val + while (true) { + var node = data.startInclude.nextSibling + if (node && node !== data.endInclude) { + target.removeChild(node) + if (lastTemplate) + lastTemplate.appendChild(node) + } else { + break + } + } + var dom = getTemplateNodes(data, val, text) + var nodes = avalon.slice(dom.childNodes) + target.insertBefore(dom, data.endInclude) + scanNodeArray(nodes, vmodels) + } + + if (data.param === "src") { + if (typeof templatePool[val] === "string") { + avalon.nextTick(function() { + scanTemplate(templatePool[val]) + }) + } else if (Array.isArray(templatePool[val])) { //#805 防止在循环绑定中发出许多相同的请求 + templatePool[val].push(scanTemplate) + } else { + var xhr = getXHR() + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + var s = xhr.status + if (s >= 200 && s < 300 || s === 304 || s === 1223) { + var text = xhr.responseText + for (var f = 0, fn; fn = templatePool[val][f++];) { + fn(text) + } + templatePool[val] = text + } + } + } + templatePool[val] = [scanTemplate] + xhr.open("GET", val, true) + if ("withCredentials" in xhr) { + xhr.withCredentials = true + } + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest") + xhr.send(null) + } + } else { + //IE系列与够新的标准浏览器支持通过ID取得元素(firefox14+) + //http://tjvantoll.com/2012/07/19/dom-element-references-as-global-variables/ + var el = val && val.nodeType === 1 ? val : DOC.getElementById(val) + if (el) { + if (el.tagName === "NOSCRIPT" && !(el.innerHTML || el.fixIE78)) { //IE7-8 innerText,innerHTML都无法取得其内容,IE6能取得其innerHTML + xhr = getXHR() //IE9-11与chrome的innerHTML会得到转义的内容,它们的innerText可以 + xhr.open("GET", location, false) //谢谢Nodejs 乱炖群 深圳-纯属虚构 + xhr.send(null) + //http://bbs.csdn.net/topics/390349046?page=1#post-393492653 + var noscripts = DOC.getElementsByTagName("noscript") + var array = (xhr.responseText || "").match(rnoscripts) || [] + var n = array.length + for (var i = 0; i < n; i++) { + var tag = noscripts[i] + if (tag) { //IE6-8中noscript标签的innerHTML,innerText是只读的 + tag.style.display = "none" //http://haslayout.net/css/noscript-Ghost-Bug + tag.fixIE78 = (array[i].match(rnoscriptText) || ["", " "])[1] + } + } + } + avalon.nextTick(function() { + scanTemplate(el.fixIE78 || el.value || el.innerText || el.innerHTML) + }) + } + } + } else { + if (!root.hasAttribute && typeof val === "string" && (method === "src" || method === "href")) { + val = val.replace(/&/g, "&") //处理IE67自动转义的问题 + } + elem[method] = val + if (window.chrome && elem.tagName === "EMBED") { + var parent = elem.parentNode //#525 chrome1-37下embed标签动态设置src不能发生请求 + var comment = document.createComment("ms-src") + parent.replaceChild(comment, elem) + parent.replaceChild(elem, comment) + } + } +} + +function getTemplateNodes(data, id, text) { + var div = data.templateCache && data.templateCache[id] + if (div) { + var dom = DOC.createDocumentFragment(), + firstChild + while (firstChild = div.firstChild) { + dom.appendChild(firstChild) + } + return dom + } + return avalon.parseHTML(text) +} + +//这几个指令都可以使用插值表达式,如ms-src="aaa/{{b}}/{{c}}.html" +"title,alt,src,value,css,include,href".replace(rword, function(name) { + bindingHandlers[name] = bindingHandlers.attr +}) +//根据VM的属性值或表达式的值切换类名,ms-class="xxx yyy zzz:flag" +//http://www.cnblogs.com/rubylouvre/archive/2012/12/17/2818540.html +bindingHandlers["class"] = function(data, vmodels) { + var oldStyle = data.param, + text = data.value, + rightExpr + data.handlerName = "class" + if (!oldStyle || isFinite(oldStyle)) { + data.param = "" //去掉数字 + var noExpr = text.replace(rexprg, function(a) { + return a.replace(/./g, "0") + //return Math.pow(10, a.length - 1) //将插值表达式插入10的N-1次方来占位 + }) + var colonIndex = noExpr.indexOf(":") //取得第一个冒号的位置 + if (colonIndex === -1) { // 比如 ms-class="aaa bbb ccc" 的情况 + var className = text + } else { // 比如 ms-class-1="ui-state-active:checked" 的情况 + className = text.slice(0, colonIndex) + rightExpr = text.slice(colonIndex + 1) + parseExpr(rightExpr, vmodels, data) //决定是添加还是删除 + if (!data.evaluator) { + log("debug: ms-class '" + (rightExpr || "").trim() + "' 不存在于VM中") + return false + } else { + data._evaluator = data.evaluator + data._args = data.args + } + } + var hasExpr = rexpr.test(className) //比如ms-class="width{{w}}"的情况 + if (!hasExpr) { + data.immobileClass = className + } + parseExprProxy("", vmodels, data, (hasExpr ? scanExpr(className) : 0)) + } else { + data.immobileClass = data.oldStyle = data.param + parseExprProxy(text, vmodels, data) + } +} + +bindingExecutors["class"] = function(val, elem, data) { + var $elem = avalon(elem), + method = data.type + if (method === "class" && data.oldStyle) { //如果是旧风格 + $elem.toggleClass(data.oldStyle, !! val) + } else { + //如果存在冒号就有求值函数 + data.toggleClass = data._evaluator ? !! data._evaluator.apply(elem, data._args) : true + data.newClass = data.immobileClass || val + if (data.oldClass && data.newClass !== data.oldClass) { + $elem.removeClass(data.oldClass) + } + data.oldClass = data.newClass + switch (method) { + case "class": + $elem.toggleClass(data.newClass, data.toggleClass) + break + case "hover": + case "active": + if (!data.hasBindEvent) { //确保只绑定一次 + var activate = "mouseenter" //在移出移入时切换类名 + var abandon = "mouseleave" + if (method === "active") { //在聚焦失焦中切换类名 + elem.tabIndex = elem.tabIndex || -1 + activate = "mousedown" + abandon = "mouseup" + var fn0 = $elem.bind("mouseleave", function() { + data.toggleClass && $elem.removeClass(data.newClass) + }) + } + var fn1 = $elem.bind(activate, function() { + data.toggleClass && $elem.addClass(data.newClass) + }) + var fn2 = $elem.bind(abandon, function() { + data.toggleClass && $elem.removeClass(data.newClass) + }) + data.rollback = function() { + $elem.unbind("mouseleave", fn0) + $elem.unbind(activate, fn1) + $elem.unbind(abandon, fn2) + } + data.hasBindEvent = true + } + break; + } + } +} + +"hover,active".replace(rword, function(method) { + bindingHandlers[method] = bindingHandlers["class"] +}) +//ms-controller绑定已经在scanTag 方法中实现 +//ms-css绑定已由ms-attr绑定实现 + + +// bindingHandlers.data 定义在if.js +bindingExecutors.data = function(val, elem, data) { + var key = "data-" + data.param + if (val && typeof val === "object") { + elem[key] = val + } else { + elem.setAttribute(key, String(val)) + } +} +//双工绑定 +var duplexBinding = bindingHandlers.duplex = function(data, vmodels) { + var elem = data.element, + hasCast + parseExprProxy(data.value, vmodels, data, 0, 1) + + data.changed = getBindingCallback(elem, "data-duplex-changed", vmodels) || noop + if (data.evaluator && data.args) { + var params = [] + var casting = oneObject("string,number,boolean,checked") + if (elem.type === "radio" && data.param === "") { + data.param = "checked" + } + if (elem.msData) { + elem.msData["ms-duplex"] = data.value + } + data.param.replace(/\w+/g, function(name) { + if (/^(checkbox|radio)$/.test(elem.type) && /^(radio|checked)$/.test(name)) { + if (name === "radio") + log("ms-duplex-radio已经更名为ms-duplex-checked") + name = "checked" + data.isChecked = true + } + if (name === "bool") { + name = "boolean" + log("ms-duplex-bool已经更名为ms-duplex-boolean") + } else if (name === "text") { + name = "string" + log("ms-duplex-text已经更名为ms-duplex-string") + } + if (casting[name]) { + hasCast = true + } + avalon.Array.ensure(params, name) + }) + if (!hasCast) { + params.push("string") + } + data.param = params.join("-") + data.bound = function(type, callback) { + if (elem.addEventListener) { + elem.addEventListener(type, callback, false) + } else { + elem.attachEvent("on" + type, callback) + } + var old = data.rollback + data.rollback = function() { + elem.avalonSetter = null + avalon.unbind(elem, type, callback) + old && old() + } + } + for (var i in avalon.vmodels) { + var v = avalon.vmodels[i] + v.$fire("avalon-ms-duplex-init", data) + } + var cpipe = data.pipe || (data.pipe = pipe) + cpipe(null, data, "init") + var tagName = elem.tagName + duplexBinding[tagName] && duplexBinding[tagName](elem, data.evaluator.apply(null, data.args), data) + } +} +//不存在 bindingExecutors.duplex + + function fixNull(val) { + return val == null ? "" : val + } +avalon.duplexHooks = { + checked: { + get: function(val, data) { + return !data.element.oldValue + } + }, + string: { + get: function(val) { //同步到VM + return val + }, + set: fixNull + }, + "boolean": { + get: function(val) { + return val === "true" + }, + set: fixNull + }, + number: { + get: function(val, data) { + var number = parseFloat(val) + if (-val === -number) { + return number + } + var arr = /strong|medium|weak/.exec(data.element.getAttribute("data-duplex-number")) || ["medium"] + switch (arr[0]) { + case "strong": + return 0 + case "medium": + return val === "" ? "" : 0 + case "weak": + return val + } + }, + set: fixNull + } +} + +function pipe(val, data, action, e) { + data.param.replace(/\w+/g, function(name) { + var hook = avalon.duplexHooks[name] + if (hook && typeof hook[action] === "function") { + val = hook[action](val, data) + } + }) + return val +} + +var TimerID, ribbon = [] + + avalon.tick = function(fn) { + if (ribbon.push(fn) === 1) { + TimerID = setInterval(ticker, 60) + } + } + + function ticker() { + for (var n = ribbon.length - 1; n >= 0; n--) { + var el = ribbon[n] + if (el() === false) { + ribbon.splice(n, 1) + } + } + if (!ribbon.length) { + clearInterval(TimerID) + } + } + +var watchValueInTimer = noop +var rmsinput = /text|password|hidden/ +new function() { // jshint ignore:line + try { //#272 IE9-IE11, firefox + var setters = {} + var aproto = HTMLInputElement.prototype + var bproto = HTMLTextAreaElement.prototype + function newSetter(value) { // jshint ignore:line + setters[this.tagName].call(this, value) + if (rmsinput.test(this.type) && !this.msFocus && this.avalonSetter) { + this.avalonSetter() + } + } + 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 + // https://docs.google.com/document/d/1jwA8mtClwxI-QJuHT7872Z0pxpZz8PBkf2bGAbsUtqs/edit?pli=1 + watchValueInTimer = avalon.tick + } +} // jshint ignore:line +if (IEVersion) { + avalon.bind(DOC, "selectionchange", function(e) { + var el = DOC.activeElement + if (el && typeof el.avalonSetter === "function") { + el.avalonSetter() + } + }) +} + +//处理radio, checkbox, text, textarea, password +duplexBinding.INPUT = function(element, evaluator, data) { + var $type = element.type, + bound = data.bound, + $elem = avalon(element), + composing = false + + function callback(value) { + data.changed.call(this, value, data) + } + + function compositionStart() { + composing = true + } + + function compositionEnd() { + composing = false + } + //当value变化时改变model的值 + var updateVModel = function() { + if (composing) //处理中文输入法在minlengh下引发的BUG + return + var val = element.oldValue = element.value //防止递归调用形成死循环 + var lastValue = data.pipe(val, data, "get") + if ($elem.data("duplexObserve") !== false) { + evaluator(lastValue) + callback.call(element, lastValue) + if ($elem.data("duplex-focus")) { + avalon.nextTick(function() { + element.focus() + }) + } + } + } + //当model变化时,它就会改变value的值 + data.handler = function() { + var val = data.pipe(evaluator(), data, "set") + "" //fix #673 + if (val !== element.oldValue) { + element.value = val + } + } + if (data.isChecked || $type === "radio") { + var IE6 = IEVersion === 6 + updateVModel = function() { + if ($elem.data("duplexObserve") !== false) { + var lastValue = data.pipe(element.value, data, "get") + evaluator(lastValue) + callback.call(element, lastValue) + } + } + data.handler = function() { + var val = evaluator() + var checked = data.isChecked ? !! val : val + "" === element.value + element.oldValue = checked + if (IE6) { + setTimeout(function() { + //IE8 checkbox, radio是使用defaultChecked控制选中状态, + //并且要先设置defaultChecked后设置checked + //并且必须设置延迟 + element.defaultChecked = checked + element.checked = checked + }, 31) + } else { + element.checked = checked + } + } + bound("click", updateVModel) + } else if ($type === "checkbox") { + updateVModel = function() { + if ($elem.data("duplexObserve") !== false) { + var method = element.checked ? "ensure" : "remove" + var array = evaluator() + if (!Array.isArray(array)) { + log("ms-duplex应用于checkbox上要对应一个数组") + array = [array] + } + var val = data.pipe(element.value, data, "get") + avalon.Array[method](array, val) + callback.call(element, array) + } + } + + data.handler = function() { + var array = [].concat(evaluator()) //强制转换为数组 + var val = data.pipe(element.value, data, "get") + element.checked = array.indexOf(val) > -1 + } + bound(W3C ? "change" : "click", updateVModel) + } else { + var events = element.getAttribute("data-duplex-event") || "input" + if (element.attributes["data-event"]) { + log("data-event指令已经废弃,请改用data-duplex-event") + } + + function delay(e) { // jshint ignore:line + setTimeout(function() { + updateVModel(e) + }) + } + events.replace(rword, function(name) { + switch (name) { + case "input": + if (!IEVersion) { // W3C + bound("input", updateVModel) + //非IE浏览器才用这个 + bound("compositionstart", compositionStart) + bound("compositionend", compositionEnd) + bound("DOMAutoComplete", updateVModel) + } else { //onpropertychange事件无法区分是程序触发还是用户触发 + // IE下通过selectionchange事件监听IE9+点击input右边的X的清空行为,及粘贴,剪切,删除行为 + if (IEVersion > 8) { + bound("input", updateVModel) //IE9使用propertychange无法监听中文输入改动 + } else { + bound("propertychange", function(e) { //IE6-8下第一次修改时不会触发,需要使用keydown或selectionchange修正 + if (e.propertyName === "value") { + updateVModel() + } + }) + } + bound("dragend", delay) + //http://www.cnblogs.com/rubylouvre/archive/2013/02/17/2914604.html + //http://www.matts411.com/post/internet-explorer-9-oninput/ + } + break + default: + bound(name, updateVModel) + break + } + }) + bound("focus", function() { + element.msFocus = true + }) + bound("blur", function() { + element.msFocus = false + }) + + if (rmsinput.test($type)) { + watchValueInTimer(function() { + if (root.contains(element)) { + if (!element.msFocus && element.oldValue !== element.value) { + updateVModel() + } + } else if (!element.msRetain) { + return false + } + }) + } + + element.avalonSetter = updateVModel //#765 + } + + element.oldValue = element.value + avalon.injectBinding(data) + callback.call(element, element.value) +} +duplexBinding.TEXTAREA = duplexBinding.INPUT +duplexBinding.SELECT = function(element, evaluator, data) { + var $elem = avalon(element) + + function updateVModel() { + if ($elem.data("duplexObserve") !== false) { + var val = $elem.val() //字符串或字符串数组 + if (Array.isArray(val)) { + val = val.map(function(v) { + return data.pipe(v, data, "get") + }) + } else { + val = data.pipe(val, data, "get") + } + if (val + "" !== element.oldValue) { + evaluator(val) + } + data.changed.call(element, val, data) + } + } + data.handler = function() { + var val = evaluator() + val = val && val.$model || val + if (Array.isArray(val)) { + if (!element.multiple) { + log("ms-duplex在不能对应一个数组") + } + } + //必须变成字符串后才能比较 + val = Array.isArray(val) ? val.map(String) : val + "" + if (val + "" !== element.oldValue) { + $elem.val(val) + element.oldValue = val + "" + } + } + data.bound("change", updateVModel) + element.msCallback = function() { + avalon.injectBinding(data) + data.changed.call(element, evaluator(), data) + } +} +// bindingHandlers.html 定义在if.js +bindingExecutors.html = function (val, elem, data) { + var isHtmlFilter = elem.nodeType !== 1 + var parent = isHtmlFilter ? elem.parentNode : elem + 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) + data.element = DOC.createComment(signature + ":end") + parent.replaceChild(data.element, elem) + elem = data.element + } + if (typeof val !== "object") {//string, number, boolean + var fragment = avalon.parseHTML(String(val)) + } else if (val.nodeType === 11) { //将val转换为文档碎片 + fragment = val + } else if (val.nodeType === 1 || val.item) { + var nodes = val.nodeType === 1 ? val.childNodes : val.item + fragment = avalonFragment.cloneNode(true) + while (nodes[0]) { + fragment.appendChild(nodes[0]) + } + } + + nodes = avalon.slice(fragment.childNodes) + //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 + if (isHtmlFilter) { + 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) + } else { + avalon.clearHTML(elem).appendChild(fragment) + } + scanNodeArray(nodes, data.vmodels) +} +bindingHandlers["if"] = + bindingHandlers.data = + bindingHandlers.text = + bindingHandlers.html = + function(data, vmodels) { + parseExprProxy(data.value, vmodels, data) +} + +bindingExecutors["if"] = function(val, elem, data) { + try { + if(!elem.parentNode) return + } catch(e) {return} + if (val) { //插回DOM树 + if (elem.nodeType === 8) { + elem.parentNode.replaceChild(data.template, elem) + // animate.enter(data.template, elem.parentNode) + elem = data.element = data.template //这时可能为null + } + if (elem.getAttribute(data.name)) { + elem.removeAttribute(data.name) + scanAttr(elem, data.vmodels) + } + data.rollback = null + } else { //移出DOM树,并用注释节点占据原位置 + if (elem.nodeType === 1) { + var node = data.element = DOC.createComment("ms-if") + elem.parentNode.replaceChild(node, elem) + // animate.leave(elem, node.parentNode, node) + data.template = elem //元素节点 + ifGroup.appendChild(elem) + data.rollback = function() { + if (elem.parentNode === ifGroup) { + ifGroup.removeChild(elem) + } + } + } + } +} +//ms-important绑定已经在scanTag 方法中实现 +//ms-include绑定已由ms-attr绑定实现 + +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处理 + value = value.replace(rdash, "") + } + } + 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)) + } + 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) + } else { + var removeFn = avalon.bind(elem, eventType, callback) + } + data.rollback = function() { + if (typeof data.specialUnbind === "function") { + data.specialUnbind() + } else { + avalon.unbind(elem, eventType, removeFn) + } + } +} +bindingHandlers.repeat = function (data, vmodels) { + var type = data.type + parseExprProxy(data.value, vmodels, data, 0, 1) + data.proxies = [] + var freturn = false + try { + var $repeat = data.$repeat = data.evaluator.apply(0, data.args || []) + var xtype = avalon.type($repeat) + if (xtype !== "object" && xtype !== "array") { + freturn = true + avalon.log("warning:" + data.value + "只能是对象或数组") + } + } catch (e) { + freturn = true + } + var arr = data.value.split(".") || [] + if (arr.length > 1) { + arr.pop() + var n = arr[0] + for (var i = 0, v; v = vmodels[i++]; ) { + if (v && v.hasOwnProperty(n)) { + var events = v[n].$events || {} + events[subscribers] = events[subscribers] || [] + events[subscribers].push(data) + break + } + } + } + + var elem = data.element + if (elem.nodeType === 1) { + elem.removeAttribute(data.name) + data.sortedCallback = getBindingCallback(elem, "data-with-sorted", vmodels) + data.renderedCallback = getBindingCallback(elem, "data-" + type + "-rendered", vmodels) + var signature = generateID(type) + var start = DOC.createComment(signature) + var end = DOC.createComment(signature + ":end") + data.signature = signature + data.template = avalonFragment.cloneNode(false) + if (type === "repeat") { + var parent = elem.parentNode + parent.replaceChild(end, elem) + parent.insertBefore(start, end) + data.template.appendChild(elem) + } else { + while (elem.firstChild) { + data.template.appendChild(elem.firstChild) + } + elem.appendChild(start) + elem.appendChild(end) + } + data.element = end + data.handler = bindingExecutors.repeat + data.rollback = function () { + var elem = data.element + if (!elem) + return + data.handler("clear") + } + } + + if (freturn) { + return + } + + data.$outer = {} + var check0 = "$key" + var check1 = "$val" + if (Array.isArray($repeat)) { + check0 = "$first" + check1 = "$last" + } + + for (i = 0; v = vmodels[i++]; ) { + if (v.hasOwnProperty(check0) && v.hasOwnProperty(check1)) { + data.$outer = v + break + } + } + var $events = $repeat.$events + var $list = ($events || {})[subscribers] + injectDependency($list, data) + if (xtype === "object") { + data.$with = true + $repeat.$proxy || ($repeat.$proxy = {}) + data.handler("append", $repeat) + } else if ($repeat.length) { + data.handler("add", 0, $repeat.length) + } +} + +bindingExecutors.repeat = function (method, pos, el) { + if (method) { + var data = this, start, fragment + var end = data.element + var comments = getComments(data) + var parent = end.parentNode + var proxies = data.proxies + var transation = avalonFragment.cloneNode(false) + switch (method) { + case "add": //在pos位置后添加el数组(pos为插入位置,el为要插入的个数) + var n = pos + el + var fragments = [] + for (var i = pos; i < n; i++) { + var proxy = eachProxyAgent(i, data) + proxies.splice(i, 0, proxy) + shimController(data, transation, proxy, fragments) + } + 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) + var removed = proxies.splice(pos, el) + recycleProxies(removed, "each") + break + case "clear": + start = comments[0] + if (start) { + sweepNodes(start, end) + if (data.$with) { + parent.insertBefore(start, end) + } + } + recycleProxies(proxies, "each") + break + case "move": + start = comments[0] + if (start) { + var signature = start.nodeValue + var rooms = [] + var room = [], + node + sweepNodes(start, end, function () { + room.unshift(this) + if (this.nodeValue === signature) { + rooms.unshift(room) + room = [] + } + }) + sortByIndex(rooms, pos) + sortByIndex(proxies, pos) + while (room = rooms.shift()) { + while (node = room.shift()) { + transation.appendChild(node) + } + } + parent.insertBefore(transation, end) + } + break + case "index": //将proxies中的第pos个起的所有元素重新索引 + var last = proxies.length - 1 + for (; el = proxies[pos]; pos++) { + el.$index = pos + el.$first = pos === 0 + el.$last = pos === last + } + return + case "set": //将proxies中的第pos个元素的VM设置为el(pos为数字,el任意) + proxy = proxies[pos] + if (proxy) { + fireDependencies(proxy.$events[data.param || "el"]) + } + break + case "append": + var object = pos //原来第2参数, 被循环对象 + var pool = object.$proxy //代理对象组成的hash + var keys = [] + fragments = [] + for (var key in pool) { + if (!object.hasOwnProperty(key)) { + proxyRecycler(pool[key], withProxyPool) //去掉之前的代理VM + delete(pool[key]) + } + } + for (key in object) { //得到所有键名 + if (object.hasOwnProperty(key) && key !== "hasOwnProperty" && key !== "$proxy") { + keys.push(key) + } + } + if (data.sortedCallback) { //如果有回调,则让它们排序 + var keys2 = data.sortedCallback.call(parent, keys) + if (keys2 && Array.isArray(keys2) && keys2.length) { + keys = keys2 + } + } + + for (i = 0; key = keys[i++]; ) { + if (key !== "hasOwnProperty") { + pool[key] = withProxyAgent(pool[key], key, data) + shimController(data, transation, pool[key], fragments) + } + } + + parent.insertBefore(transation, end) + for (i = 0; fragment = fragments[i++]; ) { + scanNodeArray(fragment.nodes, fragment.vmodels) + fragment.nodes = fragment.vmodels = null + } + break + } + if (!data.$repeat || data.$repeat.hasOwnProperty("$lock")) //IE6-8 VBScript对象会报错, 有时候data.$repeat不存在 + return + if (method === "clear") + method = "del" + var callback = data.renderedCallback || noop, + args = arguments + if (parent.oldValue && parent.tagName === "SELECT") { //fix #503 + avalon(parent).val(parent.oldValue.split(",")) + } + callback.apply(parent, args) + } +} + +"with,each".replace(rword, function (name) { + bindingHandlers[name] = bindingHandlers.repeat +}) + +function shimController(data, transation, proxy, fragments) { + var content = data.template.cloneNode(true) + var nodes = avalon.slice(content.childNodes) + if (!data.$with) { + content.insertBefore(DOC.createComment(data.signature), content.firstChild) + } + transation.appendChild(content) + var nv = [proxy].concat(data.vmodels) + var fragment = { + nodes: nodes, + vmodels: nv + } + fragments.push(fragment) +} + +function getComments(data) { + var end = data.element + var signature = end.nodeValue.replace(":end", "") + var node = end.previousSibling + var array = [] + while (node) { + if (node.nodeValue === signature) { + array.unshift(node) + } + node = node.previousSibling + } + return array +} + + +//移除掉start与end之间的节点(保留end) +function sweepNodes(start, end, callback) { + while (true) { + var node = end.previousSibling + if (!node) + break + node.parentNode.removeChild(node) + callback && callback.call(node) + if (node === start) { + break + } + } +} + +// 为ms-each,ms-with, ms-repeat会创建一个代理VM, +// 通过它们保持一个下上文,让用户能调用$index,$first,$last,$remove,$key,$val,$outer等属性与方法 +// 所有代理VM的产生,消费,收集,存放通过xxxProxyFactory,xxxProxyAgent, recycleProxies,xxxProxyPool实现 +var withProxyPool = [] +function withProxyFactory() { + var proxy = modelFactory({ + $key: "", + $outer: {}, + $host: {}, + $val: { + get: function () { + return this.$host[this.$key] + }, + set: function (val) { + this.$host[this.$key] = val + } + } + }, { + $val: 1 + }) + proxy.$id = generateID("$proxy$with") + return proxy +} + +function withProxyAgent(proxy, key, data) { + proxy = proxy || withProxyPool.pop() + if (!proxy) { + proxy = withProxyFactory() + } else { + proxy.$reinitialize() + } + var host = data.$repeat + proxy.$key = key + proxy.$host = host + proxy.$outer = data.$outer + if (host.$events) { + proxy.$events.$val = host.$events[key] + } else { + proxy.$events = {} + } + return proxy +} + + +function recycleProxies(proxies) { + eachProxyRecycler(proxies) +} +function eachProxyRecycler(proxies) { + proxies.forEach(function (proxy) { + proxyRecycler(proxy, eachProxyPool) + }) + proxies.length = 0 +} + + +var eachProxyPool = [] +function eachProxyFactory(name) { + var source = { + $host: [], + $outer: {}, + $index: 0, + $first: false, + $last: false, + $remove: avalon.noop + } + source[name] = { + get: function () { + var e = this.$events + var array = e.$index + e.$index = e[name] //#817 通过$index为el收集依赖 + try { + return this.$host[this.$index] + } finally { + e.$index = array + } + }, + set: function (val) { + try { + var e = this.$events + var array = e.$index + e.$index = [] + this.$host.set(this.$index, val) + } finally { + e.$index = array + } + } + } + var second = { + $last: 1, + $first: 1, + $index: 1 + } + var proxy = modelFactory(source, second) + proxy.$id = generateID("$proxy$each") + return proxy +} + +function eachProxyAgent(index, data) { + var param = data.param || "el", + proxy + for (var i = 0, n = eachProxyPool.length; i < n; i++) { + var candidate = eachProxyPool[i] + if (candidate && candidate.hasOwnProperty(param)) { + proxy = candidate + eachProxyPool.splice(i, 1) + } + } + if (!proxy) { + proxy = eachProxyFactory(param) + } + var host = data.$repeat + var last = host.length - 1 + proxy.$index = index + proxy.$first = index === 0 + proxy.$last = index === last + proxy.$host = host + proxy.$outer = data.$outer + proxy.$remove = function () { + return host.removeAt(proxy.$index) + } + return proxy +} + + +function proxyRecycler(proxy, proxyPool) { + for (var i in proxy.$events) { + if (Array.isArray(proxy.$events[i])) { + proxy.$events[i].forEach(function (data) { + if (typeof data === "object") + disposeData(data) + })// jshint ignore:line + proxy.$events[i].length = 0 + } + } + proxy.$host = proxy.$outer = {} + if (proxyPool.unshift(proxy) > kernel.maxRepeatSize) { + proxyPool.pop() + } +} +/********************************************************************* + * 各种指令 * + **********************************************************************/ +//ms-skip绑定已经在scanTag 方法中实现 +// bindingHandlers.text 定义在if.js +bindingExecutors.text = function(val, elem) { + val = val == null ? "" : val //不在页面上显示undefined null + if (elem.nodeType === 3) { //绑定在文本节点上 + try { //IE对游离于DOM树外的节点赋值会报错 + elem.data = val + } catch (e) {} + } else { //绑定在特性节点上 + if ("textContent" in elem) { + elem.textContent = val + } else { + elem.innerText = val + } + } +} +function parseDisplay(nodeName, val) { + //用于取得此类标签的默认display值 + var key = "_" + nodeName + if (!parseDisplay[key]) { + var node = DOC.createElement(nodeName) + root.appendChild(node) + if (W3C) { + val = getComputedStyle(node, null).display + } else { + val = node.currentStyle.display + } + root.removeChild(node) + parseDisplay[key] = val + } + return parseDisplay[key] +} + +avalon.parseDisplay = parseDisplay + +bindingHandlers.visible = function(data, vmodels) { + var elem = avalon(data.element) + var display = elem.css("display") + if (display === "none") { + var style = elem[0].style + var has = /visibility/i.test(style.cssText) + var visible = elem.css("visibility") + style.display = "" + style.visibility = "hidden" + display = elem.css("display") + if (display === "none") { + display = parseDisplay(elem[0].nodeName) + } + style.visibility = has ? visible : "" + } + data.display = display + parseExprProxy(data.value, vmodels, data) +} + +bindingExecutors.visible = function(val, elem, data) { + elem.style.display = val ? data.display : "none" +} +bindingHandlers.widget = function(data, vmodels) { + var args = data.value.match(rword) + var elem = data.element + var widget = args[0] + var id = args[1] + if (!id || id === "$") { //没有定义或为$时,取组件名+随机数 + id = generateID(widget) + } + var optName = args[2] || widget //没有定义,取组件名 + var constructor = avalon.ui[widget] + if (typeof constructor === "function") { //ms-widget="tabs,tabsAAA,optname" + vmodels = elem.vmodels || vmodels + for (var i = 0, v; v = vmodels[i++];) { + if (v.hasOwnProperty(optName) && typeof v[optName] === "object") { + var vmOptions = v[optName] + vmOptions = vmOptions.$model || vmOptions + break + } + } + if (vmOptions) { + var wid = vmOptions[widget + "Id"] + if (typeof wid === "string") { + log("warning!不再支持" + widget + "Id") + id = wid + } + } + //抽取data-tooltip-text、data-tooltip-attr属性,组成一个配置对象 + var widgetData = avalon.getWidgetData(elem, widget) + data.value = [widget, id, optName].join(",") + data[widget + "Id"] = id + data.evaluator = noop + elem.msData["ms-widget-id"] = id + var options = data[widget + "Options"] = avalon.mix({}, constructor.defaults, vmOptions || {}, widgetData) + elem.removeAttribute("ms-widget") + var vmodel = constructor(elem, data, vmodels) || {} //防止组件不返回VM + if (vmodel.$id) { + avalon.vmodels[id] = vmodel + createSignalTower(elem, vmodel) + try { + vmodel.$init(function() { + avalon.scan(elem, [vmodel].concat(vmodels)) + if (typeof options.onInit === "function") { + options.onInit.call(elem, vmodel, options, vmodels) + } + }) + } catch (e) {} + data.rollback = function() { + try { + vmodel.widgetElement = null + vmodel.$remove() + } catch (e) {} + elem.msData = {} + delete avalon.vmodels[vmodel.$id] + } + injectDisposeQueue(data, widgetList) + if (window.chrome) { + elem.addEventListener("DOMNodeRemovedFromDocument", function() { + setTimeout(rejectDisposeQueue) + }) + } + } else { + avalon.scan(elem, vmodels) + } + } else if (vmodels.length) { //如果该组件还没有加载,那么保存当前的vmodels + elem.vmodels = vmodels + } +} +var widgetList = [] +//不存在 bindingExecutors.widget +/********************************************************************* + * 自带过滤器 * + **********************************************************************/ +var rscripts = /]*>([\S\s]*?)<\/script\s*>/gim +var ron = /\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g +var ropen = /<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/ig +var rsanitize = { + a: /\b(href)\=("javascript[^"]*"|'javascript[^']*')/ig, + img: /\b(src)\=("javascript[^"]*"|'javascript[^']*')/ig, + form: /\b(action)\=("javascript[^"]*"|'javascript[^']*')/ig +} +var rsurrogate = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g +var rnoalphanumeric = /([^\#-~| |!])/g; + +function numberFormat(number, decimals, point, thousands) { + //form http://phpjs.org/functions/number_format/ + //number 必需,要格式化的数字 + //decimals 可选,规定多少个小数位。 + //point 可选,规定用作小数点的字符串(默认为 . )。 + //thousands 可选,规定用作千位分隔符的字符串(默认为 , ),如果设置了该参数,那么所有其他参数都是必需的。 + number = (number + '') + .replace(/[^0-9+\-Ee.]/g, '') + var n = !isFinite(+number) ? 0 : +number, + prec = !isFinite(+decimals) ? 3 : Math.abs(decimals), + sep = thousands || ",", + dec = point || ".", + s = '', + toFixedFix = function(n, prec) { + var k = Math.pow(10, prec) + return '' + (Math.round(n * k) / k) + .toFixed(prec) + } + // Fix for IE parseFloat(0.55).toFixed(0) = 0; + s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)) + .split('.') + if (s[0].length > 3) { + s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep) + } + if ((s[1] || '') + .length < prec) { + s[1] = s[1] || '' + s[1] += new Array(prec - s[1].length + 1) + .join('0') + } + return s.join(dec) +} + + +var filters = avalon.filters = { + uppercase: function(str) { + return str.toUpperCase() + }, + lowercase: function(str) { + return str.toLowerCase() + }, + truncate: function(str, length, truncation) { + //length,新字符串长度,truncation,新字符串的结尾的字段,返回新字符串 + length = length || 30 + truncation = typeof truncation === "string" ? truncation : "..." + return str.length > length ? str.slice(0, length - truncation.length) + truncation : String(str) + }, + $filter: function(val) { + for (var i = 1, n = arguments.length; i < n; i++) { + var array = arguments[i] + var fn = avalon.filters[array.shift()] + if (typeof fn === "function") { + var arr = [val].concat(array) + val = fn.apply(null, arr) + } + } + return val + }, + camelize: camelize, + //https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet + // chrome + // chrome + // IE67chrome + // IE67chrome + // IE67chrome + sanitize: function(str) { + return str.replace(rscripts, "").replace(ropen, function(a, b) { + var match = a.toLowerCase().match(/<(\w+)\s/) + if (match) { //处理a标签的href属性,img标签的src属性,form标签的action属性 + var reg = rsanitize[match[1]] + if (reg) { + a = a.replace(reg, function(s, name, value) { + var quote = value.charAt(0) + return name + "=" + quote + "javascript:void(0)" + quote// jshint ignore:line + }) + } + } + return a.replace(ron, " ").replace(/\s+/g, " ") //移除onXXX事件 + }) + }, + escape: function(str) { + //将字符串经过 str 转义得到适合在页面中显示的内容, 例如替换 < 为 < + return String(str). + replace(/&/g, '&'). + replace(rsurrogate, function(value) { + var hi = value.charCodeAt(0) + var low = value.charCodeAt(1) + return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';' + }). + replace(rnoalphanumeric, function(value) { + return '&#' + value.charCodeAt(0) + ';' + }). + replace(//g, '>') + }, + currency: function(amount, symbol, fractionSize) { + return (symbol || "\uFFE5") + numberFormat(amount, isFinite(fractionSize) ? fractionSize : 2) + }, + number: numberFormat +} +/* + 'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010) + 'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10) + 'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199) + 'MMMM': Month in year (January-December) + 'MMM': Month in year (Jan-Dec) + 'MM': Month in year, padded (01-12) + 'M': Month in year (1-12) + 'dd': Day in month, padded (01-31) + 'd': Day in month (1-31) + 'EEEE': Day in Week,(Sunday-Saturday) + 'EEE': Day in Week, (Sun-Sat) + 'HH': Hour in day, padded (00-23) + 'H': Hour in day (0-23) + 'hh': Hour in am/pm, padded (01-12) + 'h': Hour in am/pm, (1-12) + 'mm': Minute in hour, padded (00-59) + 'm': Minute in hour (0-59) + 'ss': Second in minute, padded (00-59) + 's': Second in minute (0-59) + 'a': am/pm marker + 'Z': 4 digit (+sign) representation of the timezone offset (-1200-+1200) + format string can also be one of the following predefined localizable formats: + + 'medium': equivalent to 'MMM d, y h:mm:ss a' for en_US locale (e.g. Sep 3, 2010 12:05:08 pm) + 'short': equivalent to 'M/d/yy h:mm a' for en_US locale (e.g. 9/3/10 12:05 pm) + 'fullDate': equivalent to 'EEEE, MMMM d,y' for en_US locale (e.g. Friday, September 3, 2010) + 'longDate': equivalent to 'MMMM d, y' for en_US locale (e.g. September 3, 2010 + 'mediumDate': equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010) + 'shortDate': equivalent to 'M/d/yy' for en_US locale (e.g. 9/3/10) + 'mediumTime': equivalent to 'h:mm:ss a' for en_US locale (e.g. 12:05:08 pm) + 'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 pm) + */ +new function() {// jshint ignore:line + function toInt(str) { + return parseInt(str, 10) || 0 + } + + function padNumber(num, digits, trim) { + var neg = "" + if (num < 0) { + neg = '-' + num = -num + } + num = "" + num + while (num.length < digits) + num = "0" + num + if (trim) + num = num.substr(num.length - digits) + return neg + num + } + + function dateGetter(name, size, offset, trim) { + return function(date) { + var value = date["get" + name]() + if (offset > 0 || value > -offset) + value += offset + if (value === 0 && offset === -12) { + value = 12 + } + return padNumber(value, size, trim) + } + } + + function dateStrGetter(name, shortForm) { + return function(date, formats) { + var value = date["get" + name]() + var get = (shortForm ? ("SHORT" + name) : name).toUpperCase() + return formats[get][value] + } + } + + function timeZoneGetter(date) { + var zone = -1 * date.getTimezoneOffset() + var paddedZone = (zone >= 0) ? "+" : "" + paddedZone += padNumber(Math[zone > 0 ? "floor" : "ceil"](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2) + return paddedZone + } + //取得上午下午 + + function ampmGetter(date, formats) { + return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1] + } + var DATE_FORMATS = { + yyyy: dateGetter("FullYear", 4), + yy: dateGetter("FullYear", 2, 0, true), + y: dateGetter("FullYear", 1), + MMMM: dateStrGetter("Month"), + MMM: dateStrGetter("Month", true), + MM: dateGetter("Month", 2, 1), + M: dateGetter("Month", 1, 1), + dd: dateGetter("Date", 2), + d: dateGetter("Date", 1), + HH: dateGetter("Hours", 2), + H: dateGetter("Hours", 1), + hh: dateGetter("Hours", 2, -12), + h: dateGetter("Hours", 1, -12), + mm: dateGetter("Minutes", 2), + m: dateGetter("Minutes", 1), + ss: dateGetter("Seconds", 2), + s: dateGetter("Seconds", 1), + sss: dateGetter("Milliseconds", 3), + EEEE: dateStrGetter("Day"), + EEE: dateStrGetter("Day", true), + a: ampmGetter, + Z: timeZoneGetter + } + var rdateFormat = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/ + var raspnetjson = /^\/Date\((\d+)\)\/$/ + filters.date = function(date, format) { + var locate = filters.date.locate, + text = "", + parts = [], + fn, match + format = format || "mediumDate" + format = locate[format] || format + if (typeof date === "string") { + if (/^\d+$/.test(date)) { + date = toInt(date) + } else if (raspnetjson.test(date)) { + date = +RegExp.$1 + } else { + var trimDate = date.trim() + var dateArray = [0, 0, 0, 0, 0, 0, 0] + var oDate = new Date(0) + //取得年月日 + trimDate = trimDate.replace(/^(\d+)\D(\d+)\D(\d+)/, function(_, a, b, c) { + var array = c.length === 4 ? [c, a, b] : [a, b, c] + dateArray[0] = toInt(array[0]) //年 + dateArray[1] = toInt(array[1]) - 1 //月 + dateArray[2] = toInt(array[2]) //日 + return "" + }) + var dateSetter = oDate.setFullYear + var timeSetter = oDate.setHours + trimDate = trimDate.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/, function(_, a, b, c, d) { + dateArray[3] = toInt(a) //小时 + dateArray[4] = toInt(b) //分钟 + dateArray[5] = toInt(c) //秒 + if (d) { //毫秒 + dateArray[6] = Math.round(parseFloat("0." + d) * 1000) + } + return "" + }) + var tzHour = 0 + var tzMin = 0 + trimDate = trimDate.replace(/Z|([+-])(\d\d):?(\d\d)/, function(z, symbol, c, d) { + dateSetter = oDate.setUTCFullYear + timeSetter = oDate.setUTCHours + if (symbol) { + tzHour = toInt(symbol + c) + tzMin = toInt(symbol + d) + } + return "" + }) + + dateArray[3] -= tzHour + dateArray[4] -= tzMin + dateSetter.apply(oDate, dateArray.slice(0, 3)) + timeSetter.apply(oDate, dateArray.slice(3)) + date = oDate + } + } + if (typeof date === "number") { + date = new Date(date) + } + if (avalon.type(date) !== "date") { + return + } + while (format) { + match = rdateFormat.exec(format) + if (match) { + parts = parts.concat(match.slice(1)) + format = parts.pop() + } else { + parts.push(format) + format = null + } + } + parts.forEach(function(value) { + fn = DATE_FORMATS[value] + text += fn ? fn(date, locate) : value.replace(/(^'|'$)/g, "").replace(/''/g, "'") + }) + return text + } + var locate = { + 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" + } + locate.SHORTMONTH = locate.MONTH + filters.date.locate = locate +}// jshint ignore:line +/********************************************************************* + * END * + **********************************************************************/ +new function () { + avalon.config({ + loader: false + }) + var fns = [], loaded = DOC.readyState === "complete", fn + function flush(f) { + loaded = 1 + while (f = fns.shift()) + f() + } + + avalon.bind(DOC, "DOMContentLoaded", fn = function () { + avalon.unbind(DOC, "DOMContentLoaded", fn) + flush() + }) + + var id = setInterval(function () { + if (document.readyState === "complete" && document.body) { + clearInterval(id) + flush() + } + }, 50) + + avalon.ready = function (fn) { + loaded ? fn(avalon) : fns.push(fn) + } + avalon.ready(function () { + avalon.scan(DOC.body) + }) +} + + +// Register as a named AMD module, since avalon can be concatenated with other +// files that may use define, but not via a proper concatenation script that +// understands anonymous AMD modules. A named AMD is safest and most robust +// way to register. Lowercase avalon is used because AMD module names are +// derived from file names, and Avalon is normally delivered in a lowercase +// file name. Do this after creating the global so that if an AMD module wants +// to call noConflict to hide this version of avalon, it will work. + +// Note that for maximum portability, libraries that are not avalon should +// declare themselves as anonymous modules, and avoid setting a global if an +// AMD loader is present. avalon is a special case. For more information, see +// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon + if (typeof define === "function" && define.amd) { + define("avalon", [], function() { + return avalon + }) + } +// Map over avalon in case of overwrite + var _avalon = window.avalon + avalon.noConflict = function(deep) { + if (deep && window.avalon === avalon) { + window.avalon = _avalon + } + return avalon + } +// Expose avalon identifiers, even in AMD +// and CommonJS for browser emulators + if (noGlobal === void 0) { + window.avalon = avalon + } + return avalon + +})); /** * @license RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/requirejs/domReady for details */ +/*jslint */ +/*global require: false, define: false, requirejs: false, + window: false, clearInterval: false, document: false, + self: false, setInterval: false */ + + +define('domReady',[],function () { + + + var isTop, testDiv, scrollIntervalId, + isBrowser = typeof window !== "undefined" && window.document, + isPageLoaded = !isBrowser, + doc = isBrowser ? document : null, + readyCalls = []; + + function runCallbacks(callbacks) { + var i; + for (i = 0; i < callbacks.length; i += 1) { + callbacks[i](doc); + } + } + + function callReady() { + var callbacks = readyCalls; + + if (isPageLoaded) { + //Call the DOM ready callbacks + if (callbacks.length) { + readyCalls = []; + runCallbacks(callbacks); + } + } + } + + /** + * Sets the page as loaded. + */ + function pageLoaded() { + if (!isPageLoaded) { + isPageLoaded = true; + if (scrollIntervalId) { + clearInterval(scrollIntervalId); + } + + callReady(); + } + } + + if (isBrowser) { + if (document.addEventListener) { + //Standards. Hooray! Assumption here that if standards based, + //it knows about DOMContentLoaded. + document.addEventListener("DOMContentLoaded", pageLoaded, false); + window.addEventListener("load", pageLoaded, false); + } else if (window.attachEvent) { + window.attachEvent("onload", pageLoaded); + + testDiv = document.createElement('div'); + try { + isTop = window.frameElement === null; + } catch (e) {} + + //DOMContentLoaded approximation that uses a doScroll, as found by + //Diego Perini: http://javascript.nwbox.com/IEContentLoaded/, + //but modified by other contributors, including jdalton + if (testDiv.doScroll && isTop && window.external) { + scrollIntervalId = setInterval(function () { + try { + testDiv.doScroll(); + pageLoaded(); + } catch (e) {} + }, 30); + } + } + + //Check if document already complete, and if so, just trigger page load + //listeners. Latest webkit browsers also use "interactive", and + //will fire the onDOMContentLoaded before "interactive" but not after + //entering "interactive" or "complete". More details: + //http://dev.w3.org/html5/spec/the-end.html#the-end + //http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded + //Hmm, this is more complicated on further use, see "firing too early" + //bug: https://github.com/requirejs/domReady/issues/1 + //so removing the || document.readyState === "interactive" test. + //There is still a window.onload binding that should get fired if + //DOMContentLoaded is missed. + if (document.readyState === "complete") { + pageLoaded(); + } + } + + /** START OF PUBLIC API **/ + + /** + * Registers a callback for DOM ready. If DOM is already ready, the + * callback is called immediately. + * @param {Function} callback + */ + function domReady(callback) { + if (isPageLoaded) { + callback(doc); + } else { + readyCalls.push(callback); + } + return domReady; + } + + domReady.version = '2.0.1'; + + /** + * Loader Plugin API method + */ + domReady.load = function (name, req, onLoad, config) { + if (config.isBuild) { + onLoad(null); + } else { + domReady(onLoad); + } + }; + + /** END OF PUBLIC API **/ + + return domReady; +}); /** * @license RequireJS text 2.0.13+ Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/requirejs/text for details */ +/*jslint regexp: true */ +/*global require, XMLHttpRequest, ActiveXObject, + define, window, process, Packages, + java, location, Components, FileUtils */ + +define('text',['module'], function (module) { + + + var text, fs, Cc, Ci, xpcIsWindows, + progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'], + xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, + bodyRegExp = /]*>\s*([\s\S]+)\s*<\/body>/im, + hasLocation = typeof location !== 'undefined' && location.href, + defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''), + defaultHostName = hasLocation && location.hostname, + defaultPort = hasLocation && (location.port || undefined), + buildMap = {}, + masterConfig = (module.config && module.config()) || {}; + + text = { + version: '2.0.13+', + + strip: function (content) { + //Strips declarations so that external SVG and XML + //documents can be added to a document without worry. Also, if the string + //is an HTML document, only the part inside the body tag is returned. + if (content) { + content = content.replace(xmlRegExp, ""); + var matches = content.match(bodyRegExp); + if (matches) { + content = matches[1]; + } + } else { + content = ""; + } + return content; + }, + + jsEscape: function (content) { + return content.replace(/(['\\])/g, '\\$1') + .replace(/[\f]/g, "\\f") + .replace(/[\b]/g, "\\b") + .replace(/[\n]/g, "\\n") + .replace(/[\t]/g, "\\t") + .replace(/[\r]/g, "\\r") + .replace(/[\u2028]/g, "\\u2028") + .replace(/[\u2029]/g, "\\u2029"); + }, + + createXhr: masterConfig.createXhr || function () { + //Would love to dump the ActiveX crap in here. Need IE 6 to die first. + var xhr, i, progId; + if (typeof XMLHttpRequest !== "undefined") { + return new XMLHttpRequest(); + } else if (typeof ActiveXObject !== "undefined") { + for (i = 0; i < 3; i += 1) { + progId = progIds[i]; + try { + xhr = new ActiveXObject(progId); + } catch (e) {} + + if (xhr) { + progIds = [progId]; // so faster next time + break; + } + } + } + + return xhr; + }, + + /** + * Parses a resource name into its component parts. Resource names + * look like: module/name.ext!strip, where the !strip part is + * optional. + * @param {String} name the resource name + * @returns {Object} with properties "moduleName", "ext" and "strip" + * where strip is a boolean. + */ + parseName: function (name) { + var modName, ext, temp, + strip = false, + index = name.lastIndexOf("."), + isRelative = name.indexOf('./') === 0 || + name.indexOf('../') === 0; + + if (index !== -1 && (!isRelative || index > 1)) { + modName = name.substring(0, index); + ext = name.substring(index + 1); + } else { + modName = name; + } + + temp = ext || modName; + index = temp.indexOf("!"); + if (index !== -1) { + //Pull off the strip arg. + strip = temp.substring(index + 1) === "strip"; + temp = temp.substring(0, index); + if (ext) { + ext = temp; + } else { + modName = temp; + } + } + + return { + moduleName: modName, + ext: ext, + strip: strip + }; + }, + + xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/, + + /** + * Is an URL on another domain. Only works for browser use, returns + * false in non-browser environments. Only used to know if an + * optimized .js version of a text resource should be loaded + * instead. + * @param {String} url + * @returns Boolean + */ + useXhr: function (url, protocol, hostname, port) { + var uProtocol, uHostName, uPort, + match = text.xdRegExp.exec(url); + if (!match) { + return true; + } + uProtocol = match[2]; + uHostName = match[3]; + + uHostName = uHostName.split(':'); + uPort = uHostName[1]; + uHostName = uHostName[0]; + + return (!uProtocol || uProtocol === protocol) && + (!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) && + ((!uPort && !uHostName) || uPort === port); + }, + + finishLoad: function (name, strip, content, onLoad) { + content = strip ? text.strip(content) : content; + if (masterConfig.isBuild) { + buildMap[name] = content; + } + onLoad(content); + }, + + load: function (name, req, onLoad, config) { + //Name has format: some.module.filext!strip + //The strip part is optional. + //if strip is present, then that means only get the string contents + //inside a body tag in an HTML string. For XML/SVG content it means + //removing the declarations so the content can be inserted + //into the current doc without problems. + + // Do not bother with the work if a build and text will + // not be inlined. + if (config && config.isBuild && !config.inlineText) { + onLoad(); + return; + } + + masterConfig.isBuild = config && config.isBuild; + + var parsed = text.parseName(name), + nonStripName = parsed.moduleName + + (parsed.ext ? '.' + parsed.ext : ''), + url = req.toUrl(nonStripName), + useXhr = (masterConfig.useXhr) || + text.useXhr; + + // Do not load if it is an empty: url + if (url.indexOf('empty:') === 0) { + onLoad(); + return; + } + + //Load the text. Use XHR if possible and in a browser. + if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) { + text.get(url, function (content) { + text.finishLoad(name, parsed.strip, content, onLoad); + }, function (err) { + if (onLoad.error) { + onLoad.error(err); + } + }); + } else { + //Need to fetch the resource across domains. Assume + //the resource has been optimized into a JS module. Fetch + //by the module name + extension, but do not include the + //!strip part to avoid file system issues. + req([nonStripName], function (content) { + text.finishLoad(parsed.moduleName + '.' + parsed.ext, + parsed.strip, content, onLoad); + }); + } + }, + + write: function (pluginName, moduleName, write, config) { + if (buildMap.hasOwnProperty(moduleName)) { + var content = text.jsEscape(buildMap[moduleName]); + write.asModule(pluginName + "!" + moduleName, + "define(function () { return '" + + content + + "';});\n"); + } + }, + + writeFile: function (pluginName, moduleName, req, write, config) { + var parsed = text.parseName(moduleName), + extPart = parsed.ext ? '.' + parsed.ext : '', + nonStripName = parsed.moduleName + extPart, + //Use a '.js' file name so that it indicates it is a + //script that can be loaded across domains. + fileName = req.toUrl(parsed.moduleName + extPart) + '.js'; + + //Leverage own load() method to load plugin value, but only + //write out values that do not have the strip argument, + //to avoid any potential issues with ! in file names. + text.load(nonStripName, req, function (value) { + //Use own write() method to construct full module value. + //But need to create shell that translates writeFile's + //write() to the right interface. + var textWrite = function (contents) { + return write(fileName, contents); + }; + textWrite.asModule = function (moduleName, contents) { + return write.asModule(moduleName, fileName, contents); + }; + + text.write(pluginName, nonStripName, textWrite, config); + }, config); + } + }; + + if (masterConfig.env === 'node' || (!masterConfig.env && + typeof process !== "undefined" && + process.versions && + !!process.versions.node && + !process.versions['node-webkit'] && + !process.versions['atom-shell'])) { + //Using special require.nodeRequire, something added by r.js. + fs = require.nodeRequire('fs'); + + text.get = function (url, callback, errback) { + try { + var file = fs.readFileSync(url, 'utf8'); + //Remove BOM (Byte Mark Order) from utf8 files if it is there. + if (file[0] === '\uFEFF') { + file = file.substring(1); + } + callback(file); + } catch (e) { + if (errback) { + errback(e); + } + } + }; + } else if (masterConfig.env === 'xhr' || (!masterConfig.env && + text.createXhr())) { + text.get = function (url, callback, errback, headers) { + var xhr = text.createXhr(), header; + xhr.open('GET', url, true); + + //Allow plugins direct access to xhr headers + if (headers) { + for (header in headers) { + if (headers.hasOwnProperty(header)) { + xhr.setRequestHeader(header.toLowerCase(), headers[header]); + } + } + } + + //Allow overrides specified in config + if (masterConfig.onXhr) { + masterConfig.onXhr(xhr, url); + } + + xhr.onreadystatechange = function (evt) { + var status, err; + //Do not explicitly handle errors, those should be + //visible via console output in the browser. + if (xhr.readyState === 4) { + status = xhr.status || 0; + if (status > 399 && status < 600) { + //An http 4xx or 5xx error. Signal an error. + err = new Error(url + ' HTTP status: ' + status); + err.xhr = xhr; + if (errback) { + errback(err); + } + } else { + callback(xhr.responseText); + } + + if (masterConfig.onXhrComplete) { + masterConfig.onXhrComplete(xhr, url); + } + } + }; + xhr.send(null); + }; + } else if (masterConfig.env === 'rhino' || (!masterConfig.env && + typeof Packages !== 'undefined' && typeof java !== 'undefined')) { + //Why Java, why is this so awkward? + text.get = function (url, callback) { + var stringBuffer, line, + encoding = "utf-8", + file = new java.io.File(url), + lineSeparator = java.lang.System.getProperty("line.separator"), + input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)), + content = ''; + try { + stringBuffer = new java.lang.StringBuffer(); + line = input.readLine(); + + // Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324 + // http://www.unicode.org/faq/utf_bom.html + + // Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK: + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058 + if (line && line.length() && line.charAt(0) === 0xfeff) { + // Eat the BOM, since we've already found the encoding on this file, + // and we plan to concatenating this buffer with others; the BOM should + // only appear at the top of a file. + line = line.substring(1); + } + + if (line !== null) { + stringBuffer.append(line); + } + + while ((line = input.readLine()) !== null) { + stringBuffer.append(lineSeparator); + stringBuffer.append(line); + } + //Make sure we return a JavaScript string and not a Java string. + content = String(stringBuffer.toString()); //String + } finally { + input.close(); + } + callback(content); + }; + } else if (masterConfig.env === 'xpconnect' || (!masterConfig.env && + typeof Components !== 'undefined' && Components.classes && + Components.interfaces)) { + //Avert your gaze! + Cc = Components.classes; + Ci = Components.interfaces; + Components.utils['import']('resource://gre/modules/FileUtils.jsm'); + xpcIsWindows = ('@mozilla.org/windows-registry-key;1' in Cc); + + text.get = function (url, callback) { + var inStream, convertStream, fileObj, + readData = {}; + + if (xpcIsWindows) { + url = url.replace(/\//g, '\\'); + } + + fileObj = new FileUtils.File(url); + + //XPCOM, you so crazy + try { + inStream = Cc['@mozilla.org/network/file-input-stream;1'] + .createInstance(Ci.nsIFileInputStream); + inStream.init(fileObj, 1, 0, false); + + convertStream = Cc['@mozilla.org/intl/converter-input-stream;1'] + .createInstance(Ci.nsIConverterInputStream); + convertStream.init(inStream, "utf-8", inStream.available(), + Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); + + convertStream.readString(inStream.available(), readData); + convertStream.close(); + inStream.close(); + callback(readData.value); + } catch (e) { + throw new Error((fileObj && fileObj.path || '') + ': ' + e); + } + }; + } + return text; +}); + +define('text!tab/avalon.tab.html',[],function () { return '
\r\n \r\n
\r\n \r\n
\r\n \r\n
';}); + + +define('text!tab/avalon.tab.panels.html',[],function () { return '
\r\n
{{panel.content | sanitize | html }}
\r\n
\r\n
\r\n
';}); + + +define('text!tab/avalon.tab.close.html',[],function () { return '\r\n';}); + +define('normalize',[],function() { + + // regular expression for removing double slashes + // eg http://www.example.com//my///url/here -> http://www.example.com/my/url/here + var slashes = /([^:])\/+/g + var removeDoubleSlashes = function(uri) { + return uri.replace(slashes, '$1/'); + } + + // given a relative URI, and two absolute base URIs, convert it from one base to another + var protocolRegEx = /[^\:\/]*:\/\/([^\/])*/; + var absUrlRegEx = /^(\/|data:)/; + function convertURIBase(uri, fromBase, toBase) { + if (uri.match(absUrlRegEx) || uri.match(protocolRegEx)) + return uri; + uri = removeDoubleSlashes(uri); + // if toBase specifies a protocol path, ensure this is the same protocol as fromBase, if not + // use absolute path at fromBase + var toBaseProtocol = toBase.match(protocolRegEx); + var fromBaseProtocol = fromBase.match(protocolRegEx); + if (fromBaseProtocol && (!toBaseProtocol || toBaseProtocol[1] != fromBaseProtocol[1] || toBaseProtocol[2] != fromBaseProtocol[2])) + return absoluteURI(uri, fromBase); + + else { + return relativeURI(absoluteURI(uri, fromBase), toBase); + } + }; + + // given a relative URI, calculate the absolute URI + function absoluteURI(uri, base) { + if (uri.substr(0, 2) == './') + uri = uri.substr(2); + + // absolute urls are left in tact + if (uri.match(absUrlRegEx) || uri.match(protocolRegEx)) + return uri; + + var baseParts = base.split('/'); + var uriParts = uri.split('/'); + + baseParts.pop(); + + while (curPart = uriParts.shift()) + if (curPart == '..') + baseParts.pop(); + else + baseParts.push(curPart); + + return baseParts.join('/'); + }; + + + // given an absolute URI, calculate the relative URI + function relativeURI(uri, base) { + + // reduce base and uri strings to just their difference string + var baseParts = base.split('/'); + baseParts.pop(); + base = baseParts.join('/') + '/'; + i = 0; + while (base.substr(i, 1) == uri.substr(i, 1)) + i++; + while (base.substr(i, 1) != '/') + i--; + base = base.substr(i + 1); + uri = uri.substr(i + 1); + + // each base folder difference is thus a backtrack + baseParts = base.split('/'); + var uriParts = uri.split('/'); + out = ''; + while (baseParts.shift()) + out += '../'; + + // finally add uri parts + while (curPart = uriParts.shift()) + out += curPart + '/'; + + return out.substr(0, out.length - 1); + }; + + var normalizeCSS = function(source, fromBase, toBase) { + + fromBase = removeDoubleSlashes(fromBase); + toBase = removeDoubleSlashes(toBase); + + var urlRegEx = /@import\s*("([^"]*)"|'([^']*)')|url\s*\((?!#)\s*(\s*"([^"]*)"|'([^']*)'|[^\)]*\s*)\s*\)/ig; + var result, url, source; + + while (result = urlRegEx.exec(source)) { + url = result[3] || result[2] || result[5] || result[6] || result[4]; + var newUrl; + newUrl = convertURIBase(url, fromBase, toBase); + var quoteLen = result[5] || result[6] ? 1 : 0; + source = source.substr(0, urlRegEx.lastIndex - url.length - quoteLen - 1) + newUrl + source.substr(urlRegEx.lastIndex - quoteLen - 1); + urlRegEx.lastIndex = urlRegEx.lastIndex + (newUrl.length - url.length); + } + + return source; + }; + + normalizeCSS.convertURIBase = convertURIBase; + normalizeCSS.absoluteURI = absoluteURI; + normalizeCSS.relativeURI = relativeURI; + + return normalizeCSS; +}); +//>>excludeEnd('excludeRequireCss'); +/* + * Require-CSS RequireJS css! loader plugin + * 0.1.8 + * Guy Bedford 2014 + * MIT + */ + +/* + * + * Usage: + * require(['css!./mycssFile']); + * + * Tested and working in (up to latest versions as of March 2013): + * Android + * iOS 6 + * IE 6 - 10 + * Chome 3 - 26 + * Firefox 3.5 - 19 + * Opera 10 - 12 + * + * browserling.com used for virtual testing environment + * + * Credit to B Cavalier & J Hann for the IE 6 - 9 method, + * refined with help from Martin Cermak + * + * Sources that helped along the way: + * - https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent + * - http://www.phpied.com/when-is-a-stylesheet-really-loaded/ + * - https://github.com/cujojs/curl/blob/master/src/curl/plugin/css.js + * + */ + +define('css',[],function() { + if (typeof window == 'undefined') + return { load: function(n, r, load){ load() } }; + + var head = document.getElementsByTagName('head')[0]; + + var engine = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/) || 0; + + // use ",s.setAttribute("ms-skip","1"),s.className="avalonHide";var o=/\[native code\]/,a="$"+n,f=e.require,l=e.define,c,h=!1,p=/[^, ]+/g,d=/^(?:object|array)$/,v=/^\[object SVG\w*Element\]$/,m=/^\[object (?:Window|DOMWindow|global)\]$/,g=Object.prototype,y=g.hasOwnProperty,b=g.toString,w=Array.prototype,E=w.slice,S={},x=e.dispatchEvent,T=r.documentElement,N=r.createDocumentFragment(),C=r.createElement("div"),k={};"Boolean Number String Function Array Date RegExp Object Error".replace(p,function(e){k["[object "+e+"]"]=e.toLowerCase()});var O=function(e){return e=e||"avalon",String(Math.random()+Math.random()).replace(/\d\.\d{4}/,e)},_=M();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 s(){var e=i.length;for(var t=0;t=0;r--)if(this[r]===e)return r;return-1},forEach:$("","_",""),filter:$("r=[],j=0,","if(_)r[j++]=this[i]","return r"),map:$("r=[],","r[i]=_","return r"),some:$("","if(_)return true","return false"),every:$("","if(!_)return false","return true")}),avalon.contains=J,r.contains||(r.contains=function(e){return J(r,e)});if(e.SVGElement){r.createTextNode("x").contains||(Node.prototype.contains=function(e){return!!(this.compareDocumentPosition(e)&16)});var Q="http://www.w3.org/2000/svg",G=r.createElementNS(Q,"svg");G.innerHTML='';if(!v.test(G.firstChild)){function Y(e,t){if(e&&e.childNodes){var n=e.childNodes;for(var i=0,s;s=n[i++];)if(s.tagName){var o=r.createElementNS(Q,s.tagName.toLowerCase());w.forEach.call(s.attributes,function(e){o.setAttribute(e.name,e.value)}),Y(s,o),t.appendChild(o)}}}Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:K,set:function(e){var t=this.tagName.toLowerCase(),n=this.parentNode,i=avalon.parseHTML(e);if(t==="svg")n.insertBefore(i,this);else{var s=r.createDocumentFragment();Y(i,s),n.insertBefore(s,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);Y(t,this)}}}})}}!T.outerHTML&&e.HTMLElement&&HTMLElement.prototype.__defineGetter__("outerHTML",K);var Z=/^(?:mouse|contextmenu|drag)|click/,tt=avalon.eventHooks;"onmouseenter"in T||avalon.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){tt[e]={type:t,deel:function(t,n,r){return function(n){var i=n.relatedTarget;if(!i||i!==t&&!(t.compareDocumentPosition(i)&16))return delete n.type,n.type=e,r.call(t,n)}}}}),avalon.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(t,n){e[t]&&!tt.animationend&&(tt.animationend={type:n})}),"oninput"in r.createElement("input")||(tt.input={type:"propertychange",deel:function(e,t,n){return function(t){if(t.propertyName==="value")return t.type="input",n.call(e,t)}}});if(r.onmousewheel===void 0){var nt=r.onwheel!==void 0?"wheel":"DOMMouseScroll",rt=nt==="wheel"?"deltaY":"detail";tt.mousewheel={type:nt,deel:function(e,t,n){return function(t){t.wheelDeltaY=t.wheelDelta=t[rt]>0?-120:120,t.wheelDeltaX=0,Object.defineProperty&&Object.defineProperty(t,"type",{value:"mousewheel"}),n.call(e,t)}}}}var st,ot,ut,at,ft,lt=/[-.*+?^${}()|[\]\/\\]/g,ht={loader:function(t){var n=c&&t;e.require=n?c:f,e.define=n?c.define:l},interpolate:function(e){st=e[0],ot=e[1];if(st===ot){throw new SyntaxError("openTag!==closeTag");var t}var n=ct(st),r=ct(ot);ut=new RegExp(n+"(.*?)"+r),at=new RegExp(n+"(.*?)"+r,"g"),ft=new RegExp(n+".*?"+r+"|\\sms-")}};it.debug=!0,it.plugins=ht,it.plugins.interpolate(["{{","}}"]),it.paths={},it.shim={},it.maxRepeatSize=100,avalon.config=it;var pt=/(\w+)\[(avalonctrl)="(\S+)"\]/,dt=r.querySelectorAll?function(e){return r.querySelectorAll(e)}:function(e){var t=e.match(pt),n=r.getElementsByTagName(t[1]),i=[];for(var s=0,o;o=n[s++];)o.getAttribute(t[2])===t[3]&&i.push(o);return i},vt={$watch:function(e,t){if(typeof t=="function"){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(n===0)this.$watch.backup=this.$events,this.$events={};else if(n===1)this.$events[e]=[];else{var r=this.$events[e]||[],i=r.length;while(~--i<0)if(r[i]===t)return r.splice(i,1)}return this},$fire:function(e){var t,n,i,s;/^(\w+)!(\S+)$/.test(e)&&(t=RegExp.$1,e=RegExp.$2);var o=this.$events;if(!o)return;var u=E.call(arguments,1),a=[e].concat(u);if(t==="all")for(n in avalon.vmodels)i=avalon.vmodels[n],i!==this&&i.$fire.apply(i,a);else if(t==="up"||t==="down"){var f=o.expr?dt(o.expr):[];if(f.length===0)return;for(n in avalon.vmodels){i=avalon.vmodels[n];if(i!==this&&i.$events.expr){var l=dt(i.$events.expr);if(l.length===0)continue;w.forEach.call(l,function(e){w.forEach.call(f,function(n){var r=t==="down"?n.contains(e):e.contains(n);r&&(e._avalon=i)})})}}var c=r.getElementsByTagName("*"),h=[];w.forEach.call(c,function(e){e._avalon&&(h.push(e._avalon),e._avalon="",e.removeAttribute("_avalon"))}),t==="up"&&h.reverse();for(n=0;s=h[n++];)if(s.$fire.apply(s,a)===!1)break}else{var p=o[e]||[],d=o.$all||[];for(n=0;s=p[n++];)D(s)&&s.apply(this,u);for(n=0;s=d[n++];)D(s)&&s.apply(this,arguments)}}},mt=avalon.vmodels={};avalon.define=function(e,t){var n=e.$id||e;n||u("warning: vm必须指定$id"),mt[n]&&u("warning: "+n+" 已经存在于avalon.vmodels中");if(typeof e=="object")var r=St(e);else{var i={$watch:L};t(i),r=St(i),h=!0,t(r),h=!1}return r.$id=n,mt[n]=r};var gt=String("$id,$watch,$unwatch,$fire,$events,$model,$skipArray,$proxy,$reinitialize,$propertyNames").match(p),yt=Object.defineProperty,bt=!0;try{yt({},"_",{value:"x"});var wt=Object.defineProperties}catch(Et){bt=!1}var xt={value:function(e){return e in this.$model},writable:!1,enumerable:!1,configurable:!0},Ot=Object.is||function(e,t){return e===0&&t===0?1/e===1/t:e!==e?t!==t:e===t},_t=x?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(!bt){"__defineGetter__"in avalon&&(yt=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},wt=function(e,t){for(var n in t)t.hasOwnProperty(n)&&yt(e,n,t[n]);return e});if(_){var Dt={};e.execScript(["Function parseVB(code)"," ExecuteGlobal(code)","End Function"].join("\n"),"VBScript");function Pt(e,t,n,r){var i=t[n];if(arguments.length!==4)return i.call(e);i.call(e,r)}wt=function(t,r,i){var s=[];s.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 i)r.hasOwnProperty(t)||s.push(" Public ["+t+"]");gt.forEach(function(e){r.hasOwnProperty(e)||s.push(" Public ["+e+"]")}),s.push(" Public [hasOwnProperty]");for(t in r)s.push(" Public Property Let ["+t+"](val"+n+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+n+")"," End Property"," Public Property Set ["+t+"](val"+n+")",' Call [__proxy__](Me,[__data__], "'+t+'", val'+n+")"," 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");s.push("End Class");var o=s.join("\r\n"),u=Dt[o];u||(u=O("VBClass"),e.parseVB("Class "+u+o),e.parseVB(["Function "+u+"Factory(a, b)"," Dim o"," Set o = (New "+u+")(a, b)"," Set "+u+"Factory = o","End Function"].join("\r\n")),Dt[o]=u);var a=e[u+"Factory"](r,Pt);return a}}}var jt=w.splice,Ft={_splice:jt,_fire:function(e,t,n){Wt(this.$events[a],e,t,n)},size:function(){return this._.length},pushArray:function(e){var t=e.length,n=this.length;return t&&(w.push.apply(this.$model,e),Bt.call(this,"add",n,t,Math.max(0,n-1))),t+n},push:function(){var e=[],t,n=arguments.length;for(t=0;t2&&(r?n.splice(3,1,0,"add",e,t-2):n.push("add",e,t-2,0),r=!0),r?Bt.apply(this,n):[]},contains:function(e){return this.indexOf(e)!==-1},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>=0?(this.$model.splice(e,1),Bt.call(this,"del",e,1,0)):[]},clear:function(){return this.$model.length=this.length=this._.length=0,this._fire("clear",0),this},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)e.indexOf(this[t])!==-1&&this.removeAt(t);else if(typeof e=="function")for(t=this.length-1;t>=0;t--){var n=this[t];e(n,t)&&this.removeAt(t)}else this.clear()},ensure:function(e){return this.contains(e)||this.push(e),this},set:function(e,t){if(e>=0){var n=avalon.type(t);t&&t.$model&&(t=t.$model);var r=this[e];if(n==="object")for(var i in t)r.hasOwnProperty(i)&&(r[i]=t[i]);else n==="array"?r.clear().push.apply(r,t):r!==t&&(this[e]=t,this.$model[e]=t,this._fire("set",e,t))}return this}};"sort,reverse".replace(p,function(e){Ft[e]=function(){var t=this.$model,n=t.concat(),r=Math.random(),i=[],s;w[e].apply(t,arguments);for(var o=0,u=n.length;o",""],param:[1,"",""],col:[2,"","
"],legend:[1,"
","
"],option:[1,""],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],g:[1,'',""],_default:x?[0,"",""]:[1,"X
","
"]};nn.th=nn.td,nn.optgroup=nn.option,nn.tbody=nn.tfoot=nn.colgroup=nn.caption=nn.thead,String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(p,function(e){nn[e]=nn.g});var rn=/<([\w:]+)/,sn=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,on=x?/[^\d\D]/:/(<(?:script|link|style|meta|noscript))/ig,un=A(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),an=/<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,fn=r.createElement("script"),ln=/<|&#?\w+;/;avalon.parseHTML=function(e){var t=N.cloneNode(!1);if(typeof e!="string")return t;if(!ln.test(e))return t.appendChild(r.createTextNode(e)),t;e=e.replace(sn,"<$1>").trim();var n=(rn.exec(e)||["",""])[1].toLowerCase(),i=nn[n]||nn._default,s=C,o,u;x||(e=e.replace(on,"
$1")),s.innerHTML=i[1]+e+i[2];var a=s.getElementsByTagName("script");if(a.length)for(var f=0,l;l=a[f++];)un[l.type]&&(u=fn.cloneNode(!1),w.forEach.call(l.attributes,function(e){e&&e.specified&&(u[e.name]=e.value,u.setAttribute(e.name,e.value))}),u.text=l.text,l.parentNode.replaceChild(u,l));if(!x){var c=i[1]==="X
"?s.lastChild.firstChild:s.lastChild;if(c&&c.tagName==="TABLE"&&n!=="tbody")for(a=c.childNodes,f=0;l=a[f++];)if(l.tagName==="TBODY"&&!l.innerHTML){c.removeChild(l);break}a=s.getElementsByTagName("br");var h=a.length;while(l=a[--h])l.className==="msNoScope"&&l.parentNode.removeChild(l);for(a=s.all,f=0;l=a[f++];)cn(l)&&hn(l)}for(f=i[0];f--;s=s.lastChild);while(o=s.firstChild)t.appendChild(o);return t},avalon.innerHTML=function(e,t){if(!x&&!on.test(t)&&!an.test(t))try{e.innerHTML=t;return}catch(n){}var r=this.parseHTML(t);this.clearHTML(e).appendChild(r)},avalon.clearHTML=function(e){e.textContent="";while(e.firstChild)e.removeChild(e.firstChild);return e};var vn={_toString:function(){var e=this.node,t=e.className,n=typeof t=="string"?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;v.test(t)?t.setAttribute("class",e):t.className=e}};"add,remove".replace(p,function(e){avalon.fn[e+"Class"]=function(t){var n=this[0];return t&&typeof t=="string"&&n&&n.nodeType===1&&t.replace(/\S+/g,function(t){mn(n)[e](t)}),this}}),avalon.fn.mix({hasClass:function(e){var t=this[0]||{};return t.nodeType===1&&mn(t).contains(e)},toggleClass:function(e,t){var n,r=0,i=String(e).split(/\s+/),s=typeof t=="boolean";while(n=i[r++]){var o=s?t:!this.hasClass(n);this[o?"addClass":"removeClass"](n)}return this},attr:function(e,t){return arguments.length===2?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){e="data-"+pn(e||"");switch(arguments.length){case 2:return this.attr(e,t),this;case 1:var n=this.attr(e);return gn(n);case 0:var r={};return w.forEach.call(this[0].attributes,function(t){t&&(e=t.name,e.indexOf("data-")||(e=dn(e.slice(5)),r[e]=gn(t.value)))}),r}},removeData:function(e){return e="data-"+pn(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 r!==void 0?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(!n)return;return this.css("position")==="fixed"?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),e[0].tagName!=="HTML"&&(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(){var e=this[0].offsetParent;while(e&&avalon.css(e,"position")==="static")e=e.offsetParent;return avalon(e||T)},bind:function(e,t,n){if(this[0])return avalon.bind(this[0],e,t,n)},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&&t.nodeType===1){var n=arguments.length===0,r=n?":get":":set",i=Fn[Bn(t)+r];if(i)var s=i(t,e);else{if(n)return(t.value||"").replace(/\r/g,"");t.value=e}}return n?s:this}});var yn=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,bn=/^[\],:{}\s]*$/,wn=/(?:^|:|,)(?:\s*\[)+/g,En=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,Sn=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g;avalon.parseJSON=e.JSON?JSON.parse:function(e){if(typeof e=="string"){e=e.trim();if(e&&bn.test(e.replace(En,"@").replace(Sn,"]").replace(wn,"")))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]||{},i=xn(r),s=e==="scrollTop";if(!arguments.length)return i?t in i?i[t]:T[e]:r[e];i?i.scrollTo(s?avalon(i).scrollLeft():n,s?n:avalon(i).scrollTop()):r[e]=n}});var Tn=avalon.cssHooks={},Nn=["","-webkit-","-o-","-moz-","-ms-"],Cn={"float":x?"cssFloat":"styleFloat"};avalon.cssNumber=A("columnCount,order,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),avalon.cssName=function(e,t,n){if(Cn[e])return Cn[e];t=t||T.style;for(var r=0,i=Nn.length;r]+))?)*\s+value[\s=]/i,Fn={"option:get":_?function(e){return jn.test(e.outerHTML)?e.value:e.text.trim()}:function(e){return e.value},"select:get":function(e,t){var n,r=e.options,i=e.selectedIndex,s=Fn["option:get"],o=e.type==="select-one"||i<0,u=o?null:[],a=o?i+1:r.length,f=i<0?a:o?i:0;for(;f-1)n=!0;n||(e.selectedIndex=-1)}},In={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},qn=e.JSON&&JSON.stringify||function(e){return'"'+e.replace(/[\\\"\x00-\x1f]/g,function(e){var t=In[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'},Rn=["break,case,catch,continue,debugger,default,delete,do,else,false","finally,for,function,if,in,instanceof,new,null,return,switch,this","throw,true,try,typeof,var,void,while,with","abstract,boolean,byte,char,class,const,double,enum,export,extends","final,float,goto,implements,import,int,interface,long,native","package,private,protected,public,short,static,super,synchronized","throws,transient,volatile","arguments,let,yield,undefined"].join(","),Un=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|[\s\t\n]*\.[\s\t\n]*[$\w\.]+/g,zn=/[^\w$]+/g,Wn=new RegExp(["\\b"+Rn.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),Xn=/\b\d[^,]*/g,Vn=/^,+|,+$/g,$n=new R(512),Jn=function(e){var t=","+e.trim(),n=$n.get(t);if(n)return n;var r=e.replace(Un,"").replace(zn,",").replace(Wn,"").replace(Xn,"").replace(Vn,"").split(/^$|,+/);return $n.put(t,Qn(r))},Gn=new R(128),Yn=/\w\[.*\]|\w\.\w/,Zn=/(\$proxy\$[a-z]+)\d+$/,er=/\)\s*$/,tr=/\)\s*\|/g,nr=/\|\s*([$\w]+)/g,rr=/"\s*\["/g,ir=/"\s*\(/g;avalon.parseExprProxy=ur,avalon.scan=function(e,t){e=e||T;var n=t?[].concat(t):[];Mr(e,n)};var ar=A("area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea".toUpperCase()),cr=function(e,t,n){var r=e.getAttribute(t);if(r)for(var i=0,s;s=n[i++];)if(s.hasOwnProperty(r)&&typeof s[r]=="function")return s[r]},pr=_&&e.MutationObserver?function(e){var t=e.firstChild,n;while(t){var r=t.nextSibling;t.nodeType===3?n?(n.nodeValue+=t.nodeValue,e.removeChild(t)):n=t:n=null,t=r}}:0,dr=/^\s*::/,vr=/ms-(\w+)-?(.*)/,mr={"if":10,repeat:90,data:100,widget:110,each:1400,"with":1500,duplex:2e3,on:3e3},gr=A("animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit"),yr=A("value,title,alt,checked,selected,disabled,readonly,enabled"),Er=/^if|widget|repeat$/,Sr=/^each|with|html|include$/;if(!"1"[0])var xr=new R(512),Tr=/\s+(ms-[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,Nr=/^['"]/,Cr=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/i,kr=/&/g,Lr=function(e){var t=e.outerHTML;if(t.slice(0,2)==="(?:[\s\S]+?)<\/noscript>/img,Xr=/([\s\S]+?)<\/noscript>/im,Vr=function(){return new(e.XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP")},$r=avalon.templateCache={};F.attr=function(e,t){var n=e.value.trim(),i=!0;n.indexOf(st)>-1&&n.indexOf(ot)>2&&(i=!1,ut.test(n)&&RegExp.rightContext===""&&RegExp.leftContext===""&&(i=!0,n=RegExp.$1));if(e.type==="include"){var s=e.element;e.includeRendered=cr(s,"data-include-rendered",t),e.includeLoaded=cr(s,"data-include-loaded",t);var o=e.includeReplace=!!avalon(s).data("includeReplace");avalon(s).data("includeCache")&&(e.templateCache={}),e.startInclude=r.createComment("ms-include"),e.endInclude=r.createComment("ms-include-end"),o?(e.element=e.startInclude,s.parentNode.insertBefore(e.startInclude,s),s.parentNode.insertBefore(e.endInclude,s.nextSibling)):(s.insertBefore(e.startInclude,s.firstChild),s.appendChild(e.endInclude))}e.handlerName="attr",ur(n,t,e,i?0:Fr(e.value))},I.attr=function(t,n,i){var o=i.type,u=i.param;if(o==="css")avalon(n).css(u,t);else if(o==="attr"){var a=t===!1||t===null||t===void 0;!x&&Ur[u]&&(u=Ur[u]);var f=Rr[u];typeof n[f]=="boolean"&&(n[f]=!!t,t||(a=!0));if(a)return n.removeAttribute(u);var l=v.test(n)?!1:r.namespaces&&cn(n)?!0:u in n.cloneNode(!1);l?n[u]=t+"":n.setAttribute(u,t)}else if(o==="include"&&t){var c=i.vmodels,h=i.includeRendered,p=i.includeLoaded,d=i.includeReplace,m=d?n.parentNode:n,g=function(e){if(p){var n=p.apply(m,[e].concat(c));typeof n=="string"&&(e=n)}h&&fr(m,function(){h.call(m)},NaN);var o=i.includeLastID;if(i.templateCache&&o&&o!==t){var u=i.templateCache[o];u||(u=i.templateCache[o]=r.createElement("div"),s.appendChild(u))}i.includeLastID=t;for(;;){var a=i.startInclude.nextSibling;if(!a||a===i.endInclude)break;m.removeChild(a),u&&u.appendChild(a)}var f=Jr(i,t,e),l=avalon.slice(f.childNodes);m.insertBefore(f,i.endInclude),Or(l,c)};if(i.param==="src")if(typeof $r[t]=="string")avalon.nextTick(function(){g($r[t])});else if(Array.isArray($r[t]))$r[t].push(g);else{var y=Vr();y.onreadystatechange=function(){if(y.readyState===4){var e=y.status;if(e>=200&&e<300||e===304||e===1223){var n=y.responseText;for(var r=0,i;i=$r[t][r++];)i(n);$r[t]=n}}},$r[t]=[g],y.open("GET",t,!0),"withCredentials"in y&&(y.withCredentials=!0),y.setRequestHeader("X-Requested-With","XMLHttpRequest"),y.send(null)}else{var b=t&&t.nodeType===1?t:r.getElementById(t);if(b){if(b.tagName==="NOSCRIPT"&&!b.innerHTML&&!b.fixIE78){y=Vr(),y.open("GET",location,!1),y.send(null);var w=r.getElementsByTagName("noscript"),E=(y.responseText||"").match(Wr)||[],S=E.length;for(var N=0;N-1},i(x?"change":"click",c);else{var d=e.getAttribute("data-duplex-event")||"input";e.attributes["data-event"]&&u("data-event指令已经废弃,请改用data-duplex-event");function v(e){setTimeout(function(){c(e)})}d.replace(p,function(e){switch(e){case"input":_?(_>8?i("input",c):i("propertychange",function(e){e.propertyName==="value"&&c()}),i("dragend",v)):(i("input",c),i("compositionstart",f),i("compositionend",l),i("DOMAutoComplete",c));break;default:i(e,c)}}),i("focus",function(){e.msFocus=!0}),i("blur",function(){e.msFocus=!1}),ni.test(r)&&ti(function(){if(T.contains(e))!e.msFocus&&e.oldValue!==e.value&&c();else if(!e.msRetain)return!1}),e.avalonSetter=c}e.oldValue=e.value,avalon.injectBinding(n),a.call(e,e.value)},Kr.TEXTAREA=Kr.INPUT,Kr.SELECT=function(e,t,n){function i(){if(r.data("duplexObserve")!==!1){var i=r.val();Array.isArray(i)?i=i.map(function(e){return n.pipe(e,n,"get")}):i=n.pipe(i,n,"get"),i+""!==e.oldValue&&t(i),n.changed.call(e,i,n)}}var r=avalon(e);n.handler=function(){var n=t();n=n&&n.$model||n,Array.isArray(n)?e.multiple||u("ms-duplex在不能对应一个数组"),n=Array.isArray(n)?n.map(String):n+"",n+""!==e.oldValue&&(r.val(n),e.oldValue=n+"")},n.bound("change",i),e.msCallback=function(){avalon.injectBinding(n),n.changed.call(e,t(),n)}},I.html=function(e,t,n){var i=t.nodeType!==1,s=i?t.parentNode:t;if(!s)return;e=e==null?"":e;if(n.oldText===e)return;n.oldText=e;if(t.nodeType===3){var o=O("html");s.insertBefore(r.createComment(o),t),n.element=r.createComment(o+":end"),s.replaceChild(n.element,t),t=n.element}if(typeof e!="object")var u=avalon.parseHTML(String(e));else if(e.nodeType===11)u=e;else if(e.nodeType===1||e.item){var a=e.nodeType===1?e.childNodes:e.item;u=N.cloneNode(!0);while(a[0])u.appendChild(a[0])}a=avalon.slice(u.childNodes);if(i){var f=t.nodeValue.slice(0,-4);for(;;){var l=t.previousSibling;if(!l||l.nodeType===8&&l.nodeValue===f)break;s.removeChild(l)}s.insertBefore(u,t)}else avalon.clearHTML(t).appendChild(u);Or(a,n.vmodels)},F["if"]=F.data=F.text=F.html=function(e,t){ur(e.value,t,e)},I["if"]=function(e,t,n){try{if(!t.parentNode)return}catch(i){return}if(e)t.nodeType===8&&(t.parentNode.replaceChild(n.template,t),t=n.element=n.template),t.getAttribute(n.name)&&(t.removeAttribute(n.name),wr(t,n.vmodels)),n.rollback=null;else if(t.nodeType===1){var o=n.element=r.createComment("ms-if");t.parentNode.replaceChild(o,t),n.template=t,s.appendChild(t),n.rollback=function(){t.parentNode===s&&s.removeChild(t)}}};var ri=/\(([^)]*)\)/;F.on=function(e,t){var n=e.value;e.type="on";var r=e.param.replace(/-\d+$/,"");typeof F.on[r+"Hook"]=="function"&&F.on[r+"Hook"](e);if(n.indexOf("(")>0&&n.indexOf(")")>-1){var i=(n.match(ri)||["",""])[1].trim();if(i===""||i==="$event")n=n.replace(ri,"")}ur(n,t,e)},I.on=function(e,t,n){e=function(e){var t=n.evaluator||L;return t.apply(this,n.args.concat(e))};var r=n.param.replace(/-\d+$/,"");if(r==="scan")e.call(t,{type:r});else if(typeof n.specialBind=="function")n.specialBind(t,e);else var i=avalon.bind(t,r,e);n.rollback=function(){typeof n.specialUnbind=="function"?n.specialUnbind():avalon.unbind(t,r,i)}},F.repeat=function(e,t){var n=e.type;ur(e.value,t,e,0,1),e.proxies=[];var i=!1;try{var s=e.$repeat=e.evaluator.apply(0,e.args||[]),o=avalon.type(s);o!=="object"&&o!=="array"&&(i=!0,avalon.log("warning:"+e.value+"只能是对象或数组"))}catch(u){i=!0}var f=e.value.split(".")||[];if(f.length>1){f.pop();var l=f[0];for(var c=0,h;h=t[c++];)if(h&&h.hasOwnProperty(l)){var p=h[l].$events||{};p[a]=p[a]||[],p[a].push(e);break}}var d=e.element;if(d.nodeType===1){d.removeAttribute(e.name),e.sortedCallback=cr(d,"data-with-sorted",t),e.renderedCallback=cr(d,"data-"+n+"-rendered",t);var v=O(n),m=r.createComment(v),g=r.createComment(v+":end");e.signature=v,e.template=N.cloneNode(!1);if(n==="repeat"){var y=d.parentNode;y.replaceChild(g,d),y.insertBefore(m,g),e.template.appendChild(d)}else{while(d.firstChild)e.template.appendChild(d.firstChild);d.appendChild(m),d.appendChild(g)}e.element=g,e.handler=I.repeat,e.rollback=function(){var t=e.element;if(!t)return;e.handler("clear")}}if(i)return;e.$outer={};var b="$key",w="$val";Array.isArray(s)&&(b="$first",w="$last");for(c=0;h=t[c++];)if(h.hasOwnProperty(b)&&h.hasOwnProperty(w)){e.$outer=h;break}var E=s.$events,S=(E||{})[a];zt(S,e),o==="object"?(e.$with=!0,s.$proxy||(s.$proxy={}),e.handler("append",s)):s.length&&e.handler("add",0,s.length)},I.repeat=function(e,t,n){if(e){var r=this,i,s,o=r.element,u=si(r),a=o.parentNode,f=r.proxies,l=N.cloneNode(!1);switch(e){case"add":var c=t+n,h=[];for(var p=t;p]*>([\S\s]*?)<\/script\s*>/gim,bi=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,wi=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/ig,Ei={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/ig,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/ig,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/ig},Si=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,xi=/([^\#-~| |!])/g,Ni=avalon.filters={uppercase:function(e){return e.toUpperCase()},lowercase:function(e){return e.toLowerCase()},truncate:function(e,t,n){return t=t||30,n=typeof n=="string"?n:"...",e.length>t?e.slice(0,t-n.length)+n:String(e)},$filter:function(e){for(var t=1,n=arguments.length;t/g,">")},currency:function(e,t,n){return(t||"¥")+Ti(e,isFinite(n)?n:2)},number:Ti};new function(){function e(e){return parseInt(e,10)||0}function t(e,t,n){var r="";e<0&&(r="-",e=-e),e=""+e;while(e.length0||o>-r)o+=r;return o===0&&r===-12&&(o=12),t(o,n,i)}}function r(e,t){return function(n,r){var i=n["get"+e](),s=(t?"SHORT"+e:e).toUpperCase();return r[s][i]}}function i(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),r}function s(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:s,Z:i},u=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,a=/^\/Date\((\d+)\)\/$/;Ni.date=function(t,n){var r=Ni.date.locate,i="",s=[],f,l;n=n||"mediumDate",n=r[n]||n;if(typeof t=="string")if(/^\d+$/.test(t))t=e(t);else if(a.test(t))t=+RegExp.$1;else{var c=t.trim(),h=[0,0,0,0,0,0,0],p=new Date(0);c=c.replace(/^(\d+)\D(\d+)\D(\d+)/,function(t,n,r,i){var s=i.length===4?[i,n,r]:[n,r,i];return h[0]=e(s[0]),h[1]=e(s[1])-1,h[2]=e(s[2]),""});var d=p.setFullYear,v=p.setHours;c=c.replace(/[T\s](\d+):(\d+):?(\d+)?\.?(\d)?/,function(t,n,r,i,s){return h[3]=e(n),h[4]=e(r),h[5]=e(i),s&&(h[6]=Math.round(parseFloat("0."+s)*1e3)),""});var m=0,g=0;c=c.replace(/Z|([+-])(\d\d):?(\d\d)/,function(t,n,r,i){return d=p.setUTCFullYear,v=p.setUTCHours,n&&(m=e(n+r),g=e(n+i)),""}),h[3]-=m,h[4]-=g,d.apply(p,h.slice(0,3)),v.apply(p,h.slice(3)),t=p}typeof t=="number"&&(t=new Date(t));if(avalon.type(t)!=="date")return;while(n)l=u.exec(n),l?(s=s.concat(l.slice(1)),n=s.pop()):(s.push(n),n=null);return s.forEach(function(e){f=o[e],i+=f?f(t,r):e.replace(/(^'|'$)/g,"").replace(/''/g,"'")}),i};var f={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"};f.SHORTMONTH=f.MONTH,Ni.date.locate=f},new function(){function i(n){t=1;while(n=e.shift())n()}avalon.config({loader:!1});var e=[],t=r.readyState==="complete",n;avalon.bind(r,"DOMContentLoaded",n=function(){avalon.unbind(r,"DOMContentLoaded",n),i()});var s=setInterval(function(){document.readyState==="complete"&&document.body&&(clearInterval(s),i())},50);avalon.ready=function(n){t?n(avalon):e.push(n)},avalon.ready(function(){avalon.scan(r.body)})},typeof define=="function"&&define.amd&&define("avalon",[],function(){return avalon});var Ci=e.avalon;return avalon.noConflict=function(t){return t&&e.avalon===avalon&&(e.avalon=Ci),avalon},t===void 0&&(e.avalon=avalon),avalon}),define("domReady",[],function(){function u(e){var t;for(t=0;t/im,a=/]*>\s*([\s\S]+)\s*<\/body>/im,f=typeof location!="undefined"&&location.href,l=f&&location.protocol&&location.protocol.replace(/\:/,""),c=f&&location.hostname,h=f&&(location.port||undefined),p={},d=e.config&&e.config()||{};t={version:"2.0.13+",strip:function(e){if(e){e=e.replace(u,"");var t=e.match(a);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:d.createXhr||function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(t=0;t<3;t+=1){n=o[t];try{e=new ActiveXObject(n)}catch(r){}if(e){o=[n];break}}return e},parseName:function(e){var t,n,r,i=!1,s=e.lastIndexOf("."),o=e.indexOf("./")===0||e.indexOf("../")===0;return s!==-1&&(!o||s>1)?(t=e.substring(0,s),n=e.substring(s+1)):t=e,r=n||t,s=r.indexOf("!"),s!==-1&&(i=r.substring(s+1)==="strip",r=r.substring(0,s),n?n=r:t=r),{moduleName:t,ext:n,strip:i}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,r,i){var s,o,u,a=t.xdRegExp.exec(e);return a?(s=a[2],o=a[3],o=o.split(":"),u=o[1],o=o[0],(!s||s===n)&&(!o||o.toLowerCase()===r.toLowerCase())&&(!u&&!o||u===i)):!0},finishLoad:function(e,n,r,i){r=n?t.strip(r):r,d.isBuild&&(p[e]=r),i(r)},load:function(e,n,r,i){if(i&&i.isBuild&&!i.inlineText){r();return}d.isBuild=i&&i.isBuild;var s=t.parseName(e),o=s.moduleName+(s.ext?"."+s.ext:""),u=n.toUrl(o),a=d.useXhr||t.useXhr;if(u.indexOf("empty:")===0){r();return}!f||a(u,l,c,h)?t.get(u,function(n){t.finishLoad(e,s.strip,n,r)},function(e){r.error&&r.error(e)}):n([o],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,r)})},write:function(e,n,r,i){if(p.hasOwnProperty(n)){var s=t.jsEscape(p[n]);r.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,r,i,s){var o=t.parseName(n),u=o.ext?"."+o.ext:"",a=o.moduleName+u,f=r.toUrl(o.moduleName+u)+".js";t.load(a,r,function(n){var r=function(e){return i(f,e)};r.asModule=function(e,t){return i.asModule(e,f,t)},t.write(e,a,r,s)},s)}};if(d.env==="node"||!d.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node&&!process.versions["node-webkit"]&&!process.versions["atom-shell"])n=require.nodeRequire("fs"),t.get=function(e,t,r){try{var i=n.readFileSync(e,"utf8");i[0]===""&&(i=i.substring(1)),t(i)}catch(s){r&&r(s)}};else if(d.env==="xhr"||!d.env&&t.createXhr())t.get=function(e,n,r,i){var s=t.createXhr(),o;s.open("GET",e,!0);if(i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);d.onXhr&&d.onXhr(s,e),s.onreadystatechange=function(t){var i,o;s.readyState===4&&(i=s.status||0,i>399&&i<600?(o=new Error(e+" HTTP status: "+i),o.xhr=s,r&&r(o)):n(s.responseText),d.onXhrComplete&&d.onXhrComplete(s,e))},s.send(null)};else if(d.env==="rhino"||!d.env&&typeof Packages!="undefined"&&typeof java!="undefined")t.get=function(e,t){var n,r,i="utf-8",s=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),u=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),i)),a="";try{n=new java.lang.StringBuffer,r=u.readLine(),r&&r.length()&&r.charAt(0)===65279&&(r=r.substring(1)),r!==null&&n.append(r);while((r=u.readLine())!==null)n.append(o),n.append(r);a=String(n.toString())}finally{u.close()}t(a)};else if(d.env==="xpconnect"||!d.env&&typeof Components!="undefined"&&Components.classes&&Components.interfaces)r=Components.classes,i=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),s="@mozilla.org/windows-registry-key;1"in r,t.get=function(e,t){var n,o,u,a={};s&&(e=e.replace(/\//g,"\\")),u=new FileUtils.File(e);try{n=r["@mozilla.org/network/file-input-stream;1"].createInstance(i.nsIFileInputStream),n.init(u,1,0,!1),o=r["@mozilla.org/intl/converter-input-stream;1"].createInstance(i.nsIConverterInputStream),o.init(n,"utf-8",n.available(),i.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),o.readString(n.available(),a),o.close(),n.close(),t(a.value)}catch(f){throw new Error((u&&u.path||"")+": "+f)}};return t}),define("text!tab/avalon.tab.html",[],function(){return'
\r\n \r\n
\r\n \r\n
\r\n \r\n
'}),define("text!tab/avalon.tab.panels.html",[],function(){return'
\r\n
{{panel.content | sanitize | html }}
\r\n
\r\n
\r\n
'}),define("text!tab/avalon.tab.close.html",[],function(){return'\r\n'}),define("normalize",[],function(){function s(e,i,s){if(e.match(r)||e.match(n))return e;e=t(e);var a=s.match(n),f=i.match(n);return f&&(!a||a[1]!=f[1]||a[2]!=f[2])?o(e,i):u(o(e,i),s)}function o(e,t){e.substr(0,2)=="./"&&(e=e.substr(2));if(e.match(r)||e.match(n))return e;var i=t.split("/"),s=e.split("/");i.pop();while(curPart=s.shift())curPart==".."?i.pop():i.push(curPart);return i.join("/")}function u(e,t){var n=t.split("/");n.pop(),t=n.join("/")+"/",i=0;while(t.substr(i,1)==e.substr(i,1))i++;while(t.substr(i,1)!="/")i--;t=t.substr(i+1),e=e.substr(i+1),n=t.split("/");var r=e.split("/");out="";while(n.shift())out+="../";while(curPart=r.shift())out+=curPart+"/";return out.substr(0,out.length-1)}var e=/([^:])\/+/g,t=function(t){return t.replace(e,"$1/")},n=/[^\:\/]*:\/\/([^\/])*/,r=/^(\/|data:)/,a=function(e,n,r){n=t(n),r=t(r);var i=/@import\s*("([^"]*)"|'([^']*)')|url\s*\((?!#)\s*(\s*"([^"]*)"|'([^']*)'|[^\)]*\s*)\s*\)/ig,o,u,e;while(o=i.exec(e)){u=o[3]||o[2]||o[5]||o[6]||o[4];var a;a=s(u,n,r);var f=o[5]||o[6]?1:0;e=e.substr(0,i.lastIndex-u.length-f-1)+a+e.substr(i.lastIndex-f-1),i.lastIndex=i.lastIndex+(a.length-u.length)}return e};return a.convertURIBase=s,a.absoluteURI=o,a.relativeURI=u,a}),define("css",[],function(){if(typeof window=="undefined")return{load:function(e,t,n){n()}};var e=document.getElementsByTagName("head")[0],t=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/)||0,n=!1,r=!0;t[1]||t[7]?n=parseInt(t[1])<6||parseInt(t[7])<=9:t[2]||t[8]?r=!1:t[4]&&(n=parseInt(t[4])<18);var i={};i.pluginBuilder="./css-builder";var s,o,u=function(){s=document.createElement("style"),e.appendChild(s),o=s.styleSheet||s.sheet},a=0,f=[],l,c=function(e){a++,a==32&&(u(),a=0),o.addImport(e),s.onload=function(){h()}},h=function(){l();var e=f.shift();if(!e){l=null;return}l=e[1],c(e[0])},p=function(e,t){(!o||!o.addImport)&&u();if(o&&o.addImport)l?f.push([e,t]):(c(e),l=t);else{s.textContent='@import "'+e+'";';var n=setInterval(function(){try{s.sheet.cssRules,clearInterval(n),t()}catch(e){}},10)}},d=function(t,n){var i=document.createElement("link");i.type="text/css",i.rel="stylesheet";if(r)i.onload=function(){i.onload=function(){},setTimeout(n,7)};else var s=setInterval(function(){for(var e=0;e=n.tabs.length&&n.tabs.length-1||n.active<0&&0||parseInt(n.active)>>0,e(t).addClass("oni-tab oni-widget oni-widget-content"+(n.event=="click"?" oni-tab-click":"")+(n.dir=="v"?" oni-tab-vertical":"")+(n.dir!="v"&&n.uiSize=="small"?" oni-tab-small":""));var h=i(n._getTemplate(0,n),n),p=i(n._getTemplate("panel",n),n);t.innerHTML=c.bottom?p+h:h+p,f?f():(e.log("avalon请尽快升到1.3.7+"),e.scan(t,[c].concat(r)),typeof o.onInit=="function"&&o.onInit.call(t,c,o,r)),n.autoSwitch&&n._autoSwitch()},n._clearTimeout=function(){clearTimeout(f)},n.activate=function(e,t,r){if(n.tabs[t].disabled===!0){n.event==="click"&&e.preventDefault();return}if(n.tabs[t].linkOnly)return;var i=this;if(n.event==="click"&&n.active===t){n.collapsible?(n.active=NaN,e.preventDefault()):o.onClickActive.call(i,e,c)||e.preventDefault();return}n.event==="click"&&e.preventDefault(),n.active!==t&&(n.active=t,o.onActivate.call(i,e,c))};if(n.event=="mouseenter"&&n.activeDelay){var l,h=n.activate;n.activate=function(t,r){clearTimeout(l);var i=this,s=arguments;l=setTimeout(function(){h.apply(i,[t,r,"fix event bug in ie"])},n.activeDelay),!i.getAttribute("leave-binded")&&0&&(i.setAttribute("leave-binded",1),e.bind(i,"mouseleave",function(){clearTimeout(l)}))}}return n._autoSwitch=function(){clearTimeout(f);if(n.tabs.length<2)return;f=setTimeout(function(){var e=n.active+1,t=0;while(e!=n.active&&t=n.tabs.length&&(e=0);if(!n.tabs[e].disabled){n.active=e,n._autoSwitch();break}e++,t++}},n.autoSwitch)},n.$remove=function(){t.innerHTML=t.textContent=""},n.disable=function(t,r){r=r==void 0?!0:r,t instanceof Array||(t=[t]);var i=n.tabs.length;e.each(t,function(e,t){t>=0&&i>t&&(n.tabs[t].disabled=r)})},n.enable=function(e){n.disable(e,!1)},n.add=function(t){var r=t.title||"Tab Tile",i=t.content||"
",s=!1;n.tabpanels.forEach(function(e){e.contentType=="include"&&e.content==t.content&&(s=!0)});if(s===!0)return;n.tabpanels.push({content:i,contentType:t.contentType}),n.tabs.push({title:r,removable:t.removable,disabled:!1}),t.actived&&e.nextTick(function(){c.active=c.tabs.length-1})},n.remove=function(t,r){arguments.length==2?(t.preventDefault(),t.stopPropagation()):r=t;if(c.tabs[r].disabled===!0||c.tabs[r].removable===!1||c.tabs[r].removable==void 0&&!n.removable)return;c.tabs.removeAt(r),c.tabpanels.removeAt(r),r=r>1?r-1:0,e.nextTick(function(){c.active=r}),n.bottom=o.bottom},n._canRemove=function(e){return(e.removable==1||e.removable!==!1&&n.removable)&&!e.disabled&&n.dir!="v"},n._canActive=function(e,t){return n.active==t&&!e.disabled},n._isAjax=function(e){return n.contentType=="content"&&!e.contentType||e.contentType=="content"},n._cutCounter=function(){return(c.dir=="h"||c.forceCut)&&c.titleCutCount},n._shallPanelAlwaysShow=function(e){return c.shallPanelAlwaysShow||e===c.active},n.sliderIndex=0,n.sliderLength=0,n.nextEnable=0,n.prevEnable=0,n.slider=function(e,t){e.preventDefault();var r;t==="prev"?(r=n.sliderIndex-1,r=r>0?r:0):(r=n.sliderIndex+1,r=r<=n.sliderLength-1?r:n.sliderLength-1),n.sliderIndex=r,n.buttonEnable()},n.computeSlider=function(){if(n.dir==="v")return;var e=document.getElementById("tabs"+n.tabs.$id);if(e){var t=e.scrollWidth,r=e.parentNode.parentNode.clientWidth;t>r?n.sliderLength=t/r:n.sliderLength=0,n.buttonEnable()}},n.buttonEnable=function(){n.sliderIndex>=n.sliderLength-1?n.nextEnable=0:n.nextEnable=1,n.sliderIndex<=0?n.prevEnable=0:n.prevEnable=1},n});return c.autoSwitch&&(e.bind(t,"mouseenter",function(){c._clearTimeout()}),e.bind(t,"mouseleave",function(){c._clearTimeout(),c._autoSwitch()}),c.$watch("autoSwitch",function(e,t){c._clearTimeout(),e&&c._autoSwitch()})),c};o.defaults={target:"_blank",toggle:!0,autoSwitch:!1,active:0,shallPanelAlwaysShow:!1,event:"mouseenter",removable:!1,preScanPannel:!1,activeDelay:0,collapsible:!1,contentType:"content",bottom:!1,dir:"h",callInit:!0,titleCutCount:8,distroyDom:!0,cutEnd:"...",forceCut:!1,onInit:e.noop,tabContainerGetter:function(e){return e.getElementsByTagName("ul")[0]||e.getElementsByTagName("ol")[0]},panelContainerGetter:function(e){return e.getElementsByTagName("div")[0]||e},onActivate:e.noop,onClickActive:e.noop,onAjaxCallback:e.noop,_getTemplate:function(e,i){var s,o;return e=="panel"?s=n:e=="close"?s=r:s=t,o=i.getTemplate(s,i,e),o||o===""?o:s},getTemplate:function(e,t,n){return e},_tabTitle:function(t,n,r,i){var s;n.titleCutCount!=void 0?s=n.titleCutCount:r!=void 0&&(s=r);if(!s)return t;var o=t.split(/<[^>]+>/g),u=0,a=0,f;return e.each(o,function(e,n){if(f>=0)a="";else{var r=n.trim();u+r.length>s?(f=e,a=r.substr(0,s-u)+i):(u+=r.length,a=0)}if(a===0)return;t=t.replace(n,a)}),t},$author:"skipper@123"}}),define("text!pager/avalon.pager.html",[],function(){return'
\r\n \r\n 1\r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n
\r\n \r\n
\r\n {{regional.pageText}}\r\n \r\n
\r\n
\r\n'}),define("css!pager/avalon.pager",[],function(){}),define("pager/avalon.pager.js",["avalon","text!./avalon.pager.html","css!../chameleon/oniui-common.css","css!./avalon.pager.css"],function(e,t){function r(e,t){var n={};for(var r=0,i=e.length;r=i)break;s>1&&r.unshift(--s);if(r.length>=i)break;o2,e.showLastOmit=e.lastPaget.totalPages&&(t.currentPage=t.totalPages);break;case"prev":t.currentPage--,t.currentPage<1&&(t.currentPage=1);break;default:t.currentPage=n}t.onJump.call(s,e,t),r(t.pages,i(t))}},t.$watch("totalItems",function(){r(t.pages,i(t))}),t.$watch("perPages",function(e){t.currentPage=1,r(t.pages,i(t))}),t.$watch("currentPage",function(e){l._currentPage=e,r(t.pages,i(t))}),t.isShowPrev=function(){var e=t.alwaysShowPrev,n=t.firstPage;return e||n!==1},t.isShowNext=function(){var e=t.alwaysShowNext,n=t.lastPage,r=t.totalPages;return e||n!==r},t.changeCurrentPage=function(e,n){if(e.type==="keyup"){n=this.value;if(e.keyCode!==13)return}else n=l._currentPage;n=parseInt(n,10)||1;if(n>l.totalPages||n<1)return;l.currentPage=n,l.pages=i(l),l.onJump.call(s,e,t)},t.pages=[],t.getPages=i,t.setRegional=function(e){l.regional=e},t._getTotalPages=function(e){var t=l.regional,n=[t.totalText,e];return e>1?n.push(t.pagesText):n.push(t.pageText),n=n.concat([" ",t.jumpToText,t.numberText]),n.join("")},t.getTitle=function(e,t,n){var r=l.regional;switch(e){case"first":if(t==1)return r.currentText;return r.jumpToText+" "+r.firstText;case"prev":return r.jumpToText+" "+r.prevText;case"next":return r.jumpToText+" "+r.nextText;case"last":if(t==n)return r.currentText;return r.jumpToText+" "+r.lastText;default:if(e===t)return r.currentText;return r.jumpToText+r.numberText+" "+e+r.pageText}}});return l.pages=i(l),l};return n.regional=[],n.regional["zh-CN"]={prevText:"上一页",nextText:"下一页",confirmText:"确定",totalText:"共",pagesText:"页",pageText:"页",toText:"到",jumpToText:"跳转到",currentText:"当前页",firstText:"第一页",lastText:"最后一页",numberText:"第"},n.defaultRegional=n.regional["zh-CN"],n.defaults={perPages:10,showPages:10,currentPage:1,_currentPage:1,totalItems:200,totalPages:0,pages:[],nextText:">",prevText:"<",ellipseText:"…",firstPage:0,lastPage:0,alwaysShowNext:!1,alwaysShowPrev:!1,showFirstOmit:!1,showLastOmit:!1,showJumper:!1,getTemplate:function(e,t){return e},options:[],onJump:function(e,t){}},e}),define("avalon.getModel",["avalon"],function(e){function t(e,t,n){var r=t,i,s;for(var o=0,u=e.length;o1?i[a]:i}return e.getModel=function(e,n){if(!e)return null;var r=e.split("."),i=r.length,s=r[i-1];r.length!=1&&r.pop();for(var o=0,u=n.length;o\r\n
\r\n
\r\n
{{calendarLabel}}
\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n  {{regional.yearText}} \r\n  {{regional.monthText}}\r\n
\r\n
\r\n  {{regional.monthText}}\r\n  {{regional.yearText}} \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n
{{el}}\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n

\r\n {{regional.hourText}}\r\n \r\n

\r\n

\r\n {{regional.minuteText}}\r\n \r\n

\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n {{calendar.month+1}}\r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {{mobileYear}}\r\n \r\n
\r\n {{regional.monthNamesShort[m - 1]}}\r\n
\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n \r\n {{_years[0]}}-{{_years[9]}}\r\n \r\n \r\n
\r\n {{_years[0]-1}}\r\n {{y}}\r\n {{_years[9]+1}}\r\n
\r\n
\r\n
\r\n
\r\n
\r\n'}),define("text!dropdown/avalon.dropdown.html",[],function(){return'
\r\n
\r\n
{{label|sanitize|html}}
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\nMS_OPTION_TEMPLATE\r\n
\r\n \r\n
\r\n'}),define("text!scrollbar/avalon.scrollbar.html",[],function(){return'
\r\n
\r\n
\r\n
{{draggerHTML | html}}
\r\n
\r\n
\r\n
'}),define("draggable/avalon.draggable",["avalon"],function(e){function b(e,t){var n="page"+t;return c?e.changedTouches[0][n]:e[n]}function w(e,t,n,r,i){var s=b(e,r);if(n.containment){var o=r==="X"?n.containment[0]:n.containment[1],u=r==="X"?n.containment[2]:n.containment[3],a=s-(r==="X"?n.clickX:n.clickY);au&&(s-=Math.abs(u-a))}n["page"+r]=s;var f=m[r],l=f.toLowerCase(),c=n["start"+f]+s-n["startPage"+r]+(i?n["end"+f]:0);n[l]=c,n["drag"+r]&&(t.style[l]=c+"px")}function C(t,n){if(!t.containment){if(Array.isArray(n.containment))return;n.containment=null;return}var r=n.$element.width(),i=n.$element.height();if(t.containment==="window"){var s=e(window);n.containment=[s.scrollLeft(),s.scrollTop(),s.scrollLeft()+s.width()-n.marginLeft-r,s.scrollTop()+s.height()-n.marginTop-i];return}if(t.containment==="document"){n.containment=[0,0,e(document).width()-n.marginLeft,e(document).height()-n.marginTop];return}if(Array.isArray(t.containment)){var o=t.containment;n.containment=[o[0],o[1],o[2]-r,o[3]-i];return}if(t.containment==="parent"||t.containment.charAt(0)==="#"){var u;t.containment==="parent"?u=n.element.parentNode:u=document.getElementById(t.containment.slice(1));if(u){var a=e(u).offset();n.containment=[a.left+n.marginLeft,a.top+n.marginTop,a.left+u.offsetWidth-n.marginLeft-r,a.top+u.offsetHeight-n.marginTop-i]}}}var t={ghosting:!1,delay:0,axis:"xy",started:!0,start:e.noop,beforeStart:e.noop,drag:e.noop,beforeStop:e.noop,stop:e.noop,scrollPlugin:!0,scrollSensitivity:20,scrollSpeed:20},n=document.getElementById("avalonStyle"),r=".ui-helper-global-drag *{ -webkit-touch-callout: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}.ui-helper-global-drag img{-webkit-user-drag:none; pointer-events:none;}";try{n.innerHTML+=r}catch(i){n.styleSheet.cssText+=r}var s,o=navigator.userAgent,u=/Android/i.test(o),a=/BlackBerry/i.test(o),f=/IEMobile/i.test(o),l=/iPhone|iPad|iPod/i.test(o),c=u||a||f||l;if(!c)var h="mousedown",p="mousemove",d="mouseup";else h="touchstart",p="touchmove",d="touchend";var v=e.bindingHandlers.draggable=function(n,r){var i=n.value.match(e.rword)||[],o=i[0]||"$",u=i[1]||"draggable",a,f;if(o!="$"){a=e.vmodels[o];if(!a)return}n.element.removeAttribute("ms-draggable"),a||(a=r.length?r[0]:null);var l=a||{};a&&typeof a[u]=="object"&&(f=a[u],f.$model&&(f=f.$model),l=f);var c=n.element,p=e(c),d=e.mix({},t,f||{},n[u]||{},e.getWidgetData(c,"draggable"));"drag,stop,start,beforeStart,beforeStop".replace(e.rword,function(e){var t=d[e];typeof t=="string"&&typeof l[t]=="function"&&(d[e]=l[t])}),d.axis!==""&&!/^(x|y|xy)$/.test(d.axis)&&(d.axis="xy"),s=document.body,p.bind(h,function(t){var n=e.mix({},d,{element:c,$element:p,pageX:b(t,"X"),pageY:b(t,"Y"),marginLeft:parseFloat(p.css("marginLeft"))||0,marginTop:parseFloat(p.css("marginTop"))||0});n.startPageX=n.pageX,n.startPageY=n.pageY,d.axis.replace(/./g,function(e){n["drag"+e.toUpperCase()]=!0}),!n.dragX&&!n.dragY&&(n.started=!1),typeof d.beforeStart=="function"&&d.beforeStart.call(n.element,t,n);if(n.handle&&l){var r=l[n.handle];r=typeof r=="function"?r:n.handle;if(typeof r=="function"){var i=r.call(c,t,n);if(!i||i.nodeType!==1)return;if(!c.contains(i))return}}S();var o=p.css("position");/^(?:r|a|f)/.test(o)||(c.style.position="relative",c.style.top="0px",c.style.left="0px"),d.delay&&isFinite(d.delay)&&(n.started=!1,setTimeout(function(){n.started=!0},d.delay));var u=p.offset();if(d.ghosting){var a=c.cloneNode(!0);e(a).css("opacity",.7).width(c.offsetWidth).height(c.offsetHeight),n.clone=a,o!=="fixed"&&(a.style.position="absolute",a.style.top=u.top-n.marginTop+"px",a.style.left=u.left-n.marginLeft+"px"),s.appendChild(a)}var f=e(n.clone||n.element);n.startLeft=parseFloat(f.css("left")),n.startTop=parseFloat(f.css("top")),n.endLeft=parseFloat(p.css("left"))-n.startLeft,n.endTop=parseFloat(p.css("top"))-n.startTop,n.clickX=n.pageX-u.left,n.clickY=n.pageY-u.top,C(d,n),v.dragData=n,"start,drag,beforeStop,stop".replace(e.rword,function(e){v[e]=[d[e]]}),v.plugin.call("start",t,n)})},m={X:"Left",Y:"Top"};v.dragData={},v.start=[],v.drag=[],v.stop=[],v.beforeStop=[],v.plugin={add:function(e,t){for(var n in t){var r=t[n];typeof r=="function"&&Array.isArray(v[n])&&(r.isPlugin=!0,r.pluginName=e+"Plugin",v[n].push(r))}},call:function(t,n,r){var i=v[t];Array.isArray(i)&&i.forEach(function(e){(typeof e.pluginName=="undefined"?!0:r[e.pluginName])&&e.call(r.element,n,r)});if(t==="stop")for(var s in v)i=v[s],Array.isArray(i)&&i.forEach(function(t){t.isPlugin||e.Array.remove(i,t)})}};var g=new Date-0,y=document.querySelector?12:30;e(document).bind(p,function(e){var t=new Date-g;if(t>y){g=t;var n=v.dragData;if(n.started===!0){e.preventDefault();var r=n.clone||n.element;w(e,r,n,"X"),w(e,r,n,"Y"),v.plugin.call("drag",e,n)}}}),e(document).bind(d,function(e){var t=v.dragData;if(t.started===!0){x();var n=t.element;v.plugin.call("beforeStop",e,t),t.dragX&&w(e,n,t,"X",!0),t.dragY&&w(e,n,t,"Y",!0),t.clone&&s.removeChild(t.clone),v.plugin.call("stop",e,t),v.dragData={}}});var E=document.documentElement,S=function(){e(E).addClass("ui-helper-global-drag")},x=function(){e(E).removeClass("ui-helper-global-drag")};if(window.VBArray&&!("msUserSelect"in E.style)){var T;function N(){var e=window.event||{};e.returnValue=!1}S=function(){T=s.onselectstart,s.onselectstart=N},x=function(){s.onselectstart=T}}return e}),define("css!scrollbar/avalon.scrollbar",[],function(){}),define("scrollbar/avalon.scrollbar",["avalon","text!./avalon.scrollbar.html","../draggable/avalon.draggable","css!./avalon.scrollbar.css","css!../chameleon/oniui-common.css"],function(e,t){function n(t,n){var n=n||document.body;if(n.getElementsByClassName)return n.getElementsByClassName(t);var r=n.getElementsByTagName("*"),i=[];return e.each(r,function(n,r){var s=e(r);s.hasClass(t)&&i.push(r)}),i}function r(e){return Math.round(parseFloat(e))||0}var i,s=[],o=[],u=e.ui.scrollbar=function(u,a,f){var l=a.scrollbarOptions;l.template=l.getTemplate(t,l);var c=e.define(a.scrollbarId,function(t){e.mix(t,l),t.widgetElement=u,t.draggerHeight=t.draggerWidth="",t.inFocuse=!1,t._position=[],t.rootElement=u,t.viewElement=u,t.$skipArray=["rootElement"],t.dragging=!1;var a,h=[],p;t.$init=function(t){if(a)return;a=!0,c.widgetElement.style.position="relative",c.viewElement=c.widgetElement==document.body?document.getElementsByTagName("html")[0]:c.widgetElement,c.viewElement.style.overflow=c.viewElement.style.overflowX=c.viewElement.style.overflowY="hidden",c.widgetElement==document.body&&(c.widgetElement.style.overflow=c.widgetElement.style.overflowX=c.widgetElement.style.overflowY="hidden"),c._position=c.position.split(",");var n=e.parseHTML(l.template);c.widgetElement.appendChild(n),t?t():(e.log("avalon请尽快升到1.3.7+"),e.scan(u,[c].concat(f)),typeof l.onInit=="function"&&l.onInit.call(u,c,l,f));var d=c.widgetElement.childNodes;e.each(d,function(t,n){var r=e(n);if(r.hasClass("oni-scrollbar")||r.hasClass("ui-scrollbar"))h.push(r);else if(r.hasClass("oni-scrollbar-scroller")||r.hasClass("ui-scrollbar-scroller"))p=r});if(c.position.match(/left|right/g)){var v=[],m=[];e.each(c._position,function(e,t){t.match(/left|right/g)?v.push([e,t]):m.push([e,t])});function g(t,n,r,i){e.each(n,function(e,n){if(!h[e].data("oni-scrollbar-needed"))return;c._computer(i||function(e){return c._clickComputer(e,t)},n[0],n[1],function(e){e||r.preventDefault()},"breakOutCallbackCannotIgnore")})}function y(e){if(c.disabled)return;c.inFocuse&&g(e.wheelDelta>0?"up":"down",v,e)}function b(e){if(c.disabled)return;var t=e.keyCode;if(t>32&&t<41&c.inFocuse)if(t in{37:1,39:1,38:1,40:1})g(t in{37:1,38:1}?"up":"down",t in{38:1,40:1}?v:m,e);else{var n=t in{33:1,36:1}?"up":"down";g(n,v,e,function(i){var s=p[0].scrollTop;t in{33:1,36:1}?s&&e.preventDefault():s>0,y:r(i.css("top"))>>0};return t.x==e.draggerparWidth-e.draggerWidth&&(t.x+=100),t.y==e.draggerparHeight-e.draggerHeight&&(t.y+=100),t},i.attr("oni-scrollbar-index"),i.attr("oni-scrollbar-pos"))},handle:function(e,t){return!c.disabled&&this},containment:"parent"},t.$draggableOpts.stop=function(t,n){c.$draggableOpts.drag(t,n),c.dragging=!1,e(n.element).removeClass("oni-state-active")},t.$remove=function(){e.each(h,function(e,t){t[0]&&t[0].parentNode&&t[0].parentNode.removeChild(t[0])})},t._onScroll=function(){if(c.show!="scrolling")return;e.each(h,function(e,t){c._show("e",!1,t)})},t._show=function(e,t,n){if(c.show!="scrolling")return;e.stopPropagation&&e.stopPropagation();var r=n.css?n:h[n];r&&(clearTimeout(r.data("oni-scrollbar-hidetimer")),r.css("visibility","visible"),r.css("opacity",1),t||r.data("oni-scrollbar-hidetimer",setTimeout(function(){r.css("opacity",0)},1e3)))},t._hide=function(t,n){if(c.show!="scrolling")return;n&&h[n]?h[n].css("opacity",0):e.each(h,function(e,t){t.css("opacity",0)})},t.getBars=function(){return h},t.getScroller=function(){return p},t.update=function(t,i,s){if(c.disabled)return;var o=e(c.viewElement),u,a,f=c.widgetElement===document.body?c.viewElement.clientHeight:r(o.css("height")),l=r(o.css("width")),d=c.viewHeightGetter(o),v=c.viewWidthGetter(o),m=c.position,g,y={},s=s==void 0?c.scrollTop:s,i=i==void 0?c.scrollLeft:i;c.viewElement!=c.widgetElement&&m.match(/right|left/g)&&e(c.widgetElement).css("height",f);var b=p.width()-p.innerWidth(),w=p.height()-p.innerHeight();p.css("height",d+w),p.css("width",v+b),u=p[0].scrollWidth,a=p[0].scrollHeight,g={top:m.match(/top/g)&&u>v,right:m.match(/right/g)&&a>d,bottom:m.match(/bottom/g)&&u>v,left:m.match(/left/g)&&a>d};if(h.length>1){var E=["top","right","bottom","left"];for(var S=0;S<4;S++)y[E[S]]=[(g[S?E[S-1]:E[3]]&&1)>>0,(g[S<3?E[S+1]:E[0]]&&1)>>0],S>1&&(y[E[S]]=y[E[S]].reverse())}d=p.innerHeight(),v=p.innerWidth(),e.each(c._position,function(o,m){var E=h[o],S=m.match(/left|right/),T;E&&(T=e(n("oni-scrollbar-dragger",E.element)[0])),t&&T&&(T.attr("ms-draggable","$,$draggableOpts"),T.attr("oni-scrollbar-pos",m),T.attr("oni-scrollbar-index",o),e.scan(T[0],c));if(!g[m]){E&&(E.css("opacity",0),E.css("visibility","hidden"),E.data("oni-scrollbar-needed",!1));return}E&&(E.data("oni-scrollbar-needed",!0),E.css("visibility","visible"),c.show=="scrolling"||c.show=="never"?E.css("opacity",0):E.css("opacity",1));if(E){var N=r(E.css("height")),C=r(E.css("width")),k=N,L=C,A=e(n("oni-scrollbar-draggerpar",E[0])[0]),O=c.showBarHeader?2:0,M=[];if(h.length>1){var _=[],D=y[m];S?(_=[["top",D[0]*L],["height",f-L*(D[0]+D[1])]],M=[["top",O/2*L],["height",f-L*(D[0]+D[1]+O)]]):(_=[["left",D[0]*k],["width",l-k*(D[0]+D[1])]],M=[["left",O/2*k],["width",l-k*(O+D[0]+D[1])]]),e.each(_,function(e,t){E.css.apply(E,t)}),k=E.height(),L=E.width()}else S?M=[["top",L],["height",f-L*2]]:M=[["left",k],["width",l-k*2]];var P;S?(P=c.show=="always"?L:0,p.css("width",v+b-P)):(P=c.show=="always"?k:0,p.css("height",d+w-P)),e.each(M,function(e,t){A.css.apply(A,t)}),N=k-O*L,C=L-O*k;var H;if(S){var B=s,j=r(d*N/a);j=c.limitRateV*L>j&&c.limitRateV*L||j,B=B<0?0:B,B=B>a-d?a-d:B,B=r((N-j)*B/(a-d)),B=Math.min(N-j,B),H=[["width","100%"],["height",j],["top",B]],s=s>0?s>a-d+P?a-d+P:s:0}else{var F=i,I=r(v*C/u);I=c.limitRateH*k>I&&c.limitRateH*k||I,F=F<0?0:F,F=F>u-v?u-v:F,F=r((C-I)*F/(u-v)),F=Math.min(C-I,F),H=[["height","100%"],["width",I],["left",F]],i=i>0?i>u-v+P?u-v+P:i:0}e.each(H,function(e,t){T.css.apply(T,t)}),t&&(S?c._scrollTo(void 0,s):c._scrollTo(i,void 0)),c.showBarHeader&&(s==0&&S||!S&&i==0?e(n("oni-scrollbar-arrow-up",E[0])[0]).addClass("oni-state-disabled"):e(n("oni-scrollbar-arrow-up",E[0])[0]).removeClass("oni-state-disabled"),s>=A.innerHeight()-T.innerHeight()&&S||!S&&i>=A.innerWidth()-T.innerWidth()?!c.breakOutCallback&&e(n("oni-scrollbar-arrow-down",E[0])[0]).addClass("oni-state-disabled"):e(n("oni-scrollbar-arrow-down",E[0])[0]).removeClass("oni-state-disabled"))}})},t._arrClick=function(e,t,n,r){if(c.disabled)return;c._computer(function(e){return c._clickComputer(e,t)},r,n)},t._clickComputer=function(e,t,n){var n=n||e.step||40,i=r(e.dragger.css("left"))>>0,s=r(e.dragger.css("top"))>>0,o=t=="down"?i+n:i-n,u=t=="down"?s+n:s-n;return{x:o,y:u}},t._arrDown=function(t,n,r,i,s){if(c.disabled)return;var o=this,u=e(o);clearInterval(u.data("mousedownTimer")),clearTimeout(u.data("setTimer"));var a=h[i];if(s||u.hasClass("oni-state-disabled"))return u.removeClass("oni-state-active");u.data("setTimer",setTimeout(function(){u.addClass("oni-state-active"),u.data("mousedownTimer",setInterval(function(){return c._computer(function(e){return c._clickComputer(e,n)},i,r,function(e){if(!e)return;clearInterval(u.data("mousedownTimer")),clearTimeout(u.data("setTimer"))})},120))},10))},t._barClick=function(t,n,r){if(c.disabled)return;var i=e(this);if(i.hasClass("oni-scrollbar-dragger"))return;c._computer(function(e){return{x:Math.ceil(t.pageX-e.offset.left-e.draggerWidth/2),y:Math.ceil(t.pageY-e.offset.top-e.draggerHeight/2)}},r,n)},t._computer=function(t,i,s,o,u){if(c.disabled)return;var a=h[i];if(a&&a.data("oni-scrollbar-needed")){var f={},l=s.match(/left|right/g);f.dragger=e(n("oni-scrollbar-dragger",a[0])[0]),f.draggerWidth=r(f.dragger.css("width")),f.draggerHeight=r(f.dragger.css("height")),f.draggerpar=e(f.dragger[0].parentNode),f.draggerparWidth=r(f.draggerpar.css("width")),f.draggerparHeight=r(f.draggerpar.css("height")),f.offset=f.draggerpar.offset(),f.up=e(n("oni-scrollbar-arrow-up",a[0])[0]),f.down=e(n("oni-scrollbar-arrow-down",a[0])[0]),f.viewer=e(c.viewElement),f.viewH=p.innerHeight(),f.viewW=p.innerWidth(),f.scrollerH=p[0].scrollHeight,f.scrollerW=p[0].scrollWidth,f.step=l?40*(f.draggerparHeight-f.draggerHeight)/(f.scrollerH-f.viewH):40*(f.draggerparWidth-f.draggerWidth)/(f.scrollerW-f.viewW),f.step=r(f.step)||1;var d=t(f),v;d.x=r(d.x),d.y=r(d.y);if(l){d.y<0?(d.y=0,f.up.addClass("oni-state-disabled"),v=["v","up"]):f.up.removeClass("oni-state-disabled"),d.y>f.draggerparHeight-f.draggerHeight?(d.y=f.draggerparHeight-f.draggerHeight,v=["v","down"],f.down.addClass("oni-state-disabled")):f.down.removeClass("oni-state-disabled");var m=r((f.scrollerH-f.viewH)*d.y/(f.draggerparHeight-f.draggerHeight))-c.scrollTop;f.dragger.css("top",d.y),c._scrollTo(void 0,r((f.scrollerH-f.viewH)*d.y/(f.draggerparHeight-f.draggerHeight)))}else d.x<0?(d.x=0,v=["h","up"],f.up.addClass("oni-state-disabled")):f.up.removeClass("oni-state-disabled"),d.x>f.draggerparWidth-f.draggerWidth?(d.x=f.draggerparWidth-f.draggerWidth,v=["h","down"],!c.breakOutCallback&&f.down.addClass("oni-state-disabled")):f.down.removeClass("oni-state-disabled"),f.dragger.css("left",d.x),c._scrollTo(r((f.scrollerW-f.viewW)*d.x/(f.draggerparWidth-f.draggerWidth)),void 0)}(!c.breakOutCallback||u)&&o&&o(v),c.breakOutCallback&&c.breakOutCallback(v,c,f)},t._scrollTo=function(e,t){t!=void 0&&(p[0].scrollTop=t,c.scrollTop=p[0].scrollTop),e!=void 0&&(p[0].scrollLeft=e,c.scrollLeft=p[0].scrollLeft)},t.scrollTo=function(e,n){c.update(!1,e,n),t._scrollTo(e,n)},t._initWheel=function(e,t){t=="enter"?c.inFocuse=!0:c.inFocuse=!1},t._draggerDown=function(t,n){if(c.disabled)return;var r=e(this);n?r.addClass("oni-state-active"):r.removeClass("oni-state-active")},t._stopPropagation=function(e){e.stopPropagation()}});return c.$watch("scrollLeft",function(e,t){c._onScroll(),c.onScroll&&c.onScroll(e,t,"h",c)}),c.$watch("scrollTop",function(e,t){c._onScroll(),c.onScroll&&c.onScroll(e,t,"v",c)}),c};u.defaults={disabled:!1,toggle:!0,position:"right",limitRateV:1.5,limitRateH:1.5,scrollTop:0,scrollLeft:0,show:"always",showBarHeader:!0,draggerHTML:"",breakOutCallback:!1,onInit:e.noop,viewHeightGetter:function(e){return e.innerHeight()},viewWidthGetter:function(e){return e.innerWidth()},getTemplate:function(e,t){return e},onScroll:function(e,t,n,r){},size:"normal",$author:"skipper@123"}}),define("css!dropdown/avalon.dropdown",[],function(){}),define("dropdown/avalon.dropdown.js",["avalon","text!./avalon.dropdown.html","../avalon.getModel","../scrollbar/avalon.scrollbar","css!../chameleon/oniui-common.css","css!./avalon.dropdown.css"],function(e,t){function s(e){try{e=e==="true"?!0:e==="false"?!1:e==="null"?null:+e+""===e?+e:e}catch(t){}return e}function o(e,t,n){var r=t||[];n=n||null;for(var i=0,s;s=e[i++];)Array.isArray(s.options)?(r.push({label:s.label,value:s.value,enable:a(s.enable,!0),group:!0,parent:n,toggle:!0}),o(s.options,r,s)):(typeof s=="string"&&(s={label:s,value:s,title:s}),r.push({label:s.label,value:s.value,title:s.title,enable:a(n&&n.enable,!0)&&a(s.enable,!0),group:!1,parent:n,data:s,toggle:!0}));return r}function u(e){var t=document.createDocumentFragment(),n,r;for(var i=0,s;s=e[i++];)s.group?(r=document.createElement("optgroup"),r.label=s.label,r.disabled=!s.enable,t.appendChild(r),n=r):(r=document.createElement("option"),r.text=s.label,r.value=s.value,r.disabled=!s.enable,s.parent&&n?n.appendChild(r):t.appendChild(r));return t}function a(e,t){return typeof e=="boolean"?e:t}function f(e,t,n){var r=t||[],i=e.children;n=n||null;for(var o=0,u;u=i[o++];)u.nodeType===1&&(u.tagName==="OPTGROUP"?(n={label:u.label,value:"",enable:!u.disabled,group:!0,parent:!1,toggle:!0},r.push(n),f(u,r,n)):u.tagName==="OPTION"&&r.push({label:u.label.trim()||u.text.trim()||u.value.trim(),title:u.title.trim(),value:s(u.value.trim()||u.text.trim()),enable:a(n&&n.enable,!0)&&!u.disabled,group:!1,parent:n,toggle:!0}));return r}function l(e,t,n){var r=e.size(),i=[],s=[],o={},u,a;for(u=0;u0?s.shift():i.shift():a=i.length>0?i.pop():s.pop(),a}function h(e){var t=[];for(;e;e=e.nextSibling)e.nodeType===1&&t.push(e);return t}var n=/^(\d+).*$/,r=!-[1]&&!window.XMLHttpRequest,i=e.ui.dropdown=function(i,a,p){function _(){e.each(i.getElementsByTagName("option"),function(t,n){if(M.value.$model.indexOf(n.value)>-1||M.value.$model.indexOf(s(n.value))>-1)try{n.selected=!0}catch(r){e(n).attr("selected","selected")}else try{n.selected=!1}catch(r){n.removeAttribute("selected")}})}function D(t){var n=(i.msData["ms-duplex"]||"").trim(),r;if(n&&(r=e.getModel(n,p)))t.value=r[1][r[0]],t.$hasDuplex=!0;else if(!g)Array.isArray(t.value)||(t.value=[t.value||""]);else{var o=[];Array.prototype.forEach.call(i.options,function(e){e.selected&&o.push(s(e.value))}),t.value=o}if(!t.multiple){Array.isArray(t.value)&&(t.value=t.value[0]!==void 0?t.value[0]:"");var u=t.data.filter(function(e){return e.value===t.value&&!e.group}),a=t.data.filter(function(e){return!e.group});u.length===0&&a.length>0&&(t.value=a[0].value,r&&(r[1][r[0]]=t.value))}var f=d.attr("data-duplex-changed"),l;f&&(l=e.getModel(f,p))&&(t.changedCallback=l[1][l[0]]),t.duplexName=n;var c=document.body,h=t.container;t.container=(e.type(h)==="object"&&h.nodeType===1&&c.contains(h)?h:document.getElementById(h))||c}function P(){return e.parseHTML(S)}function H(t){var n=M.data.$model.filter(function(e){return e.value===t});return n=n.length>0?n[0]:null,n?(M.label=n.label,M.title=n.title||n.label||""):e.log("[log] avalon.dropdown 设置label出错"),n}function B(){var t=document.getElementById("title-"+M.$id),r=e(t);return M.width-r.css("paddingLeft").replace(n,"$1")-r.css("paddingRight").replace(n,"$1")}function j(){!M.multiple&&O&&M._position()}var d=e(i),v=i.parentNode,m=a.dropdownOptions,g=!0,y,b,w,E,S,x,T,N,C=!1;"multiple,size".replace(e.rword,function(e){c(i,e)&&(m[e]=i[e])}),m.enable=!i.disabled,w=m.template=m.getTemplate(t,m).replace(/MS_OPTION_ID/g,a.dropdownId).split("MS_OPTION_TEMPLATE"),E=w[0],S=w[1],y=m.data.$model||m.data,i.removeAttribute("ms-duplex"),e.scan(i,p),b=f(i),g=!!b.length,b.length===0&&(b=o(y)),m.data=b,e(i).css("display","none"),D(m);for(var k=0,L=b.length;k0&&M._refresh(M.$source.length):M.$source=null;M.$source&&M.$source.$watch&&M.$source.$watch("length",function(e){M._refresh(e)})}e.scan(i.parentNode,[M].concat(p)),t?t():(e.log("请尽快升到avalon1.3.7+"),typeof m.onInit=="function"&&m.onInit.call(i,M,m,p)),M.multiple&&_()},t.repeatRendered=function(){M.multiple&&e.vmodels["scrollbar-"+M.$id].update()},t.$remove=function(){x&&e.unbind(window,"click",x),T&&e.unbind(window,"scroll",T),N&&e.unbind(window,"resize",N),M.toggle=!1,O&&M.container&&M.container.contains(O)&&M.container.removeChild(O),e.log("dropdown $remove")},t._select=function(t,n){var r=M.data[t].$model;if(r&&r.enable&&!r.group){var s=M.value;M.multiple?(t=M.value.indexOf(r.value),t>-1?M.value.splice(t,1):M.value.push(r.value)):M.value=r.value,M.toggle=!1,e.type(M.onSelect)==="function"&&M.onSelect.call(i,n,M.value,s,M),M.activeIndex=t}},t._refresh=function(e){M.data.clear(),M.label="",M.__cursorInList__=!1;if(e>0){M._disabledScrollbar(!1),M.data.pushArray(o(M.$source.$model||M.$source));var t;(t=H(M.value))?M.activeIndex=M.data.$model.indexOf(t):(M.currentOption=M.data[0].$model,M.activeIndex=0,H(M.value=M.data[0].value)),M.menuNode&&M._styleFix(!0)}},t._titleenter=function(){M.hoverAutoShow&&M._toggle()},t._titleleave=function(){M.hoverAutoShow&&(M.toggle=!1)},t._keydown=function(t){if(M.keyboardEvent===!1)return;if(!M.multiple){var n=M.activeIndex||0,r=M.value;switch(t.keyCode){case 9:case 27:t.preventDefault();break;case 13:M._select(n,t);break;case 38:case 63233:t.preventDefault(),n=l(M.data,n);if(n===null)return;M.value=M.data[n].value,M.activeIndex=n,M.scrollTo(n),e.type(M.onSelect)==="function"&&M.onSelect.call(i,t,M.value,r,M);break;case 40:case 63235:t.preventDefault(),n=l(M.data,n,!0);if(n===null)return;M.value=M.data[n].value,M.activeIndex=n,M.scrollTo(n),e.type(M.onSelect)==="function"&&M.onSelect.call(i,t,M.value,r,M)}}},t._toggle=function(n){if(M.data.length===0&&!M.realTimeData||!M.enable||M.readOnly){M.toggle=!1;return}if(!O){var r;O=P(),r=O.firstChild,M.container.appendChild(O),O=r,t.rootElement=r,e.scan(r,[M].concat(p)),M.menuNode=document.getElementById("menu-"+M.$id),M.dropdownNode=document.getElementById("list-"+M.$id)}if(typeof n!="boolean"){M.toggle=!M.toggle;return}if(!n)e.type(M.onHide)==="function"&&M.onHide.call(i,O,M);else{var s,o,u=M.value;e.type(u)!=="array"&&(u=[u]),M.activeIndex==null&&(e.each(M.data,function(e,t){return s===void 0&&t.enable&&(s=e),t.value===u[0]?(o=e,!1):!0}),o||(o=s),M.activeIndex=o||0),M.scrollWidget=e.vmodels["scrollbar-"+M.$id],M._styleFix(),M._position(),e.type(M.onShow)==="function"&&M.onShow.call(i,O,M)}},t.$watch("toggle",function(e){M.focusClass=e,M._toggle(e)}),t.toggle=!1,t._position=function(){var t=e(A),r=t.offset(),i=t.outerHeight(!0),s=e(O),o=e(A.firstChild),u=s.height(),a=e(window),f={},l=O.offsetParent,c=e(l);while(o.element&&o.element.nodeType!=1)o=e(o.element.nextSibling);m.position&&r.top+i+u>a.scrollTop()+a.height()&&r.top-u>a.scrollTop()?f.top=r.top-u:f.top=r.top+i-o.css("borderBottomWidth").replace(n,"$1"),l&&l.tagName!=="BODY"&&l.tagName!=="HTML"?(f.top=f.top-c.offset().top+O.offsetParent.scrollTop,f.left=r.left-c.offset().left+O.offsetParent.scrollLeft):f.left=r.left,s.css(f)},t.__cursorInList__=!1,t._listenter=function(){M.__cursorInList__=!0,M.hoverAutoShow&&(M.toggle=!0)},t._listleave=function(){M.__cursorInList__=!1,M.hoverAutoShow&&(M.toggle=!1)},t._blur=function(){!M.__cursorInList__&&!M.multiple&&M.toggle&&(M.toggle=!1)},t.val=function(t){return typeof t!="undefined"&&(e.type(t)!=="array"&&(t=[t]),M.value=t),M.value},t.isActive=function(e){var t=e.value,n=e.enable,r=e.group;return M.multiple?M.value.indexOf(t)>-1&&n&&!r:M.value===t&&n&&!r},t._styleFix=function(t){var i=m.height||200,s=e(M.menuNode),o="";t&&(M.menuHeight="",e(M.dropdownNode).css({height:""})),o=M.dropdownNode.scrollHeight,M.menuWidth=r?M.listWidth:M.listWidth-s.css("borderLeftWidth").replace(n,"$1")-s.css("borderRightWidth").replace(n,"$1"),o>i?(M._disabledScrollbar(!1),o=i,e(M.dropdownNode).css({width:M.menuWidth-M.scrollWidget.getBars()[0].width()})):(M._disabledScrollbar(!0),e(M.dropdownNode).css({width:M.menuWidth})),M.menuHeight=o,M.updateScrollbar(),M.scrollTo(M.activeIndex)},t.updateScrollbar=function(){M.scrollWidget.update()},t.scrollTo=function(t){if(!M.dropdownNode)return;var n=h(M.dropdownNode.firstChild),r=e(n[t]),i=M.menuHeight,s=n.length?r.position().top-e(n[0]).position().top:0,o=n.length?r.height():0,u=M.dropdownNode.scrollTop;(s>u+i-o||s+o(?![^<]*<['"])/));return(new RegExp("\\s"+t+"\\b","i")).test(r)};return e}),define("text!slider/avalon.slider.html",[],function(){return'
\r\n
\r\n
\r\n \r\n \r\n \r\n
'}),define("css!slider/avalon.slider",[],function(){}),define("slider/avalon.slider.js",["../draggable/avalon.draggable","text!./avalon.slider.html","css!../chameleon/oniui-common.css","css!./avalon.slider.css","../avalon.getModel"],function(e,t){var n=[],r=0,i,s=t,o=e.ui.slider=function(t,i,o){function w(e){return ec&&(e=c),parseFloat(((e-l)/(c-l)*100).toFixed(5))}function E(e){var t=(c-l)*e+l;return t=S(t),parseFloat(t.toFixed(3))}function S(e){var t=a.step>0?a.step:1,n;try{n=t.toString().split(".")[1].length}catch(r){n=0}var i=Math.pow(10,n),s=(e-l)*i%t*i,o=(e-l)/t;return e=(l*i+(s*2>=t?t*i*Math.ceil(o):t*i*Math.floor(o)))/i,e}function T(e,t,n){if(isFinite(n))var i=n;else{var s=f?"left":"top",o=t[s]+parseFloat(t.$element.css("border-top-width")),u=o/x.$pixelTotal;f||(u=Math.abs(1-u)),u>.999&&(u=1),u<.001&&(u=0),i=E(u)}if(d){if(r===0){var a=x.values[1];i>a&&(i=a)}else a=x.values[0],i0?a.step:1,i.disabled=t.disabled,i.percent=d?w(p[1]-p[0]+l):w(v),i.percent0=d?w(p[0]):0,i.percent1=d?w(p[1]):0,i.value=d?p.join():v,i.values=p,i.$axis=f?"x":"y",i.$valueMin=l,i.$valueMax=c,i.$twohandlebars=d,i.$percent2Value=E,i.$pixelTotal=0,i._dragEnd=!1,i.dragstart=function(e,t){x.$pixelTotal=f?y.offsetWidth:y.offsetHeight,n=b,t.started=!x.disabled,t.dragX=t.dragY=!1,r=b.indexOf(t.element),t.$element.addClass("oni-state-active"),a.onDragStart.call(null,e,t)},i.dragend=function(e,t,n){t.$element.removeClass("oni-state-active"),a.onDragEnd.call(null,e,t),x._dragEnd=!1},i.drag=function(e,t,n){T(e,t,n),a.onDrag.call(null,x,t),x._dragEnd=!0},i.$init=function(){var n=y.getElementsByTagName("b");for(var r=0,i;i=n[r++];){i.sliderModel=x;if(!d&&e(i).hasClass("hander___flag")){b.push(i),e(i).removeClass("hander___flag");break}d&&!e(i).hasClass("hander___flag")&&b.push(i)}e(t).css({display:"none",height:0,width:0,padding:0}),e(y).css("width",x.width),e.scan(y,[x].concat(o)),typeof a.onInit=="function"&&a.onInit.call(t,x,a,o)},i.$remove=function(){y.innerHTML=y.textContent="",y.parentNode.removeChild(y)}});return x.$watch("value",function(e){e=S(Number(e)||0),!e||eNumber(x.max)&&(e=x.max),x.value=e,x.percent=w(e),x._dragEnd||a.onDragEnd.call(null,i)}),x};return o.defaults={max:100,min:0,width:-1,orientation:"horizontal",range:!1,step:1,value:0,values:null,disabled:!1,onDragStart:e.noop,onDrag:e.noop,onDragEnd:e.noop,getTemplate:function(e,t){return e}},e(document).bind("click",function(t){t.stopPropagation();var r=t.target,s=n.indexOf(r);s!==-1?(i&&i.removeClass("oni-state-focus"),i=e(r).addClass("oni-state-focus")):i&&(i.removeClass("oni-state-focus"),i=null)}),e(document).bind("keydown",function(e){if(i){var t=i[0].sliderModel,s=n.length==1?t.percent:t["percent"+r],o=t.$percent2Value(s/100),u;switch(e.which){case 34:case 39:case 38:u=Math.min(o+1,t.$valueMax);break;case 33:case 37:case 40:u=Math.max(o-1,t.$valueMin);break;case 36:u=t.$valueMin;break;case 35:u=t.$valueMax}isFinite(u)&&t.drag(e,{},u)}}),e}),define("css!datepicker/avalon.datepicker",[],function(){}),define("datepicker/avalon.datepicker.js",["../avalon.getModel","./avalon.datepicker.lang","text!./avalon.datepicker.html","../dropdown/avalon.dropdown.js","../slider/avalon.slider.js","css!../chameleon/oniui-common.css","css!./avalon.datepicker.css"],function(e,t,n){function f(e){return e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),e}function l(e){var t={},n=[];for(var r in e){var i=e[r],s=c(r);s&&(i.date=s,n.push(i))}n.sort(function(e,t){return(e.dayIndex||0)-(t.dayIndex||0)});for(var r=0,o=n.length;r0?"后"+f+"天":""),cellClass:f===0&&i.holidayClass||"",cellText:f===0&&i.holidayText||""}}return t}function c(t){if(!t)return null;if(e.type(t)==="date")return t;var n=this.separator||"-",r="^(\\d{4})"+n+"(\\d{1,2})"+n+"(\\d{1,2})[\\s\\w\\W]*$";r=new RegExp(r);var i=t.match(r);return i?new Date(i[1],i[2]*1-1,i[3]):null}function h(e){if(!e)return;var t;this.$id&&this.regional?t=this.regional:t=a.defaultRegional;var n=t.holidayDate||{},r=f(new Date).getTime(),i=e.getTime(),o=t.dayNames;if(r==i)return{text:t.currentDayFullText,cellClass:"c_today",cellText:t.currentDayText};if(r==i-s)return{text:t.nextDayText,cellClass:""};if(r==i-s*2)return{text:t.dayAfterTomorrow,cellClass:""};var u=n&&n[e.getTime()];return u?u:{text:t.weekDayNames[e.getDay()]}}var r=n,i,s=864e5,o=1901,u=2050,a=e.ui.datepicker=function(t,n,i){function A(){var e=t.value,n=p(e),r=f(new Date),i=n,o=!1;e&&!n&&(s.tip=s.formatErrorTip,s.dateError="#ff8888",i=r),s.allowBlank?e?n&&(o=M(n,s)):(s.tip="",i=r):e?n&&(o=M(n,s)):(e=d(r),s.tip=h(r).text,i=r,o=M(r,s)),o&&(i=s.minDate||s.maxDate,e=d(i)),C=i.getFullYear(),T=i.getMonth(),N=i.getDate(),b=e}function O(e){var t=L._years,n=(e+"").substr(0,3),r=[];if(!~t.indexOf(e)){for(var i=0;i<=9;i++)r.push(Number(n+i));L._years=r}}function M(e,t){var n=e.getTime(),r=t.minDate,i=t.maxDate;return r&&ni.getTime()?!0:!1}function _(n,r){e.bind(t,"focus",function(e){L.toggle=!0}),e.bind(document,"click",function(e){var t=e.target;if(s.type==="range")return;if(!n.contains(t)&&!r.contains(t)&&L.toggle&&!L.timer){L.toggle=!1;return}if(!L.toggle&&!L.disabled&&r.contains(t)){L.toggle=!0;return}}),e.bind(t,"keydown",function(e){var t=e.keyCode,n,r;r=e.key;if(r)switch(r){case"-":n="-";break;case"/":n="/"}else switch(t){case 189:n="-";break;case 191:n="/"}L.toggle||(L.toggle=!0);if((t<48||t>57&&t<96||t>105)&&t!==13&&t!==8&&s.separator!==n&&t!==27&&t!==9&&t!==37&&t!==39&&t!==46)return e.preventDefault(),!1}),e.bind(t,"keyup",function(e){var n=t.value,r=L.year,i=L.month,s=e.keyCode,o,u,a;if(s===37||s===39)return!1;if(s===13||s==27||s==9)return L.toggle=!1,!1;if(a=p(n))o=a.getMonth(),u=a.getFullYear(),L.dateError="#cccccc",L.tip=h(f(a)).text,L.day=a.getDate(),i!=o&&r!=u?(g=!0,L.year=u,L.month=o):i!=o?L.month=o:L.year=u;else{if(L.allowBlank&&n==""){L.tip="",L.dateError="#cccccc";return}L.tip=L.formatErrorTip,L.dateError="#ff8888"}})}function D(e){var t=L.month,n=L.year,r=L.stepMonths,i=L.numberOfMonths,s,o=0,u=0;e==="next"?t=t+r+i-1:t=t-r-i+1,s=new Date(n,t,1),o=s.getMonth(),u=s.getFullYear(),u!=L.year?(g=!0,L.year=u,L.month=o):L.month=o}function P(){var e=[],t=s.startDay;for(var n=0,r=L.regional.dayNames;n<7;n++){var i=(n+t)%7;e.push(r[i])}return e}function H(e,t,n,r,i,s,o,u){var a=!1,f=h(e),l=f&&f.cellText||u,c=e.getDay(),p=c%7==0||c%7==6,d=M(e,t);n&&n.getDate()===+u&&r===n.getMonth()&&i===n.getFullYear()&&(a=!0),s.push({day:u+"",_day:l+"",month:r,year:i,weekend:p,selected:a,dateDisabled:d}),o.push(l+"")}function B(e,n){var r=L.startDay,i=new Date(n,e,1),s=new Date(n,e,1-(i.getDay()-r+7)%7),o=L.showOtherMonths,u=p(t.value),a=L.minDate,f=L.maxDate,l=a?(n-a.getFullYear())*12+e-a.getMonth()>0:!0,c=f?(f.getFullYear()-n)*12+f.getMonth()-e>0:!0,h=[],d=[],v=[],m=[],g=[],b=[],w,E,S;L.prevMonth=l,L.nextMonth=c;for(var x=0,T=L.numberOfMonths;x0:!0,d=c?(c.getFullYear()-r)*12+c.getMonth()-n>0:!0,v,m,g;L.prevMonth=h,L.nextMonth=d;for(var b=0,w=L.numberOfMonths;b=t[t.length-1])return;O(e[9]+1)},n.mobileYearDisabled=function(e){var t=L.years;return et[t.length-1]?!0:!1},n.getRawValue=function(){return t.value},n.getDate=function(){var e=L.getRawValue();return p(e)},n._afterYearRendered=function(){this.setAttribute("ms-widget",["dropdown",n.$yearVmId,"$yearOpts"].join(",")),this.setAttribute("ms-duplex","year"),e.scan(this,L)},n._afterMonthRendered=function(){this.setAttribute("ms-widget",["dropdown",n.$monthVmId,"$monthOpts"].join(",")),this.setAttribute("ms-duplex","_month"),e.scan(this,L)},n._selectDate=function(n,r,i,o){var u=e.filters.timer,a=L.month,l=L.year,p=y[i].rows[r][n],v=p.year,m=p.month,b=+p.day,w=p.dateDisabled;o.stopPropagation(),o.preventDefault();if(m!==!1&&!w&&!L.showDatepickerAlways){var E=new Date(v,m,b),S=d(E),x=s.type==="range"?t["data-calenderwrapper"]:null;L.tip=h(f(E)).text,L.dateError="#cccccc",!x&&!L.timer?(t.value=S,L.toggle=!1):(L.timer&&(S=S+" "+u(L.hour)+":"+u(L.minute)),t.value=S),m===a&&v===l&&L.day==b?L.$fire("day",b):L.day=b,m!==a&&v!==l?(g=!0,L.year=v,L.month=m):m!==a?L.month=m:v!==l&&(L.year=v)}if(!L.showDatepickerAlways&&!c){if(typeof L.onSelect=="string"){e.log("onSelect 回调必须是个function!");return}L.onSelect.call(null,S,L,e(t).data())}},n.setRegional=function(e){L.regional=e},n.$init=function(o){var u=t.parentNode,a=null;x=e.parseHTML(r).firstChild,u.insertBefore(x,t),u.insertBefore(t,x),e(t).attr("ms-css-width","width"),L.weekNames=P();if(t.tagName==="INPUT"&&L.type!=="range"){var l=document.createElement("div");l.className="oni-datepicker-input-wrapper",l.setAttribute("ms-class","oni-datepicker-active:toggle"),l.setAttribute("ms-css-border-color","dateError"),l.setAttribute("ms-hover","oni-state-hover"),u.insertBefore(l,t),l.appendChild(t);if(L.showTip){var c=e.parseHTML("
{{tip}}
");l.appendChild(c)}else t.style.paddingRight="0px";l.appendChild(x)}if(L.timer){L.width=100;var d=q(b);b&&d&&(b=L.getInitTime(d))}t.value=b;if(a=p(b))L.tip=h(f(a)).text;t.disabled=L.disabled,L.showDatepickerAlways?(t.style.display="none",L.toggle=!0,L._position="relative",l.style.borderWidth=0):_(x,l),s.type==="range"?(l=t["data-calenderwrapper"],L._position="static"):e.scan(l,[L]),n.rootElement=l,e.scan(x,[L].concat(i)),setTimeout(function(){B(L.month,L.year)},10),typeof s.onInit=="function"&&s.onInit.call(t,L,s,i)},n._getTitle=function(e,t){return L.regional.titleFormat.call(L.regional,e,t)},n.$remove=function(){var e=t.parentNode,n=e.parentNode,r=x.parentNode;x.innerHTML=x.textContent="",r.removeChild(x),n.removeChild(e)}});return h=h.bind(L),L.$watch("toggle",function(n){var r=t.value,i=p(r),s=i&&i.getFullYear(),o=i&&i.getMonth();if(n)L.elementMonth=o||-1,L.elementYear=s||-1;else{if(L.year!=s&&L.month!=o)if(!i){g=!0;var u=new Date,a=u.getFullYear(),f=u.getMonth();L.year==a&&L.month==f?F(L.month,L.year,L.day):L.year==a?L.month=f:L.month==f?L.year=a:(g=!0,L.year=a,L.month=f)}else g=!0,L.year=s,L.month=o;else L.year!=s?L.year=s:L.month!=o&&(L.month=o);e.vmodels[L.$yearVmId]&&(e.vmodels[L.$yearVmId].toggle=!1),e.vmodels[L.$monthVmId]&&(e.vmodels[L.$monthVmId].toggle=!1),L.onClose(new Date(L.year,L.month,L.day),L)}}),L.$watch("year",function(e){L.mobileMonthAndYear&&O(e),g?g=!1:F(L.month,e,L.day),L.onChangeMonthYear(e,L.month+1,L)}),L.changeMonthAndYear&&L.$watch("_month",function(e){L.month=e-1}),L.$watch("month",function(e){L._month=e+1,F(e,L.year,L.day),L.onChangeMonthYear(L.year,e,L)}),L.$watch("day",function(e,t){var n=y,r=L.month,i=L.year,s=!1,o,u,a;for(var f=0,l=n.length;f=0&&t<=9&&(e="0"+e),e},e}),require(["avalon","domReady!","./tab/avalon.tab.js","./pager/avalon.pager.js","./datepicker/avalon.datepicker.js"],function(){console.log("111"),avalon.define({$id:"demo"}),avalon.scan()}),define("main",function(){}),function(e){var t=document,n="appendChild",r="styleSheet",i=t.createElement("style");i.type="text/css",t.getElementsByTagName("head")[0][n](i),i[r]?i[r].cssText=e:i[n](t.createTextNode(e))}('@charset "UTF-8";\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\ndiv.oni-tab {\r\n border: none; }\r\n\r\n.oni-tab {\r\n /*dir=v, small size*/\r\n /*dir=v, normal size*/ }\r\n .oni-tab-slider {\r\n position: relative;\r\n overflow: hidden; }\r\n .oni-tab-slider-enable {\r\n width: 10000px; }\r\n .oni-tab-slider-button {\r\n text-decoration: none;\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n padding: 10px 4px;\r\n width: 8px;\r\n font-weight: bold;\r\n background: #ccc;\r\n z-index: 10;\r\n cursor: pointer;\r\n color: #000; }\r\n .oni-tab-slider-button-left {\r\n left: 0; }\r\n .oni-tab .oni-tab-nav {\r\n float: left; }\r\n .oni-tab .oni-tab-nav .oni-state-default {\r\n float: left;\r\n display: inline;\r\n list-style: none;\r\n text-align: center;\r\n font-size: 12px;\r\n padding: 10px 20px;\r\n position: relative;\r\n background-color: #f8f8f8;\r\n cursor: pointer;\r\n border: 1px solid #d4d4d4;\r\n border-right-width: 0;\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-default a, .oni-tab .oni-tab-nav .oni-state-default:link, .oni-tab .oni-tab-nav .oni-state-default a:hover {\r\n color: black;\r\n text-decoration: none;\r\n font-size: 12px; }\r\n .oni-tab .oni-tab-nav .oni-state-hover {\r\n color: black;\r\n background: white; }\r\n .oni-tab .oni-tab-nav .oni-state-hover a {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-hover a:link {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-hover .oni-tab-close {\r\n border-color: white; }\r\n .oni-tab .oni-tab-nav .oni-state-active {\r\n border-bottom-color: white;\r\n background: white;\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active a {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active a:link {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active .oni-tab-close {\r\n border-color: white; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled a {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled a:link {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-tab-last {\r\n border-right-width: 1px; }\r\n .oni-tab-small .oni-tab-nav .oni-state-default {\r\n border-right-width: 1px;\r\n margin-right: -1px;\r\n z-index: 1;\r\n padding: 7px 10px; }\r\n .oni-tab-small .oni-tab-nav .oni-state-active {\r\n border-color: #3775c0;\r\n z-index: 10; }\r\n .oni-tab-vertical .oni-tab-nav .oni-state-default {\r\n float: none;\r\n display: block;\r\n text-align: left;\r\n border-right-width: 1px;\r\n border-bottom-width: 0; }\r\n .oni-tab-vertical .oni-tab-nav .oni-state-active {\r\n border-right-color: white;\r\n border-bottom-color: #d4d4d4; }\r\n .oni-tab-vertical .oni-tab-nav .oni-tab-last {\r\n border-bottom-width: 1px; }\r\n .oni-tab-click .oni-state-default {\r\n cursor: pointer; }\r\n .oni-tab-removable {\r\n padding-right: 30px; }\r\n .oni-tab-nav .oni-tab-item .oni-tab-close {\r\n position: absolute;\r\n right: 0px;\r\n top: 7px;\r\n padding: 3px;\r\n height: 12px;\r\n width: 12px;\r\n overflow: hidden;\r\n border: 1px solid #f8f8f8;\r\n border-right-width: 0;\r\n color: #666666;\r\n text-indent: 0;\r\n line-height: 14px;\r\n font-family: Helvetica, Arial, sans-serif; }\r\n .oni-tab .oni-tab-nav .oni-state-active .oni-tab-close-hover {\r\n background: white;\r\n border-color: #d4d4d4;\r\n cursor: pointer; }\r\n .oni-tab .oni-tab-nav .oni-state-hover .oni-tab-close-hover {\r\n background: white;\r\n border-color: #d4d4d4;\r\n cursor: pointer; }\r\n\r\n/*\r\nchameleon\r\nby 司徒正美 2014.6.28 拉萨开往西宁的火车上\r\n这里放置所有组件都共用的类名,它们根据compass构建\r\n\r\noinui的CSS规范\r\n\r\n不能出现大写,以连字符风格命名 \r\n表示状态的应该用ui-state-*命名 \r\n表示功能的应该用ui-helper-*命名\r\n表示布局的应用用ui-uiname-* 命名, 它的子元素应该全部包在 .oni-uiname这个根类下\r\n如 .oni-grid .oni-grid-tbody{ ... }\r\n如果某一个区域的背景要换肤,能用ui-widget-header或ui-widget-content就尽用\r\n其他细微之后的换肤,使用ui-state-*-?-color实现,或至少包在if(oniui-theme === xxx){}分支内\r\n\r\n\r\n样式规则的出现顺序\r\n1 display float position overflow表示布局的样式\r\n2 width height line-height 表示尺寸的样式\r\n3 margin border padding 表示盒子模型的样式\r\n4 cursor font-size vertical-align text-align user-select outline....装饰用的样式\r\n5 color background 表示换肤的样式(上面的bordrer-color outline-color也可以放到这里)\r\n\r\n\r\nCSSShrink 是一个压缩 CSS 的在线工具。压缩比真高!\r\n\r\nhttp://cssshrink.com/\r\n*/\r\n.oni-helper-hidden {\r\n display: none; }\r\n\r\n.oni-helper-hidden-accessible {\r\n border: 0;\r\n clip: rect(0 0 0 0);\r\n height: 1px;\r\n margin: -1px;\r\n overflow: hidden;\r\n padding: 0;\r\n position: absolute;\r\n width: 1px; }\r\n\r\n.oni-helper-reset {\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n outline: 0;\r\n line-height: 1.3;\r\n text-decoration: none;\r\n font-size: 100%;\r\n list-style: none; }\r\n\r\n.oni-helper-noselect {\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none; }\r\n .oni-helper-noselect img, .oni-helper-noselect a {\r\n -webkit-user-drag: none;\r\n pointer-events: none; }\r\n\r\n.oni-helper-clearfix {\r\n *zoom: 1; }\r\n .oni-helper-clearfix:after {\r\n content: "\\0020";\r\n display: block;\r\n height: 0;\r\n clear: both;\r\n overflow: hidden;\r\n visibility: hidden; }\r\n\r\nhtml .oni-helper-max-index, body .oni-helper-max-index {\r\n z-index: 1000; }\r\n\r\n@font-face {\r\n font-family: fontawesome;\r\n font-style: normal;\r\n font-weight: normal;\r\n src: url("http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.eot?v=4.2.0");\r\n src: url("http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.eot?#iefix&v=4.2.0") format("embedded-opentype"), \r\n url("http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.woff?v=4.2.0") format("woff"), \r\n url("http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.ttf?v=4.2.0") format("truetype"), \r\n url("http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.svg?v=4.2.0#fontawesomeregular") format("svg");}\r\n.oni-icon {\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n cursor: default;\r\n font-family: fontawesome !important;\r\n font-size: 14px;\r\n -moz-osx-font-smoothing: grayscale;\r\n -webkit-font-smoothing: antialiased;\r\n font-style: normal;\r\n font-weight: normal;\r\n line-height: 18px;\r\n vertical-align: middle; }\r\n\r\na .oni-icon, .oni-btn .oni-icon {\r\n cursor: pointer; }\r\n\r\n.oni-state-error {\r\n border: 1px solid #ff8888; }\r\n\r\n.oni-pager {\r\n font: normal 12px/1.5 tahoma, arial, \'Hiragino Sans GB\', \'\\5b8b\\4f53\', sans-serif; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-pager {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle;\r\n white-space: nowrap;\r\n /*!省略掉的页数*/\r\n /*!页面跳转部分的样式*/\r\n /*!输入域的容器*/\r\n /*!输入域*/\r\n /*!里面的按钮的样式*/\r\n /*!里面的文本全部包在一个容器内,以便实现居中*/ }\r\n .oni-pager .oni-pager-items {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle; }\r\n .oni-pager .oni-pager-prev, .oni-pager .oni-pager-next, .oni-pager .oni-pager-item {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n background-color: white;\r\n color: #333;\r\n height: 24px;\r\n line-height: 24px;\r\n margin-right: 5px;\r\n border: 1px solid #d4d4d4;\r\n padding: 0 10px;\r\n -webkit-border-radius: 2px;\r\n -moz-border-radius: 2px;\r\n -ms-border-radius: 2px;\r\n -o-border-radius: 2px;\r\n border-radius: 2px;\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: middle;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n /*!当前页,没有边框*/\r\n /*!掠过*/\r\n /*!禁用*/ }\r\n .oni-pager .oni-pager-prev.oni-state-active, .oni-pager .oni-pager-next.oni-state-active, .oni-pager .oni-pager-item.oni-state-active {\r\n color: #ff8888;\r\n border: 0 none;\r\n padding: 1px 11px;\r\n cursor: default;\r\n background: transparent; }\r\n .oni-pager .oni-pager-prev.oni-state-hover, .oni-pager .oni-pager-next.oni-state-hover, .oni-pager .oni-pager-item.oni-state-hover {\r\n border-color: #ff8888; }\r\n .oni-pager .oni-pager-prev.oni-state-disabled, .oni-pager .oni-pager-next.oni-state-disabled, .oni-pager .oni-pager-item.oni-state-disabled {\r\n border-color: #d9d9d9;\r\n background-color: whitesmoke;\r\n color: #999999;\r\n cursor: default; }\r\n .oni-pager .oni-pager-omit {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n height: 24px;\r\n line-height: 24px;\r\n margin-right: 5px;\r\n padding: 1px 0;\r\n vertical-align: middle;\r\n font-size: 12px;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n cursor: default; }\r\n .oni-pager .oni-pager-jump {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle;\r\n padding-left: 5px;\r\n padding-right: 5px;\r\n vertical-align: middle; }\r\n .oni-pager .oni-pager-textbox-wrapper {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n width: 26px;\r\n margin-left: 5px;\r\n margin-right: 5px;\r\n padding: 3px 5px;\r\n vertical-align: middle;\r\n font-size: 0;\r\n outline: none;\r\n background-color: white;\r\n border: 1px solid #d4d4d4; }\r\n .oni-pager .oni-pager-textbox {\r\n display: inline;\r\n float: left;\r\n position: relative;\r\n width: 26px;\r\n height: 18px;\r\n line-height: 18px;\r\n padding: 0;\r\n border: 0 none;\r\n font-size: 12px;\r\n outline: medium none;\r\n vertical-align: middle;\r\n text-align: center;\r\n color: #333333;\r\n background: #fff; }\r\n .oni-pager .oni-pager-button {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n overflow: visible;\r\n _overflow-y: hidden;\r\n height: 26px;\r\n margin-left: 5px;\r\n border-radius: 2px;\r\n outline: none;\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: middle;\r\n padding: 0 10px;\r\n text-decoration: none;\r\n border: 1px solid #ccc;\r\n background-color: #f8f8f8;\r\n color: #333; }\r\n .oni-pager .oni-pager-button:hover {\r\n border-color: #bbb; }\r\n .oni-pager .oni-pager-text {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n font-size: 12px;\r\n vertical-align: middle; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\ndiv.oni-scrollbar {\r\n position: absolute;\r\n margin: 0;\r\n padding: 0;\r\n border: 0; }\r\n\r\n.oni-scrollbar {\r\n width: 10px;\r\n height: 100%;\r\n left: auto;\r\n right: 0;\r\n top: 0;\r\n bottom: auto;\r\n background: #f8f8f8;\r\n z-index: 100;\r\n transition: opacity .5s;\r\n -webkit-transition: opacity .5s;\r\n -moz-transition: opacity .5s;\r\n -o-transition: opacity .5s;\r\n -ms-transition: opacity .5s; }\r\n .oni-scrollbar-arrow {\r\n position: absolute;\r\n background: #eeeeee;\r\n top: 0;\r\n left: 0;\r\n width: 10px;\r\n height: 10px; }\r\n .oni-scrollbar-arrow b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 0 none;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 4px solid #bcbcbc;\r\n border-left: 4px dashed transparent;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n margin-top: -2px;\r\n margin-left: -4px;\r\n font-size: 0;\r\n line-height: 0; }\r\n div .oni-scrollbar-arrow-down {\r\n top: auto;\r\n bottom: 0; }\r\n div .oni-scrollbar-arrow-down b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px solid #bcbcbc;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 0;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar .oni-state-hover {\r\n background: #aaaaaa; }\r\n .oni-scrollbar .oni-state-active {\r\n background: #999999; }\r\n .oni-scrollbar .oni-state-disabled {\r\n background: #e9e9e9; }\r\n .oni-scrollbar-left .oni-state-active b.oni-scrollbar-trangle-up, .oni-scrollbar-right .oni-state-active b.oni-scrollbar-trangle-up {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 0 none;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 4px solid white;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar-left .oni-state-active b.oni-scrollbar-trangle-down, .oni-scrollbar-right .oni-state-active b.oni-scrollbar-trangle-down {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px solid white;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 0;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar-top .oni-state-active b.oni-scrollbar-trangle-up, .oni-scrollbar-bottom .oni-state-active b.oni-scrollbar-trangle-up {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 4px solid white;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 0; }\r\n .oni-scrollbar-top .oni-state-active b.oni-scrollbar-trangle-down, .oni-scrollbar-bottom .oni-state-active b.oni-scrollbar-trangle-down {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 0;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 4px solid white; }\r\n .oni-scrollbar-scroller {\r\n overflow: hidden; }\r\n .oni-scrollbar-left {\r\n left: 0;\r\n right: auto; }\r\n .oni-scrollbar-top {\r\n width: 100%;\r\n height: 10px;\r\n left: 0;\r\n top: 0;\r\n bottom: auto; }\r\n .oni-scrollbar-bottom {\r\n width: 100%;\r\n height: 10px;\r\n left: 0;\r\n top: auto;\r\n bottom: 0; }\r\n .oni-scrollbar-draggerpar {\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n width: 100%;\r\n height: 100%; }\r\n .oni-scrollbar-draggerpar .oni-scrollbar-dragger {\r\n position: absolute;\r\n width: 100%;\r\n left: 0;\r\n background: #cccccc; }\r\n .oni-scrollbar-draggerpar .oni-state-hover {\r\n background: #999999; }\r\n .oni-scrollbar-draggerpar .oni-state-active {\r\n background: #888888; }\r\n .oni-scrollbar-draggerpar .oni-state-disabled {\r\n background: #e9e9e9; }\r\n .oni-scrollbar-top .oni-scrollbar-ragger, .oni-scrollbar-bottom .oni-scrollbar-ragger {\r\n height: 100%;\r\n width: auto;\r\n top: 0; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow b, .oni-scrollbar-bottom .oni-scrollbar-arrow b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 4px solid #bcbcbc;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 0;\r\n margin-top: -4px;\r\n margin-left: -2px; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow-down, .oni-scrollbar-bottom .oni-scrollbar-arrow-down {\r\n right: 0;\r\n left: auto; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow-down b, .oni-scrollbar-bottom .oni-scrollbar-arrow-down b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 0;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 4px solid #bcbcbc; }\r\n\r\n.oni-scrollbar-large {\r\n width: 14px; }\r\n .oni-scrollbar-large .oni-scrollbar-arrow {\r\n width: 14px;\r\n height: 14px; }\r\n .oni-scrollbar-large .oni-scrollbar-top, .oni-scrollbar-large .oni-scrollbar-bottom {\r\n height: 14px; }\r\n\r\n.oni-scrollbar-bottom-large {\r\n height: 14px; }\r\n\r\n.oni-scrollbar-small {\r\n width: 8px; }\r\n .oni-scrollbar-small .oni-scrollbar-arrow {\r\n width: 8px;\r\n height: 8px; }\r\n\r\n.oni-scrollbar-bottom-small {\r\n height: 8px; }\r\n\r\n.ui-scrollbar-scroller {\r\n overflow: hidden; }\r\n\r\n.oni-dropdown {\r\n font: normal 12px/1.5 tahoma, arial, \'Hiragino Sans GB\', \'\\5b8b\\4f53\', sans-serif; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-dropdown {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n outline: none; }\r\n.oni-dropdown .oni-dropdown-source {\r\n border: 1px solid #cccccc;\r\n background-color: white;\r\n cursor: pointer; }\r\n.oni-dropdown .oni-dropdown-source .oni-dropdown-input {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n white-space: nowrap;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -ms-text-overflow: ellipsis;\r\n -o-text-overflow: ellipsis;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n height: 18px;\r\n padding: 3px 21px 3px 6px;\r\n word-break: normal;\r\n word-wrap: normal; }\r\n.oni-dropdown .oni-icon {\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: baseline; }\r\n.oni-dropdown.oni-state-hover .oni-dropdown-source {\r\n border-color: #999999; }\r\n.oni-dropdown.oni-state-focus .oni-dropdown-source {\r\n border-color: #3775c0; }\r\n.oni-dropdown.oni-state-disabled .oni-dropdown-source {\r\n background-color: whitesmoke;\r\n border-color: #d9d9d9;\r\n color: #cccccc;\r\n cursor: default; }\r\n.oni-dropdown.oni-state-disabled .oni-dropdown-icon {\r\n cursor: default; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-source {\r\n border-radius: 2px; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-input {\r\n padding-top: 1px;\r\n padding-bottom: 1px; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-icon {\r\n top: -19px; }\r\n.oni-dropdown.oni-state-error .oni-dropdown-source {\r\n border-color: #ff8888; }\r\n.oni-dropdown.oni-state-error:hover .oni-dropdown-source {\r\n border-color: #ff8888; }\r\n.oni-dropdown .oni-dropdown-icon {\r\n display: none;\r\n color: #b5b5b5;\r\n cursor: pointer;\r\n padding: 0 6px;\r\n position: absolute;\r\n right: 0;\r\n text-align: center;\r\n top: -21px; }\r\n.oni-dropdown .oni-dropdown-icon-wrap {\r\n display: block;\r\n position: relative;\r\n height: 0; }\r\n.oni-dropdown .oni-dropdown-icon-wrap .oni-icon-angle-down {\r\n display: block; }\r\n.oni-dropdown .oni-dropdown-icon-wrap .oni-icon-angle-up {\r\n display: block; }\r\n.oni-dropdown.oni-dropdown-menu {\r\n display: none;\r\n left: 0;\r\n position: absolute;\r\n top: -1px;\r\n width: 100%;\r\n _width: auto !important;\r\n z-index: 1001; }\r\n.oni-dropdown .oni-dropdown-menu-inner {\r\n box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.1);\r\n background-color: white;\r\n border: 1px solid #d4d4d4;\r\n overflow-y: scroll;\r\n padding: 3px 0; }\r\n.oni-dropdown .oni-dropdown-item {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -ms-text-overflow: ellipsis;\r\n -o-text-overflow: ellipsis;\r\n text-overflow: ellipsis;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n *zoom: 1;\r\n width: 100%;\r\n padding: 3px 0;\r\n height: 24px;\r\n line-height: 24px;\r\n text-indent: 20px;\r\n cursor: pointer;\r\n word-break: normal;\r\n word-wrap: normal; }\r\n.oni-dropdown .oni-dropdown-item.oni-dropdown-group {\r\n font-size: 14px;\r\n font-weight: bold;\r\n text-indent: 10px; }\r\n.oni-dropdown .oni-dropdown-item.oni-dropdown-divider {\r\n border-top: 1px solid #f2f2f2; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-disabled {\r\n border-color: #d9d9d9;\r\n background-color: whitesmoke;\r\n color: #999999; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-hover {\r\n border-color: #f8f8f8;\r\n background-color: #f8f8f8;\r\n color: black; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-active {\r\n border-color: #3775c0;\r\n background-color: #3775c0;\r\n color: white; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-active .oni-icon {\r\n color: white; }\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-slider { position: relative; text-align: left; display: -moz-inline-stack; display: inline-block; vertical-align: middle; *vertical-align: auto; zoom: 1; *display: inline; width: 100%; background: #e6e6e6; }\r\n.oni-slider .oni-helper-hidden-accessible { position: absolute; height: 1px; width: 1px; overflow: hidden; border: 0 none; margin: -1px; padding: 0; clip: rect(0px 0px 0px 0px); }\r\n.oni-slider .oni-corner-all { -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; }\r\n.oni-slider .oni-slider-handle { position: absolute; display: block; cursor: default; height: 14px; width: 14px; line-height: 0px; z-index: 2; -webkit-border-radius: 7px; -moz-border-radius: 7px; -ms-border-radius: 7px; -o-border-radius: 7px; border-radius: 7px; font-size: 0px; background: #3775c0; }\r\n.oni-slider .oni-slider-handle.oni-state-hover { background: #82aadb; }\r\n.oni-slider .oni-slider-handle.oni-state-active, .oni-slider .oni-slider-handle.oni-state-focus { background: #22dddd; }\r\n.oni-slider .oni-slider-range { position: absolute; display: block; z-index: 1; line-height: 0px; border: 0 none; font-size: 0px; background: #afd9fc; }\r\n.oni-slider.oni-slider-vertical { height: 100px; width: 8px; }\r\n.oni-slider.oni-slider-vertical .oni-slider-handle { left: -3px; margin-bottom: -7px; margin-left: 0; margin-top: -7px; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range { left: 0; width: 100%; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range.oni-slider-range-min { bottom: 0; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range.oni-slider-range-max { top: 0; }\r\n.oni-slider.oni-slider-horizontal { height: 8px; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-handle { margin-left: -7px; top: -3px; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range { height: 100%; top: 0; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range.oni-slider-range-min { left: 0; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range.oni-slider-range-max { right: 0; }\r\n.oni-slider.oni-state-disabled .oni-slider-handle, .oni-slider.oni-state-disabled .oni-slider-range { background: #ccc; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-datepicker { position: relative; display: block; font-size: 0; white-space: nowrap; color: #333; z-index: 10; width: auto; margin-left: -1px; }\r\n.oni-datepicker tr, .oni-datepicker td, .oni-datepicker th { border: 0; }\r\n.oni-datepicker .oni-icon { text-indent: 0; }\r\n.oni-datepicker .oni-icon-calendar-o { padding: 0 6px; vertical-align: top; text-indent: 0; display: inline; }\r\n.oni-datepicker .oni-dropdown-source { margin-top: -2px; *margin-top: 0; }\r\n.oni-datepicker .oni-dropdown-source .oni-dropdown-input { padding: 0 21px 0 6px; line-height: 20px; height: 20px; }\r\n.oni-datepicker .oni-dropdown-source .oni-dropdown-icon { top: -20px; line-height: 20px; }\r\n\r\n.oni-datepicker-wrapper { padding: 9px 0 9px 10px; border: 1px solid #cccccc; box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.1); position: absolute; background: #fff; }\r\n\r\n.oni-datepicker-content { border: 1px solid #e5e5e5; font-size: 12px; margin-right: 10px; background: #fff; }\r\n\r\n.oni-datepicker-label { background-color: #f8f8f8; border-bottom: 1px solid #e5e5e5; font-weight: 700; padding: 7px 0; text-align: center; }\r\n\r\n.oni-datepicker-timer { border-top: 1px solid #efefef; padding: 5px 0; }\r\n.oni-datepicker-timer .oni-btn { height: 26px; overflow: visible; _overflow-y: hidden; padding: 0 10px; -webkit-border-radius: 2px; -moz-border-radius: 2px; -ms-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; font-size: 12px; color: #333333; background-color: #f8f8f8; border: 1px solid #cccccc; cursor: pointer; }\r\n.oni-datepicker-timer .oni-btn:hover { box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.1); background-color: #f8f8f8; border-color: #bbbbbb; color: #333333; }\r\n.oni-datepicker-timer .oni-btn-small { height: 22px; padding: 0 5px; font-size: 12px; }\r\n.oni-datepicker-timer p, .oni-datepicker-timer label { margin: 0; }\r\n.oni-datepicker-timer p span, .oni-datepicker-timer label span { display: -moz-inline-stack; display: inline-block; vertical-align: middle; *vertical-align: auto; zoom: 1; *display: inline; width: 50px; }\r\n\r\n.oni-datepicker-content-content { padding: 0 10px; width: 196px; position: relative; display: -moz-inline-stack; display: inline-block; vertical-align: middle; *vertical-align: auto; zoom: 1; *display: inline; white-space: normal; word-break: break-word; }\r\n\r\n.oni-datepicker-watermark { position: absolute; top: 60px; left: 10px; width: 196px; height: 150px; background: transparent; color: #000; _color: #f2f2f2; filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=5); opacity: 0.05; font-size: 150px; line-height: 150px; text-align: center; }\r\n\r\n.oni-datepicker-month-year span { display: block; width: 23%; height: 42px; line-height: 42px; float: left; margin: 1%; cursor: pointer; text-align: center; _margin-left: -1px; }\r\n.oni-datepicker-month-year .oni-datepicker-prev, .oni-datepicker-month-year .oni-datepicker-next { height: auto; line-height: auto; position: relative; width: auto; }\r\n.oni-datepicker-month-year .oni-datepicker-day-hover { background: #dbebff; }\r\n.oni-datepicker-month-year .oni-datepicker-selected { background: #3775c0; color: #fff; }\r\n.oni-datepicker-month-year .oni-datepicker-prev-year, .oni-datepicker-month-year .oni-datepicker-next-year { color: #999999; }\r\n.oni-datepicker-month-year .oni-state-disabled { color: #cccccc; cursor: default; background: transparent; }\r\n\r\n.oni-datepicker-header { position: relative; height: 30px; line-height: 30px; }\r\n\r\n.oni-datepicker .oni-datepicker-prev, .oni-datepicker .oni-datepicker-next { color: #3775c0; cursor: pointer; height: 30px; line-height: 30px; position: absolute; text-align: center; width: 20px; z-index: 1; }\r\n\r\n.oni-datepicker .oni-datepicker-prev { left: 0; }\r\n\r\n.oni-datepicker .oni-datepicker-next { right: 0; }\r\n\r\n.oni-datepicker-content-content .oni-datepicker-prev { left: 0; top: 0; }\r\n\r\n.oni-datepicker-content-content .oni-datepicker-next { right: 0; top: 0; }\r\n\r\n.oni-datepicker .oni-datepicker-prev-disabled, .oni-datepicker .oni-datepicker-next-disabled { color: #cccccc; cursor: default; }\r\n\r\n.oni-datepicker-title { color: #3775c0; font-weight: 700; text-align: center; }\r\n.oni-datepicker-title span.oni-state-hover { background: #dbebff; padding: 5px 10px; }\r\n\r\n.oni-datepicker-calendar-days { height: 150px; position: relative; z-index: 20; }\r\n\r\n.oni-datepicker-calendar-week, .oni-datepicker-calendar-days { border-collapse: collapse; margin-bottom: 5px; table-layout: fixed; width: 100%; border-spacing: 0; }\r\n\r\n.oni-datepicker-calendar-week th { border-bottom: 1px solid #efefef; border-top: 1px solid #efefef; padding: 3px 0; text-align: center; line-height: 18px; font-weight: 400; font-size: 12px; }\r\n\r\n.oni-datepicker-week-end, .oni-datepicker-calendar-days .oni-datepicker-week-end { color: #ff5555; }\r\n\r\n.oni-datepicker-calendar-days td { color: #333333; cursor: pointer; text-align: center; line-height: 18px; padding: 3px 0; background: transparent; }\r\n\r\n.oni-datepicker-default { background: #fff; }\r\n\r\n.oni-datepicker-calendar-days .oni-datepicker-day-hover { background: #dbebff; }\r\n\r\n.oni-datepicker-today { font-family: pmingliu, arial, sans-serif; font-size: 11px; }\r\n\r\n@media screen and (-webkit-transform-2d: 1) { .oni-datepicker-today { /* font-size: 12px; */ -webkit-transform: scale(0.91667); } }\r\n.oni-datepicker-day-none { cursor: auto; }\r\n\r\n.oni-datepicker-calendar-days .oni-datepicker-selected { background: #3775c0; color: #fff; }\r\n\r\n.oni-datepicker-calendar-days .oni-state-disabled { color: #cccccc; cursor: default; background: transparent; }\r\n\r\n.oni-datepicker-multiple .oni-datepicker-content { border-right: 0; }\r\n.oni-datepicker-multiple .oni-datepicker-content-content { border-right: 1px solid #e5e5e5; }\r\n\r\n.oni-datepicker-dropdown .oni-dropdown-item { color: #333333; font-size: 12px; padding: 0; text-indent: 0; text-align: center; }\r\n.oni-datepicker-dropdown .oni-dropdown-item-hover { background: #f5f5f5; }\r\n.oni-datepicker-dropdown .oni-dropdown-item-selected { background: #3775c0; }\r\n.oni-datepicker-dropdown .oni-dropdown:hover .oni-dropdown-source { border-color: #3775c0; border-bottom-color: #cccccc; }\r\n\r\n.oni-datepicker-input-wrapper { background: #ffffff; border: 1px solid #cccccc; cursor: pointer; color: #333; font-size: 12px; position: relative; display: inline-block; *display: inline; zoom: 1; z-index: 1; }\r\n.oni-datepicker-input-wrapper input { border: 0 none; cursor: pointer; outline: none; padding: 3px 90px 3px 6px; width: 90px; height: 18px; margin: 0; font-size: 12px; }\r\n\r\n.oni-datepicker-tip { position: absolute; top: 3px; right: 10px; line-height: 18px; height: 18px; color: #b5b5b5; }\r\n\r\n.oni-datepicker-active { border-color: #3775c0; }\r\n'); \ No newline at end of file +(function(c){var d=document,a='appendChild',i='styleSheet',s=d.createElement('style');s.type='text/css';d.getElementsByTagName('head')[0][a](s);s[i]?s[i].cssText=c:s[a](d.createTextNode(c));}) +('@charset \"UTF-8\";\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\ndiv.oni-tab {\r\n border: none; }\r\n\r\n.oni-tab {\r\n /*dir=v, small size*/\r\n /*dir=v, normal size*/ }\r\n .oni-tab-slider {\r\n position: relative;\r\n overflow: hidden; }\r\n .oni-tab-slider-enable {\r\n width: 10000px; }\r\n .oni-tab-slider-button {\r\n text-decoration: none;\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n padding: 10px 4px;\r\n width: 8px;\r\n font-weight: bold;\r\n background: #ccc;\r\n z-index: 10;\r\n cursor: pointer;\r\n color: #000; }\r\n .oni-tab-slider-button-left {\r\n left: 0; }\r\n .oni-tab .oni-tab-nav {\r\n float: left; }\r\n .oni-tab .oni-tab-nav .oni-state-default {\r\n float: left;\r\n display: inline;\r\n list-style: none;\r\n text-align: center;\r\n font-size: 12px;\r\n padding: 10px 20px;\r\n position: relative;\r\n background-color: #f8f8f8;\r\n cursor: pointer;\r\n border: 1px solid #d4d4d4;\r\n border-right-width: 0;\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-default a, .oni-tab .oni-tab-nav .oni-state-default:link, .oni-tab .oni-tab-nav .oni-state-default a:hover {\r\n color: black;\r\n text-decoration: none;\r\n font-size: 12px; }\r\n .oni-tab .oni-tab-nav .oni-state-hover {\r\n color: black;\r\n background: white; }\r\n .oni-tab .oni-tab-nav .oni-state-hover a {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-hover a:link {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-hover .oni-tab-close {\r\n border-color: white; }\r\n .oni-tab .oni-tab-nav .oni-state-active {\r\n border-bottom-color: white;\r\n background: white;\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active a {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active a:link {\r\n color: black; }\r\n .oni-tab .oni-tab-nav .oni-state-active .oni-tab-close {\r\n border-color: white; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled a {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-state-disabled a:link {\r\n color: #999999;\r\n cursor: default; }\r\n .oni-tab .oni-tab-nav .oni-tab-last {\r\n border-right-width: 1px; }\r\n .oni-tab-small .oni-tab-nav .oni-state-default {\r\n border-right-width: 1px;\r\n margin-right: -1px;\r\n z-index: 1;\r\n padding: 7px 10px; }\r\n .oni-tab-small .oni-tab-nav .oni-state-active {\r\n border-color: #3775c0;\r\n z-index: 10; }\r\n .oni-tab-vertical .oni-tab-nav .oni-state-default {\r\n float: none;\r\n display: block;\r\n text-align: left;\r\n border-right-width: 1px;\r\n border-bottom-width: 0; }\r\n .oni-tab-vertical .oni-tab-nav .oni-state-active {\r\n border-right-color: white;\r\n border-bottom-color: #d4d4d4; }\r\n .oni-tab-vertical .oni-tab-nav .oni-tab-last {\r\n border-bottom-width: 1px; }\r\n .oni-tab-click .oni-state-default {\r\n cursor: pointer; }\r\n .oni-tab-removable {\r\n padding-right: 30px; }\r\n .oni-tab-nav .oni-tab-item .oni-tab-close {\r\n position: absolute;\r\n right: 0px;\r\n top: 7px;\r\n padding: 3px;\r\n height: 12px;\r\n width: 12px;\r\n overflow: hidden;\r\n border: 1px solid #f8f8f8;\r\n border-right-width: 0;\r\n color: #666666;\r\n text-indent: 0;\r\n line-height: 14px;\r\n font-family: Helvetica, Arial, sans-serif; }\r\n .oni-tab .oni-tab-nav .oni-state-active .oni-tab-close-hover {\r\n background: white;\r\n border-color: #d4d4d4;\r\n cursor: pointer; }\r\n .oni-tab .oni-tab-nav .oni-state-hover .oni-tab-close-hover {\r\n background: white;\r\n border-color: #d4d4d4;\r\n cursor: pointer; }\r\n\r\n/*\r\nchameleon\r\nby 司徒正美 2014.6.28 拉萨开往西宁的火车上\r\n这里放置所有组件都共用的类名,它们根据compass构建\r\n\r\noinui的CSS规范\r\n\r\n不能出现大写,以连字符风格命名 \r\n表示状态的应该用ui-state-*命名 \r\n表示功能的应该用ui-helper-*命名\r\n表示布局的应用用ui-uiname-* 命名, 它的子元素应该全部包在 .oni-uiname这个根类下\r\n如 .oni-grid .oni-grid-tbody{ ... }\r\n如果某一个区域的背景要换肤,能用ui-widget-header或ui-widget-content就尽用\r\n其他细微之后的换肤,使用ui-state-*-?-color实现,或至少包在if(oniui-theme === xxx){}分支内\r\n\r\n\r\n样式规则的出现顺序\r\n1 display float position overflow表示布局的样式\r\n2 width height line-height 表示尺寸的样式\r\n3 margin border padding 表示盒子模型的样式\r\n4 cursor font-size vertical-align text-align user-select outline....装饰用的样式\r\n5 color background 表示换肤的样式(上面的bordrer-color outline-color也可以放到这里)\r\n\r\n\r\nCSSShrink 是一个压缩 CSS 的在线工具。压缩比真高!\r\n\r\nhttp://cssshrink.com/\r\n*/\r\n.oni-helper-hidden {\r\n display: none; }\r\n\r\n.oni-helper-hidden-accessible {\r\n border: 0;\r\n clip: rect(0 0 0 0);\r\n height: 1px;\r\n margin: -1px;\r\n overflow: hidden;\r\n padding: 0;\r\n position: absolute;\r\n width: 1px; }\r\n\r\n.oni-helper-reset {\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n outline: 0;\r\n line-height: 1.3;\r\n text-decoration: none;\r\n font-size: 100%;\r\n list-style: none; }\r\n\r\n.oni-helper-noselect {\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none; }\r\n .oni-helper-noselect img, .oni-helper-noselect a {\r\n -webkit-user-drag: none;\r\n pointer-events: none; }\r\n\r\n.oni-helper-clearfix {\r\n *zoom: 1; }\r\n .oni-helper-clearfix:after {\r\n content: \"\\0020\";\r\n display: block;\r\n height: 0;\r\n clear: both;\r\n overflow: hidden;\r\n visibility: hidden; }\r\n\r\nhtml .oni-helper-max-index, body .oni-helper-max-index {\r\n z-index: 1000; }\r\n\r\n@font-face {\r\n font-family: fontawesome;\r\n font-style: normal;\r\n font-weight: normal;\r\n src: url(\"http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.eot?v=4.2.0\");\r\n src: url(\"http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.eot?#iefix&v=4.2.0\") format(\"embedded-opentype\"), \r\n url(\"http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.woff?v=4.2.0\") format(\"woff\"), \r\n url(\"http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.ttf?v=4.2.0\") format(\"truetype\"), \r\n url(\"http://source.qunarzz.com/fonts/oniui/0.0.3/oniui-webfont.svg?v=4.2.0#fontawesomeregular\") format(\"svg\");}\r\n.oni-icon {\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n cursor: default;\r\n font-family: fontawesome !important;\r\n font-size: 14px;\r\n -moz-osx-font-smoothing: grayscale;\r\n -webkit-font-smoothing: antialiased;\r\n font-style: normal;\r\n font-weight: normal;\r\n line-height: 18px;\r\n vertical-align: middle; }\r\n\r\na .oni-icon, .oni-btn .oni-icon {\r\n cursor: pointer; }\r\n\r\n.oni-state-error {\r\n border: 1px solid #ff8888; }\r\n\r\n.oni-pager {\r\n font: normal 12px/1.5 tahoma, arial, \'Hiragino Sans GB\', \'\\5b8b\\4f53\', sans-serif; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-pager {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle;\r\n white-space: nowrap;\r\n /*!省略掉的页数*/\r\n /*!页面跳转部分的样式*/\r\n /*!输入域的容器*/\r\n /*!输入域*/\r\n /*!里面的按钮的样式*/\r\n /*!里面的文本全部包在一个容器内,以便实现居中*/ }\r\n .oni-pager .oni-pager-items {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle; }\r\n .oni-pager .oni-pager-prev, .oni-pager .oni-pager-next, .oni-pager .oni-pager-item {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n background-color: white;\r\n color: #333;\r\n height: 24px;\r\n line-height: 24px;\r\n margin-right: 5px;\r\n border: 1px solid #d4d4d4;\r\n padding: 0 10px;\r\n -webkit-border-radius: 2px;\r\n -moz-border-radius: 2px;\r\n -ms-border-radius: 2px;\r\n -o-border-radius: 2px;\r\n border-radius: 2px;\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: middle;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n /*!当前页,没有边框*/\r\n /*!掠过*/\r\n /*!禁用*/ }\r\n .oni-pager .oni-pager-prev.oni-state-active, .oni-pager .oni-pager-next.oni-state-active, .oni-pager .oni-pager-item.oni-state-active {\r\n color: #ff8888;\r\n border: 0 none;\r\n padding: 1px 11px;\r\n cursor: default;\r\n background: transparent; }\r\n .oni-pager .oni-pager-prev.oni-state-hover, .oni-pager .oni-pager-next.oni-state-hover, .oni-pager .oni-pager-item.oni-state-hover {\r\n border-color: #ff8888; }\r\n .oni-pager .oni-pager-prev.oni-state-disabled, .oni-pager .oni-pager-next.oni-state-disabled, .oni-pager .oni-pager-item.oni-state-disabled {\r\n border-color: #d9d9d9;\r\n background-color: whitesmoke;\r\n color: #999999;\r\n cursor: default; }\r\n .oni-pager .oni-pager-omit {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n height: 24px;\r\n line-height: 24px;\r\n margin-right: 5px;\r\n padding: 1px 0;\r\n vertical-align: middle;\r\n font-size: 12px;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n cursor: default; }\r\n .oni-pager .oni-pager-jump {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n vertical-align: middle;\r\n padding-left: 5px;\r\n padding-right: 5px;\r\n vertical-align: middle; }\r\n .oni-pager .oni-pager-textbox-wrapper {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n width: 26px;\r\n margin-left: 5px;\r\n margin-right: 5px;\r\n padding: 3px 5px;\r\n vertical-align: middle;\r\n font-size: 0;\r\n outline: none;\r\n background-color: white;\r\n border: 1px solid #d4d4d4; }\r\n .oni-pager .oni-pager-textbox {\r\n display: inline;\r\n float: left;\r\n position: relative;\r\n width: 26px;\r\n height: 18px;\r\n line-height: 18px;\r\n padding: 0;\r\n border: 0 none;\r\n font-size: 12px;\r\n outline: medium none;\r\n vertical-align: middle;\r\n text-align: center;\r\n color: #333333;\r\n background: #fff; }\r\n .oni-pager .oni-pager-button {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n overflow: visible;\r\n _overflow-y: hidden;\r\n height: 26px;\r\n margin-left: 5px;\r\n border-radius: 2px;\r\n outline: none;\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: middle;\r\n padding: 0 10px;\r\n text-decoration: none;\r\n border: 1px solid #ccc;\r\n background-color: #f8f8f8;\r\n color: #333; }\r\n .oni-pager .oni-pager-button:hover {\r\n border-color: #bbb; }\r\n .oni-pager .oni-pager-text {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n font-size: 12px;\r\n vertical-align: middle; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\ndiv.oni-scrollbar {\r\n position: absolute;\r\n margin: 0;\r\n padding: 0;\r\n border: 0; }\r\n\r\n.oni-scrollbar {\r\n width: 10px;\r\n height: 100%;\r\n left: auto;\r\n right: 0;\r\n top: 0;\r\n bottom: auto;\r\n background: #f8f8f8;\r\n z-index: 100;\r\n transition: opacity .5s;\r\n -webkit-transition: opacity .5s;\r\n -moz-transition: opacity .5s;\r\n -o-transition: opacity .5s;\r\n -ms-transition: opacity .5s; }\r\n .oni-scrollbar-arrow {\r\n position: absolute;\r\n background: #eeeeee;\r\n top: 0;\r\n left: 0;\r\n width: 10px;\r\n height: 10px; }\r\n .oni-scrollbar-arrow b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 0 none;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 4px solid #bcbcbc;\r\n border-left: 4px dashed transparent;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n margin-top: -2px;\r\n margin-left: -4px;\r\n font-size: 0;\r\n line-height: 0; }\r\n div .oni-scrollbar-arrow-down {\r\n top: auto;\r\n bottom: 0; }\r\n div .oni-scrollbar-arrow-down b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px solid #bcbcbc;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 0;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar .oni-state-hover {\r\n background: #aaaaaa; }\r\n .oni-scrollbar .oni-state-active {\r\n background: #999999; }\r\n .oni-scrollbar .oni-state-disabled {\r\n background: #e9e9e9; }\r\n .oni-scrollbar-left .oni-state-active b.oni-scrollbar-trangle-up, .oni-scrollbar-right .oni-state-active b.oni-scrollbar-trangle-up {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 0 none;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 4px solid white;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar-left .oni-state-active b.oni-scrollbar-trangle-down, .oni-scrollbar-right .oni-state-active b.oni-scrollbar-trangle-down {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px solid white;\r\n border-right: 4px dashed transparent;\r\n border-bottom: 0;\r\n border-left: 4px dashed transparent; }\r\n .oni-scrollbar-top .oni-state-active b.oni-scrollbar-trangle-up, .oni-scrollbar-bottom .oni-state-active b.oni-scrollbar-trangle-up {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 4px solid white;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 0; }\r\n .oni-scrollbar-top .oni-state-active b.oni-scrollbar-trangle-down, .oni-scrollbar-bottom .oni-state-active b.oni-scrollbar-trangle-down {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 0;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 4px solid white; }\r\n .oni-scrollbar-scroller {\r\n overflow: hidden; }\r\n .oni-scrollbar-left {\r\n left: 0;\r\n right: auto; }\r\n .oni-scrollbar-top {\r\n width: 100%;\r\n height: 10px;\r\n left: 0;\r\n top: 0;\r\n bottom: auto; }\r\n .oni-scrollbar-bottom {\r\n width: 100%;\r\n height: 10px;\r\n left: 0;\r\n top: auto;\r\n bottom: 0; }\r\n .oni-scrollbar-draggerpar {\r\n position: absolute;\r\n left: 0;\r\n top: 0;\r\n width: 100%;\r\n height: 100%; }\r\n .oni-scrollbar-draggerpar .oni-scrollbar-dragger {\r\n position: absolute;\r\n width: 100%;\r\n left: 0;\r\n background: #cccccc; }\r\n .oni-scrollbar-draggerpar .oni-state-hover {\r\n background: #999999; }\r\n .oni-scrollbar-draggerpar .oni-state-active {\r\n background: #888888; }\r\n .oni-scrollbar-draggerpar .oni-state-disabled {\r\n background: #e9e9e9; }\r\n .oni-scrollbar-top .oni-scrollbar-ragger, .oni-scrollbar-bottom .oni-scrollbar-ragger {\r\n height: 100%;\r\n width: auto;\r\n top: 0; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow b, .oni-scrollbar-bottom .oni-scrollbar-arrow b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 4px solid #bcbcbc;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 0;\r\n margin-top: -4px;\r\n margin-left: -2px; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow-down, .oni-scrollbar-bottom .oni-scrollbar-arrow-down {\r\n right: 0;\r\n left: auto; }\r\n .oni-scrollbar-top .oni-scrollbar-arrow-down b, .oni-scrollbar-bottom .oni-scrollbar-arrow-down b {\r\n width: 0;\r\n height: 0;\r\n line-height: 0;\r\n font-size: 0;\r\n border-top: 4px dashed transparent;\r\n border-right: 0;\r\n border-bottom: 4px dashed transparent;\r\n border-left: 4px solid #bcbcbc; }\r\n\r\n.oni-scrollbar-large {\r\n width: 14px; }\r\n .oni-scrollbar-large .oni-scrollbar-arrow {\r\n width: 14px;\r\n height: 14px; }\r\n .oni-scrollbar-large .oni-scrollbar-top, .oni-scrollbar-large .oni-scrollbar-bottom {\r\n height: 14px; }\r\n\r\n.oni-scrollbar-bottom-large {\r\n height: 14px; }\r\n\r\n.oni-scrollbar-small {\r\n width: 8px; }\r\n .oni-scrollbar-small .oni-scrollbar-arrow {\r\n width: 8px;\r\n height: 8px; }\r\n\r\n.oni-scrollbar-bottom-small {\r\n height: 8px; }\r\n\r\n.ui-scrollbar-scroller {\r\n overflow: hidden; }\r\n\r\n.oni-dropdown {\r\n font: normal 12px/1.5 tahoma, arial, \'Hiragino Sans GB\', \'\\5b8b\\4f53\', sans-serif; }\r\n\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-dropdown {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n outline: none; }\r\n.oni-dropdown .oni-dropdown-source {\r\n border: 1px solid #cccccc;\r\n background-color: white;\r\n cursor: pointer; }\r\n.oni-dropdown .oni-dropdown-source .oni-dropdown-input {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n white-space: nowrap;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -ms-text-overflow: ellipsis;\r\n -o-text-overflow: ellipsis;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n height: 18px;\r\n padding: 3px 21px 3px 6px;\r\n word-break: normal;\r\n word-wrap: normal; }\r\n.oni-dropdown .oni-icon {\r\n cursor: pointer;\r\n font-size: 12px;\r\n vertical-align: baseline; }\r\n.oni-dropdown.oni-state-hover .oni-dropdown-source {\r\n border-color: #999999; }\r\n.oni-dropdown.oni-state-focus .oni-dropdown-source {\r\n border-color: #3775c0; }\r\n.oni-dropdown.oni-state-disabled .oni-dropdown-source {\r\n background-color: whitesmoke;\r\n border-color: #d9d9d9;\r\n color: #cccccc;\r\n cursor: default; }\r\n.oni-dropdown.oni-state-disabled .oni-dropdown-icon {\r\n cursor: default; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-source {\r\n border-radius: 2px; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-input {\r\n padding-top: 1px;\r\n padding-bottom: 1px; }\r\n.oni-dropdown.oni-state-small .oni-dropdown-icon {\r\n top: -19px; }\r\n.oni-dropdown.oni-state-error .oni-dropdown-source {\r\n border-color: #ff8888; }\r\n.oni-dropdown.oni-state-error:hover .oni-dropdown-source {\r\n border-color: #ff8888; }\r\n.oni-dropdown .oni-dropdown-icon {\r\n display: none;\r\n color: #b5b5b5;\r\n cursor: pointer;\r\n padding: 0 6px;\r\n position: absolute;\r\n right: 0;\r\n text-align: center;\r\n top: -21px; }\r\n.oni-dropdown .oni-dropdown-icon-wrap {\r\n display: block;\r\n position: relative;\r\n height: 0; }\r\n.oni-dropdown .oni-dropdown-icon-wrap .oni-icon-angle-down {\r\n display: block; }\r\n.oni-dropdown .oni-dropdown-icon-wrap .oni-icon-angle-up {\r\n display: block; }\r\n.oni-dropdown.oni-dropdown-menu {\r\n display: none;\r\n left: 0;\r\n position: absolute;\r\n top: -1px;\r\n width: 100%;\r\n _width: auto !important;\r\n z-index: 1001; }\r\n.oni-dropdown .oni-dropdown-menu-inner {\r\n box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.1);\r\n background-color: white;\r\n border: 1px solid #d4d4d4;\r\n overflow-y: scroll;\r\n padding: 3px 0; }\r\n.oni-dropdown .oni-dropdown-item {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -ms-text-overflow: ellipsis;\r\n -o-text-overflow: ellipsis;\r\n text-overflow: ellipsis;\r\n -webkit-touch-callout: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n user-select: none;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n *zoom: 1;\r\n width: 100%;\r\n padding: 3px 0;\r\n height: 24px;\r\n line-height: 24px;\r\n text-indent: 20px;\r\n cursor: pointer;\r\n word-break: normal;\r\n word-wrap: normal; }\r\n.oni-dropdown .oni-dropdown-item.oni-dropdown-group {\r\n font-size: 14px;\r\n font-weight: bold;\r\n text-indent: 10px; }\r\n.oni-dropdown .oni-dropdown-item.oni-dropdown-divider {\r\n border-top: 1px solid #f2f2f2; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-disabled {\r\n border-color: #d9d9d9;\r\n background-color: whitesmoke;\r\n color: #999999; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-hover {\r\n border-color: #f8f8f8;\r\n background-color: #f8f8f8;\r\n color: black; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-active {\r\n border-color: #3775c0;\r\n background-color: #3775c0;\r\n color: white; }\r\n.oni-dropdown .oni-dropdown-item.oni-state-active .oni-icon {\r\n color: white; }\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-slider { position: relative; text-align: left; display: -moz-inline-stack; display: inline-block; vertical-align: middle; *vertical-align: auto; zoom: 1; *display: inline; width: 100%; background: #e6e6e6; }\r\n.oni-slider .oni-helper-hidden-accessible { position: absolute; height: 1px; width: 1px; overflow: hidden; border: 0 none; margin: -1px; padding: 0; clip: rect(0px 0px 0px 0px); }\r\n.oni-slider .oni-corner-all { -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; }\r\n.oni-slider .oni-slider-handle { position: absolute; display: block; cursor: default; height: 14px; width: 14px; line-height: 0px; z-index: 2; -webkit-border-radius: 7px; -moz-border-radius: 7px; -ms-border-radius: 7px; -o-border-radius: 7px; border-radius: 7px; font-size: 0px; background: #3775c0; }\r\n.oni-slider .oni-slider-handle.oni-state-hover { background: #82aadb; }\r\n.oni-slider .oni-slider-handle.oni-state-active, .oni-slider .oni-slider-handle.oni-state-focus { background: #22dddd; }\r\n.oni-slider .oni-slider-range { position: absolute; display: block; z-index: 1; line-height: 0px; border: 0 none; font-size: 0px; background: #afd9fc; }\r\n.oni-slider.oni-slider-vertical { height: 100px; width: 8px; }\r\n.oni-slider.oni-slider-vertical .oni-slider-handle { left: -3px; margin-bottom: -7px; margin-left: 0; margin-top: -7px; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range { left: 0; width: 100%; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range.oni-slider-range-min { bottom: 0; }\r\n.oni-slider.oni-slider-vertical .oni-slider-range.oni-slider-range-max { top: 0; }\r\n.oni-slider.oni-slider-horizontal { height: 8px; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-handle { margin-left: -7px; top: -3px; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range { height: 100%; top: 0; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range.oni-slider-range-min { left: 0; }\r\n.oni-slider.oni-slider-horizontal .oni-slider-range.oni-slider-range-max { right: 0; }\r\n.oni-slider.oni-state-disabled .oni-slider-handle, .oni-slider.oni-state-disabled .oni-slider-range { background: #ccc; }\r\n@charset \"UTF-8\";\r\n/*\r\n这是每个都组件都应该引用的部分\r\n*/\r\n.oni-datepicker {\r\n position: relative;\r\n display: block;\r\n font-size: 0;\r\n white-space: nowrap;\r\n color: #333;\r\n z-index: 10;\r\n width: auto;\r\n margin-left: -1px; }\r\n .oni-datepicker tr, .oni-datepicker td, .oni-datepicker th {\r\n border: 0; }\r\n .oni-datepicker .oni-icon {\r\n text-indent: 0; }\r\n .oni-datepicker .oni-icon-calendar-o {\r\n padding: 0 6px;\r\n vertical-align: top;\r\n text-indent: 0;\r\n display: inline; }\r\n .oni-datepicker .oni-dropdown-source {\r\n margin-top: -2px;\r\n *margin-top: 0; }\r\n .oni-datepicker .oni-dropdown-source .oni-dropdown-input {\r\n padding: 0 21px 0 6px;\r\n line-height: 20px;\r\n height: 20px; }\r\n .oni-datepicker .oni-dropdown-source .oni-dropdown-icon {\r\n top: -20px;\r\n line-height: 20px; }\r\n\r\n.oni-datepicker-wrapper {\r\n padding: 9px 0 9px 10px;\r\n border: 1px solid #cccccc;\r\n box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.1);\r\n position: absolute;\r\n background: #fff; }\r\n\r\n.oni-datepicker-wrapper-right {\r\n right: -1px; }\r\n\r\n.oni-datepicker-wrapper-top {\r\n bottom: 24px; }\r\n\r\n.oni-datepicker-wrapper-top-right {\r\n bottom: 24px;\r\n right: -1px; }\r\n\r\n.oni-datepicker-content {\r\n border: 1px solid #e5e5e5;\r\n font-size: 12px;\r\n margin-right: 10px;\r\n background: #fff; }\r\n\r\n.oni-datepicker-label {\r\n background-color: #f8f8f8;\r\n border-bottom: 1px solid #e5e5e5;\r\n font-weight: 700;\r\n padding: 7px 0;\r\n text-align: center; }\r\n\r\n.oni-datepicker-timer {\r\n border-top: 1px solid #efefef;\r\n padding: 5px 0; }\r\n .oni-datepicker-timer .oni-btn {\r\n height: 26px;\r\n overflow: visible;\r\n _overflow-y: hidden;\r\n padding: 0 10px;\r\n -webkit-border-radius: 2px;\r\n -moz-border-radius: 2px;\r\n -ms-border-radius: 2px;\r\n -o-border-radius: 2px;\r\n border-radius: 2px;\r\n font-size: 12px;\r\n color: #333333;\r\n background-color: #f8f8f8;\r\n border: 1px solid #cccccc;\r\n cursor: pointer; }\r\n .oni-datepicker-timer .oni-btn:hover {\r\n box-shadow: 1px 1px 0 0 rgba(0, 0, 0, 0.1);\r\n background-color: #f8f8f8;\r\n border-color: #bbbbbb;\r\n color: #333333; }\r\n .oni-datepicker-timer .oni-btn-small {\r\n height: 22px;\r\n padding: 0 5px;\r\n font-size: 12px; }\r\n .oni-datepicker-timer p, .oni-datepicker-timer label {\r\n margin: 0; }\r\n .oni-datepicker-timer p span, .oni-datepicker-timer label span {\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n width: 50px; }\r\n\r\n.oni-datepicker-content-content {\r\n padding: 0 10px;\r\n position: relative;\r\n display: -moz-inline-stack;\r\n display: inline-block;\r\n vertical-align: middle;\r\n *vertical-align: auto;\r\n zoom: 1;\r\n *display: inline;\r\n white-space: normal;\r\n word-break: break-word; }\r\n\r\n.oni-datepicker-watermark {\r\n position: absolute;\r\n top: 60px;\r\n left: 10px;\r\n background: transparent;\r\n color: #000;\r\n _color: #f2f2f2;\r\n filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=5);\r\n opacity: 0.05;\r\n text-align: center; }\r\n\r\n.oni-datepicker-month-year span {\r\n display: block;\r\n width: 23%;\r\n height: 42px;\r\n line-height: 42px;\r\n float: left;\r\n margin: 1%;\r\n cursor: pointer;\r\n text-align: center;\r\n _margin-left: -1px; }\r\n.oni-datepicker-month-year .oni-datepicker-prev, .oni-datepicker-month-year .oni-datepicker-next {\r\n height: auto;\r\n line-height: auto;\r\n position: relative;\r\n width: auto; }\r\n.oni-datepicker-month-year .oni-datepicker-day-hover {\r\n background: #dbebff; }\r\n.oni-datepicker-month-year .oni-datepicker-selected {\r\n background: #3775c0;\r\n color: #fff; }\r\n.oni-datepicker-month-year .oni-datepicker-prev-year, .oni-datepicker-month-year .oni-datepicker-next-year {\r\n color: #999999; }\r\n.oni-datepicker-month-year .oni-state-disabled {\r\n color: #cccccc;\r\n cursor: default;\r\n background: transparent; }\r\n\r\n.oni-datepicker-header {\r\n position: relative;\r\n height: 30px;\r\n line-height: 30px; }\r\n\r\n.oni-datepicker .oni-datepicker-prev, .oni-datepicker .oni-datepicker-next {\r\n color: #3775c0;\r\n cursor: pointer;\r\n height: 30px;\r\n line-height: 30px;\r\n position: absolute;\r\n text-align: center;\r\n width: 20px;\r\n z-index: 1; }\r\n\r\n.oni-datepicker .oni-datepicker-prev {\r\n left: 0; }\r\n\r\n.oni-datepicker .oni-datepicker-next {\r\n right: 0; }\r\n\r\n.oni-datepicker-content-content .oni-datepicker-prev {\r\n left: 0;\r\n top: 0; }\r\n\r\n.oni-datepicker-content-content .oni-datepicker-next {\r\n right: 0;\r\n top: 0; }\r\n\r\n.oni-datepicker .oni-datepicker-prev-disabled, .oni-datepicker .oni-datepicker-next-disabled {\r\n color: #cccccc;\r\n cursor: default; }\r\n\r\n.oni-datepicker-title {\r\n color: #3775c0;\r\n font-weight: 700;\r\n text-align: center; }\r\n .oni-datepicker-title span.oni-state-hover {\r\n background: #dbebff;\r\n padding: 5px 10px; }\r\n\r\n.oni-datepicker-calendar-days {\r\n height: 150px;\r\n position: relative;\r\n z-index: 20; }\r\n\r\n.oni-datepicker-calendar-week, .oni-datepicker-calendar-days {\r\n border-collapse: collapse;\r\n margin-bottom: 5px;\r\n table-layout: fixed;\r\n width: 100%;\r\n border-spacing: 0; }\r\n\r\n.oni-datepicker-calendar-week th {\r\n border-bottom: 1px solid #efefef;\r\n border-top: 1px solid #efefef;\r\n padding: 3px 0;\r\n text-align: center;\r\n line-height: 18px;\r\n font-weight: 400;\r\n font-size: 12px; }\r\n\r\n.oni-datepicker-week-end, .oni-datepicker-calendar-days .oni-datepicker-week-end {\r\n color: #ff5555; }\r\n\r\n.oni-datepicker-calendar-days td {\r\n color: #333333;\r\n cursor: pointer;\r\n text-align: center;\r\n line-height: 18px;\r\n padding: 3px 0;\r\n background: transparent; }\r\n\r\n.oni-datepicker-default {\r\n background: #fff; }\r\n\r\n.oni-datepicker-calendar-days .oni-datepicker-day-hover {\r\n background: #dbebff; }\r\n\r\n.oni-datepicker-today {\r\n font-family: pmingliu, arial, sans-serif;\r\n font-size: 11px; }\r\n\r\n@media screen and (-webkit-transform-2d: 1) {\r\n .oni-datepicker-today {\r\n /* font-size: 12px; */\r\n -webkit-transform: scale(0.91667); } }\r\n.oni-datepicker-day-none {\r\n cursor: auto; }\r\n\r\n.oni-datepicker-calendar-days .oni-datepicker-selected {\r\n background: #3775c0;\r\n color: #fff; }\r\n\r\n.oni-datepicker-calendar-days .oni-state-disabled {\r\n color: #cccccc;\r\n cursor: default;\r\n background: transparent; }\r\n\r\n.oni-datepicker-multiple .oni-datepicker-content {\r\n border-right: 0; }\r\n.oni-datepicker-multiple .oni-datepicker-content-content {\r\n border-right: 1px solid #e5e5e5; }\r\n\r\n.oni-datepicker-dropdown .oni-dropdown-item {\r\n color: #333333;\r\n font-size: 12px;\r\n padding: 0;\r\n text-indent: 0;\r\n text-align: center; }\r\n.oni-datepicker-dropdown .oni-dropdown-item-hover {\r\n background: #f5f5f5; }\r\n.oni-datepicker-dropdown .oni-dropdown-item-selected {\r\n background: #3775c0; }\r\n.oni-datepicker-dropdown .oni-dropdown:hover .oni-dropdown-source {\r\n border-color: #3775c0;\r\n border-bottom-color: #cccccc; }\r\n\r\n.oni-datepicker-input-wrapper {\r\n background: #ffffff;\r\n border: 1px solid #cccccc;\r\n cursor: pointer;\r\n color: #333;\r\n font-size: 12px;\r\n position: relative;\r\n display: inline-block;\r\n *display: inline;\r\n zoom: 1;\r\n z-index: 1; }\r\n .oni-datepicker-input-wrapper input {\r\n border: 0 none;\r\n cursor: pointer;\r\n outline: none;\r\n padding: 3px 90px 3px 6px;\r\n width: 90px;\r\n height: 18px;\r\n margin: 0;\r\n font-size: 12px; }\r\n\r\n.oni-datepicker-tip {\r\n position: absolute;\r\n top: 3px;\r\n right: 10px;\r\n line-height: 18px;\r\n height: 18px;\r\n color: #b5b5b5; }\r\n\r\n.oni-datepicker-active {\r\n border-color: #3775c0; }\r\n\r\n/*# sourceMappingURL=avalon.datepicker.css.map */\r\n'); diff --git a/main.js b/main.js index 426ed462..00cb2ffb 100644 --- a/main.js +++ b/main.js @@ -2,12 +2,66 @@ require([ "avalon", "domReady!", - "avalon.tab", - "avalon.pager", - "avalon.datepicker", + "./tab/avalon.tab", + "./pager/avalon.pager", + "./datepicker/avalon.datepicker" ], function (avalon) { - avalon.log("domReady完成1") - var vm = avalon.define({$id: "demo"}) + avalon.log("domReady完成!") + var vm = avalon.define({$id: "demo", + //切换卡相关的配置 + tab: { + onActivate: function (e) { + avalon.log("user define cc activate callback") + } + , onClickActive: function (e, model) { + alert('u click a active tab') + } + , autoSwitch: 1200 + , active: 1 + , tabs: [{ + title: "水果2", + name: "fruit", + removable: false, + href: "http://news.163.com/" + }, + { + title: "服装2", + name: "cloth" + }, + { + title: "水果非国产经典品牌十分流弊" + , name: "tool" + }, + { + title: "电器2" + , name: "tool" + }, + { + title: "动物2" + , name: "animal" + , disabled: true + } + ] + , tabpanels: [ + {content: "line 1 - 点击我添加一个tab!"}, + {content: "avalon.tab.ajax.html", contentType: "ajax"}, + {content: "line 2 - 点击我激活动物tab!"}, + {content: 'line 3 - 点击我添加一个不能删除的tab! '}, + {content: "line 4"} + ] + }, + peaple: { + title: "人类" + , content: "我是来搞笑的" + }, + peaple2: { + title: "人类" + , removable: false + , content: "我是来搞笑的" + }, + $skipArray: ["tab"] + + }) avalon.scan(document.body, vm); //你们的业务代码 })