diff --git a/spm_modules/bui-common/1.1.2/HISTORY.md b/spm_modules/bui-common/1.1.2/HISTORY.md deleted file mode 100644 index b322954..0000000 --- a/spm_modules/bui-common/1.1.2/HISTORY.md +++ /dev/null @@ -1,7 +0,0 @@ -# History - ---- - -## 1.1.0 - -`new` It is the first version of bui-common. diff --git a/spm_modules/bui-common/1.1.2/README.md b/spm_modules/bui-common/1.1.2/README.md deleted file mode 100644 index 867dac1..0000000 --- a/spm_modules/bui-common/1.1.2/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# bui-common - ---- - -[![spm version](http://spmjs.io/badge/bui-common)](http://spmjs.io/package/bui-common) - -An awesome spm package! - ---- - -## Install - -``` -$ spm install bui-common --save -``` - -## Usage - -```js -var common = require('bui-common'); -// use common -``` - -## Api - -Here is more details. - diff --git a/spm_modules/bui-common/1.1.2/common.js b/spm_modules/bui-common/1.1.2/common.js deleted file mode 100644 index b7ab2fd..0000000 --- a/spm_modules/bui-common/1.1.2/common.js +++ /dev/null @@ -1,14 +0,0 @@ -var BUI = require('./src/util'); - -BUI.mix(BUI, { - UA: require('./src/ua'), - JSON: require('./src/json'), - Date: require('./src/date'), - Array: require('./src/array'), - KeyCode: require('./src/keycode'), - Observable: require('./src/observable'), - Base: require('./src/base'), - Component: require('./src/component/component') -}); - -module.exports = BUI; diff --git a/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common-debug.js b/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common-debug.js deleted file mode 100644 index ab96338..0000000 --- a/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common-debug.js +++ /dev/null @@ -1,10860 +0,0 @@ -define("bui-common/1.1.2/common-debug", ["jquery"], function(require, exports, module){ -var BUI = require("bui-common/1.1.2/src/util-debug"); - -BUI.mix(BUI, { - UA: require("bui-common/1.1.2/src/ua-debug"), - JSON: require("bui-common/1.1.2/src/json-debug"), - Date: require("bui-common/1.1.2/src/date-debug"), - Array: require("bui-common/1.1.2/src/array-debug"), - KeyCode: require("bui-common/1.1.2/src/keycode-debug"), - Observable: require("bui-common/1.1.2/src/observable-debug"), - Base: require("bui-common/1.1.2/src/base-debug"), - Component: require("bui-common/1.1.2/src/component/component-debug") -}); - -module.exports = BUI; - -}); -define("bui-common/1.1.2/src/util-debug", ["jquery"], function(require, exports, module){ -/** - * @class BUI - * 控件库的工具方法,这些工具方法直接绑定到BUI对象上 - *

- *   BUI.isString(str);
- *
- *   BUI.extend(A,B);
- *
- *   BUI.mix(A,{a:'a'});
- * 
- * @singleton - */ - -var $ = require('jquery'); - -//兼容jquery 1.6以下 -(function($) { - if ($.fn) { - $.fn.on = $.fn.on || $.fn.bind; - $.fn.off = $.fn.off || $.fn.unbind; - } -})($); -/** - * @ignore - * 处于效率的目的,复制属性 - */ -function mixAttrs(to, from) { - - for (var c in from) { - if (from.hasOwnProperty(c)) { - to[c] = to[c] || {}; - mixAttr(to[c], from[c]); - } - } - -} -//合并属性 -function mixAttr(attr, attrConfig) { - for (var p in attrConfig) { - if (attrConfig.hasOwnProperty(p)) { - if (p == 'value') { - if (BUI.isObject(attrConfig[p])) { - attr[p] = attr[p] || {}; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else if (BUI.isArray(attrConfig[p])) { - attr[p] = attr[p] || []; - //BUI.mix(/*true,*/attr[p], attrConfig[p]); - attr[p] = attr[p].concat(attrConfig[p]); - } else { - attr[p] = attrConfig[p]; - } - } else { - attr[p] = attrConfig[p]; - } - } - }; -} - -var win = window, - doc = document, - objectPrototype = Object.prototype, - toString = objectPrototype.toString, - BODY = 'body', - DOC_ELEMENT = 'documentElement', - SCROLL = 'scroll', - SCROLL_WIDTH = SCROLL + 'Width', - SCROLL_HEIGHT = SCROLL + 'Height', - ATTRS = 'ATTRS', - PARSER = 'PARSER', - GUID_DEFAULT = 'guid'; - -window.BUI = window.BUI || {}; - -$.extend(BUI, { - /** - * 版本号 - * @memberOf BUI - * @type {Number} - */ - version: '1.1.0', - /** - * 是否为函数 - * @param {*} fn 对象 - * @return {Boolean} 是否函数 - */ - isFunction: function(fn) { - return typeof(fn) === 'function'; - }, - /** - * 是否数组 - * @method - * @param {*} obj 是否数组 - * @return {Boolean} 是否数组 - */ - isArray: ('isArray' in Array) ? Array.isArray : function(value) { - return toString.call(value) === '[object Array]'; - }, - /** - * 是否日期 - * @param {*} value 对象 - * @return {Boolean} 是否日期 - */ - isDate: function(value) { - return toString.call(value) === '[object Date]'; - }, - /** - * 是否是javascript对象 - * @param {Object} value The value to test - * @return {Boolean} - * @method - */ - isObject: (toString.call(null) === '[object Object]') ? - function(value) { - // check ownerDocument here as well to exclude DOM nodes - return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined; - } : function(value) { - return toString.call(value) === '[object Object]'; - }, - /** - * 是否是数字或者数字字符串 - * @param {String} value 数字字符串 - * @return {Boolean} 是否是数字或者数字字符串 - */ - isNumeric: function(value) { - return !isNaN(parseFloat(value)) && isFinite(value); - }, - /** - * 将指定的方法或属性放到构造函数的原型链上, - * 函数支持多于2个变量,后面的变量同s1一样将其成员复制到构造函数的原型链上。 - * @param {Function} r 构造函数 - * @param {Object} s1 将s1 的成员复制到构造函数的原型链上 - * @example - * BUI.augment(class1,{ - * method1: function(){ - * - * } - * }); - */ - augment: function(r, s1) { - if (!BUI.isFunction(r)) { - return r; - } - for (var i = 1; i < arguments.length; i++) { - BUI.mix(r.prototype, arguments[i].prototype || arguments[i]); - }; - return r; - }, - /** - * 拷贝对象 - * @param {Object} obj 要拷贝的对象 - * @return {Object} 拷贝生成的对象 - */ - cloneObject: function(obj) { - var result = BUI.isArray(obj) ? [] : {}; - - return BUI.mix(true, result, obj); - }, - /** - * 抛出错误 - */ - error: function(msg) { - if (BUI.debug) { - throw msg; - } - }, - - /** - * 实现类的继承,通过父类生成子类 - * @param {Function} subclass - * @param {Function} superclass 父类构造函数 - * @param {Object} overrides 子类的属性或者方法 - * @return {Function} 返回的子类构造函数 - * 示例: - * @example - * //父类 - * function base(){ - * - * } - * - * function sub(){ - * - * } - * //子类 - * BUI.extend(sub,base,{ - * method : function(){ - * - * } - * }); - * - * //或者 - * var sub = BUI.extend(base,{}); - */ - extend: function(subclass, superclass, overrides, staticOverrides) { - //如果只提供父类构造函数,则自动生成子类构造函数 - if (!BUI.isFunction(superclass)) { - - overrides = superclass; - superclass = subclass; - subclass = function() {}; - } - - var create = Object.create ? - function(proto, c) { - return Object.create(proto, { - constructor: { - value: c - } - }); - } : - function(proto, c) { - function F() {} - - F.prototype = proto; - - var o = new F(); - o.constructor = c; - return o; - }; - var superObj = create(superclass.prototype, subclass); //new superclass(),//实例化父类作为子类的prototype - subclass.prototype = BUI.mix(superObj, subclass.prototype); //指定子类的prototype - subclass.superclass = create(superclass.prototype, superclass); - BUI.mix(superObj, overrides); - BUI.mix(subclass, staticOverrides); - return subclass; - }, - /** - * 生成唯一的Id - * @method - * @param {String} prefix 前缀 - * @default 'bui-guid' - * @return {String} 唯一的编号 - */ - guid: (function() { - var map = {}; - return function(prefix) { - prefix = prefix || BUI.prefix + GUID_DEFAULT; - if (!map[prefix]) { - map[prefix] = 1; - } else { - map[prefix] += 1; - } - return prefix + map[prefix]; - }; - })(), - /** - * 判断是否是字符串 - * @return {Boolean} 是否是字符串 - */ - isString: function(value) { - return typeof value === 'string'; - }, - /** - * 判断是否数字,由于$.isNumberic方法会把 '123'认为数字 - * @return {Boolean} 是否数字 - */ - isNumber: function(value) { - return typeof value === 'number'; - }, - /** - * 是否是布尔类型 - * - * @param {Object} value 测试的值 - * @return {Boolean} - */ - isBoolean: function(value) { - return typeof value === 'boolean'; - }, - /** - * 控制台输出日志 - * @param {Object} obj 输出的数据 - */ - log: function(obj) { - if (BUI.debug && win.console && win.console.log) { - win.console.log(obj); - } - }, - /** - * 将多个对象的属性复制到一个新的对象 - */ - merge: function() { - var args = $.makeArray(arguments), - first = args[0]; - if (BUI.isBoolean(first)) { - args.shift(); - args.unshift({}); - args.unshift(first); - } else { - args.unshift({}); - } - - return BUI.mix.apply(null, args); - - }, - /** - * 封装 jQuery.extend 方法,将多个对象的属性merge到第一个对象中 - * @return {Object} - */ - mix: function() { - return $.extend.apply(null, arguments); - }, - /** - * 创造顶层的命名空间,附加到window对象上, - * 包含namespace方法 - */ - app: function(name) { - if (!window[name]) { - window[name] = { - namespace: function(nsName) { - return BUI.namespace(nsName, window[name]); - } - }; - } - return window[name]; - }, - - mixAttrs: mixAttrs, - - mixAttr: mixAttr, - - /** - * 将其他类作为mixin集成到指定类上面 - * @param {Function} c 构造函数 - * @param {Array} mixins 扩展类 - * @param {Array} attrs 扩展的静态属性,默认为['ATTRS'] - * @return {Function} 传入的构造函数 - */ - mixin: function(c, mixins, attrs) { - attrs = attrs || [ATTRS, PARSER]; - var extensions = mixins; - if (extensions) { - c.mixins = extensions; - - var desc = { - // ATTRS: - // HTML_PARSER: - }, - constructors = extensions['concat'](c); - - // [ex1,ex2],扩展类后面的优先,ex2 定义的覆盖 ex1 定义的 - // 主类最优先 - BUI.each(constructors, function(ext) { - if (ext) { - // 合并 ATTRS/HTML_PARSER 到主类 - BUI.each(attrs, function(K) { - if (ext[K]) { - desc[K] = desc[K] || {}; - // 不覆盖主类上的定义,因为继承层次上扩展类比主类层次高 - // 但是值是对象的话会深度合并 - // 注意:最好值是简单对象,自定义 new 出来的对象就会有问题(用 function return 出来)! - if (K == 'ATTRS') { - //BUI.mix(true,desc[K], ext[K]); - mixAttrs(desc[K], ext[K]); - } else { - BUI.mix(desc[K], ext[K]); - } - - } - }); - } - }); - - BUI.each(desc, function(v, k) { - c[k] = v; - }); - - var prototype = {}; - - // 主类最优先 - BUI.each(constructors, function(ext) { - if (ext) { - var proto = ext.prototype; - // 合并功能代码到主类,不覆盖 - for (var p in proto) { - // 不覆盖主类,但是主类的父类还是覆盖吧 - if (proto.hasOwnProperty(p)) { - prototype[p] = proto[p]; - } - } - } - }); - - BUI.each(prototype, function(v, k) { - c.prototype[k] = v; - }); - } - return c; - }, - /** - * 生成命名空间 - * @param {String} name 命名空间的名称 - * @param {Object} baseNS 在已有的命名空间上创建命名空间,默认“BUI” - * @return {Object} 返回的命名空间对象 - * @example - * BUI.namespace("Grid"); // BUI.Grid - */ - namespace: function(name, baseNS) { - baseNS = baseNS || BUI; - if (!name) { - return baseNS; - } - var list = name.split('.'), - //firstNS = win[list[0]], - curNS = baseNS; - - for (var i = 0; i < list.length; i++) { - var nsName = list[i]; - if (!curNS[nsName]) { - curNS[nsName] = {}; - } - curNS = curNS[nsName]; - }; - return curNS; - }, - /** - * BUI 控件的公用前缀 - * @type {String} - */ - prefix: 'bui-', - /** - * 替换字符串中的字段. - * @param {String} str 模版字符串 - * @param {Object} o json data - * @param {RegExp} [regexp] 匹配字符串的正则表达式 - */ - substitute: function(str, o, regexp) { - if (!BUI.isString(str) || (!BUI.isObject(o)) && !BUI.isArray(o)) { - return str; - } - - return str.replace(regexp || /\\?\{([^{}]+)\}/g, function(match, name) { - if (match.charAt(0) === '\\') { - return match.slice(1); - } - return (o[name] === undefined) ? '' : o[name]; - }); - }, - /** - * 将$.param的反操作 - * jquery只提供param方法 - * @return {[type]} [description] - */ - unparam: function(str){ - if (typeof str != 'string' || !(str = $.trim(str))) { - return {}; - } - var pairs = str.split('&'), - pairsArr, - rst = {}; - for(var i = pairs.length - 1; i >= 0; i--) { - pairsArr = pairs[i].split('='); - rst[pairsArr[0]] = decodeURIComponent(pairsArr[1]); - } - return rst; - }, - /** - * 使第一个字母变成大写 - * @param {String} s 字符串 - * @return {String} 首字母大写后的字符串 - */ - ucfirst: function(s) { - s += ''; - return s.charAt(0).toUpperCase() + s.substring(1); - }, - /** - * 页面上的一点是否在用户的视图内 - * @param {Object} offset 坐标,left,top - * @return {Boolean} 是否在视图内 - */ - isInView: function(offset) { - var left = offset.left, - top = offset.top, - viewWidth = BUI.viewportWidth(), - wiewHeight = BUI.viewportHeight(), - scrollTop = BUI.scrollTop(), - scrollLeft = BUI.scrollLeft(); - //判断横坐标 - if (left < scrollLeft || left > scrollLeft + viewWidth) { - return false; - } - //判断纵坐标 - if (top < scrollTop || top > scrollTop + wiewHeight) { - return false; - } - return true; - }, - /** - * 页面上的一点纵向坐标是否在用户的视图内 - * @param {Object} top 纵坐标 - * @return {Boolean} 是否在视图内 - */ - isInVerticalView: function(top) { - var wiewHeight = BUI.viewportHeight(), - scrollTop = BUI.scrollTop(); - - //判断纵坐标 - if (top < scrollTop || top > scrollTop + wiewHeight) { - return false; - } - return true; - }, - /** - * 页面上的一点横向坐标是否在用户的视图内 - * @param {Object} left 横坐标 - * @return {Boolean} 是否在视图内 - */ - isInHorizontalView: function(left) { - var viewWidth = BUI.viewportWidth(), - scrollLeft = BUI.scrollLeft(); - //判断横坐标 - if (left < scrollLeft || left > scrollLeft + viewWidth) { - return false; - } - return true; - }, - /** - * 获取窗口可视范围宽度 - * @return {Number} 可视区宽度 - */ - viewportWidth: function() { - return $(window).width(); - }, - /** - * 获取窗口可视范围高度 - * @return {Number} 可视区高度 - */ - viewportHeight: function() { - return $(window).height(); - }, - /** - * 滚动到窗口的left位置 - */ - scrollLeft: function() { - return $(window).scrollLeft(); - }, - /** - * 滚动到横向位置 - */ - scrollTop: function() { - return $(window).scrollTop(); - }, - /** - * 窗口宽度 - * @return {Number} 窗口宽度 - */ - docWidth: function() { - return Math.max(this.viewportWidth(), doc[DOC_ELEMENT][SCROLL_WIDTH], doc[BODY][SCROLL_WIDTH]); - }, - /** - * 窗口高度 - * @return {Number} 窗口高度 - */ - docHeight: function() { - return Math.max(this.viewportHeight(), doc[DOC_ELEMENT][SCROLL_HEIGHT], doc[BODY][SCROLL_HEIGHT]); - }, - /** - * 遍历数组或者对象 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){} - */ - each: function(elements, func) { - if (!elements) { - return; - } - $.each(elements, function(k, v) { - return func(v, k); - }); - }, - /** - * 封装事件,便于使用上下文this,和便于解除事件时使用 - * @protected - * @param {Object} self 对象 - * @param {String} action 事件名称 - */ - wrapBehavior: function(self, action) { - return self['__bui_wrap_' + action] = function(e) { - if (!self.get('disabled')) { - self[action](e); - } - }; - }, - /** - * 获取封装的事件 - * @protected - * @param {Object} self 对象 - * @param {String} action 事件名称 - */ - getWrapBehavior: function(self, action) { - return self['__bui_wrap_' + action]; - }, - /** - * 获取页面上使用了此id的控件 - * @param {String} id 控件id - * @return {BUI.Component.Controller} 查找的控件 - */ - getControl: function(id) { - return BUI.Component.Manager.getComponent(id); - } - -}); - -/** - * 表单帮助类,序列化、反序列化,设置值 - * @class BUI.FormHelper - * @singleton - */ -var FormHelper = { - /** - * 将表单格式化成键值对形式 - * @param {HTMLElement} form 表单 - * @return {Object} 键值对的对象 - */ - serializeToObject: function(form) { - var array = $(form).serializeArray(), - result = {}; - BUI.each(array, function(item) { - var name = item.name; - if (!result[name]) { //如果是单个值,直接赋值 - result[name] = item.value; - } else { //多值使用数组 - if (!BUI.isArray(result[name])) { - result[name] = [result[name]]; - } - result[name].push(item.value); - } - }); - return result; - }, - /** - * 设置表单的值 - * @param {HTMLElement} form 表单 - * @param {Object} obj 键值对 - */ - setFields: function(form, obj) { - for (var name in obj) { - if (obj.hasOwnProperty(name)) { - BUI.FormHelper.setField(form, name, obj[name]); - } - } - }, - /** - * 清空表单 - * @param {HTMLElement} form 表单元素 - */ - clear: function(form) { - var elements = $.makeArray(form.elements); - - BUI.each(elements, function(element) { - if (element.type === 'checkbox' || element.type === 'radio') { - $(element).attr('checked', false); - } else { - $(element).val(''); - } - $(element).change(); - }); - }, - /** - * 设置表单字段 - * @param {HTMLElement} form 表单元素 - * @param {string} field 字段名 - * @param {string} value 字段值 - */ - setField: function(form, fieldName, value) { - var fields = form.elements[fieldName]; - if (fields && fields.type) { - formHelper._setFieldValue(fields, value); - } else if (BUI.isArray(fields) || (fields && fields.length)) { - BUI.each(fields, function(field) { - formHelper._setFieldValue(field, value); - }); - } - }, - //设置字段的值 - _setFieldValue: function(field, value) { - if (field.type === 'checkbox') { - if (field.value == '' + value || (BUI.isArray(value) && BUI.Array.indexOf(field.value, value) !== -1)) { - $(field).attr('checked', true); - } else { - $(field).attr('checked', false); - } - } else if (field.type === 'radio') { - if (field.value == '' + value) { - $(field).attr('checked', true); - } else { - $(field).attr('checked', false); - } - } else { - $(field).val(value); - } - }, - /** - * 获取表单字段值 - * @param {HTMLElement} form 表单元素 - * @param {string} field 字段名 - * @return {String} 字段值 - */ - getField: function(form, fieldName) { - return BUI.FormHelper.serializeToObject(form)[fieldName]; - } -}; - - -BUI.FormHelper = FormHelper; - -module.exports = BUI; - -}); -define("bui-common/1.1.2/src/ua-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview UA,jQuery的 $.browser 对象非常难使用 - * @ignore - * @author dxq613@gmail.com - */ - -var $ = require('jquery'); - -function numberify(s) { - var c = 0; - // convert '1.2.3.4' to 1.234 - return parseFloat(s.replace(/\./g, function() { - return (c++ === 0) ? '.' : ''; - })); -}; - -function uaMatch(s) { - s = s.toLowerCase(); - var r = /(chrome)[ \/]([\w.]+)/.exec(s) || /(webkit)[ \/]([\w.]+)/.exec(s) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(s) || /(msie) ([\w.]+)/.exec(s) || s.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(s) || [], - a = { - browser: r[1] || "", - version: r[2] || "0" - }, - b = {}; - a.browser && (b[a.browser] = !0, b.version = a.version), - b.chrome ? b.webkit = !0 : b.webkit && (b.safari = !0); - return b; -} - -var UA = $.UA || (function() { - var browser = $.browser || uaMatch(navigator.userAgent), - versionNumber = numberify(browser.version), - /** - * 浏览器版本检测 - * @class BUI.UA - * @singleton - */ - ua = { - /** - * ie 版本 - * @type {Number} - */ - ie: browser.msie && versionNumber, - - /** - * webkit 版本 - * @type {Number} - */ - webkit: browser.webkit && versionNumber, - /** - * opera 版本 - * @type {Number} - */ - opera: browser.opera && versionNumber, - /** - * mozilla 火狐版本 - * @type {Number} - */ - mozilla: browser.mozilla && versionNumber - }; - return ua; -})(); - -module.exports = UA; - -}); -define("bui-common/1.1.2/src/json-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 由于jQuery只有 parseJSON ,没有stringify所以使用过程不方便 - * @ignore - */ - -var $ = require('jquery'), - UA = require("bui-common/1.1.2/src/ua-debug"), - win = window, - JSON = win.JSON; - -// ie 8.0.7600.16315@win7 json 有问题 -if (!JSON || UA['ie'] < 9) { - JSON = win.JSON = {}; -} - -function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; -} - -if (typeof Date.prototype.toJSON !== 'function') { - - Date.prototype.toJSON = function(key) { - - return isFinite(this.valueOf()) ? - this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z' : null; - }; - - String.prototype.toJSON = - Number.prototype.toJSON = - Boolean.prototype.toJSON = function(key) { - return this.valueOf(); - }; -} - - -var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"': '\\"', - '\\': '\\\\' - }, - rep; - -function quote(string) { - - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable['lastIndex'] = 0; - return escapable.test(string) ? - '"' + string.replace(escapable, function(a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : - '"' + string + '"'; -} - -function str(key, holder) { - - // Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - // If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - - // JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - - return String(value); - - // If the type is 'object', we might be dealing with an object or an array or - // null. - - case 'object': - - // Due to a specification blunder in ECMAScript, typeof null is 'object', - // so watch out for that case. - - if (!value) { - return 'null'; - } - - // Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - - // Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - - // The value is an array. Stringify every element. Use null as a placeholder - // for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and wrap them in - // brackets. - - v = partial.length === 0 ? '[]' : - gap ? '[\n' + gap + - partial.join(',\n' + gap) + '\n' + - mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - - // Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 ? '{}' : - gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + - mind + '}' : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } -} - -if (typeof JSON.stringify !== 'function') { - JSON.stringify = function(value, replacer, space) { - - // The stringify method takes a value and an optional replacer, and an optional - // space parameter, and returns a JSON text. The replacer can be a function - // that can replace values, or an array of strings that will select the keys. - // A default replacer method can be provided. Use of the space parameter can - // produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - - // If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - - return str('', { - '': value - }); - }; -} - -function looseParse(data) { - try { - return new Function('return ' + data + ';')(); - } catch (e) { - throw 'Json parse error!'; - } -} -/** - * JSON 格式化 - * @class BUI.JSON - * @singleton - */ -var JSON = { - /** - * 转成json 等同于$.parseJSON - * @method - * @param {String} jsonstring 合法的json 字符串 - */ - parse: $.parseJSON, - /** - * 业务中有些字符串组成的json数据不是严格的json数据,如使用单引号,或者属性名不是字符串 - * 如 : {a:'abc'} - * @method - * @param {String} jsonstring - */ - looseParse: looseParse, - /** - * 将Json转成字符串 - * @method - * @param {Object} json json 对象 - */ - stringify: JSON.stringify -} - -module.exports = JSON; - -}); -define("bui-common/1.1.2/src/date-debug", [], function(require, exports, module){ -/* - * @fileOverview Date Format 1.2.3 - * @ignore - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - * - * Last modified by jayli 拔赤 2010-09-09 - * - 增加中文的支持 - * - 简单的本地化,对w(星期x)的支持 - * - */ - -var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/; - -function dateParse(val, format) { - if (val instanceof Date) { - return val; - } - if (typeof(format) == "undefined" || format == null || format == "") { - var checkList = new Array('y-m-d', 'yyyy-mm-dd', 'yyyy-mm-dd HH:MM:ss', 'H:M:s'); - for (var i = 0; i < checkList.length; i++) { - var d = dateParse(val, checkList[i]); - if (d != null) { - return d; - } - } - return null; - }; - val = val + ""; - var i_val = 0; - var i_format = 0; - var c = ""; - var token = ""; - var x, y; - var now = new Date(); - var year = now.getYear(); - var month = now.getMonth() + 1; - var date = 1; - var hh = 00; - var mm = 00; - var ss = 00; - this.isInteger = function(val) { - return /^\d*$/.test(val); - }; - this.getInt = function(str, i, minlength, maxlength) { - for (var x = maxlength; x >= minlength; x--) { - var token = str.substring(i, i + x); - if (token.length < minlength) { - return null; - } - if (this.isInteger(token)) { - return token; - } - } - return null; - }; - - while (i_format < format.length) { - c = format.charAt(i_format); - token = ""; - while ((format.charAt(i_format) == c) && (i_format < format.length)) { - token += format.charAt(i_format++); - } - if (token == "yyyy" || token == "yy" || token == "y") { - if (token == "yyyy") { - x = 4; - y = 4; - } - if (token == "yy") { - x = 2; - y = 2; - } - if (token == "y") { - x = 2; - y = 4; - } - year = this.getInt(val, i_val, x, y); - if (year == null) { - return null; - } - i_val += year.length; - if (year.length == 2) { - year = year > 70 ? 1900 + (year - 0) : 2000 + (year - 0); - } - } else if (token == "mm" || token == "m") { - month = this.getInt(val, i_val, token.length, 2); - if (month == null || (month < 1) || (month > 12)) { - return null; - } - i_val += month.length; - } else if (token == "dd" || token == "d") { - date = this.getInt(val, i_val, token.length, 2); - if (date == null || (date < 1) || (date > 31)) { - return null; - } - i_val += date.length; - } else if (token == "hh" || token == "h") { - hh = this.getInt(val, i_val, token.length, 2); - if (hh == null || (hh < 1) || (hh > 12)) { - return null; - } - i_val += hh.length; - } else if (token == "HH" || token == "H") { - hh = this.getInt(val, i_val, token.length, 2); - if (hh == null || (hh < 0) || (hh > 23)) { - return null; - } - i_val += hh.length; - } else if (token == "MM" || token == "M") { - mm = this.getInt(val, i_val, token.length, 2); - if (mm == null || (mm < 0) || (mm > 59)) { - return null; - } - i_val += mm.length; - } else if (token == "ss" || token == "s") { - ss = this.getInt(val, i_val, token.length, 2); - if (ss == null || (ss < 0) || (ss > 59)) { - return null; - } - i_val += ss.length; - } else { - if (val.substring(i_val, i_val + token.length) != token) { - return null; - } else { - i_val += token.length; - } - } - } - if (i_val != val.length) { - return null; - } - if (month == 2) { - if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { // leap year - if (date > 29) { - return null; - } - } else { - if (date > 28) { - return null; - } - } - } - if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { - if (date > 30) { - return null; - } - } - return new Date(year, month - 1, date, hh, mm, ss); -} - -function DateAdd(strInterval, NumDay, dtDate) { - var dtTmp = new Date(dtDate); - if (isNaN(dtTmp)) { - dtTmp = new Date(); - } - NumDay = parseInt(NumDay, 10); - switch (strInterval) { - case 's': - dtTmp = new Date(dtTmp.getTime() + (1000 * NumDay)); - break; - case 'n': - dtTmp = new Date(dtTmp.getTime() + (60000 * NumDay)); - break; - case 'h': - dtTmp = new Date(dtTmp.getTime() + (3600000 * NumDay)); - break; - case 'd': - dtTmp = new Date(dtTmp.getTime() + (86400000 * NumDay)); - break; - case 'w': - dtTmp = new Date(dtTmp.getTime() + ((86400000 * 7) * NumDay)); - break; - case 'm': - dtTmp = new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + NumDay, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds()); - break; - case 'y': - //alert(dtTmp.getFullYear()); - dtTmp = new Date(dtTmp.getFullYear() + NumDay, dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds()); - //alert(dtTmp); - break; - } - return dtTmp; -} - -var dateFormat = function() { - var token = /w{1}|d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function(val, len) { - val = String(val); - len = len || 2; - while (val.length < len) { - val = '0' + val; - } - return val; - }, - // Some common format strings - masks = { - 'default': 'ddd mmm dd yyyy HH:MM:ss', - shortDate: 'm/d/yy', - //mediumDate: 'mmm d, yyyy', - longDate: 'mmmm d, yyyy', - fullDate: 'dddd, mmmm d, yyyy', - shortTime: 'h:MM TT', - //mediumTime: 'h:MM:ss TT', - longTime: 'h:MM:ss TT Z', - isoDate: 'yyyy-mm-dd', - isoTime: 'HH:MM:ss', - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUTCDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'", - - //added by jayli - localShortDate: 'yy年mm月dd日', - localShortDateTime: 'yy年mm月dd日 hh:MM:ss TT', - localLongDate: 'yyyy年mm月dd日', - localLongDateTime: 'yyyy年mm月dd日 hh:MM:ss TT', - localFullDate: 'yyyy年mm月dd日 w', - localFullDateTime: 'yyyy年mm月dd日 w hh:MM:ss TT' - - }, - - // Internationalization strings - i18n = { - dayNames: [ - 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', - 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', - '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六' - ], - monthNames: [ - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', - 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' - ] - }; - - // Regexes and supporting functions are cached through closure - return function(date, mask, utc) { - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length === 1 && Object.prototype.toString.call(date) === '[object String]' && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date(); - if (isNaN(date)) { - throw SyntaxError('invalid date'); - } - - mask = String(masks[mask] || mask || masks['default']); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) === 'UTC:') { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? 'getUTC' : 'get', - d = date[_ + 'Date'](), - D = date[_ + 'Day'](), - m = date[_ + 'Month'](), - y = date[_ + 'FullYear'](), - H = date[_ + 'Hours'](), - M = date[_ + 'Minutes'](), - s = date[_ + 'Seconds'](), - L = date[_ + 'Milliseconds'](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d, undefined), - ddd: i18n.dayNames[D], - dddd: i18n.dayNames[D + 7], - w: i18n.dayNames[D + 14], - m: m + 1, - mm: pad(m + 1, undefined), - mmm: i18n.monthNames[m], - mmmm: i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12, undefined), - H: H, - HH: pad(H, undefined), - M: M, - MM: pad(M, undefined), - s: s, - ss: pad(s, undefined), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L, undefined), - t: H < 12 ? 'a' : 'p', - tt: H < 12 ? 'am' : 'pm', - T: H < 12 ? 'A' : 'P', - TT: H < 12 ? 'AM' : 'PM', - Z: utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''), - o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 !== 10) * d % 10] - }; - - return mask.replace(token, function($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -/** - * 日期的工具方法 - * @class BUI.Date - */ -var DateUtil = { - /** - * 日期加法 - * @param {String} strInterval 加法的类型,s(秒),n(分),h(时),d(天),w(周),m(月),y(年) - * @param {Number} Num 数量,如果为负数,则为减法 - * @param {Date} dtDate 起始日期,默认为此时 - */ - add: function(strInterval, Num, dtDate) { - return DateAdd(strInterval, Num, dtDate); - }, - /** - * 小时的加法 - * @param {Number} hours 小时 - * @param {Date} date 起始日期 - */ - addHour: function(hours, date) { - return DateAdd('h', hours, date); - }, - /** - * 分的加法 - * @param {Number} minutes 分 - * @param {Date} date 起始日期 - */ - addMinute: function(minutes, date) { - return DateAdd('n', minutes, date); - }, - /** - * 秒的加法 - * @param {Number} seconds 秒 - * @param {Date} date 起始日期 - */ - addSecond: function(seconds, date) { - return DateAdd('s', seconds, date); - }, - /** - * 天的加法 - * @param {Number} days 天数 - * @param {Date} date 起始日期 - */ - addDay: function(days, date) { - return DateAdd('d', days, date); - }, - /** - * 增加周 - * @param {Number} weeks 周数 - * @param {Date} date 起始日期 - */ - addWeek: function(weeks, date) { - return DateAdd('w', weeks, date); - }, - /** - * 增加月 - * @param {Number} months 月数 - * @param {Date} date 起始日期 - */ - addMonths: function(months, date) { - return DateAdd('m', months, date); - }, - /** - * 增加年 - * @param {Number} years 年数 - * @param {Date} date 起始日期 - */ - addYear: function(years, date) { - return DateAdd('y', years, date); - }, - /** - * 日期是否相等,忽略时间 - * @param {Date} d1 日期对象 - * @param {Date} d2 日期对象 - * @return {Boolean} 是否相等 - */ - isDateEquals: function(d1, d2) { - - return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate(); - }, - /** - * 日期时间是否相等,包含时间 - * @param {Date} d1 日期对象 - * @param {Date} d2 日期对象 - * @return {Boolean} 是否相等 - */ - isEquals: function(d1, d2) { - if (d1 == d2) { - return true; - } - if (!d1 || !d2) { - return false; - } - if (!d1.getTime || !d2.getTime) { - return false; - } - return d1.getTime() == d2.getTime(); - }, - /** - * 字符串是否是有效的日期类型 - * @param {String} str 字符串 - * @return 字符串是否能转换成日期 - */ - isDateString: function(str) { - return dateRegex.test(str); - }, - /** - * 将日期格式化成字符串 - * @param {Date} date 日期 - * @param {String} mask 格式化方式 - * @param {Date} utc 是否utc时间 - * @return {String} 日期的字符串 - */ - format: function(date, mask, utc) { - return dateFormat(date, mask, utc); - }, - /** - * 转换成日期 - * @param {String|Date} date 字符串或者日期 - * @param {String} dateMask 日期的格式,如:yyyy-MM-dd - * @return {Date} 日期对象 - */ - parse: function(date, s) { - if (BUI.isString(date)) { - date = date.replace('\/', '-'); - } - return dateParse(date, s); - }, - /** - * 当前天 - * @return {Date} 当前天 00:00:00 - */ - today: function() { - var now = new Date(); - return new Date(now.getFullYear(), now.getMonth(), now.getDate()); - }, - /** - * 返回当前日期 - * @return {Date} 日期的 00:00:00 - */ - getDate: function(date) { - return new Date(date.getFullYear(), date.getMonth(), date.getDate()); - } -}; - -module.exports = DateUtil; - -}); -define("bui-common/1.1.2/src/array-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 数组帮助类 - * @ignore - */ - -/** - * @class BUI - * 控件库的基础命名空间 - * @singleton - */ - - -var BUI = require("bui-common/1.1.2/src/util-debug"); -/** - * @class BUI.Array - * 数组帮助类 - */ -var ArrayUtil = { - /** - * 返回数组的最后一个对象 - * @param {Array} array 数组或者类似于数组的对象. - * @return {*} 数组的最后一项. - */ - peek: function(array) { - return array[array.length - 1]; - }, - /** - * 查找记录所在的位置 - * @param {*} value 值 - * @param {Array} array 数组或者类似于数组的对象 - * @param {Number} [fromIndex=0] 起始项,默认为0 - * @return {Number} 位置,如果为 -1则不在数组内 - */ - indexOf: function(value, array, opt_fromIndex) { - var fromIndex = opt_fromIndex == null ? - 0 : (opt_fromIndex < 0 ? - Math.max(0, array.length + opt_fromIndex) : opt_fromIndex); - - for (var i = fromIndex; i < array.length; i++) { - if (i in array && array[i] === value) - return i; - } - return -1; - }, - /** - * 数组是否存在指定值 - * @param {*} value 值 - * @param {Array} array 数组或者类似于数组的对象 - * @return {Boolean} 是否存在于数组中 - */ - contains: function(value, array) { - return ArrayUtil.indexOf(value, array) >= 0; - }, - /** - * 遍历数组或者对象 - * @method - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){} - */ - each: BUI.each, - /** - * 2个数组内部的值是否相等 - * @param {Array} a1 数组1 - * @param {Array} a2 数组2 - * @return {Boolean} 2个数组相等或者内部元素是否相等 - */ - equals: function(a1, a2) { - if (a1 == a2) { - return true; - } - if (!a1 || !a2) { - return false; - } - - if (a1.length != a2.length) { - return false; - } - var rst = true; - for (var i = 0; i < a1.length; i++) { - if (a1[i] !== a2[i]) { - rst = false; - break; - } - } - return rst; - }, - - /** - * 过滤数组 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){},如果返回true则添加到结果集 - * @return {Array} 过滤的结果集 - */ - filter: function(array, func) { - var result = []; - ArrayUtil.each(array, function(value, index) { - if (func(value, index)) { - result.push(value); - } - }); - return result; - }, - /** - * 转换数组数组 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){},将返回的结果添加到结果集 - * @return {Array} 过滤的结果集 - */ - map: function(array, func) { - var result = []; - ArrayUtil.each(array, function(value, index) { - result.push(func(value, index)); - }); - return result; - }, - /** - * 获取第一个符合条件的数据 - * @param {Array} array 数组 - * @param {Function} func 匹配函数 - * @return {*} 符合条件的数据 - */ - find: function(array, func) { - var i = ArrayUtil.findIndex(array, func); - return i < 0 ? null : array[i]; - }, - /** - * 获取第一个符合条件的数据的索引值 - * @param {Array} array 数组 - * @param {Function} func 匹配函数 - * @return {Number} 符合条件的数据的索引值 - */ - findIndex: function(array, func) { - var result = -1; - ArrayUtil.each(array, function(value, index) { - if (func(value, index)) { - result = index; - return false; - } - }); - return result; - }, - /** - * 数组是否为空 - * @param {Array} array 数组 - * @return {Boolean} 是否为空 - */ - isEmpty: function(array) { - return array.length == 0; - }, - /** - * 插入数组 - * @param {Array} array 数组 - * @param {Number} index 位置 - * @param {*} value 插入的数据 - */ - add: function(array, value) { - array.push(value); - }, - /** - * 将数据插入数组指定的位置 - * @param {Array} array 数组 - * @param {*} value 插入的数据 - * @param {Number} index 位置 - */ - addAt: function(array, value, index) { - ArrayUtil.splice(array, index, 0, value); - }, - /** - * 清空数组 - * @param {Array} array 数组 - * @return {Array} 清空后的数组 - */ - empty: function(array) { - if (!(array instanceof(Array))) { - for (var i = array.length - 1; i >= 0; i--) { - delete array[i]; - } - } - array.length = 0; - }, - /** - * 移除记录 - * @param {Array} array 数组 - * @param {*} value 记录 - * @return {Boolean} 是否移除成功 - */ - remove: function(array, value) { - var i = ArrayUtil.indexOf(value, array); - var rv; - if ((rv = i >= 0)) { - ArrayUtil.removeAt(array, i); - } - return rv; - }, - /** - * 移除指定位置的记录 - * @param {Array} array 数组 - * @param {Number} index 索引值 - * @return {Boolean} 是否移除成功 - */ - removeAt: function(array, index) { - return ArrayUtil.splice(array, index, 1).length == 1; - }, - /** - * @private - */ - slice: function(arr, start, opt_end) { - if (arguments.length <= 2) { - return Array.prototype.slice.call(arr, start); - } else { - return Array.prototype.slice.call(arr, start, opt_end); - } - }, - /** - * @private - */ - splice: function(arr, index, howMany, var_args) { - return Array.prototype.splice.apply(arr, ArrayUtil.slice(arguments, 1)) - } - -}; - -module.exports = ArrayUtil; - -}); -define("bui-common/1.1.2/src/keycode-debug", [], function(require, exports, module){ -/** - * @fileOverview 键盘值 - * @ignore - */ - -/** - * 键盘按键对应的数字值 - * @class BUI.KeyCode - * @singleton - */ -var keyCode = { - /** Key constant @type Number */ - BACKSPACE: 8, - /** Key constant @type Number */ - TAB: 9, - /** Key constant @type Number */ - NUM_CENTER: 12, - /** Key constant @type Number */ - ENTER: 13, - /** Key constant @type Number */ - RETURN: 13, - /** Key constant @type Number */ - SHIFT: 16, - /** Key constant @type Number */ - CTRL: 17, - /** Key constant @type Number */ - ALT: 18, - /** Key constant @type Number */ - PAUSE: 19, - /** Key constant @type Number */ - CAPS_LOCK: 20, - /** Key constant @type Number */ - ESC: 27, - /** Key constant @type Number */ - SPACE: 32, - /** Key constant @type Number */ - PAGE_UP: 33, - /** Key constant @type Number */ - PAGE_DOWN: 34, - /** Key constant @type Number */ - END: 35, - /** Key constant @type Number */ - HOME: 36, - /** Key constant @type Number */ - LEFT: 37, - /** Key constant @type Number */ - UP: 38, - /** Key constant @type Number */ - RIGHT: 39, - /** Key constant @type Number */ - DOWN: 40, - /** Key constant @type Number */ - PRINT_SCREEN: 44, - /** Key constant @type Number */ - INSERT: 45, - /** Key constant @type Number */ - DELETE: 46, - /** Key constant @type Number */ - ZERO: 48, - /** Key constant @type Number */ - ONE: 49, - /** Key constant @type Number */ - TWO: 50, - /** Key constant @type Number */ - THREE: 51, - /** Key constant @type Number */ - FOUR: 52, - /** Key constant @type Number */ - FIVE: 53, - /** Key constant @type Number */ - SIX: 54, - /** Key constant @type Number */ - SEVEN: 55, - /** Key constant @type Number */ - EIGHT: 56, - /** Key constant @type Number */ - NINE: 57, - /** Key constant @type Number */ - A: 65, - /** Key constant @type Number */ - B: 66, - /** Key constant @type Number */ - C: 67, - /** Key constant @type Number */ - D: 68, - /** Key constant @type Number */ - E: 69, - /** Key constant @type Number */ - F: 70, - /** Key constant @type Number */ - G: 71, - /** Key constant @type Number */ - H: 72, - /** Key constant @type Number */ - I: 73, - /** Key constant @type Number */ - J: 74, - /** Key constant @type Number */ - K: 75, - /** Key constant @type Number */ - L: 76, - /** Key constant @type Number */ - M: 77, - /** Key constant @type Number */ - N: 78, - /** Key constant @type Number */ - O: 79, - /** Key constant @type Number */ - P: 80, - /** Key constant @type Number */ - Q: 81, - /** Key constant @type Number */ - R: 82, - /** Key constant @type Number */ - S: 83, - /** Key constant @type Number */ - T: 84, - /** Key constant @type Number */ - U: 85, - /** Key constant @type Number */ - V: 86, - /** Key constant @type Number */ - W: 87, - /** Key constant @type Number */ - X: 88, - /** Key constant @type Number */ - Y: 89, - /** Key constant @type Number */ - Z: 90, - /** Key constant @type Number */ - CONTEXT_MENU: 93, - /** Key constant @type Number */ - NUM_ZERO: 96, - /** Key constant @type Number */ - NUM_ONE: 97, - /** Key constant @type Number */ - NUM_TWO: 98, - /** Key constant @type Number */ - NUM_THREE: 99, - /** Key constant @type Number */ - NUM_FOUR: 100, - /** Key constant @type Number */ - NUM_FIVE: 101, - /** Key constant @type Number */ - NUM_SIX: 102, - /** Key constant @type Number */ - NUM_SEVEN: 103, - /** Key constant @type Number */ - NUM_EIGHT: 104, - /** Key constant @type Number */ - NUM_NINE: 105, - /** Key constant @type Number */ - NUM_MULTIPLY: 106, - /** Key constant @type Number */ - NUM_PLUS: 107, - /** Key constant @type Number */ - NUM_MINUS: 109, - /** Key constant @type Number */ - NUM_PERIOD: 110, - /** Key constant @type Number */ - NUM_DIVISION: 111, - /** Key constant @type Number */ - F1: 112, - /** Key constant @type Number */ - F2: 113, - /** Key constant @type Number */ - F3: 114, - /** Key constant @type Number */ - F4: 115, - /** Key constant @type Number */ - F5: 116, - /** Key constant @type Number */ - F6: 117, - /** Key constant @type Number */ - F7: 118, - /** Key constant @type Number */ - F8: 119, - /** Key constant @type Number */ - F9: 120, - /** Key constant @type Number */ - F10: 121, - /** Key constant @type Number */ - F11: 122, - /** Key constant @type Number */ - F12: 123 -}; - -module.exports = keyCode; - -}); -define("bui-common/1.1.2/src/observable-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 观察者模式实现事件 - * @ignore - */ - -var $ = require('jquery'); - -var BUI = require("bui-common/1.1.2/src/util-debug"), - ArrayUtil = require("bui-common/1.1.2/src/array-debug"); -/** - * @private - * @class BUI.Observable.Callbacks - * jquery 1.7 时存在 $.Callbacks,但是fireWith的返回结果是$.Callbacks 对象, - * 而我们想要的效果是:当其中有一个函数返回为false时,阻止后面的执行,并返回false - */ -var Callbacks = function() { - this._init(); -}; - -BUI.augment(Callbacks, { - - _functions: null, - - _init: function() { - var _self = this; - - _self._functions = []; - }, - /** - * 添加回调函数 - * @param {Function} fn 回调函数 - */ - add: function(fn) { - this._functions.push(fn); - }, - /** - * 移除回调函数 - * @param {Function} fn 回调函数 - */ - remove: function(fn) { - var functions = this._functions; - index = ArrayUtil.indexOf(fn, functions); - if (index >= 0) { - functions.splice(index, 1); - } - }, - /** - * 清空事件 - */ - empty: function() { - var length = this._functions.length; //ie6,7下,必须指定需要删除的数量 - this._functions.splice(0, length); - }, - /** - * 暂停事件 - */ - pause: function() { - this._paused = true; - }, - /** - * 唤醒事件 - */ - resume: function() { - this._paused = false; - }, - /** - * 触发回调 - * @param {Object} scope 上下文 - * @param {Array} args 回调函数的参数 - * @return {Boolean|undefined} 当其中有一个函数返回为false时,阻止后面的执行,并返回false - */ - fireWith: function(scope, args) { - var _self = this, - rst; - if (_self._paused) { - return; - } - BUI.each(_self._functions, function(fn) { - rst = fn.apply(scope, args); - if (rst === false) { - return false; - } - }); - return rst; - } -}); - -function getCallbacks() { - return new Callbacks(); -} -/** - * 支持事件的对象,参考观察者模式 - * - 此类提供事件绑定 - * - 提供事件冒泡机制 - * - *

- *   var control = new Control();
- *   control.on('click',function(ev){
- *
- *   });
- *
- *   control.off();  //移除所有事件
- * 
- * @class BUI.Observable - * @abstract - * @param {Object} config 配置项键值对 - */ -var Observable = function(config) { - this._events = []; - this._eventMap = {}; - this._bubblesEvents = []; - this._initEvents(config); -}; - -BUI.augment(Observable, { - - /** - * @cfg {Object} listeners - * 初始化事件,快速注册事件 - *

-   *    var list = new BUI.List.SimpleList({
-   *      listeners : {
-   *        itemclick : function(ev){},
-   *        itemrendered : function(ev){}
-   *      },
-   *      items : []
-   *    });
-   *    list.render();
-   *  
- */ - - /** - * @cfg {Function} handler - * 点击事件的处理函数,快速配置点击事件而不需要写listeners属性 - *

-   *    var list = new BUI.List.SimpleList({
-   *      handler : function(ev){} //click 事件
-   *    });
-   *    list.render();
-   *  
- */ - - /** - * 支持的事件名列表 - * @private - */ - _events: [], - - /** - * 绑定的事件 - * @private - */ - _eventMap: {}, - - _bubblesEvents: [], - - _bubbleTarget: null, - - //获取回调集合 - _getCallbacks: function(eventType) { - var _self = this, - eventMap = _self._eventMap; - return eventMap[eventType]; - }, - //初始化事件列表 - _initEvents: function(config) { - var _self = this, - listeners = null; - - if (!config) { - return; - } - listeners = config.listeners || {}; - if (config.handler) { - listeners.click = config.handler; - } - if (listeners) { - for (var name in listeners) { - if (listeners.hasOwnProperty(name)) { - _self.on(name, listeners[name]); - } - }; - } - }, - //事件是否支持冒泡 - _isBubbles: function(eventType) { - return ArrayUtil.indexOf(eventType, this._bubblesEvents) >= 0; - }, - /** - * 添加冒泡的对象 - * @protected - * @param {Object} target 冒泡的事件源 - */ - addTarget: function(target) { - this._bubbleTarget = target; - }, - /** - * 添加支持的事件 - * @protected - * @param {String|String[]} events 事件 - */ - addEvents: function(events) { - var _self = this, - existEvents = _self._events, - eventMap = _self._eventMap; - - function addEvent(eventType) { - if (ArrayUtil.indexOf(eventType, existEvents) === -1) { - eventMap[eventType] = getCallbacks(); - existEvents.push(eventType); - } - } - if (BUI.isArray(events)) { - BUI.each(events, function(eventType) { - addEvent(eventType); - }); - } else { - addEvent(events); - } - }, - /** - * 移除所有绑定的事件 - * @protected - */ - clearListeners: function() { - var _self = this, - eventMap = _self._eventMap; - for (var name in eventMap) { - if (eventMap.hasOwnProperty(name)) { - eventMap[name].empty(); - } - } - }, - /** - * 触发事件 - *

-   *   //绑定事件
-   *   list.on('itemclick',function(ev){
-   *     alert('21');
-   *   });
-   *   //触发事件
-   *   list.fire('itemclick');
-   * 
- * @param {String} eventType 事件类型 - * @param {Object} eventData 事件触发时传递的数据 - * @return {Boolean|undefined} 如果其中一个事件处理器返回 false , 则返回 false, 否则返回最后一个事件处理器的返回值 - */ - fire: function(eventType, eventData) { - var _self = this, - callbacks = _self._getCallbacks(eventType), - args = $.makeArray(arguments), - result; - if (!eventData) { - eventData = {}; - args.push(eventData); - } - if (!eventData.target) { - eventData.target = _self; - } - if (callbacks) { - result = callbacks.fireWith(_self, Array.prototype.slice.call(args, 1)); - } - if (_self._isBubbles(eventType)) { - var bubbleTarget = _self._bubbleTarget; - if (bubbleTarget && bubbleTarget.fire) { - bubbleTarget.fire(eventType, eventData); - } - } - return result; - }, - /** - * 暂停事件的执行 - *

-   *  list.pauseEvent('itemclick');
-   * 
- * @param {String} eventType 事件类型 - */ - pauseEvent: function(eventType) { - var _self = this, - callbacks = _self._getCallbacks(eventType); - callbacks && callbacks.pause(); - }, - /** - * 唤醒事件 - *

-   *  list.resumeEvent('itemclick');
-   * 
- * @param {String} eventType 事件类型 - */ - resumeEvent: function(eventType) { - var _self = this, - callbacks = _self._getCallbacks(eventType); - callbacks && callbacks.resume(); - }, - /** - * 添加绑定事件 - *

-   *   //绑定单个事件
-   *   list.on('itemclick',function(ev){
-   *     alert('21');
-   *   });
-   *   //绑定多个事件
-   *   list.on('itemrendered itemupdated',function(){
-   *     //列表项创建、更新时触发操作
-   *   });
-   * 
- * @param {String} eventType 事件类型 - * @param {Function} fn 回调函数 - */ - on: function(eventType, fn) { - //一次监听多个事件 - var arr = eventType.split(' '), - _self = this, - callbacks = null; - if (arr.length > 1) { - BUI.each(arr, function(name) { - _self.on(name, fn); - }); - } else { - callbacks = _self._getCallbacks(eventType); - if (callbacks) { - callbacks.add(fn); - } else { - _self.addEvents(eventType); - _self.on(eventType, fn); - } - } - return _self; - }, - /** - * 移除绑定的事件 - *

-   *  //移除所有事件
-   *  list.off();
-   *
-   *  //移除特定事件
-   *  function callback(ev){}
-   *  list.on('click',callback);
-   *
-   *  list.off('click',callback);//需要保存回调函数的引用
-   *
-   * 
- * @param {String} eventType 事件类型 - * @param {Function} fn 回调函数 - */ - off: function(eventType, fn) { - if (!eventType && !fn) { - this.clearListeners(); - return this; - } - var _self = this, - callbacks = _self._getCallbacks(eventType); - if (callbacks) { - if (fn) { - callbacks.remove(fn); - } else { - callbacks.empty(); - } - - } - return _self; - }, - /** - * 配置事件是否允许冒泡 - * @protected - * @param {String} eventType 支持冒泡的事件 - * @param {Object} cfg 配置项 - * @param {Boolean} cfg.bubbles 是否支持冒泡 - */ - publish: function(eventType, cfg) { - var _self = this, - bubblesEvents = _self._bubblesEvents; - - if (cfg.bubbles) { - if (BUI.Array.indexOf(eventType, bubblesEvents) === -1) { - bubblesEvents.push(eventType); - } - } else { - var index = BUI.Array.indexOf(eventType, bubblesEvents); - if (index !== -1) { - bubblesEvents.splice(index, 1); - } - } - } -}); - -module.exports = Observable; - -}); -define("bui-common/1.1.2/src/base-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview Base UI控件的最基础的类 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -var INVALID = {}, - Observable = require("bui-common/1.1.2/src/observable-debug"); - -function ensureNonEmpty(obj, name, create) { - var ret = obj[name] || {}; - if (create) { - obj[name] = ret; - } - return ret; -} - -function normalFn(host, method) { - if (BUI.isString(method)) { - return host[method]; - } - return method; -} - -function __fireAttrChange(self, when, name, prevVal, newVal) { - var attrName = name; - return self.fire(when + BUI.ucfirst(name) + 'Change', { - attrName: attrName, - prevVal: prevVal, - newVal: newVal - }); -} - -function setInternal(self, name, value, opts, attrs) { - opts = opts || {}; - - var ret, - subVal, - prevVal; - - prevVal = self.get(name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return undefined; - } - // check before event - if (!opts['silent']) { - if (false === __fireAttrChange(self, 'before', name, prevVal, value)) { - return false; - } - } - // set it - ret = self._set(name, value, opts); - - if (ret === false) { - return ret; - } - - // fire after event - if (!opts['silent']) { - value = self.__attrVals[name]; - __fireAttrChange(self, 'after', name, prevVal, value); - } - return self; -} - -function initClassAttrs(c) { - if (c._attrs || c == Base) { - return; - } - - var superCon = c.superclass.constructor; - if (superCon && !superCon._attrs) { - initClassAttrs(superCon); - } - c._attrs = {}; - - BUI.mixAttrs(c._attrs, superCon._attrs); - BUI.mixAttrs(c._attrs, c.ATTRS); -} -/** - * 基础类,此类提供以下功能 - * - 提供设置获取属性 - * - 提供事件支持 - * - 属性变化时会触发对应的事件 - * - 将配置项自动转换成属性 - * - * ** 创建类,继承BUI.Base类 ** - *

- *   var Control = function(cfg){
- *     Control.superclass.constructor.call(this,cfg); //调用BUI.Base的构造方法,将配置项变成属性
- *   };
- *
- *   BUI.extend(Control,BUI.Base);
- * 
- * - * ** 声明默认属性 ** - *

- *   Control.ATTRS = {
- *     id : {
- *       value : 'id' //value 是此属性的默认值
- *     },
- *     renderTo : {
- *
- *     },
- *     el : {
- *       valueFn : function(){                 //第一次调用的时候将renderTo的DOM转换成el属性
- *         return $(this.get('renderTo'));
- *       }
- *     },
- *     text : {
- *       getter : function(){ //getter 用于获取值,而不是设置的值
- *         return this.get('el').val();
- *       },
- *       setter : function(v){ //不仅仅是设置值,可以进行相应的操作
- *         this.get('el').val(v);
- *       }
- *     }
- *   };
- * 
- * - * ** 声明类的方法 ** - *

- *   BUI.augment(Control,{
- *     getText : function(){
- *       return this.get('text');   //可以用get方法获取属性值
- *     },
- *     setText : function(txt){
- *       this.set('text',txt);      //使用set 设置属性值
- *     }
- *   });
- * 
- * - * ** 创建对象 ** - *

- *   var c = new Control({
- *     id : 'oldId',
- *     text : '测试文本',
- *     renderTo : '#t1'
- *   });
- *
- *   var el = c.get(el); //$(#t1);
- *   el.val(); //text的值 : '测试文本'
- *   c.set('text','修改的值');
- *   el.val();  //'修改的值'
- *
- *   c.set('id','newId') //会触发2个事件: beforeIdChange,afterIdChange 2个事件 ev.newVal 和ev.prevVal标示新旧值
- * 
- * @class BUI.Base - * @abstract - * @extends BUI.Observable - * @param {Object} config 配置项 - */ -var Base = function(config) { - var _self = this, - c = _self.constructor, - constructors = []; - this.__attrs = {}; - this.__attrVals = {}; - Observable.apply(this, arguments); - // define - while (c) { - constructors.push(c); - if (c.extensions) { //延迟执行mixin - BUI.mixin(c, c.extensions); - delete c.extensions; - } - //_self.addAttrs(c['ATTRS']); - c = c.superclass ? c.superclass.constructor : null; - } - //以当前对象的属性最终添加到属性中,覆盖之前的属性 - /*for (var i = constructors.length - 1; i >= 0; i--) { - _self.addAttrs(constructors[i]['ATTRS'],true); - };*/ - var con = _self.constructor; - initClassAttrs(con); - _self._initStaticAttrs(con._attrs); - _self._initAttrs(config); -}; - -Base.INVALID = INVALID; - -BUI.extend(Base, Observable); - -BUI.augment(Base, { - _initStaticAttrs: function(attrs) { - var _self = this, - __attrs; - - __attrs = _self.__attrs = {}; - for (var p in attrs) { - if (attrs.hasOwnProperty(p)) { - var attr = attrs[p]; - /*if(BUI.isObject(attr.value) || BUI.isArray(attr.value) || attr.valueFn){*/ - if (attr.shared === false || attr.valueFn) { - __attrs[p] = {}; - BUI.mixAttr(__attrs[p], attrs[p]); - } else { - __attrs[p] = attrs[p]; - } - } - }; - }, - /** - * 添加属性定义 - * @protected - * @param {String} name 属性名 - * @param {Object} attrConfig 属性定义 - * @param {Boolean} overrides 是否覆盖字段 - */ - addAttr: function(name, attrConfig, overrides) { - var _self = this, - attrs = _self.__attrs, - attr = attrs[name]; - - if (!attr) { - attr = attrs[name] = {}; - } - for (var p in attrConfig) { - if (attrConfig.hasOwnProperty(p)) { - if (p == 'value') { - if (BUI.isObject(attrConfig[p])) { - attr[p] = attr[p] || {}; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else if (BUI.isArray(attrConfig[p])) { - attr[p] = attr[p] || []; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else { - attr[p] = attrConfig[p]; - } - } else { - attr[p] = attrConfig[p]; - } - } - - }; - return _self; - }, - /** - * 添加属性定义 - * @protected - * @param {Object} attrConfigs An object with attribute name/configuration pairs. - * @param {Object} initialValues user defined initial values - * @param {Boolean} overrides 是否覆盖字段 - */ - addAttrs: function(attrConfigs, initialValues, overrides) { - var _self = this; - if (!attrConfigs) { - return _self; - } - if (typeof(initialValues) === 'boolean') { - overrides = initialValues; - initialValues = null; - } - BUI.each(attrConfigs, function(attrConfig, name) { - _self.addAttr(name, attrConfig, overrides); - }); - if (initialValues) { - _self.set(initialValues); - } - return _self; - }, - /** - * 是否包含此属性 - * @protected - * @param {String} name 值 - * @return {Boolean} 是否包含 - */ - hasAttr: function(name) { - return name && this.__attrs.hasOwnProperty(name); - }, - /** - * 获取默认的属性值 - * @protected - * @return {Object} 属性值的键值对 - */ - getAttrs: function() { - return this.__attrs; //ensureNonEmpty(this, '__attrs', true); - }, - /** - * 获取属性名/属性值键值对 - * @protected - * @return {Object} 属性对象 - */ - getAttrVals: function() { - return this.__attrVals; //ensureNonEmpty(this, '__attrVals', true); - }, - /** - * 获取属性值,所有的配置项和属性都可以通过get方法获取 - *

-   *  var control = new Control({
-   *   text : 'control text'
-   *  });
-   *  control.get('text'); //control text
-   *
-   *  control.set('customValue','value'); //临时变量
-   *  control.get('customValue'); //value
-   * 
- * ** 属性值/配置项 ** - *

-   *   Control.ATTRS = { //声明属性值
-   *     text : {
-   *       valueFn : function(){},
-   *       value : 'value',
-   *       getter : function(v){}
-   *     }
-   *   };
-   *   var c = new Control({
-   *     text : 'text value'
-   *   });
-   *   //get 函数取的顺序为:是否有修改值(配置项、set)、默认值(第一次调用执行valueFn),如果有getter,则将值传入getter返回
-   *
-   *   c.get('text') //text value
-   *   c.set('text','new text');//修改值
-   *   c.get('text');//new text
-   * 
- * @param {String} name 属性名 - * @return {Object} 属性值 - */ - get: function(name) { - var _self = this, - //declared = _self.hasAttr(name), - attrVals = _self.__attrVals, - attrConfig, - getter, - ret; - - attrConfig = ensureNonEmpty(_self.__attrs, name); - getter = attrConfig['getter']; - - // get user-set value or default value - //user-set value takes privilege - ret = name in attrVals ? - attrVals[name] : - _self._getDefAttrVal(name); - - // invoke getter for this attribute - if (getter && (getter = normalFn(_self, getter))) { - ret = getter.call(_self, ret, name); - } - - return ret; - }, - /** - * @清理所有属性值 - * @protected - */ - clearAttrVals: function() { - this.__attrVals = {}; - }, - /** - * 移除属性定义 - * @protected - */ - removeAttr: function(name) { - var _self = this; - - if (_self.hasAttr(name)) { - delete _self.__attrs[name]; - delete _self.__attrVals[name]; - } - - return _self; - }, - /** - * 设置属性值,会触发before+Name+Change,和 after+Name+Change事件 - *

-   *  control.on('beforeTextChange',function(ev){
-   *    var newVal = ev.newVal,
-   *      attrName = ev.attrName,
-   *      preVal = ev.prevVal;
-   *
-   *    //TO DO
-   *  });
-   *  control.set('text','new text');  //此时触发 beforeTextChange,afterTextChange
-   *  control.set('text','modify text',{silent : true}); //此时不触发事件
-   * 
- * @param {String|Object} name 属性名 - * @param {Object} value 值 - * @param {Object} opts 配置项 - * @param {Boolean} opts.silent 配置属性时,是否不触发事件 - */ - set: function(name, value, opts) { - var _self = this; - if ($.isPlainObject(name)) { - opts = value; - var all = Object(name), - attrs = []; - - for (name in all) { - if (all.hasOwnProperty(name)) { - setInternal(_self, name, all[name], opts); - } - } - return _self; - } - return setInternal(_self, name, value, opts); - }, - /** - * 设置属性,不触发事件 - *

-   *  control.setInternal('text','text');//此时不触发事件
-   * 
- * @param {String} name 属性名 - * @param {Object} value 属性值 - * @return {Boolean|undefined} 如果值无效则返回false,否则返回undefined - */ - setInternal: function(name, value, opts) { - return this._set(name, value, opts); - }, - //获取属性默认值 - _getDefAttrVal: function(name) { - var _self = this, - attrs = _self.__attrs, - attrConfig = ensureNonEmpty(attrs, name), - valFn = attrConfig.valueFn, - val; - - if (valFn && (valFn = normalFn(_self, valFn))) { - val = valFn.call(_self); - if (val !== undefined) { - attrConfig.value = val; - } - delete attrConfig.valueFn; - attrs[name] = attrConfig; - } - - return attrConfig.value; - }, - //仅仅设置属性值 - _set: function(name, value, opts) { - var _self = this, - setValue, - // if host does not have meta info corresponding to (name,value) - // then register on demand in order to collect all data meta info - // 一定要注册属性元数据,否则其他模块通过 _attrs 不能枚举到所有有效属性 - // 因为属性在声明注册前可以直接设置值 - attrConfig = ensureNonEmpty(_self.__attrs, name, true), - setter = attrConfig['setter']; - - // if setter has effect - if (setter && (setter = normalFn(_self, setter))) { - setValue = setter.call(_self, value, name); - } - - if (setValue === INVALID) { - return false; - } - - if (setValue !== undefined) { - value = setValue; - } - - // finally set - _self.__attrVals[name] = value; - return _self; - }, - //初始化属性 - _initAttrs: function(config) { - var _self = this; - if (config) { - for (var attr in config) { - if (config.hasOwnProperty(attr)) { - // 用户设置会调用 setter/validator 的,但不会触发属性变化事件 - _self._set(attr, config[attr]); - } - - } - } - } -}); -module.exports = Base; - -}); -define("bui-common/1.1.2/src/component/component-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview Component命名空间的入口文件 - * @ignore - */ - -/** - * @class BUI.Component - *

- * - *

- * 控件基类的命名空间 - */ -var Component = {}; - -BUI.mix(Component, { - Manager: require("bui-common/1.1.2/src/component/manage-debug"), - UIBase: require("bui-common/1.1.2/src/component/uibase/uibase-debug"), - View: require("bui-common/1.1.2/src/component/view-debug"), - Controller: require("bui-common/1.1.2/src/component/controller-debug") -}); - -function create(component, self) { - var childConstructor, xclass; - if (component && (xclass = component.xclass)) { - if (self && !component.prefixCls) { - component.prefixCls = self.get('prefixCls'); - } - childConstructor = Component.Manager.getConstructorByXClass(xclass); - if (!childConstructor) { - BUI.error('can not find class by xclass desc : ' + xclass); - } - component = new childConstructor(component); - } - return component; -} - -/** - * 根据Xclass创建对象 - * @method - * @static - * @param {Object} component 控件的配置项或者控件 - * @param {Object} self 父类实例 - * @return {Object} 实例对象 - */ -Component.create = create; - -module.exports = Component; - -}); -define("bui-common/1.1.2/src/component/manage-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview Base UI控件的管理类 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - - - -//控件类的管理器 - - -var $ = require('jquery'); - -var uis = { - // 不带前缀 prefixCls - /* - "menu" :{ - priority:0, - constructor:Menu - } - */ -}; - -function getConstructorByXClass(cls) { - var cs = cls.split(/\s+/), - p = -1, - t, - ui = null; - for (var i = 0; i < cs.length; i++) { - var uic = uis[cs[i]]; - if (uic && (t = uic.priority) > p) { - p = t; - ui = uic.constructor; - } - } - return ui; -} - -function getXClassByConstructor(constructor) { - for (var u in uis) { - var ui = uis[u]; - if (ui.constructor == constructor) { - return u; - } - } - return 0; -} - -function setConstructorByXClass(cls, uic) { - if (BUI.isFunction(uic)) { - uis[cls] = { - constructor: uic, - priority: 0 - }; - } else { - uic.priority = uic.priority || 0; - uis[cls] = uic; - } -} - - -function getCssClassWithPrefix(cls) { - var cs = $.trim(cls).split(/\s+/); - for (var i = 0; i < cs.length; i++) { - if (cs[i]) { - cs[i] = this.get('prefixCls') + cs[i]; - } - } - return cs.join(' '); -} - - - -var componentInstances = {}; - -/** - * Manage component metadata. - * @class BUI.Component.Manager - * @singleton - */ -var Manager = { - - __instances: componentInstances, - /** - * 每实例化一个控件,就注册到管理器上 - * @param {String} id 控件 id - * @param {BUI.Component.Controller} component 控件对象 - */ - addComponent: function(id, component) { - componentInstances[id] = component; - }, - /** - * 移除注册的控件 - * @param {String} id 控件 id - */ - removeComponent: function(id) { - delete componentInstances[id]; - }, - /** - * 遍历所有的控件 - * @param {Function} fn 遍历函数 - */ - eachComponent: function(fn) { - BUI.each(componentInstances, fn); - }, - /** - * 根据Id获取控件 - * @param {String} id 编号 - * @return {BUI.Component.UIBase} 继承 UIBase的类对象 - */ - getComponent: function(id) { - return componentInstances[id]; - }, - - getCssClassWithPrefix: getCssClassWithPrefix, - /** - * 通过构造函数获取xclass. - * @param {Function} constructor 控件的构造函数. - * @type {Function} - * @return {String} - * @method - */ - getXClassByConstructor: getXClassByConstructor, - /** - * 通过xclass获取控件的构造函数 - * @param {String} classNames Class names separated by space. - * @type {Function} - * @return {Function} - * @method - */ - getConstructorByXClass: getConstructorByXClass, - /** - * 将 xclass 同构造函数相关联. - * @type {Function} - * @param {String} className 控件的xclass名称. - * @param {Function} componentConstructor 构造函数 - * @method - */ - setConstructorByXClass: setConstructorByXClass -}; - -module.exports = Manager; - -}); -define("bui-common/1.1.2/src/component/uibase/uibase-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview uibase的入口文件 - * @ignore - */ -var UIBase = require("bui-common/1.1.2/src/component/uibase/base-debug"); - -BUI.mix(UIBase, { - Align: require("bui-common/1.1.2/src/component/uibase/align-debug"), - AutoShow: require("bui-common/1.1.2/src/component/uibase/autoshow-debug"), - AutoHide: require("bui-common/1.1.2/src/component/uibase/autohide-debug"), - Close: require("bui-common/1.1.2/src/component/uibase/close-debug"), - Collapsable: require("bui-common/1.1.2/src/component/uibase/collapsable-debug"), - Drag: require("bui-common/1.1.2/src/component/uibase/drag-debug"), - KeyNav: require("bui-common/1.1.2/src/component/uibase/keynav-debug"), - List: require("bui-common/1.1.2/src/component/uibase/list-debug"), - ListItem: require("bui-common/1.1.2/src/component/uibase/listitem-debug"), - Mask: require("bui-common/1.1.2/src/component/uibase/mask-debug"), - Position: require("bui-common/1.1.2/src/component/uibase/position-debug"), - Selection: require("bui-common/1.1.2/src/component/uibase/selection-debug"), - StdMod: require("bui-common/1.1.2/src/component/uibase/stdmod-debug"), - Decorate: require("bui-common/1.1.2/src/component/uibase/decorate-debug"), - Tpl: require("bui-common/1.1.2/src/component/uibase/tpl-debug"), - ChildCfg: require("bui-common/1.1.2/src/component/uibase/childcfg-debug"), - Bindable: require("bui-common/1.1.2/src/component/uibase/bindable-debug"), - Depends: require("bui-common/1.1.2/src/component/uibase/depends-debug") -}); - -BUI.mix(UIBase, { - CloseView: UIBase.Close.View, - CollapsableView: UIBase.Collapsable.View, - ChildList: UIBase.List.ChildList, - /*DomList : UIBase.List.DomList, - DomListView : UIBase.List.DomList.View,*/ - ListItemView: UIBase.ListItem.View, - MaskView: UIBase.Mask.View, - PositionView: UIBase.Position.View, - StdModView: UIBase.StdMod.View, - TplView: UIBase.Tpl.View -}); - -module.exports = UIBase; - -}); -define("bui-common/1.1.2/src/component/uibase/base-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview UI控件的流程控制 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -var Manager = require("bui-common/1.1.2/src/component/manage-debug"), - - UI_SET = '_uiSet', - ATTRS = 'ATTRS', - ucfirst = BUI.ucfirst, - noop = $.noop, - Base = require("bui-common/1.1.2/src/base-debug"); -/** - * 模拟多继承 - * init attr using constructors ATTRS meta info - * @ignore - */ -function initHierarchy(host, config) { - callMethodByHierarchy(host, 'initializer', 'constructor'); -} - -function callMethodByHierarchy(host, mainMethod, extMethod) { - var c = host.constructor, - extChains = [], - ext, - main, - exts, - t; - - // define - while (c) { - - // 收集扩展类 - t = []; - if (exts = c.mixins) { - for (var i = 0; i < exts.length; i++) { - ext = exts[i]; - if (ext) { - if (extMethod != 'constructor') { - //只调用真正自己构造器原型的定义,继承原型链上的不要管 - if (ext.prototype.hasOwnProperty(extMethod)) { - ext = ext.prototype[extMethod]; - } else { - ext = null; - } - } - ext && t.push(ext); - } - } - } - - // 收集主类 - // 只调用真正自己构造器原型的定义,继承原型链上的不要管 !important - // 所以不用自己在 renderUI 中调用 superclass.renderUI 了,UIBase 构造器自动搜寻 - // 以及 initializer 等同理 - if (c.prototype.hasOwnProperty(mainMethod) && (main = c.prototype[mainMethod])) { - t.push(main); - } - - // 原地 reverse - if (t.length) { - extChains.push.apply(extChains, t.reverse()); - } - - c = c.superclass && c.superclass.constructor; - } - - // 初始化函数 - // 顺序:父类的所有扩展类函数 -> 父类对应函数 -> 子类的所有扩展函数 -> 子类对应函数 - for (i = extChains.length - 1; i >= 0; i--) { - extChains[i] && extChains[i].call(host); - } -} - -/** - * 销毁组件顺序: 子类 destructor -> 子类扩展 destructor -> 父类 destructor -> 父类扩展 destructor - * @ignore - */ -function destroyHierarchy(host) { - var c = host.constructor, - extensions, - d, - i; - - while (c) { - // 只触发该类真正的析构器,和父亲没关系,所以不要在子类析构器中调用 superclass - if (c.prototype.hasOwnProperty('destructor')) { - c.prototype.destructor.apply(host); - } - - if ((extensions = c.mixins)) { - for (i = extensions.length - 1; i >= 0; i--) { - d = extensions[i] && extensions[i].prototype.__destructor; - d && d.apply(host); - } - } - - c = c.superclass && c.superclass.constructor; - } -} - -/** - * 构建 插件 - * @ignore - */ -function constructPlugins(plugins) { - if (!plugins) { - return; - } - BUI.each(plugins, function(plugin, i) { - if (BUI.isFunction(plugin)) { - plugins[i] = new plugin(); - } - }); -} - -/** - * 调用插件的方法 - * @ignore - */ -function actionPlugins(self, plugins, action) { - if (!plugins) { - return; - } - BUI.each(plugins, function(plugin, i) { - if (plugin[action]) { - plugin[action](self); - } - }); -} - -/** - * 根据属性变化设置 UI - * @ignore - */ -function bindUI(self) { - /*var attrs = self.getAttrs(), - attr, - m; - - for (attr in attrs) { - if (attrs.hasOwnProperty(attr)) { - m = UI_SET + ucfirst(attr); - if (self[m]) { - // 自动绑定事件到对应函数 - (function (attr, m) { - self.on('after' + ucfirst(attr) + 'Change', function (ev) { - // fix! 防止冒泡过来的 - if (ev.target === self) { - self[m](ev.newVal, ev); - } - }); - })(attr, m); - } - } - } - */ -} - -/** - * 根据当前(初始化)状态来设置 UI - * @ignore - */ -function syncUI(self) { - var v, - f, - attrs = self.getAttrs(); - for (var a in attrs) { - if (attrs.hasOwnProperty(a)) { - var m = UI_SET + ucfirst(a); - //存在方法,并且用户设置了初始值或者存在默认值,就同步状态 - if ((f = self[m]) - // 用户如果设置了显式不同步,就不同步,比如一些值从 html 中读取,不需要同步再次设置 - && attrs[a].sync !== false && (v = self.get(a)) !== undefined) { - f.call(self, v); - } - } - } -} - -/** - * 控件库的基类,包括控件的生命周期,下面是基本的扩展类 - *

- * - *

- * @class BUI.Component.UIBase - * @extends BUI.Base - * @param {Object} config 配置项 - */ -var UIBase = function(config) { - - var _self = this, - id; - - // 读取用户设置的属性值并设置到自身 - Base.apply(_self, arguments); - - //保存用户传入的配置项 - _self.setInternal('userConfig', config); - // 按照类层次执行初始函数,主类执行 initializer 函数,扩展类执行构造器函数 - initHierarchy(_self, config); - - var listener, - n, - plugins = _self.get('plugins') - /*, - listeners = _self.get('listeners')*/ - ; - - constructPlugins(plugins); - - var xclass = _self.get('xclass'); - if (xclass) { - _self.__xclass = xclass; //debug 方便 - } - actionPlugins(_self, plugins, 'initializer'); - - // 是否自动渲染 - config && config.autoRender && _self.render(); - -}; - -UIBase.ATTRS = { - - - /** - * 用户传入的配置项 - * @type {Object} - * @readOnly - * @protected - */ - userConfig: { - - }, - /** - * 是否自动渲染,如果不自动渲染,需要用户调用 render()方法 - *

-   *  //默认状态下创建对象,并没有进行render
-   *  var control = new Control();
-   *  control.render(); //需要调用render方法
-   *
-   *  //设置autoRender后,不需要调用render方法
-   *  var control = new Control({
-   *   autoRender : true
-   *  });
-   * 
- * @cfg {Boolean} autoRender - */ - /** - * 是否自动渲染,如果不自动渲染,需要用户调用 render()方法 - * @type {Boolean} - * @ignore - */ - autoRender: { - value: false - }, - /** - * @type {Object} - * 事件处理函数: - * { - * 'click':function(e){} - * } - * @ignore - */ - listeners: { - value: {} - }, - /** - * 插件集合 - *

-   *  var grid = new Grid({
-   *    columns : [{},{}],
-   *    plugins : [Grid.Plugins.RadioSelection]
-   *  });
-   * 
- * @cfg {Array} plugins - */ - /** - * 插件集合 - * @type {Array} - * @readOnly - */ - plugins: { - //value : [] - }, - /** - * 是否已经渲染完成 - * @type {Boolean} - * @default false - * @readOnly - */ - rendered: { - value: false - }, - /** - * 获取控件的 xclass - * @readOnly - * @type {String} - * @protected - */ - xclass: { - valueFn: function() { - return Manager.getXClassByConstructor(this.constructor); - } - } -}; - -BUI.extend(UIBase, Base); - -BUI.augment(UIBase, { - /** - * 创建DOM结构 - * @protected - */ - create: function() { - var self = this; - // 是否生成过节点 - if (!self.get('created')) { - /** - * @event beforeCreateDom - * fired before root node is created - * @param e - */ - self.fire('beforeCreateDom'); - callMethodByHierarchy(self, 'createDom', '__createDom'); - self._set('created', true); - /** - * @event afterCreateDom - * fired when root node is created - * @param e - */ - self.fire('afterCreateDom'); - actionPlugins(self, self.get('plugins'), 'createDom'); - } - return self; - }, - /** - * 渲染 - */ - render: function() { - var _self = this; - // 是否已经渲染过 - if (!_self.get('rendered')) { - var plugins = _self.get('plugins'); - _self.create(undefined); - _self.set('created', true); - /** - * @event beforeRenderUI - * fired when root node is ready - * @param e - */ - _self.fire('beforeRenderUI'); - callMethodByHierarchy(_self, 'renderUI', '__renderUI'); - - /** - * @event afterRenderUI - * fired after root node is rendered into dom - * @param e - */ - - _self.fire('afterRenderUI'); - actionPlugins(_self, plugins, 'renderUI'); - - /** - * @event beforeBindUI - * fired before UIBase 's internal event is bind. - * @param e - */ - - _self.fire('beforeBindUI'); - bindUI(_self); - callMethodByHierarchy(_self, 'bindUI', '__bindUI'); - _self.set('binded', true); - /** - * @event afterBindUI - * fired when UIBase 's internal event is bind. - * @param e - */ - - _self.fire('afterBindUI'); - actionPlugins(_self, plugins, 'bindUI'); - - /** - * @event beforeSyncUI - * fired before UIBase 's internal state is synchronized. - * @param e - */ - - _self.fire('beforeSyncUI'); - - syncUI(_self); - callMethodByHierarchy(_self, 'syncUI', '__syncUI'); - - /** - * @event afterSyncUI - * fired after UIBase 's internal state is synchronized. - * @param e - */ - - _self.fire('afterSyncUI'); - actionPlugins(_self, plugins, 'syncUI'); - _self._set('rendered', true); - } - return _self; - }, - /** - * 子类可继承此方法,当DOM创建时调用 - * @protected - * @method - */ - createDom: noop, - /** - * 子类可继承此方法,渲染UI时调用 - * @protected - * @method - */ - renderUI: noop, - /** - * 子类可继承此方法,绑定事件时调用 - * @protected - * @method - */ - bindUI: noop, - /** - * 同步属性值到UI上 - * @protected - * @method - */ - syncUI: noop, - - /** - * 析构函数 - */ - destroy: function() { - var _self = this; - if (_self.destroyed) { //防止返回销毁 - return _self; - } - /** - * @event beforeDestroy - * fired before UIBase 's destroy. - * @param e - */ - _self.fire('beforeDestroy'); - - actionPlugins(_self, _self.get('plugins'), 'destructor'); - destroyHierarchy(_self); - /** - * @event afterDestroy - * fired before UIBase 's destroy. - * @param e - */ - _self.fire('afterDestroy'); - _self.off(); - _self.clearAttrVals(); - _self.destroyed = true; - return _self; - } -}); - -//延时处理构造函数 -function initConstuctor(c) { - var constructors = []; - while (c.base) { - constructors.push(c); - c = c.base; - } - for (var i = constructors.length - 1; i >= 0; i--) { - var C = constructors[i]; - //BUI.extend(C,C.base,C.px,C.sx); - BUI.mix(C.prototype, C.px); - BUI.mix(C, C.sx); - C.base = null; - C.px = null; - C.sx = null; - } -} - -BUI.mix(UIBase, { - /** - * 定义一个类 - * @static - * @param {Function} base 基类构造函数 - * @param {Array} extensions 扩展 - * @param {Object} px 原型链上的扩展 - * @param {Object} sx - * @return {Function} 继承与基类的构造函数 - */ - define: function(base, extensions, px, sx) { - if ($.isPlainObject(extensions)) { - sx = px; - px = extensions; - extensions = []; - } - - function C() { - var c = this.constructor; - if (c.base) { - initConstuctor(c); - } - UIBase.apply(this, arguments); - } - - BUI.extend(C, base); //无法延迟 - C.base = base; - C.px = px; //延迟复制原型链上的函数 - C.sx = sx; //延迟复制静态属性 - - //BUI.mixin(C,extensions); - if (extensions.length) { //延迟执行mixin - C.extensions = extensions; - } - - return C; - }, - /** - * 扩展一个类,基类就是类本身 - * @static - * @param {Array} extensions 扩展 - * @param {Object} px 原型链上的扩展 - * @param {Object} sx - * @return {Function} 继承与基类的构造函数 - */ - extend: function extend(extensions, px, sx) { - var args = $.makeArray(arguments), - ret, - last = args[args.length - 1]; - args.unshift(this); - if (last.xclass) { - args.pop(); - args.push(last.xclass); - } - ret = UIBase.define.apply(UIBase, args); - if (last.xclass) { - var priority = last.priority || (this.priority ? (this.priority + 1) : 1); - - Manager.setConstructorByXClass(last.xclass, { - constructor: ret, - priority: priority - }); - //方便调试 - ret.__xclass = last.xclass; - ret.priority = priority; - ret.toString = function() { - return last.xclass; - } - } - ret.extend = extend; - return ret; - } -}); - -module.exports = UIBase; - -}); -define("bui-common/1.1.2/src/component/uibase/align-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 跟指定的元素项对齐的方式 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'), - UA = require("bui-common/1.1.2/src/ua-debug"), - CLS_ALIGN_PREFIX ='x-align-', - win = window; - -// var ieMode = document.documentMode || UA.ie; - -/* - inspired by closure library by Google - see http://yiminghe.iteye.com/blog/1124720 - */ - -/** - * 得到会导致元素显示不全的祖先元素 - * @ignore - */ -function getOffsetParent(element) { - // ie 这个也不是完全可行 - /** -
-
- 元素 6 高 100px 宽 50px
-
-
- @ignore - **/ - // element.offsetParent does the right thing in ie7 and below. Return parent with layout! - // In other browsers it only includes elements with position absolute, relative or - // fixed, not elements with overflow set to auto or scroll. - // if (UA.ie && ieMode < 8) { - // return element.offsetParent; - // } - // 统一的 offsetParent 方法 - var doc = element.ownerDocument, - body = doc.body, - parent, - positionStyle = $(element).css('position'), - skipStatic = positionStyle == 'fixed' || positionStyle == 'absolute'; - - if (!skipStatic) { - return element.nodeName.toLowerCase() == 'html' ? null : element.parentNode; - } - - for (parent = element.parentNode; parent && parent != body; parent = parent.parentNode) { - positionStyle = $(parent).css('position'); - if (positionStyle != 'static') { - return parent; - } - } - return null; -} - -/** - * 获得元素的显示部分的区域 - * @private - * @ignore - */ -function getVisibleRectForElement(element) { - var visibleRect = { - left:0, - right:Infinity, - top:0, - bottom:Infinity - }, - el, - scrollX, - scrollY, - winSize, - doc = element.ownerDocument, - body = doc.body, - documentElement = doc.documentElement; - - // Determine the size of the visible rect by climbing the dom accounting for - // all scrollable containers. - for (el = element; el = getOffsetParent(el);) { - // clientWidth is zero for inline block elements in ie. - if ((!UA.ie || el.clientWidth != 0) && - // body may have overflow set on it, yet we still get the entire - // viewport. In some browsers, el.offsetParent may be - // document.documentElement, so check for that too. - (el != body && el != documentElement && $(el).css('overflow') != 'visible')) { - var pos = $(el).offset(); - // add border - pos.left += el.clientLeft; - pos.top += el.clientTop; - - visibleRect.top = Math.max(visibleRect.top, pos.top); - visibleRect.right = Math.min(visibleRect.right, - // consider area without scrollBar - pos.left + el.clientWidth); - visibleRect.bottom = Math.min(visibleRect.bottom, - pos.top + el.clientHeight); - visibleRect.left = Math.max(visibleRect.left, pos.left); - } - } - - // Clip by window's viewport. - scrollX = $(win).scrollLeft(); - scrollY = $(win).scrollTop(); - visibleRect.left = Math.max(visibleRect.left, scrollX); - visibleRect.top = Math.max(visibleRect.top, scrollY); - winSize = { - width:BUI.viewportWidth(), - height:BUI.viewportHeight() - }; - visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); - visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); - return visibleRect.top >= 0 && visibleRect.left >= 0 && - visibleRect.bottom > visibleRect.top && - visibleRect.right > visibleRect.left ? - visibleRect : null; -} - -function getElFuturePos(elRegion, refNodeRegion, points, offset) { - var xy, - diff, - p1, - p2; - - xy = { - left:elRegion.left, - top:elRegion.top - }; - - p1 = getAlignOffset(refNodeRegion, points[0]); - p2 = getAlignOffset(elRegion, points[1]); - - diff = [p2.left - p1.left, p2.top - p1.top]; - - return { - left:xy.left - diff[0] + (+offset[0]), - top:xy.top - diff[1] + (+offset[1]) - }; -} - -function isFailX(elFuturePos, elRegion, visibleRect) { - return elFuturePos.left < visibleRect.left || - elFuturePos.left + elRegion.width > visibleRect.right; -} - -function isFailY(elFuturePos, elRegion, visibleRect) { - return elFuturePos.top < visibleRect.top || - elFuturePos.top + elRegion.height > visibleRect.bottom; -} - -function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { - var pos = BUI.cloneObject(elFuturePos), - size = { - width:elRegion.width, - height:elRegion.height - }; - - if (overflow.adjustX && pos.left < visibleRect.left) { - pos.left = visibleRect.left; - } - - // Left edge inside and right edge outside viewport, try to resize it. - if (overflow['resizeWidth'] && - pos.left >= visibleRect.left && - pos.left + size.width > visibleRect.right) { - size.width -= (pos.left + size.width) - visibleRect.right; - } - - // Right edge outside viewport, try to move it. - if (overflow.adjustX && pos.left + size.width > visibleRect.right) { - // 保证左边界和可视区域左边界对齐 - pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); - } - - // Top edge outside viewport, try to move it. - if (overflow.adjustY && pos.top < visibleRect.top) { - pos.top = visibleRect.top; - } - - // Top edge inside and bottom edge outside viewport, try to resize it. - if (overflow['resizeHeight'] && - pos.top >= visibleRect.top && - pos.top + size.height > visibleRect.bottom) { - size.height -= (pos.top + size.height) - visibleRect.bottom; - } - - // Bottom edge outside viewport, try to move it. - if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { - // 保证上边界和可视区域上边界对齐 - pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); - } - - return BUI.mix(pos, size); -} - - -function flip(points, reg, map) { - var ret = []; - $.each(points, function (index,p) { - ret.push(p.replace(reg, function (m) { - return map[m]; - })); - }); - return ret; -} - -function flipOffset(offset, index) { - offset[index] = -offset[index]; - return offset; -} - - -/** - * @class BUI.Component.UIBase.Align - * Align extension class. - * Align component with specified element. - * - */ -function Align() { -} - - -Align.__getOffsetParent = getOffsetParent; - -Align.__getVisibleRectForElement = getVisibleRectForElement; - -Align.ATTRS = -{ - /** - * 对齐配置,详细说明请参看: JS控件 对齐 - * @cfg {Object} align - *

-   *  var overlay = new Overlay( {  
-   *     align :{
-   *     node: null,     // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素
-   *     points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tl 与参考节点的 tr 对齐
-   *     offset: [0, 0]    // 有效值为 [n, m]
-   *     }
-   *   }); 
-   * 
- */ - - /** - * 设置对齐属性 - * @type {Object} - * @field - * - * var align = { - * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 - * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tl 与参考节点的 tr 对齐 - * offset: [0, 0] // 有效值为 [n, m] - * }; - * overlay.set('align',align); - * - */ - align:{ - shared : false, - value:{} - } -}; - -function getRegion(node) { - var offset, w, h; - if (node.length && !$.isWindow(node[0])) { - offset = node.offset(); - w = node.outerWidth(); - h = node.outerHeight(); - } else { - offset = { left:BUI.scrollLeft(), top:BUI.scrollTop() }; - w = BUI.viewportWidth(); - h = BUI.viewportHeight(); - } - offset.width = w; - offset.height = h; - return offset; -} - -/** - * 获取 node 上的 align 对齐点 相对于页面的坐标 - * @param region - * @param align - */ -function getAlignOffset(region, align) { - var V = align.charAt(0), - H = align.charAt(1), - w = region.width, - h = region.height, - x, y; - - x = region.left; - y = region.top; - - if (V === 'c') { - y += h / 2; - } else if (V === 'b') { - y += h; - } - - if (H === 'c') { - x += w / 2; - } else if (H === 'r') { - x += w; - } - - return { left:x, top:y }; -} - -//清除对齐的css样式 -function clearAlignCls(el){ - var cls = el.attr('class'), - regex = new RegExp('\s?'+CLS_ALIGN_PREFIX+'[a-z]{2}-[a-z]{2}','ig'), - arr = regex.exec(cls); - if(arr){ - el.removeClass(arr.join(' ')); - } -} - -Align.prototype = -{ - _uiSetAlign:function (v,ev) { - var alignCls = '', - el, - selfAlign; //points 的第二个参数,是自己对齐于其他节点的的方式 - if (v && v.points) { - this.align(v.node, v.points, v.offset, v.overflow); - this.set('cachePosition',null); - el = this.get('el'); - clearAlignCls(el); - selfAlign = v.points.join('-'); - alignCls = CLS_ALIGN_PREFIX + selfAlign; - el.addClass(alignCls); - /**/ - } - }, - __bindUI : function(){ - var _self = this; - - var fn = BUI.wrapBehavior(_self,'handleWindowResize'); - - _self.on('show',function(){ - $(window).on('resize',fn); - }); - - _self.on('hide',function(){ - $(window).off('resize',fn); - }); - }, - //处理window resize事件 - handleWindowResize : function(){ - var _self = this, - align = _self.get('align'); - - _self.set('align',align); - }, - /* - 对齐 Overlay 到 node 的 points 点, 偏移 offset 处 - @method - @ignore - @param {Element} node 参照元素, 可取配置选项中的设置, 也可是一元素 - @param {String[]} points 对齐方式 - @param {Number[]} [offset] 偏移 - */ - align:function (refNode, points, offset, overflow) { - refNode = $(refNode || win); - offset = offset && [].concat(offset) || [0, 0]; - overflow = overflow || {}; - - var self = this, - el = self.get('el'), - fail = 0, - // 当前节点可以被放置的显示区域 - visibleRect = getVisibleRectForElement(el[0]), - // 当前节点所占的区域, left/top/width/height - elRegion = getRegion(el), - // 参照节点所占的区域, left/top/width/height - refNodeRegion = getRegion(refNode), - // 当前节点将要被放置的位置 - elFuturePos = getElFuturePos(elRegion, refNodeRegion, points, offset), - // 当前节点将要所处的区域 - newElRegion = BUI.merge(elRegion, elFuturePos); - - // 如果可视区域不能完全放置当前节点时允许调整 - if (visibleRect && (overflow.adjustX || overflow.adjustY)) { - - // 如果横向不能放下 - if (isFailX(elFuturePos, elRegion, visibleRect)) { - fail = 1; - // 对齐位置反下 - points = flip(points, /[lr]/ig, { - l:'r', - r:'l' - }); - // 偏移量也反下 - offset = flipOffset(offset, 0); - } - - // 如果纵向不能放下 - if (isFailY(elFuturePos, elRegion, visibleRect)) { - fail = 1; - // 对齐位置反下 - points = flip(points, /[tb]/ig, { - t:'b', - b:'t' - }); - // 偏移量也反下 - offset = flipOffset(offset, 1); - } - - // 如果失败,重新计算当前节点将要被放置的位置 - if (fail) { - elFuturePos = getElFuturePos(elRegion, refNodeRegion, points, offset); - BUI.mix(newElRegion, elFuturePos); - } - - var newOverflowCfg = {}; - - // 检查反下后的位置是否可以放下了 - // 如果仍然放不下只有指定了可以调整当前方向才调整 - newOverflowCfg.adjustX = overflow.adjustX && - isFailX(elFuturePos, elRegion, visibleRect); - - newOverflowCfg.adjustY = overflow.adjustY && - isFailY(elFuturePos, elRegion, visibleRect); - - // 确实要调整,甚至可能会调整高度宽度 - if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { - newElRegion = adjustForViewport(elFuturePos, elRegion, - visibleRect, newOverflowCfg); - } - } - - // 新区域位置发生了变化 - if (newElRegion.left != elRegion.left) { - self.setInternal('x', null); - self.get('view').setInternal('x', null); - self.set('x', newElRegion.left); - } - - if (newElRegion.top != elRegion.top) { - // https://github.com/kissyteam/kissy/issues/190 - // 相对于屏幕位置没变,而 left/top 变了 - // 例如
- // el.align(div) - self.setInternal('y', null); - self.get('view').setInternal('y', null); - self.set('y', newElRegion.top); - } - - // 新区域高宽发生了变化 - if (newElRegion.width != elRegion.width) { - el.width(el.width() + newElRegion.width - elRegion.width); - } - if (newElRegion.height != elRegion.height) { - el.height(el.height() + newElRegion.height - elRegion.height); - } - - return self; - }, - - /** - * 对齐到元素的中间,查看属性 {@link BUI.Component.UIBase.Align#property-align} . - *

-   *  control.center('#t1'); //控件处于容器#t1的中间位置
-   * 
- * @param {undefined|String|HTMLElement|jQuery} node - * - */ - center:function (node) { - var self = this; - self.set('align', { - node:node, - points:['cc', 'cc'], - offset:[0, 0] - }); - return self; - } -}; - -module.exports = Align; - -}); -define("bui-common/1.1.2/src/component/uibase/autoshow-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview click,focus,hover等引起控件显示,并且定位 - * @ignore - */ - -var $ = require('jquery'); - -/** - * 处理自动显示控件的扩展,一般用于显示menu,picker,tip等 - * @class BUI.Component.UIBase.AutoShow - */ -function autoShow() { - -} - -autoShow.ATTRS = { - - /** - * 触发显示控件的DOM选择器 - *

-   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,overlay之外的元素隐藏
-   *    trigger : '#t1',
-   *    autoHide : true,
-   *    content : '悬浮内容'
-   *  });
-   *  overlay.render();
-   * 
- * @cfg {HTMLElement|String|jQuery} trigger - */ - /** - * 触发显示控件的DOM选择器 - * @type {HTMLElement|String|jQuery} - */ - trigger: { - - }, - delegateTigger: { - getter: function() { - this.get('delegateTrigger'); //兼容之前的版本 - }, - setter: function(v) { - this.set('delegateTrigger', v); - } - - }, - /** - * 是否使用代理的方式触发显示控件,如果tigger不是字符串,此属性无效 - *

-   *  var overlay = new Overlay({ //点击.t1(无论创建控件时.t1是否存在)时显示,点击.t1,overlay之外的元素隐藏
-   *    trigger : '.t1',
-   *    autoHide : true,
-   *    delegateTrigger : true, //使用委托的方式触发显示控件
-   *    content : '悬浮内容'
-   *  });
-   *  overlay.render();
-   * 
- * @cfg {Boolean} [delegateTrigger = false] - */ - /** - * 是否使用代理的方式触发显示控件,如果tigger不是字符串,此属性无效 - * @type {Boolean} - * @ignore - */ - delegateTrigger: { - value: false - }, - /** - * 选择器是否始终跟随触发器对齐 - * @cfg {Boolean} autoAlign - * @ignore - */ - /** - * 选择器是否始终跟随触发器对齐 - * @type {Boolean} - * @protected - */ - autoAlign: { - value: true - }, - /** - * 显示时是否默认获取焦点 - * @type {Boolean} - */ - autoFocused: { - value: true - }, - /** - * 如果设置了这个样式,那么触发显示(overlay)时trigger会添加此样式 - * @type {Object} - */ - triggerActiveCls: { - - }, - /** - * 控件显示时由此trigger触发,当配置项 trigger 选择器代表多个DOM 对象时, - * 控件可由多个DOM对象触发显示。 - *

-   *  overlay.on('show',function(){
-   *    var curTrigger = overlay.get('curTrigger');
-   *    //TO DO
-   *  });
-   * 
- * @type {jQuery} - * @readOnly - */ - curTrigger: { - - }, - /** - * 触发显示时的回调函数 - * @cfg {Function} triggerCallback - * @ignore - */ - /** - * 触发显示时的回调函数 - * @type {Function} - * @ignore - */ - triggerCallback: { - - }, - /** - * 显示菜单的事件 - *

-   *    var overlay = new Overlay({ //移动到#t1时显示,移动出#t1,overlay之外控件隐藏
-   *      trigger : '#t1',
-   *      autoHide : true,
-   *      triggerEvent :'mouseover',
-   *      autoHideType : 'leave',
-   *      content : '悬浮内容'
-   *    });
-   *    overlay.render();
-   *
-   *  
- * @cfg {String} [triggerEvent='click'] - * @default 'click' - */ - /** - * 显示菜单的事件 - * @type {String} - * @default 'click' - * @ignore - */ - triggerEvent: { - value: 'click' - }, - /** - * 因为触发元素发生改变而导致控件隐藏 - * @cfg {String} triggerHideEvent - * @ignore - */ - /** - * 因为触发元素发生改变而导致控件隐藏 - * @type {String} - * @ignore - */ - triggerHideEvent: { - - }, - events: { - value: { - /** - * 当触发器(触发选择器出现)发生改变时,经常用于一个选择器对应多个触发器的情况 - *

-       *  overlay.on('triggerchange',function(ev){
-       *    var curTrigger = ev.curTrigger;
-       *    overlay.set('content',curTrigger.html());
-       *  });
-       * 
- * @event - * @param {Object} e 事件对象 - * @param {jQuery} e.prevTrigger 之前触发器,可能为null - * @param {jQuery} e.curTrigger 当前的触发器 - */ - 'triggerchange': false - } - } -}; - -autoShow.prototype = { - - __createDom: function() { - this._setTrigger(); - }, - __bindUI: function() { - var _self = this, - triggerActiveCls = _self.get('triggerActiveCls'); - if (triggerActiveCls) { - _self.on('hide', function() { - var curTrigger = _self.get('curTrigger'); - if (curTrigger) { - curTrigger.removeClass(triggerActiveCls); - } - }); - } - - }, - _setTrigger: function() { - var _self = this, - triggerEvent = _self.get('triggerEvent'), - triggerHideEvent = _self.get('triggerHideEvent'), - triggerCallback = _self.get('triggerCallback'), - triggerActiveCls = _self.get('triggerActiveCls') || '', - trigger = _self.get('trigger'), - isDelegate = _self.get('delegateTrigger'), - triggerEl = $(trigger); - - //触发显示 - function tiggerShow(ev) { - if (_self.get('disabled')) { //如果禁用则中断 - return; - } - var prevTrigger = _self.get('curTrigger'), - curTrigger = isDelegate ? $(ev.currentTarget) : $(this), - align = _self.get('align'); - if (!prevTrigger || prevTrigger[0] != curTrigger[0]) { - if (prevTrigger) { - prevTrigger.removeClass(triggerActiveCls); - } - _self.set('curTrigger', curTrigger); - _self.fire('triggerchange', { - prevTrigger: prevTrigger, - curTrigger: curTrigger - }); - } - curTrigger.addClass(triggerActiveCls); - if (_self.get('autoAlign')) { - align.node = curTrigger; - - } - _self.set('align', align); - _self.show(); - - - triggerCallback && triggerCallback(ev); - } - - //触发隐藏 - function tiggerHide(ev) { - var toElement = ev.toElement || ev.relatedTarget; - if (!toElement || !_self.containsElement(toElement)) { //mouseleave时,如果移动到当前控件上,取消消失 - _self.hide(); - } - } - - if (triggerEvent) { - if (isDelegate && BUI.isString(trigger)) { - $(document).delegate(trigger, triggerEvent, tiggerShow); - } else { - triggerEl.on(triggerEvent, tiggerShow); - } - - } - - if (triggerHideEvent) { - if (isDelegate && BUI.isString(trigger)) { - $(document).delegate(trigger, triggerHideEvent, tiggerHide); - } else { - triggerEl.on(triggerHideEvent, tiggerHide); - } - } - }, - __renderUI: function() { - var _self = this, - align = _self.get('align'); - //如果控件显示时不是由trigger触发,则同父元素对齐 - if (align && !align.node) { - align.node = _self.get('render') || _self.get('trigger'); - } - } -}; - -module.exports = autoShow; - -}); -define("bui-common/1.1.2/src/component/uibase/autohide-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 点击或移出控件外部,控件隐藏 - * @author dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - -function isExcept(self, elem) { - var hideExceptNode = self.get('hideExceptNode'); - if (hideExceptNode && hideExceptNode.length) { - return $.contains(hideExceptNode[0], elem); - } - return false; -} -/** - * 点击隐藏控件的扩展 - * @class BUI.Component.UIBase.AutoHide - */ -function autoHide() { - -} - -autoHide.ATTRS = { - - /** - * 控件自动隐藏的事件,这里支持2种: - * - 'click' - * - 'leave' - *

-   *    var overlay = new Overlay({ //点击#t1时显示,点击#t1之外的元素隐藏
-   *      trigger : '#t1',
-   *      autoHide : true,
-   *      content : '悬浮内容'
-   *    });
-   *    overlay.render();
-   *
-   *    var overlay = new Overlay({ //移动到#t1时显示,移动出#t1,overlay之外控件隐藏
-   *      trigger : '#t1',
-   *      autoHide : true,
-   *      triggerEvent :'mouseover',
-   *      autoHideType : 'leave',
-   *      content : '悬浮内容'
-   *    });
-   *    overlay.render();
-   *
-   *  
- * @cfg {String} [autoHideType = 'click'] - */ - /** - * 控件自动隐藏的事件,这里支持2种: - * 'click',和'leave',默认为'click' - * @type {String} - */ - autoHideType: { - value: 'click' - }, - /** - * 是否自动隐藏 - *

-   *
-   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,overlay之外的元素隐藏
-   *    trigger : '#t1',
-   *    autoHide : true,
-   *    content : '悬浮内容'
-   *  });
-   *  overlay.render();
-   * 
- * @cfg {Object} autoHide - */ - /** - * 是否自动隐藏 - * @type {Object} - * @ignore - */ - autoHide: { - value: false - }, - /** - * 点击或者移动到此节点时不触发自动隐藏 - *

-   *
-   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,#t2,overlay之外的元素隐藏
-   *    trigger : '#t1',
-   *    autoHide : true,
-   *    hideExceptNode : '#t2',
-   *    content : '悬浮内容'
-   *  });
-   *  overlay.render();
-   * 
- * @cfg {Object} hideExceptNode - */ - hideExceptNode: { - - }, - events: { - value: { - /** - * @event autohide - * 点击控件外部时触发,只有在控件设置自动隐藏(autoHide = true)有效 - * 可以阻止控件隐藏,通过在事件监听函数中 return false - *

-       *  overlay.on('autohide',function(){
-       *    var curTrigger = overlay.curTrigger; //当前触发的项
-       *    if(condtion){
-       *      return false; //阻止隐藏
-       *    }
-       *  });
-       * 
- */ - autohide: false - } - } -}; - -autoHide.prototype = { - - __bindUI: function() { - var _self = this; - - _self.on('afterVisibleChange', function(ev) { - var visible = ev.newVal; - if (_self.get('autoHide')) { - if (visible) { - _self._bindHideEvent(); - } else { - _self._clearHideEvent(); - } - } - }); - }, - /** - * 处理鼠标移出事件,不影响{BUI.Component.Controller#handleMouseLeave}事件 - * @param {jQuery.Event} ev 事件对象 - */ - handleMoveOuter: function(ev) { - var _self = this, - target = ev.toElement || ev.relatedTarget; - if (!_self.containsElement(target) && !isExcept(_self, target)) { - if (_self.fire('autohide') !== false) { - _self.hide(); - } - } - }, - /** - * 点击页面时的处理函数 - * @param {jQuery.Event} ev 事件对象 - * @protected - */ - handleDocumentClick: function(ev) { - var _self = this, - target = ev.target; - if (!_self.containsElement(target) && !isExcept(_self, target)) { - if (_self.fire('autohide') !== false) { - _self.hide(); - } - } - }, - _bindHideEvent: function() { - var _self = this, - trigger = _self.get('curTrigger'), - autoHideType = _self.get('autoHideType'); - if (autoHideType === 'click') { - $(document).on('mousedown', wrapBehavior(_self, 'handleDocumentClick')); - } else { - _self.get('el').on('mouseleave', wrapBehavior(_self, 'handleMoveOuter')); - if (trigger) { - $(trigger).on('mouseleave', wrapBehavior(_self, 'handleMoveOuter')) - } - } - - }, - //清除绑定的隐藏事件 - _clearHideEvent: function() { - var _self = this, - trigger = _self.get('curTrigger'), - autoHideType = _self.get('autoHideType'); - if (autoHideType === 'click') { - $(document).off('mousedown', getWrapBehavior(_self, 'handleDocumentClick')); - } else { - _self.get('el').off('mouseleave', getWrapBehavior(_self, 'handleMoveOuter')); - if (trigger) { - $(trigger).off('mouseleave', getWrapBehavior(_self, 'handleMoveOuter')) - } - } - } -}; - -module.exports = autoHide; - -}); -define("bui-common/1.1.2/src/component/uibase/close-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview close 关闭或隐藏控件 - * @author yiminghe@gmail.com - * copied and modified by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'); - - -var CLS_PREFIX = BUI.prefix + 'ext-'; - -function getCloseRenderBtn(self) { - return $(self.get('closeTpl')); -} - -/** - * 关闭按钮的视图类 - * @class BUI.Component.UIBase.CloseView - * @private - */ -function CloseView() {} - -CloseView.ATTRS = { - closeTpl: { - value: '' + - '关闭<' + '/span>' + - '<' + '/a>' - }, - closeable: { - value: true - }, - closeBtn: {} -}; - -CloseView.prototype = { - _uiSetCloseable: function(v) { - var self = this, - btn = self.get('closeBtn'); - if (v) { - if (!btn) { - self.setInternal('closeBtn', btn = getCloseRenderBtn(self)); - } - btn.appendTo(self.get('el'), undefined); - } else { - if (btn) { - btn.remove(); - } - } - } -}; - -/** - * @class BUI.Component.UIBase.Close - * Close extension class. - * Represent a close button. - */ -function Close() {} - -var HIDE = 'hide'; -Close.ATTRS = { - /** - * 关闭按钮的默认模版 - *

-   *   var overlay = new Overlay({
-   *     closeTpl : 'x',
-   *     closeable : true,
-   *     trigger : '#t1'
-   *   });
-   *   overlay.render();
-   * 
- * @cfg {String} closeTpl - */ - /** - * 关闭按钮的默认模版 - * @type {String} - * @protected - */ - closeTpl: { - view: true - }, - /** - * 是否出现关闭按钮 - * @cfg {Boolean} [closeable = false] - */ - /** - * 是否出现关闭按钮 - * @type {Boolean} - */ - closeable: { - view: 1 - }, - - /** - * 关闭按钮. - * @protected - * @type {jQuery} - */ - closeBtn: { - view: 1 - }, - /** - * 关闭时隐藏还是移除DOM结构
- * - * - "hide" : default 隐藏. - * - "destroy":当点击关闭按钮时移除(destroy)控件 - * - 'remove' : 当存在父控件时使用remove,同时从父元素中删除 - * @cfg {String} [closeAction = 'hide'] - */ - /** - * 关闭时隐藏还是移除DOM结构 - * default "hide".可以设置 "destroy" ,当点击关闭按钮时移除(destroy)控件 - * @type {String} - * @protected - */ - closeAction: { - value: HIDE - } - - /** - * @event closing - * 正在关闭,可以通过return false 阻止关闭事件 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event beforeclosed - * 关闭前,发生在closing后,closed前,用于处理关闭前的一些工作 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event closed - * 已经关闭 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event closeclick - * 触发点击关闭按钮的事件,return false 阻止关闭 - * @param {Object} e 关闭事件 - * @param {String} e.domTarget 点击的关闭按钮节点 - */ -}; - -var actions = { - hide: HIDE, - destroy: 'destroy', - remove: 'remove' -}; - -Close.prototype = { - _uiSetCloseable: function(v) { - var self = this; - if (v && !self.__bindCloseEvent) { - self.__bindCloseEvent = 1; - self.get('closeBtn').on('click', function(ev) { - if (self.fire('closeclick', { - domTarget: ev.target - }) !== false) { - self.close(); - } - ev.preventDefault(); - }); - } - }, - __destructor: function() { - var btn = this.get('closeBtn'); - btn && btn.detach(); - }, - /** - * 关闭弹出框,如果closeAction = 'hide'那么就是隐藏,如果 closeAction = 'destroy'那么就是释放,'remove'从父控件中删除,并释放 - */ - close: function() { - var self = this, - action = actions[self.get('closeAction') || HIDE]; - if (self.fire('closing', { - action: action - }) !== false) { - self.fire('beforeclosed', { - action: action - }); - if (action == 'remove') { //移除时同时destroy - self[action](true); - } else { - self[action](); - } - self.fire('closed', { - action: action - }); - } - } -}; - -Close.View = CloseView; - -module.exports = Close; - -}); -define("bui-common/1.1.2/src/component/uibase/collapsable-debug", [], function(require, exports, module){ -/** - * @fileOverview 可以展开折叠的控件 - * @ignore - */ - - -/** - * 控件展开折叠的视图类 - * @class BUI.Component.UIBase.CollapsableView - * @private - */ -var collapsableView = function() { - -}; - -collapsableView.ATTRS = { - collapsed: {} -} - -collapsableView.prototype = { - //设置收缩样式 - _uiSetCollapsed: function(v) { - var _self = this, - cls = _self.getStatusCls('collapsed'), - el = _self.get('el'); - if (v) { - el.addClass(cls); - } else { - el.removeClass(cls); - } - } -} -/** - * 控件展开折叠的扩展 - * @class BUI.Component.UIBase.Collapsable - */ -var collapsable = function() { - -}; - -collapsable.ATTRS = { - /** - * 是否可折叠 - * @type {Boolean} - */ - collapsable: { - value: false - }, - /** - * 是否已经折叠 collapsed - * @cfg {Boolean} collapsed - */ - /** - * 是否已经折叠 - * @type {Boolean} - */ - collapsed: { - view: true, - value: false - }, - events: { - value: { - /** - * 控件展开 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} target 控件 - */ - 'expanded': true, - /** - * 控件折叠 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} target 控件 - */ - 'collapsed': true - } - } -}; - -collapsable.prototype = { - _uiSetCollapsed: function(v) { - var _self = this; - if (v) { - _self.fire('collapsed'); - } else { - _self.fire('expanded'); - } - } -}; - -collapsable.View = collapsableView; - -module.exports = collapsable; - -}); -define("bui-common/1.1.2/src/component/uibase/drag-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 拖拽 - * @author by dxq613@gmail.com - * @ignore - */ - - - -var $ = require('jquery'), - dragBackId = BUI.guid('drag'); - -/** - * 拖拽控件的扩展 - *

- *  var Control = Overlay.extend([UIBase.Drag],{
- *
- *  });
- *
- *  var c = new Contol({ //拖动控件时,在#t2内
- *      content : '
', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
- * @class BUI.Component.UIBase.Drag - */ -var drag = function() { - -}; - -drag.ATTRS = { - - /** - * 点击拖动的节点 - *

-   *  var Control = Overlay.extend([UIBase.Drag],{
-   *
-   *  });
-   *
-   *  var c = new Contol({ //拖动控件时,在#t2内
-   *      content : '
', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
- * @cfg {jQuery} dragNode - */ - /** - * 点击拖动的节点 - * @type {jQuery} - * @ignore - */ - dragNode: { - - }, - /** - * 是否正在拖动 - * @type {Boolean} - * @protected - */ - draging: { - setter: function(v) { - if (v === true) { - return {}; - } - }, - value: null - }, - /** - * 拖动的限制范围 - *

-   *  var Control = Overlay.extend([UIBase.Drag],{
-   *
-   *  });
-   *
-   *  var c = new Contol({ //拖动控件时,在#t2内
-   *      content : '
', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
- * @cfg {jQuery} constraint - */ - /** - * 拖动的限制范围 - * @type {jQuery} - * @ignore - */ - constraint: { - - }, - /** - * @private - * @type {jQuery} - */ - dragBackEl: { - /** @private **/ - getter: function() { - return $('#' + dragBackId); - } - } -}; -var dragTpl = ''; - -function initBack() { - var el = $(dragTpl).css('opacity', 0).prependTo('body'); - return el; -} -drag.prototype = { - - __bindUI: function() { - var _self = this, - constraint = _self.get('constraint'), - dragNode = _self.get('dragNode'); - if (!dragNode) { - return; - } - dragNode.on('mousedown', function(e) { - - if (e.which == 1) { - e.preventDefault(); - _self.set('draging', { - elX: _self.get('x'), - elY: _self.get('y'), - startX: e.pageX, - startY: e.pageY - }); - registEvent(); - } - }); - /** - * @private - */ - function mouseMove(e) { - var draging = _self.get('draging'); - if (draging) { - e.preventDefault(); - _self._dragMoveTo(e.pageX, e.pageY, draging, constraint); - } - } - /** - * @private - */ - function mouseUp(e) { - if (e.which == 1) { - _self.set('draging', false); - var dragBackEl = _self.get('dragBackEl'); - if (dragBackEl) { - dragBackEl.hide(); - } - unregistEvent(); - } - } - /** - * @private - */ - function registEvent() { - $(document).on('mousemove', mouseMove); - $(document).on('mouseup', mouseUp); - } - /** - * @private - */ - function unregistEvent() { - $(document).off('mousemove', mouseMove); - $(document).off('mouseup', mouseUp); - } - - }, - _dragMoveTo: function(x, y, draging, constraint) { - var _self = this, - dragBackEl = _self.get('dragBackEl'), - draging = draging || _self.get('draging'), - offsetX = draging.startX - x, - offsetY = draging.startY - y; - if (!dragBackEl.length) { - dragBackEl = initBack(); - } - dragBackEl.css({ - cursor: 'move', - display: 'block' - }); - _self.set('xy', [_self._getConstrainX(draging.elX - offsetX, constraint), - _self._getConstrainY(draging.elY - offsetY, constraint) - ]); - - }, - _getConstrainX: function(x, constraint) { - var _self = this, - width = _self.get('el').outerWidth(), - endX = x + width, - curX = _self.get('x'); - //如果存在约束 - if (constraint) { - var constraintOffset = constraint.offset(); - if (constraintOffset.left >= x) { - return constraintOffset.left; - } - if (constraintOffset.left + constraint.width() < endX) { - return constraintOffset.left + constraint.width() - width; - } - return x; - } - //当左右顶点都在视图内,移动到此点 - if (BUI.isInHorizontalView(x) && BUI.isInHorizontalView(endX)) { - return x; - } - - return curX; - }, - _getConstrainY: function(y, constraint) { - var _self = this, - height = _self.get('el').outerHeight(), - endY = y + height, - curY = _self.get('y'); - //如果存在约束 - if (constraint) { - var constraintOffset = constraint.offset(); - if (constraintOffset.top > y) { - return constraintOffset.top; - } - if (constraintOffset.top + constraint.height() < endY) { - return constraintOffset.top + constraint.height() - height; - } - return y; - } - //当左右顶点都在视图内,移动到此点 - if (BUI.isInVerticalView(y) && BUI.isInVerticalView(endY)) { - return y; - } - - return curY; - } -}; - -module.exports = drag; - -}); -define("bui-common/1.1.2/src/component/uibase/keynav-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 使用键盘导航 - * @ignore - */ - - - var $ = require('jquery'), - KeyCode = require("bui-common/1.1.2/src/keycode-debug"), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - /** - * 键盘导航 - * @class BUI.Component.UIBase.KeyNav - */ - var keyNav = function() { - - }; - - keyNav.ATTRS = { - - /** - * 是否允许键盘导航 - * @cfg {Boolean} [allowKeyNav = true] - */ - allowKeyNav: { - value: true - }, - /** - * 导航使用的事件 - * @cfg {String} [navEvent = 'keydown'] - */ - navEvent: { - value: 'keydown' - }, - /** - * 当获取事件的DOM是 input,textarea,select等时,不处理键盘导航 - * @cfg {Object} [ignoreInputFields='true'] - */ - ignoreInputFields: { - value: true - } - - }; - - keyNav.prototype = { - - __bindUI: function() { - - }, - _uiSetAllowKeyNav: function(v) { - var _self = this, - eventName = _self.get('navEvent'), - el = _self.get('el'); - if (v) { - el.on(eventName, wrapBehavior(_self, '_handleKeyDown')); - } else { - el.off(eventName, getWrapBehavior(_self, '_handleKeyDown')); - } - }, - /** - * 处理键盘导航 - * @private - */ - _handleKeyDown: function(ev) { - var _self = this, - ignoreInputFields = _self.get('ignoreInputFields'), - code = ev.which; - if (ignoreInputFields && $(ev.target).is('input,select,textarea')) { - return; - } - - switch (code) { - case KeyCode.UP: - //ev.preventDefault(); - _self.handleNavUp(ev); - break; - case KeyCode.DOWN: - //ev.preventDefault(); - _self.handleNavDown(ev); - break; - case KeyCode.RIGHT: - // ev.preventDefault(); - _self.handleNavRight(ev); - break; - case KeyCode.LEFT: - //ev.preventDefault(); - _self.handleNavLeft(ev); - break; - case KeyCode.ENTER: - _self.handleNavEnter(ev); - break; - case KeyCode.ESC: - _self.handleNavEsc(ev); - break; - case KeyCode.TAB: - _self.handleNavTab(ev); - break; - default: - break; - } - }, - /** - * 处理向上导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavUp: function(ev) { - // body... - }, - /** - * 处理向下导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavDown: function(ev) { - // body... - }, - /** - * 处理向左导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavLeft: function(ev) { - // body... - }, - /** - * 处理向右导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavRight: function(ev) { - // body... - }, - /** - * 处理确认键 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavEnter: function(ev) { - // body... - }, - /** - * 处理 esc 键 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavEsc: function(ev) { - // body... - }, - /** - * 处理Tab键 - * @param {jQuery.Event} ev 事件对象 - */ - handleNavTab: function(ev) { - - } - - }; - -module.exports = keyNav; - -}); -define("bui-common/1.1.2/src/component/uibase/list-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 所有子元素都是同一类的集合 - * @ignore - */ - - -var $ = require('jquery'), - Selection = require("bui-common/1.1.2/src/component/uibase/selection-debug"); - -/** - * 列表一类的控件的扩展,list,menu,grid都是可以从此类扩展 - * @class BUI.Component.UIBase.List - */ -var list = function() { - -}; - -list.ATTRS = { - - /** - * 选择的数据集合 - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{value}">{text}</li>',
-   *   idField : 'value',
-   *   render : '#t1',
-   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
-   * });
-   * list.render();
-   * 
- * @cfg {Array} items - */ - /** - * 选择的数据集合 - *

-   *  list.set('items',items); //列表会直接替换内容
-   *  //等同于
-   *  list.clearItems();
-   *  list.addItems(items);
-   * 
- * @type {Array} - */ - items: { - shared: false, - view: true - }, - /** - * 选项的默认key值 - * @cfg {String} [idField = 'id'] - */ - idField: { - value: 'id' - }, - /** - * 列表项的默认模板,仅在初始化时传入。 - * @type {String} - * @ignore - */ - itemTpl: { - view: true - }, - /** - * 列表项的渲染函数,应对列表项之间有很多差异时 - *

-   * var list = new List.SimpleList({
-   *   itemTplRender : function(item){
-   *     if(item.type == '1'){
-   *       return '<li><img src="xxx.jpg"/>'+item.text+'</li>'
-   *     }else{
-   *       return '<li>item.text</li>'
-   *     }
-   *   },
-   *   idField : 'value',
-   *   render : '#t1',
-   *   items : [{value : '1',text : '1',type : '0'},{value : '2',text : '2',type : '1'}]
-   * });
-   * list.render();
-   * 
- * @type {Function} - */ - itemTplRender: { - view: true - }, - /** - * 子控件各个状态默认采用的样式 - *

-   * var list = new List.SimpleList({
-   *   render : '#t1',
-   *   itemStatusCls : {
-   *     selected : 'active', //默认样式为list-item-selected,现在变成'active'
-   *     hover : 'hover' //默认样式为list-item-hover,现在变成'hover'
-   *   },
-   *   items : [{id : '1',text : '1',type : '0'},{id : '2',text : '2',type : '1'}]
-   * });
-   * list.render();
-   * 
- * see {@link BUI.Component.Controller#property-statusCls} - * @type {Object} - */ - itemStatusCls: { - view: true, - value: {} - }, - events: { - - value: { - /** - * 选项点击事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.UIBase.ListItem} e.item 点击的选项 - * @param {HTMLElement} e.element 选项代表的DOM对象 - * @param {HTMLElement} e.domTarget 点击的DOM对象 - * @param {HTMLElement} e.domEvent 点击的原生事件对象 - */ - 'itemclick': true - } - } -}; - -list.prototype = { - - /** - * 获取选项的数量 - *

-   *   var count = list.getItemCount();
-   * 
- * @return {Number} 选项数量 - */ - getItemCount: function() { - return this.getItems().length; - }, - /** - * 获取字段的值 - * @param {*} item 字段名 - * @param {String} field 字段名 - * @return {*} 字段的值 - * @protected - */ - getValueByField: function(item, field) { - - }, - /** - * 获取所有选项值,如果选项是子控件,则是所有子控件 - *

-   *   var items = list.getItems();
-   *   //等同
-   *   list.get(items);
-   * 
- * @return {Array} 选项值集合 - */ - getItems: function() { - - }, - /** - * 获取第一项 - *

-   *   var item = list.getFirstItem();
-   *   //等同
-   *   list.getItemAt(0);
-   * 
- * @return {Object|BUI.Component.Controller} 选项值(子控件) - */ - getFirstItem: function() { - return this.getItemAt(0); - }, - /** - * 获取最后一项 - *

-   *   var item = list.getLastItem();
-   *   //等同
-   *   list.getItemAt(list.getItemCount()-1);
-   * 
- * @return {Object|BUI.Component.Controller} 选项值(子控件) - */ - getLastItem: function() { - return this.getItemAt(this.getItemCount() - 1); - }, - /** - * 通过索引获取选项值(子控件) - *

-   *   var item = list.getItemAt(0); //获取第1个
-   *   var item = list.getItemAt(2); //获取第3个
-   * 
- * @param {Number} index 索引值 - * @return {Object|BUI.Component.Controller} 选项(子控件) - */ - getItemAt: function(index) { - return this.getItems()[index] || null; - }, - /** - * 通过Id获取选项,如果是改变了idField则通过改变的idField来查找选项 - *

-   *   //如果idField = 'id'
-   *   var item = list.getItem('2');
-   *   //等同于
-   *   list.findItemByField('id','2');
-   *
-   *   //如果idField = 'value'
-   *   var item = list.getItem('2');
-   *   //等同于
-   *   list.findItemByField('value','2');
-   * 
- * @param {String} id 编号 - * @return {Object|BUI.Component.Controller} 选项(子控件) - */ - getItem: function(id) { - var field = this.get('idField'); - return this.findItemByField(field, id); - }, - /** - * 返回指定项的索引 - *

-   * var index = list.indexOf(item); //返回索引,不存在则返回-1
-   * 
- * @param {Object|BUI.Component.Controller} item 选项 - * @return {Number} 项的索引值 - */ - indexOfItem: function(item) { - return BUI.Array.indexOf(item, this.getItems()); - }, - /** - * 添加多条选项 - *

-   * var items = [{id : '1',text : '1'},{id : '2',text : '2'}];
-   * list.addItems(items);
-   * 
- * @param {Array} items 记录集合(子控件配置项) - */ - addItems: function(items) { - var _self = this; - BUI.each(items, function(item) { - _self.addItem(item); - }); - }, - /** - * 插入多条记录 - *

-   * var items = [{id : '1',text : '1'},{id : '2',text : '2'}];
-   * list.addItemsAt(items,0); // 在最前面插入
-   * list.addItemsAt(items,2); //第三个位置插入
-   * 
- * @param {Array} items 多条记录 - * @param {Number} start 起始位置 - */ - addItemsAt: function(items, start) { - var _self = this; - BUI.each(items, function(item, index) { - _self.addItemAt(item, start + index); - }); - }, - /** - * 更新列表项,修改选项值后,DOM跟随变化 - *

-   *   var item = list.getItem('2');
-   *   list.text = '新内容'; //此时对应的DOM不会变化
-   *   list.updateItem(item); //DOM进行相应的变化
-   * 
- * @param {Object} item 选项值 - */ - updateItem: function(item) { - - }, - /** - * 添加选项,添加在控件最后 - * - *

-   * list.addItem({id : '3',text : '3',type : '0'});
-   * 
- * - * @param {Object|BUI.Component.Controller} item 选项,子控件配置项、子控件 - * @return {Object|BUI.Component.Controller} 子控件或者选项记录 - */ - addItem: function(item) { - return this.addItemAt(item, this.getItemCount()); - }, - /** - * 在指定位置添加选项 - *

-   * list.addItemAt({id : '3',text : '3',type : '0'},0); //第一个位置
-   * 
- * @param {Object|BUI.Component.Controller} item 选项,子控件配置项、子控件 - * @param {Number} index 索引 - * @return {Object|BUI.Component.Controller} 子控件或者选项记录 - */ - addItemAt: function(item, index) { - - }, - /** - * 根据字段查找指定的项 - * @param {String} field 字段名 - * @param {Object} value 字段值 - * @return {Object} 查询出来的项(传入的记录或者子控件) - * @protected - */ - findItemByField: function(field, value) { - - }, - /** - * - * 获取此项显示的文本 - * @param {Object} item 获取记录显示的文本 - * @protected - */ - getItemText: function(item) { - - }, - /** - * 清除所有选项,不等同于删除全部,此时不会触发删除事件 - *

-   * list.clearItems();
-   * //等同于
-   * list.set('items',items);
-   * 
- */ - clearItems: function() { - var _self = this, - items = _self.getItems(); - items.splice(0); - _self.clearControl(); - }, - /** - * 删除选项 - *

-   * var item = list.getItem('1');
-   * list.removeItem(item);
-   * 
- * @param {Object|BUI.Component.Controller} item 选项(子控件) - */ - removeItem: function(item) { - - }, - /** - * 移除选项集合 - *

-   * var items = list.getSelection();
-   * list.removeItems(items);
-   * 
- * @param {Array} items 选项集合 - */ - removeItems: function(items) { - var _self = this; - - BUI.each(items, function(item) { - _self.removeItem(item); - }); - }, - /** - * 通过索引删除选项 - *

-   * list.removeItemAt(0); //删除第一个
-   * 
- * @param {Number} index 索引 - */ - removeItemAt: function(index) { - this.removeItem(this.getItemAt(index)); - }, - /** - * @protected - * @template - * 清除所有的子控件或者列表项的DOM - */ - clearControl: function() { - - } -} - - - - - -function clearSelected(item) { - if (item.selected) { - item.selected = false; - } - if (item.set) { - item.set('selected', false); - } -} - -function beforeAddItem(self, item) { - - var c = item.isController ? item.getAttrVals() : item, - defaultTpl = self.get('itemTpl'), - defaultStatusCls = self.get('itemStatusCls'), - defaultTplRender = self.get('itemTplRender'); - - //配置默认模板 - if (defaultTpl && !c.tpl) { - setItemAttr(item, 'tpl', defaultTpl); - // c.tpl = defaultTpl; - } - //配置默认渲染函数 - if (defaultTplRender && !c.tplRender) { - setItemAttr(item, 'tplRender', defaultTplRender); - //c.tplRender = defaultTplRender; - } - //配置默认状态样式 - if (defaultStatusCls) { - var statusCls = c.statusCls || item.isController ? item.get('statusCls') : {}; - BUI.each(defaultStatusCls, function(v, k) { - if (v && !statusCls[k]) { - statusCls[k] = v; - } - }); - setItemAttr(item, 'statusCls', statusCls) - //item.statusCls = statusCls; - } - // clearSelected(item); -} - -function setItemAttr(item, name, val) { - if (item.isController) { - item.set(name, val); - } else { - item[name] = val; - } -} - -/** - * @class BUI.Component.UIBase.ChildList - * 选中其中的DOM结构 - * @extends BUI.Component.UIBase.List - * @mixins BUI.Component.UIBase.Selection - */ -var childList = function() { - this.__init(); -}; - -childList.ATTRS = BUI.merge(true, list.ATTRS, Selection.ATTRS, { - items: { - sync: false - }, - /** - * 配置的items 项是在初始化时作为children - * @protected - * @type {Boolean} - */ - autoInitItems: { - value: true - }, - /** - * 使用srcNode时,是否将内部的DOM转换成子控件 - * @type {Boolean} - */ - isDecorateChild: { - value: true - }, - /** - * 默认的加载控件内容的配置,默认值: - *
-   *  {
-   *   property : 'children',
-   *   dataType : 'json'
-   * }
-   * 
- * @type {Object} - */ - defaultLoaderCfg: { - value: { - property: 'children', - dataType: 'json' - } - } -}); - -BUI.augment(childList, list, Selection, { - //初始化,将items转换成children - __init: function() { - var _self = this, - items = _self.get('items'); - if (items && _self.get('autoInitItems')) { - _self.addItems(items); - } - _self.on('beforeRenderUI', function() { - _self._beforeRenderUI(); - }); - }, - _uiSetItems: function(items) { - var _self = this; - //清理子控件 - _self.clearControl(); - _self.addItems(items); - }, - //渲染子控件 - _beforeRenderUI: function() { - var _self = this, - children = _self.get('children'), - items = _self.get('items'); - BUI.each(children, function(item) { - beforeAddItem(_self, item); - }); - }, - //绑定事件 - __bindUI: function() { - var _self = this, - selectedEvent = _self.get('selectedEvent'); - - _self.on(selectedEvent, function(e) { - var item = e.target; - if (item.get('selectable')) { - if (!item.get('selected')) { - _self.setSelected(item); - } else if (_self.get('multipleSelect')) { - _self.clearSelected(item); - } - } - }); - - _self.on('click', function(e) { - if (e.target !== _self) { - _self.fire('itemclick', { - item: e.target, - domTarget: e.domTarget, - domEvent: e - }); - } - }); - _self.on('beforeAddChild', function(ev) { - beforeAddItem(_self, ev.child); - }); - _self.on('beforeRemoveChild', function(ev) { - var item = ev.child, - selected = item.get('selected'); - //清理选中状态 - if (selected) { - if (_self.get('multipleSelect')) { - _self.clearSelected(item); - } else { - _self.setSelected(null); - } - } - item.set('selected', false); - }); - }, - /** - * @protected - * @override - * 清除者列表项的DOM - */ - clearControl: function() { - this.removeChildren(true); - }, - /** - * 获取所有子控件 - * @return {Array} 子控件集合 - * @override - */ - getItems: function() { - return this.get('children'); - }, - /** - * 更新列表项 - * @param {Object} item 选项值 - */ - updateItem: function(item) { - var _self = this, - idField = _self.get('idField'), - element = _self.findItemByField(idField, item[idField]); - if (element) { - element.setTplContent(); - } - return element; - }, - /** - * 删除项,子控件作为选项 - * @param {Object} element 子控件 - */ - removeItem: function(item) { - var _self = this, - idField = _self.get('idField'); - if (!(item instanceof BUI.Component.Controller)) { - item = _self.findItemByField(idField, item[idField]); - } - this.removeChild(item, true); - }, - /** - * 在指定位置添加选项,此处选项指子控件 - * @param {Object|BUI.Component.Controller} item 子控件配置项、子控件 - * @param {Number} index 索引 - * @return {Object|BUI.Component.Controller} 子控件 - */ - addItemAt: function(item, index) { - return this.addChild(item, index); - }, - findItemByField: function(field, value, root) { - - root = root || this; - var _self = this, - children = root.get('children'), - result = null; - $(children).each(function(index, item) { - if (item.get(field) == value) { - result = item; - } else if (item.get('children').length) { - result = _self.findItemByField(field, value, item); - } - if (result) { - return false; - } - }); - return result; - }, - getItemText: function(item) { - return item.get('el').text(); - }, - getValueByField: function(item, field) { - return item && item.get(field); - }, - /** - * @protected - * @ignore - */ - setItemSelectedStatus: function(item, selected) { - var _self = this, - method = selected ? 'addClass' : 'removeClass', - element = null; - - if (item) { - item.set('selected', selected); - element = item.get('el'); - } - _self.afterSelected(item, selected, element); - }, - /** - * 选项是否被选中 - * @override - * @param {*} item 选项 - * @return {Boolean} 是否选中 - */ - isItemSelected: function(item) { - return item ? item.get('selected') : false; - }, - /** - * 设置所有选项选中 - * @override - */ - setAllSelection: function() { - var _self = this, - items = _self.getItems(); - _self.setSelection(items); - }, - /** - * 获取选中的项的值 - * @return {Array} - * @override - * @ignore - */ - getSelection: function() { - var _self = this, - items = _self.getItems(), - rst = []; - BUI.each(items, function(item) { - if (_self.isItemSelected(item)) { - rst.push(item); - } - - }); - return rst; - } -}); - -list.ChildList = childList; - -module.exports = list; - -/** - * @ignore - * 2013-1-22 - * 更改显示数据的方式,使用 _uiSetItems - */ - -}); -define("bui-common/1.1.2/src/component/uibase/selection-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 单选或者多选 - * @author dxq613@gmail.com - * @ignore - */ -var $ = require('jquery'); -var SINGLE_SELECTED = 'single'; - -/** - * @class BUI.Component.UIBase.Selection - * 选中控件中的项(子元素或者DOM),此类选择的内容有2种 - *
    - *
  1. 子控件
  2. - *
  3. DOM元素
  4. - *
- * ** 当选择是子控件时,element 和 item 都是指 子控件;** - * ** 当选择的是DOM元素时,element 指DOM元素,item 指DOM元素对应的记录 ** - * @abstract - */ -var selection = function() { - -}; - -selection.ATTRS = - -{ - /** - * 选中的事件 - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{value}">{text}</li>',
-   *   idField : 'value',
-   *   selectedEvent : 'mouseenter',
-   *   render : '#t1',
-   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
-   * });
-   * 
- * @cfg {String} [selectedEvent = 'click'] - */ - selectedEvent: { - value: 'click' - }, - events: { - value: { - /** - * 选中的菜单改变时发生, - * 多选时,选中,取消选中都触发此事件,单选时,只有选中时触发此事件 - * @name BUI.Component.UIBase.Selection#selectedchange - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - * @param {Boolean} e.selected 是否选中 - */ - 'selectedchange': false, - - /** - * 选择改变前触发,可以通过return false,阻止selectedchange事件 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {Boolean} e.selected 是否选中 - */ - 'beforeselectedchange': false, - - /** - * 菜单选中 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - */ - 'itemselected': false, - /** - * 菜单取消选中 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - */ - 'itemunselected': false - } - }, - /** - * 数据的id字段名称,通过此字段查找对应的数据 - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{value}">{text}</li>',
-   *   idField : 'value',
-   *   render : '#t1',
-   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
-   * });
-   * 
- * @cfg {String} [idField = 'id'] - */ - /** - * 数据的id字段名称,通过此字段查找对应的数据 - * @type {String} - * @ignore - */ - idField: { - value: 'id' - }, - /** - * 是否多选 - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{value}">{text}</li>',
-   *   idField : 'value',
-   *   render : '#t1',
-   *   multipleSelect : true,
-   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
-   * });
-   * 
- * @cfg {Boolean} [multipleSelect=false] - */ - /** - * 是否多选 - * @type {Boolean} - * @default false - */ - multipleSelect: { - value: false - } - -}; - -selection.prototype = - -{ - /** - * 清理选中的项 - *

-   *  list.clearSelection();
-   * 
- * - */ - clearSelection: function() { - var _self = this, - selection = _self.getSelection(); - BUI.each(selection, function(item) { - _self.clearSelected(item); - }); - }, - /** - * 获取选中的项的值 - * @template - * @return {Array} - */ - getSelection: function() { - - }, - /** - * 获取选中的第一项 - *

-   * var item = list.getSelected(); //多选模式下第一条
-   * 
- * @return {Object} 选中的第一项或者为undefined - */ - getSelected: function() { - return this.getSelection()[0]; - }, - /** - * 根据 idField 获取到的值 - * @protected - * @return {Object} 选中的值 - */ - getSelectedValue: function() { - var _self = this, - field = _self.get('idField'), - item = _self.getSelected(); - - return _self.getValueByField(item, field); - }, - /** - * 获取选中的值集合 - * @protected - * @return {Array} 选中值得集合 - */ - getSelectionValues: function() { - var _self = this, - field = _self.get('idField'), - items = _self.getSelection(); - return $.map(items, function(item) { - return _self.getValueByField(item, field); - }); - }, - /** - * 获取选中的文本 - * @protected - * @return {Array} 选中的文本集合 - */ - getSelectionText: function() { - var _self = this, - items = _self.getSelection(); - return $.map(items, function(item) { - return _self.getItemText(item); - }); - }, - /** - * 移除选中 - *

-   *    var item = list.getItem('id'); //通过id 获取选项
-   *    list.setSelected(item); //选中
-   *
-   *    list.clearSelected();//单选模式下清除所选,多选模式下清除选中的第一项
-   *    list.clearSelected(item); //清除选项的选中状态
-   * 
- * @param {Object} [item] 清除选项的选中状态,如果未指定则清除选中的第一个选项的选中状态 - */ - clearSelected: function(item) { - var _self = this; - item = item || _self.getSelected(); - if (item) { - _self.setItemSelected(item, false); - } - }, - /** - * 获取选项显示的文本 - * @protected - */ - getSelectedText: function() { - var _self = this, - item = _self.getSelected(); - return _self.getItemText(item); - }, - /** - * 设置选中的项 - *

-   *  var items = list.getItemsByStatus('active'); //获取某种状态的选项
-   *  list.setSelection(items);
-   * 
- * @param {Array} items 项的集合 - */ - setSelection: function(items) { - var _self = this; - - items = BUI.isArray(items) ? items : [items]; - - BUI.each(items, function(item) { - _self.setSelected(item); - }); - }, - /** - * 设置选中的项 - *

-   *   var item = list.getItem('id');
-   *   list.setSelected(item);
-   * 
- * @param {Object} item 记录或者子控件 - */ - setSelected: function(item) { - var _self = this, - multipleSelect = _self.get('multipleSelect'); - - if (!_self.isItemSelectable(item)) { - return; - } - if (!multipleSelect) { - var selectedItem = _self.getSelected(); - if (item != selectedItem) { - //如果是单选,清除已经选中的项 - _self.clearSelected(selectedItem); - } - - } - _self.setItemSelected(item, true); - - }, - /** - * 选项是否被选中 - * @template - * @param {*} item 选项 - * @return {Boolean} 是否选中 - */ - isItemSelected: function(item) { - - }, - /** - * 选项是否可以选中 - * @protected - * @param {*} item 选项 - * @return {Boolean} 选项是否可以选中 - */ - isItemSelectable: function(item) { - return true; - }, - /** - * 设置选项的选中状态 - * @param {*} item 选项 - * @param {Boolean} selected 选中或者取消选中 - * @protected - */ - setItemSelected: function(item, selected) { - var _self = this, - isSelected; - - //当前状态等于要设置的状态时,不触发改变事件 - if (item) { - isSelected = _self.isItemSelected(item); - if (isSelected == selected) { - return; - } - } - if (_self.fire('beforeselectedchange', { - item: item, - selected: selected - }) !== false) { - _self.setItemSelectedStatus(item, selected); - } - }, - /** - * 设置选项的选中状态 - * @template - * @param {*} item 选项 - * @param {Boolean} selected 选中或者取消选中 - * @protected - */ - setItemSelectedStatus: function(item, selected) { - - }, - /** - * 设置所有选项选中 - *

-   *  list.setAllSelection(); //选中全部,多选状态下有效
-   * 
- * @template - */ - setAllSelection: function() { - - }, - /** - * 设置项选中,通过字段和值 - * @param {String} field 字段名,默认为配置项'idField',所以此字段可以不填写,仅填写值 - * @param {Object} value 值 - * @example - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{id}">{text}</li>',
-   *   idField : 'id', //id 字段作为key
-   *   render : '#t1',
-   *   items : [{id : '1',text : '1'},{id : '2',text : '2'}]
-   * });
-   *
-   *   list.setSelectedByField('123'); //默认按照id字段查找
-   *   //或者
-   *   list.setSelectedByField('id','123');
-   *
-   *   list.setSelectedByField('value','123');
-   * 
- */ - setSelectedByField: function(field, value) { - if (!value) { - value = field; - field = this.get('idField'); - } - var _self = this, - item = _self.findItemByField(field, value); - _self.setSelected(item); - }, - /** - * 设置多个选中,根据字段和值 - *

-   * var list = new List.SimpleList({
-   *   itemTpl : '<li id="{value}">{text}</li>',
-   *   idField : 'value', //value 字段作为key
-   *   render : '#t1',
-   *   multipleSelect : true,
-   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
-   * });
-   *   var values = ['1','2','3'];
-   *   list.setSelectionByField(values);//
-   *
-   *   //等于
-   *   list.setSelectionByField('value',values);
-   * 
- * @param {String} field 默认为idField - * @param {Array} values 值得集合 - */ - setSelectionByField: function(field, values) { - if (!values) { - values = field; - field = this.get('idField'); - } - var _self = this; - BUI.each(values, function(value) { - _self.setSelectedByField(field, value); - }); - }, - /** - * 选中完成后,触发事件 - * @protected - * @param {*} item 选项 - * @param {Boolean} selected 是否选中 - * @param {jQuery} element - */ - afterSelected: function(item, selected, element) { - var _self = this; - - if (selected) { - _self.fire('itemselected', { - item: item, - domTarget: element - }); - _self.fire('selectedchange', { - item: item, - domTarget: element, - selected: selected - }); - } else { - _self.fire('itemunselected', { - item: item, - domTarget: element - }); - if (_self.get('multipleSelect')) { //只有当多选时,取消选中才触发selectedchange - _self.fire('selectedchange', { - item: item, - domTarget: element, - selected: selected - }); - } - } - } - -} - -module.exports = selection; - -}); -define("bui-common/1.1.2/src/component/uibase/listitem-debug", [], function(require, exports, module){ -/** - * @fileOverview 可选中的控件,父控件支持selection扩展 - * @ignore - */ - - -/** - * 列表项控件的视图层 - * @class BUI.Component.UIBase.ListItemView - * @private - */ -function listItemView() { - // body... -} - -listItemView.ATTRS = { - /** - * 是否选中 - * @type {Boolean} - */ - selected: { - - } -}; - -listItemView.prototype = { - _uiSetSelected: function(v) { - var _self = this, - cls = _self.getStatusCls('selected'), - el = _self.get('el'); - if (v) { - el.addClass(cls); - } else { - el.removeClass(cls); - } - } -}; -/** - * 列表项的扩展 - * @class BUI.Component.UIBase.ListItem - */ -function listItem() { - -} - -listItem.ATTRS = { - - /** - * 是否可以被选中 - * @cfg {Boolean} [selectable=true] - */ - /** - * 是否可以被选中 - * @type {Boolean} - */ - selectable: { - value: true - }, - - /** - * 是否选中,只能通过设置父类的选中方法来实现选中 - * @type {Boolean} - * @readOnly - */ - selected: { - view: true, - sync: false, - value: false - } -}; - -listItem.prototype = { - -}; - -listItem.View = listItemView; - -module.exports = listItem; - -}); -define("bui-common/1.1.2/src/component/uibase/mask-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview mask 遮罩层 - * @author yiminghe@gmail.com - * copied and modified by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'), - UA = require("bui-common/1.1.2/src/ua-debug"), - - /** - * 每组相同 prefixCls 的 position 共享一个遮罩 - * @ignore - */ - maskMap = { - /** - * @ignore - * { - * node: - * num: - * } - */ - - }, - ie6 = UA.ie == 6; - -function getMaskCls(self) { - return self.get('prefixCls') + 'ext-mask'; -} - -function docWidth() { - return ie6 ? BUI.docWidth() + 'px' : '100%'; -} - -function docHeight() { - return ie6 ? BUI.docHeight() + 'px' : '100%'; -} - -function initMask(maskCls) { - var mask = $('
' + - (ie6 ? '<' + 'iframe ' + - 'style="position:absolute;' + - 'left:' + '0' + ';' + - 'top:' + '0' + ';' + - 'background:white;' + - 'width: expression(this.parentNode.offsetWidth);' + - 'height: expression(this.parentNode.offsetHeight);' + - 'filter:alpha(opacity=0);' + - 'z-index:-1;">' : '') + - '
') - .prependTo('body'); - /** - * 点 mask 焦点不转移 - * @ignore - */ - // mask.unselectable(); - mask.on('mousedown', function(e) { - e.preventDefault(); - }); - return mask; -} - -/** - * 遮罩层的视图类 - * @class BUI.Component.UIBase.MaskView - * @private - */ -function MaskView() {} - -MaskView.ATTRS = { - maskShared: { - value: true - } -}; - -MaskView.prototype = { - - _maskExtShow: function() { - var self = this, - zIndex, - maskCls = getMaskCls(self), - maskDesc = maskMap[maskCls], - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (!mask) { - if (maskShared) { - if (maskDesc) { - mask = maskDesc.node; - } else { - mask = initMask(maskCls); - maskDesc = maskMap[maskCls] = { - num: 0, - node: mask - }; - } - } else { - mask = initMask(maskCls); - } - self.setInternal('maskNode', mask); - } - if (zIndex = self.get('zIndex')) { - mask.css('z-index', zIndex - 1); - } - if (maskShared) { - maskDesc.num++; - } - if (!maskShared || maskDesc.num == 1) { - mask.show(); - } - $('body').addClass('x-masked-relative'); - }, - - _maskExtHide: function() { - var self = this, - maskCls = getMaskCls(self), - maskDesc = maskMap[maskCls], - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (maskShared && maskDesc) { - maskDesc.num = Math.max(maskDesc.num - 1, 0); - if (maskDesc.num == 0) { - mask.hide(); - } - } else if (mask) { - mask.hide(); - } - $('body').removeClass('x-masked-relative'); - }, - - __destructor: function() { - var self = this, - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (self.get('maskNode')) { - if (maskShared) { - if (self.get('visible')) { - self._maskExtHide(); - } - } else { - mask.remove(); - } - } - } - -}; - -/** - * @class BUI.Component.UIBase.Mask - * Mask extension class. - * Make component to be able to show with mask. - */ -function Mask() {} - -Mask.ATTRS = { - /** - * 控件显示时,是否显示屏蔽层 - *

-   *   var overlay = new Overlay({ //显示overlay时,屏蔽body
-   *     mask : true,
-   *     maskNode : 'body',
-   *     trigger : '#t1'
-   *   });
-   *   overlay.render();
-   * 
- * @cfg {Boolean} [mask = false] - */ - /** - * 控件显示时,是否显示屏蔽层 - * @type {Boolean} - * @protected - */ - mask: { - value: false - }, - /** - * 屏蔽的内容 - *

-   *   var overlay = new Overlay({ //显示overlay时,屏蔽body
-   *     mask : true,
-   *     maskNode : 'body',
-   *     trigger : '#t1'
-   *   });
-   *   overlay.render();
-   * 
- * @cfg {jQuery} maskNode - */ - /** - * 屏蔽的内容 - * @type {jQuery} - * @protected - */ - maskNode: { - view: 1 - }, - /** - * Whether to share mask with other overlays. - * @default true. - * @type {Boolean} - * @protected - */ - maskShared: { - view: 1 - } -}; - -Mask.prototype = { - - __bindUI: function() { - var self = this, - view = self.get('view'), - _maskExtShow = view._maskExtShow, - _maskExtHide = view._maskExtHide; - if (self.get('mask')) { - self.on('show', function() { - view._maskExtShow(); - }); - self.on('hide', function() { - view._maskExtHide(); - }); - } - } -}; - -Mask = Mask; -Mask.View = MaskView; - -module.exports = Mask; - -}); -define("bui-common/1.1.2/src/component/uibase/position-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 位置,控件绝对定位 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -/** - * 对齐的视图类 - * @class BUI.Component.UIBase.PositionView - * @private - */ -function PositionView() { - -} - -PositionView.ATTRS = { - x: { - /** - * 水平方向绝对位置 - * @private - * @ignore - */ - valueFn: function() { - var self = this; - // 读到这里时,el 一定是已经加到 dom 树中了,否则报未知错误 - // el 不在 dom 树中 offset 报错的 - // 最早读就是在 syncUI 中,一点重复设置(读取自身 X 再调用 _uiSetX)无所谓了 - return self.get('el') && self.get('el').offset().left; - } - }, - y: { - /** - * 垂直方向绝对位置 - * @private - * @ignore - */ - valueFn: function() { - var self = this; - return self.get('el') && self.get('el').offset().top; - } - }, - zIndex: {}, - /** - * @private - * see {@link BUI.Component.UIBase.Box#visibleMode}. - * @default "visibility" - * @ignore - */ - visibleMode: { - value: 'visibility' - } -}; - - -PositionView.prototype = { - - __createDom: function() { - this.get('el').addClass(BUI.prefix + 'ext-position'); - }, - - _uiSetZIndex: function(x) { - this.get('el').css('z-index', x); - }, - _uiSetX: function(x) { - if (x != null) { - this.get('el').offset({ - left: x - }); - } - }, - _uiSetY: function(y) { - if (y != null) { - this.get('el').offset({ - top: y - }); - } - }, - _uiSetLeft: function(left) { - if (left != null) { - this.get('el').css({ - left: left - }); - } - }, - _uiSetTop: function(top) { - if (top != null) { - this.get('el').css({ - top: top - }); - } - } -}; - -/** - * @class BUI.Component.UIBase.Position - * Position extension class. - * Make component positionable - */ -function Position() {} - -Position.ATTRS = { - /** - * 水平坐标 - * @cfg {Number} x - */ - /** - * 水平坐标 - *

-   *     overlay.set('x',100);
-   * 
- * @type {Number} - */ - x: { - view: 1 - }, - /** - * 垂直坐标 - * @cfg {Number} y - */ - /** - * 垂直坐标 - *

-   *     overlay.set('y',100);
-   * 
- * @type {Number} - */ - y: { - view: 1 - }, - /** - * 相对于父元素的水平位置 - * @type {Number} - * @protected - */ - left: { - view: 1 - }, - /** - * 相对于父元素的垂直位置 - * @type {Number} - * @protected - */ - top: { - view: 1 - }, - /** - * 水平和垂直坐标 - *

-   * var overlay = new Overlay({
-   *   xy : [100,100],
-   *   trigger : '#t1',
-   *   srcNode : '#c1'
-   * });
-   * 
- * @cfg {Number[]} xy - */ - /** - * 水平和垂直坐标 - *

-   *     overlay.set('xy',[100,100]);
-   * 
- * @type {Number[]} - */ - xy: { - // 相对 page 定位, 有效值为 [n, m], 为 null 时, 选 align 设置 - setter: function(v) { - var self = this, - xy = $.makeArray(v); - /* - 属性内分发特别注意: - xy -> x,y - */ - if (xy.length) { - xy[0] && self.set('x', xy[0]); - xy[1] && self.set('y', xy[1]); - } - return v; - }, - /** - * xy 纯中转作用 - * @ignore - */ - getter: function() { - return [this.get('x'), this.get('y')]; - } - }, - /** - * z-index value. - *

-   *   var overlay = new Overlay({
-   *       zIndex : '1000'
-   *   });
-   * 
- * @cfg {Number} zIndex - */ - /** - * z-index value. - *

-   *   overlay.set('zIndex','1200');
-   * 
- * @type {Number} - */ - zIndex: { - view: 1 - }, - /** - * Positionable element is by default visible false. - * For compatibility in overlay and PopupMenu. - * @default false - * @ignore - */ - visible: { - view: true, - value: true - } -}; - - -Position.prototype = { - /** - * Move to absolute position. - * @param {Number|Number[]} x - * @param {Number} [y] - * @example - *

-   * move(x, y);
-   * move(x);
-   * move([x,y])
-   * 
- */ - move: function(x, y) { - var self = this; - if (BUI.isArray(x)) { - y = x[1]; - x = x[0]; - } - self.set('xy', [x, y]); - return self; - }, - //设置 x 坐标时,重置 left - _uiSetX: function(v) { - if (v != null) { - var _self = this, - el = _self.get('el'); - _self.setInternal('left', el.position().left); - if (v != -999) { - this.set('cachePosition', null); - } - - } - - }, - //设置 y 坐标时,重置 top - _uiSetY: function(v) { - if (v != null) { - var _self = this, - el = _self.get('el'); - _self.setInternal('top', el.position().top); - if (v != -999) { - this.set('cachePosition', null); - } - } - }, - //设置 left时,重置 x - _uiSetLeft: function(v) { - var _self = this, - el = _self.get('el'); - if (v != null) { - _self.setInternal('x', el.offset().left); - } - /*else{ //如果lef 为null,同时设置过left和top,那么取对应的值 - _self.setInternal('left',el.position().left); - }*/ - }, - //设置top 时,重置y - _uiSetTop: function(v) { - var _self = this, - el = _self.get('el'); - if (v != null) { - _self.setInternal('y', el.offset().top); - } - /*else{ //如果lef 为null,同时设置过left和top,那么取对应的值 - _self.setInternal('top',el.position().top); - }*/ - } -}; - -Position.View = PositionView; - -module.exports = Position; - -}); -define("bui-common/1.1.2/src/component/uibase/stdmod-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview - * 控件包含头部(head)、内容(content)和尾部(foot) - * @ignore - */ - -var $ = require('jquery'), - CLS_PREFIX = BUI.prefix + 'stdmod-'; - - -/** - * 标准模块组织的视图类 - * @class BUI.Component.UIBase.StdModView - * @private - */ -function StdModView() {} - -StdModView.ATTRS = { - header: {}, - body: {}, - footer: {}, - bodyStyle: {}, - footerStyle: {}, - headerStyle: {}, - headerContent: {}, - bodyContent: {}, - footerContent: {} -}; - -StdModView.PARSER = { - header: function(el) { - return el.one("." + CLS_PREFIX + "header"); - }, - body: function(el) { - return el.one("." + CLS_PREFIX + "body"); - }, - footer: function(el) { - return el.one("." + CLS_PREFIX + "footer"); - } -}; /**/ - -function createUI(self, part) { - var el = self.get('contentEl'), - partEl = self.get(part); - if (!partEl) { - partEl = $('
' + - '
'); - partEl.appendTo(el); - self.setInternal(part, partEl); - } -} - - -function _setStdModRenderContent(self, part, v) { - part = self.get(part); - if (BUI.isString(v)) { - part.html(v); - } else { - part.html('') - .append(v); - } -} - -StdModView.prototype = { - - __renderUI: function() { //createDom - createUI(this, 'header'); - createUI(this, 'body'); - createUI(this, 'footer'); - }, - - _uiSetBodyStyle: function(v) { - this.get('body').css(v); - }, - - _uiSetHeaderStyle: function(v) { - this.get('header').css(v); - }, - _uiSetFooterStyle: function(v) { - this.get('footer').css(v); - }, - - _uiSetBodyContent: function(v) { - _setStdModRenderContent(this, 'body', v); - }, - - _uiSetHeaderContent: function(v) { - _setStdModRenderContent(this, 'header', v); - }, - - _uiSetFooterContent: function(v) { - _setStdModRenderContent(this, 'footer', v); - } -}; - -/** - * @class BUI.Component.UIBase.StdMod - * StdMod extension class. - * Generate head, body, foot for component. - */ -function StdMod() {} - -StdMod.ATTRS = { - /** - * 控件的头部DOM. Readonly - * @readOnly - * @type {jQuery} - */ - header: { - view: 1 - }, - /** - * 控件的内容DOM. Readonly - * @readOnly - * @type {jQuery} - */ - body: { - view: 1 - }, - /** - * 控件的底部DOM. Readonly - * @readOnly - * @type {jQuery} - */ - footer: { - view: 1 - }, - /** - * 应用到控件内容的css属性,键值对形式 - * @cfg {Object} bodyStyle - */ - /** - * 应用到控件内容的css属性,键值对形式 - * @type {Object} - * @protected - */ - bodyStyle: { - view: 1 - }, - /** - * 应用到控件底部的css属性,键值对形式 - * @cfg {Object} footerStyle - */ - /** - * 应用到控件底部的css属性,键值对形式 - * @type {Object} - * @protected - */ - footerStyle: { - view: 1 - }, - /** - * 应用到控件头部的css属性,键值对形式 - * @cfg {Object} headerStyle - */ - /** - * 应用到控件头部的css属性,键值对形式 - * @type {Object} - * @protected - */ - headerStyle: { - view: 1 - }, - /** - * 控件头部的html - *

-   * var dialog = new Dialog({
-   *     headerContent: '<div class="header"></div>',
-   *     bodyContent : '#c1',
-   *     footerContent : '<div class="footer"></div>'
-   * });
-   * dialog.show();
-   * 
- * @cfg {jQuery|String} headerContent - */ - /** - * 控件头部的html - * @type {jQuery|String} - */ - headerContent: { - view: 1 - }, - /** - * 控件内容的html - *

-   * var dialog = new Dialog({
-   *     headerContent: '<div class="header"></div>',
-   *     bodyContent : '#c1',
-   *     footerContent : '<div class="footer"></div>'
-   * });
-   * dialog.show();
-   * 
- * @cfg {jQuery|String} bodyContent - */ - /** - * 控件内容的html - * @type {jQuery|String} - */ - bodyContent: { - view: 1 - }, - /** - * 控件底部的html - *

-   * var dialog = new Dialog({
-   *     headerContent: '<div class="header"></div>',
-   *     bodyContent : '#c1',
-   *     footerContent : '<div class="footer"></div>'
-   * });
-   * dialog.show();
-   * 
- * @cfg {jQuery|String} footerContent - */ - /** - * 控件底部的html - * @type {jQuery|String} - */ - footerContent: { - view: 1 - } -}; - -StdMod.View = StdModView; - -module.exports = StdMod; - -}); -define("bui-common/1.1.2/src/component/uibase/decorate-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 使用wrapper - * @ignore - */ - - -var $ = require('jquery'), - ArrayUtil = require("bui-common/1.1.2/src/array-debug"), - JSON = require("bui-common/1.1.2/src/json-debug"), - prefixCls = BUI.prefix, - FIELD_PREFIX = 'data-', - FIELD_CFG = FIELD_PREFIX + 'cfg', - PARSER = 'PARSER', - Manager = require("bui-common/1.1.2/src/component/manage-debug"), - RE_DASH_WORD = /-([a-z])/g, - regx = /^[\{\[]/; - -function isConfigField(name, cfgFields) { - if (cfgFields[name]) { - return true; - } - var reg = new RegExp("^" + FIELD_PREFIX); - if (name !== FIELD_CFG && reg.test(name)) { - return true; - } - return false; -} - -// 收集单继承链,子类在前,父类在后 -function collectConstructorChains(self) { - var constructorChains = [], - c = self.constructor; - while (c) { - constructorChains.push(c); - c = c.superclass && c.superclass.constructor; - } - return constructorChains; -} - -function camelCase(str) { - return str.toLowerCase().replace(RE_DASH_WORD, function(all, letter) { - return (letter + '').toUpperCase() - }) -} - -//如果属性为对象或者数组,则进行转换 -function parseFieldValue(value) { - - value = $.trim(value); - if (value.toLowerCase() === 'false') { - value = false - } else if (value.toLowerCase() === 'true') { - value = true - } else if (regx.test(value)) { - value = JSON.looseParse(value); - } else if (/\d/.test(value) && /[^a-z]/i.test(value)) { - var number = parseFloat(value) - if (number + '' === value) { - value = number - } - } - - return value; -} - -function setConfigFields(self, cfg) { - - var userConfig = self.userConfig || {}; - for (var p in cfg) { - // 用户设置过那么这里不从 dom 节点取 - // 用户设置 > html parser > default value - if (!(p in userConfig)) { - self.setInternal(p, cfg[p]); - } - } -} - -function applyParser(srcNode, parser) { - var self = this, - p, v, - userConfig = self.userConfig || {}; - - // 从 parser 中,默默设置属性,不触发事件 - for (p in parser) { - // 用户设置过那么这里不从 dom 节点取 - // 用户设置 > html parser > default value - if (!(p in userConfig)) { - v = parser[p]; - // 函数 - if (BUI.isFunction(v)) { - self.setInternal(p, v.call(self, srcNode)); - } - // 单选选择器 - else if (typeof v == 'string') { - self.setInternal(p, srcNode.find(v)); - } - // 多选选择器 - else if (BUI.isArray(v) && v[0]) { - self.setInternal(p, srcNode.find(v[0])) - } - } - } -} - -function initParser(self, srcNode) { - - var c = self.constructor, - len, - p, - constructorChains; - - constructorChains = collectConstructorChains(self); - - // 从父类到子类开始从 html 读取属性 - for (len = constructorChains.length - 1; len >= 0; len--) { - c = constructorChains[len]; - if (p = c[PARSER]) { - applyParser.call(self, srcNode, p); - } - } -} - -function initDecorate(self) { - var _self = self, - srcNode = _self.get('srcNode'), - userConfig, - decorateCfg; - if (srcNode) { - srcNode = $(srcNode); - _self.setInternal('el', srcNode); - _self.setInternal('srcNode', srcNode); - - userConfig = _self.get('userConfig'); - decorateCfg = _self.getDecorateConfig(srcNode); - setConfigFields(self, decorateCfg); - - //如果从DOM中读取子控件 - if (_self.get('isDecorateChild') && _self.decorateInternal) { - _self.decorateInternal(srcNode); - } - initParser(self, srcNode); - } -} - -/** - * @class BUI.Component.UIBase.Decorate - * 将DOM对象封装成控件 - */ -function decorate() { - initDecorate(this); -} - -decorate.ATTRS = { - - /** - * 配置控件的根节点的DOM - *

-   * new Form.Form({
-   *   srcNode : '#J_Form'
-   * }).render();
-   * 
- * @cfg {jQuery} srcNode - */ - /** - * 配置控件的根节点的DOM - * @type {jQuery} - */ - srcNode: { - view: true - }, - /** - * 是否根据DOM生成子控件 - * @type {Boolean} - * @protected - */ - isDecorateChild: { - value: false - }, - /** - * 此配置项配置使用那些srcNode上的节点作为配置项 - * - 当时用 decorate 时,取 srcNode上的节点的属性作为控件的配置信息 - * - 默认id,name,value,title 都会作为属性传入 - * - 使用 'data-cfg' 作为整体的配置属性 - *

-   *     
-   *     //会生成以下配置项:
-   *     {
-   *         name : 'txtName',
-   *         id : 'id',
-   *         allowBlank:false
-   *     }
-   *     new Form.Field({
-   *        src:'#c1'
-   *     }).render();
-   *  
- * @type {Object} - * @protected - */ - decorateCfgFields: { - value: { - 'id': true, - 'name': true, - 'value': true, - 'title': true - } - } -}; - -decorate.prototype = { - - /** - * 获取控件的配置信息 - * @protected - */ - getDecorateConfig: function(el) { - if (!el.length) { - return null; - } - var _self = this, - dom = el[0], - attributes = dom.attributes, - decorateCfgFields = _self.get('decorateCfgFields'), - config = {}, - statusCfg = _self._getStautsCfg(el); - - BUI.each(attributes, function(attr) { - var name = attr.nodeName; - try { - if (name === FIELD_CFG) { - var cfg = parseFieldValue(attr.nodeValue); - BUI.mix(config, cfg); - } else if (isConfigField(name, decorateCfgFields)) { - var value = attr.nodeValue; - if (name.indexOf(FIELD_PREFIX) !== -1) { - name = name.replace(FIELD_PREFIX, ''); - name = camelCase(name); - value = parseFieldValue(value); - } - - if (config[name] && BUI.isObject(value)) { - BUI.mix(config[name], value); - } else { - config[name] = value; - } - } - } catch (e) { - BUI.log('parse field error,the attribute is:' + name); - } - }); - return BUI.mix(config, statusCfg); - }, - //根据css class获取状态属性 - //如: selected,disabled等属性 - _getStautsCfg: function(el) { - var _self = this, - rst = {}, - statusCls = _self.get('statusCls'); - BUI.each(statusCls, function(v, k) { - if (el.hasClass(v)) { - rst[k] = true; - } - }); - return rst; - }, - /** - * 获取封装成子控件的节点集合 - * @protected - * @return {Array} 节点集合 - */ - getDecorateElments: function() { - var _self = this, - el = _self.get('el'), - contentContainer = _self.get('childContainer'); - if (contentContainer) { - return el.find(contentContainer).children(); - } else { - return el.children(); - } - }, - - /** - * 封装所有的子控件 - * @protected - * @param {jQuery} el Root element of current component. - */ - decorateInternal: function(el) { - var self = this; - self.decorateChildren(el); - }, - /** - * 获取子控件的xclass类型 - * @protected - * @param {jQuery} childNode 子控件的根节点 - */ - findXClassByNode: function(childNode, ignoreError) { - var _self = this, - cls = childNode.attr("class") || '', - childClass = _self.get('defaultChildClass'); //如果没有样式或者查找不到对应的类,使用默认的子控件类型 - - // 过滤掉特定前缀 - cls = cls.replace(new RegExp("\\b" + prefixCls, "ig"), ""); - - var UI = Manager.getConstructorByXClass(cls) || Manager.getConstructorByXClass(childClass); - - if (!UI && !ignoreError) { - BUI.log(childNode); - BUI.error("can not find ui " + cls + " from this markup"); - } - return Manager.getXClassByConstructor(UI); - }, - // 生成一个组件 - decorateChildrenInternal: function(xclass, c) { - var _self = this, - children = _self.get('children'); - children.push({ - xclass: xclass, - srcNode: c - }); - }, - /** - * 封装子控件 - * @private - * @param {jQuery} el component's root element. - */ - decorateChildren: function(el) { - var _self = this, - children = _self.getDecorateElments(); - BUI.each(children, function(c) { - var xclass = _self.findXClassByNode($(c)); - _self.decorateChildrenInternal(xclass, $(c)); - }); - } -}; - -module.exports = decorate; - -}); -define("bui-common/1.1.2/src/component/uibase/tpl-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 控件模板 - * @author dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -/** - * @private - * 控件模板扩展类的渲染类(view) - * @class BUI.Component.UIBase.TplView - */ -function tplView() { - -} - -tplView.ATTRS = { - /** - * 模板 - * @protected - * @type {String} - */ - tpl: { - - }, - tplEl: { - - } -}; - -tplView.prototype = { - __renderUI: function() { - var _self = this, - contentContainer = _self.get('childContainer'), - contentEl; - - if (contentContainer) { - contentEl = _self.get('el').find(contentContainer); - if (contentEl.length) { - _self.set('contentEl', contentEl); - } - } - }, - /** - * 获取生成控件的模板 - * @protected - * @param {Object} attrs 属性值 - * @return {String} 模板 - */ - getTpl: function(attrs) { - var _self = this, - tpl = _self.get('tpl'), - tplRender = _self.get('tplRender'); - attrs = attrs || _self.getAttrVals(); - - if (tplRender) { - return tplRender(attrs); - } - if (tpl) { - return BUI.substitute(tpl, attrs); - } - return ''; - }, - /** - * 如果控件设置了模板,则根据模板和属性值生成DOM - * 如果设置了content属性,此模板不应用 - * @protected - * @param {Object} attrs 属性值,默认为初始化时传入的值 - */ - setTplContent: function(attrs) { - var _self = this, - el = _self.get('el'), - content = _self.get('content'), - tplEl = _self.get('tplEl'), - tpl = _self.getTpl(attrs); - - //tplEl.remove(); - if (!content && tpl) { //替换掉原先的内容 - el.empty(); - el.html(tpl); - /*if(tplEl){ - var node = $(tpl).insertBefore(tplEl); - tplEl.remove(); - tplEl = node; - }else{ - tplEl = $(tpl).appendTo(el); - } - _self.set('tplEl',tplEl) - */ - } - } -} - -/** - * 控件的模板扩展 - * @class BUI.Component.UIBase.Tpl - */ -function tpl() { - -} - -tpl.ATTRS = { - /** - * 控件的模版,用于初始化 - *

-   * var list = new List.List({
-   *   tpl : '<div class="toolbar"></div><ul></ul>',
-   *   childContainer : 'ul'
-   * });
-   * //用于统一子控件模板
-   * var list = new List.List({
-   *   defaultChildCfg : {
-   *     tpl : '<span>{text}</span>'
-   *   }
-   * });
-   * list.render();
-   * 
- * @cfg {String} tpl - */ - /** - * 控件的模板 - *

-   *   list.set('tpl','<div class="toolbar"></div><ul></ul><div class="bottom"></div>')
-   * 
- * @type {String} - */ - tpl: { - view: true, - sync: false - }, - /** - *

控件的渲染函数,应对一些简单模板解决不了的问题,例如有if,else逻辑,有循环逻辑, - * 函数原型是function(data){},其中data是控件的属性值

- *

控件模板的加强模式,此属性会覆盖@see {BUI.Component.UIBase.Tpl#property-tpl}属性

- * //用于统一子控件模板 - * var list = new List.List({ - * defaultChildCfg : { - * tplRender : funciton(item){ - * if(item.type == '1'){ - * return 'type1 html'; - * }else{ - * return 'type2 html'; - * } - * } - * } - * }); - * list.render(); - * @cfg {Function} tplRender - */ - tplRender: { - view: true, - value: null - }, - /** - * 这是一个选择器,使用了模板后,子控件可能会添加到模板对应的位置, - * - 默认为null,此时子控件会将控件最外层 el 作为容器 - *

-   * var list = new List.List({
-   *   tpl : '<div class="toolbar"></div><ul></ul>',
-   *   childContainer : 'ul'
-   * });
-   * 
- * @cfg {String} childContainer - */ - childContainer: { - view: true - } -}; - -tpl.prototype = { - - __renderUI: function() { - //使用srcNode时,不使用模板 - if (!this.get('srcNode')) { - this.setTplContent(); - } - }, - /** - * 控件信息发生改变时,控件内容跟模板相关时需要调用这个函数, - * 重新通过模板和控件信息构造内容 - */ - updateContent: function() { - this.setTplContent(); - }, - /** - * 根据控件的属性和模板生成控件内容 - * @protected - */ - setTplContent: function() { - var _self = this, - attrs = _self.getAttrVals(); - _self.get('view').setTplContent(attrs); - }, - //模板发生改变 - _uiSetTpl: function() { - this.setTplContent(); - } -}; - -tpl.View = tplView; - -module.exports = tpl; - -}); -define("bui-common/1.1.2/src/component/uibase/childcfg-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 子控件的默认配置项 - * @ignore - */ - -var $ = require('jquery'); - -/** - * @class BUI.Component.UIBase.ChildCfg - * 子控件默认配置项的扩展类 - */ -var childCfg = function(config) { - this._init(); -}; - -childCfg.ATTRS = { - /** - * 默认的子控件配置项,在初始化控件时配置 - * - * - 如果控件已经渲染过,此配置项无效, - * - 控件生成后,修改此配置项无效。 - *

-   *   var control = new Control({
-   *     defaultChildCfg : {
-   *       tpl : '<li>{text}</li>',
-   *       xclass : 'a-b'
-   *     }
-   *   });
-   * 
- * @cfg {Object} defaultChildCfg - */ - /** - * @ignore - */ - defaultChildCfg: { - - } -}; - -childCfg.prototype = { - - _init: function() { - var _self = this, - defaultChildCfg = _self.get('defaultChildCfg'); - if (defaultChildCfg) { - _self.on('beforeAddChild', function(ev) { - var child = ev.child; - if ($.isPlainObject(child)) { - BUI.each(defaultChildCfg, function(v, k) { - if (child[k] == null) { //如果未在配置项中设置,则使用默认值 - child[k] = v; - } - }); - } - }); - } - } - -}; - -module.exports = childCfg; - -}); -define("bui-common/1.1.2/src/component/uibase/bindable-debug", [], function(require, exports, module){ -/** - * @fileOverview bindable extension class. - * @author dxq613@gmail.com - * @ignore - */ - -/** - * bindable extension class. - *

- *   BUI.use(['bui/list','bui/data','bui/mask'],function(List,Data,Mask){
- *     var store = new Data.Store({
- *       url : 'data/xx.json'
- *     });
- *   	var list = new List.SimpleList({
- *  	    render : '#l1',
- *  	    store : store,
- *  	    loadMask : new Mask.LoadMask({el : '#t1'})
- *     });
- *
- *     list.render();
- *     store.load();
- *   });
- * 
- * 使控件绑定store,处理store的事件 {@link BUI.Data.Store} - * @class BUI.Component.UIBase.Bindable - */ -function bindable() { - -} - -bindable.ATTRS = { - /** - * 绑定 {@link BUI.Data.Store}的事件 - *

-   *  var store = new Data.Store({
-   *   url : 'data/xx.json',
-   *   autoLoad : true
-   *  });
-   *
-   *  var list = new List.SimpleList({
-   *  	 render : '#l1',
-   *  	 store : store
-   *  });
-   *
-   *  list.render();
-   * 
- * @cfg {BUI.Data.Store} store - */ - /** - * 绑定 {@link BUI.Data.Store}的事件 - *

-   *  var store = list.get('store');
-   * 
- * @type {BUI.Data.Store} - */ - store: { - - }, - /** - * 加载数据时,是否显示等待加载的屏蔽层 - *

-   *   BUI.use(['bui/list','bui/data','bui/mask'],function(List,Data,Mask){
-   *     var store = new Data.Store({
-   *       url : 'data/xx.json'
-   *     });
-   *   	var list = new List.SimpleList({
-   *  	    render : '#l1',
-   *  	    store : store,
-   *  	    loadMask : new Mask.LoadMask({el : '#t1'})
-   *     });
-   *
-   *     list.render();
-   *     store.load();
-   *   });
-   * 
- * @cfg {Boolean|Object} loadMask - */ - /** - * 加载数据时,是否显示等待加载的屏蔽层 - * @type {Boolean|Object} - * @ignore - */ - loadMask: { - value: false - } -}; - - -BUI.augment(bindable, { - - __bindUI: function() { - var _self = this, - store = _self.get('store'), - loadMask = _self.get('loadMask'); - if (!store) { - return; - } - store.on('beforeload', function(e) { - _self.onBeforeLoad(e); - if (loadMask && loadMask.show) { - loadMask.show(); - } - }); - store.on('load', function(e) { - _self.onLoad(e); - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - }); - store.on('exception', function(e) { - _self.onException(e); - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - }); - store.on('add', function(e) { - _self.onAdd(e); - }); - store.on('remove', function(e) { - _self.onRemove(e); - }); - store.on('update', function(e) { - _self.onUpdate(e); - }); - store.on('localsort', function(e) { - _self.onLocalSort(e); - }); - store.on('filtered', function(e) { - _self.onFiltered(e); - }); - }, - __syncUI: function() { - var _self = this, - store = _self.get('store'); - if (!store) { - return; - } - if (store.hasData()) { - _self.onLoad(); - } - }, - /** - * @protected - * @template - * before store load data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-beforeload} - */ - onBeforeLoad: function(e) { - - }, - /** - * @protected - * @template - * after store load data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-load} - */ - onLoad: function(e) { - - }, - /** - * @protected - * @template - * occurred exception when store is loading data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-exception} - */ - onException: function(e) { - - }, - /** - * @protected - * @template - * after added data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-add} - */ - onAdd: function(e) { - - }, - /** - * @protected - * @template - * after remvoed data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-remove} - */ - onRemove: function(e) { - - }, - /** - * @protected - * @template - * after updated data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-update} - */ - onUpdate: function(e) { - - }, - /** - * @protected - * @template - * after local sorted data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-localsort} - */ - onLocalSort: function(e) { - - }, - /** - * @protected - * @template - * after filter data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-filtered} - */ - onFiltered: function(e) {} -}); - -module.exports = bindable; - -}); -define("bui-common/1.1.2/src/component/uibase/depends-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 依赖扩展,用于观察者模式中的观察者 - * @ignore - */ - - -var $ = require('jquery'), - regexp = /^#(.*):(.*)$/, - Manager = require("bui-common/1.1.2/src/component/manage-debug"); - -//获取依赖信息 -function getDepend(name) { - - var arr = regexp.exec(name), - id = arr[1], - eventType = arr[2], - source = getSource(id); - return { - source: source, - eventType: eventType - }; -} - -//绑定依赖 -function bindDepend(self, name, action) { - var depend = getDepend(name), - source = depend.source, - eventType = depend.eventType, - callbak; - if (source && action && eventType) { - - if (BUI.isFunction(action)) { //如果action是一个函数 - callbak = action; - } else if (BUI.isArray(action)) { //如果是一个数组,构建一个回调函数 - callbak = function() { - BUI.each(action, function(methodName) { - if (self[methodName]) { - self[methodName](); - } - }); - } - } - } - if (callbak) { - depend.callbak = callbak; - source.on(eventType, callbak); - return depend; - } - return null; -} -//去除依赖 -function offDepend(depend) { - var source = depend.source, - eventType = depend.eventType, - callbak = depend.callbak; - source.off(eventType, callbak); -} - -//获取绑定的事件源 -function getSource(id) { - var control = Manager.getComponent(id); - if (!control) { - control = $('#' + id); - if (!control.length) { - control = null; - } - } - return control; -} - -/** - * @class BUI.Component.UIBase.Depends - * 依赖事件源的扩展 - *

- *       var control = new Control({
- *         depends : {
- *           '#btn:click':['toggle'],//当点击id为'btn'的按钮时,执行 control 的toggle方法
- *           '#checkbox1:checked':['show'],//当勾选checkbox时,显示控件
- *           '#menu:click',function(){}
- *         }
- *       });
- * 
- */ -function Depends() { - -}; - -Depends.ATTRS = { - /** - * 控件的依赖事件,是一个数组集合,每一条记录是一个依赖关系
- * 一个依赖是注册一个事件,所以需要在一个依赖中提供: - *
    - *
  1. 绑定源:为了方便配置,我们使用 #id来指定绑定源,可以使控件的ID(只支持继承{BUI.Component.Controller}的控件),也可以是DOM的id
  2. - *
  3. 事件名:事件名是一个使用":"为前缀的字符串,例如 "#id:change",即监听change事件
  4. - *
  5. 触发的方法:可以是一个数组,如["disable","clear"],数组里面是控件的方法名,也可以是一个回调函数
  6. - *
- *

-   *       var control = new Control({
-   *         depends : {
-   *           '#btn:click':['toggle'],//当点击id为'btn'的按钮时,执行 control 的toggle方法
-   *           '#checkbox1:checked':['show'],//当勾选checkbox时,显示控件
-   *           '#menu:click',function(){}
-   *         }
-   *       });
-   * 
- * ** 注意:** 这些依赖项是在控件渲染(render)后进行的。 - * @type {Object} - */ - depends: { - - }, - /** - * @private - * 依赖的映射集合 - * @type {Object} - */ - dependencesMap: { - shared: false, - value: {} - } -}; - -Depends.prototype = { - - __syncUI: function() { - this.initDependences(); - }, - /** - * 初始化依赖项 - * @protected - */ - initDependences: function() { - var _self = this, - depends = _self.get('depends'); - BUI.each(depends, function(action, name) { - _self.addDependence(name, action); - }); - }, - /** - * 添加依赖,如果已经有同名的事件,则移除,再添加 - *

-   *  form.addDependence('#btn:click',['toggle']); //当按钮#btn点击时,表单交替显示隐藏
-   *
-   *  form.addDependence('#btn:click',function(){//当按钮#btn点击时,表单交替显示隐藏
-   *   //TO DO
-   *  });
-   * 
- * @param {String} name 依赖项的名称 - * @param {Array|Function} action 依赖项的事件 - */ - addDependence: function(name, action) { - var _self = this, - dependencesMap = _self.get('dependencesMap'), - depend; - _self.removeDependence(name); - depend = bindDepend(_self, name, action) - if (depend) { - dependencesMap[name] = depend; - } - }, - /** - * 移除依赖 - *

-   *  form.removeDependence('#btn:click'); //当按钮#btn点击时,表单不在监听
-   * 
- * @param {String} name 依赖名称 - */ - removeDependence: function(name) { - var _self = this, - dependencesMap = _self.get('dependencesMap'), - depend = dependencesMap[name]; - if (depend) { - offDepend(depend); - delete dependencesMap[name]; - } - }, - /** - * 清除所有的依赖 - *

-   *  form.clearDependences();
-   * 
- */ - clearDependences: function() { - var _self = this, - map = _self.get('dependencesMap'); - BUI.each(map, function(depend, name) { - offDepend(depend); - }); - _self.set('dependencesMap', {}); - }, - __destructor: function() { - this.clearDependences(); - } - -}; - -module.exports = Depends; - -}); -define("bui-common/1.1.2/src/component/view-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 控件的视图层 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'), - win = window, - Manager = require("bui-common/1.1.2/src/component/manage-debug"), - UIBase = require("bui-common/1.1.2/src/component/uibase/uibase-debug"), //BUI.Component.UIBase, - doc = document; - -/** - * 控件的视图层基类 - * @class BUI.Component.View - * @protected - * @extends BUI.Component.UIBase - * @mixins BUI.Component.UIBase.TplView - */ -var View = UIBase.extend([UIBase.TplView], { - - /** - * Get all css class name to be applied to the root element of this component for given state. - * the css class names are prefixed with component name. - * @param {String} [state] This component's state info. - */ - getComponentCssClassWithState: function(state) { - var self = this, - componentCls = self.get('ksComponentCss'); - state = state || ''; - return self.getCssClassWithPrefix(componentCls.split(/\s+/).join(state + ' ') + state); - }, - - /** - * Get full class name (with prefix) for current component - * @param classes {String} class names without prefixCls. Separated by space. - * @method - * @return {String} class name with prefixCls - * @private - */ - getCssClassWithPrefix: Manager.getCssClassWithPrefix, - - /** - * Returns the dom element which is responsible for listening keyboard events. - * @return {jQuery} - */ - getKeyEventTarget: function() { - return this.get('el'); - }, - /** - * Return the dom element into which child component to be rendered. - * @return {jQuery} - */ - getContentElement: function() { - return this.get('contentEl') || this.get('el'); - }, - /** - * 获取状态对应的css样式 - * @param {String} name 状态名称 例如:hover,disabled等等 - * @return {String} 状态样式 - */ - getStatusCls: function(name) { - var self = this, - statusCls = self.get('statusCls'), - cls = statusCls[name]; - if (!cls) { - cls = self.getComponentCssClassWithState('-' + name); - } - return cls; - }, - /** - * 渲染控件 - * @protected - */ - renderUI: function() { - var self = this; - - // 新建的节点才需要摆放定位,不支持srcNode模式 - if (!self.get('srcNode')) { - var render = self.get('render'), - el = self.get('el'), - renderBefore = self.get('elBefore'); - if (renderBefore) { - el.insertBefore(renderBefore, undefined); - } else if (render) { - el.appendTo(render, undefined); - } else { - el.appendTo(doc.body, undefined); - } - } - }, - /** - * 只负责建立节点,如果是 decorate 过来的,甚至内容会丢失 - * @protected - * 通过 render 来重建原有的内容 - */ - createDom: function() { - var self = this, - contentEl = self.get('contentEl'), - el = self.get('el'); - if (!self.get('srcNode')) { - - el = $('<' + self.get('elTagName') + '>'); - - if (contentEl) { - el.append(contentEl); - } - - self.setInternal('el', el); - } - - el.addClass(self.getComponentCssClassWithState()); - if (!contentEl) { - // 没取到,这里设下值, uiSet 时可以 set('content') 取到 - self.setInternal('contentEl', el); - } - }, - /** - * 设置高亮显示 - * @protected - */ - _uiSetHighlighted: function(v) { - var self = this, - componentCls = self.getStatusCls('hover'), - el = self.get('el'); - el[v ? 'addClass' : 'removeClass'](componentCls); - }, - - /** - * 设置禁用 - * @protected - */ - _uiSetDisabled: function(v) { - var self = this, - componentCls = self.getStatusCls('disabled'), - el = self.get('el'); - el[v ? 'addClass' : 'removeClass'](componentCls) - .attr('aria-disabled', v); - - //如果禁用控件时,处于hover状态,则清除 - if (v && self.get('highlighted')) { - self.set('highlighted', false); - } - - if (self.get('focusable')) { - //不能被 tab focus 到 - self.getKeyEventTarget().attr('tabIndex', v ? -1 : 0); - } - }, - /** - * 设置激活状态 - * @protected - */ - _uiSetActive: function(v) { - var self = this, - componentCls = self.getStatusCls('active'); - self.get('el')[v ? 'addClass' : 'removeClass'](componentCls) - .attr('aria-pressed', !!v); - }, - /** - * 设置获得焦点 - * @protected - */ - _uiSetFocused: function(v) { - var self = this, - el = self.get('el'), - componentCls = self.getStatusCls('focused'); - el[v ? 'addClass' : 'removeClass'](componentCls); - }, - /** - * 设置控件最外层DOM的属性 - * @protected - */ - _uiSetElAttrs: function(attrs) { - this.get('el').attr(attrs); - }, - /** - * 设置应用到控件最外层DOM的css class - * @protected - */ - _uiSetElCls: function(cls) { - this.get('el').addClass(cls); - }, - /** - * 设置应用到控件最外层DOM的css style - * @protected - */ - _uiSetElStyle: function(style) { - this.get('el').css(style); - }, - //设置role - _uiSetRole: function(role) { - if (role) { - this.get('el').attr('role', role); - } - }, - /** - * 设置应用到控件宽度 - * @protected - */ - _uiSetWidth: function(w) { - this.get('el').width(w); - }, - /** - * 设置应用到控件高度 - * @protected - */ - _uiSetHeight: function(h) { - var self = this; - self.get('el').height(h); - }, - /** - * 设置应用到控件的内容 - * @protected - */ - _uiSetContent: function(c) { - var self = this, - el; - // srcNode 时不重新渲染 content - // 防止内部有改变,而 content 则是老的 html 内容 - if (self.get('srcNode') && !self.get('rendered')) {} else { - el = self.get('contentEl'); - if (typeof c == 'string') { - el.html(c); - } else if (c) { - el.empty().append(c); - } - } - }, - /** - * 设置应用到控件是否可见 - * @protected - */ - _uiSetVisible: function(isVisible) { - var self = this, - el = self.get('el'), - visibleMode = self.get('visibleMode'); - if (visibleMode === 'visibility') { - el.css('visibility', isVisible ? 'visible' : 'hidden'); - } else { - el.css('display', isVisible ? '' : 'none'); - } - }, - set: function(name, value) { - var _self = this, - attr = _self.__attrs[name], - ev, - ucName, - m; - - if (!attr || !_self.get('binded')) { //未初始化view或者没用定义属性 - View.superclass.set.call(this, name, value); - return _self; - } - - var prevVal = View.superclass.get.call(this, name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return _self; - } - View.superclass.set.call(this, name, value); - - value = _self.__attrVals[name]; - ev = { - attrName: name, - prevVal: prevVal, - newVal: value - }; - ucName = BUI.ucfirst(name); - m = '_uiSet' + ucName; - if (_self[m]) { - _self[m](value, ev); - } - - return _self; - - }, - /** - * 析构函数 - * @protected - */ - destructor: function() { - var el = this.get('el'); - if (el) { - el.remove(); - } - } -}, { - xclass: 'view', - priority: 0 -}); - - -View.ATTRS = { - /** - * 控件根节点 - * @readOnly - * see {@link BUI.Component.Controller#property-el} - */ - el: { - /** - * @private - */ - setter: function(v) { - return $(v); - } - }, - - /** - * 控件根节点样式 - * see {@link BUI.Component.Controller#property-elCls} - */ - elCls: {}, - /** - * 控件根节点样式属性 - * see {@link BUI.Component.Controller#property-elStyle} - */ - elStyle: {}, - /** - * ARIA 标准中的role - * @type {String} - */ - role: { - - }, - /** - * 控件宽度 - * see {@link BUI.Component.Controller#property-width} - */ - width: {}, - /** - * 控件高度 - * see {@link BUI.Component.Controller#property-height} - */ - height: {}, - /** - * 状态相关的样式,默认情况下会使用 前缀名 + xclass + '-' + 状态名 - * see {@link BUI.Component.Controller#property-statusCls} - * @type {Object} - */ - statusCls: { - value: {} - }, - /** - * 控件根节点使用的标签 - * @type {String} - */ - elTagName: { - // 生成标签名字 - value: 'div' - }, - /** - * 控件根节点属性 - * see {@link BUI.Component.Controller#property-elAttrs} - * @ignore - */ - elAttrs: {}, - /** - * 控件内容,html,文本等 - * see {@link BUI.Component.Controller#property-content} - */ - content: {}, - /** - * 控件插入到指定元素前 - * see {@link BUI.Component.Controller#property-tpl} - */ - elBefore: { - // better named to renderBefore, too late ! - }, - /** - * 控件在指定元素内部渲染 - * see {@link BUI.Component.Controller#property-render} - * @ignore - */ - render: {}, - /** - * 是否可见 - * see {@link BUI.Component.Controller#property-visible} - */ - visible: { - value: true - }, - /** - * 可视模式 - * see {@link BUI.Component.Controller#property-visibleMode} - */ - visibleMode: { - value: 'display' - }, - /** - * @private - * 缓存隐藏时的位置,对应visibleMode = 'visiblity' 的场景 - * @type {Object} - */ - cachePosition: { - - }, - /** - * content 设置的内容节点,默认根节点 - * @type {jQuery} - * @default el - */ - contentEl: { - valueFn: function() { - return this.get('el'); - } - }, - /** - * 样式前缀 - * see {@link BUI.Component.Controller#property-prefixCls} - */ - prefixCls: { - value: BUI.prefix - }, - /** - * 可以获取焦点 - * @protected - * see {@link BUI.Component.Controller#property-focusable} - */ - focusable: { - value: true - }, - /** - * 获取焦点 - * see {@link BUI.Component.Controller#property-focused} - */ - focused: {}, - /** - * 激活 - * see {@link BUI.Component.Controller#property-active} - */ - active: {}, - /** - * 禁用 - * see {@link BUI.Component.Controller#property-disabled} - */ - disabled: {}, - /** - * 高亮显示 - * see {@link BUI.Component.Controller#property-highlighted} - */ - highlighted: {} -}; - -module.exports = View; - -}); -define("bui-common/1.1.2/src/component/controller-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 控件可以实例化的基类 - * @ignore - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - */ - -/** - * jQuery 事件 - * @class jQuery.Event - * @private - */ - - -'use strict'; - -var $ = require('jquery'), - UIBase = require("bui-common/1.1.2/src/component/uibase/uibase-debug"), - Manager = require("bui-common/1.1.2/src/component/manage-debug"), - View = require("bui-common/1.1.2/src/component/view-debug"), - Loader = require("bui-common/1.1.2/src/component/loader-debug"), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - -/** - * @ignore - */ -function wrapperViewSetter(attrName) { - return function(ev) { - var self = this; - // in case bubbled from sub component - if (self === ev.target) { - var value = ev.newVal, - view = self.get('view'); - if (view) { - view.set(attrName, value); - } - - } - }; -} - -/** - * @ignore - */ -function wrapperViewGetter(attrName) { - return function(v) { - var self = this, - view = self.get('view'); - return v === undefined ? view.get(attrName) : v; - }; -} - -/** - * @ignore - */ -function initChild(self, c, renderBefore) { - // 生成父组件的 dom 结构 - self.create(); - var contentEl = self.getContentElement(), - defaultCls = self.get('defaultChildClass'); - //配置默认 xclass - if (!c.xclass && !(c instanceof Controller)) { - if (!c.xtype) { - c.xclass = defaultCls; - } else { - c.xclass = defaultCls + '-' + c.xtype; - } - - } - - c = BUI.Component.create(c, self); - c.setInternal('parent', self); - // set 通知 view 也更新对应属性 - c.set('render', contentEl); - c.set('elBefore', renderBefore); - // 如果 parent 也没渲染,子组件 create 出来和 parent 节点关联 - // 子组件和 parent 组件一起渲染 - // 之前设好属性,view ,logic 同步还没 bind ,create 不是 render ,还没有 bindUI - c.create(undefined); - return c; -} - -/** - * 不使用 valueFn, - * 只有 render 时需要找到默认,其他时候不需要,防止莫名其妙初始化 - * @ignore - */ -function constructView(self) { - // 逐层找默认渲染器 - var attrs, - attrCfg, - attrName, - cfg = {}, - v, - Render = self.get('xview'); - - - //将渲染层初始化所需要的属性,直接构造器设置过去 - - attrs = self.getAttrs(); - - // 整理属性,对纯属于 view 的属性,添加 getter setter 直接到 view - for (attrName in attrs) { - if (attrs.hasOwnProperty(attrName)) { - attrCfg = attrs[attrName]; - if (attrCfg.view) { - // 先取后 getter - // 防止死循环 - if ((v = self.get(attrName)) !== undefined) { - cfg[attrName] = v; - } - - // setter 不应该有实际操作,仅用于正规化比较好 - // attrCfg.setter = wrapperViewSetter(attrName); - // 不更改attrCfg的定义,可以多个实例公用一份attrCfg - /*self.on('after' + BUI.ucfirst(attrName) + 'Change', - wrapperViewSetter(attrName)); - */ - // 逻辑层读值直接从 view 层读 - // 那么如果存在默认值也设置在 view 层 - // 逻辑层不要设置 getter - //attrCfg.getter = wrapperViewGetter(attrName); - } - } - } - // does not autoRender for view - delete cfg.autoRender; - cfg.ksComponentCss = getComponentCss(self); - return new Render(cfg); -} - -function getComponentCss(self) { - var constructor = self.constructor, - cls, - re = []; - while (constructor && constructor !== Controller) { - cls = Manager.getXClassByConstructor(constructor); - if (cls) { - re.push(cls); - } - constructor = constructor.superclass && constructor.superclass.constructor; - } - return re.join(' '); -} - -function isMouseEventWithinElement(e, elem) { - var relatedTarget = e.relatedTarget; - // 在里面或等于自身都不算 mouseenter/leave - return relatedTarget && - (relatedTarget === elem[0] || $.contains(elem, relatedTarget)); -} - -/** - * 可以实例化的控件,作为最顶层的控件类,一切用户控件都继承此控件 - * xclass: 'controller'. - * ** 创建子控件 ** - *

- * var Control = Controller.extend([mixin1,mixin2],{ //原型链上的函数
- *   renderUI : function(){ //创建DOM
- *
- *   },
- *   bindUI : function(){  //绑定事件
- *
- *   },
- *   destructor : funciton(){ //析构函数
- *
- *   }
- * },{
- *   ATTRS : { //默认的属性
- *     text : {
- *
- *     }
- *   }
- * },{
- *   xclass : 'a' //用于把对象解析成类
- * });
- * 
- * - * ** 创建对象 ** - *

- * var c1 = new Control({
- *   render : '#t1', //在t1上创建
- *   text : 'text1',
- *   children : [{xclass : 'a',text : 'a1'},{xclass : 'b',text : 'b1'}]
- * });
- *
- * c1.render();
- * 
- * @extends BUI.Component.UIBase - * @mixins BUI.Component.UIBase.Tpl - * @mixins BUI.Component.UIBase.Decorate - * @mixins BUI.Component.UIBase.Depends - * @mixins BUI.Component.UIBase.ChildCfg - * @class BUI.Component.Controller - */ -var Controller = UIBase.extend([UIBase.Decorate, UIBase.Tpl, UIBase.ChildCfg, UIBase.KeyNav, UIBase.Depends], { - /** - * 是否是控件,标示对象是否是一个UI 控件 - * @type {Boolean} - */ - isController: true, - - /** - * 使用前缀获取类的名字 - * @param classes {String} class names without prefixCls. Separated by space. - * @method - * @protected - * @return {String} class name with prefixCls - */ - getCssClassWithPrefix: Manager.getCssClassWithPrefix, - - /** - * From UIBase, Initialize this component. * - * @protected - */ - initializer: function() { - var self = this; - - if (!self.get('id')) { - self.set('id', self.getNextUniqueId()); - } - Manager.addComponent(self.get('id'), self); - // initialize view - var view = constructView(self); - self.setInternal('view', view); - self.__view = view; - }, - - /** - * 返回新的唯一的Id,结果是 'xclass' + number - * @protected - * @return {String} 唯一id - */ - getNextUniqueId: function() { - var self = this, - xclass = Manager.getXClassByConstructor(self.constructor); - return BUI.guid(xclass); - }, - /** - * From UIBase. Constructor(or get) view object to create ui elements. - * @protected - * - */ - createDom: function() { - var self = this, - //el, - view = self.get('view'); - view.create(undefined); - //el = view.getKeyEventTarget(); - /*if (!self.get('allowTextSelection')) { - //el.unselectable(undefined); - }*/ - }, - - /** - * From UIBase. Call view object to render ui elements. - * @protected - * - */ - renderUI: function() { - var self = this, - loader = self.get('loader'); - self.get('view').render(); - self._initChildren(); - if (loader) { - self.setInternal('loader', loader); - } - /**/ - - }, - _initChildren: function(children) { - var self = this, - i, - children, - child; - // then render my children - children = children || self.get('children').concat(); - self.get('children').length = 0; - for (i = 0; i < children.length; i++) { - child = self.addChild(children[i]); - child.render(); - } - }, - /** - * bind ui for box - * @private - */ - bindUI: function() { - var self = this, - events = self.get('events'); - this.on('afterVisibleChange', function(e) { - this.fire(e.newVal ? 'show' : 'hide'); - }); - //处理控件事件,设置事件是否冒泡 - BUI.each(events, function(v, k) { - self.publish(k, { - bubbles: v - }); - }); - }, - /** - * 控件是否包含指定的DOM元素,包括根节点 - *

-   *   var control = new Control();
-   *   $(document).on('click',function(ev){
-   *   var target = ev.target;
-   *
-   *   if(!control.containsElement(elem)){ //未点击在控件内部
-   *     control.hide();
-   *   }
-   *   });
-   * 
- * @param {HTMLElement} elem DOM 元素 - * @return {Boolean} 是否包含 - */ - containsElement: function(elem) { - var _self = this, - el = _self.get('el'), - children = _self.get('children'), - result = false; - if (!_self.get('rendered')) { - return false; - } - if ($.contains(el[0], elem) || el[0] === elem) { - result = true; - } else { - BUI.each(children, function(item) { - if (item.containsElement(elem)) { - result = true; - return false; - } - }); - } - return result; - }, - /** - * 是否是子控件的DOM元素 - * @protected - * @return {Boolean} 是否子控件的DOM元素 - */ - isChildrenElement: function(elem) { - var _self = this, - children = _self.get('children'), - rst = false; - BUI.each(children, function(child) { - if (child.containsElement(elem)) { - rst = true; - return false; - } - }); - return rst; - }, - /** - * 显示控件 - */ - show: function() { - var self = this; - self.render(); - self.set('visible', true); - return self; - }, - - /** - * 隐藏控件 - */ - hide: function() { - var self = this; - self.set('visible', false); - return self; - }, - /** - * 交替显示或者隐藏 - *

-   *  control.show(); //显示
-   *  control.toggle(); //隐藏
-   *  control.toggle(); //显示
-   * 
- */ - toggle: function() { - this.set('visible', !this.get('visible')); - return this; - }, - _uiSetFocusable: function(focusable) { - var self = this, - t, - el = self.getKeyEventTarget(); - if (focusable) { - el.attr('tabIndex', 0) - // remove smart outline in ie - // set outline in style for other standard browser - .attr('hideFocus', true) - .on('focus', wrapBehavior(self, 'handleFocus')) - .on('blur', wrapBehavior(self, 'handleBlur')) - .on('keydown', wrapBehavior(self, 'handleKeydown')) - .on('keyup', wrapBehavior(self, 'handleKeyUp')); - } else { - el.removeAttr('tabIndex'); - if (t = getWrapBehavior(self, 'handleFocus')) { - el.off('focus', t); - } - if (t = getWrapBehavior(self, 'handleBlur')) { - el.off('blur', t); - } - if (t = getWrapBehavior(self, 'handleKeydown')) { - el.off('keydown', t); - } - if (t = getWrapBehavior(self, 'handleKeyUp')) { - el.off('keyup', t); - } - } - }, - - _uiSetHandleMouseEvents: function(handleMouseEvents) { - var self = this, - el = self.get('el'), - t; - if (handleMouseEvents) { - el.on('mouseenter', wrapBehavior(self, 'handleMouseEnter')) - .on('mouseleave', wrapBehavior(self, 'handleMouseLeave')) - .on('contextmenu', wrapBehavior(self, 'handleContextMenu')) - .on('mousedown', wrapBehavior(self, 'handleMouseDown')) - .on('mouseup', wrapBehavior(self, 'handleMouseUp')) - .on('dblclick', wrapBehavior(self, 'handleDblClick')); - } else { - t = getWrapBehavior(self, 'handleMouseEnter') && - el.off('mouseenter', t); - t = getWrapBehavior(self, 'handleMouseLeave') && - el.off('mouseleave', t); - t = getWrapBehavior(self, 'handleContextMenu') && - el.off('contextmenu', t); - t = getWrapBehavior(self, 'handleMouseDown') && - el.off('mousedown', t); - t = getWrapBehavior(self, 'handleMouseUp') && - el.off('mouseup', t); - t = getWrapBehavior(self, 'handleDblClick') && - el.off('dblclick', t); - } - }, - - _uiSetFocused: function(v) { - if (v) { - this.getKeyEventTarget()[0].focus(); - } - }, - //当使用visiblity显示隐藏时,隐藏时把DOM移除出视图内,显示时回复原位置 - _uiSetVisible: function(isVisible) { - var self = this, - el = self.get('el'), - visibleMode = self.get('visibleMode'); - if (visibleMode === 'visibility') { - if (isVisible) { - var position = self.get('cachePosition'); - if (position) { - self.set('xy', position); - } - } - if (!isVisible) { - var position = [ - self.get('x'), self.get('y') - ]; - self.set('cachePosition', position); - self.set('xy', [-999, -999]); - } - } - }, - //设置children时 - _uiSetChildren: function(v) { - var self = this, - children = BUI.cloneObject(v); - //self.removeChildren(true); - self._initChildren(children); - }, - /** - * 使控件可用 - */ - enable: function() { - this.set('disabled', false); - return this; - }, - /** - * 使控件不可用,控件不可用时,点击等事件不会触发 - *

-   *  control.disable(); //禁用
-   *  control.enable(); //解除禁用
-   * 
- */ - disable: function() { - this.set('disabled', true); - return this; - }, - /** - * 控件获取焦点 - */ - focus: function() { - if (this.get('focusable')) { - this.set('focused', true); - } - }, - /** - * 子组件将要渲染到的节点,在 render 类上覆盖对应方法 - * @protected - * @ignore - */ - getContentElement: function() { - return this.get('view').getContentElement(); - }, - - /** - * 焦点所在元素即键盘事件处理元素,在 render 类上覆盖对应方法 - * @protected - * @ignore - */ - getKeyEventTarget: function() { - return this.get('view').getKeyEventTarget(); - }, - - /** - * 添加控件的子控件,索引值为 0-based - *

-   *  control.add(new Control());//添加controller对象
-   *  control.add({xclass : 'a'});//添加xclass 为a 的一个对象
-   *  control.add({xclass : 'b'},2);//插入到第三个位置
-   * 
- * @param {BUI.Component.Controller|Object} c 子控件的实例或者配置项 - * @param {String} [c.xclass] 如果c为配置项,设置c的xclass - * @param {Number} [index] 0-based 如果未指定索引值,则插在控件的最后 - */ - addChild: function(c, index) { - var self = this, - children = self.get('children'), - renderBefore; - if (index === undefined) { - index = children.length; - } - /** - * 添加子控件前触发 - * @event beforeAddChild - * @param {Object} e - * @param {Object} e.child 添加子控件时传入的配置项或者子控件 - * @param {Number} e.index 添加的位置 - */ - self.fire('beforeAddChild', { - child: c, - index: index - }); - renderBefore = children[index] && children[index].get('el') || null; - c = initChild(self, c, renderBefore); - children.splice(index, 0, c); - // 先 create 占位 再 render - // 防止 render 逻辑里读 parent.get('children') 不同步 - // 如果 parent 已经渲染好了子组件也要立即渲染,就 创建 dom ,绑定事件 - if (self.get('rendered')) { - c.render(); - } - - /** - * 添加子控件后触发 - * @event afterAddChild - * @param {Object} e - * @param {Object} e.child 添加子控件 - * @param {Number} e.index 添加的位置 - */ - self.fire('afterAddChild', { - child: c, - index: index - }); - return c; - }, - /** - * 将自己从父控件中移除 - *

-   *  control.remove(); //将控件从父控件中移除,并未删除
-   *  parent.addChild(control); //还可以添加回父控件
-   *
-   *  control.remove(true); //从控件中移除并调用控件的析构函数
-   * 
- * @param {Boolean} destroy 是否删除DON节点 - * @return {BUI.Component.Controller} 删除的子对象. - */ - remove: function(destroy) { - var self = this, - parent = self.get('parent'); - if (parent) { - parent.removeChild(self, destroy); - } else if (destroy) { - self.destroy(); - } - return self; - }, - /** - * 移除子控件,并返回移除的控件 - * - * ** 如果 destroy=true,调用移除控件的 {@link BUI.Component.UIBase#destroy} 方法, - * 同时删除对应的DOM ** - *

-   *  var child = control.getChild(id);
-   *  control.removeChild(child); //仅仅移除
-   *
-   *  control.removeChild(child,true); //移除,并调用析构函数
-   * 
- * @param {BUI.Component.Controller} c 要移除的子控件. - * @param {Boolean} [destroy=false] 如果是true, - * 调用控件的方法 {@link BUI.Component.UIBase#destroy} . - * @return {BUI.Component.Controller} 移除的子控件. - */ - removeChild: function(c, destroy) { - var self = this, - children = self.get('children'), - index = BUI.Array.indexOf(c, children); - - if (index === -1) { - return; - } - /** - * 删除子控件前触发 - * @event beforeRemoveChild - * @param {Object} e - * @param {Object} e.child 子控件 - * @param {Boolean} e.destroy 是否清除DOM - */ - self.fire('beforeRemoveChild', { - child: c, - destroy: destroy - }); - - if (index !== -1) { - children.splice(index, 1); - } - if (destroy && - // c is still json - c.destroy) { - c.destroy(); - } - /** - * 删除子控件前触发 - * @event afterRemoveChild - * @param {Object} e - * @param {Object} e.child 子控件 - * @param {Boolean} e.destroy 是否清除DOM - */ - self.fire('afterRemoveChild', { - child: c, - destroy: destroy - }); - - return c; - }, - - /** - * 删除当前控件的子控件 - *

-   *   control.removeChildren();//删除所有子控件
-   *   control.removeChildren(true);//删除所有子控件,并调用子控件的析构函数
-   * 
- * @see Component.Controller#removeChild - * @param {Boolean} [destroy] 如果设置 true, - * 调用子控件的 {@link BUI.Component.UIBase#destroy}方法. - */ - removeChildren: function(destroy) { - var self = this, - i, - t = [].concat(self.get('children')); - for (i = 0; i < t.length; i++) { - self.removeChild(t[i], destroy); - } - }, - - /** - * 根据索引获取子控件 - *

-   *  control.getChildAt(0);//获取第一个子控件
-   *  control.getChildAt(2); //获取第三个子控件
-   * 
- * @param {Number} index 0-based 索引值. - * @return {BUI.Component.Controller} 子控件或者null - */ - getChildAt: function(index) { - var children = this.get('children'); - return children[index] || null; - }, - /** - * 根据Id获取子控件 - *

-   *  control.getChild('id'); //从控件的直接子控件中查找
-   *  control.getChild('id',true);//递归查找所有子控件,包含子控件的子控件
-   * 
- * @param {String} id 控件编号 - * @param {Boolean} deep 是否继续查找在子控件中查找 - * @return {BUI.Component.Controller} 子控件或者null - */ - getChild: function(id, deep) { - return this.getChildBy(function(item) { - return item.get('id') === id; - }, deep); - }, - /** - * 通过匹配函数查找子控件,返回第一个匹配的对象 - *

-   *  control.getChildBy(function(child){//从控件的直接子控件中查找
-   *  return child.get('id') = '1243';
-   *  });
-   *
-   *  control.getChild(function(child){//递归查找所有子控件,包含子控件的子控件
-   *  return child.get('id') = '1243';
-   *  },true);
-   * 
- * @param {Function} math 查找的匹配函数 - * @param {Boolean} deep 是否继续查找在子控件中查找 - * @return {BUI.Component.Controller} 子控件或者null - */ - getChildBy: function(math, deep) { - return this.getChildrenBy(math, deep)[0] || null; - }, - /** - * 获取控件的附加高度 = control.get('el').outerHeight() - control.get('el').height() - * @protected - * @return {Number} 附加宽度 - */ - getAppendHeight: function() { - var el = this.get('el'); - return el.outerHeight() - el.height(); - }, - /** - * 获取控件的附加宽度 = control.get('el').outerWidth() - control.get('el').width() - * @protected - * @return {Number} 附加宽度 - */ - getAppendWidth: function() { - var el = this.get('el'); - return el.outerWidth() - el.width(); - }, - /** - * 查找符合条件的子控件 - *

-   *  control.getChildrenBy(function(child){//从控件的直接子控件中查找
-   *  return child.get('type') = '1';
-   *  });
-   *
-   *  control.getChildrenBy(function(child){//递归查找所有子控件,包含子控件的子控件
-   *  return child.get('type') = '1';
-   *  },true);
-   * 
- * @param {Function} math 查找的匹配函数 - * @param {Boolean} deep 是否继续查找在子控件中查找,如果符合上面的匹配函数,则不再往下查找 - * @return {BUI.Component.Controller[]} 子控件数组 - */ - getChildrenBy: function(math, deep) { - var self = this, - results = []; - if (!math) { - return results; - } - - self.eachChild(function(child) { - if (math(child)) { - results.push(child); - } else if (deep) { - - results = results.concat(child.getChildrenBy(math, deep)); - } - }); - return results; - }, - /** - * 遍历子元素 - *

-   *  control.eachChild(function(child,index){ //遍历子控件
-   *
-   *  });
-   * 
- * @param {Function} func 迭代函数,函数原型function(child,index) - */ - eachChild: function(func) { - BUI.each(this.get('children'), func); - }, - /** - * Handle dblclick events. By default, this performs its associated action by calling - * {@link BUI.Component.Controller#performActionInternal}. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleDblClick: function(ev) { - this.performActionInternal(ev); - if (!this.isChildrenElement(ev.target)) { - this.fire('dblclick', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Called by it's container component to dispatch mouseenter event. - * @private - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseOver: function(ev) { - var self = this, - el = self.get('el'); - if (!isMouseEventWithinElement(ev, el)) { - self.handleMouseEnter(ev); - - } - }, - - /** - * Called by it's container component to dispatch mouseleave event. - * @private - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseOut: function(ev) { - var self = this, - el = self.get('el'); - if (!isMouseEventWithinElement(ev, el)) { - self.handleMouseLeave(ev); - - } - }, - - /** - * Handle mouseenter events. If the component is not disabled, highlights it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseEnter: function(ev) { - var self = this; - this.set('highlighted', !!ev); - self.fire('mouseenter', { - domTarget: ev.target, - domEvent: ev - }); - }, - - /** - * Handle mouseleave events. If the component is not disabled, de-highlights it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseLeave: function(ev) { - var self = this; - self.set('active', false); - self.set('highlighted', !ev); - self.fire('mouseleave', { - domTarget: ev.target, - domEvent: ev - }); - }, - - /** - * Handles mousedown events. If the component is not disabled, - * If the component is activeable, then activate it. - * If the component is focusable, then focus it, - * else prevent it from receiving keyboard focus. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseDown: function(ev) { - var self = this, - n, - target = $(ev.target), - isMouseActionButton = ev['which'] === 1, - el; - if (isMouseActionButton) { - el = self.getKeyEventTarget(); - if (self.get('activeable')) { - self.set('active', true); - } - if (self.get('focusable')) { - //如果不是input,select,area等可以获取焦点的控件,那么设置此控件的focus - /*if(target[0] == el[0] || (!target.is('input,select,area') && !target.attr('tabindex'))){ - el[0].focus(); - - }*/ - self.setInternal('focused', true); - } - - if (!self.get('allowTextSelection')) { - // firefox /chrome 不会引起焦点转移 - n = ev.target.nodeName; - n = n && n.toLowerCase(); - // do not prevent focus when click on editable element - if (n !== 'input' && n !== 'textarea') { - ev.preventDefault(); - } - } - if (!self.isChildrenElement(ev.target)) { - self.fire('mousedown', { - domTarget: ev.target, - domEvent: ev - }); - } - - } - }, - - /** - * Handles mouseup events. - * If this component is not disabled, performs its associated action by calling - * {@link BUI.Component.Controller#performActionInternal}, then deactivates it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseUp: function(ev) { - var self = this, - isChildrenElement = self.isChildrenElement(ev.target); - // 左键 - if (self.get('active') && ev.which === 1) { - self.performActionInternal(ev); - self.set('active', false); - if (!isChildrenElement) { - self.fire('click', { - domTarget: ev.target, - domEvent: ev - }); - } - } - if (!isChildrenElement) { - self.fire('mouseup', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Handles context menu. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleContextMenu: function(ev) {}, - - /** - * Handles focus events. Style focused class. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleFocus: function(ev) { - this.set('focused', !!ev); - this.fire('focus', { - domEvent: ev, - domTarget: ev.target - }); - }, - - /** - * Handles blur events. Remove focused class. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleBlur: function(ev) { - this.set('focused', !ev); - this.fire('blur', { - domEvent: ev, - domTarget: ev.target - }); - }, - - /** - * Handle enter keydown event to {@link BUI.Component.Controller#performActionInternal}. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleKeyEventInternal: function(ev) { - var self = this, - isChildrenElement = self.isChildrenElement(ev.target); - if (ev.which === 13) { - if (!isChildrenElement) { - self.fire('click', { - domTarget: ev.target, - domEvent: ev - }); - } - - return this.performActionInternal(ev); - } - if (!isChildrenElement) { - self.fire('keydown', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Handle keydown events. - * If the component is not disabled, call {@link BUI.Component.Controller#handleKeyEventInternal} - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleKeydown: function(ev) { - var self = this; - if (self.handleKeyEventInternal(ev)) { - ev.halt(); - return true; - } - }, - handleKeyUp: function(ev) { - var self = this; - if (!self.isChildrenElement(ev.target)) { - self.fire('keyup', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - /** - * Performs the appropriate action when this component is activated by the user. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - performActionInternal: function(ev) {}, - /** - * 析构函数 - * @protected - */ - destructor: function() { - var self = this, - id, - i, - view, - children = self.get('children'); - id = self.get('id'); - for (i = 0; i < children.length; i++) { - children[i].destroy && children[i].destroy(); - } - self.get('view').destroy(); - Manager.removeComponent(id); - }, - //覆写set方法 - set: function(name, value, opt) { - var _self = this, - view = _self.__view, - attr = _self.__attrs[name], - ucName, - ev, - m; - if (BUI.isObject(name)) { - opt = value; - BUI.each(name, function(v, k) { - _self.set(k, v, opt); - }); - } - if (!view || !attr || (opt && opt.silent)) { //未初始化view或者没用定义属性 - Controller.superclass.set.call(this, name, value, opt); - return _self; - } - - var prevVal = Controller.superclass.get.call(this, name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return _self; - } - ucName = BUI.ucfirst(name); - m = '_uiSet' + ucName; - //触发before事件 - _self.fire('before' + ucName + 'Change', { - attrName: name, - prevVal: prevVal, - newVal: value - }); - - _self.setInternal(name, value); - - value = _self.__attrVals[name]; - if (view && attr.view) { - view.set(name, value); - //return _self; - } - ev = { - attrName: name, - prevVal: prevVal, - newVal: value - }; - - //触发before事件 - _self.fire('after' + ucName + 'Change', ev); - if (_self.get('binded') && _self[m]) { - _self[m](value, ev); - } - return _self; - }, - //覆写get方法,改变时同时改变view的值 - get: function(name) { - var _self = this, - view = _self.__view, - attr = _self.__attrs[name], - value = Controller.superclass.get.call(this, name); - if (value !== undefined) { - return value; - } - if (view && attr && attr.view) { - return view.get(name); - } - - return value; - } -}, { - ATTRS: { - /** - * 控件的Html 内容 - *

-     *  new Control({
-     *   content : '内容',
-     *   render : '#c1'
-     *  });
-     * 
- * @cfg {String|jQuery} content - */ - /** - * 控件的Html 内容 - * @type {String|jQuery} - */ - content: { - view: 1 - }, - /** - * 控件根节点使用的标签 - *

-     *  new Control({
-     *   elTagName : 'ul',
-     *    content : '
  • 内容
  • ', //控件的DOM <ul><li>内容</li></ul> - * render : '#c1' - * }); - *
    - * @cfg {String} elTagName - */ - elTagName: { - // 生成标签名字 - view: true, - value: 'div' - }, - /** - * 子元素的默认 xclass,配置child的时候没必要每次都填写xclass - * @type {String} - */ - defaultChildClass: { - - }, - /** - * 如果控件未设置 xclass,同时父元素设置了 defaultChildClass,那么 - * xclass = defaultChildClass + '-' + xtype - *
    
    -     *  A.ATTRS = {
    -     *  defaultChildClass : {
    -     *    value : 'b'
    -     *  }
    -     *  }
    -     *  //类B 的xclass = 'b'类 B1的xclass = 'b-1',类 B2的xclass = 'b-2',那么
    -     *  var a = new A({
    -     *  children : [
    -     *    {content : 'b'}, //B类
    -     *    {content : 'b1',xtype:'1'}, //B1类
    -     *    {content : 'b2',xtype:'2'}, //B2类
    -     *  ]
    -     *  });
    -     * 
    - * @type {String} - */ - xtype: { - - }, - /** - * 标示控件的唯一编号,默认会自动生成 - * @cfg {String} id - */ - /** - * 标示控件的唯一编号,默认会自动生成 - * @type {String} - */ - id: { - view: true - }, - /** - * 控件宽度 - *
    
    -     * new Control({
    -     *   width : 200 // 200,'200px','20%'
    -     * });
    -     * 
    - * @cfg {Number|String} width - */ - /** - * 控件宽度 - *
    
    -     *  control.set('width',200);
    -     *  control.set('width','200px');
    -     *  control.set('width','20%');
    -     * 
    - * @type {Number|String} - */ - width: { - view: 1 - }, - /** - * 控件宽度 - *
    
    -     * new Control({
    -     *   height : 200 // 200,'200px','20%'
    -     * });
    -     * 
    - * @cfg {Number|String} height - */ - /** - * 控件宽度 - *
    
    -     *  control.set('height',200);
    -     *  control.set('height','200px');
    -     *  control.set('height','20%');
    -     * 
    - * @type {Number|String} - */ - height: { - view: 1 - }, - /** - * 控件根节点应用的样式 - *
    
    -     *  new Control({
    -     *   elCls : 'test',
    -     *   content : '内容',
    -     *   render : '#t1'   //<div id='t1'><div class="test">内容</div></div>
    -     *  });
    -     * 
    - * @cfg {String} elCls - */ - /** - * 控件根节点应用的样式 css class - * @type {String} - */ - elCls: { - view: 1 - }, - /** - * @cfg {Object} elStyle - * 控件根节点应用的css属性 - *
    
    -     *  var cfg = {elStyle : {width:'100px', height:'200px'}};
    -     *  
    - */ - /** - * 控件根节点应用的css属性,以键值对形式 - * @type {Object} - *
    
    -     *	 control.set('elStyle',	{
    -     *		width:'100px',
    -     *		height:'200px'
    -     *   });
    -     *  
    - */ - elStyle: { - view: 1 - }, - /** - * @cfg {Object} elAttrs - * 控件根节点应用的属性,以键值对形式: - *
    
    -     *  new Control({
    -     *  elAttrs :{title : 'tips'}
    -     *  });
    -     * 
    - */ - /** - * @type {Object} - * 控件根节点应用的属性,以键值对形式: - * { title : 'tips'} - * @ignore - */ - elAttrs: { - view: 1 - }, - /** - * 将控件插入到指定元素前 - *
    
    -     *  new Control({
    -     *    elBefore : '#t1'
    -     *  });
    -     * 
    - * @cfg {jQuery} elBefore - */ - /** - * 将控件插入到指定元素前 - * @type {jQuery} - * @ignore - */ - elBefore: { - // better named to renderBefore, too late ! - view: 1 - }, - - /** - * 只读属性,根节点DOM - * @type {jQuery} - */ - el: { - view: 1 - }, - /** - * 控件支持的事件 - * @type {Object} - * @protected - */ - events: { - value: { - /** - * 点击事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'click': true, - /** - * 双击事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'dblclick': true, - /** - * 鼠标移入控件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseenter': true, - /** - * 鼠标移出控件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseleave': true, - /** - * 键盘按下按键事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'keydown': true, - /** - * 键盘按键抬起控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'keyup': true, - /** - * 控件获取焦点事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'focus': false, - /** - * 控件丢失焦点事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'blur': false, - /** - * 鼠标按下控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mousedown': true, - /** - * 鼠标抬起控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseup': true, - /** - * 控件显示 - * @event - */ - 'show': false, - /** - * 控件隐藏 - * @event - */ - 'hide': false - } - }, - /** - * 指定控件的容器 - *
    
    -     *  new Control({
    -     *  render : '#t1',
    -     *  elCls : 'test',
    -     *  content : '123'  //<div id="t1"><div class="test bui-xclass"><span>123</span></div></div>
    -     *  });
    -     * 
    - * @cfg {jQuery} render - */ - /** - * 指定控件的容器 - * @type {jQuery} - * @ignore - */ - render: { - view: 1 - }, - /** - * ARIA 标准中的role,不要更改此属性 - * @type {String} - * @protected - */ - role: { - view: 1 - }, - /** - * 状态相关的样式,默认情况下会使用 前缀名 + xclass + '-' + 状态名 - *
      - *
    1. hover
    2. - *
    3. focused
    4. - *
    5. active
    6. - *
    7. disabled
    8. - *
    - * @type {Object} - */ - statusCls: { - view: true, - value: { - - } - }, - /** - * 控件的可视方式,值为: - * - 'display' - * - 'visibility' - *
    
    -     *   new Control({
    -     *   visibleMode: 'visibility'
    -     *   });
    -     *  
    - * @cfg {String} [visibleMode = 'display'] - */ - /** - * 控件的可视方式,使用 css - * - 'display' 或者 - * - 'visibility' - *
    
    -     *  control.set('visibleMode','display')
    -     * 
    - * @type {String} - */ - visibleMode: { - view: 1, - value: 'display' - }, - /** - * 控件是否可见 - *
    
    -     *  new Control({
    -     *  visible : false   //隐藏
    -     *  });
    -     * 
    - * @cfg {Boolean} [visible = true] - */ - /** - * 控件是否可见 - *
    
    -     *  control.set('visible',true); //control.show();
    -     *  control.set('visible',false); //control.hide();
    -     * 
    - * @type {Boolean} - * @default true - */ - visible: { - value: true, - view: 1 - }, - /** - * 是否允许处理鼠标事件 - * @default true. - * @type {Boolean} - * @protected - */ - handleMouseEvents: { - value: true - }, - - /** - * 控件是否可以获取焦点 - * @default true. - * @protected - * @type {Boolean} - */ - focusable: { - value: false, - view: 1 - }, - /** - * 一旦使用loader的默认配置 - * @protected - * @type {Object} - */ - defaultLoaderCfg: { - value: { - property: 'content', - autoLoad: true - } - }, - /** - * 控件内容的加载器 - * @type {BUI.Component.Loader} - */ - loader: { - getter: function(v) { - var _self = this, - defaultCfg; - if (v && !v.isLoader) { - v.target = _self; - defaultCfg = _self.get('defaultLoaderCfg') - v = new Loader(BUI.merge(defaultCfg, v)); - _self.setInternal('loader', v); - } - return v; - } - }, - /** - * 1. Whether allow select this component's text.
    - * 2. Whether not to lose last component's focus if click current one (set false). - * - * Defaults to: false. - * @type {Boolean} - * @property allowTextSelection - * @protected - */ - /** - * @ignore - */ - allowTextSelection: { - // 和 focusable 分离 - // grid 需求:容器允许选择里面内容 - value: true - }, - - /** - * 控件是否可以激活 - * @default true. - * @type {Boolean} - * @protected - */ - activeable: { - value: true - }, - - /** - * 控件是否获取焦点 - * @type {Boolean} - * @readOnly - */ - focused: { - view: 1 - }, - - /** - * 控件是否处于激活状态,按钮按下还未抬起 - * @type {Boolean} - * @default false - * @protected - */ - active: { - view: 1 - }, - /** - * 控件是否高亮 - * @cfg {Boolean} highlighted - * @ignore - */ - /** - * 控件是否高亮 - * @type {Boolean} - * @protected - */ - highlighted: { - view: 1 - }, - /** - * 子控件集合 - * @cfg {BUI.Component.Controller[]} children - */ - /** - * 子控件集合 - * @type {BUI.Component.Controller[]} - */ - children: { - sync: false, - shared: false, - value: [] /**/ - }, - /** - * 控件的CSS前缀 - * @cfg {String} [prefixCls = BUI.prefix] - */ - /** - * 控件的CSS前缀 - * @type {String} - * @default BUI.prefix - */ - prefixCls: { - value: BUI.prefix, // box srcNode need - view: 1 - }, - - /** - * 父控件 - * @cfg {BUI.Component.Controller} parent - * @ignore - */ - /** - * 父控件 - * @type {BUI.Component.Controller} - */ - parent: { - setter: function(p) { - // 事件冒泡源 - this.addTarget(p); - } - }, - - /** - * 禁用控件 - * @cfg {Boolean} [disabled = false] - */ - /** - * 禁用控件 - *
    
    -     *  control.set('disabled',true); //==  control.disable();
    -     *  control.set('disabled',false); //==  control.enable();
    -     * 
    - * @type {Boolean} - * @default false - */ - disabled: { - view: 1, - value: false - }, - /** - * 渲染控件的View类. - * @protected - * @cfg {BUI.Component.View} [xview = BUI.Component.View] - */ - /** - * 渲染控件的View类. - * @protected - * @type {BUI.Component.View} - */ - xview: { - value: View - } - }, - PARSER: { - visible: function(el) { - var _self = this, - display = el.css('display'), - - visibility = el.css('visibility'), - visibleMode = _self.get('visibleMode'); - if ((display == 'none' && visibleMode == 'display') || (visibility == 'hidden' && visibleMode == 'visibility')) { - return false; - } - return true; - }, - disabled: function(el){ - var _self = this, - cls = _self.get('prefixCls') + _self.get('xclass') + '-disabled'; - return el.hasClass(cls); - } - } -}, { - xclass: 'controller', - priority: 0 -}); -module.exports = Controller; - -}); -define("bui-common/1.1.2/src/component/loader-debug", ["jquery"], function(require, exports, module){ -/** - * @fileOverview 加载控件内容 - * @ignore - */ - -'use strict'; -var $ = require('jquery'), - BUI = require("bui-common/1.1.2/src/util-debug"), - Base = require("bui-common/1.1.2/src/base-debug"), - /** - * @class BUI.Component.Loader - * @extends BUI.Base - * ** 控件的默认Loader属性是:** - *
    
    -   *
    -   *   defaultLoader : {
    -   *     value : {
    -   *       property : 'content',
    -   *       autoLoad : true
    -   *     }
    -   *   }
    -   * 
    - * ** 一般的控件默认读取html,作为控件的content值 ** - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * - * ** 可以修改Loader的默认属性,加载children ** - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/children.json',
    -   *       property : 'children',
    -   *       dataType : 'json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * 加载控件内容的类,一般不进行实例化 - */ - Loader = function(config) { - Loader.superclass.constructor.call(this, config); - this._init(); - }; - -Loader.ATTRS = { - - /** - * 加载内容的地址 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} url - */ - url: { - - }, - /** - * 对应的控件,加载完成后设置属性到对应的控件 - * @readOnly - * @type {BUI.Component.Controller} - */ - target: { - - }, - /** - * @private - * 是否load 过 - */ - hasLoad: { - value: false - }, - /** - * 是否自动加载数据 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       autoLoad : false
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Boolean} [autoLoad = true] - */ - autoLoad: { - - }, - /** - * 延迟加载 - * - * - event : 触发加载的事件 - * - repeat :是否重复加载 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       lazyLoad : {
    -   *         event : 'show',
    -   *         repeat : true
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Object} [lazyLoad = null] - */ - lazyLoad: { - - }, - /** - * 加载返回的数据作为控件的那个属性 - *
    
    -   *   var control = new BUI.List.SimpleList({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       dataType : 'json',
    -   *       property : 'items'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} property - */ - property: { - - }, - /** - * 格式化返回的数据 - * @cfg {Function} renderer - */ - renderer: { - value: function(value) { - return value; - } - }, - /** - * 加载数据时是否显示屏蔽层和加载提示 {@link BUI.Mask.LoadMask} - * - * - loadMask : true时使用loadMask 默认的配置信息 - * - loadMask : {msg : '正在加载,请稍后。。'} LoadMask的配置信息 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       loadMask : true
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Boolean|Object} [loadMask = false] - */ - loadMask: { - value: false - }, - /** - * ajax 请求返回数据的类型 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       dataType : 'json',
    -   *       property : 'items'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} [dataType = 'text'] - */ - dataType: { - value: 'text' - }, - /** - * Ajax请求的配置项,会覆盖 url,dataType数据 - * @cfg {Object} ajaxOptions - */ - ajaxOptions: { - //shared : false, - value: { - type: 'get', - cache: false - } - }, - /** - * 初始化的请求参数 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       params : {
    -   *         a : 'a',
    -   *         b : 'b'
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Object} params - * @default null - */ - params: { - - }, - /** - * 附加参数,每次请求都带的参数 - * @cfg {Object} appendParams - */ - appendParams: { - - }, - /** - * 最后一次请求的参数 - * @readOnly - * @private - * @type {Object} - */ - lastParams: { - shared: false, - value: {} - }, - /** - * 加载数据,并添加属性到控件后的回调函数 - * - data : 加载的数据 - * - params : 加载的参数 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       callback : function(text){
    -   *         var target = this.get('target');//control
    -   *         //TO DO
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Function} callback - */ - callback: { - - }, - /** - * 失败的回调函数 - * - response : 返回的错误对象 - * - params : 加载的参数 - * @cfg {Function} failure - */ - failure: { - - } - -}; - -BUI.extend(Loader, Base); - -BUI.augment(Loader, { - /** - * @protected - * 是否是Loader - * @type {Boolean} - */ - isLoader: true, - //初始化 - _init: function() { - var _self = this, - autoLoad = _self.get('autoLoad'), - params = _self.get('params'); - - _self._initMask(); - if (autoLoad) { - _self.load(params); - } else { - _self._initParams(); - _self._initLazyLoad(); - } - }, - //初始化延迟加载 - _initLazyLoad: function() { - var _self = this, - target = _self.get('target'), - lazyLoad = _self.get('lazyLoad'); - - if (target && lazyLoad && lazyLoad.event) { - target.on(lazyLoad.event, function() { - if (!_self.get('hasLoad') || lazyLoad.repeat) { - _self.load(); - } - }); - } - }, - /** - * 初始化mask - * @private - */ - _initMask: function() { - var _self = this, - target = _self.get('target'), - loadMask = _self.get('loadMask'); - if (target && loadMask) { - require.async('bui-mask/1.1.0/index', function(Mask) { - var cfg = $.isPlainObject(loadMask) ? loadMask : {}; - loadMask = new Mask.LoadMask(BUI.mix({ - el: target.get('el') - }, cfg)); - _self.set('loadMask', loadMask); - }); - } - }, - //初始化查询参数 - _initParams: function() { - var _self = this, - lastParams = _self.get('lastParams'), - params = _self.get('params'); - - //初始化 参数 - BUI.mix(lastParams, params); - }, - /** - * 加载内容 - * @param {Object} params 加载数据的参数 - */ - load: function(params) { - var _self = this, - url = _self.get('url'), - ajaxOptions = _self.get('ajaxOptions'), - lastParams = _self.get('lastParams'), - appendParams = _self.get('appendParams'); - - //BUI.mix(true,lastParams,appendParams,params); - params = params || lastParams; - params = BUI.merge(appendParams, params); //BUI.cloneObject(lastParams); - _self.set('lastParams', params); - //未提供加载地址,阻止加载 - if (!url) { - return; - } - - _self.onBeforeLoad(); - _self.set('hasLoad', true); - $.ajax(BUI.mix({ - dataType: _self.get('dataType'), - data: params, - url: url, - success: function(data) { - _self.onload(data, params); - }, - error: function(jqXHR, textStatus, errorThrown) { - _self.onException({ - jqXHR: jqXHR, - textStatus: textStatus, - errorThrown: errorThrown - }, params); - } - }, ajaxOptions)); - }, - /** - * @private - * 加载前 - */ - onBeforeLoad: function() { - var _self = this, - loadMask = _self.get('loadMask'); - if (loadMask && loadMask.show) { - loadMask.show(); - } - }, - /** - * @private - * 加载完毕 - */ - onload: function(data, params) { - var _self = this, - loadMask = _self.get('loadMask'), - property = _self.get('property'), - callback = _self.get('callback'), - renderer = _self.get('renderer'), - target = _self.get('target'); - - if (BUI.isString(data)) { - target.set(property, ''); //防止2次返回的数据一样 - } - target.set(property, renderer.call(_self, data)); - - /**/ - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - if (callback) { - callback.call(this, data, params); - } - }, - /** - * @private - * 加载出错 - */ - onException: function(response, params) { - var _self = this, - failure = _self.get('failure'); - if (failure) { - failure.call(this, response, params); - } - } - -}); -module.exports = Loader; - -}); diff --git a/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common.js b/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common.js deleted file mode 100644 index b7099ff..0000000 --- a/spm_modules/bui-common/1.1.2/dist/bui-common/1.1.2/common.js +++ /dev/null @@ -1,3 +0,0 @@ -define("bui-common/1.1.2/common",["jquery"],function(e,t,n){var i=e("bui-common/1.1.2/src/util");i.mix(i,{UA:e("bui-common/1.1.2/src/ua"),JSON:e("bui-common/1.1.2/src/json"),Date:e("bui-common/1.1.2/src/date"),Array:e("bui-common/1.1.2/src/array"),KeyCode:e("bui-common/1.1.2/src/keycode"),Observable:e("bui-common/1.1.2/src/observable"),Base:e("bui-common/1.1.2/src/base"),Component:e("bui-common/1.1.2/src/component/component")}),n.exports=i}),define("bui-common/1.1.2/src/util",["jquery"],function(e,t,n){function i(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=e[n]||{},r(e[n],t[n]))}function r(e,t){for(var n in t)t.hasOwnProperty(n)&&("value"==n?BUI.isObject(t[n])?(e[n]=e[n]||{},BUI.mix(e[n],t[n])):BUI.isArray(t[n])?(e[n]=e[n]||[],e[n]=e[n].concat(t[n])):e[n]=t[n]:e[n]=t[n])}var o=e("jquery");!function(e){e.fn&&(e.fn.on=e.fn.on||e.fn.bind,e.fn.off=e.fn.off||e.fn.unbind)}(o);var a=window,s=document,u=Object.prototype,c=u.toString,l="body",d="documentElement",f="scroll",h=f+"Width",g=f+"Height",m="ATTRS",v="PARSER",p="guid";window.BUI=window.BUI||{},o.extend(BUI,{version:"1.1.0",isFunction:function(e){return"function"==typeof e},isArray:"isArray"in Array?Array.isArray:function(e){return"[object Array]"===c.call(e)},isDate:function(e){return"[object Date]"===c.call(e)},isObject:"[object Object]"===c.call(null)?function(e){return null!==e&&void 0!==e&&"[object Object]"===c.call(e)&&void 0===e.ownerDocument}:function(e){return"[object Object]"===c.call(e)},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},augment:function(e){if(!BUI.isFunction(e))return e;for(var t=1;t=0;r--)t=n[r].split("="),i[t[0]]=decodeURIComponent(t[1]);return i},ucfirst:function(e){return e+="",e.charAt(0).toUpperCase()+e.substring(1)},isInView:function(e){var t=e.left,n=e.top,i=BUI.viewportWidth(),r=BUI.viewportHeight(),o=BUI.scrollTop(),a=BUI.scrollLeft();return a>t||t>a+i?!1:o>n||n>o+r?!1:!0},isInVerticalView:function(e){var t=BUI.viewportHeight(),n=BUI.scrollTop();return n>e||e>n+t?!1:!0},isInHorizontalView:function(e){var t=BUI.viewportWidth(),n=BUI.scrollLeft();return n>e||e>n+t?!1:!0},viewportWidth:function(){return o(window).width()},viewportHeight:function(){return o(window).height()},scrollLeft:function(){return o(window).scrollLeft()},scrollTop:function(){return o(window).scrollTop()},docWidth:function(){return Math.max(this.viewportWidth(),s[d][h],s[l][h])},docHeight:function(){return Math.max(this.viewportHeight(),s[d][g],s[l][g])},each:function(e,t){e&&o.each(e,function(e,n){return t(n,e)})},wrapBehavior:function(e,t){return e["__bui_wrap_"+t]=function(n){e.get("disabled")||e[t](n)}},getWrapBehavior:function(e,t){return e["__bui_wrap_"+t]},getControl:function(e){return BUI.Component.Manager.getComponent(e)}});var y={serializeToObject:function(e){var t=o(e).serializeArray(),n={};return BUI.each(t,function(e){var t=e.name;n[t]?(BUI.isArray(n[t])||(n[t]=[n[t]]),n[t].push(e.value)):n[t]=e.value}),n},setFields:function(e,t){for(var n in t)t.hasOwnProperty(n)&&BUI.FormHelper.setField(e,n,t[n])},clear:function(e){var t=o.makeArray(e.elements);BUI.each(t,function(e){"checkbox"===e.type||"radio"===e.type?o(e).attr("checked",!1):o(e).val(""),o(e).change()})},setField:function(e,t,n){var i=e.elements[t];i&&i.type?formHelper._setFieldValue(i,n):(BUI.isArray(i)||i&&i.length)&&BUI.each(i,function(e){formHelper._setFieldValue(e,n)})},_setFieldValue:function(e,t){"checkbox"===e.type?e.value==""+t||BUI.isArray(t)&&-1!==BUI.Array.indexOf(e.value,t)?o(e).attr("checked",!0):o(e).attr("checked",!1):"radio"===e.type?e.value==""+t?o(e).attr("checked",!0):o(e).attr("checked",!1):o(e).val(t)},getField:function(e,t){return BUI.FormHelper.serializeToObject(e)[t]}};BUI.FormHelper=y,n.exports=BUI}),define("bui-common/1.1.2/src/ua",["jquery"],function(e,t,n){function i(e){var t=0;return parseFloat(e.replace(/\./g,function(){return 0===t++?".":""}))}function r(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[],n={browser:t[1]||"",version:t[2]||"0"},i={};return n.browser&&(i[n.browser]=!0,i.version=n.version),i.chrome?i.webkit=!0:i.webkit&&(i.safari=!0),i}var o=e("jquery"),a=o.UA||function(){var e=o.browser||r(navigator.userAgent),t=i(e.version),n={ie:e.msie&&t,webkit:e.webkit&&t,opera:e.opera&&t,mozilla:e.mozilla&&t};return n}();n.exports=a}),define("bui-common/1.1.2/src/json",["jquery"],function(e,t,n){function i(e){return 10>e?"0"+e:e}function r(e){return g.lastIndex=0,g.test(e)?'"'+e.replace(g,function(e){var t=m[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function o(e,t){var n,i,a,s,u,c=d,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof h&&(l=h.call(t,e,l)),typeof l){case"string":return r(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(d+=f,u=[],"[object Array]"===Object.prototype.toString.apply(l)){for(s=l.length,n=0;s>n;n+=1)u[n]=o(n,l)||"null";return a=0===u.length?"[]":d?"[\n"+d+u.join(",\n"+d)+"\n"+c+"]":"["+u.join(",")+"]",d=c,a}if(h&&"object"==typeof h)for(s=h.length,n=0;s>n;n+=1)i=h[n],"string"==typeof i&&(a=o(i,l),a&&u.push(r(i)+(d?": ":":")+a));else for(i in l)Object.hasOwnProperty.call(l,i)&&(a=o(i,l),a&&u.push(r(i)+(d?": ":":")+a));return a=0===u.length?"{}":d?"{\n"+d+u.join(",\n"+d)+"\n"+c+"}":"{"+u.join(",")+"}",d=c,a}}function a(e){try{return new Function("return "+e+";")()}catch(t){throw"Json parse error!"}}var s=e("jquery"),u=e("bui-common/1.1.2/src/ua"),c=window,l=c.JSON;(!l||u.ie<9)&&(l=c.JSON={}),"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+i(this.getUTCMonth()+1)+"-"+i(this.getUTCDate())+"T"+i(this.getUTCHours())+":"+i(this.getUTCMinutes())+":"+i(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var d,f,h,g=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,m={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};"function"!=typeof l.stringify&&(l.stringify=function(e,t,n){var i;if(d="",f="","number"==typeof n)for(i=0;n>i;i+=1)f+=" ";else"string"==typeof n&&(f=n);if(h=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return o("",{"":e})});var l={parse:s.parseJSON,looseParse:a,stringify:l.stringify};n.exports=l}),define("bui-common/1.1.2/src/date",[],function(e,t,n){function i(e,t){if(e instanceof Date)return e;if("undefined"==typeof t||null==t||""==t){for(var n=new Array("y-m-d","yyyy-mm-dd","yyyy-mm-dd HH:MM:ss","H:M:s"),r=0;r=n;r--){var o=e.substring(t,t+r);if(o.length70?1900+(h-0):2e3+(h-0))}else if("mm"==d||"m"==d){if(g=this.getInt(e,u,d.length,2),null==g||1>g||g>12)return null;u+=g.length}else if("dd"==d||"d"==d){if(m=this.getInt(e,u,d.length,2),null==m||1>m||m>31)return null;u+=m.length}else if("hh"==d||"h"==d){if(v=this.getInt(e,u,d.length,2),null==v||1>v||v>12)return null;u+=v.length}else if("HH"==d||"H"==d){if(v=this.getInt(e,u,d.length,2),null==v||0>v||v>23)return null;u+=v.length}else if("MM"==d||"M"==d){if(p=this.getInt(e,u,d.length,2),null==p||0>p||p>59)return null;u+=p.length}else if("ss"==d||"s"==d){if(y=this.getInt(e,u,d.length,2),null==y||0>y||y>59)return null;u+=y.length}else{if(e.substring(u,u+d.length)!=d)return null;u+=d.length}}if(u!=e.length)return null;if(2==g)if(h%4==0&&h%100!=0||h%400==0){if(m>29)return null}else if(m>28)return null;return(4==g||6==g||9==g||11==g)&&m>30?null:new Date(h,g-1,m,v,p,y)}function r(e,t,n){var i=new Date(n);switch(isNaN(i)&&(i=new Date),t=parseInt(t,10),e){case"s":i=new Date(i.getTime()+1e3*t);break;case"n":i=new Date(i.getTime()+6e4*t);break;case"h":i=new Date(i.getTime()+36e5*t);break;case"d":i=new Date(i.getTime()+864e5*t);break;case"w":i=new Date(i.getTime()+6048e5*t);break;case"m":i=new Date(i.getFullYear(),i.getMonth()+t,i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds());break;case"y":i=new Date(i.getFullYear()+t,i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds())}return i}var o=/^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/,a=function(){var e=/w{1}|d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,i=function(e,t){for(e=String(e),t=t||2;e.length99?Math.round(p/10):p,void 0),t:12>g?"a":"p",tt:12>g?"am":"pm",T:12>g?"A":"P",TT:12>g?"AM":"PM",Z:u?"UTC":(String(a).match(t)||[""]).pop().replace(n,""),o:(y>0?"-":"+")+i(100*Math.floor(Math.abs(y)/60)+Math.abs(y)%60,4),S:["th","st","nd","rd"][l%10>3?0:(l%100-l%10!==10)*l%10]};return s.replace(e,function(e){return e in b?b[e]:e.slice(1,e.length-1)})}}(),s={add:function(e,t,n){return r(e,t,n)},addHour:function(e,t){return r("h",e,t)},addMinute:function(e,t){return r("n",e,t)},addSecond:function(e,t){return r("s",e,t)},addDay:function(e,t){return r("d",e,t)},addWeek:function(e,t){return r("w",e,t)},addMonths:function(e,t){return r("m",e,t)},addYear:function(e,t){return r("y",e,t)},isDateEquals:function(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()},isEquals:function(e,t){return e==t?!0:e&&t&&e.getTime&&t.getTime?e.getTime()==t.getTime():!1},isDateString:function(e){return o.test(e)},format:function(e,t,n){return a(e,t,n)},parse:function(e,t){return BUI.isString(e)&&(e=e.replace("/","-")),i(e,t)},today:function(){var e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},getDate:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}};n.exports=s}),define("bui-common/1.1.2/src/array",["jquery"],function(e,t,n){var i=e("bui-common/1.1.2/src/util"),r={peek:function(e){return e[e.length-1]},indexOf:function(e,t,n){for(var i=null==n?0:0>n?Math.max(0,t.length+n):n,r=i;r=0},each:i.each,equals:function(e,t){if(e==t)return!0;if(!e||!t)return!1;if(e.length!=t.length)return!1;for(var n=!0,i=0;in?null:e[n]},findIndex:function(e,t){var n=-1;return r.each(e,function(e,i){return t(e,i)?(n=i,!1):void 0}),n},isEmpty:function(e){return 0==e.length},add:function(e,t){e.push(t)},addAt:function(e,t,n){r.splice(e,n,0,t)},empty:function(e){if(!(e instanceof Array))for(var t=e.length-1;t>=0;t--)delete e[t];e.length=0},remove:function(e,t){var n,i=r.indexOf(t,e);return(n=i>=0)&&r.removeAt(e,i),n},removeAt:function(e,t){return 1==r.splice(e,t,1).length},slice:function(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)},splice:function(e){return Array.prototype.splice.apply(e,r.slice(arguments,1))}};n.exports=r}),define("bui-common/1.1.2/src/keycode",[],function(e,t,n){var i={BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,RETURN:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123};n.exports=i}),define("bui-common/1.1.2/src/observable",["jquery"],function(e,t,n){function i(){return new s}var r=e("jquery"),o=e("bui-common/1.1.2/src/util"),a=e("bui-common/1.1.2/src/array"),s=function(){this._init()};o.augment(s,{_functions:null,_init:function(){var e=this;e._functions=[]},add:function(e){this._functions.push(e)},remove:function(e){var t=this._functions;index=a.indexOf(e,t),index>=0&&t.splice(index,1)},empty:function(){var e=this._functions.length;this._functions.splice(0,e)},pause:function(){this._paused=!0},resume:function(){this._paused=!1},fireWith:function(e,t){var n,i=this;if(!i._paused)return o.each(i._functions,function(i){return n=i.apply(e,t),n===!1?!1:void 0}),n}});var u=function(e){this._events=[],this._eventMap={},this._bubblesEvents=[],this._initEvents(e)};o.augment(u,{_events:[],_eventMap:{},_bubblesEvents:[],_bubbleTarget:null,_getCallbacks:function(e){var t=this,n=t._eventMap;return n[e]},_initEvents:function(e){var t=this,n=null;if(e&&(n=e.listeners||{},e.handler&&(n.click=e.handler),n))for(var i in n)n.hasOwnProperty(i)&&t.on(i,n[i])},_isBubbles:function(e){return a.indexOf(e,this._bubblesEvents)>=0},addTarget:function(e){this._bubbleTarget=e},addEvents:function(e){function t(e){-1===a.indexOf(e,r)&&(s[e]=i(),r.push(e))}var n=this,r=n._events,s=n._eventMap;o.isArray(e)?o.each(e,function(e){t(e)}):t(e)},clearListeners:function(){var e=this,t=e._eventMap;for(var n in t)t.hasOwnProperty(n)&&t[n].empty()},fire:function(e,t){var n,i=this,o=i._getCallbacks(e),a=r.makeArray(arguments);if(t||(t={},a.push(t)),t.target||(t.target=i),o&&(n=o.fireWith(i,Array.prototype.slice.call(a,1))),i._isBubbles(e)){var s=i._bubbleTarget;s&&s.fire&&s.fire(e,t)}return n},pauseEvent:function(e){var t=this,n=t._getCallbacks(e);n&&n.pause()},resumeEvent:function(e){var t=this,n=t._getCallbacks(e);n&&n.resume()},on:function(e,t){var n=e.split(" "),i=this,r=null;return n.length>1?o.each(n,function(e){i.on(e,t)}):(r=i._getCallbacks(e),r?r.add(t):(i.addEvents(e),i.on(e,t))),i},off:function(e,t){if(!e&&!t)return this.clearListeners(),this;var n=this,i=n._getCallbacks(e);return i&&(t?i.remove(t):i.empty()),n},publish:function(e,t){var n=this,i=n._bubblesEvents;if(t.bubbles)-1===o.Array.indexOf(e,i)&&i.push(e);else{var r=o.Array.indexOf(e,i);-1!==r&&i.splice(r,1)}}}),n.exports=u}),define("bui-common/1.1.2/src/base",["jquery"],function(e,t,n){function i(e,t,n){var i=e[t]||{};return n&&(e[t]=i),i}function r(e,t){return BUI.isString(t)?e[t]:t}function o(e,t,n,i,r){var o=n;return e.fire(t+BUI.ucfirst(n)+"Change",{attrName:o,prevVal:i,newVal:r})}function a(e,t,n,i){i=i||{};var r,a;return a=e.get(t),u.isPlainObject(n)||BUI.isArray(n)||a!==n?i.silent||!1!==o(e,"before",t,a,n)?(r=e._set(t,n,i),r===!1?r:(i.silent||(n=e.__attrVals[t],o(e,"after",t,a,n)),e)):!1:void 0}function s(e){if(!e._attrs&&e!=d){var t=e.superclass.constructor;t&&!t._attrs&&s(t),e._attrs={},BUI.mixAttrs(e._attrs,t._attrs),BUI.mixAttrs(e._attrs,e.ATTRS)}}var u=e("jquery"),c={},l=e("bui-common/1.1.2/src/observable"),d=function(e){var t=this,n=t.constructor,i=[];for(this.__attrs={},this.__attrVals={},l.apply(this,arguments);n;)i.push(n),n.extensions&&(BUI.mixin(n,n.extensions),delete n.extensions),n=n.superclass?n.superclass.constructor:null;var r=t.constructor;s(r),t._initStaticAttrs(r._attrs),t._initAttrs(e)};d.INVALID=c,BUI.extend(d,l),BUI.augment(d,{_initStaticAttrs:function(e){var t,n=this;t=n.__attrs={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];r.shared===!1||r.valueFn?(t[i]={},BUI.mixAttr(t[i],e[i])):t[i]=e[i]}},addAttr:function(e,t){var n=this,i=n.__attrs,r=i[e];r||(r=i[e]={});for(var o in t)t.hasOwnProperty(o)&&("value"==o?BUI.isObject(t[o])?(r[o]=r[o]||{},BUI.mix(r[o],t[o])):BUI.isArray(t[o])?(r[o]=r[o]||[],BUI.mix(r[o],t[o])):r[o]=t[o]:r[o]=t[o]);return n},addAttrs:function(e,t,n){var i=this;return e?("boolean"==typeof t&&(n=t,t=null),BUI.each(e,function(e,t){i.addAttr(t,e,n)}),t&&i.set(t),i):i},hasAttr:function(e){return e&&this.__attrs.hasOwnProperty(e)},getAttrs:function(){return this.__attrs},getAttrVals:function(){return this.__attrVals},get:function(e){var t,n,o,a=this,s=a.__attrVals;return t=i(a.__attrs,e),n=t.getter,o=e in s?s[e]:a._getDefAttrVal(e),n&&(n=r(a,n))&&(o=n.call(a,o,e)),o},clearAttrVals:function(){this.__attrVals={}},removeAttr:function(e){var t=this;return t.hasAttr(e)&&(delete t.__attrs[e],delete t.__attrVals[e]),t},set:function(e,t,n){var i=this;if(u.isPlainObject(e)){n=t;var r=Object(e);for(e in r)r.hasOwnProperty(e)&&a(i,e,r[e],n);return i}return a(i,e,t,n)},setInternal:function(e,t,n){return this._set(e,t,n)},_getDefAttrVal:function(e){var t,n=this,o=n.__attrs,a=i(o,e),s=a.valueFn;return s&&(s=r(n,s))&&(t=s.call(n),void 0!==t&&(a.value=t),delete a.valueFn,o[e]=a),a.value},_set:function(e,t){var n,o=this,a=i(o.__attrs,e,!0),s=a.setter;return s&&(s=r(o,s))&&(n=s.call(o,t,e)),n===c?!1:(void 0!==n&&(t=n),o.__attrVals[e]=t,o)},_initAttrs:function(e){var t=this;if(e)for(var n in e)e.hasOwnProperty(n)&&t._set(n,e[n])}}),n.exports=d}),define("bui-common/1.1.2/src/component/component",["jquery"],function(e,t,n){function i(e,t){var n,i;return e&&(i=e.xclass)&&(t&&!e.prefixCls&&(e.prefixCls=t.get("prefixCls")),n=r.Manager.getConstructorByXClass(i),n||BUI.error("can not find class by xclass desc : "+i),e=new n(e)),e}var r={};BUI.mix(r,{Manager:e("bui-common/1.1.2/src/component/manage"),UIBase:e("bui-common/1.1.2/src/component/uibase/uibase"),View:e("bui-common/1.1.2/src/component/view"),Controller:e("bui-common/1.1.2/src/component/controller")}),r.create=i,n.exports=r}),define("bui-common/1.1.2/src/component/manage",["jquery"],function(e,t,n){function i(e){for(var t,n=e.split(/\s+/),i=-1,r=null,o=0;oi&&(i=t,r=a.constructor)}return r}function r(e){for(var t in u){var n=u[t];if(n.constructor==e)return t}return 0}function o(e,t){BUI.isFunction(t)?u[e]={constructor:t,priority:0}:(t.priority=t.priority||0,u[e]=t)}function a(e){for(var t=s.trim(e).split(/\s+/),n=0;n=0;c--)u[c]&&u[c].call(e)}function o(e){for(var t,n,i,r=e.constructor;r;){if(r.prototype.hasOwnProperty("destructor")&&r.prototype.destructor.apply(e),t=r.mixins)for(i=t.length-1;i>=0;i--)n=t[i]&&t[i].prototype.__destructor,n&&n.apply(e);r=r.superclass&&r.superclass.constructor}}function a(e){e&&BUI.each(e,function(t,n){BUI.isFunction(t)&&(e[n]=new t)})}function s(e,t,n){t&&BUI.each(t,function(t){t[n]&&t[n](e)})}function u(){}function c(e){var t,n,i=e.getAttrs();for(var r in i)if(i.hasOwnProperty(r)){var o=h+g(r);(n=e[o])&&i[r].sync!==!1&&void 0!==(t=e.get(r))&&n.call(e,t)}}function l(e){for(var t=[];e.base;)t.push(e),e=e.base;for(var n=t.length-1;n>=0;n--){var i=t[n];BUI.mix(i.prototype,i.px),BUI.mix(i,i.sx),i.base=null,i.px=null,i.sx=null}}var d=e("jquery"),f=e("bui-common/1.1.2/src/component/manage"),h="_uiSet",g=BUI.ucfirst,m=d.noop,v=e("bui-common/1.1.2/src/base"),p=function(e){var t=this;v.apply(t,arguments),t.setInternal("userConfig",e),i(t,e);var n=t.get("plugins");a(n);var r=t.get("xclass");r&&(t.__xclass=r),s(t,n,"initializer"),e&&e.autoRender&&t.render()};p.ATTRS={userConfig:{},autoRender:{value:!1},listeners:{value:{}},plugins:{},rendered:{value:!1},xclass:{valueFn:function(){return f.getXClassByConstructor(this.constructor)}}},BUI.extend(p,v),BUI.augment(p,{create:function(){var e=this;return e.get("created")||(e.fire("beforeCreateDom"),r(e,"createDom","__createDom"),e._set("created",!0),e.fire("afterCreateDom"),s(e,e.get("plugins"),"createDom")),e},render:function(){var e=this;if(!e.get("rendered")){var t=e.get("plugins");e.create(void 0),e.set("created",!0),e.fire("beforeRenderUI"),r(e,"renderUI","__renderUI"),e.fire("afterRenderUI"),s(e,t,"renderUI"),e.fire("beforeBindUI"),u(e),r(e,"bindUI","__bindUI"),e.set("binded",!0),e.fire("afterBindUI"),s(e,t,"bindUI"),e.fire("beforeSyncUI"),c(e),r(e,"syncUI","__syncUI"),e.fire("afterSyncUI"),s(e,t,"syncUI"),e._set("rendered",!0)}return e},createDom:m,renderUI:m,bindUI:m,syncUI:m,destroy:function(){var e=this;return e.destroyed?e:(e.fire("beforeDestroy"),s(e,e.get("plugins"),"destructor"),o(e),e.fire("afterDestroy"),e.off(),e.clearAttrVals(),e.destroyed=!0,e)}}),BUI.mix(p,{define:function(e,t,n,i){function r(){var e=this.constructor;e.base&&l(e),p.apply(this,arguments)}return d.isPlainObject(t)&&(i=n,n=t,t=[]),BUI.extend(r,e),r.base=e,r.px=n,r.sx=i,t.length&&(r.extensions=t),r},extend:function y(){var e,t=d.makeArray(arguments),n=t[t.length-1];if(t.unshift(this),n.xclass&&(t.pop(),t.push(n.xclass)),e=p.define.apply(p,t),n.xclass){var i=n.priority||(this.priority?this.priority+1:1);f.setConstructorByXClass(n.xclass,{constructor:e,priority:i}),e.__xclass=n.xclass,e.priority=i,e.toString=function(){return n.xclass}}return e.extend=y,e}}),n.exports=p}),define("bui-common/1.1.2/src/component/uibase/align",["jquery"],function(e,t,n){function i(e){var t,n=e.ownerDocument,i=n.body,r=m(e).css("position"),o="fixed"==r||"absolute"==r;if(!o)return"html"==e.nodeName.toLowerCase()?null:e.parentNode;for(t=e.parentNode;t&&t!=i;t=t.parentNode)if(r=m(t).css("position"),"static"!=r)return t;return null}function r(e){var t,n,r,o,a={left:0,right:1/0,top:0,bottom:1/0},s=e.ownerDocument,u=s.body,c=s.documentElement;for(t=e;t=i(t);)if((!v.ie||0!=t.clientWidth)&&t!=u&&t!=c&&"visible"!=m(t).css("overflow")){var l=m(t).offset();l.left+=t.clientLeft,l.top+=t.clientTop,a.top=Math.max(a.top,l.top),a.right=Math.min(a.right,l.left+t.clientWidth),a.bottom=Math.min(a.bottom,l.top+t.clientHeight),a.left=Math.max(a.left,l.left)}return n=m(y).scrollLeft(),r=m(y).scrollTop(),a.left=Math.max(a.left,n),a.top=Math.max(a.top,r),o={width:BUI.viewportWidth(),height:BUI.viewportHeight()},a.right=Math.min(a.right,n+o.width),a.bottom=Math.min(a.bottom,r+o.height),a.top>=0&&a.left>=0&&a.bottom>a.top&&a.right>a.left?a:null}function o(e,t,n,i){var r,o,a,s;return r={left:e.left,top:e.top},a=h(t,n[0]),s=h(e,n[1]),o=[s.left-a.left,s.top-a.top],{left:r.left-o[0]+ +i[0],top:r.top-o[1]+ +i[1]}}function a(e,t,n){return e.leftn.right}function s(e,t,n){return e.topn.bottom}function u(e,t,n,i){var r=BUI.cloneObject(e),o={width:t.width,height:t.height};return i.adjustX&&r.left=n.left&&r.left+o.width>n.right&&(o.width-=r.left+o.width-n.right),i.adjustX&&r.left+o.width>n.right&&(r.left=Math.max(n.right-o.width,n.left)),i.adjustY&&r.top=n.top&&r.top+o.height>n.bottom&&(o.height-=r.top+o.height-n.bottom),i.adjustY&&r.top+o.height>n.bottom&&(r.top=Math.max(n.bottom-o.height,n.top)),BUI.mix(r,o)}function c(e,t,n){var i=[];return m.each(e,function(e,r){i.push(r.replace(t,function(e){return n[e]}))}),i}function l(e,t){return e[t]=-e[t],e}function d(){}function f(e){var t,n,i;return e.length&&!m.isWindow(e[0])?(t=e.offset(),n=e.outerWidth(),i=e.outerHeight()):(t={left:BUI.scrollLeft(),top:BUI.scrollTop()},n=BUI.viewportWidth(),i=BUI.viewportHeight()),t.width=n,t.height=i,t}function h(e,t){var n,i,r=t.charAt(0),o=t.charAt(1),a=e.width,s=e.height;return n=e.left,i=e.top,"c"===r?i+=s/2:"b"===r&&(i+=s),"c"===o?n+=a/2:"r"===o&&(n+=a),{left:n,top:i}}function g(e){var t=e.attr("class"),n=new RegExp("s?"+p+"[a-z]{2}-[a-z]{2}","ig"),i=n.exec(t);i&&e.removeClass(i.join(" "))}var m=e("jquery"),v=e("bui-common/1.1.2/src/ua"),p="x-align-",y=window;d.__getOffsetParent=i,d.__getVisibleRectForElement=r,d.ATTRS={align:{shared:!1,value:{}}},d.prototype={_uiSetAlign:function(e){var t,n,i="";e&&e.points&&(this.align(e.node,e.points,e.offset,e.overflow),this.set("cachePosition",null),t=this.get("el"),g(t),n=e.points.join("-"),i=p+n,t.addClass(i))},__bindUI:function(){var e=this,t=BUI.wrapBehavior(e,"handleWindowResize");e.on("show",function(){m(window).on("resize",t)}),e.on("hide",function(){m(window).off("resize",t)})},handleWindowResize:function(){var e=this,t=e.get("align");e.set("align",t)},align:function(e,t,n,i){e=m(e||y),n=n&&[].concat(n)||[0,0],i=i||{};var d=this,h=d.get("el"),g=0,v=r(h[0]),p=f(h),b=f(e),I=o(p,b,t,n),w=BUI.merge(p,I);if(v&&(i.adjustX||i.adjustY)){a(I,p,v)&&(g=1,t=c(t,/[lr]/gi,{l:"r",r:"l"}),n=l(n,0)),s(I,p,v)&&(g=1,t=c(t,/[tb]/gi,{t:"b",b:"t"}),n=l(n,1)),g&&(I=o(p,b,t,n),BUI.mix(w,I));var C={};C.adjustX=i.adjustX&&a(I,p,v),C.adjustY=i.adjustY&&s(I,p,v),(C.adjustX||C.adjustY)&&(w=u(I,p,v,C))}return w.left!=p.left&&(d.setInternal("x",null),d.get("view").setInternal("x",null),d.set("x",w.left)),w.top!=p.top&&(d.setInternal("y",null),d.get("view").setInternal("y",null),d.set("y",w.top)),w.width!=p.width&&h.width(h.width()+w.width-p.width),w.height!=p.height&&h.height(h.height()+w.height-p.height),d},center:function(e){var t=this;return t.set("align",{node:e,points:["cc","cc"],offset:[0,0]}),t}},n.exports=d}),define("bui-common/1.1.2/src/component/uibase/autoshow",["jquery"],function(e,t,n){function i(){}var r=e("jquery"); -i.ATTRS={trigger:{},delegateTigger:{getter:function(){this.get("delegateTrigger")},setter:function(e){this.set("delegateTrigger",e)}},delegateTrigger:{value:!1},autoAlign:{value:!0},autoFocused:{value:!0},triggerActiveCls:{},curTrigger:{},triggerCallback:{},triggerEvent:{value:"click"},triggerHideEvent:{},events:{value:{triggerchange:!1}}},i.prototype={__createDom:function(){this._setTrigger()},__bindUI:function(){var e=this,t=e.get("triggerActiveCls");t&&e.on("hide",function(){var n=e.get("curTrigger");n&&n.removeClass(t)})},_setTrigger:function(){function e(e){if(!n.get("disabled")){var t=n.get("curTrigger"),i=r(c?e.currentTarget:this),o=n.get("align");t&&t[0]==i[0]||(t&&t.removeClass(s),n.set("curTrigger",i),n.fire("triggerchange",{prevTrigger:t,curTrigger:i})),i.addClass(s),n.get("autoAlign")&&(o.node=i),n.set("align",o),n.show(),a&&a(e)}}function t(e){var t=e.toElement||e.relatedTarget;t&&n.containsElement(t)||n.hide()}var n=this,i=n.get("triggerEvent"),o=n.get("triggerHideEvent"),a=n.get("triggerCallback"),s=n.get("triggerActiveCls")||"",u=n.get("trigger"),c=n.get("delegateTrigger"),l=r(u);i&&(c&&BUI.isString(u)?r(document).delegate(u,i,e):l.on(i,e)),o&&(c&&BUI.isString(u)?r(document).delegate(u,o,t):l.on(o,t))},__renderUI:function(){var e=this,t=e.get("align");t&&!t.node&&(t.node=e.get("render")||e.get("trigger"))}},n.exports=i}),define("bui-common/1.1.2/src/component/uibase/autohide",["jquery"],function(e,t,n){function i(e,t){var n=e.get("hideExceptNode");return n&&n.length?o.contains(n[0],t):!1}function r(){}var o=e("jquery"),a=BUI.wrapBehavior,s=BUI.getWrapBehavior;r.ATTRS={autoHideType:{value:"click"},autoHide:{value:!1},hideExceptNode:{},events:{value:{autohide:!1}}},r.prototype={__bindUI:function(){var e=this;e.on("afterVisibleChange",function(t){var n=t.newVal;e.get("autoHide")&&(n?e._bindHideEvent():e._clearHideEvent())})},handleMoveOuter:function(e){var t=this,n=e.toElement||e.relatedTarget;t.containsElement(n)||i(t,n)||t.fire("autohide")!==!1&&t.hide()},handleDocumentClick:function(e){var t=this,n=e.target;t.containsElement(n)||i(t,n)||t.fire("autohide")!==!1&&t.hide()},_bindHideEvent:function(){var e=this,t=e.get("curTrigger"),n=e.get("autoHideType");"click"===n?o(document).on("mousedown",a(e,"handleDocumentClick")):(e.get("el").on("mouseleave",a(e,"handleMoveOuter")),t&&o(t).on("mouseleave",a(e,"handleMoveOuter")))},_clearHideEvent:function(){var e=this,t=e.get("curTrigger"),n=e.get("autoHideType");"click"===n?o(document).off("mousedown",s(e,"handleDocumentClick")):(e.get("el").off("mouseleave",s(e,"handleMoveOuter")),t&&o(t).off("mouseleave",s(e,"handleMoveOuter")))}},n.exports=r}),define("bui-common/1.1.2/src/component/uibase/close",["jquery"],function(e,t,n){function i(e){return a(e.get("closeTpl"))}function r(){}function o(){}var a=e("jquery"),s=BUI.prefix+"ext-";r.ATTRS={closeTpl:{value:'\u5173\u95ed'},closeable:{value:!0},closeBtn:{}},r.prototype={_uiSetCloseable:function(e){var t=this,n=t.get("closeBtn");e?(n||t.setInternal("closeBtn",n=i(t)),n.appendTo(t.get("el"),void 0)):n&&n.remove()}};var u="hide";o.ATTRS={closeTpl:{view:!0},closeable:{view:1},closeBtn:{view:1},closeAction:{value:u}};var c={hide:u,destroy:"destroy",remove:"remove"};o.prototype={_uiSetCloseable:function(e){var t=this;e&&!t.__bindCloseEvent&&(t.__bindCloseEvent=1,t.get("closeBtn").on("click",function(e){t.fire("closeclick",{domTarget:e.target})!==!1&&t.close(),e.preventDefault()}))},__destructor:function(){var e=this.get("closeBtn");e&&e.detach()},close:function(){var e=this,t=c[e.get("closeAction")||u];e.fire("closing",{action:t})!==!1&&(e.fire("beforeclosed",{action:t}),"remove"==t?e[t](!0):e[t](),e.fire("closed",{action:t}))}},o.View=r,n.exports=o}),define("bui-common/1.1.2/src/component/uibase/collapsable",[],function(e,t,n){var i=function(){};i.ATTRS={collapsed:{}},i.prototype={_uiSetCollapsed:function(e){var t=this,n=t.getStatusCls("collapsed"),i=t.get("el");e?i.addClass(n):i.removeClass(n)}};var r=function(){};r.ATTRS={collapsable:{value:!1},collapsed:{view:!0,value:!1},events:{value:{expanded:!0,collapsed:!0}}},r.prototype={_uiSetCollapsed:function(e){var t=this;t.fire(e?"collapsed":"expanded")}},r.View=i,n.exports=r}),define("bui-common/1.1.2/src/component/uibase/drag",["jquery"],function(e,t,n){function i(){var e=r(s).css("opacity",0).prependTo("body");return e}var r=e("jquery"),o=BUI.guid("drag"),a=function(){};a.ATTRS={dragNode:{},draging:{setter:function(e){return e===!0?{}:void 0},value:null},constraint:{},dragBackEl:{getter:function(){return r("#"+o)}}};var s='';a.prototype={__bindUI:function(){function e(e){var t=o.get("draging");t&&(e.preventDefault(),o._dragMoveTo(e.pageX,e.pageY,t,a))}function t(e){if(1==e.which){o.set("draging",!1);var t=o.get("dragBackEl");t&&t.hide(),i()}}function n(){r(document).on("mousemove",e),r(document).on("mouseup",t)}function i(){r(document).off("mousemove",e),r(document).off("mouseup",t)}var o=this,a=o.get("constraint"),s=o.get("dragNode");s&&s.on("mousedown",function(e){1==e.which&&(e.preventDefault(),o.set("draging",{elX:o.get("x"),elY:o.get("y"),startX:e.pageX,startY:e.pageY}),n())})},_dragMoveTo:function(e,t,n,r){var o=this,a=o.get("dragBackEl"),n=n||o.get("draging"),s=n.startX-e,u=n.startY-t;a.length||(a=i()),a.css({cursor:"move",display:"block"}),o.set("xy",[o._getConstrainX(n.elX-s,r),o._getConstrainY(n.elY-u,r)])},_getConstrainX:function(e,t){var n=this,i=n.get("el").outerWidth(),r=e+i,o=n.get("x");if(t){var a=t.offset();return a.left>=e?a.left:a.left+t.width()e?a.top:a.top+t.height()'+(f?'':"")+"").prependTo("body");return t.on("mousedown",function(e){e.preventDefault()}),t}function s(){}function u(){}var c=e("jquery"),l=e("bui-common/1.1.2/src/ua"),d={},f=6==l.ie;s.ATTRS={maskShared:{value:!0}},s.prototype={_maskExtShow:function(){var e,t=this,n=i(t),r=d[n],o=t.get("maskShared"),s=t.get("maskNode");s||(o?r?s=r.node:(s=a(n),r=d[n]={num:0,node:s}):s=a(n),t.setInternal("maskNode",s)),(e=t.get("zIndex"))&&s.css("z-index",e-1),o&&r.num++,o&&1!=r.num||s.show(),c("body").addClass("x-masked-relative")},_maskExtHide:function(){var e=this,t=i(e),n=d[t],r=e.get("maskShared"),o=e.get("maskNode");r&&n?(n.num=Math.max(n.num-1,0),0==n.num&&o.hide()):o&&o.hide(),c("body").removeClass("x-masked-relative")},__destructor:function(){var e=this,t=e.get("maskShared"),n=e.get("maskNode");e.get("maskNode")&&(t?e.get("visible")&&e._maskExtHide():n.remove())}},u.ATTRS={mask:{value:!1},maskNode:{view:1},maskShared:{view:1}},u.prototype={__bindUI:function(){{var e=this,t=e.get("view");t._maskExtShow,t._maskExtHide}e.get("mask")&&(e.on("show",function(){t._maskExtShow()}),e.on("hide",function(){t._maskExtHide()}))}},u=u,u.View=s,n.exports=u}),define("bui-common/1.1.2/src/component/uibase/position",["jquery"],function(e,t,n){function i(){}function r(){}var o=e("jquery");i.ATTRS={x:{valueFn:function(){var e=this;return e.get("el")&&e.get("el").offset().left}},y:{valueFn:function(){var e=this;return e.get("el")&&e.get("el").offset().top}},zIndex:{},visibleMode:{value:"visibility"}},i.prototype={__createDom:function(){this.get("el").addClass(BUI.prefix+"ext-position")},_uiSetZIndex:function(e){this.get("el").css("z-index",e)},_uiSetX:function(e){null!=e&&this.get("el").offset({left:e})},_uiSetY:function(e){null!=e&&this.get("el").offset({top:e})},_uiSetLeft:function(e){null!=e&&this.get("el").css({left:e})},_uiSetTop:function(e){null!=e&&this.get("el").css({top:e})}},r.ATTRS={x:{view:1},y:{view:1},left:{view:1},top:{view:1},xy:{setter:function(e){var t=this,n=o.makeArray(e);return n.length&&(n[0]&&t.set("x",n[0]),n[1]&&t.set("y",n[1])),e},getter:function(){return[this.get("x"),this.get("y")]}},zIndex:{view:1},visible:{view:!0,value:!0}},r.prototype={move:function(e,t){var n=this;return BUI.isArray(e)&&(t=e[1],e=e[0]),n.set("xy",[e,t]),n},_uiSetX:function(e){if(null!=e){var t=this,n=t.get("el");t.setInternal("left",n.position().left),-999!=e&&this.set("cachePosition",null)}},_uiSetY:function(e){if(null!=e){var t=this,n=t.get("el");t.setInternal("top",n.position().top),-999!=e&&this.set("cachePosition",null)}},_uiSetLeft:function(e){var t=this,n=t.get("el");null!=e&&t.setInternal("x",n.offset().left)},_uiSetTop:function(e){var t=this,n=t.get("el");null!=e&&t.setInternal("y",n.offset().top)}},r.View=i,n.exports=r}),define("bui-common/1.1.2/src/component/uibase/stdmod",["jquery"],function(e,t,n){function i(){}function r(e,t){var n=e.get("contentEl"),i=e.get(t);i||(i=s('
    '),i.appendTo(n),e.setInternal(t,i))}function o(e,t,n){t=e.get(t),BUI.isString(n)?t.html(n):t.html("").append(n)}function a(){}var s=e("jquery"),u=BUI.prefix+"stdmod-";i.ATTRS={header:{},body:{},footer:{},bodyStyle:{},footerStyle:{},headerStyle:{},headerContent:{},bodyContent:{},footerContent:{}},i.PARSER={header:function(e){return e.one("."+u+"header")},body:function(e){return e.one("."+u+"body")},footer:function(e){return e.one("."+u+"footer")}},i.prototype={__renderUI:function(){r(this,"header"),r(this,"body"),r(this,"footer")},_uiSetBodyStyle:function(e){this.get("body").css(e)},_uiSetHeaderStyle:function(e){this.get("header").css(e)},_uiSetFooterStyle:function(e){this.get("footer").css(e)},_uiSetBodyContent:function(e){o(this,"body",e)},_uiSetHeaderContent:function(e){o(this,"header",e)},_uiSetFooterContent:function(e){o(this,"footer",e)}},a.ATTRS={header:{view:1},body:{view:1},footer:{view:1},bodyStyle:{view:1},footerStyle:{view:1},headerStyle:{view:1},headerContent:{view:1},bodyContent:{view:1},footerContent:{view:1}},a.View=i,n.exports=a}),define("bui-common/1.1.2/src/component/uibase/decorate",["jquery"],function(e,t,n){function i(e,t){if(t[e])return!0;var n=new RegExp("^"+m);return e!==v&&n.test(e)?!0:!1}function r(e){for(var t=[],n=e.constructor;n;)t.push(n),n=n.superclass&&n.superclass.constructor;return t}function o(e){return e.toLowerCase().replace(b,function(e,t){return(t+"").toUpperCase()})}function a(e){if(e=f.trim(e),"false"===e.toLowerCase())e=!1;else if("true"===e.toLowerCase())e=!0;else if(I.test(e))e=h.looseParse(e);else if(/\d/.test(e)&&/[^a-z]/i.test(e)){var t=parseFloat(e);t+""===e&&(e=t)}return e}function s(e,t){var n=e.userConfig||{};for(var i in t)i in n||e.setInternal(i,t[i])}function u(e,t){var n,i,r=this,o=r.userConfig||{};for(n in t)n in o||(i=t[n],BUI.isFunction(i)?r.setInternal(n,i.call(r,e)):"string"==typeof i?r.setInternal(n,e.find(i)):BUI.isArray(i)&&i[0]&&r.setInternal(n,e.find(i[0])))}function c(e,t){var n,i,o,a=e.constructor;for(o=r(e),n=o.length-1;n>=0;n--)a=o[n],(i=a[p])&&u.call(e,t,i)}function l(e){var t,n,i=e,r=i.get("srcNode");r&&(r=f(r),i.setInternal("el",r),i.setInternal("srcNode",r),t=i.get("userConfig"),n=i.getDecorateConfig(r),s(e,n),i.get("isDecorateChild")&&i.decorateInternal&&i.decorateInternal(r),c(e,r))}function d(){l(this)}var f=e("jquery"),h=(e("bui-common/1.1.2/src/array"),e("bui-common/1.1.2/src/json")),g=BUI.prefix,m="data-",v=m+"cfg",p="PARSER",y=e("bui-common/1.1.2/src/component/manage"),b=/-([a-z])/g,I=/^[\{\[]/;d.ATTRS={srcNode:{view:!0},isDecorateChild:{value:!1},decorateCfgFields:{value:{id:!0,name:!0,value:!0,title:!0}}},d.prototype={getDecorateConfig:function(e){if(!e.length)return null;var t=this,n=e[0],r=n.attributes,s=t.get("decorateCfgFields"),u={},c=t._getStautsCfg(e);return BUI.each(r,function(e){var t=e.nodeName;try{if(t===v){var n=a(e.nodeValue);BUI.mix(u,n)}else if(i(t,s)){var r=e.nodeValue;-1!==t.indexOf(m)&&(t=t.replace(m,""),t=o(t),r=a(r)),u[t]&&BUI.isObject(r)?BUI.mix(u[t],r):u[t]=r}}catch(c){BUI.log("parse field error,the attribute is:"+t)}}),BUI.mix(u,c)},_getStautsCfg:function(e){var t=this,n={},i=t.get("statusCls");return BUI.each(i,function(t,i){e.hasClass(t)&&(n[i]=!0)}),n},getDecorateElments:function(){var e=this,t=e.get("el"),n=e.get("childContainer");return n?t.find(n).children():t.children()},decorateInternal:function(e){var t=this;t.decorateChildren(e)},findXClassByNode:function(e,t){var n=this,i=e.attr("class")||"",r=n.get("defaultChildClass");i=i.replace(new RegExp("\\b"+g,"ig"),"");var o=y.getConstructorByXClass(i)||y.getConstructorByXClass(r);return o||t||(BUI.log(e),BUI.error("can not find ui "+i+" from this markup")),y.getXClassByConstructor(o)},decorateChildrenInternal:function(e,t){var n=this,i=n.get("children");i.push({xclass:e,srcNode:t})},decorateChildren:function(){var e=this,t=e.getDecorateElments();BUI.each(t,function(t){var n=e.findXClassByNode(f(t));e.decorateChildrenInternal(n,f(t))})}},n.exports=d}),define("bui-common/1.1.2/src/component/uibase/tpl",["jquery"],function(e,t,n){function i(){}function r(){}e("jquery");i.ATTRS={tpl:{},tplEl:{}},i.prototype={__renderUI:function(){var e,t=this,n=t.get("childContainer");n&&(e=t.get("el").find(n),e.length&&t.set("contentEl",e))},getTpl:function(e){var t=this,n=t.get("tpl"),i=t.get("tplRender");return e=e||t.getAttrVals(),i?i(e):n?BUI.substitute(n,e):""},setTplContent:function(e){var t=this,n=t.get("el"),i=t.get("content"),r=(t.get("tplEl"),t.getTpl(e));!i&&r&&(n.empty(),n.html(r))}},r.ATTRS={tpl:{view:!0,sync:!1},tplRender:{view:!0,value:null},childContainer:{view:!0}},r.prototype={__renderUI:function(){this.get("srcNode")||this.setTplContent()},updateContent:function(){this.setTplContent()},setTplContent:function(){var e=this,t=e.getAttrVals();e.get("view").setTplContent(t)},_uiSetTpl:function(){this.setTplContent()}},r.View=i,n.exports=r}),define("bui-common/1.1.2/src/component/uibase/childcfg",["jquery"],function(e,t,n){var i=e("jquery"),r=function(){this._init()};r.ATTRS={defaultChildCfg:{}},r.prototype={_init:function(){var e=this,t=e.get("defaultChildCfg");t&&e.on("beforeAddChild",function(e){var n=e.child;i.isPlainObject(n)&&BUI.each(t,function(e,t){null==n[t]&&(n[t]=e)})})}},n.exports=r}),define("bui-common/1.1.2/src/component/uibase/bindable",[],function(e,t,n){function i(){}i.ATTRS={store:{},loadMask:{value:!1}},BUI.augment(i,{__bindUI:function(){var e=this,t=e.get("store"),n=e.get("loadMask");t&&(t.on("beforeload",function(t){e.onBeforeLoad(t),n&&n.show&&n.show()}),t.on("load",function(t){e.onLoad(t),n&&n.hide&&n.hide()}),t.on("exception",function(t){e.onException(t),n&&n.hide&&n.hide()}),t.on("add",function(t){e.onAdd(t)}),t.on("remove",function(t){e.onRemove(t)}),t.on("update",function(t){e.onUpdate(t)}),t.on("localsort",function(t){e.onLocalSort(t)}),t.on("filtered",function(t){e.onFiltered(t)}))},__syncUI:function(){var e=this,t=e.get("store");t&&t.hasData()&&e.onLoad()},onBeforeLoad:function(){},onLoad:function(){},onException:function(){},onAdd:function(){},onRemove:function(){},onUpdate:function(){},onLocalSort:function(){},onFiltered:function(){}}),n.exports=i}),define("bui-common/1.1.2/src/component/uibase/depends",["jquery"],function(e,t,n){function i(e){var t=c.exec(e),n=t[1],i=t[2],r=a(n);return{source:r,eventType:i}}function r(e,t,n){var r,o=i(t),a=o.source,s=o.eventType;return a&&n&&s&&(BUI.isFunction(n)?r=n:BUI.isArray(n)&&(r=function(){BUI.each(n,function(t){e[t]&&e[t]()})})),r?(o.callbak=r,a.on(s,r),o):null}function o(e){var t=e.source,n=e.eventType,i=e.callbak;t.off(n,i)}function a(e){var t=l.getComponent(e);return t||(t=u("#"+e),t.length||(t=null)),t}function s(){}var u=e("jquery"),c=/^#(.*):(.*)$/,l=e("bui-common/1.1.2/src/component/manage");s.ATTRS={depends:{},dependencesMap:{shared:!1,value:{}}},s.prototype={__syncUI:function(){this.initDependences()},initDependences:function(){var e=this,t=e.get("depends");BUI.each(t,function(t,n){e.addDependence(n,t)})},addDependence:function(e,t){var n,i=this,o=i.get("dependencesMap");i.removeDependence(e),n=r(i,e,t),n&&(o[e]=n)},removeDependence:function(e){var t=this,n=t.get("dependencesMap"),i=n[e];i&&(o(i),delete n[e])},clearDependences:function(){var e=this,t=e.get("dependencesMap");BUI.each(t,function(e){o(e)}),e.set("dependencesMap",{})},__destructor:function(){this.clearDependences()}},n.exports=s}),define("bui-common/1.1.2/src/component/view",["jquery"],function(e,t,n){var i=e("jquery"),r=e("bui-common/1.1.2/src/component/manage"),o=e("bui-common/1.1.2/src/component/uibase/uibase"),a=document,s=o.extend([o.TplView],{getComponentCssClassWithState:function(e){var t=this,n=t.get("ksComponentCss");return e=e||"",t.getCssClassWithPrefix(n.split(/\s+/).join(e+" ")+e)},getCssClassWithPrefix:r.getCssClassWithPrefix,getKeyEventTarget:function(){return this.get("el")},getContentElement:function(){return this.get("contentEl")||this.get("el")},getStatusCls:function(e){var t=this,n=t.get("statusCls"),i=n[e];return i||(i=t.getComponentCssClassWithState("-"+e)),i},renderUI:function(){var e=this;if(!e.get("srcNode")){var t=e.get("render"),n=e.get("el"),i=e.get("elBefore");i?n.insertBefore(i,void 0):t?n.appendTo(t,void 0):n.appendTo(a.body,void 0)}},createDom:function(){var e=this,t=e.get("contentEl"),n=e.get("el");e.get("srcNode")||(n=i("<"+e.get("elTagName")+">"),t&&n.append(t),e.setInternal("el",n)),n.addClass(e.getComponentCssClassWithState()),t||e.setInternal("contentEl",n)},_uiSetHighlighted:function(e){var t=this,n=t.getStatusCls("hover"),i=t.get("el");i[e?"addClass":"removeClass"](n)},_uiSetDisabled:function(e){var t=this,n=t.getStatusCls("disabled"),i=t.get("el");i[e?"addClass":"removeClass"](n).attr("aria-disabled",e),e&&t.get("highlighted")&&t.set("highlighted",!1),t.get("focusable")&&t.getKeyEventTarget().attr("tabIndex",e?-1:0)},_uiSetActive:function(e){var t=this,n=t.getStatusCls("active");t.get("el")[e?"addClass":"removeClass"](n).attr("aria-pressed",!!e)},_uiSetFocused:function(e){var t=this,n=t.get("el"),i=t.getStatusCls("focused");n[e?"addClass":"removeClass"](i)},_uiSetElAttrs:function(e){this.get("el").attr(e)},_uiSetElCls:function(e){this.get("el").addClass(e)},_uiSetElStyle:function(e){this.get("el").css(e)},_uiSetRole:function(e){e&&this.get("el").attr("role",e)},_uiSetWidth:function(e){this.get("el").width(e)},_uiSetHeight:function(e){var t=this;t.get("el").height(e)},_uiSetContent:function(e){var t,n=this;n.get("srcNode")&&!n.get("rendered")||(t=n.get("contentEl"),"string"==typeof e?t.html(e):e&&t.empty().append(e))},_uiSetVisible:function(e){var t=this,n=t.get("el"),i=t.get("visibleMode");"visibility"===i?n.css("visibility",e?"visible":"hidden"):n.css("display",e?"":"none")},set:function(e,t){var n,r,o,a=this,u=a.__attrs[e];if(!u||!a.get("binded"))return s.superclass.set.call(this,e,t),a;var c=s.superclass.get.call(this,e);return i.isPlainObject(t)||BUI.isArray(t)||c!==t?(s.superclass.set.call(this,e,t),t=a.__attrVals[e],n={attrName:e,prevVal:c,newVal:t},r=BUI.ucfirst(e),o="_uiSet"+r,a[o]&&a[o](t,n),a):a},destructor:function(){var e=this.get("el");e&&e.remove()}},{xclass:"view",priority:0});s.ATTRS={el:{setter:function(e){return i(e)}},elCls:{},elStyle:{},role:{},width:{},height:{},statusCls:{value:{}},elTagName:{value:"div"},elAttrs:{},content:{},elBefore:{},render:{},visible:{value:!0},visibleMode:{value:"display"},cachePosition:{},contentEl:{valueFn:function(){return this.get("el")}},prefixCls:{value:BUI.prefix},focusable:{value:!0},focused:{},active:{},disabled:{},highlighted:{}},n.exports=s}),define("bui-common/1.1.2/src/component/controller",["jquery"],function(e,t,n){"use strict";function i(e,t,n){e.create();var i=e.getContentElement(),r=e.get("defaultChildClass");return t.xclass||t instanceof g||(t.xclass=t.xtype?r+"-"+t.xtype:r),t=BUI.Component.create(t,e),t.setInternal("parent",e),t.set("render",i),t.set("elBefore",n),t.create(void 0),t}function r(e){var t,n,i,r,a={},s=e.get("xview");t=e.getAttrs();for(i in t)t.hasOwnProperty(i)&&(n=t[i],n.view&&void 0!==(r=e.get(i))&&(a[i]=r));return delete a.autoRender,a.ksComponentCss=o(e),new s(a)}function o(e){for(var t,n=e.constructor,i=[];n&&n!==g;)t=c.getXClassByConstructor(n),t&&i.push(t),n=n.superclass&&n.superclass.constructor;return i.join(" ")}function a(e,t){var n=e.relatedTarget;return n&&(n===t[0]||s.contains(t,n))}var s=e("jquery"),u=e("bui-common/1.1.2/src/component/uibase/uibase"),c=e("bui-common/1.1.2/src/component/manage"),l=e("bui-common/1.1.2/src/component/view"),d=e("bui-common/1.1.2/src/component/loader"),f=BUI.wrapBehavior,h=BUI.getWrapBehavior,g=u.extend([u.Decorate,u.Tpl,u.ChildCfg,u.KeyNav,u.Depends],{isController:!0,getCssClassWithPrefix:c.getCssClassWithPrefix,initializer:function(){var e=this;e.get("id")||e.set("id",e.getNextUniqueId()),c.addComponent(e.get("id"),e);var t=r(e);e.setInternal("view",t),e.__view=t},getNextUniqueId:function(){var e=this,t=c.getXClassByConstructor(e.constructor);return BUI.guid(t)},createDom:function(){var e=this,t=e.get("view");t.create(void 0)},renderUI:function(){var e=this,t=e.get("loader");e.get("view").render(),e._initChildren(),t&&e.setInternal("loader",t)},_initChildren:function(e){var t,e,n,i=this;for(e=e||i.get("children").concat(),i.get("children").length=0,t=0;t= 0; - }, - /** - * 遍历数组或者对象 - * @method - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){} - */ - each: BUI.each, - /** - * 2个数组内部的值是否相等 - * @param {Array} a1 数组1 - * @param {Array} a2 数组2 - * @return {Boolean} 2个数组相等或者内部元素是否相等 - */ - equals: function(a1, a2) { - if (a1 == a2) { - return true; - } - if (!a1 || !a2) { - return false; - } - - if (a1.length != a2.length) { - return false; - } - var rst = true; - for (var i = 0; i < a1.length; i++) { - if (a1[i] !== a2[i]) { - rst = false; - break; - } - } - return rst; - }, - - /** - * 过滤数组 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){},如果返回true则添加到结果集 - * @return {Array} 过滤的结果集 - */ - filter: function(array, func) { - var result = []; - ArrayUtil.each(array, function(value, index) { - if (func(value, index)) { - result.push(value); - } - }); - return result; - }, - /** - * 转换数组数组 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){},将返回的结果添加到结果集 - * @return {Array} 过滤的结果集 - */ - map: function(array, func) { - var result = []; - ArrayUtil.each(array, function(value, index) { - result.push(func(value, index)); - }); - return result; - }, - /** - * 获取第一个符合条件的数据 - * @param {Array} array 数组 - * @param {Function} func 匹配函数 - * @return {*} 符合条件的数据 - */ - find: function(array, func) { - var i = ArrayUtil.findIndex(array, func); - return i < 0 ? null : array[i]; - }, - /** - * 获取第一个符合条件的数据的索引值 - * @param {Array} array 数组 - * @param {Function} func 匹配函数 - * @return {Number} 符合条件的数据的索引值 - */ - findIndex: function(array, func) { - var result = -1; - ArrayUtil.each(array, function(value, index) { - if (func(value, index)) { - result = index; - return false; - } - }); - return result; - }, - /** - * 数组是否为空 - * @param {Array} array 数组 - * @return {Boolean} 是否为空 - */ - isEmpty: function(array) { - return array.length == 0; - }, - /** - * 插入数组 - * @param {Array} array 数组 - * @param {Number} index 位置 - * @param {*} value 插入的数据 - */ - add: function(array, value) { - array.push(value); - }, - /** - * 将数据插入数组指定的位置 - * @param {Array} array 数组 - * @param {*} value 插入的数据 - * @param {Number} index 位置 - */ - addAt: function(array, value, index) { - ArrayUtil.splice(array, index, 0, value); - }, - /** - * 清空数组 - * @param {Array} array 数组 - * @return {Array} 清空后的数组 - */ - empty: function(array) { - if (!(array instanceof(Array))) { - for (var i = array.length - 1; i >= 0; i--) { - delete array[i]; - } - } - array.length = 0; - }, - /** - * 移除记录 - * @param {Array} array 数组 - * @param {*} value 记录 - * @return {Boolean} 是否移除成功 - */ - remove: function(array, value) { - var i = ArrayUtil.indexOf(value, array); - var rv; - if ((rv = i >= 0)) { - ArrayUtil.removeAt(array, i); - } - return rv; - }, - /** - * 移除指定位置的记录 - * @param {Array} array 数组 - * @param {Number} index 索引值 - * @return {Boolean} 是否移除成功 - */ - removeAt: function(array, index) { - return ArrayUtil.splice(array, index, 1).length == 1; - }, - /** - * @private - */ - slice: function(arr, start, opt_end) { - if (arguments.length <= 2) { - return Array.prototype.slice.call(arr, start); - } else { - return Array.prototype.slice.call(arr, start, opt_end); - } - }, - /** - * @private - */ - splice: function(arr, index, howMany, var_args) { - return Array.prototype.splice.apply(arr, ArrayUtil.slice(arguments, 1)) - } - -}; - -module.exports = ArrayUtil; diff --git a/spm_modules/bui-common/1.1.2/src/base.js b/spm_modules/bui-common/1.1.2/src/base.js deleted file mode 100644 index f8d83cb..0000000 --- a/spm_modules/bui-common/1.1.2/src/base.js +++ /dev/null @@ -1,476 +0,0 @@ -/** - * @fileOverview Base UI控件的最基础的类 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -var INVALID = {}, - Observable = require('./observable'); - -function ensureNonEmpty(obj, name, create) { - var ret = obj[name] || {}; - if (create) { - obj[name] = ret; - } - return ret; -} - -function normalFn(host, method) { - if (BUI.isString(method)) { - return host[method]; - } - return method; -} - -function __fireAttrChange(self, when, name, prevVal, newVal) { - var attrName = name; - return self.fire(when + BUI.ucfirst(name) + 'Change', { - attrName: attrName, - prevVal: prevVal, - newVal: newVal - }); -} - -function setInternal(self, name, value, opts, attrs) { - opts = opts || {}; - - var ret, - subVal, - prevVal; - - prevVal = self.get(name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return undefined; - } - // check before event - if (!opts['silent']) { - if (false === __fireAttrChange(self, 'before', name, prevVal, value)) { - return false; - } - } - // set it - ret = self._set(name, value, opts); - - if (ret === false) { - return ret; - } - - // fire after event - if (!opts['silent']) { - value = self.__attrVals[name]; - __fireAttrChange(self, 'after', name, prevVal, value); - } - return self; -} - -function initClassAttrs(c) { - if (c._attrs || c == Base) { - return; - } - - var superCon = c.superclass.constructor; - if (superCon && !superCon._attrs) { - initClassAttrs(superCon); - } - c._attrs = {}; - - BUI.mixAttrs(c._attrs, superCon._attrs); - BUI.mixAttrs(c._attrs, c.ATTRS); -} -/** - * 基础类,此类提供以下功能 - * - 提供设置获取属性 - * - 提供事件支持 - * - 属性变化时会触发对应的事件 - * - 将配置项自动转换成属性 - * - * ** 创建类,继承BUI.Base类 ** - *
    
    - *   var Control = function(cfg){
    - *     Control.superclass.constructor.call(this,cfg); //调用BUI.Base的构造方法,将配置项变成属性
    - *   };
    - *
    - *   BUI.extend(Control,BUI.Base);
    - * 
    - * - * ** 声明默认属性 ** - *
    
    - *   Control.ATTRS = {
    - *     id : {
    - *       value : 'id' //value 是此属性的默认值
    - *     },
    - *     renderTo : {
    - *
    - *     },
    - *     el : {
    - *       valueFn : function(){                 //第一次调用的时候将renderTo的DOM转换成el属性
    - *         return $(this.get('renderTo'));
    - *       }
    - *     },
    - *     text : {
    - *       getter : function(){ //getter 用于获取值,而不是设置的值
    - *         return this.get('el').val();
    - *       },
    - *       setter : function(v){ //不仅仅是设置值,可以进行相应的操作
    - *         this.get('el').val(v);
    - *       }
    - *     }
    - *   };
    - * 
    - * - * ** 声明类的方法 ** - *
    
    - *   BUI.augment(Control,{
    - *     getText : function(){
    - *       return this.get('text');   //可以用get方法获取属性值
    - *     },
    - *     setText : function(txt){
    - *       this.set('text',txt);      //使用set 设置属性值
    - *     }
    - *   });
    - * 
    - * - * ** 创建对象 ** - *
    
    - *   var c = new Control({
    - *     id : 'oldId',
    - *     text : '测试文本',
    - *     renderTo : '#t1'
    - *   });
    - *
    - *   var el = c.get(el); //$(#t1);
    - *   el.val(); //text的值 : '测试文本'
    - *   c.set('text','修改的值');
    - *   el.val();  //'修改的值'
    - *
    - *   c.set('id','newId') //会触发2个事件: beforeIdChange,afterIdChange 2个事件 ev.newVal 和ev.prevVal标示新旧值
    - * 
    - * @class BUI.Base - * @abstract - * @extends BUI.Observable - * @param {Object} config 配置项 - */ -var Base = function(config) { - var _self = this, - c = _self.constructor, - constructors = []; - this.__attrs = {}; - this.__attrVals = {}; - Observable.apply(this, arguments); - // define - while (c) { - constructors.push(c); - if (c.extensions) { //延迟执行mixin - BUI.mixin(c, c.extensions); - delete c.extensions; - } - //_self.addAttrs(c['ATTRS']); - c = c.superclass ? c.superclass.constructor : null; - } - //以当前对象的属性最终添加到属性中,覆盖之前的属性 - /*for (var i = constructors.length - 1; i >= 0; i--) { - _self.addAttrs(constructors[i]['ATTRS'],true); - };*/ - var con = _self.constructor; - initClassAttrs(con); - _self._initStaticAttrs(con._attrs); - _self._initAttrs(config); -}; - -Base.INVALID = INVALID; - -BUI.extend(Base, Observable); - -BUI.augment(Base, { - _initStaticAttrs: function(attrs) { - var _self = this, - __attrs; - - __attrs = _self.__attrs = {}; - for (var p in attrs) { - if (attrs.hasOwnProperty(p)) { - var attr = attrs[p]; - /*if(BUI.isObject(attr.value) || BUI.isArray(attr.value) || attr.valueFn){*/ - if (attr.shared === false || attr.valueFn) { - __attrs[p] = {}; - BUI.mixAttr(__attrs[p], attrs[p]); - } else { - __attrs[p] = attrs[p]; - } - } - }; - }, - /** - * 添加属性定义 - * @protected - * @param {String} name 属性名 - * @param {Object} attrConfig 属性定义 - * @param {Boolean} overrides 是否覆盖字段 - */ - addAttr: function(name, attrConfig, overrides) { - var _self = this, - attrs = _self.__attrs, - attr = attrs[name]; - - if (!attr) { - attr = attrs[name] = {}; - } - for (var p in attrConfig) { - if (attrConfig.hasOwnProperty(p)) { - if (p == 'value') { - if (BUI.isObject(attrConfig[p])) { - attr[p] = attr[p] || {}; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else if (BUI.isArray(attrConfig[p])) { - attr[p] = attr[p] || []; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else { - attr[p] = attrConfig[p]; - } - } else { - attr[p] = attrConfig[p]; - } - } - - }; - return _self; - }, - /** - * 添加属性定义 - * @protected - * @param {Object} attrConfigs An object with attribute name/configuration pairs. - * @param {Object} initialValues user defined initial values - * @param {Boolean} overrides 是否覆盖字段 - */ - addAttrs: function(attrConfigs, initialValues, overrides) { - var _self = this; - if (!attrConfigs) { - return _self; - } - if (typeof(initialValues) === 'boolean') { - overrides = initialValues; - initialValues = null; - } - BUI.each(attrConfigs, function(attrConfig, name) { - _self.addAttr(name, attrConfig, overrides); - }); - if (initialValues) { - _self.set(initialValues); - } - return _self; - }, - /** - * 是否包含此属性 - * @protected - * @param {String} name 值 - * @return {Boolean} 是否包含 - */ - hasAttr: function(name) { - return name && this.__attrs.hasOwnProperty(name); - }, - /** - * 获取默认的属性值 - * @protected - * @return {Object} 属性值的键值对 - */ - getAttrs: function() { - return this.__attrs; //ensureNonEmpty(this, '__attrs', true); - }, - /** - * 获取属性名/属性值键值对 - * @protected - * @return {Object} 属性对象 - */ - getAttrVals: function() { - return this.__attrVals; //ensureNonEmpty(this, '__attrVals', true); - }, - /** - * 获取属性值,所有的配置项和属性都可以通过get方法获取 - *
    
    -   *  var control = new Control({
    -   *   text : 'control text'
    -   *  });
    -   *  control.get('text'); //control text
    -   *
    -   *  control.set('customValue','value'); //临时变量
    -   *  control.get('customValue'); //value
    -   * 
    - * ** 属性值/配置项 ** - *
    
    -   *   Control.ATTRS = { //声明属性值
    -   *     text : {
    -   *       valueFn : function(){},
    -   *       value : 'value',
    -   *       getter : function(v){}
    -   *     }
    -   *   };
    -   *   var c = new Control({
    -   *     text : 'text value'
    -   *   });
    -   *   //get 函数取的顺序为:是否有修改值(配置项、set)、默认值(第一次调用执行valueFn),如果有getter,则将值传入getter返回
    -   *
    -   *   c.get('text') //text value
    -   *   c.set('text','new text');//修改值
    -   *   c.get('text');//new text
    -   * 
    - * @param {String} name 属性名 - * @return {Object} 属性值 - */ - get: function(name) { - var _self = this, - //declared = _self.hasAttr(name), - attrVals = _self.__attrVals, - attrConfig, - getter, - ret; - - attrConfig = ensureNonEmpty(_self.__attrs, name); - getter = attrConfig['getter']; - - // get user-set value or default value - //user-set value takes privilege - ret = name in attrVals ? - attrVals[name] : - _self._getDefAttrVal(name); - - // invoke getter for this attribute - if (getter && (getter = normalFn(_self, getter))) { - ret = getter.call(_self, ret, name); - } - - return ret; - }, - /** - * @清理所有属性值 - * @protected - */ - clearAttrVals: function() { - this.__attrVals = {}; - }, - /** - * 移除属性定义 - * @protected - */ - removeAttr: function(name) { - var _self = this; - - if (_self.hasAttr(name)) { - delete _self.__attrs[name]; - delete _self.__attrVals[name]; - } - - return _self; - }, - /** - * 设置属性值,会触发before+Name+Change,和 after+Name+Change事件 - *
    
    -   *  control.on('beforeTextChange',function(ev){
    -   *    var newVal = ev.newVal,
    -   *      attrName = ev.attrName,
    -   *      preVal = ev.prevVal;
    -   *
    -   *    //TO DO
    -   *  });
    -   *  control.set('text','new text');  //此时触发 beforeTextChange,afterTextChange
    -   *  control.set('text','modify text',{silent : true}); //此时不触发事件
    -   * 
    - * @param {String|Object} name 属性名 - * @param {Object} value 值 - * @param {Object} opts 配置项 - * @param {Boolean} opts.silent 配置属性时,是否不触发事件 - */ - set: function(name, value, opts) { - var _self = this; - if ($.isPlainObject(name)) { - opts = value; - var all = Object(name), - attrs = []; - - for (name in all) { - if (all.hasOwnProperty(name)) { - setInternal(_self, name, all[name], opts); - } - } - return _self; - } - return setInternal(_self, name, value, opts); - }, - /** - * 设置属性,不触发事件 - *
    
    -   *  control.setInternal('text','text');//此时不触发事件
    -   * 
    - * @param {String} name 属性名 - * @param {Object} value 属性值 - * @return {Boolean|undefined} 如果值无效则返回false,否则返回undefined - */ - setInternal: function(name, value, opts) { - return this._set(name, value, opts); - }, - //获取属性默认值 - _getDefAttrVal: function(name) { - var _self = this, - attrs = _self.__attrs, - attrConfig = ensureNonEmpty(attrs, name), - valFn = attrConfig.valueFn, - val; - - if (valFn && (valFn = normalFn(_self, valFn))) { - val = valFn.call(_self); - if (val !== undefined) { - attrConfig.value = val; - } - delete attrConfig.valueFn; - attrs[name] = attrConfig; - } - - return attrConfig.value; - }, - //仅仅设置属性值 - _set: function(name, value, opts) { - var _self = this, - setValue, - // if host does not have meta info corresponding to (name,value) - // then register on demand in order to collect all data meta info - // 一定要注册属性元数据,否则其他模块通过 _attrs 不能枚举到所有有效属性 - // 因为属性在声明注册前可以直接设置值 - attrConfig = ensureNonEmpty(_self.__attrs, name, true), - setter = attrConfig['setter']; - - // if setter has effect - if (setter && (setter = normalFn(_self, setter))) { - setValue = setter.call(_self, value, name); - } - - if (setValue === INVALID) { - return false; - } - - if (setValue !== undefined) { - value = setValue; - } - - // finally set - _self.__attrVals[name] = value; - return _self; - }, - //初始化属性 - _initAttrs: function(config) { - var _self = this; - if (config) { - for (var attr in config) { - if (config.hasOwnProperty(attr)) { - // 用户设置会调用 setter/validator 的,但不会触发属性变化事件 - _self._set(attr, config[attr]); - } - - } - } - } -}); -module.exports = Base; diff --git a/spm_modules/bui-common/1.1.2/src/component/component.js b/spm_modules/bui-common/1.1.2/src/component/component.js deleted file mode 100644 index 0ef4003..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/component.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @fileOverview Component命名空间的入口文件 - * @ignore - */ - -/** - * @class BUI.Component - *

    - * - *

    - * 控件基类的命名空间 - */ -var Component = {}; - -BUI.mix(Component, { - Manager: require('./manage'), - UIBase: require('./uibase/uibase'), - View: require('./view'), - Controller: require('./controller') -}); - -function create(component, self) { - var childConstructor, xclass; - if (component && (xclass = component.xclass)) { - if (self && !component.prefixCls) { - component.prefixCls = self.get('prefixCls'); - } - childConstructor = Component.Manager.getConstructorByXClass(xclass); - if (!childConstructor) { - BUI.error('can not find class by xclass desc : ' + xclass); - } - component = new childConstructor(component); - } - return component; -} - -/** - * 根据Xclass创建对象 - * @method - * @static - * @param {Object} component 控件的配置项或者控件 - * @param {Object} self 父类实例 - * @return {Object} 实例对象 - */ -Component.create = create; - -module.exports = Component; diff --git a/spm_modules/bui-common/1.1.2/src/component/controller.js b/spm_modules/bui-common/1.1.2/src/component/controller.js deleted file mode 100644 index bc5801d..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/controller.js +++ /dev/null @@ -1,1700 +0,0 @@ -/** - * @fileOverview 控件可以实例化的基类 - * @ignore - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - */ - -/** - * jQuery 事件 - * @class jQuery.Event - * @private - */ - - -'use strict'; - -var $ = require('jquery'), - UIBase = require('./uibase/uibase'), - Manager = require('./manage'), - View = require('./view'), - Loader = require('./loader'), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - -/** - * @ignore - */ -function wrapperViewSetter(attrName) { - return function(ev) { - var self = this; - // in case bubbled from sub component - if (self === ev.target) { - var value = ev.newVal, - view = self.get('view'); - if (view) { - view.set(attrName, value); - } - - } - }; -} - -/** - * @ignore - */ -function wrapperViewGetter(attrName) { - return function(v) { - var self = this, - view = self.get('view'); - return v === undefined ? view.get(attrName) : v; - }; -} - -/** - * @ignore - */ -function initChild(self, c, renderBefore) { - // 生成父组件的 dom 结构 - self.create(); - var contentEl = self.getContentElement(), - defaultCls = self.get('defaultChildClass'); - //配置默认 xclass - if (!c.xclass && !(c instanceof Controller)) { - if (!c.xtype) { - c.xclass = defaultCls; - } else { - c.xclass = defaultCls + '-' + c.xtype; - } - - } - - c = BUI.Component.create(c, self); - c.setInternal('parent', self); - // set 通知 view 也更新对应属性 - c.set('render', contentEl); - c.set('elBefore', renderBefore); - // 如果 parent 也没渲染,子组件 create 出来和 parent 节点关联 - // 子组件和 parent 组件一起渲染 - // 之前设好属性,view ,logic 同步还没 bind ,create 不是 render ,还没有 bindUI - c.create(undefined); - return c; -} - -/** - * 不使用 valueFn, - * 只有 render 时需要找到默认,其他时候不需要,防止莫名其妙初始化 - * @ignore - */ -function constructView(self) { - // 逐层找默认渲染器 - var attrs, - attrCfg, - attrName, - cfg = {}, - v, - Render = self.get('xview'); - - - //将渲染层初始化所需要的属性,直接构造器设置过去 - - attrs = self.getAttrs(); - - // 整理属性,对纯属于 view 的属性,添加 getter setter 直接到 view - for (attrName in attrs) { - if (attrs.hasOwnProperty(attrName)) { - attrCfg = attrs[attrName]; - if (attrCfg.view) { - // 先取后 getter - // 防止死循环 - if ((v = self.get(attrName)) !== undefined) { - cfg[attrName] = v; - } - - // setter 不应该有实际操作,仅用于正规化比较好 - // attrCfg.setter = wrapperViewSetter(attrName); - // 不更改attrCfg的定义,可以多个实例公用一份attrCfg - /*self.on('after' + BUI.ucfirst(attrName) + 'Change', - wrapperViewSetter(attrName)); - */ - // 逻辑层读值直接从 view 层读 - // 那么如果存在默认值也设置在 view 层 - // 逻辑层不要设置 getter - //attrCfg.getter = wrapperViewGetter(attrName); - } - } - } - // does not autoRender for view - delete cfg.autoRender; - cfg.ksComponentCss = getComponentCss(self); - return new Render(cfg); -} - -function getComponentCss(self) { - var constructor = self.constructor, - cls, - re = []; - while (constructor && constructor !== Controller) { - cls = Manager.getXClassByConstructor(constructor); - if (cls) { - re.push(cls); - } - constructor = constructor.superclass && constructor.superclass.constructor; - } - return re.join(' '); -} - -function isMouseEventWithinElement(e, elem) { - var relatedTarget = e.relatedTarget; - // 在里面或等于自身都不算 mouseenter/leave - return relatedTarget && - (relatedTarget === elem[0] || $.contains(elem, relatedTarget)); -} - -/** - * 可以实例化的控件,作为最顶层的控件类,一切用户控件都继承此控件 - * xclass: 'controller'. - * ** 创建子控件 ** - *
    
    - * var Control = Controller.extend([mixin1,mixin2],{ //原型链上的函数
    - *   renderUI : function(){ //创建DOM
    - *
    - *   },
    - *   bindUI : function(){  //绑定事件
    - *
    - *   },
    - *   destructor : funciton(){ //析构函数
    - *
    - *   }
    - * },{
    - *   ATTRS : { //默认的属性
    - *     text : {
    - *
    - *     }
    - *   }
    - * },{
    - *   xclass : 'a' //用于把对象解析成类
    - * });
    - * 
    - * - * ** 创建对象 ** - *
    
    - * var c1 = new Control({
    - *   render : '#t1', //在t1上创建
    - *   text : 'text1',
    - *   children : [{xclass : 'a',text : 'a1'},{xclass : 'b',text : 'b1'}]
    - * });
    - *
    - * c1.render();
    - * 
    - * @extends BUI.Component.UIBase - * @mixins BUI.Component.UIBase.Tpl - * @mixins BUI.Component.UIBase.Decorate - * @mixins BUI.Component.UIBase.Depends - * @mixins BUI.Component.UIBase.ChildCfg - * @class BUI.Component.Controller - */ -var Controller = UIBase.extend([UIBase.Decorate, UIBase.Tpl, UIBase.ChildCfg, UIBase.KeyNav, UIBase.Depends], { - /** - * 是否是控件,标示对象是否是一个UI 控件 - * @type {Boolean} - */ - isController: true, - - /** - * 使用前缀获取类的名字 - * @param classes {String} class names without prefixCls. Separated by space. - * @method - * @protected - * @return {String} class name with prefixCls - */ - getCssClassWithPrefix: Manager.getCssClassWithPrefix, - - /** - * From UIBase, Initialize this component. * - * @protected - */ - initializer: function() { - var self = this; - - if (!self.get('id')) { - self.set('id', self.getNextUniqueId()); - } - Manager.addComponent(self.get('id'), self); - // initialize view - var view = constructView(self); - self.setInternal('view', view); - self.__view = view; - }, - - /** - * 返回新的唯一的Id,结果是 'xclass' + number - * @protected - * @return {String} 唯一id - */ - getNextUniqueId: function() { - var self = this, - xclass = Manager.getXClassByConstructor(self.constructor); - return BUI.guid(xclass); - }, - /** - * From UIBase. Constructor(or get) view object to create ui elements. - * @protected - * - */ - createDom: function() { - var self = this, - //el, - view = self.get('view'); - view.create(undefined); - //el = view.getKeyEventTarget(); - /*if (!self.get('allowTextSelection')) { - //el.unselectable(undefined); - }*/ - }, - - /** - * From UIBase. Call view object to render ui elements. - * @protected - * - */ - renderUI: function() { - var self = this, - loader = self.get('loader'); - self.get('view').render(); - self._initChildren(); - if (loader) { - self.setInternal('loader', loader); - } - /**/ - - }, - _initChildren: function(children) { - var self = this, - i, - children, - child; - // then render my children - children = children || self.get('children').concat(); - self.get('children').length = 0; - for (i = 0; i < children.length; i++) { - child = self.addChild(children[i]); - child.render(); - } - }, - /** - * bind ui for box - * @private - */ - bindUI: function() { - var self = this, - events = self.get('events'); - this.on('afterVisibleChange', function(e) { - this.fire(e.newVal ? 'show' : 'hide'); - }); - //处理控件事件,设置事件是否冒泡 - BUI.each(events, function(v, k) { - self.publish(k, { - bubbles: v - }); - }); - }, - /** - * 控件是否包含指定的DOM元素,包括根节点 - *
    
    -   *   var control = new Control();
    -   *   $(document).on('click',function(ev){
    -   *   var target = ev.target;
    -   *
    -   *   if(!control.containsElement(elem)){ //未点击在控件内部
    -   *     control.hide();
    -   *   }
    -   *   });
    -   * 
    - * @param {HTMLElement} elem DOM 元素 - * @return {Boolean} 是否包含 - */ - containsElement: function(elem) { - var _self = this, - el = _self.get('el'), - children = _self.get('children'), - result = false; - if (!_self.get('rendered')) { - return false; - } - if ($.contains(el[0], elem) || el[0] === elem) { - result = true; - } else { - BUI.each(children, function(item) { - if (item.containsElement(elem)) { - result = true; - return false; - } - }); - } - return result; - }, - /** - * 是否是子控件的DOM元素 - * @protected - * @return {Boolean} 是否子控件的DOM元素 - */ - isChildrenElement: function(elem) { - var _self = this, - children = _self.get('children'), - rst = false; - BUI.each(children, function(child) { - if (child.containsElement(elem)) { - rst = true; - return false; - } - }); - return rst; - }, - /** - * 显示控件 - */ - show: function() { - var self = this; - self.render(); - self.set('visible', true); - return self; - }, - - /** - * 隐藏控件 - */ - hide: function() { - var self = this; - self.set('visible', false); - return self; - }, - /** - * 交替显示或者隐藏 - *
    
    -   *  control.show(); //显示
    -   *  control.toggle(); //隐藏
    -   *  control.toggle(); //显示
    -   * 
    - */ - toggle: function() { - this.set('visible', !this.get('visible')); - return this; - }, - _uiSetFocusable: function(focusable) { - var self = this, - t, - el = self.getKeyEventTarget(); - if (focusable) { - el.attr('tabIndex', 0) - // remove smart outline in ie - // set outline in style for other standard browser - .attr('hideFocus', true) - .on('focus', wrapBehavior(self, 'handleFocus')) - .on('blur', wrapBehavior(self, 'handleBlur')) - .on('keydown', wrapBehavior(self, 'handleKeydown')) - .on('keyup', wrapBehavior(self, 'handleKeyUp')); - } else { - el.removeAttr('tabIndex'); - if (t = getWrapBehavior(self, 'handleFocus')) { - el.off('focus', t); - } - if (t = getWrapBehavior(self, 'handleBlur')) { - el.off('blur', t); - } - if (t = getWrapBehavior(self, 'handleKeydown')) { - el.off('keydown', t); - } - if (t = getWrapBehavior(self, 'handleKeyUp')) { - el.off('keyup', t); - } - } - }, - - _uiSetHandleMouseEvents: function(handleMouseEvents) { - var self = this, - el = self.get('el'), - t; - if (handleMouseEvents) { - el.on('mouseenter', wrapBehavior(self, 'handleMouseEnter')) - .on('mouseleave', wrapBehavior(self, 'handleMouseLeave')) - .on('contextmenu', wrapBehavior(self, 'handleContextMenu')) - .on('mousedown', wrapBehavior(self, 'handleMouseDown')) - .on('mouseup', wrapBehavior(self, 'handleMouseUp')) - .on('dblclick', wrapBehavior(self, 'handleDblClick')); - } else { - t = getWrapBehavior(self, 'handleMouseEnter') && - el.off('mouseenter', t); - t = getWrapBehavior(self, 'handleMouseLeave') && - el.off('mouseleave', t); - t = getWrapBehavior(self, 'handleContextMenu') && - el.off('contextmenu', t); - t = getWrapBehavior(self, 'handleMouseDown') && - el.off('mousedown', t); - t = getWrapBehavior(self, 'handleMouseUp') && - el.off('mouseup', t); - t = getWrapBehavior(self, 'handleDblClick') && - el.off('dblclick', t); - } - }, - - _uiSetFocused: function(v) { - if (v) { - this.getKeyEventTarget()[0].focus(); - } - }, - //当使用visiblity显示隐藏时,隐藏时把DOM移除出视图内,显示时回复原位置 - _uiSetVisible: function(isVisible) { - var self = this, - el = self.get('el'), - visibleMode = self.get('visibleMode'); - if (visibleMode === 'visibility') { - if (isVisible) { - var position = self.get('cachePosition'); - if (position) { - self.set('xy', position); - } - } - if (!isVisible) { - var position = [ - self.get('x'), self.get('y') - ]; - self.set('cachePosition', position); - self.set('xy', [-999, -999]); - } - } - }, - //设置children时 - _uiSetChildren: function(v) { - var self = this, - children = BUI.cloneObject(v); - //self.removeChildren(true); - self._initChildren(children); - }, - /** - * 使控件可用 - */ - enable: function() { - this.set('disabled', false); - return this; - }, - /** - * 使控件不可用,控件不可用时,点击等事件不会触发 - *
    
    -   *  control.disable(); //禁用
    -   *  control.enable(); //解除禁用
    -   * 
    - */ - disable: function() { - this.set('disabled', true); - return this; - }, - /** - * 控件获取焦点 - */ - focus: function() { - if (this.get('focusable')) { - this.set('focused', true); - } - }, - /** - * 子组件将要渲染到的节点,在 render 类上覆盖对应方法 - * @protected - * @ignore - */ - getContentElement: function() { - return this.get('view').getContentElement(); - }, - - /** - * 焦点所在元素即键盘事件处理元素,在 render 类上覆盖对应方法 - * @protected - * @ignore - */ - getKeyEventTarget: function() { - return this.get('view').getKeyEventTarget(); - }, - - /** - * 添加控件的子控件,索引值为 0-based - *
    
    -   *  control.add(new Control());//添加controller对象
    -   *  control.add({xclass : 'a'});//添加xclass 为a 的一个对象
    -   *  control.add({xclass : 'b'},2);//插入到第三个位置
    -   * 
    - * @param {BUI.Component.Controller|Object} c 子控件的实例或者配置项 - * @param {String} [c.xclass] 如果c为配置项,设置c的xclass - * @param {Number} [index] 0-based 如果未指定索引值,则插在控件的最后 - */ - addChild: function(c, index) { - var self = this, - children = self.get('children'), - renderBefore; - if (index === undefined) { - index = children.length; - } - /** - * 添加子控件前触发 - * @event beforeAddChild - * @param {Object} e - * @param {Object} e.child 添加子控件时传入的配置项或者子控件 - * @param {Number} e.index 添加的位置 - */ - self.fire('beforeAddChild', { - child: c, - index: index - }); - renderBefore = children[index] && children[index].get('el') || null; - c = initChild(self, c, renderBefore); - children.splice(index, 0, c); - // 先 create 占位 再 render - // 防止 render 逻辑里读 parent.get('children') 不同步 - // 如果 parent 已经渲染好了子组件也要立即渲染,就 创建 dom ,绑定事件 - if (self.get('rendered')) { - c.render(); - } - - /** - * 添加子控件后触发 - * @event afterAddChild - * @param {Object} e - * @param {Object} e.child 添加子控件 - * @param {Number} e.index 添加的位置 - */ - self.fire('afterAddChild', { - child: c, - index: index - }); - return c; - }, - /** - * 将自己从父控件中移除 - *
    
    -   *  control.remove(); //将控件从父控件中移除,并未删除
    -   *  parent.addChild(control); //还可以添加回父控件
    -   *
    -   *  control.remove(true); //从控件中移除并调用控件的析构函数
    -   * 
    - * @param {Boolean} destroy 是否删除DON节点 - * @return {BUI.Component.Controller} 删除的子对象. - */ - remove: function(destroy) { - var self = this, - parent = self.get('parent'); - if (parent) { - parent.removeChild(self, destroy); - } else if (destroy) { - self.destroy(); - } - return self; - }, - /** - * 移除子控件,并返回移除的控件 - * - * ** 如果 destroy=true,调用移除控件的 {@link BUI.Component.UIBase#destroy} 方法, - * 同时删除对应的DOM ** - *
    
    -   *  var child = control.getChild(id);
    -   *  control.removeChild(child); //仅仅移除
    -   *
    -   *  control.removeChild(child,true); //移除,并调用析构函数
    -   * 
    - * @param {BUI.Component.Controller} c 要移除的子控件. - * @param {Boolean} [destroy=false] 如果是true, - * 调用控件的方法 {@link BUI.Component.UIBase#destroy} . - * @return {BUI.Component.Controller} 移除的子控件. - */ - removeChild: function(c, destroy) { - var self = this, - children = self.get('children'), - index = BUI.Array.indexOf(c, children); - - if (index === -1) { - return; - } - /** - * 删除子控件前触发 - * @event beforeRemoveChild - * @param {Object} e - * @param {Object} e.child 子控件 - * @param {Boolean} e.destroy 是否清除DOM - */ - self.fire('beforeRemoveChild', { - child: c, - destroy: destroy - }); - - if (index !== -1) { - children.splice(index, 1); - } - if (destroy && - // c is still json - c.destroy) { - c.destroy(); - } - /** - * 删除子控件前触发 - * @event afterRemoveChild - * @param {Object} e - * @param {Object} e.child 子控件 - * @param {Boolean} e.destroy 是否清除DOM - */ - self.fire('afterRemoveChild', { - child: c, - destroy: destroy - }); - - return c; - }, - - /** - * 删除当前控件的子控件 - *
    
    -   *   control.removeChildren();//删除所有子控件
    -   *   control.removeChildren(true);//删除所有子控件,并调用子控件的析构函数
    -   * 
    - * @see Component.Controller#removeChild - * @param {Boolean} [destroy] 如果设置 true, - * 调用子控件的 {@link BUI.Component.UIBase#destroy}方法. - */ - removeChildren: function(destroy) { - var self = this, - i, - t = [].concat(self.get('children')); - for (i = 0; i < t.length; i++) { - self.removeChild(t[i], destroy); - } - }, - - /** - * 根据索引获取子控件 - *
    
    -   *  control.getChildAt(0);//获取第一个子控件
    -   *  control.getChildAt(2); //获取第三个子控件
    -   * 
    - * @param {Number} index 0-based 索引值. - * @return {BUI.Component.Controller} 子控件或者null - */ - getChildAt: function(index) { - var children = this.get('children'); - return children[index] || null; - }, - /** - * 根据Id获取子控件 - *
    
    -   *  control.getChild('id'); //从控件的直接子控件中查找
    -   *  control.getChild('id',true);//递归查找所有子控件,包含子控件的子控件
    -   * 
    - * @param {String} id 控件编号 - * @param {Boolean} deep 是否继续查找在子控件中查找 - * @return {BUI.Component.Controller} 子控件或者null - */ - getChild: function(id, deep) { - return this.getChildBy(function(item) { - return item.get('id') === id; - }, deep); - }, - /** - * 通过匹配函数查找子控件,返回第一个匹配的对象 - *
    
    -   *  control.getChildBy(function(child){//从控件的直接子控件中查找
    -   *  return child.get('id') = '1243';
    -   *  });
    -   *
    -   *  control.getChild(function(child){//递归查找所有子控件,包含子控件的子控件
    -   *  return child.get('id') = '1243';
    -   *  },true);
    -   * 
    - * @param {Function} math 查找的匹配函数 - * @param {Boolean} deep 是否继续查找在子控件中查找 - * @return {BUI.Component.Controller} 子控件或者null - */ - getChildBy: function(math, deep) { - return this.getChildrenBy(math, deep)[0] || null; - }, - /** - * 获取控件的附加高度 = control.get('el').outerHeight() - control.get('el').height() - * @protected - * @return {Number} 附加宽度 - */ - getAppendHeight: function() { - var el = this.get('el'); - return el.outerHeight() - el.height(); - }, - /** - * 获取控件的附加宽度 = control.get('el').outerWidth() - control.get('el').width() - * @protected - * @return {Number} 附加宽度 - */ - getAppendWidth: function() { - var el = this.get('el'); - return el.outerWidth() - el.width(); - }, - /** - * 查找符合条件的子控件 - *
    
    -   *  control.getChildrenBy(function(child){//从控件的直接子控件中查找
    -   *  return child.get('type') = '1';
    -   *  });
    -   *
    -   *  control.getChildrenBy(function(child){//递归查找所有子控件,包含子控件的子控件
    -   *  return child.get('type') = '1';
    -   *  },true);
    -   * 
    - * @param {Function} math 查找的匹配函数 - * @param {Boolean} deep 是否继续查找在子控件中查找,如果符合上面的匹配函数,则不再往下查找 - * @return {BUI.Component.Controller[]} 子控件数组 - */ - getChildrenBy: function(math, deep) { - var self = this, - results = []; - if (!math) { - return results; - } - - self.eachChild(function(child) { - if (math(child)) { - results.push(child); - } else if (deep) { - - results = results.concat(child.getChildrenBy(math, deep)); - } - }); - return results; - }, - /** - * 遍历子元素 - *
    
    -   *  control.eachChild(function(child,index){ //遍历子控件
    -   *
    -   *  });
    -   * 
    - * @param {Function} func 迭代函数,函数原型function(child,index) - */ - eachChild: function(func) { - BUI.each(this.get('children'), func); - }, - /** - * Handle dblclick events. By default, this performs its associated action by calling - * {@link BUI.Component.Controller#performActionInternal}. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleDblClick: function(ev) { - this.performActionInternal(ev); - if (!this.isChildrenElement(ev.target)) { - this.fire('dblclick', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Called by it's container component to dispatch mouseenter event. - * @private - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseOver: function(ev) { - var self = this, - el = self.get('el'); - if (!isMouseEventWithinElement(ev, el)) { - self.handleMouseEnter(ev); - - } - }, - - /** - * Called by it's container component to dispatch mouseleave event. - * @private - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseOut: function(ev) { - var self = this, - el = self.get('el'); - if (!isMouseEventWithinElement(ev, el)) { - self.handleMouseLeave(ev); - - } - }, - - /** - * Handle mouseenter events. If the component is not disabled, highlights it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseEnter: function(ev) { - var self = this; - this.set('highlighted', !!ev); - self.fire('mouseenter', { - domTarget: ev.target, - domEvent: ev - }); - }, - - /** - * Handle mouseleave events. If the component is not disabled, de-highlights it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseLeave: function(ev) { - var self = this; - self.set('active', false); - self.set('highlighted', !ev); - self.fire('mouseleave', { - domTarget: ev.target, - domEvent: ev - }); - }, - - /** - * Handles mousedown events. If the component is not disabled, - * If the component is activeable, then activate it. - * If the component is focusable, then focus it, - * else prevent it from receiving keyboard focus. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseDown: function(ev) { - var self = this, - n, - target = $(ev.target), - isMouseActionButton = ev['which'] === 1, - el; - if (isMouseActionButton) { - el = self.getKeyEventTarget(); - if (self.get('activeable')) { - self.set('active', true); - } - if (self.get('focusable')) { - //如果不是input,select,area等可以获取焦点的控件,那么设置此控件的focus - /*if(target[0] == el[0] || (!target.is('input,select,area') && !target.attr('tabindex'))){ - el[0].focus(); - - }*/ - self.setInternal('focused', true); - } - - if (!self.get('allowTextSelection')) { - // firefox /chrome 不会引起焦点转移 - n = ev.target.nodeName; - n = n && n.toLowerCase(); - // do not prevent focus when click on editable element - if (n !== 'input' && n !== 'textarea') { - ev.preventDefault(); - } - } - if (!self.isChildrenElement(ev.target)) { - self.fire('mousedown', { - domTarget: ev.target, - domEvent: ev - }); - } - - } - }, - - /** - * Handles mouseup events. - * If this component is not disabled, performs its associated action by calling - * {@link BUI.Component.Controller#performActionInternal}, then deactivates it. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleMouseUp: function(ev) { - var self = this, - isChildrenElement = self.isChildrenElement(ev.target); - // 左键 - if (self.get('active') && ev.which === 1) { - self.performActionInternal(ev); - self.set('active', false); - if (!isChildrenElement) { - self.fire('click', { - domTarget: ev.target, - domEvent: ev - }); - } - } - if (!isChildrenElement) { - self.fire('mouseup', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Handles context menu. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleContextMenu: function(ev) {}, - - /** - * Handles focus events. Style focused class. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleFocus: function(ev) { - this.set('focused', !!ev); - this.fire('focus', { - domEvent: ev, - domTarget: ev.target - }); - }, - - /** - * Handles blur events. Remove focused class. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleBlur: function(ev) { - this.set('focused', !ev); - this.fire('blur', { - domEvent: ev, - domTarget: ev.target - }); - }, - - /** - * Handle enter keydown event to {@link BUI.Component.Controller#performActionInternal}. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleKeyEventInternal: function(ev) { - var self = this, - isChildrenElement = self.isChildrenElement(ev.target); - if (ev.which === 13) { - if (!isChildrenElement) { - self.fire('click', { - domTarget: ev.target, - domEvent: ev - }); - } - - return this.performActionInternal(ev); - } - if (!isChildrenElement) { - self.fire('keydown', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - - /** - * Handle keydown events. - * If the component is not disabled, call {@link BUI.Component.Controller#handleKeyEventInternal} - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - handleKeydown: function(ev) { - var self = this; - if (self.handleKeyEventInternal(ev)) { - ev.halt(); - return true; - } - }, - handleKeyUp: function(ev) { - var self = this; - if (!self.isChildrenElement(ev.target)) { - self.fire('keyup', { - domTarget: ev.target, - domEvent: ev - }); - } - }, - /** - * Performs the appropriate action when this component is activated by the user. - * @protected - * @param {jQuery.Event} ev DOM event to handle. - */ - performActionInternal: function(ev) {}, - /** - * 析构函数 - * @protected - */ - destructor: function() { - var self = this, - id, - i, - view, - children = self.get('children'); - id = self.get('id'); - for (i = 0; i < children.length; i++) { - children[i].destroy && children[i].destroy(); - } - self.get('view').destroy(); - Manager.removeComponent(id); - }, - //覆写set方法 - set: function(name, value, opt) { - var _self = this, - view = _self.__view, - attr = _self.__attrs[name], - ucName, - ev, - m; - if (BUI.isObject(name)) { - opt = value; - BUI.each(name, function(v, k) { - _self.set(k, v, opt); - }); - } - if (!view || !attr || (opt && opt.silent)) { //未初始化view或者没用定义属性 - Controller.superclass.set.call(this, name, value, opt); - return _self; - } - - var prevVal = Controller.superclass.get.call(this, name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return _self; - } - ucName = BUI.ucfirst(name); - m = '_uiSet' + ucName; - //触发before事件 - _self.fire('before' + ucName + 'Change', { - attrName: name, - prevVal: prevVal, - newVal: value - }); - - _self.setInternal(name, value); - - value = _self.__attrVals[name]; - if (view && attr.view) { - view.set(name, value); - //return _self; - } - ev = { - attrName: name, - prevVal: prevVal, - newVal: value - }; - - //触发before事件 - _self.fire('after' + ucName + 'Change', ev); - if (_self.get('binded') && _self[m]) { - _self[m](value, ev); - } - return _self; - }, - //覆写get方法,改变时同时改变view的值 - get: function(name) { - var _self = this, - view = _self.__view, - attr = _self.__attrs[name], - value = Controller.superclass.get.call(this, name); - if (value !== undefined) { - return value; - } - if (view && attr && attr.view) { - return view.get(name); - } - - return value; - } -}, { - ATTRS: { - /** - * 控件的Html 内容 - *
    
    -     *  new Control({
    -     *   content : '内容',
    -     *   render : '#c1'
    -     *  });
    -     * 
    - * @cfg {String|jQuery} content - */ - /** - * 控件的Html 内容 - * @type {String|jQuery} - */ - content: { - view: 1 - }, - /** - * 控件根节点使用的标签 - *
    
    -     *  new Control({
    -     *   elTagName : 'ul',
    -     *    content : '
  • 内容
  • ', //控件的DOM <ul><li>内容</li></ul> - * render : '#c1' - * }); - *
    - * @cfg {String} elTagName - */ - elTagName: { - // 生成标签名字 - view: true, - value: 'div' - }, - /** - * 子元素的默认 xclass,配置child的时候没必要每次都填写xclass - * @type {String} - */ - defaultChildClass: { - - }, - /** - * 如果控件未设置 xclass,同时父元素设置了 defaultChildClass,那么 - * xclass = defaultChildClass + '-' + xtype - *
    
    -     *  A.ATTRS = {
    -     *  defaultChildClass : {
    -     *    value : 'b'
    -     *  }
    -     *  }
    -     *  //类B 的xclass = 'b'类 B1的xclass = 'b-1',类 B2的xclass = 'b-2',那么
    -     *  var a = new A({
    -     *  children : [
    -     *    {content : 'b'}, //B类
    -     *    {content : 'b1',xtype:'1'}, //B1类
    -     *    {content : 'b2',xtype:'2'}, //B2类
    -     *  ]
    -     *  });
    -     * 
    - * @type {String} - */ - xtype: { - - }, - /** - * 标示控件的唯一编号,默认会自动生成 - * @cfg {String} id - */ - /** - * 标示控件的唯一编号,默认会自动生成 - * @type {String} - */ - id: { - view: true - }, - /** - * 控件宽度 - *
    
    -     * new Control({
    -     *   width : 200 // 200,'200px','20%'
    -     * });
    -     * 
    - * @cfg {Number|String} width - */ - /** - * 控件宽度 - *
    
    -     *  control.set('width',200);
    -     *  control.set('width','200px');
    -     *  control.set('width','20%');
    -     * 
    - * @type {Number|String} - */ - width: { - view: 1 - }, - /** - * 控件宽度 - *
    
    -     * new Control({
    -     *   height : 200 // 200,'200px','20%'
    -     * });
    -     * 
    - * @cfg {Number|String} height - */ - /** - * 控件宽度 - *
    
    -     *  control.set('height',200);
    -     *  control.set('height','200px');
    -     *  control.set('height','20%');
    -     * 
    - * @type {Number|String} - */ - height: { - view: 1 - }, - /** - * 控件根节点应用的样式 - *
    
    -     *  new Control({
    -     *   elCls : 'test',
    -     *   content : '内容',
    -     *   render : '#t1'   //<div id='t1'><div class="test">内容</div></div>
    -     *  });
    -     * 
    - * @cfg {String} elCls - */ - /** - * 控件根节点应用的样式 css class - * @type {String} - */ - elCls: { - view: 1 - }, - /** - * @cfg {Object} elStyle - * 控件根节点应用的css属性 - *
    
    -     *  var cfg = {elStyle : {width:'100px', height:'200px'}};
    -     *  
    - */ - /** - * 控件根节点应用的css属性,以键值对形式 - * @type {Object} - *
    
    -     *	 control.set('elStyle',	{
    -     *		width:'100px',
    -     *		height:'200px'
    -     *   });
    -     *  
    - */ - elStyle: { - view: 1 - }, - /** - * @cfg {Object} elAttrs - * 控件根节点应用的属性,以键值对形式: - *
    
    -     *  new Control({
    -     *  elAttrs :{title : 'tips'}
    -     *  });
    -     * 
    - */ - /** - * @type {Object} - * 控件根节点应用的属性,以键值对形式: - * { title : 'tips'} - * @ignore - */ - elAttrs: { - view: 1 - }, - /** - * 将控件插入到指定元素前 - *
    
    -     *  new Control({
    -     *    elBefore : '#t1'
    -     *  });
    -     * 
    - * @cfg {jQuery} elBefore - */ - /** - * 将控件插入到指定元素前 - * @type {jQuery} - * @ignore - */ - elBefore: { - // better named to renderBefore, too late ! - view: 1 - }, - - /** - * 只读属性,根节点DOM - * @type {jQuery} - */ - el: { - view: 1 - }, - /** - * 控件支持的事件 - * @type {Object} - * @protected - */ - events: { - value: { - /** - * 点击事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'click': true, - /** - * 双击事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'dblclick': true, - /** - * 鼠标移入控件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseenter': true, - /** - * 鼠标移出控件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseleave': true, - /** - * 键盘按下按键事件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'keydown': true, - /** - * 键盘按键抬起控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'keyup': true, - /** - * 控件获取焦点事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'focus': false, - /** - * 控件丢失焦点事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'blur': false, - /** - * 鼠标按下控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mousedown': true, - /** - * 鼠标抬起控件,此事件会冒泡,所以可以在父元素上监听所有子元素的此事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} e.target 触发事件的对象 - * @param {jQuery.Event} e.domEvent DOM触发的事件 - * @param {HTMLElement} e.domTarget 触发事件的DOM节点 - */ - 'mouseup': true, - /** - * 控件显示 - * @event - */ - 'show': false, - /** - * 控件隐藏 - * @event - */ - 'hide': false - } - }, - /** - * 指定控件的容器 - *
    
    -     *  new Control({
    -     *  render : '#t1',
    -     *  elCls : 'test',
    -     *  content : '123'  //<div id="t1"><div class="test bui-xclass"><span>123</span></div></div>
    -     *  });
    -     * 
    - * @cfg {jQuery} render - */ - /** - * 指定控件的容器 - * @type {jQuery} - * @ignore - */ - render: { - view: 1 - }, - /** - * ARIA 标准中的role,不要更改此属性 - * @type {String} - * @protected - */ - role: { - view: 1 - }, - /** - * 状态相关的样式,默认情况下会使用 前缀名 + xclass + '-' + 状态名 - *
      - *
    1. hover
    2. - *
    3. focused
    4. - *
    5. active
    6. - *
    7. disabled
    8. - *
    - * @type {Object} - */ - statusCls: { - view: true, - value: { - - } - }, - /** - * 控件的可视方式,值为: - * - 'display' - * - 'visibility' - *
    
    -     *   new Control({
    -     *   visibleMode: 'visibility'
    -     *   });
    -     *  
    - * @cfg {String} [visibleMode = 'display'] - */ - /** - * 控件的可视方式,使用 css - * - 'display' 或者 - * - 'visibility' - *
    
    -     *  control.set('visibleMode','display')
    -     * 
    - * @type {String} - */ - visibleMode: { - view: 1, - value: 'display' - }, - /** - * 控件是否可见 - *
    
    -     *  new Control({
    -     *  visible : false   //隐藏
    -     *  });
    -     * 
    - * @cfg {Boolean} [visible = true] - */ - /** - * 控件是否可见 - *
    
    -     *  control.set('visible',true); //control.show();
    -     *  control.set('visible',false); //control.hide();
    -     * 
    - * @type {Boolean} - * @default true - */ - visible: { - value: true, - view: 1 - }, - /** - * 是否允许处理鼠标事件 - * @default true. - * @type {Boolean} - * @protected - */ - handleMouseEvents: { - value: true - }, - - /** - * 控件是否可以获取焦点 - * @default true. - * @protected - * @type {Boolean} - */ - focusable: { - value: false, - view: 1 - }, - /** - * 一旦使用loader的默认配置 - * @protected - * @type {Object} - */ - defaultLoaderCfg: { - value: { - property: 'content', - autoLoad: true - } - }, - /** - * 控件内容的加载器 - * @type {BUI.Component.Loader} - */ - loader: { - getter: function(v) { - var _self = this, - defaultCfg; - if (v && !v.isLoader) { - v.target = _self; - defaultCfg = _self.get('defaultLoaderCfg') - v = new Loader(BUI.merge(defaultCfg, v)); - _self.setInternal('loader', v); - } - return v; - } - }, - /** - * 1. Whether allow select this component's text.
    - * 2. Whether not to lose last component's focus if click current one (set false). - * - * Defaults to: false. - * @type {Boolean} - * @property allowTextSelection - * @protected - */ - /** - * @ignore - */ - allowTextSelection: { - // 和 focusable 分离 - // grid 需求:容器允许选择里面内容 - value: true - }, - - /** - * 控件是否可以激活 - * @default true. - * @type {Boolean} - * @protected - */ - activeable: { - value: true - }, - - /** - * 控件是否获取焦点 - * @type {Boolean} - * @readOnly - */ - focused: { - view: 1 - }, - - /** - * 控件是否处于激活状态,按钮按下还未抬起 - * @type {Boolean} - * @default false - * @protected - */ - active: { - view: 1 - }, - /** - * 控件是否高亮 - * @cfg {Boolean} highlighted - * @ignore - */ - /** - * 控件是否高亮 - * @type {Boolean} - * @protected - */ - highlighted: { - view: 1 - }, - /** - * 子控件集合 - * @cfg {BUI.Component.Controller[]} children - */ - /** - * 子控件集合 - * @type {BUI.Component.Controller[]} - */ - children: { - sync: false, - shared: false, - value: [] /**/ - }, - /** - * 控件的CSS前缀 - * @cfg {String} [prefixCls = BUI.prefix] - */ - /** - * 控件的CSS前缀 - * @type {String} - * @default BUI.prefix - */ - prefixCls: { - value: BUI.prefix, // box srcNode need - view: 1 - }, - - /** - * 父控件 - * @cfg {BUI.Component.Controller} parent - * @ignore - */ - /** - * 父控件 - * @type {BUI.Component.Controller} - */ - parent: { - setter: function(p) { - // 事件冒泡源 - this.addTarget(p); - } - }, - - /** - * 禁用控件 - * @cfg {Boolean} [disabled = false] - */ - /** - * 禁用控件 - *
    
    -     *  control.set('disabled',true); //==  control.disable();
    -     *  control.set('disabled',false); //==  control.enable();
    -     * 
    - * @type {Boolean} - * @default false - */ - disabled: { - view: 1, - value: false - }, - /** - * 渲染控件的View类. - * @protected - * @cfg {BUI.Component.View} [xview = BUI.Component.View] - */ - /** - * 渲染控件的View类. - * @protected - * @type {BUI.Component.View} - */ - xview: { - value: View - } - }, - PARSER: { - visible: function(el) { - var _self = this, - display = el.css('display'), - - visibility = el.css('visibility'), - visibleMode = _self.get('visibleMode'); - if ((display == 'none' && visibleMode == 'display') || (visibility == 'hidden' && visibleMode == 'visibility')) { - return false; - } - return true; - }, - disabled: function(el){ - var _self = this, - cls = _self.get('prefixCls') + _self.get('xclass') + '-disabled'; - return el.hasClass(cls); - } - } -}, { - xclass: 'controller', - priority: 0 -}); -module.exports = Controller; diff --git a/spm_modules/bui-common/1.1.2/src/component/loader.js b/spm_modules/bui-common/1.1.2/src/component/loader.js deleted file mode 100644 index 4627407..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/loader.js +++ /dev/null @@ -1,435 +0,0 @@ -/** - * @fileOverview 加载控件内容 - * @ignore - */ - -'use strict'; -var $ = require('jquery'), - BUI = require('../util'), - Base = require('../base'), - /** - * @class BUI.Component.Loader - * @extends BUI.Base - * ** 控件的默认Loader属性是:** - *
    
    -   *
    -   *   defaultLoader : {
    -   *     value : {
    -   *       property : 'content',
    -   *       autoLoad : true
    -   *     }
    -   *   }
    -   * 
    - * ** 一般的控件默认读取html,作为控件的content值 ** - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * - * ** 可以修改Loader的默认属性,加载children ** - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/children.json',
    -   *       property : 'children',
    -   *       dataType : 'json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * 加载控件内容的类,一般不进行实例化 - */ - Loader = function(config) { - Loader.superclass.constructor.call(this, config); - this._init(); - }; - -Loader.ATTRS = { - - /** - * 加载内容的地址 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} url - */ - url: { - - }, - /** - * 对应的控件,加载完成后设置属性到对应的控件 - * @readOnly - * @type {BUI.Component.Controller} - */ - target: { - - }, - /** - * @private - * 是否load 过 - */ - hasLoad: { - value: false - }, - /** - * 是否自动加载数据 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       autoLoad : false
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Boolean} [autoLoad = true] - */ - autoLoad: { - - }, - /** - * 延迟加载 - * - * - event : 触发加载的事件 - * - repeat :是否重复加载 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       lazyLoad : {
    -   *         event : 'show',
    -   *         repeat : true
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Object} [lazyLoad = null] - */ - lazyLoad: { - - }, - /** - * 加载返回的数据作为控件的那个属性 - *
    
    -   *   var control = new BUI.List.SimpleList({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       dataType : 'json',
    -   *       property : 'items'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} property - */ - property: { - - }, - /** - * 格式化返回的数据 - * @cfg {Function} renderer - */ - renderer: { - value: function(value) { - return value; - } - }, - /** - * 加载数据时是否显示屏蔽层和加载提示 {@link BUI.Mask.LoadMask} - * - * - loadMask : true时使用loadMask 默认的配置信息 - * - loadMask : {msg : '正在加载,请稍后。。'} LoadMask的配置信息 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       loadMask : true
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Boolean|Object} [loadMask = false] - */ - loadMask: { - value: false - }, - /** - * ajax 请求返回数据的类型 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       dataType : 'json',
    -   *       property : 'items'
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {String} [dataType = 'text'] - */ - dataType: { - value: 'text' - }, - /** - * Ajax请求的配置项,会覆盖 url,dataType数据 - * @cfg {Object} ajaxOptions - */ - ajaxOptions: { - //shared : false, - value: { - type: 'get', - cache: false - } - }, - /** - * 初始化的请求参数 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       params : {
    -   *         a : 'a',
    -   *         b : 'b'
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Object} params - * @default null - */ - params: { - - }, - /** - * 附加参数,每次请求都带的参数 - * @cfg {Object} appendParams - */ - appendParams: { - - }, - /** - * 最后一次请求的参数 - * @readOnly - * @private - * @type {Object} - */ - lastParams: { - shared: false, - value: {} - }, - /** - * 加载数据,并添加属性到控件后的回调函数 - * - data : 加载的数据 - * - params : 加载的参数 - *
    
    -   *   var control = new BUI.Component.Controller({
    -   *     render : '#c1',
    -   *     loader : {
    -   *       url : 'data/text.json',
    -   *       callback : function(text){
    -   *         var target = this.get('target');//control
    -   *         //TO DO
    -   *       }
    -   *     }
    -   *   });
    -   *
    -   *   control.render();
    -   * 
    - * @cfg {Function} callback - */ - callback: { - - }, - /** - * 失败的回调函数 - * - response : 返回的错误对象 - * - params : 加载的参数 - * @cfg {Function} failure - */ - failure: { - - } - -}; - -BUI.extend(Loader, Base); - -BUI.augment(Loader, { - /** - * @protected - * 是否是Loader - * @type {Boolean} - */ - isLoader: true, - //初始化 - _init: function() { - var _self = this, - autoLoad = _self.get('autoLoad'), - params = _self.get('params'); - - _self._initMask(); - if (autoLoad) { - _self.load(params); - } else { - _self._initParams(); - _self._initLazyLoad(); - } - }, - //初始化延迟加载 - _initLazyLoad: function() { - var _self = this, - target = _self.get('target'), - lazyLoad = _self.get('lazyLoad'); - - if (target && lazyLoad && lazyLoad.event) { - target.on(lazyLoad.event, function() { - if (!_self.get('hasLoad') || lazyLoad.repeat) { - _self.load(); - } - }); - } - }, - /** - * 初始化mask - * @private - */ - _initMask: function() { - var _self = this, - target = _self.get('target'), - loadMask = _self.get('loadMask'); - if (target && loadMask) { - require.async('bui-mask/1.1.0/index', function(Mask) { - var cfg = $.isPlainObject(loadMask) ? loadMask : {}; - loadMask = new Mask.LoadMask(BUI.mix({ - el: target.get('el') - }, cfg)); - _self.set('loadMask', loadMask); - }); - } - }, - //初始化查询参数 - _initParams: function() { - var _self = this, - lastParams = _self.get('lastParams'), - params = _self.get('params'); - - //初始化 参数 - BUI.mix(lastParams, params); - }, - /** - * 加载内容 - * @param {Object} params 加载数据的参数 - */ - load: function(params) { - var _self = this, - url = _self.get('url'), - ajaxOptions = _self.get('ajaxOptions'), - lastParams = _self.get('lastParams'), - appendParams = _self.get('appendParams'); - - //BUI.mix(true,lastParams,appendParams,params); - params = params || lastParams; - params = BUI.merge(appendParams, params); //BUI.cloneObject(lastParams); - _self.set('lastParams', params); - //未提供加载地址,阻止加载 - if (!url) { - return; - } - - _self.onBeforeLoad(); - _self.set('hasLoad', true); - $.ajax(BUI.mix({ - dataType: _self.get('dataType'), - data: params, - url: url, - success: function(data) { - _self.onload(data, params); - }, - error: function(jqXHR, textStatus, errorThrown) { - _self.onException({ - jqXHR: jqXHR, - textStatus: textStatus, - errorThrown: errorThrown - }, params); - } - }, ajaxOptions)); - }, - /** - * @private - * 加载前 - */ - onBeforeLoad: function() { - var _self = this, - loadMask = _self.get('loadMask'); - if (loadMask && loadMask.show) { - loadMask.show(); - } - }, - /** - * @private - * 加载完毕 - */ - onload: function(data, params) { - var _self = this, - loadMask = _self.get('loadMask'), - property = _self.get('property'), - callback = _self.get('callback'), - renderer = _self.get('renderer'), - target = _self.get('target'); - - if (BUI.isString(data)) { - target.set(property, ''); //防止2次返回的数据一样 - } - target.set(property, renderer.call(_self, data)); - - /**/ - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - if (callback) { - callback.call(this, data, params); - } - }, - /** - * @private - * 加载出错 - */ - onException: function(response, params) { - var _self = this, - failure = _self.get('failure'); - if (failure) { - failure.call(this, response, params); - } - } - -}); -module.exports = Loader; diff --git a/spm_modules/bui-common/1.1.2/src/component/manage.js b/spm_modules/bui-common/1.1.2/src/component/manage.js deleted file mode 100644 index 8531d46..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/manage.js +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @fileOverview Base UI控件的管理类 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - - - -//控件类的管理器 - - -var $ = require('jquery'); - -var uis = { - // 不带前缀 prefixCls - /* - "menu" :{ - priority:0, - constructor:Menu - } - */ -}; - -function getConstructorByXClass(cls) { - var cs = cls.split(/\s+/), - p = -1, - t, - ui = null; - for (var i = 0; i < cs.length; i++) { - var uic = uis[cs[i]]; - if (uic && (t = uic.priority) > p) { - p = t; - ui = uic.constructor; - } - } - return ui; -} - -function getXClassByConstructor(constructor) { - for (var u in uis) { - var ui = uis[u]; - if (ui.constructor == constructor) { - return u; - } - } - return 0; -} - -function setConstructorByXClass(cls, uic) { - if (BUI.isFunction(uic)) { - uis[cls] = { - constructor: uic, - priority: 0 - }; - } else { - uic.priority = uic.priority || 0; - uis[cls] = uic; - } -} - - -function getCssClassWithPrefix(cls) { - var cs = $.trim(cls).split(/\s+/); - for (var i = 0; i < cs.length; i++) { - if (cs[i]) { - cs[i] = this.get('prefixCls') + cs[i]; - } - } - return cs.join(' '); -} - - - -var componentInstances = {}; - -/** - * Manage component metadata. - * @class BUI.Component.Manager - * @singleton - */ -var Manager = { - - __instances: componentInstances, - /** - * 每实例化一个控件,就注册到管理器上 - * @param {String} id 控件 id - * @param {BUI.Component.Controller} component 控件对象 - */ - addComponent: function(id, component) { - componentInstances[id] = component; - }, - /** - * 移除注册的控件 - * @param {String} id 控件 id - */ - removeComponent: function(id) { - delete componentInstances[id]; - }, - /** - * 遍历所有的控件 - * @param {Function} fn 遍历函数 - */ - eachComponent: function(fn) { - BUI.each(componentInstances, fn); - }, - /** - * 根据Id获取控件 - * @param {String} id 编号 - * @return {BUI.Component.UIBase} 继承 UIBase的类对象 - */ - getComponent: function(id) { - return componentInstances[id]; - }, - - getCssClassWithPrefix: getCssClassWithPrefix, - /** - * 通过构造函数获取xclass. - * @param {Function} constructor 控件的构造函数. - * @type {Function} - * @return {String} - * @method - */ - getXClassByConstructor: getXClassByConstructor, - /** - * 通过xclass获取控件的构造函数 - * @param {String} classNames Class names separated by space. - * @type {Function} - * @return {Function} - * @method - */ - getConstructorByXClass: getConstructorByXClass, - /** - * 将 xclass 同构造函数相关联. - * @type {Function} - * @param {String} className 控件的xclass名称. - * @param {Function} componentConstructor 构造函数 - * @method - */ - setConstructorByXClass: setConstructorByXClass -}; - -module.exports = Manager; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/align.js b/spm_modules/bui-common/1.1.2/src/component/uibase/align.js deleted file mode 100644 index 8667e5a..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/align.js +++ /dev/null @@ -1,482 +0,0 @@ -/** - * @fileOverview 跟指定的元素项对齐的方式 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'), - UA = require('../../ua'), - CLS_ALIGN_PREFIX ='x-align-', - win = window; - -// var ieMode = document.documentMode || UA.ie; - -/* - inspired by closure library by Google - see http://yiminghe.iteye.com/blog/1124720 - */ - -/** - * 得到会导致元素显示不全的祖先元素 - * @ignore - */ -function getOffsetParent(element) { - // ie 这个也不是完全可行 - /** -
    -
    - 元素 6 高 100px 宽 50px
    -
    -
    - @ignore - **/ - // element.offsetParent does the right thing in ie7 and below. Return parent with layout! - // In other browsers it only includes elements with position absolute, relative or - // fixed, not elements with overflow set to auto or scroll. - // if (UA.ie && ieMode < 8) { - // return element.offsetParent; - // } - // 统一的 offsetParent 方法 - var doc = element.ownerDocument, - body = doc.body, - parent, - positionStyle = $(element).css('position'), - skipStatic = positionStyle == 'fixed' || positionStyle == 'absolute'; - - if (!skipStatic) { - return element.nodeName.toLowerCase() == 'html' ? null : element.parentNode; - } - - for (parent = element.parentNode; parent && parent != body; parent = parent.parentNode) { - positionStyle = $(parent).css('position'); - if (positionStyle != 'static') { - return parent; - } - } - return null; -} - -/** - * 获得元素的显示部分的区域 - * @private - * @ignore - */ -function getVisibleRectForElement(element) { - var visibleRect = { - left:0, - right:Infinity, - top:0, - bottom:Infinity - }, - el, - scrollX, - scrollY, - winSize, - doc = element.ownerDocument, - body = doc.body, - documentElement = doc.documentElement; - - // Determine the size of the visible rect by climbing the dom accounting for - // all scrollable containers. - for (el = element; el = getOffsetParent(el);) { - // clientWidth is zero for inline block elements in ie. - if ((!UA.ie || el.clientWidth != 0) && - // body may have overflow set on it, yet we still get the entire - // viewport. In some browsers, el.offsetParent may be - // document.documentElement, so check for that too. - (el != body && el != documentElement && $(el).css('overflow') != 'visible')) { - var pos = $(el).offset(); - // add border - pos.left += el.clientLeft; - pos.top += el.clientTop; - - visibleRect.top = Math.max(visibleRect.top, pos.top); - visibleRect.right = Math.min(visibleRect.right, - // consider area without scrollBar - pos.left + el.clientWidth); - visibleRect.bottom = Math.min(visibleRect.bottom, - pos.top + el.clientHeight); - visibleRect.left = Math.max(visibleRect.left, pos.left); - } - } - - // Clip by window's viewport. - scrollX = $(win).scrollLeft(); - scrollY = $(win).scrollTop(); - visibleRect.left = Math.max(visibleRect.left, scrollX); - visibleRect.top = Math.max(visibleRect.top, scrollY); - winSize = { - width:BUI.viewportWidth(), - height:BUI.viewportHeight() - }; - visibleRect.right = Math.min(visibleRect.right, scrollX + winSize.width); - visibleRect.bottom = Math.min(visibleRect.bottom, scrollY + winSize.height); - return visibleRect.top >= 0 && visibleRect.left >= 0 && - visibleRect.bottom > visibleRect.top && - visibleRect.right > visibleRect.left ? - visibleRect : null; -} - -function getElFuturePos(elRegion, refNodeRegion, points, offset) { - var xy, - diff, - p1, - p2; - - xy = { - left:elRegion.left, - top:elRegion.top - }; - - p1 = getAlignOffset(refNodeRegion, points[0]); - p2 = getAlignOffset(elRegion, points[1]); - - diff = [p2.left - p1.left, p2.top - p1.top]; - - return { - left:xy.left - diff[0] + (+offset[0]), - top:xy.top - diff[1] + (+offset[1]) - }; -} - -function isFailX(elFuturePos, elRegion, visibleRect) { - return elFuturePos.left < visibleRect.left || - elFuturePos.left + elRegion.width > visibleRect.right; -} - -function isFailY(elFuturePos, elRegion, visibleRect) { - return elFuturePos.top < visibleRect.top || - elFuturePos.top + elRegion.height > visibleRect.bottom; -} - -function adjustForViewport(elFuturePos, elRegion, visibleRect, overflow) { - var pos = BUI.cloneObject(elFuturePos), - size = { - width:elRegion.width, - height:elRegion.height - }; - - if (overflow.adjustX && pos.left < visibleRect.left) { - pos.left = visibleRect.left; - } - - // Left edge inside and right edge outside viewport, try to resize it. - if (overflow['resizeWidth'] && - pos.left >= visibleRect.left && - pos.left + size.width > visibleRect.right) { - size.width -= (pos.left + size.width) - visibleRect.right; - } - - // Right edge outside viewport, try to move it. - if (overflow.adjustX && pos.left + size.width > visibleRect.right) { - // 保证左边界和可视区域左边界对齐 - pos.left = Math.max(visibleRect.right - size.width, visibleRect.left); - } - - // Top edge outside viewport, try to move it. - if (overflow.adjustY && pos.top < visibleRect.top) { - pos.top = visibleRect.top; - } - - // Top edge inside and bottom edge outside viewport, try to resize it. - if (overflow['resizeHeight'] && - pos.top >= visibleRect.top && - pos.top + size.height > visibleRect.bottom) { - size.height -= (pos.top + size.height) - visibleRect.bottom; - } - - // Bottom edge outside viewport, try to move it. - if (overflow.adjustY && pos.top + size.height > visibleRect.bottom) { - // 保证上边界和可视区域上边界对齐 - pos.top = Math.max(visibleRect.bottom - size.height, visibleRect.top); - } - - return BUI.mix(pos, size); -} - - -function flip(points, reg, map) { - var ret = []; - $.each(points, function (index,p) { - ret.push(p.replace(reg, function (m) { - return map[m]; - })); - }); - return ret; -} - -function flipOffset(offset, index) { - offset[index] = -offset[index]; - return offset; -} - - -/** - * @class BUI.Component.UIBase.Align - * Align extension class. - * Align component with specified element. - * - */ -function Align() { -} - - -Align.__getOffsetParent = getOffsetParent; - -Align.__getVisibleRectForElement = getVisibleRectForElement; - -Align.ATTRS = -{ - /** - * 对齐配置,详细说明请参看: JS控件 对齐 - * @cfg {Object} align - *
    
    -   *  var overlay = new Overlay( {  
    -   *     align :{
    -   *     node: null,     // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素
    -   *     points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tl 与参考节点的 tr 对齐
    -   *     offset: [0, 0]    // 有效值为 [n, m]
    -   *     }
    -   *   }); 
    -   * 
    - */ - - /** - * 设置对齐属性 - * @type {Object} - * @field - * - * var align = { - * node: null, // 参考元素, falsy 或 window 为可视区域, 'trigger' 为触发元素, 其他为指定元素 - * points: ['cc','cc'], // ['tr', 'tl'] 表示 overlay 的 tl 与参考节点的 tr 对齐 - * offset: [0, 0] // 有效值为 [n, m] - * }; - * overlay.set('align',align); - * - */ - align:{ - shared : false, - value:{} - } -}; - -function getRegion(node) { - var offset, w, h; - if (node.length && !$.isWindow(node[0])) { - offset = node.offset(); - w = node.outerWidth(); - h = node.outerHeight(); - } else { - offset = { left:BUI.scrollLeft(), top:BUI.scrollTop() }; - w = BUI.viewportWidth(); - h = BUI.viewportHeight(); - } - offset.width = w; - offset.height = h; - return offset; -} - -/** - * 获取 node 上的 align 对齐点 相对于页面的坐标 - * @param region - * @param align - */ -function getAlignOffset(region, align) { - var V = align.charAt(0), - H = align.charAt(1), - w = region.width, - h = region.height, - x, y; - - x = region.left; - y = region.top; - - if (V === 'c') { - y += h / 2; - } else if (V === 'b') { - y += h; - } - - if (H === 'c') { - x += w / 2; - } else if (H === 'r') { - x += w; - } - - return { left:x, top:y }; -} - -//清除对齐的css样式 -function clearAlignCls(el){ - var cls = el.attr('class'), - regex = new RegExp('\s?'+CLS_ALIGN_PREFIX+'[a-z]{2}-[a-z]{2}','ig'), - arr = regex.exec(cls); - if(arr){ - el.removeClass(arr.join(' ')); - } -} - -Align.prototype = -{ - _uiSetAlign:function (v,ev) { - var alignCls = '', - el, - selfAlign; //points 的第二个参数,是自己对齐于其他节点的的方式 - if (v && v.points) { - this.align(v.node, v.points, v.offset, v.overflow); - this.set('cachePosition',null); - el = this.get('el'); - clearAlignCls(el); - selfAlign = v.points.join('-'); - alignCls = CLS_ALIGN_PREFIX + selfAlign; - el.addClass(alignCls); - /**/ - } - }, - __bindUI : function(){ - var _self = this; - - var fn = BUI.wrapBehavior(_self,'handleWindowResize'); - - _self.on('show',function(){ - $(window).on('resize',fn); - }); - - _self.on('hide',function(){ - $(window).off('resize',fn); - }); - }, - //处理window resize事件 - handleWindowResize : function(){ - var _self = this, - align = _self.get('align'); - - _self.set('align',align); - }, - /* - 对齐 Overlay 到 node 的 points 点, 偏移 offset 处 - @method - @ignore - @param {Element} node 参照元素, 可取配置选项中的设置, 也可是一元素 - @param {String[]} points 对齐方式 - @param {Number[]} [offset] 偏移 - */ - align:function (refNode, points, offset, overflow) { - refNode = $(refNode || win); - offset = offset && [].concat(offset) || [0, 0]; - overflow = overflow || {}; - - var self = this, - el = self.get('el'), - fail = 0, - // 当前节点可以被放置的显示区域 - visibleRect = getVisibleRectForElement(el[0]), - // 当前节点所占的区域, left/top/width/height - elRegion = getRegion(el), - // 参照节点所占的区域, left/top/width/height - refNodeRegion = getRegion(refNode), - // 当前节点将要被放置的位置 - elFuturePos = getElFuturePos(elRegion, refNodeRegion, points, offset), - // 当前节点将要所处的区域 - newElRegion = BUI.merge(elRegion, elFuturePos); - - // 如果可视区域不能完全放置当前节点时允许调整 - if (visibleRect && (overflow.adjustX || overflow.adjustY)) { - - // 如果横向不能放下 - if (isFailX(elFuturePos, elRegion, visibleRect)) { - fail = 1; - // 对齐位置反下 - points = flip(points, /[lr]/ig, { - l:'r', - r:'l' - }); - // 偏移量也反下 - offset = flipOffset(offset, 0); - } - - // 如果纵向不能放下 - if (isFailY(elFuturePos, elRegion, visibleRect)) { - fail = 1; - // 对齐位置反下 - points = flip(points, /[tb]/ig, { - t:'b', - b:'t' - }); - // 偏移量也反下 - offset = flipOffset(offset, 1); - } - - // 如果失败,重新计算当前节点将要被放置的位置 - if (fail) { - elFuturePos = getElFuturePos(elRegion, refNodeRegion, points, offset); - BUI.mix(newElRegion, elFuturePos); - } - - var newOverflowCfg = {}; - - // 检查反下后的位置是否可以放下了 - // 如果仍然放不下只有指定了可以调整当前方向才调整 - newOverflowCfg.adjustX = overflow.adjustX && - isFailX(elFuturePos, elRegion, visibleRect); - - newOverflowCfg.adjustY = overflow.adjustY && - isFailY(elFuturePos, elRegion, visibleRect); - - // 确实要调整,甚至可能会调整高度宽度 - if (newOverflowCfg.adjustX || newOverflowCfg.adjustY) { - newElRegion = adjustForViewport(elFuturePos, elRegion, - visibleRect, newOverflowCfg); - } - } - - // 新区域位置发生了变化 - if (newElRegion.left != elRegion.left) { - self.setInternal('x', null); - self.get('view').setInternal('x', null); - self.set('x', newElRegion.left); - } - - if (newElRegion.top != elRegion.top) { - // https://github.com/kissyteam/kissy/issues/190 - // 相对于屏幕位置没变,而 left/top 变了 - // 例如
    - // el.align(div) - self.setInternal('y', null); - self.get('view').setInternal('y', null); - self.set('y', newElRegion.top); - } - - // 新区域高宽发生了变化 - if (newElRegion.width != elRegion.width) { - el.width(el.width() + newElRegion.width - elRegion.width); - } - if (newElRegion.height != elRegion.height) { - el.height(el.height() + newElRegion.height - elRegion.height); - } - - return self; - }, - - /** - * 对齐到元素的中间,查看属性 {@link BUI.Component.UIBase.Align#property-align} . - *
    
    -   *  control.center('#t1'); //控件处于容器#t1的中间位置
    -   * 
    - * @param {undefined|String|HTMLElement|jQuery} node - * - */ - center:function (node) { - var self = this; - self.set('align', { - node:node, - points:['cc', 'cc'], - offset:[0, 0] - }); - return self; - } -}; - -module.exports = Align; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/autohide.js b/spm_modules/bui-common/1.1.2/src/component/uibase/autohide.js deleted file mode 100644 index 9b57d66..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/autohide.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @fileOverview 点击或移出控件外部,控件隐藏 - * @author dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - -function isExcept(self, elem) { - var hideExceptNode = self.get('hideExceptNode'); - if (hideExceptNode && hideExceptNode.length) { - return $.contains(hideExceptNode[0], elem); - } - return false; -} -/** - * 点击隐藏控件的扩展 - * @class BUI.Component.UIBase.AutoHide - */ -function autoHide() { - -} - -autoHide.ATTRS = { - - /** - * 控件自动隐藏的事件,这里支持2种: - * - 'click' - * - 'leave' - *
    
    -   *    var overlay = new Overlay({ //点击#t1时显示,点击#t1之外的元素隐藏
    -   *      trigger : '#t1',
    -   *      autoHide : true,
    -   *      content : '悬浮内容'
    -   *    });
    -   *    overlay.render();
    -   *
    -   *    var overlay = new Overlay({ //移动到#t1时显示,移动出#t1,overlay之外控件隐藏
    -   *      trigger : '#t1',
    -   *      autoHide : true,
    -   *      triggerEvent :'mouseover',
    -   *      autoHideType : 'leave',
    -   *      content : '悬浮内容'
    -   *    });
    -   *    overlay.render();
    -   *
    -   *  
    - * @cfg {String} [autoHideType = 'click'] - */ - /** - * 控件自动隐藏的事件,这里支持2种: - * 'click',和'leave',默认为'click' - * @type {String} - */ - autoHideType: { - value: 'click' - }, - /** - * 是否自动隐藏 - *
    
    -   *
    -   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,overlay之外的元素隐藏
    -   *    trigger : '#t1',
    -   *    autoHide : true,
    -   *    content : '悬浮内容'
    -   *  });
    -   *  overlay.render();
    -   * 
    - * @cfg {Object} autoHide - */ - /** - * 是否自动隐藏 - * @type {Object} - * @ignore - */ - autoHide: { - value: false - }, - /** - * 点击或者移动到此节点时不触发自动隐藏 - *
    
    -   *
    -   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,#t2,overlay之外的元素隐藏
    -   *    trigger : '#t1',
    -   *    autoHide : true,
    -   *    hideExceptNode : '#t2',
    -   *    content : '悬浮内容'
    -   *  });
    -   *  overlay.render();
    -   * 
    - * @cfg {Object} hideExceptNode - */ - hideExceptNode: { - - }, - events: { - value: { - /** - * @event autohide - * 点击控件外部时触发,只有在控件设置自动隐藏(autoHide = true)有效 - * 可以阻止控件隐藏,通过在事件监听函数中 return false - *
    
    -       *  overlay.on('autohide',function(){
    -       *    var curTrigger = overlay.curTrigger; //当前触发的项
    -       *    if(condtion){
    -       *      return false; //阻止隐藏
    -       *    }
    -       *  });
    -       * 
    - */ - autohide: false - } - } -}; - -autoHide.prototype = { - - __bindUI: function() { - var _self = this; - - _self.on('afterVisibleChange', function(ev) { - var visible = ev.newVal; - if (_self.get('autoHide')) { - if (visible) { - _self._bindHideEvent(); - } else { - _self._clearHideEvent(); - } - } - }); - }, - /** - * 处理鼠标移出事件,不影响{BUI.Component.Controller#handleMouseLeave}事件 - * @param {jQuery.Event} ev 事件对象 - */ - handleMoveOuter: function(ev) { - var _self = this, - target = ev.toElement || ev.relatedTarget; - if (!_self.containsElement(target) && !isExcept(_self, target)) { - if (_self.fire('autohide') !== false) { - _self.hide(); - } - } - }, - /** - * 点击页面时的处理函数 - * @param {jQuery.Event} ev 事件对象 - * @protected - */ - handleDocumentClick: function(ev) { - var _self = this, - target = ev.target; - if (!_self.containsElement(target) && !isExcept(_self, target)) { - if (_self.fire('autohide') !== false) { - _self.hide(); - } - } - }, - _bindHideEvent: function() { - var _self = this, - trigger = _self.get('curTrigger'), - autoHideType = _self.get('autoHideType'); - if (autoHideType === 'click') { - $(document).on('mousedown', wrapBehavior(_self, 'handleDocumentClick')); - } else { - _self.get('el').on('mouseleave', wrapBehavior(_self, 'handleMoveOuter')); - if (trigger) { - $(trigger).on('mouseleave', wrapBehavior(_self, 'handleMoveOuter')) - } - } - - }, - //清除绑定的隐藏事件 - _clearHideEvent: function() { - var _self = this, - trigger = _self.get('curTrigger'), - autoHideType = _self.get('autoHideType'); - if (autoHideType === 'click') { - $(document).off('mousedown', getWrapBehavior(_self, 'handleDocumentClick')); - } else { - _self.get('el').off('mouseleave', getWrapBehavior(_self, 'handleMoveOuter')); - if (trigger) { - $(trigger).off('mouseleave', getWrapBehavior(_self, 'handleMoveOuter')) - } - } - } -}; - -module.exports = autoHide; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/autoshow.js b/spm_modules/bui-common/1.1.2/src/component/uibase/autoshow.js deleted file mode 100644 index a9c7f85..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/autoshow.js +++ /dev/null @@ -1,273 +0,0 @@ -/** - * @fileOverview click,focus,hover等引起控件显示,并且定位 - * @ignore - */ - -var $ = require('jquery'); - -/** - * 处理自动显示控件的扩展,一般用于显示menu,picker,tip等 - * @class BUI.Component.UIBase.AutoShow - */ -function autoShow() { - -} - -autoShow.ATTRS = { - - /** - * 触发显示控件的DOM选择器 - *
    
    -   *  var overlay = new Overlay({ //点击#t1时显示,点击#t1,overlay之外的元素隐藏
    -   *    trigger : '#t1',
    -   *    autoHide : true,
    -   *    content : '悬浮内容'
    -   *  });
    -   *  overlay.render();
    -   * 
    - * @cfg {HTMLElement|String|jQuery} trigger - */ - /** - * 触发显示控件的DOM选择器 - * @type {HTMLElement|String|jQuery} - */ - trigger: { - - }, - delegateTigger: { - getter: function() { - this.get('delegateTrigger'); //兼容之前的版本 - }, - setter: function(v) { - this.set('delegateTrigger', v); - } - - }, - /** - * 是否使用代理的方式触发显示控件,如果tigger不是字符串,此属性无效 - *
    
    -   *  var overlay = new Overlay({ //点击.t1(无论创建控件时.t1是否存在)时显示,点击.t1,overlay之外的元素隐藏
    -   *    trigger : '.t1',
    -   *    autoHide : true,
    -   *    delegateTrigger : true, //使用委托的方式触发显示控件
    -   *    content : '悬浮内容'
    -   *  });
    -   *  overlay.render();
    -   * 
    - * @cfg {Boolean} [delegateTrigger = false] - */ - /** - * 是否使用代理的方式触发显示控件,如果tigger不是字符串,此属性无效 - * @type {Boolean} - * @ignore - */ - delegateTrigger: { - value: false - }, - /** - * 选择器是否始终跟随触发器对齐 - * @cfg {Boolean} autoAlign - * @ignore - */ - /** - * 选择器是否始终跟随触发器对齐 - * @type {Boolean} - * @protected - */ - autoAlign: { - value: true - }, - /** - * 显示时是否默认获取焦点 - * @type {Boolean} - */ - autoFocused: { - value: true - }, - /** - * 如果设置了这个样式,那么触发显示(overlay)时trigger会添加此样式 - * @type {Object} - */ - triggerActiveCls: { - - }, - /** - * 控件显示时由此trigger触发,当配置项 trigger 选择器代表多个DOM 对象时, - * 控件可由多个DOM对象触发显示。 - *
    
    -   *  overlay.on('show',function(){
    -   *    var curTrigger = overlay.get('curTrigger');
    -   *    //TO DO
    -   *  });
    -   * 
    - * @type {jQuery} - * @readOnly - */ - curTrigger: { - - }, - /** - * 触发显示时的回调函数 - * @cfg {Function} triggerCallback - * @ignore - */ - /** - * 触发显示时的回调函数 - * @type {Function} - * @ignore - */ - triggerCallback: { - - }, - /** - * 显示菜单的事件 - *
    
    -   *    var overlay = new Overlay({ //移动到#t1时显示,移动出#t1,overlay之外控件隐藏
    -   *      trigger : '#t1',
    -   *      autoHide : true,
    -   *      triggerEvent :'mouseover',
    -   *      autoHideType : 'leave',
    -   *      content : '悬浮内容'
    -   *    });
    -   *    overlay.render();
    -   *
    -   *  
    - * @cfg {String} [triggerEvent='click'] - * @default 'click' - */ - /** - * 显示菜单的事件 - * @type {String} - * @default 'click' - * @ignore - */ - triggerEvent: { - value: 'click' - }, - /** - * 因为触发元素发生改变而导致控件隐藏 - * @cfg {String} triggerHideEvent - * @ignore - */ - /** - * 因为触发元素发生改变而导致控件隐藏 - * @type {String} - * @ignore - */ - triggerHideEvent: { - - }, - events: { - value: { - /** - * 当触发器(触发选择器出现)发生改变时,经常用于一个选择器对应多个触发器的情况 - *
    
    -       *  overlay.on('triggerchange',function(ev){
    -       *    var curTrigger = ev.curTrigger;
    -       *    overlay.set('content',curTrigger.html());
    -       *  });
    -       * 
    - * @event - * @param {Object} e 事件对象 - * @param {jQuery} e.prevTrigger 之前触发器,可能为null - * @param {jQuery} e.curTrigger 当前的触发器 - */ - 'triggerchange': false - } - } -}; - -autoShow.prototype = { - - __createDom: function() { - this._setTrigger(); - }, - __bindUI: function() { - var _self = this, - triggerActiveCls = _self.get('triggerActiveCls'); - if (triggerActiveCls) { - _self.on('hide', function() { - var curTrigger = _self.get('curTrigger'); - if (curTrigger) { - curTrigger.removeClass(triggerActiveCls); - } - }); - } - - }, - _setTrigger: function() { - var _self = this, - triggerEvent = _self.get('triggerEvent'), - triggerHideEvent = _self.get('triggerHideEvent'), - triggerCallback = _self.get('triggerCallback'), - triggerActiveCls = _self.get('triggerActiveCls') || '', - trigger = _self.get('trigger'), - isDelegate = _self.get('delegateTrigger'), - triggerEl = $(trigger); - - //触发显示 - function tiggerShow(ev) { - if (_self.get('disabled')) { //如果禁用则中断 - return; - } - var prevTrigger = _self.get('curTrigger'), - curTrigger = isDelegate ? $(ev.currentTarget) : $(this), - align = _self.get('align'); - if (!prevTrigger || prevTrigger[0] != curTrigger[0]) { - if (prevTrigger) { - prevTrigger.removeClass(triggerActiveCls); - } - _self.set('curTrigger', curTrigger); - _self.fire('triggerchange', { - prevTrigger: prevTrigger, - curTrigger: curTrigger - }); - } - curTrigger.addClass(triggerActiveCls); - if (_self.get('autoAlign')) { - align.node = curTrigger; - - } - _self.set('align', align); - _self.show(); - - - triggerCallback && triggerCallback(ev); - } - - //触发隐藏 - function tiggerHide(ev) { - var toElement = ev.toElement || ev.relatedTarget; - if (!toElement || !_self.containsElement(toElement)) { //mouseleave时,如果移动到当前控件上,取消消失 - _self.hide(); - } - } - - if (triggerEvent) { - if (isDelegate && BUI.isString(trigger)) { - $(document).delegate(trigger, triggerEvent, tiggerShow); - } else { - triggerEl.on(triggerEvent, tiggerShow); - } - - } - - if (triggerHideEvent) { - if (isDelegate && BUI.isString(trigger)) { - $(document).delegate(trigger, triggerHideEvent, tiggerHide); - } else { - triggerEl.on(triggerHideEvent, tiggerHide); - } - } - }, - __renderUI: function() { - var _self = this, - align = _self.get('align'); - //如果控件显示时不是由trigger触发,则同父元素对齐 - if (align && !align.node) { - align.node = _self.get('render') || _self.get('trigger'); - } - } -}; - -module.exports = autoShow; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/base.js b/spm_modules/bui-common/1.1.2/src/component/uibase/base.js deleted file mode 100644 index e915956..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/base.js +++ /dev/null @@ -1,557 +0,0 @@ -/** - * @fileOverview UI控件的流程控制 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -var Manager = require('../manage'), - - UI_SET = '_uiSet', - ATTRS = 'ATTRS', - ucfirst = BUI.ucfirst, - noop = $.noop, - Base = require('../../base'); -/** - * 模拟多继承 - * init attr using constructors ATTRS meta info - * @ignore - */ -function initHierarchy(host, config) { - callMethodByHierarchy(host, 'initializer', 'constructor'); -} - -function callMethodByHierarchy(host, mainMethod, extMethod) { - var c = host.constructor, - extChains = [], - ext, - main, - exts, - t; - - // define - while (c) { - - // 收集扩展类 - t = []; - if (exts = c.mixins) { - for (var i = 0; i < exts.length; i++) { - ext = exts[i]; - if (ext) { - if (extMethod != 'constructor') { - //只调用真正自己构造器原型的定义,继承原型链上的不要管 - if (ext.prototype.hasOwnProperty(extMethod)) { - ext = ext.prototype[extMethod]; - } else { - ext = null; - } - } - ext && t.push(ext); - } - } - } - - // 收集主类 - // 只调用真正自己构造器原型的定义,继承原型链上的不要管 !important - // 所以不用自己在 renderUI 中调用 superclass.renderUI 了,UIBase 构造器自动搜寻 - // 以及 initializer 等同理 - if (c.prototype.hasOwnProperty(mainMethod) && (main = c.prototype[mainMethod])) { - t.push(main); - } - - // 原地 reverse - if (t.length) { - extChains.push.apply(extChains, t.reverse()); - } - - c = c.superclass && c.superclass.constructor; - } - - // 初始化函数 - // 顺序:父类的所有扩展类函数 -> 父类对应函数 -> 子类的所有扩展函数 -> 子类对应函数 - for (i = extChains.length - 1; i >= 0; i--) { - extChains[i] && extChains[i].call(host); - } -} - -/** - * 销毁组件顺序: 子类 destructor -> 子类扩展 destructor -> 父类 destructor -> 父类扩展 destructor - * @ignore - */ -function destroyHierarchy(host) { - var c = host.constructor, - extensions, - d, - i; - - while (c) { - // 只触发该类真正的析构器,和父亲没关系,所以不要在子类析构器中调用 superclass - if (c.prototype.hasOwnProperty('destructor')) { - c.prototype.destructor.apply(host); - } - - if ((extensions = c.mixins)) { - for (i = extensions.length - 1; i >= 0; i--) { - d = extensions[i] && extensions[i].prototype.__destructor; - d && d.apply(host); - } - } - - c = c.superclass && c.superclass.constructor; - } -} - -/** - * 构建 插件 - * @ignore - */ -function constructPlugins(plugins) { - if (!plugins) { - return; - } - BUI.each(plugins, function(plugin, i) { - if (BUI.isFunction(plugin)) { - plugins[i] = new plugin(); - } - }); -} - -/** - * 调用插件的方法 - * @ignore - */ -function actionPlugins(self, plugins, action) { - if (!plugins) { - return; - } - BUI.each(plugins, function(plugin, i) { - if (plugin[action]) { - plugin[action](self); - } - }); -} - -/** - * 根据属性变化设置 UI - * @ignore - */ -function bindUI(self) { - /*var attrs = self.getAttrs(), - attr, - m; - - for (attr in attrs) { - if (attrs.hasOwnProperty(attr)) { - m = UI_SET + ucfirst(attr); - if (self[m]) { - // 自动绑定事件到对应函数 - (function (attr, m) { - self.on('after' + ucfirst(attr) + 'Change', function (ev) { - // fix! 防止冒泡过来的 - if (ev.target === self) { - self[m](ev.newVal, ev); - } - }); - })(attr, m); - } - } - } - */ -} - -/** - * 根据当前(初始化)状态来设置 UI - * @ignore - */ -function syncUI(self) { - var v, - f, - attrs = self.getAttrs(); - for (var a in attrs) { - if (attrs.hasOwnProperty(a)) { - var m = UI_SET + ucfirst(a); - //存在方法,并且用户设置了初始值或者存在默认值,就同步状态 - if ((f = self[m]) - // 用户如果设置了显式不同步,就不同步,比如一些值从 html 中读取,不需要同步再次设置 - && attrs[a].sync !== false && (v = self.get(a)) !== undefined) { - f.call(self, v); - } - } - } -} - -/** - * 控件库的基类,包括控件的生命周期,下面是基本的扩展类 - *

    - * - *

    - * @class BUI.Component.UIBase - * @extends BUI.Base - * @param {Object} config 配置项 - */ -var UIBase = function(config) { - - var _self = this, - id; - - // 读取用户设置的属性值并设置到自身 - Base.apply(_self, arguments); - - //保存用户传入的配置项 - _self.setInternal('userConfig', config); - // 按照类层次执行初始函数,主类执行 initializer 函数,扩展类执行构造器函数 - initHierarchy(_self, config); - - var listener, - n, - plugins = _self.get('plugins') - /*, - listeners = _self.get('listeners')*/ - ; - - constructPlugins(plugins); - - var xclass = _self.get('xclass'); - if (xclass) { - _self.__xclass = xclass; //debug 方便 - } - actionPlugins(_self, plugins, 'initializer'); - - // 是否自动渲染 - config && config.autoRender && _self.render(); - -}; - -UIBase.ATTRS = { - - - /** - * 用户传入的配置项 - * @type {Object} - * @readOnly - * @protected - */ - userConfig: { - - }, - /** - * 是否自动渲染,如果不自动渲染,需要用户调用 render()方法 - *
    
    -   *  //默认状态下创建对象,并没有进行render
    -   *  var control = new Control();
    -   *  control.render(); //需要调用render方法
    -   *
    -   *  //设置autoRender后,不需要调用render方法
    -   *  var control = new Control({
    -   *   autoRender : true
    -   *  });
    -   * 
    - * @cfg {Boolean} autoRender - */ - /** - * 是否自动渲染,如果不自动渲染,需要用户调用 render()方法 - * @type {Boolean} - * @ignore - */ - autoRender: { - value: false - }, - /** - * @type {Object} - * 事件处理函数: - * { - * 'click':function(e){} - * } - * @ignore - */ - listeners: { - value: {} - }, - /** - * 插件集合 - *
    
    -   *  var grid = new Grid({
    -   *    columns : [{},{}],
    -   *    plugins : [Grid.Plugins.RadioSelection]
    -   *  });
    -   * 
    - * @cfg {Array} plugins - */ - /** - * 插件集合 - * @type {Array} - * @readOnly - */ - plugins: { - //value : [] - }, - /** - * 是否已经渲染完成 - * @type {Boolean} - * @default false - * @readOnly - */ - rendered: { - value: false - }, - /** - * 获取控件的 xclass - * @readOnly - * @type {String} - * @protected - */ - xclass: { - valueFn: function() { - return Manager.getXClassByConstructor(this.constructor); - } - } -}; - -BUI.extend(UIBase, Base); - -BUI.augment(UIBase, { - /** - * 创建DOM结构 - * @protected - */ - create: function() { - var self = this; - // 是否生成过节点 - if (!self.get('created')) { - /** - * @event beforeCreateDom - * fired before root node is created - * @param e - */ - self.fire('beforeCreateDom'); - callMethodByHierarchy(self, 'createDom', '__createDom'); - self._set('created', true); - /** - * @event afterCreateDom - * fired when root node is created - * @param e - */ - self.fire('afterCreateDom'); - actionPlugins(self, self.get('plugins'), 'createDom'); - } - return self; - }, - /** - * 渲染 - */ - render: function() { - var _self = this; - // 是否已经渲染过 - if (!_self.get('rendered')) { - var plugins = _self.get('plugins'); - _self.create(undefined); - _self.set('created', true); - /** - * @event beforeRenderUI - * fired when root node is ready - * @param e - */ - _self.fire('beforeRenderUI'); - callMethodByHierarchy(_self, 'renderUI', '__renderUI'); - - /** - * @event afterRenderUI - * fired after root node is rendered into dom - * @param e - */ - - _self.fire('afterRenderUI'); - actionPlugins(_self, plugins, 'renderUI'); - - /** - * @event beforeBindUI - * fired before UIBase 's internal event is bind. - * @param e - */ - - _self.fire('beforeBindUI'); - bindUI(_self); - callMethodByHierarchy(_self, 'bindUI', '__bindUI'); - _self.set('binded', true); - /** - * @event afterBindUI - * fired when UIBase 's internal event is bind. - * @param e - */ - - _self.fire('afterBindUI'); - actionPlugins(_self, plugins, 'bindUI'); - - /** - * @event beforeSyncUI - * fired before UIBase 's internal state is synchronized. - * @param e - */ - - _self.fire('beforeSyncUI'); - - syncUI(_self); - callMethodByHierarchy(_self, 'syncUI', '__syncUI'); - - /** - * @event afterSyncUI - * fired after UIBase 's internal state is synchronized. - * @param e - */ - - _self.fire('afterSyncUI'); - actionPlugins(_self, plugins, 'syncUI'); - _self._set('rendered', true); - } - return _self; - }, - /** - * 子类可继承此方法,当DOM创建时调用 - * @protected - * @method - */ - createDom: noop, - /** - * 子类可继承此方法,渲染UI时调用 - * @protected - * @method - */ - renderUI: noop, - /** - * 子类可继承此方法,绑定事件时调用 - * @protected - * @method - */ - bindUI: noop, - /** - * 同步属性值到UI上 - * @protected - * @method - */ - syncUI: noop, - - /** - * 析构函数 - */ - destroy: function() { - var _self = this; - if (_self.destroyed) { //防止返回销毁 - return _self; - } - /** - * @event beforeDestroy - * fired before UIBase 's destroy. - * @param e - */ - _self.fire('beforeDestroy'); - - actionPlugins(_self, _self.get('plugins'), 'destructor'); - destroyHierarchy(_self); - /** - * @event afterDestroy - * fired before UIBase 's destroy. - * @param e - */ - _self.fire('afterDestroy'); - _self.off(); - _self.clearAttrVals(); - _self.destroyed = true; - return _self; - } -}); - -//延时处理构造函数 -function initConstuctor(c) { - var constructors = []; - while (c.base) { - constructors.push(c); - c = c.base; - } - for (var i = constructors.length - 1; i >= 0; i--) { - var C = constructors[i]; - //BUI.extend(C,C.base,C.px,C.sx); - BUI.mix(C.prototype, C.px); - BUI.mix(C, C.sx); - C.base = null; - C.px = null; - C.sx = null; - } -} - -BUI.mix(UIBase, { - /** - * 定义一个类 - * @static - * @param {Function} base 基类构造函数 - * @param {Array} extensions 扩展 - * @param {Object} px 原型链上的扩展 - * @param {Object} sx - * @return {Function} 继承与基类的构造函数 - */ - define: function(base, extensions, px, sx) { - if ($.isPlainObject(extensions)) { - sx = px; - px = extensions; - extensions = []; - } - - function C() { - var c = this.constructor; - if (c.base) { - initConstuctor(c); - } - UIBase.apply(this, arguments); - } - - BUI.extend(C, base); //无法延迟 - C.base = base; - C.px = px; //延迟复制原型链上的函数 - C.sx = sx; //延迟复制静态属性 - - //BUI.mixin(C,extensions); - if (extensions.length) { //延迟执行mixin - C.extensions = extensions; - } - - return C; - }, - /** - * 扩展一个类,基类就是类本身 - * @static - * @param {Array} extensions 扩展 - * @param {Object} px 原型链上的扩展 - * @param {Object} sx - * @return {Function} 继承与基类的构造函数 - */ - extend: function extend(extensions, px, sx) { - var args = $.makeArray(arguments), - ret, - last = args[args.length - 1]; - args.unshift(this); - if (last.xclass) { - args.pop(); - args.push(last.xclass); - } - ret = UIBase.define.apply(UIBase, args); - if (last.xclass) { - var priority = last.priority || (this.priority ? (this.priority + 1) : 1); - - Manager.setConstructorByXClass(last.xclass, { - constructor: ret, - priority: priority - }); - //方便调试 - ret.__xclass = last.xclass; - ret.priority = priority; - ret.toString = function() { - return last.xclass; - } - } - ret.extend = extend; - return ret; - } -}); - -module.exports = UIBase; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/bindable.js b/spm_modules/bui-common/1.1.2/src/component/uibase/bindable.js deleted file mode 100644 index 55627d5..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/bindable.js +++ /dev/null @@ -1,222 +0,0 @@ -/** - * @fileOverview bindable extension class. - * @author dxq613@gmail.com - * @ignore - */ - -/** - * bindable extension class. - *
    
    - *   BUI.use(['bui/list','bui/data','bui/mask'],function(List,Data,Mask){
    - *     var store = new Data.Store({
    - *       url : 'data/xx.json'
    - *     });
    - *   	var list = new List.SimpleList({
    - *  	    render : '#l1',
    - *  	    store : store,
    - *  	    loadMask : new Mask.LoadMask({el : '#t1'})
    - *     });
    - *
    - *     list.render();
    - *     store.load();
    - *   });
    - * 
    - * 使控件绑定store,处理store的事件 {@link BUI.Data.Store} - * @class BUI.Component.UIBase.Bindable - */ -function bindable() { - -} - -bindable.ATTRS = { - /** - * 绑定 {@link BUI.Data.Store}的事件 - *
    
    -   *  var store = new Data.Store({
    -   *   url : 'data/xx.json',
    -   *   autoLoad : true
    -   *  });
    -   *
    -   *  var list = new List.SimpleList({
    -   *  	 render : '#l1',
    -   *  	 store : store
    -   *  });
    -   *
    -   *  list.render();
    -   * 
    - * @cfg {BUI.Data.Store} store - */ - /** - * 绑定 {@link BUI.Data.Store}的事件 - *
    
    -   *  var store = list.get('store');
    -   * 
    - * @type {BUI.Data.Store} - */ - store: { - - }, - /** - * 加载数据时,是否显示等待加载的屏蔽层 - *
    
    -   *   BUI.use(['bui/list','bui/data','bui/mask'],function(List,Data,Mask){
    -   *     var store = new Data.Store({
    -   *       url : 'data/xx.json'
    -   *     });
    -   *   	var list = new List.SimpleList({
    -   *  	    render : '#l1',
    -   *  	    store : store,
    -   *  	    loadMask : new Mask.LoadMask({el : '#t1'})
    -   *     });
    -   *
    -   *     list.render();
    -   *     store.load();
    -   *   });
    -   * 
    - * @cfg {Boolean|Object} loadMask - */ - /** - * 加载数据时,是否显示等待加载的屏蔽层 - * @type {Boolean|Object} - * @ignore - */ - loadMask: { - value: false - } -}; - - -BUI.augment(bindable, { - - __bindUI: function() { - var _self = this, - store = _self.get('store'), - loadMask = _self.get('loadMask'); - if (!store) { - return; - } - store.on('beforeload', function(e) { - _self.onBeforeLoad(e); - if (loadMask && loadMask.show) { - loadMask.show(); - } - }); - store.on('load', function(e) { - _self.onLoad(e); - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - }); - store.on('exception', function(e) { - _self.onException(e); - if (loadMask && loadMask.hide) { - loadMask.hide(); - } - }); - store.on('add', function(e) { - _self.onAdd(e); - }); - store.on('remove', function(e) { - _self.onRemove(e); - }); - store.on('update', function(e) { - _self.onUpdate(e); - }); - store.on('localsort', function(e) { - _self.onLocalSort(e); - }); - store.on('filtered', function(e) { - _self.onFiltered(e); - }); - }, - __syncUI: function() { - var _self = this, - store = _self.get('store'); - if (!store) { - return; - } - if (store.hasData()) { - _self.onLoad(); - } - }, - /** - * @protected - * @template - * before store load data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-beforeload} - */ - onBeforeLoad: function(e) { - - }, - /** - * @protected - * @template - * after store load data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-load} - */ - onLoad: function(e) { - - }, - /** - * @protected - * @template - * occurred exception when store is loading data - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-exception} - */ - onException: function(e) { - - }, - /** - * @protected - * @template - * after added data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-add} - */ - onAdd: function(e) { - - }, - /** - * @protected - * @template - * after remvoed data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-remove} - */ - onRemove: function(e) { - - }, - /** - * @protected - * @template - * after updated data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-update} - */ - onUpdate: function(e) { - - }, - /** - * @protected - * @template - * after local sorted data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-localsort} - */ - onLocalSort: function(e) { - - }, - /** - * @protected - * @template - * after filter data to store - * @param {Object} e The event object - * @see {@link BUI.Data.Store#event-filtered} - */ - onFiltered: function(e) {} -}); - -module.exports = bindable; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/childCfg.js b/spm_modules/bui-common/1.1.2/src/component/uibase/childCfg.js deleted file mode 100644 index 745c03c..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/childCfg.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @fileOverview 子控件的默认配置项 - * @ignore - */ - -var $ = require('jquery'); - -/** - * @class BUI.Component.UIBase.ChildCfg - * 子控件默认配置项的扩展类 - */ -var childCfg = function(config) { - this._init(); -}; - -childCfg.ATTRS = { - /** - * 默认的子控件配置项,在初始化控件时配置 - * - * - 如果控件已经渲染过,此配置项无效, - * - 控件生成后,修改此配置项无效。 - *
    
    -   *   var control = new Control({
    -   *     defaultChildCfg : {
    -   *       tpl : '<li>{text}</li>',
    -   *       xclass : 'a-b'
    -   *     }
    -   *   });
    -   * 
    - * @cfg {Object} defaultChildCfg - */ - /** - * @ignore - */ - defaultChildCfg: { - - } -}; - -childCfg.prototype = { - - _init: function() { - var _self = this, - defaultChildCfg = _self.get('defaultChildCfg'); - if (defaultChildCfg) { - _self.on('beforeAddChild', function(ev) { - var child = ev.child; - if ($.isPlainObject(child)) { - BUI.each(defaultChildCfg, function(v, k) { - if (child[k] == null) { //如果未在配置项中设置,则使用默认值 - child[k] = v; - } - }); - } - }); - } - } - -}; - -module.exports = childCfg; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/close.js b/spm_modules/bui-common/1.1.2/src/component/uibase/close.js deleted file mode 100644 index ff9b006..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/close.js +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @fileOverview close 关闭或隐藏控件 - * @author yiminghe@gmail.com - * copied and modified by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'); - - -var CLS_PREFIX = BUI.prefix + 'ext-'; - -function getCloseRenderBtn(self) { - return $(self.get('closeTpl')); -} - -/** - * 关闭按钮的视图类 - * @class BUI.Component.UIBase.CloseView - * @private - */ -function CloseView() {} - -CloseView.ATTRS = { - closeTpl: { - value: '' + - '关闭<' + '/span>' + - '<' + '/a>' - }, - closeable: { - value: true - }, - closeBtn: {} -}; - -CloseView.prototype = { - _uiSetCloseable: function(v) { - var self = this, - btn = self.get('closeBtn'); - if (v) { - if (!btn) { - self.setInternal('closeBtn', btn = getCloseRenderBtn(self)); - } - btn.appendTo(self.get('el'), undefined); - } else { - if (btn) { - btn.remove(); - } - } - } -}; - -/** - * @class BUI.Component.UIBase.Close - * Close extension class. - * Represent a close button. - */ -function Close() {} - -var HIDE = 'hide'; -Close.ATTRS = { - /** - * 关闭按钮的默认模版 - *
    
    -   *   var overlay = new Overlay({
    -   *     closeTpl : 'x',
    -   *     closeable : true,
    -   *     trigger : '#t1'
    -   *   });
    -   *   overlay.render();
    -   * 
    - * @cfg {String} closeTpl - */ - /** - * 关闭按钮的默认模版 - * @type {String} - * @protected - */ - closeTpl: { - view: true - }, - /** - * 是否出现关闭按钮 - * @cfg {Boolean} [closeable = false] - */ - /** - * 是否出现关闭按钮 - * @type {Boolean} - */ - closeable: { - view: 1 - }, - - /** - * 关闭按钮. - * @protected - * @type {jQuery} - */ - closeBtn: { - view: 1 - }, - /** - * 关闭时隐藏还是移除DOM结构
    - * - * - "hide" : default 隐藏. - * - "destroy":当点击关闭按钮时移除(destroy)控件 - * - 'remove' : 当存在父控件时使用remove,同时从父元素中删除 - * @cfg {String} [closeAction = 'hide'] - */ - /** - * 关闭时隐藏还是移除DOM结构 - * default "hide".可以设置 "destroy" ,当点击关闭按钮时移除(destroy)控件 - * @type {String} - * @protected - */ - closeAction: { - value: HIDE - } - - /** - * @event closing - * 正在关闭,可以通过return false 阻止关闭事件 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event beforeclosed - * 关闭前,发生在closing后,closed前,用于处理关闭前的一些工作 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event closed - * 已经关闭 - * @param {Object} e 关闭事件 - * @param {String} e.action 关闭执行的行为,hide,destroy,remove - */ - - /** - * @event closeclick - * 触发点击关闭按钮的事件,return false 阻止关闭 - * @param {Object} e 关闭事件 - * @param {String} e.domTarget 点击的关闭按钮节点 - */ -}; - -var actions = { - hide: HIDE, - destroy: 'destroy', - remove: 'remove' -}; - -Close.prototype = { - _uiSetCloseable: function(v) { - var self = this; - if (v && !self.__bindCloseEvent) { - self.__bindCloseEvent = 1; - self.get('closeBtn').on('click', function(ev) { - if (self.fire('closeclick', { - domTarget: ev.target - }) !== false) { - self.close(); - } - ev.preventDefault(); - }); - } - }, - __destructor: function() { - var btn = this.get('closeBtn'); - btn && btn.detach(); - }, - /** - * 关闭弹出框,如果closeAction = 'hide'那么就是隐藏,如果 closeAction = 'destroy'那么就是释放,'remove'从父控件中删除,并释放 - */ - close: function() { - var self = this, - action = actions[self.get('closeAction') || HIDE]; - if (self.fire('closing', { - action: action - }) !== false) { - self.fire('beforeclosed', { - action: action - }); - if (action == 'remove') { //移除时同时destroy - self[action](true); - } else { - self[action](); - } - self.fire('closed', { - action: action - }); - } - } -}; - -Close.View = CloseView; - -module.exports = Close; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/collapsable.js b/spm_modules/bui-common/1.1.2/src/component/uibase/collapsable.js deleted file mode 100644 index 08479d5..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/collapsable.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @fileOverview 可以展开折叠的控件 - * @ignore - */ - - -/** - * 控件展开折叠的视图类 - * @class BUI.Component.UIBase.CollapsableView - * @private - */ -var collapsableView = function() { - -}; - -collapsableView.ATTRS = { - collapsed: {} -} - -collapsableView.prototype = { - //设置收缩样式 - _uiSetCollapsed: function(v) { - var _self = this, - cls = _self.getStatusCls('collapsed'), - el = _self.get('el'); - if (v) { - el.addClass(cls); - } else { - el.removeClass(cls); - } - } -} -/** - * 控件展开折叠的扩展 - * @class BUI.Component.UIBase.Collapsable - */ -var collapsable = function() { - -}; - -collapsable.ATTRS = { - /** - * 是否可折叠 - * @type {Boolean} - */ - collapsable: { - value: false - }, - /** - * 是否已经折叠 collapsed - * @cfg {Boolean} collapsed - */ - /** - * 是否已经折叠 - * @type {Boolean} - */ - collapsed: { - view: true, - value: false - }, - events: { - value: { - /** - * 控件展开 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} target 控件 - */ - 'expanded': true, - /** - * 控件折叠 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.Controller} target 控件 - */ - 'collapsed': true - } - } -}; - -collapsable.prototype = { - _uiSetCollapsed: function(v) { - var _self = this; - if (v) { - _self.fire('collapsed'); - } else { - _self.fire('expanded'); - } - } -}; - -collapsable.View = collapsableView; - -module.exports = collapsable; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/decorate.js b/spm_modules/bui-common/1.1.2/src/component/uibase/decorate.js deleted file mode 100644 index e5a7520..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/decorate.js +++ /dev/null @@ -1,335 +0,0 @@ -/** - * @fileOverview 使用wrapper - * @ignore - */ - - -var $ = require('jquery'), - ArrayUtil = require('../../array'), - JSON = require('../../json'), - prefixCls = BUI.prefix, - FIELD_PREFIX = 'data-', - FIELD_CFG = FIELD_PREFIX + 'cfg', - PARSER = 'PARSER', - Manager = require('../manage'), - RE_DASH_WORD = /-([a-z])/g, - regx = /^[\{\[]/; - -function isConfigField(name, cfgFields) { - if (cfgFields[name]) { - return true; - } - var reg = new RegExp("^" + FIELD_PREFIX); - if (name !== FIELD_CFG && reg.test(name)) { - return true; - } - return false; -} - -// 收集单继承链,子类在前,父类在后 -function collectConstructorChains(self) { - var constructorChains = [], - c = self.constructor; - while (c) { - constructorChains.push(c); - c = c.superclass && c.superclass.constructor; - } - return constructorChains; -} - -function camelCase(str) { - return str.toLowerCase().replace(RE_DASH_WORD, function(all, letter) { - return (letter + '').toUpperCase() - }) -} - -//如果属性为对象或者数组,则进行转换 -function parseFieldValue(value) { - - value = $.trim(value); - if (value.toLowerCase() === 'false') { - value = false - } else if (value.toLowerCase() === 'true') { - value = true - } else if (regx.test(value)) { - value = JSON.looseParse(value); - } else if (/\d/.test(value) && /[^a-z]/i.test(value)) { - var number = parseFloat(value) - if (number + '' === value) { - value = number - } - } - - return value; -} - -function setConfigFields(self, cfg) { - - var userConfig = self.userConfig || {}; - for (var p in cfg) { - // 用户设置过那么这里不从 dom 节点取 - // 用户设置 > html parser > default value - if (!(p in userConfig)) { - self.setInternal(p, cfg[p]); - } - } -} - -function applyParser(srcNode, parser) { - var self = this, - p, v, - userConfig = self.userConfig || {}; - - // 从 parser 中,默默设置属性,不触发事件 - for (p in parser) { - // 用户设置过那么这里不从 dom 节点取 - // 用户设置 > html parser > default value - if (!(p in userConfig)) { - v = parser[p]; - // 函数 - if (BUI.isFunction(v)) { - self.setInternal(p, v.call(self, srcNode)); - } - // 单选选择器 - else if (typeof v == 'string') { - self.setInternal(p, srcNode.find(v)); - } - // 多选选择器 - else if (BUI.isArray(v) && v[0]) { - self.setInternal(p, srcNode.find(v[0])) - } - } - } -} - -function initParser(self, srcNode) { - - var c = self.constructor, - len, - p, - constructorChains; - - constructorChains = collectConstructorChains(self); - - // 从父类到子类开始从 html 读取属性 - for (len = constructorChains.length - 1; len >= 0; len--) { - c = constructorChains[len]; - if (p = c[PARSER]) { - applyParser.call(self, srcNode, p); - } - } -} - -function initDecorate(self) { - var _self = self, - srcNode = _self.get('srcNode'), - userConfig, - decorateCfg; - if (srcNode) { - srcNode = $(srcNode); - _self.setInternal('el', srcNode); - _self.setInternal('srcNode', srcNode); - - userConfig = _self.get('userConfig'); - decorateCfg = _self.getDecorateConfig(srcNode); - setConfigFields(self, decorateCfg); - - //如果从DOM中读取子控件 - if (_self.get('isDecorateChild') && _self.decorateInternal) { - _self.decorateInternal(srcNode); - } - initParser(self, srcNode); - } -} - -/** - * @class BUI.Component.UIBase.Decorate - * 将DOM对象封装成控件 - */ -function decorate() { - initDecorate(this); -} - -decorate.ATTRS = { - - /** - * 配置控件的根节点的DOM - *
    
    -   * new Form.Form({
    -   *   srcNode : '#J_Form'
    -   * }).render();
    -   * 
    - * @cfg {jQuery} srcNode - */ - /** - * 配置控件的根节点的DOM - * @type {jQuery} - */ - srcNode: { - view: true - }, - /** - * 是否根据DOM生成子控件 - * @type {Boolean} - * @protected - */ - isDecorateChild: { - value: false - }, - /** - * 此配置项配置使用那些srcNode上的节点作为配置项 - * - 当时用 decorate 时,取 srcNode上的节点的属性作为控件的配置信息 - * - 默认id,name,value,title 都会作为属性传入 - * - 使用 'data-cfg' 作为整体的配置属性 - *
    
    -   *     
    -   *     //会生成以下配置项:
    -   *     {
    -   *         name : 'txtName',
    -   *         id : 'id',
    -   *         allowBlank:false
    -   *     }
    -   *     new Form.Field({
    -   *        src:'#c1'
    -   *     }).render();
    -   *  
    - * @type {Object} - * @protected - */ - decorateCfgFields: { - value: { - 'id': true, - 'name': true, - 'value': true, - 'title': true - } - } -}; - -decorate.prototype = { - - /** - * 获取控件的配置信息 - * @protected - */ - getDecorateConfig: function(el) { - if (!el.length) { - return null; - } - var _self = this, - dom = el[0], - attributes = dom.attributes, - decorateCfgFields = _self.get('decorateCfgFields'), - config = {}, - statusCfg = _self._getStautsCfg(el); - - BUI.each(attributes, function(attr) { - var name = attr.nodeName; - try { - if (name === FIELD_CFG) { - var cfg = parseFieldValue(attr.nodeValue); - BUI.mix(config, cfg); - } else if (isConfigField(name, decorateCfgFields)) { - var value = attr.nodeValue; - if (name.indexOf(FIELD_PREFIX) !== -1) { - name = name.replace(FIELD_PREFIX, ''); - name = camelCase(name); - value = parseFieldValue(value); - } - - if (config[name] && BUI.isObject(value)) { - BUI.mix(config[name], value); - } else { - config[name] = value; - } - } - } catch (e) { - BUI.log('parse field error,the attribute is:' + name); - } - }); - return BUI.mix(config, statusCfg); - }, - //根据css class获取状态属性 - //如: selected,disabled等属性 - _getStautsCfg: function(el) { - var _self = this, - rst = {}, - statusCls = _self.get('statusCls'); - BUI.each(statusCls, function(v, k) { - if (el.hasClass(v)) { - rst[k] = true; - } - }); - return rst; - }, - /** - * 获取封装成子控件的节点集合 - * @protected - * @return {Array} 节点集合 - */ - getDecorateElments: function() { - var _self = this, - el = _self.get('el'), - contentContainer = _self.get('childContainer'); - if (contentContainer) { - return el.find(contentContainer).children(); - } else { - return el.children(); - } - }, - - /** - * 封装所有的子控件 - * @protected - * @param {jQuery} el Root element of current component. - */ - decorateInternal: function(el) { - var self = this; - self.decorateChildren(el); - }, - /** - * 获取子控件的xclass类型 - * @protected - * @param {jQuery} childNode 子控件的根节点 - */ - findXClassByNode: function(childNode, ignoreError) { - var _self = this, - cls = childNode.attr("class") || '', - childClass = _self.get('defaultChildClass'); //如果没有样式或者查找不到对应的类,使用默认的子控件类型 - - // 过滤掉特定前缀 - cls = cls.replace(new RegExp("\\b" + prefixCls, "ig"), ""); - - var UI = Manager.getConstructorByXClass(cls) || Manager.getConstructorByXClass(childClass); - - if (!UI && !ignoreError) { - BUI.log(childNode); - BUI.error("can not find ui " + cls + " from this markup"); - } - return Manager.getXClassByConstructor(UI); - }, - // 生成一个组件 - decorateChildrenInternal: function(xclass, c) { - var _self = this, - children = _self.get('children'); - children.push({ - xclass: xclass, - srcNode: c - }); - }, - /** - * 封装子控件 - * @private - * @param {jQuery} el component's root element. - */ - decorateChildren: function(el) { - var _self = this, - children = _self.getDecorateElments(); - BUI.each(children, function(c) { - var xclass = _self.findXClassByNode($(c)); - _self.decorateChildrenInternal(xclass, $(c)); - }); - } -}; - -module.exports = decorate; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/depends.js b/spm_modules/bui-common/1.1.2/src/component/uibase/depends.js deleted file mode 100644 index b3cdceb..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/depends.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @fileOverview 依赖扩展,用于观察者模式中的观察者 - * @ignore - */ - - -var $ = require('jquery'), - regexp = /^#(.*):(.*)$/, - Manager = require('../manage'); - -//获取依赖信息 -function getDepend(name) { - - var arr = regexp.exec(name), - id = arr[1], - eventType = arr[2], - source = getSource(id); - return { - source: source, - eventType: eventType - }; -} - -//绑定依赖 -function bindDepend(self, name, action) { - var depend = getDepend(name), - source = depend.source, - eventType = depend.eventType, - callbak; - if (source && action && eventType) { - - if (BUI.isFunction(action)) { //如果action是一个函数 - callbak = action; - } else if (BUI.isArray(action)) { //如果是一个数组,构建一个回调函数 - callbak = function() { - BUI.each(action, function(methodName) { - if (self[methodName]) { - self[methodName](); - } - }); - } - } - } - if (callbak) { - depend.callbak = callbak; - source.on(eventType, callbak); - return depend; - } - return null; -} -//去除依赖 -function offDepend(depend) { - var source = depend.source, - eventType = depend.eventType, - callbak = depend.callbak; - source.off(eventType, callbak); -} - -//获取绑定的事件源 -function getSource(id) { - var control = Manager.getComponent(id); - if (!control) { - control = $('#' + id); - if (!control.length) { - control = null; - } - } - return control; -} - -/** - * @class BUI.Component.UIBase.Depends - * 依赖事件源的扩展 - *
    
    - *       var control = new Control({
    - *         depends : {
    - *           '#btn:click':['toggle'],//当点击id为'btn'的按钮时,执行 control 的toggle方法
    - *           '#checkbox1:checked':['show'],//当勾选checkbox时,显示控件
    - *           '#menu:click',function(){}
    - *         }
    - *       });
    - * 
    - */ -function Depends() { - -}; - -Depends.ATTRS = { - /** - * 控件的依赖事件,是一个数组集合,每一条记录是一个依赖关系
    - * 一个依赖是注册一个事件,所以需要在一个依赖中提供: - *
      - *
    1. 绑定源:为了方便配置,我们使用 #id来指定绑定源,可以使控件的ID(只支持继承{BUI.Component.Controller}的控件),也可以是DOM的id
    2. - *
    3. 事件名:事件名是一个使用":"为前缀的字符串,例如 "#id:change",即监听change事件
    4. - *
    5. 触发的方法:可以是一个数组,如["disable","clear"],数组里面是控件的方法名,也可以是一个回调函数
    6. - *
    - *
    
    -   *       var control = new Control({
    -   *         depends : {
    -   *           '#btn:click':['toggle'],//当点击id为'btn'的按钮时,执行 control 的toggle方法
    -   *           '#checkbox1:checked':['show'],//当勾选checkbox时,显示控件
    -   *           '#menu:click',function(){}
    -   *         }
    -   *       });
    -   * 
    - * ** 注意:** 这些依赖项是在控件渲染(render)后进行的。 - * @type {Object} - */ - depends: { - - }, - /** - * @private - * 依赖的映射集合 - * @type {Object} - */ - dependencesMap: { - shared: false, - value: {} - } -}; - -Depends.prototype = { - - __syncUI: function() { - this.initDependences(); - }, - /** - * 初始化依赖项 - * @protected - */ - initDependences: function() { - var _self = this, - depends = _self.get('depends'); - BUI.each(depends, function(action, name) { - _self.addDependence(name, action); - }); - }, - /** - * 添加依赖,如果已经有同名的事件,则移除,再添加 - *
    
    -   *  form.addDependence('#btn:click',['toggle']); //当按钮#btn点击时,表单交替显示隐藏
    -   *
    -   *  form.addDependence('#btn:click',function(){//当按钮#btn点击时,表单交替显示隐藏
    -   *   //TO DO
    -   *  });
    -   * 
    - * @param {String} name 依赖项的名称 - * @param {Array|Function} action 依赖项的事件 - */ - addDependence: function(name, action) { - var _self = this, - dependencesMap = _self.get('dependencesMap'), - depend; - _self.removeDependence(name); - depend = bindDepend(_self, name, action) - if (depend) { - dependencesMap[name] = depend; - } - }, - /** - * 移除依赖 - *
    
    -   *  form.removeDependence('#btn:click'); //当按钮#btn点击时,表单不在监听
    -   * 
    - * @param {String} name 依赖名称 - */ - removeDependence: function(name) { - var _self = this, - dependencesMap = _self.get('dependencesMap'), - depend = dependencesMap[name]; - if (depend) { - offDepend(depend); - delete dependencesMap[name]; - } - }, - /** - * 清除所有的依赖 - *
    
    -   *  form.clearDependences();
    -   * 
    - */ - clearDependences: function() { - var _self = this, - map = _self.get('dependencesMap'); - BUI.each(map, function(depend, name) { - offDepend(depend); - }); - _self.set('dependencesMap', {}); - }, - __destructor: function() { - this.clearDependences(); - } - -}; - -module.exports = Depends; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/drag.js b/spm_modules/bui-common/1.1.2/src/component/uibase/drag.js deleted file mode 100644 index 78ee9c4..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/drag.js +++ /dev/null @@ -1,236 +0,0 @@ -/** - * @fileOverview 拖拽 - * @author by dxq613@gmail.com - * @ignore - */ - - - -var $ = require('jquery'), - dragBackId = BUI.guid('drag'); - -/** - * 拖拽控件的扩展 - *
    
    - *  var Control = Overlay.extend([UIBase.Drag],{
    - *
    - *  });
    - *
    - *  var c = new Contol({ //拖动控件时,在#t2内
    - *      content : '
    ', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
    - * @class BUI.Component.UIBase.Drag - */ -var drag = function() { - -}; - -drag.ATTRS = { - - /** - * 点击拖动的节点 - *
    
    -   *  var Control = Overlay.extend([UIBase.Drag],{
    -   *
    -   *  });
    -   *
    -   *  var c = new Contol({ //拖动控件时,在#t2内
    -   *      content : '
    ', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
    - * @cfg {jQuery} dragNode - */ - /** - * 点击拖动的节点 - * @type {jQuery} - * @ignore - */ - dragNode: { - - }, - /** - * 是否正在拖动 - * @type {Boolean} - * @protected - */ - draging: { - setter: function(v) { - if (v === true) { - return {}; - } - }, - value: null - }, - /** - * 拖动的限制范围 - *
    
    -   *  var Control = Overlay.extend([UIBase.Drag],{
    -   *
    -   *  });
    -   *
    -   *  var c = new Contol({ //拖动控件时,在#t2内
    -   *      content : '
    ', - * dragNode : '#header', - * constraint : '#t2' - * }); - *
    - * @cfg {jQuery} constraint - */ - /** - * 拖动的限制范围 - * @type {jQuery} - * @ignore - */ - constraint: { - - }, - /** - * @private - * @type {jQuery} - */ - dragBackEl: { - /** @private **/ - getter: function() { - return $('#' + dragBackId); - } - } -}; -var dragTpl = ''; - -function initBack() { - var el = $(dragTpl).css('opacity', 0).prependTo('body'); - return el; -} -drag.prototype = { - - __bindUI: function() { - var _self = this, - constraint = _self.get('constraint'), - dragNode = _self.get('dragNode'); - if (!dragNode) { - return; - } - dragNode.on('mousedown', function(e) { - - if (e.which == 1) { - e.preventDefault(); - _self.set('draging', { - elX: _self.get('x'), - elY: _self.get('y'), - startX: e.pageX, - startY: e.pageY - }); - registEvent(); - } - }); - /** - * @private - */ - function mouseMove(e) { - var draging = _self.get('draging'); - if (draging) { - e.preventDefault(); - _self._dragMoveTo(e.pageX, e.pageY, draging, constraint); - } - } - /** - * @private - */ - function mouseUp(e) { - if (e.which == 1) { - _self.set('draging', false); - var dragBackEl = _self.get('dragBackEl'); - if (dragBackEl) { - dragBackEl.hide(); - } - unregistEvent(); - } - } - /** - * @private - */ - function registEvent() { - $(document).on('mousemove', mouseMove); - $(document).on('mouseup', mouseUp); - } - /** - * @private - */ - function unregistEvent() { - $(document).off('mousemove', mouseMove); - $(document).off('mouseup', mouseUp); - } - - }, - _dragMoveTo: function(x, y, draging, constraint) { - var _self = this, - dragBackEl = _self.get('dragBackEl'), - draging = draging || _self.get('draging'), - offsetX = draging.startX - x, - offsetY = draging.startY - y; - if (!dragBackEl.length) { - dragBackEl = initBack(); - } - dragBackEl.css({ - cursor: 'move', - display: 'block' - }); - _self.set('xy', [_self._getConstrainX(draging.elX - offsetX, constraint), - _self._getConstrainY(draging.elY - offsetY, constraint) - ]); - - }, - _getConstrainX: function(x, constraint) { - var _self = this, - width = _self.get('el').outerWidth(), - endX = x + width, - curX = _self.get('x'); - //如果存在约束 - if (constraint) { - var constraintOffset = constraint.offset(); - if (constraintOffset.left >= x) { - return constraintOffset.left; - } - if (constraintOffset.left + constraint.width() < endX) { - return constraintOffset.left + constraint.width() - width; - } - return x; - } - //当左右顶点都在视图内,移动到此点 - if (BUI.isInHorizontalView(x) && BUI.isInHorizontalView(endX)) { - return x; - } - - return curX; - }, - _getConstrainY: function(y, constraint) { - var _self = this, - height = _self.get('el').outerHeight(), - endY = y + height, - curY = _self.get('y'); - //如果存在约束 - if (constraint) { - var constraintOffset = constraint.offset(); - if (constraintOffset.top > y) { - return constraintOffset.top; - } - if (constraintOffset.top + constraint.height() < endY) { - return constraintOffset.top + constraint.height() - height; - } - return y; - } - //当左右顶点都在视图内,移动到此点 - if (BUI.isInVerticalView(y) && BUI.isInVerticalView(endY)) { - return y; - } - - return curY; - } -}; - -module.exports = drag; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/keynav.js b/spm_modules/bui-common/1.1.2/src/component/uibase/keynav.js deleted file mode 100644 index 6a571d1..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/keynav.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @fileOverview 使用键盘导航 - * @ignore - */ - - - var $ = require('jquery'), - KeyCode = require('../../keycode'), - wrapBehavior = BUI.wrapBehavior, - getWrapBehavior = BUI.getWrapBehavior; - /** - * 键盘导航 - * @class BUI.Component.UIBase.KeyNav - */ - var keyNav = function() { - - }; - - keyNav.ATTRS = { - - /** - * 是否允许键盘导航 - * @cfg {Boolean} [allowKeyNav = true] - */ - allowKeyNav: { - value: true - }, - /** - * 导航使用的事件 - * @cfg {String} [navEvent = 'keydown'] - */ - navEvent: { - value: 'keydown' - }, - /** - * 当获取事件的DOM是 input,textarea,select等时,不处理键盘导航 - * @cfg {Object} [ignoreInputFields='true'] - */ - ignoreInputFields: { - value: true - } - - }; - - keyNav.prototype = { - - __bindUI: function() { - - }, - _uiSetAllowKeyNav: function(v) { - var _self = this, - eventName = _self.get('navEvent'), - el = _self.get('el'); - if (v) { - el.on(eventName, wrapBehavior(_self, '_handleKeyDown')); - } else { - el.off(eventName, getWrapBehavior(_self, '_handleKeyDown')); - } - }, - /** - * 处理键盘导航 - * @private - */ - _handleKeyDown: function(ev) { - var _self = this, - ignoreInputFields = _self.get('ignoreInputFields'), - code = ev.which; - if (ignoreInputFields && $(ev.target).is('input,select,textarea')) { - return; - } - - switch (code) { - case KeyCode.UP: - //ev.preventDefault(); - _self.handleNavUp(ev); - break; - case KeyCode.DOWN: - //ev.preventDefault(); - _self.handleNavDown(ev); - break; - case KeyCode.RIGHT: - // ev.preventDefault(); - _self.handleNavRight(ev); - break; - case KeyCode.LEFT: - //ev.preventDefault(); - _self.handleNavLeft(ev); - break; - case KeyCode.ENTER: - _self.handleNavEnter(ev); - break; - case KeyCode.ESC: - _self.handleNavEsc(ev); - break; - case KeyCode.TAB: - _self.handleNavTab(ev); - break; - default: - break; - } - }, - /** - * 处理向上导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavUp: function(ev) { - // body... - }, - /** - * 处理向下导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavDown: function(ev) { - // body... - }, - /** - * 处理向左导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavLeft: function(ev) { - // body... - }, - /** - * 处理向右导航 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavRight: function(ev) { - // body... - }, - /** - * 处理确认键 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavEnter: function(ev) { - // body... - }, - /** - * 处理 esc 键 - * @protected - * @param {jQuery.Event} ev 事件对象 - */ - handleNavEsc: function(ev) { - // body... - }, - /** - * 处理Tab键 - * @param {jQuery.Event} ev 事件对象 - */ - handleNavTab: function(ev) { - - } - - }; - -module.exports = keyNav; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/list.js b/spm_modules/bui-common/1.1.2/src/component/uibase/list.js deleted file mode 100644 index 7296fd7..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/list.js +++ /dev/null @@ -1,671 +0,0 @@ -/** - * @fileOverview 所有子元素都是同一类的集合 - * @ignore - */ - - -var $ = require('jquery'), - Selection = require('./selection'); - -/** - * 列表一类的控件的扩展,list,menu,grid都是可以从此类扩展 - * @class BUI.Component.UIBase.List - */ -var list = function() { - -}; - -list.ATTRS = { - - /** - * 选择的数据集合 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{value}">{text}</li>',
    -   *   idField : 'value',
    -   *   render : '#t1',
    -   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
    -   * });
    -   * list.render();
    -   * 
    - * @cfg {Array} items - */ - /** - * 选择的数据集合 - *
    
    -   *  list.set('items',items); //列表会直接替换内容
    -   *  //等同于
    -   *  list.clearItems();
    -   *  list.addItems(items);
    -   * 
    - * @type {Array} - */ - items: { - shared: false, - view: true - }, - /** - * 选项的默认key值 - * @cfg {String} [idField = 'id'] - */ - idField: { - value: 'id' - }, - /** - * 列表项的默认模板,仅在初始化时传入。 - * @type {String} - * @ignore - */ - itemTpl: { - view: true - }, - /** - * 列表项的渲染函数,应对列表项之间有很多差异时 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTplRender : function(item){
    -   *     if(item.type == '1'){
    -   *       return '<li><img src="xxx.jpg"/>'+item.text+'</li>'
    -   *     }else{
    -   *       return '<li>item.text</li>'
    -   *     }
    -   *   },
    -   *   idField : 'value',
    -   *   render : '#t1',
    -   *   items : [{value : '1',text : '1',type : '0'},{value : '2',text : '2',type : '1'}]
    -   * });
    -   * list.render();
    -   * 
    - * @type {Function} - */ - itemTplRender: { - view: true - }, - /** - * 子控件各个状态默认采用的样式 - *
    
    -   * var list = new List.SimpleList({
    -   *   render : '#t1',
    -   *   itemStatusCls : {
    -   *     selected : 'active', //默认样式为list-item-selected,现在变成'active'
    -   *     hover : 'hover' //默认样式为list-item-hover,现在变成'hover'
    -   *   },
    -   *   items : [{id : '1',text : '1',type : '0'},{id : '2',text : '2',type : '1'}]
    -   * });
    -   * list.render();
    -   * 
    - * see {@link BUI.Component.Controller#property-statusCls} - * @type {Object} - */ - itemStatusCls: { - view: true, - value: {} - }, - events: { - - value: { - /** - * 选项点击事件 - * @event - * @param {Object} e 事件对象 - * @param {BUI.Component.UIBase.ListItem} e.item 点击的选项 - * @param {HTMLElement} e.element 选项代表的DOM对象 - * @param {HTMLElement} e.domTarget 点击的DOM对象 - * @param {HTMLElement} e.domEvent 点击的原生事件对象 - */ - 'itemclick': true - } - } -}; - -list.prototype = { - - /** - * 获取选项的数量 - *
    
    -   *   var count = list.getItemCount();
    -   * 
    - * @return {Number} 选项数量 - */ - getItemCount: function() { - return this.getItems().length; - }, - /** - * 获取字段的值 - * @param {*} item 字段名 - * @param {String} field 字段名 - * @return {*} 字段的值 - * @protected - */ - getValueByField: function(item, field) { - - }, - /** - * 获取所有选项值,如果选项是子控件,则是所有子控件 - *
    
    -   *   var items = list.getItems();
    -   *   //等同
    -   *   list.get(items);
    -   * 
    - * @return {Array} 选项值集合 - */ - getItems: function() { - - }, - /** - * 获取第一项 - *
    
    -   *   var item = list.getFirstItem();
    -   *   //等同
    -   *   list.getItemAt(0);
    -   * 
    - * @return {Object|BUI.Component.Controller} 选项值(子控件) - */ - getFirstItem: function() { - return this.getItemAt(0); - }, - /** - * 获取最后一项 - *
    
    -   *   var item = list.getLastItem();
    -   *   //等同
    -   *   list.getItemAt(list.getItemCount()-1);
    -   * 
    - * @return {Object|BUI.Component.Controller} 选项值(子控件) - */ - getLastItem: function() { - return this.getItemAt(this.getItemCount() - 1); - }, - /** - * 通过索引获取选项值(子控件) - *
    
    -   *   var item = list.getItemAt(0); //获取第1个
    -   *   var item = list.getItemAt(2); //获取第3个
    -   * 
    - * @param {Number} index 索引值 - * @return {Object|BUI.Component.Controller} 选项(子控件) - */ - getItemAt: function(index) { - return this.getItems()[index] || null; - }, - /** - * 通过Id获取选项,如果是改变了idField则通过改变的idField来查找选项 - *
    
    -   *   //如果idField = 'id'
    -   *   var item = list.getItem('2');
    -   *   //等同于
    -   *   list.findItemByField('id','2');
    -   *
    -   *   //如果idField = 'value'
    -   *   var item = list.getItem('2');
    -   *   //等同于
    -   *   list.findItemByField('value','2');
    -   * 
    - * @param {String} id 编号 - * @return {Object|BUI.Component.Controller} 选项(子控件) - */ - getItem: function(id) { - var field = this.get('idField'); - return this.findItemByField(field, id); - }, - /** - * 返回指定项的索引 - *
    
    -   * var index = list.indexOf(item); //返回索引,不存在则返回-1
    -   * 
    - * @param {Object|BUI.Component.Controller} item 选项 - * @return {Number} 项的索引值 - */ - indexOfItem: function(item) { - return BUI.Array.indexOf(item, this.getItems()); - }, - /** - * 添加多条选项 - *
    
    -   * var items = [{id : '1',text : '1'},{id : '2',text : '2'}];
    -   * list.addItems(items);
    -   * 
    - * @param {Array} items 记录集合(子控件配置项) - */ - addItems: function(items) { - var _self = this; - BUI.each(items, function(item) { - _self.addItem(item); - }); - }, - /** - * 插入多条记录 - *
    
    -   * var items = [{id : '1',text : '1'},{id : '2',text : '2'}];
    -   * list.addItemsAt(items,0); // 在最前面插入
    -   * list.addItemsAt(items,2); //第三个位置插入
    -   * 
    - * @param {Array} items 多条记录 - * @param {Number} start 起始位置 - */ - addItemsAt: function(items, start) { - var _self = this; - BUI.each(items, function(item, index) { - _self.addItemAt(item, start + index); - }); - }, - /** - * 更新列表项,修改选项值后,DOM跟随变化 - *
    
    -   *   var item = list.getItem('2');
    -   *   list.text = '新内容'; //此时对应的DOM不会变化
    -   *   list.updateItem(item); //DOM进行相应的变化
    -   * 
    - * @param {Object} item 选项值 - */ - updateItem: function(item) { - - }, - /** - * 添加选项,添加在控件最后 - * - *
    
    -   * list.addItem({id : '3',text : '3',type : '0'});
    -   * 
    - * - * @param {Object|BUI.Component.Controller} item 选项,子控件配置项、子控件 - * @return {Object|BUI.Component.Controller} 子控件或者选项记录 - */ - addItem: function(item) { - return this.addItemAt(item, this.getItemCount()); - }, - /** - * 在指定位置添加选项 - *
    
    -   * list.addItemAt({id : '3',text : '3',type : '0'},0); //第一个位置
    -   * 
    - * @param {Object|BUI.Component.Controller} item 选项,子控件配置项、子控件 - * @param {Number} index 索引 - * @return {Object|BUI.Component.Controller} 子控件或者选项记录 - */ - addItemAt: function(item, index) { - - }, - /** - * 根据字段查找指定的项 - * @param {String} field 字段名 - * @param {Object} value 字段值 - * @return {Object} 查询出来的项(传入的记录或者子控件) - * @protected - */ - findItemByField: function(field, value) { - - }, - /** - * - * 获取此项显示的文本 - * @param {Object} item 获取记录显示的文本 - * @protected - */ - getItemText: function(item) { - - }, - /** - * 清除所有选项,不等同于删除全部,此时不会触发删除事件 - *
    
    -   * list.clearItems();
    -   * //等同于
    -   * list.set('items',items);
    -   * 
    - */ - clearItems: function() { - var _self = this, - items = _self.getItems(); - items.splice(0); - _self.clearControl(); - }, - /** - * 删除选项 - *
    
    -   * var item = list.getItem('1');
    -   * list.removeItem(item);
    -   * 
    - * @param {Object|BUI.Component.Controller} item 选项(子控件) - */ - removeItem: function(item) { - - }, - /** - * 移除选项集合 - *
    
    -   * var items = list.getSelection();
    -   * list.removeItems(items);
    -   * 
    - * @param {Array} items 选项集合 - */ - removeItems: function(items) { - var _self = this; - - BUI.each(items, function(item) { - _self.removeItem(item); - }); - }, - /** - * 通过索引删除选项 - *
    
    -   * list.removeItemAt(0); //删除第一个
    -   * 
    - * @param {Number} index 索引 - */ - removeItemAt: function(index) { - this.removeItem(this.getItemAt(index)); - }, - /** - * @protected - * @template - * 清除所有的子控件或者列表项的DOM - */ - clearControl: function() { - - } -} - - - - - -function clearSelected(item) { - if (item.selected) { - item.selected = false; - } - if (item.set) { - item.set('selected', false); - } -} - -function beforeAddItem(self, item) { - - var c = item.isController ? item.getAttrVals() : item, - defaultTpl = self.get('itemTpl'), - defaultStatusCls = self.get('itemStatusCls'), - defaultTplRender = self.get('itemTplRender'); - - //配置默认模板 - if (defaultTpl && !c.tpl) { - setItemAttr(item, 'tpl', defaultTpl); - // c.tpl = defaultTpl; - } - //配置默认渲染函数 - if (defaultTplRender && !c.tplRender) { - setItemAttr(item, 'tplRender', defaultTplRender); - //c.tplRender = defaultTplRender; - } - //配置默认状态样式 - if (defaultStatusCls) { - var statusCls = c.statusCls || item.isController ? item.get('statusCls') : {}; - BUI.each(defaultStatusCls, function(v, k) { - if (v && !statusCls[k]) { - statusCls[k] = v; - } - }); - setItemAttr(item, 'statusCls', statusCls) - //item.statusCls = statusCls; - } - // clearSelected(item); -} - -function setItemAttr(item, name, val) { - if (item.isController) { - item.set(name, val); - } else { - item[name] = val; - } -} - -/** - * @class BUI.Component.UIBase.ChildList - * 选中其中的DOM结构 - * @extends BUI.Component.UIBase.List - * @mixins BUI.Component.UIBase.Selection - */ -var childList = function() { - this.__init(); -}; - -childList.ATTRS = BUI.merge(true, list.ATTRS, Selection.ATTRS, { - items: { - sync: false - }, - /** - * 配置的items 项是在初始化时作为children - * @protected - * @type {Boolean} - */ - autoInitItems: { - value: true - }, - /** - * 使用srcNode时,是否将内部的DOM转换成子控件 - * @type {Boolean} - */ - isDecorateChild: { - value: true - }, - /** - * 默认的加载控件内容的配置,默认值: - *
    -   *  {
    -   *   property : 'children',
    -   *   dataType : 'json'
    -   * }
    -   * 
    - * @type {Object} - */ - defaultLoaderCfg: { - value: { - property: 'children', - dataType: 'json' - } - } -}); - -BUI.augment(childList, list, Selection, { - //初始化,将items转换成children - __init: function() { - var _self = this, - items = _self.get('items'); - if (items && _self.get('autoInitItems')) { - _self.addItems(items); - } - _self.on('beforeRenderUI', function() { - _self._beforeRenderUI(); - }); - }, - _uiSetItems: function(items) { - var _self = this; - //清理子控件 - _self.clearControl(); - _self.addItems(items); - }, - //渲染子控件 - _beforeRenderUI: function() { - var _self = this, - children = _self.get('children'), - items = _self.get('items'); - BUI.each(children, function(item) { - beforeAddItem(_self, item); - }); - }, - //绑定事件 - __bindUI: function() { - var _self = this, - selectedEvent = _self.get('selectedEvent'); - - _self.on(selectedEvent, function(e) { - var item = e.target; - if (item.get('selectable')) { - if (!item.get('selected')) { - _self.setSelected(item); - } else if (_self.get('multipleSelect')) { - _self.clearSelected(item); - } - } - }); - - _self.on('click', function(e) { - if (e.target !== _self) { - _self.fire('itemclick', { - item: e.target, - domTarget: e.domTarget, - domEvent: e - }); - } - }); - _self.on('beforeAddChild', function(ev) { - beforeAddItem(_self, ev.child); - }); - _self.on('beforeRemoveChild', function(ev) { - var item = ev.child, - selected = item.get('selected'); - //清理选中状态 - if (selected) { - if (_self.get('multipleSelect')) { - _self.clearSelected(item); - } else { - _self.setSelected(null); - } - } - item.set('selected', false); - }); - }, - /** - * @protected - * @override - * 清除者列表项的DOM - */ - clearControl: function() { - this.removeChildren(true); - }, - /** - * 获取所有子控件 - * @return {Array} 子控件集合 - * @override - */ - getItems: function() { - return this.get('children'); - }, - /** - * 更新列表项 - * @param {Object} item 选项值 - */ - updateItem: function(item) { - var _self = this, - idField = _self.get('idField'), - element = _self.findItemByField(idField, item[idField]); - if (element) { - element.setTplContent(); - } - return element; - }, - /** - * 删除项,子控件作为选项 - * @param {Object} element 子控件 - */ - removeItem: function(item) { - var _self = this, - idField = _self.get('idField'); - if (!(item instanceof BUI.Component.Controller)) { - item = _self.findItemByField(idField, item[idField]); - } - this.removeChild(item, true); - }, - /** - * 在指定位置添加选项,此处选项指子控件 - * @param {Object|BUI.Component.Controller} item 子控件配置项、子控件 - * @param {Number} index 索引 - * @return {Object|BUI.Component.Controller} 子控件 - */ - addItemAt: function(item, index) { - return this.addChild(item, index); - }, - findItemByField: function(field, value, root) { - - root = root || this; - var _self = this, - children = root.get('children'), - result = null; - $(children).each(function(index, item) { - if (item.get(field) == value) { - result = item; - } else if (item.get('children').length) { - result = _self.findItemByField(field, value, item); - } - if (result) { - return false; - } - }); - return result; - }, - getItemText: function(item) { - return item.get('el').text(); - }, - getValueByField: function(item, field) { - return item && item.get(field); - }, - /** - * @protected - * @ignore - */ - setItemSelectedStatus: function(item, selected) { - var _self = this, - method = selected ? 'addClass' : 'removeClass', - element = null; - - if (item) { - item.set('selected', selected); - element = item.get('el'); - } - _self.afterSelected(item, selected, element); - }, - /** - * 选项是否被选中 - * @override - * @param {*} item 选项 - * @return {Boolean} 是否选中 - */ - isItemSelected: function(item) { - return item ? item.get('selected') : false; - }, - /** - * 设置所有选项选中 - * @override - */ - setAllSelection: function() { - var _self = this, - items = _self.getItems(); - _self.setSelection(items); - }, - /** - * 获取选中的项的值 - * @return {Array} - * @override - * @ignore - */ - getSelection: function() { - var _self = this, - items = _self.getItems(), - rst = []; - BUI.each(items, function(item) { - if (_self.isItemSelected(item)) { - rst.push(item); - } - - }); - return rst; - } -}); - -list.ChildList = childList; - -module.exports = list; - -/** - * @ignore - * 2013-1-22 - * 更改显示数据的方式,使用 _uiSetItems - */ diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/listitem.js b/spm_modules/bui-common/1.1.2/src/component/uibase/listitem.js deleted file mode 100644 index 6d1910a..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/listitem.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @fileOverview 可选中的控件,父控件支持selection扩展 - * @ignore - */ - - -/** - * 列表项控件的视图层 - * @class BUI.Component.UIBase.ListItemView - * @private - */ -function listItemView() { - // body... -} - -listItemView.ATTRS = { - /** - * 是否选中 - * @type {Boolean} - */ - selected: { - - } -}; - -listItemView.prototype = { - _uiSetSelected: function(v) { - var _self = this, - cls = _self.getStatusCls('selected'), - el = _self.get('el'); - if (v) { - el.addClass(cls); - } else { - el.removeClass(cls); - } - } -}; -/** - * 列表项的扩展 - * @class BUI.Component.UIBase.ListItem - */ -function listItem() { - -} - -listItem.ATTRS = { - - /** - * 是否可以被选中 - * @cfg {Boolean} [selectable=true] - */ - /** - * 是否可以被选中 - * @type {Boolean} - */ - selectable: { - value: true - }, - - /** - * 是否选中,只能通过设置父类的选中方法来实现选中 - * @type {Boolean} - * @readOnly - */ - selected: { - view: true, - sync: false, - value: false - } -}; - -listItem.prototype = { - -}; - -listItem.View = listItemView; - -module.exports = listItem; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/mask.js b/spm_modules/bui-common/1.1.2/src/component/uibase/mask.js deleted file mode 100644 index 0849340..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/mask.js +++ /dev/null @@ -1,236 +0,0 @@ -/** - * @fileOverview mask 遮罩层 - * @author yiminghe@gmail.com - * copied and modified by dxq613@gmail.com - * @ignore - */ - - -var $ = require('jquery'), - UA = require('../../ua'), - - /** - * 每组相同 prefixCls 的 position 共享一个遮罩 - * @ignore - */ - maskMap = { - /** - * @ignore - * { - * node: - * num: - * } - */ - - }, - ie6 = UA.ie == 6; - -function getMaskCls(self) { - return self.get('prefixCls') + 'ext-mask'; -} - -function docWidth() { - return ie6 ? BUI.docWidth() + 'px' : '100%'; -} - -function docHeight() { - return ie6 ? BUI.docHeight() + 'px' : '100%'; -} - -function initMask(maskCls) { - var mask = $('
    ' + - (ie6 ? '<' + 'iframe ' + - 'style="position:absolute;' + - 'left:' + '0' + ';' + - 'top:' + '0' + ';' + - 'background:white;' + - 'width: expression(this.parentNode.offsetWidth);' + - 'height: expression(this.parentNode.offsetHeight);' + - 'filter:alpha(opacity=0);' + - 'z-index:-1;">' : '') + - '
    ') - .prependTo('body'); - /** - * 点 mask 焦点不转移 - * @ignore - */ - // mask.unselectable(); - mask.on('mousedown', function(e) { - e.preventDefault(); - }); - return mask; -} - -/** - * 遮罩层的视图类 - * @class BUI.Component.UIBase.MaskView - * @private - */ -function MaskView() {} - -MaskView.ATTRS = { - maskShared: { - value: true - } -}; - -MaskView.prototype = { - - _maskExtShow: function() { - var self = this, - zIndex, - maskCls = getMaskCls(self), - maskDesc = maskMap[maskCls], - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (!mask) { - if (maskShared) { - if (maskDesc) { - mask = maskDesc.node; - } else { - mask = initMask(maskCls); - maskDesc = maskMap[maskCls] = { - num: 0, - node: mask - }; - } - } else { - mask = initMask(maskCls); - } - self.setInternal('maskNode', mask); - } - if (zIndex = self.get('zIndex')) { - mask.css('z-index', zIndex - 1); - } - if (maskShared) { - maskDesc.num++; - } - if (!maskShared || maskDesc.num == 1) { - mask.show(); - } - $('body').addClass('x-masked-relative'); - }, - - _maskExtHide: function() { - var self = this, - maskCls = getMaskCls(self), - maskDesc = maskMap[maskCls], - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (maskShared && maskDesc) { - maskDesc.num = Math.max(maskDesc.num - 1, 0); - if (maskDesc.num == 0) { - mask.hide(); - } - } else if (mask) { - mask.hide(); - } - $('body').removeClass('x-masked-relative'); - }, - - __destructor: function() { - var self = this, - maskShared = self.get('maskShared'), - mask = self.get('maskNode'); - if (self.get('maskNode')) { - if (maskShared) { - if (self.get('visible')) { - self._maskExtHide(); - } - } else { - mask.remove(); - } - } - } - -}; - -/** - * @class BUI.Component.UIBase.Mask - * Mask extension class. - * Make component to be able to show with mask. - */ -function Mask() {} - -Mask.ATTRS = { - /** - * 控件显示时,是否显示屏蔽层 - *
    
    -   *   var overlay = new Overlay({ //显示overlay时,屏蔽body
    -   *     mask : true,
    -   *     maskNode : 'body',
    -   *     trigger : '#t1'
    -   *   });
    -   *   overlay.render();
    -   * 
    - * @cfg {Boolean} [mask = false] - */ - /** - * 控件显示时,是否显示屏蔽层 - * @type {Boolean} - * @protected - */ - mask: { - value: false - }, - /** - * 屏蔽的内容 - *
    
    -   *   var overlay = new Overlay({ //显示overlay时,屏蔽body
    -   *     mask : true,
    -   *     maskNode : 'body',
    -   *     trigger : '#t1'
    -   *   });
    -   *   overlay.render();
    -   * 
    - * @cfg {jQuery} maskNode - */ - /** - * 屏蔽的内容 - * @type {jQuery} - * @protected - */ - maskNode: { - view: 1 - }, - /** - * Whether to share mask with other overlays. - * @default true. - * @type {Boolean} - * @protected - */ - maskShared: { - view: 1 - } -}; - -Mask.prototype = { - - __bindUI: function() { - var self = this, - view = self.get('view'), - _maskExtShow = view._maskExtShow, - _maskExtHide = view._maskExtHide; - if (self.get('mask')) { - self.on('show', function() { - view._maskExtShow(); - }); - self.on('hide', function() { - view._maskExtHide(); - }); - } - } -}; - -Mask = Mask; -Mask.View = MaskView; - -module.exports = Mask; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/position.js b/spm_modules/bui-common/1.1.2/src/component/uibase/position.js deleted file mode 100644 index 36a2099..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/position.js +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @fileOverview 位置,控件绝对定位 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -/** - * 对齐的视图类 - * @class BUI.Component.UIBase.PositionView - * @private - */ -function PositionView() { - -} - -PositionView.ATTRS = { - x: { - /** - * 水平方向绝对位置 - * @private - * @ignore - */ - valueFn: function() { - var self = this; - // 读到这里时,el 一定是已经加到 dom 树中了,否则报未知错误 - // el 不在 dom 树中 offset 报错的 - // 最早读就是在 syncUI 中,一点重复设置(读取自身 X 再调用 _uiSetX)无所谓了 - return self.get('el') && self.get('el').offset().left; - } - }, - y: { - /** - * 垂直方向绝对位置 - * @private - * @ignore - */ - valueFn: function() { - var self = this; - return self.get('el') && self.get('el').offset().top; - } - }, - zIndex: {}, - /** - * @private - * see {@link BUI.Component.UIBase.Box#visibleMode}. - * @default "visibility" - * @ignore - */ - visibleMode: { - value: 'visibility' - } -}; - - -PositionView.prototype = { - - __createDom: function() { - this.get('el').addClass(BUI.prefix + 'ext-position'); - }, - - _uiSetZIndex: function(x) { - this.get('el').css('z-index', x); - }, - _uiSetX: function(x) { - if (x != null) { - this.get('el').offset({ - left: x - }); - } - }, - _uiSetY: function(y) { - if (y != null) { - this.get('el').offset({ - top: y - }); - } - }, - _uiSetLeft: function(left) { - if (left != null) { - this.get('el').css({ - left: left - }); - } - }, - _uiSetTop: function(top) { - if (top != null) { - this.get('el').css({ - top: top - }); - } - } -}; - -/** - * @class BUI.Component.UIBase.Position - * Position extension class. - * Make component positionable - */ -function Position() {} - -Position.ATTRS = { - /** - * 水平坐标 - * @cfg {Number} x - */ - /** - * 水平坐标 - *
    
    -   *     overlay.set('x',100);
    -   * 
    - * @type {Number} - */ - x: { - view: 1 - }, - /** - * 垂直坐标 - * @cfg {Number} y - */ - /** - * 垂直坐标 - *
    
    -   *     overlay.set('y',100);
    -   * 
    - * @type {Number} - */ - y: { - view: 1 - }, - /** - * 相对于父元素的水平位置 - * @type {Number} - * @protected - */ - left: { - view: 1 - }, - /** - * 相对于父元素的垂直位置 - * @type {Number} - * @protected - */ - top: { - view: 1 - }, - /** - * 水平和垂直坐标 - *
    
    -   * var overlay = new Overlay({
    -   *   xy : [100,100],
    -   *   trigger : '#t1',
    -   *   srcNode : '#c1'
    -   * });
    -   * 
    - * @cfg {Number[]} xy - */ - /** - * 水平和垂直坐标 - *
    
    -   *     overlay.set('xy',[100,100]);
    -   * 
    - * @type {Number[]} - */ - xy: { - // 相对 page 定位, 有效值为 [n, m], 为 null 时, 选 align 设置 - setter: function(v) { - var self = this, - xy = $.makeArray(v); - /* - 属性内分发特别注意: - xy -> x,y - */ - if (xy.length) { - xy[0] && self.set('x', xy[0]); - xy[1] && self.set('y', xy[1]); - } - return v; - }, - /** - * xy 纯中转作用 - * @ignore - */ - getter: function() { - return [this.get('x'), this.get('y')]; - } - }, - /** - * z-index value. - *
    
    -   *   var overlay = new Overlay({
    -   *       zIndex : '1000'
    -   *   });
    -   * 
    - * @cfg {Number} zIndex - */ - /** - * z-index value. - *
    
    -   *   overlay.set('zIndex','1200');
    -   * 
    - * @type {Number} - */ - zIndex: { - view: 1 - }, - /** - * Positionable element is by default visible false. - * For compatibility in overlay and PopupMenu. - * @default false - * @ignore - */ - visible: { - view: true, - value: true - } -}; - - -Position.prototype = { - /** - * Move to absolute position. - * @param {Number|Number[]} x - * @param {Number} [y] - * @example - *
    
    -   * move(x, y);
    -   * move(x);
    -   * move([x,y])
    -   * 
    - */ - move: function(x, y) { - var self = this; - if (BUI.isArray(x)) { - y = x[1]; - x = x[0]; - } - self.set('xy', [x, y]); - return self; - }, - //设置 x 坐标时,重置 left - _uiSetX: function(v) { - if (v != null) { - var _self = this, - el = _self.get('el'); - _self.setInternal('left', el.position().left); - if (v != -999) { - this.set('cachePosition', null); - } - - } - - }, - //设置 y 坐标时,重置 top - _uiSetY: function(v) { - if (v != null) { - var _self = this, - el = _self.get('el'); - _self.setInternal('top', el.position().top); - if (v != -999) { - this.set('cachePosition', null); - } - } - }, - //设置 left时,重置 x - _uiSetLeft: function(v) { - var _self = this, - el = _self.get('el'); - if (v != null) { - _self.setInternal('x', el.offset().left); - } - /*else{ //如果lef 为null,同时设置过left和top,那么取对应的值 - _self.setInternal('left',el.position().left); - }*/ - }, - //设置top 时,重置y - _uiSetTop: function(v) { - var _self = this, - el = _self.get('el'); - if (v != null) { - _self.setInternal('y', el.offset().top); - } - /*else{ //如果lef 为null,同时设置过left和top,那么取对应的值 - _self.setInternal('top',el.position().top); - }*/ - } -}; - -Position.View = PositionView; - -module.exports = Position; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/selection.js b/spm_modules/bui-common/1.1.2/src/component/uibase/selection.js deleted file mode 100644 index 9a810d1..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/selection.js +++ /dev/null @@ -1,427 +0,0 @@ -/** - * @fileOverview 单选或者多选 - * @author dxq613@gmail.com - * @ignore - */ -var $ = require('jquery'); -var SINGLE_SELECTED = 'single'; - -/** - * @class BUI.Component.UIBase.Selection - * 选中控件中的项(子元素或者DOM),此类选择的内容有2种 - *
      - *
    1. 子控件
    2. - *
    3. DOM元素
    4. - *
    - * ** 当选择是子控件时,element 和 item 都是指 子控件;** - * ** 当选择的是DOM元素时,element 指DOM元素,item 指DOM元素对应的记录 ** - * @abstract - */ -var selection = function() { - -}; - -selection.ATTRS = - -{ - /** - * 选中的事件 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{value}">{text}</li>',
    -   *   idField : 'value',
    -   *   selectedEvent : 'mouseenter',
    -   *   render : '#t1',
    -   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
    -   * });
    -   * 
    - * @cfg {String} [selectedEvent = 'click'] - */ - selectedEvent: { - value: 'click' - }, - events: { - value: { - /** - * 选中的菜单改变时发生, - * 多选时,选中,取消选中都触发此事件,单选时,只有选中时触发此事件 - * @name BUI.Component.UIBase.Selection#selectedchange - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - * @param {Boolean} e.selected 是否选中 - */ - 'selectedchange': false, - - /** - * 选择改变前触发,可以通过return false,阻止selectedchange事件 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {Boolean} e.selected 是否选中 - */ - 'beforeselectedchange': false, - - /** - * 菜单选中 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - */ - 'itemselected': false, - /** - * 菜单取消选中 - * @event - * @param {Object} e 事件对象 - * @param {Object} e.item 当前选中的项 - * @param {HTMLElement} e.domTarget 当前选中的项的DOM结构 - */ - 'itemunselected': false - } - }, - /** - * 数据的id字段名称,通过此字段查找对应的数据 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{value}">{text}</li>',
    -   *   idField : 'value',
    -   *   render : '#t1',
    -   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
    -   * });
    -   * 
    - * @cfg {String} [idField = 'id'] - */ - /** - * 数据的id字段名称,通过此字段查找对应的数据 - * @type {String} - * @ignore - */ - idField: { - value: 'id' - }, - /** - * 是否多选 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{value}">{text}</li>',
    -   *   idField : 'value',
    -   *   render : '#t1',
    -   *   multipleSelect : true,
    -   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
    -   * });
    -   * 
    - * @cfg {Boolean} [multipleSelect=false] - */ - /** - * 是否多选 - * @type {Boolean} - * @default false - */ - multipleSelect: { - value: false - } - -}; - -selection.prototype = - -{ - /** - * 清理选中的项 - *
    
    -   *  list.clearSelection();
    -   * 
    - * - */ - clearSelection: function() { - var _self = this, - selection = _self.getSelection(); - BUI.each(selection, function(item) { - _self.clearSelected(item); - }); - }, - /** - * 获取选中的项的值 - * @template - * @return {Array} - */ - getSelection: function() { - - }, - /** - * 获取选中的第一项 - *
    
    -   * var item = list.getSelected(); //多选模式下第一条
    -   * 
    - * @return {Object} 选中的第一项或者为undefined - */ - getSelected: function() { - return this.getSelection()[0]; - }, - /** - * 根据 idField 获取到的值 - * @protected - * @return {Object} 选中的值 - */ - getSelectedValue: function() { - var _self = this, - field = _self.get('idField'), - item = _self.getSelected(); - - return _self.getValueByField(item, field); - }, - /** - * 获取选中的值集合 - * @protected - * @return {Array} 选中值得集合 - */ - getSelectionValues: function() { - var _self = this, - field = _self.get('idField'), - items = _self.getSelection(); - return $.map(items, function(item) { - return _self.getValueByField(item, field); - }); - }, - /** - * 获取选中的文本 - * @protected - * @return {Array} 选中的文本集合 - */ - getSelectionText: function() { - var _self = this, - items = _self.getSelection(); - return $.map(items, function(item) { - return _self.getItemText(item); - }); - }, - /** - * 移除选中 - *
    
    -   *    var item = list.getItem('id'); //通过id 获取选项
    -   *    list.setSelected(item); //选中
    -   *
    -   *    list.clearSelected();//单选模式下清除所选,多选模式下清除选中的第一项
    -   *    list.clearSelected(item); //清除选项的选中状态
    -   * 
    - * @param {Object} [item] 清除选项的选中状态,如果未指定则清除选中的第一个选项的选中状态 - */ - clearSelected: function(item) { - var _self = this; - item = item || _self.getSelected(); - if (item) { - _self.setItemSelected(item, false); - } - }, - /** - * 获取选项显示的文本 - * @protected - */ - getSelectedText: function() { - var _self = this, - item = _self.getSelected(); - return _self.getItemText(item); - }, - /** - * 设置选中的项 - *
    
    -   *  var items = list.getItemsByStatus('active'); //获取某种状态的选项
    -   *  list.setSelection(items);
    -   * 
    - * @param {Array} items 项的集合 - */ - setSelection: function(items) { - var _self = this; - - items = BUI.isArray(items) ? items : [items]; - - BUI.each(items, function(item) { - _self.setSelected(item); - }); - }, - /** - * 设置选中的项 - *
    
    -   *   var item = list.getItem('id');
    -   *   list.setSelected(item);
    -   * 
    - * @param {Object} item 记录或者子控件 - */ - setSelected: function(item) { - var _self = this, - multipleSelect = _self.get('multipleSelect'); - - if (!_self.isItemSelectable(item)) { - return; - } - if (!multipleSelect) { - var selectedItem = _self.getSelected(); - if (item != selectedItem) { - //如果是单选,清除已经选中的项 - _self.clearSelected(selectedItem); - } - - } - _self.setItemSelected(item, true); - - }, - /** - * 选项是否被选中 - * @template - * @param {*} item 选项 - * @return {Boolean} 是否选中 - */ - isItemSelected: function(item) { - - }, - /** - * 选项是否可以选中 - * @protected - * @param {*} item 选项 - * @return {Boolean} 选项是否可以选中 - */ - isItemSelectable: function(item) { - return true; - }, - /** - * 设置选项的选中状态 - * @param {*} item 选项 - * @param {Boolean} selected 选中或者取消选中 - * @protected - */ - setItemSelected: function(item, selected) { - var _self = this, - isSelected; - - //当前状态等于要设置的状态时,不触发改变事件 - if (item) { - isSelected = _self.isItemSelected(item); - if (isSelected == selected) { - return; - } - } - if (_self.fire('beforeselectedchange', { - item: item, - selected: selected - }) !== false) { - _self.setItemSelectedStatus(item, selected); - } - }, - /** - * 设置选项的选中状态 - * @template - * @param {*} item 选项 - * @param {Boolean} selected 选中或者取消选中 - * @protected - */ - setItemSelectedStatus: function(item, selected) { - - }, - /** - * 设置所有选项选中 - *
    
    -   *  list.setAllSelection(); //选中全部,多选状态下有效
    -   * 
    - * @template - */ - setAllSelection: function() { - - }, - /** - * 设置项选中,通过字段和值 - * @param {String} field 字段名,默认为配置项'idField',所以此字段可以不填写,仅填写值 - * @param {Object} value 值 - * @example - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{id}">{text}</li>',
    -   *   idField : 'id', //id 字段作为key
    -   *   render : '#t1',
    -   *   items : [{id : '1',text : '1'},{id : '2',text : '2'}]
    -   * });
    -   *
    -   *   list.setSelectedByField('123'); //默认按照id字段查找
    -   *   //或者
    -   *   list.setSelectedByField('id','123');
    -   *
    -   *   list.setSelectedByField('value','123');
    -   * 
    - */ - setSelectedByField: function(field, value) { - if (!value) { - value = field; - field = this.get('idField'); - } - var _self = this, - item = _self.findItemByField(field, value); - _self.setSelected(item); - }, - /** - * 设置多个选中,根据字段和值 - *
    
    -   * var list = new List.SimpleList({
    -   *   itemTpl : '<li id="{value}">{text}</li>',
    -   *   idField : 'value', //value 字段作为key
    -   *   render : '#t1',
    -   *   multipleSelect : true,
    -   *   items : [{value : '1',text : '1'},{value : '2',text : '2'}]
    -   * });
    -   *   var values = ['1','2','3'];
    -   *   list.setSelectionByField(values);//
    -   *
    -   *   //等于
    -   *   list.setSelectionByField('value',values);
    -   * 
    - * @param {String} field 默认为idField - * @param {Array} values 值得集合 - */ - setSelectionByField: function(field, values) { - if (!values) { - values = field; - field = this.get('idField'); - } - var _self = this; - BUI.each(values, function(value) { - _self.setSelectedByField(field, value); - }); - }, - /** - * 选中完成后,触发事件 - * @protected - * @param {*} item 选项 - * @param {Boolean} selected 是否选中 - * @param {jQuery} element - */ - afterSelected: function(item, selected, element) { - var _self = this; - - if (selected) { - _self.fire('itemselected', { - item: item, - domTarget: element - }); - _self.fire('selectedchange', { - item: item, - domTarget: element, - selected: selected - }); - } else { - _self.fire('itemunselected', { - item: item, - domTarget: element - }); - if (_self.get('multipleSelect')) { //只有当多选时,取消选中才触发selectedchange - _self.fire('selectedchange', { - item: item, - domTarget: element, - selected: selected - }); - } - } - } - -} - -module.exports = selection; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/stdmod.js b/spm_modules/bui-common/1.1.2/src/component/uibase/stdmod.js deleted file mode 100644 index 85a08cc..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/stdmod.js +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @fileOverview - * 控件包含头部(head)、内容(content)和尾部(foot) - * @ignore - */ - -var $ = require('jquery'), - CLS_PREFIX = BUI.prefix + 'stdmod-'; - - -/** - * 标准模块组织的视图类 - * @class BUI.Component.UIBase.StdModView - * @private - */ -function StdModView() {} - -StdModView.ATTRS = { - header: {}, - body: {}, - footer: {}, - bodyStyle: {}, - footerStyle: {}, - headerStyle: {}, - headerContent: {}, - bodyContent: {}, - footerContent: {} -}; - -StdModView.PARSER = { - header: function(el) { - return el.one("." + CLS_PREFIX + "header"); - }, - body: function(el) { - return el.one("." + CLS_PREFIX + "body"); - }, - footer: function(el) { - return el.one("." + CLS_PREFIX + "footer"); - } -}; /**/ - -function createUI(self, part) { - var el = self.get('contentEl'), - partEl = self.get(part); - if (!partEl) { - partEl = $('
    ' + - '
    '); - partEl.appendTo(el); - self.setInternal(part, partEl); - } -} - - -function _setStdModRenderContent(self, part, v) { - part = self.get(part); - if (BUI.isString(v)) { - part.html(v); - } else { - part.html('') - .append(v); - } -} - -StdModView.prototype = { - - __renderUI: function() { //createDom - createUI(this, 'header'); - createUI(this, 'body'); - createUI(this, 'footer'); - }, - - _uiSetBodyStyle: function(v) { - this.get('body').css(v); - }, - - _uiSetHeaderStyle: function(v) { - this.get('header').css(v); - }, - _uiSetFooterStyle: function(v) { - this.get('footer').css(v); - }, - - _uiSetBodyContent: function(v) { - _setStdModRenderContent(this, 'body', v); - }, - - _uiSetHeaderContent: function(v) { - _setStdModRenderContent(this, 'header', v); - }, - - _uiSetFooterContent: function(v) { - _setStdModRenderContent(this, 'footer', v); - } -}; - -/** - * @class BUI.Component.UIBase.StdMod - * StdMod extension class. - * Generate head, body, foot for component. - */ -function StdMod() {} - -StdMod.ATTRS = { - /** - * 控件的头部DOM. Readonly - * @readOnly - * @type {jQuery} - */ - header: { - view: 1 - }, - /** - * 控件的内容DOM. Readonly - * @readOnly - * @type {jQuery} - */ - body: { - view: 1 - }, - /** - * 控件的底部DOM. Readonly - * @readOnly - * @type {jQuery} - */ - footer: { - view: 1 - }, - /** - * 应用到控件内容的css属性,键值对形式 - * @cfg {Object} bodyStyle - */ - /** - * 应用到控件内容的css属性,键值对形式 - * @type {Object} - * @protected - */ - bodyStyle: { - view: 1 - }, - /** - * 应用到控件底部的css属性,键值对形式 - * @cfg {Object} footerStyle - */ - /** - * 应用到控件底部的css属性,键值对形式 - * @type {Object} - * @protected - */ - footerStyle: { - view: 1 - }, - /** - * 应用到控件头部的css属性,键值对形式 - * @cfg {Object} headerStyle - */ - /** - * 应用到控件头部的css属性,键值对形式 - * @type {Object} - * @protected - */ - headerStyle: { - view: 1 - }, - /** - * 控件头部的html - *
    
    -   * var dialog = new Dialog({
    -   *     headerContent: '<div class="header"></div>',
    -   *     bodyContent : '#c1',
    -   *     footerContent : '<div class="footer"></div>'
    -   * });
    -   * dialog.show();
    -   * 
    - * @cfg {jQuery|String} headerContent - */ - /** - * 控件头部的html - * @type {jQuery|String} - */ - headerContent: { - view: 1 - }, - /** - * 控件内容的html - *
    
    -   * var dialog = new Dialog({
    -   *     headerContent: '<div class="header"></div>',
    -   *     bodyContent : '#c1',
    -   *     footerContent : '<div class="footer"></div>'
    -   * });
    -   * dialog.show();
    -   * 
    - * @cfg {jQuery|String} bodyContent - */ - /** - * 控件内容的html - * @type {jQuery|String} - */ - bodyContent: { - view: 1 - }, - /** - * 控件底部的html - *
    
    -   * var dialog = new Dialog({
    -   *     headerContent: '<div class="header"></div>',
    -   *     bodyContent : '#c1',
    -   *     footerContent : '<div class="footer"></div>'
    -   * });
    -   * dialog.show();
    -   * 
    - * @cfg {jQuery|String} footerContent - */ - /** - * 控件底部的html - * @type {jQuery|String} - */ - footerContent: { - view: 1 - } -}; - -StdMod.View = StdModView; - -module.exports = StdMod; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/tpl.js b/spm_modules/bui-common/1.1.2/src/component/uibase/tpl.js deleted file mode 100644 index ae1e9d6..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/tpl.js +++ /dev/null @@ -1,203 +0,0 @@ -/** - * @fileOverview 控件模板 - * @author dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'); - -/** - * @private - * 控件模板扩展类的渲染类(view) - * @class BUI.Component.UIBase.TplView - */ -function tplView() { - -} - -tplView.ATTRS = { - /** - * 模板 - * @protected - * @type {String} - */ - tpl: { - - }, - tplEl: { - - } -}; - -tplView.prototype = { - __renderUI: function() { - var _self = this, - contentContainer = _self.get('childContainer'), - contentEl; - - if (contentContainer) { - contentEl = _self.get('el').find(contentContainer); - if (contentEl.length) { - _self.set('contentEl', contentEl); - } - } - }, - /** - * 获取生成控件的模板 - * @protected - * @param {Object} attrs 属性值 - * @return {String} 模板 - */ - getTpl: function(attrs) { - var _self = this, - tpl = _self.get('tpl'), - tplRender = _self.get('tplRender'); - attrs = attrs || _self.getAttrVals(); - - if (tplRender) { - return tplRender(attrs); - } - if (tpl) { - return BUI.substitute(tpl, attrs); - } - return ''; - }, - /** - * 如果控件设置了模板,则根据模板和属性值生成DOM - * 如果设置了content属性,此模板不应用 - * @protected - * @param {Object} attrs 属性值,默认为初始化时传入的值 - */ - setTplContent: function(attrs) { - var _self = this, - el = _self.get('el'), - content = _self.get('content'), - tplEl = _self.get('tplEl'), - tpl = _self.getTpl(attrs); - - //tplEl.remove(); - if (!content && tpl) { //替换掉原先的内容 - el.empty(); - el.html(tpl); - /*if(tplEl){ - var node = $(tpl).insertBefore(tplEl); - tplEl.remove(); - tplEl = node; - }else{ - tplEl = $(tpl).appendTo(el); - } - _self.set('tplEl',tplEl) - */ - } - } -} - -/** - * 控件的模板扩展 - * @class BUI.Component.UIBase.Tpl - */ -function tpl() { - -} - -tpl.ATTRS = { - /** - * 控件的模版,用于初始化 - *
    
    -   * var list = new List.List({
    -   *   tpl : '<div class="toolbar"></div><ul></ul>',
    -   *   childContainer : 'ul'
    -   * });
    -   * //用于统一子控件模板
    -   * var list = new List.List({
    -   *   defaultChildCfg : {
    -   *     tpl : '<span>{text}</span>'
    -   *   }
    -   * });
    -   * list.render();
    -   * 
    - * @cfg {String} tpl - */ - /** - * 控件的模板 - *
    
    -   *   list.set('tpl','<div class="toolbar"></div><ul></ul><div class="bottom"></div>')
    -   * 
    - * @type {String} - */ - tpl: { - view: true, - sync: false - }, - /** - *

    控件的渲染函数,应对一些简单模板解决不了的问题,例如有if,else逻辑,有循环逻辑, - * 函数原型是function(data){},其中data是控件的属性值

    - *

    控件模板的加强模式,此属性会覆盖@see {BUI.Component.UIBase.Tpl#property-tpl}属性

    - * //用于统一子控件模板 - * var list = new List.List({ - * defaultChildCfg : { - * tplRender : funciton(item){ - * if(item.type == '1'){ - * return 'type1 html'; - * }else{ - * return 'type2 html'; - * } - * } - * } - * }); - * list.render(); - * @cfg {Function} tplRender - */ - tplRender: { - view: true, - value: null - }, - /** - * 这是一个选择器,使用了模板后,子控件可能会添加到模板对应的位置, - * - 默认为null,此时子控件会将控件最外层 el 作为容器 - *
    
    -   * var list = new List.List({
    -   *   tpl : '<div class="toolbar"></div><ul></ul>',
    -   *   childContainer : 'ul'
    -   * });
    -   * 
    - * @cfg {String} childContainer - */ - childContainer: { - view: true - } -}; - -tpl.prototype = { - - __renderUI: function() { - //使用srcNode时,不使用模板 - if (!this.get('srcNode')) { - this.setTplContent(); - } - }, - /** - * 控件信息发生改变时,控件内容跟模板相关时需要调用这个函数, - * 重新通过模板和控件信息构造内容 - */ - updateContent: function() { - this.setTplContent(); - }, - /** - * 根据控件的属性和模板生成控件内容 - * @protected - */ - setTplContent: function() { - var _self = this, - attrs = _self.getAttrVals(); - _self.get('view').setTplContent(attrs); - }, - //模板发生改变 - _uiSetTpl: function() { - this.setTplContent(); - } -}; - -tpl.View = tplView; - -module.exports = tpl; diff --git a/spm_modules/bui-common/1.1.2/src/component/uibase/uibase.js b/spm_modules/bui-common/1.1.2/src/component/uibase/uibase.js deleted file mode 100644 index d3add3e..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/uibase/uibase.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @fileOverview uibase的入口文件 - * @ignore - */ -var UIBase = require('./base'); - -BUI.mix(UIBase, { - Align: require('./align'), - AutoShow: require('./autoshow'), - AutoHide: require('./autohide'), - Close: require('./close'), - Collapsable: require('./collapsable'), - Drag: require('./drag'), - KeyNav: require('./keynav'), - List: require('./list'), - ListItem: require('./listitem'), - Mask: require('./mask'), - Position: require('./position'), - Selection: require('./selection'), - StdMod: require('./stdmod'), - Decorate: require('./decorate'), - Tpl: require('./tpl'), - ChildCfg: require('./childcfg'), - Bindable: require('./bindable'), - Depends: require('./depends') -}); - -BUI.mix(UIBase, { - CloseView: UIBase.Close.View, - CollapsableView: UIBase.Collapsable.View, - ChildList: UIBase.List.ChildList, - /*DomList : UIBase.List.DomList, - DomListView : UIBase.List.DomList.View,*/ - ListItemView: UIBase.ListItem.View, - MaskView: UIBase.Mask.View, - PositionView: UIBase.Position.View, - StdModView: UIBase.StdMod.View, - TplView: UIBase.Tpl.View -}); - -module.exports = UIBase; diff --git a/spm_modules/bui-common/1.1.2/src/component/view.js b/spm_modules/bui-common/1.1.2/src/component/view.js deleted file mode 100644 index 18505e3..0000000 --- a/spm_modules/bui-common/1.1.2/src/component/view.js +++ /dev/null @@ -1,447 +0,0 @@ -/** - * @fileOverview 控件的视图层 - * @author yiminghe@gmail.com - * copied by dxq613@gmail.com - * @ignore - */ - -var $ = require('jquery'), - win = window, - Manager = require('./manage'), - UIBase = require('./uibase/uibase'), //BUI.Component.UIBase, - doc = document; - -/** - * 控件的视图层基类 - * @class BUI.Component.View - * @protected - * @extends BUI.Component.UIBase - * @mixins BUI.Component.UIBase.TplView - */ -var View = UIBase.extend([UIBase.TplView], { - - /** - * Get all css class name to be applied to the root element of this component for given state. - * the css class names are prefixed with component name. - * @param {String} [state] This component's state info. - */ - getComponentCssClassWithState: function(state) { - var self = this, - componentCls = self.get('ksComponentCss'); - state = state || ''; - return self.getCssClassWithPrefix(componentCls.split(/\s+/).join(state + ' ') + state); - }, - - /** - * Get full class name (with prefix) for current component - * @param classes {String} class names without prefixCls. Separated by space. - * @method - * @return {String} class name with prefixCls - * @private - */ - getCssClassWithPrefix: Manager.getCssClassWithPrefix, - - /** - * Returns the dom element which is responsible for listening keyboard events. - * @return {jQuery} - */ - getKeyEventTarget: function() { - return this.get('el'); - }, - /** - * Return the dom element into which child component to be rendered. - * @return {jQuery} - */ - getContentElement: function() { - return this.get('contentEl') || this.get('el'); - }, - /** - * 获取状态对应的css样式 - * @param {String} name 状态名称 例如:hover,disabled等等 - * @return {String} 状态样式 - */ - getStatusCls: function(name) { - var self = this, - statusCls = self.get('statusCls'), - cls = statusCls[name]; - if (!cls) { - cls = self.getComponentCssClassWithState('-' + name); - } - return cls; - }, - /** - * 渲染控件 - * @protected - */ - renderUI: function() { - var self = this; - - // 新建的节点才需要摆放定位,不支持srcNode模式 - if (!self.get('srcNode')) { - var render = self.get('render'), - el = self.get('el'), - renderBefore = self.get('elBefore'); - if (renderBefore) { - el.insertBefore(renderBefore, undefined); - } else if (render) { - el.appendTo(render, undefined); - } else { - el.appendTo(doc.body, undefined); - } - } - }, - /** - * 只负责建立节点,如果是 decorate 过来的,甚至内容会丢失 - * @protected - * 通过 render 来重建原有的内容 - */ - createDom: function() { - var self = this, - contentEl = self.get('contentEl'), - el = self.get('el'); - if (!self.get('srcNode')) { - - el = $('<' + self.get('elTagName') + '>'); - - if (contentEl) { - el.append(contentEl); - } - - self.setInternal('el', el); - } - - el.addClass(self.getComponentCssClassWithState()); - if (!contentEl) { - // 没取到,这里设下值, uiSet 时可以 set('content') 取到 - self.setInternal('contentEl', el); - } - }, - /** - * 设置高亮显示 - * @protected - */ - _uiSetHighlighted: function(v) { - var self = this, - componentCls = self.getStatusCls('hover'), - el = self.get('el'); - el[v ? 'addClass' : 'removeClass'](componentCls); - }, - - /** - * 设置禁用 - * @protected - */ - _uiSetDisabled: function(v) { - var self = this, - componentCls = self.getStatusCls('disabled'), - el = self.get('el'); - el[v ? 'addClass' : 'removeClass'](componentCls) - .attr('aria-disabled', v); - - //如果禁用控件时,处于hover状态,则清除 - if (v && self.get('highlighted')) { - self.set('highlighted', false); - } - - if (self.get('focusable')) { - //不能被 tab focus 到 - self.getKeyEventTarget().attr('tabIndex', v ? -1 : 0); - } - }, - /** - * 设置激活状态 - * @protected - */ - _uiSetActive: function(v) { - var self = this, - componentCls = self.getStatusCls('active'); - self.get('el')[v ? 'addClass' : 'removeClass'](componentCls) - .attr('aria-pressed', !!v); - }, - /** - * 设置获得焦点 - * @protected - */ - _uiSetFocused: function(v) { - var self = this, - el = self.get('el'), - componentCls = self.getStatusCls('focused'); - el[v ? 'addClass' : 'removeClass'](componentCls); - }, - /** - * 设置控件最外层DOM的属性 - * @protected - */ - _uiSetElAttrs: function(attrs) { - this.get('el').attr(attrs); - }, - /** - * 设置应用到控件最外层DOM的css class - * @protected - */ - _uiSetElCls: function(cls) { - this.get('el').addClass(cls); - }, - /** - * 设置应用到控件最外层DOM的css style - * @protected - */ - _uiSetElStyle: function(style) { - this.get('el').css(style); - }, - //设置role - _uiSetRole: function(role) { - if (role) { - this.get('el').attr('role', role); - } - }, - /** - * 设置应用到控件宽度 - * @protected - */ - _uiSetWidth: function(w) { - this.get('el').width(w); - }, - /** - * 设置应用到控件高度 - * @protected - */ - _uiSetHeight: function(h) { - var self = this; - self.get('el').height(h); - }, - /** - * 设置应用到控件的内容 - * @protected - */ - _uiSetContent: function(c) { - var self = this, - el; - // srcNode 时不重新渲染 content - // 防止内部有改变,而 content 则是老的 html 内容 - if (self.get('srcNode') && !self.get('rendered')) {} else { - el = self.get('contentEl'); - if (typeof c == 'string') { - el.html(c); - } else if (c) { - el.empty().append(c); - } - } - }, - /** - * 设置应用到控件是否可见 - * @protected - */ - _uiSetVisible: function(isVisible) { - var self = this, - el = self.get('el'), - visibleMode = self.get('visibleMode'); - if (visibleMode === 'visibility') { - el.css('visibility', isVisible ? 'visible' : 'hidden'); - } else { - el.css('display', isVisible ? '' : 'none'); - } - }, - set: function(name, value) { - var _self = this, - attr = _self.__attrs[name], - ev, - ucName, - m; - - if (!attr || !_self.get('binded')) { //未初始化view或者没用定义属性 - View.superclass.set.call(this, name, value); - return _self; - } - - var prevVal = View.superclass.get.call(this, name); - - //如果未改变值不进行修改 - if (!$.isPlainObject(value) && !BUI.isArray(value) && prevVal === value) { - return _self; - } - View.superclass.set.call(this, name, value); - - value = _self.__attrVals[name]; - ev = { - attrName: name, - prevVal: prevVal, - newVal: value - }; - ucName = BUI.ucfirst(name); - m = '_uiSet' + ucName; - if (_self[m]) { - _self[m](value, ev); - } - - return _self; - - }, - /** - * 析构函数 - * @protected - */ - destructor: function() { - var el = this.get('el'); - if (el) { - el.remove(); - } - } -}, { - xclass: 'view', - priority: 0 -}); - - -View.ATTRS = { - /** - * 控件根节点 - * @readOnly - * see {@link BUI.Component.Controller#property-el} - */ - el: { - /** - * @private - */ - setter: function(v) { - return $(v); - } - }, - - /** - * 控件根节点样式 - * see {@link BUI.Component.Controller#property-elCls} - */ - elCls: {}, - /** - * 控件根节点样式属性 - * see {@link BUI.Component.Controller#property-elStyle} - */ - elStyle: {}, - /** - * ARIA 标准中的role - * @type {String} - */ - role: { - - }, - /** - * 控件宽度 - * see {@link BUI.Component.Controller#property-width} - */ - width: {}, - /** - * 控件高度 - * see {@link BUI.Component.Controller#property-height} - */ - height: {}, - /** - * 状态相关的样式,默认情况下会使用 前缀名 + xclass + '-' + 状态名 - * see {@link BUI.Component.Controller#property-statusCls} - * @type {Object} - */ - statusCls: { - value: {} - }, - /** - * 控件根节点使用的标签 - * @type {String} - */ - elTagName: { - // 生成标签名字 - value: 'div' - }, - /** - * 控件根节点属性 - * see {@link BUI.Component.Controller#property-elAttrs} - * @ignore - */ - elAttrs: {}, - /** - * 控件内容,html,文本等 - * see {@link BUI.Component.Controller#property-content} - */ - content: {}, - /** - * 控件插入到指定元素前 - * see {@link BUI.Component.Controller#property-tpl} - */ - elBefore: { - // better named to renderBefore, too late ! - }, - /** - * 控件在指定元素内部渲染 - * see {@link BUI.Component.Controller#property-render} - * @ignore - */ - render: {}, - /** - * 是否可见 - * see {@link BUI.Component.Controller#property-visible} - */ - visible: { - value: true - }, - /** - * 可视模式 - * see {@link BUI.Component.Controller#property-visibleMode} - */ - visibleMode: { - value: 'display' - }, - /** - * @private - * 缓存隐藏时的位置,对应visibleMode = 'visiblity' 的场景 - * @type {Object} - */ - cachePosition: { - - }, - /** - * content 设置的内容节点,默认根节点 - * @type {jQuery} - * @default el - */ - contentEl: { - valueFn: function() { - return this.get('el'); - } - }, - /** - * 样式前缀 - * see {@link BUI.Component.Controller#property-prefixCls} - */ - prefixCls: { - value: BUI.prefix - }, - /** - * 可以获取焦点 - * @protected - * see {@link BUI.Component.Controller#property-focusable} - */ - focusable: { - value: true - }, - /** - * 获取焦点 - * see {@link BUI.Component.Controller#property-focused} - */ - focused: {}, - /** - * 激活 - * see {@link BUI.Component.Controller#property-active} - */ - active: {}, - /** - * 禁用 - * see {@link BUI.Component.Controller#property-disabled} - */ - disabled: {}, - /** - * 高亮显示 - * see {@link BUI.Component.Controller#property-highlighted} - */ - highlighted: {} -}; - -module.exports = View; diff --git a/spm_modules/bui-common/1.1.2/src/date.js b/spm_modules/bui-common/1.1.2/src/date.js deleted file mode 100644 index eadecc2..0000000 --- a/spm_modules/bui-common/1.1.2/src/date.js +++ /dev/null @@ -1,458 +0,0 @@ -/* - * @fileOverview Date Format 1.2.3 - * @ignore - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - * - * Last modified by jayli 拔赤 2010-09-09 - * - 增加中文的支持 - * - 简单的本地化,对w(星期x)的支持 - * - */ - -var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/; - -function dateParse(val, format) { - if (val instanceof Date) { - return val; - } - if (typeof(format) == "undefined" || format == null || format == "") { - var checkList = new Array('y-m-d', 'yyyy-mm-dd', 'yyyy-mm-dd HH:MM:ss', 'H:M:s'); - for (var i = 0; i < checkList.length; i++) { - var d = dateParse(val, checkList[i]); - if (d != null) { - return d; - } - } - return null; - }; - val = val + ""; - var i_val = 0; - var i_format = 0; - var c = ""; - var token = ""; - var x, y; - var now = new Date(); - var year = now.getYear(); - var month = now.getMonth() + 1; - var date = 1; - var hh = 00; - var mm = 00; - var ss = 00; - this.isInteger = function(val) { - return /^\d*$/.test(val); - }; - this.getInt = function(str, i, minlength, maxlength) { - for (var x = maxlength; x >= minlength; x--) { - var token = str.substring(i, i + x); - if (token.length < minlength) { - return null; - } - if (this.isInteger(token)) { - return token; - } - } - return null; - }; - - while (i_format < format.length) { - c = format.charAt(i_format); - token = ""; - while ((format.charAt(i_format) == c) && (i_format < format.length)) { - token += format.charAt(i_format++); - } - if (token == "yyyy" || token == "yy" || token == "y") { - if (token == "yyyy") { - x = 4; - y = 4; - } - if (token == "yy") { - x = 2; - y = 2; - } - if (token == "y") { - x = 2; - y = 4; - } - year = this.getInt(val, i_val, x, y); - if (year == null) { - return null; - } - i_val += year.length; - if (year.length == 2) { - year = year > 70 ? 1900 + (year - 0) : 2000 + (year - 0); - } - } else if (token == "mm" || token == "m") { - month = this.getInt(val, i_val, token.length, 2); - if (month == null || (month < 1) || (month > 12)) { - return null; - } - i_val += month.length; - } else if (token == "dd" || token == "d") { - date = this.getInt(val, i_val, token.length, 2); - if (date == null || (date < 1) || (date > 31)) { - return null; - } - i_val += date.length; - } else if (token == "hh" || token == "h") { - hh = this.getInt(val, i_val, token.length, 2); - if (hh == null || (hh < 1) || (hh > 12)) { - return null; - } - i_val += hh.length; - } else if (token == "HH" || token == "H") { - hh = this.getInt(val, i_val, token.length, 2); - if (hh == null || (hh < 0) || (hh > 23)) { - return null; - } - i_val += hh.length; - } else if (token == "MM" || token == "M") { - mm = this.getInt(val, i_val, token.length, 2); - if (mm == null || (mm < 0) || (mm > 59)) { - return null; - } - i_val += mm.length; - } else if (token == "ss" || token == "s") { - ss = this.getInt(val, i_val, token.length, 2); - if (ss == null || (ss < 0) || (ss > 59)) { - return null; - } - i_val += ss.length; - } else { - if (val.substring(i_val, i_val + token.length) != token) { - return null; - } else { - i_val += token.length; - } - } - } - if (i_val != val.length) { - return null; - } - if (month == 2) { - if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { // leap year - if (date > 29) { - return null; - } - } else { - if (date > 28) { - return null; - } - } - } - if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) { - if (date > 30) { - return null; - } - } - return new Date(year, month - 1, date, hh, mm, ss); -} - -function DateAdd(strInterval, NumDay, dtDate) { - var dtTmp = new Date(dtDate); - if (isNaN(dtTmp)) { - dtTmp = new Date(); - } - NumDay = parseInt(NumDay, 10); - switch (strInterval) { - case 's': - dtTmp = new Date(dtTmp.getTime() + (1000 * NumDay)); - break; - case 'n': - dtTmp = new Date(dtTmp.getTime() + (60000 * NumDay)); - break; - case 'h': - dtTmp = new Date(dtTmp.getTime() + (3600000 * NumDay)); - break; - case 'd': - dtTmp = new Date(dtTmp.getTime() + (86400000 * NumDay)); - break; - case 'w': - dtTmp = new Date(dtTmp.getTime() + ((86400000 * 7) * NumDay)); - break; - case 'm': - dtTmp = new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + NumDay, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds()); - break; - case 'y': - //alert(dtTmp.getFullYear()); - dtTmp = new Date(dtTmp.getFullYear() + NumDay, dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds()); - //alert(dtTmp); - break; - } - return dtTmp; -} - -var dateFormat = function() { - var token = /w{1}|d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function(val, len) { - val = String(val); - len = len || 2; - while (val.length < len) { - val = '0' + val; - } - return val; - }, - // Some common format strings - masks = { - 'default': 'ddd mmm dd yyyy HH:MM:ss', - shortDate: 'm/d/yy', - //mediumDate: 'mmm d, yyyy', - longDate: 'mmmm d, yyyy', - fullDate: 'dddd, mmmm d, yyyy', - shortTime: 'h:MM TT', - //mediumTime: 'h:MM:ss TT', - longTime: 'h:MM:ss TT Z', - isoDate: 'yyyy-mm-dd', - isoTime: 'HH:MM:ss', - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUTCDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'", - - //added by jayli - localShortDate: 'yy年mm月dd日', - localShortDateTime: 'yy年mm月dd日 hh:MM:ss TT', - localLongDate: 'yyyy年mm月dd日', - localLongDateTime: 'yyyy年mm月dd日 hh:MM:ss TT', - localFullDate: 'yyyy年mm月dd日 w', - localFullDateTime: 'yyyy年mm月dd日 w hh:MM:ss TT' - - }, - - // Internationalization strings - i18n = { - dayNames: [ - 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', - 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', - '星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六' - ], - monthNames: [ - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', - 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' - ] - }; - - // Regexes and supporting functions are cached through closure - return function(date, mask, utc) { - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length === 1 && Object.prototype.toString.call(date) === '[object String]' && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date(); - if (isNaN(date)) { - throw SyntaxError('invalid date'); - } - - mask = String(masks[mask] || mask || masks['default']); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) === 'UTC:') { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? 'getUTC' : 'get', - d = date[_ + 'Date'](), - D = date[_ + 'Day'](), - m = date[_ + 'Month'](), - y = date[_ + 'FullYear'](), - H = date[_ + 'Hours'](), - M = date[_ + 'Minutes'](), - s = date[_ + 'Seconds'](), - L = date[_ + 'Milliseconds'](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d, undefined), - ddd: i18n.dayNames[D], - dddd: i18n.dayNames[D + 7], - w: i18n.dayNames[D + 14], - m: m + 1, - mm: pad(m + 1, undefined), - mmm: i18n.monthNames[m], - mmmm: i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12, undefined), - H: H, - HH: pad(H, undefined), - M: M, - MM: pad(M, undefined), - s: s, - ss: pad(s, undefined), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L, undefined), - t: H < 12 ? 'a' : 'p', - tt: H < 12 ? 'am' : 'pm', - T: H < 12 ? 'A' : 'P', - TT: H < 12 ? 'AM' : 'PM', - Z: utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''), - o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 !== 10) * d % 10] - }; - - return mask.replace(token, function($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -/** - * 日期的工具方法 - * @class BUI.Date - */ -var DateUtil = { - /** - * 日期加法 - * @param {String} strInterval 加法的类型,s(秒),n(分),h(时),d(天),w(周),m(月),y(年) - * @param {Number} Num 数量,如果为负数,则为减法 - * @param {Date} dtDate 起始日期,默认为此时 - */ - add: function(strInterval, Num, dtDate) { - return DateAdd(strInterval, Num, dtDate); - }, - /** - * 小时的加法 - * @param {Number} hours 小时 - * @param {Date} date 起始日期 - */ - addHour: function(hours, date) { - return DateAdd('h', hours, date); - }, - /** - * 分的加法 - * @param {Number} minutes 分 - * @param {Date} date 起始日期 - */ - addMinute: function(minutes, date) { - return DateAdd('n', minutes, date); - }, - /** - * 秒的加法 - * @param {Number} seconds 秒 - * @param {Date} date 起始日期 - */ - addSecond: function(seconds, date) { - return DateAdd('s', seconds, date); - }, - /** - * 天的加法 - * @param {Number} days 天数 - * @param {Date} date 起始日期 - */ - addDay: function(days, date) { - return DateAdd('d', days, date); - }, - /** - * 增加周 - * @param {Number} weeks 周数 - * @param {Date} date 起始日期 - */ - addWeek: function(weeks, date) { - return DateAdd('w', weeks, date); - }, - /** - * 增加月 - * @param {Number} months 月数 - * @param {Date} date 起始日期 - */ - addMonths: function(months, date) { - return DateAdd('m', months, date); - }, - /** - * 增加年 - * @param {Number} years 年数 - * @param {Date} date 起始日期 - */ - addYear: function(years, date) { - return DateAdd('y', years, date); - }, - /** - * 日期是否相等,忽略时间 - * @param {Date} d1 日期对象 - * @param {Date} d2 日期对象 - * @return {Boolean} 是否相等 - */ - isDateEquals: function(d1, d2) { - - return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate(); - }, - /** - * 日期时间是否相等,包含时间 - * @param {Date} d1 日期对象 - * @param {Date} d2 日期对象 - * @return {Boolean} 是否相等 - */ - isEquals: function(d1, d2) { - if (d1 == d2) { - return true; - } - if (!d1 || !d2) { - return false; - } - if (!d1.getTime || !d2.getTime) { - return false; - } - return d1.getTime() == d2.getTime(); - }, - /** - * 字符串是否是有效的日期类型 - * @param {String} str 字符串 - * @return 字符串是否能转换成日期 - */ - isDateString: function(str) { - return dateRegex.test(str); - }, - /** - * 将日期格式化成字符串 - * @param {Date} date 日期 - * @param {String} mask 格式化方式 - * @param {Date} utc 是否utc时间 - * @return {String} 日期的字符串 - */ - format: function(date, mask, utc) { - return dateFormat(date, mask, utc); - }, - /** - * 转换成日期 - * @param {String|Date} date 字符串或者日期 - * @param {String} dateMask 日期的格式,如:yyyy-MM-dd - * @return {Date} 日期对象 - */ - parse: function(date, s) { - if (BUI.isString(date)) { - date = date.replace('\/', '-'); - } - return dateParse(date, s); - }, - /** - * 当前天 - * @return {Date} 当前天 00:00:00 - */ - today: function() { - var now = new Date(); - return new Date(now.getFullYear(), now.getMonth(), now.getDate()); - }, - /** - * 返回当前日期 - * @return {Date} 日期的 00:00:00 - */ - getDate: function(date) { - return new Date(date.getFullYear(), date.getMonth(), date.getDate()); - } -}; - -module.exports = DateUtil; diff --git a/spm_modules/bui-common/1.1.2/src/json.js b/spm_modules/bui-common/1.1.2/src/json.js deleted file mode 100644 index dc05e0f..0000000 --- a/spm_modules/bui-common/1.1.2/src/json.js +++ /dev/null @@ -1,280 +0,0 @@ -/** - * @fileOverview 由于jQuery只有 parseJSON ,没有stringify所以使用过程不方便 - * @ignore - */ - -var $ = require('jquery'), - UA = require('./ua'), - win = window, - JSON = win.JSON; - -// ie 8.0.7600.16315@win7 json 有问题 -if (!JSON || UA['ie'] < 9) { - JSON = win.JSON = {}; -} - -function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; -} - -if (typeof Date.prototype.toJSON !== 'function') { - - Date.prototype.toJSON = function(key) { - - return isFinite(this.valueOf()) ? - this.getUTCFullYear() + '-' + - f(this.getUTCMonth() + 1) + '-' + - f(this.getUTCDate()) + 'T' + - f(this.getUTCHours()) + ':' + - f(this.getUTCMinutes()) + ':' + - f(this.getUTCSeconds()) + 'Z' : null; - }; - - String.prototype.toJSON = - Number.prototype.toJSON = - Boolean.prototype.toJSON = function(key) { - return this.valueOf(); - }; -} - - -var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"': '\\"', - '\\': '\\\\' - }, - rep; - -function quote(string) { - - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable['lastIndex'] = 0; - return escapable.test(string) ? - '"' + string.replace(escapable, function(a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : - '"' + string + '"'; -} - -function str(key, holder) { - - // Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - // If the value has a toJSON method, call it to obtain a replacement value. - - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - - // JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - - return String(value); - - // If the type is 'object', we might be dealing with an object or an array or - // null. - - case 'object': - - // Due to a specification blunder in ECMAScript, typeof null is 'object', - // so watch out for that case. - - if (!value) { - return 'null'; - } - - // Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - - // Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - - // The value is an array. Stringify every element. Use null as a placeholder - // for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and wrap them in - // brackets. - - v = partial.length === 0 ? '[]' : - gap ? '[\n' + gap + - partial.join(',\n' + gap) + '\n' + - mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - - // Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 ? '{}' : - gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + - mind + '}' : '{' + partial.join(',') + '}'; - gap = mind; - return v; - } -} - -if (typeof JSON.stringify !== 'function') { - JSON.stringify = function(value, replacer, space) { - - // The stringify method takes a value and an optional replacer, and an optional - // space parameter, and returns a JSON text. The replacer can be a function - // that can replace values, or an array of strings that will select the keys. - // A default replacer method can be provided. Use of the space parameter can - // produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - - // If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - - return str('', { - '': value - }); - }; -} - -function looseParse(data) { - try { - return new Function('return ' + data + ';')(); - } catch (e) { - throw 'Json parse error!'; - } -} -/** - * JSON 格式化 - * @class BUI.JSON - * @singleton - */ -var JSON = { - /** - * 转成json 等同于$.parseJSON - * @method - * @param {String} jsonstring 合法的json 字符串 - */ - parse: $.parseJSON, - /** - * 业务中有些字符串组成的json数据不是严格的json数据,如使用单引号,或者属性名不是字符串 - * 如 : {a:'abc'} - * @method - * @param {String} jsonstring - */ - looseParse: looseParse, - /** - * 将Json转成字符串 - * @method - * @param {Object} json json 对象 - */ - stringify: JSON.stringify -} - -module.exports = JSON; diff --git a/spm_modules/bui-common/1.1.2/src/keycode.js b/spm_modules/bui-common/1.1.2/src/keycode.js deleted file mode 100644 index 5386075..0000000 --- a/spm_modules/bui-common/1.1.2/src/keycode.js +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @fileOverview 键盘值 - * @ignore - */ - -/** - * 键盘按键对应的数字值 - * @class BUI.KeyCode - * @singleton - */ -var keyCode = { - /** Key constant @type Number */ - BACKSPACE: 8, - /** Key constant @type Number */ - TAB: 9, - /** Key constant @type Number */ - NUM_CENTER: 12, - /** Key constant @type Number */ - ENTER: 13, - /** Key constant @type Number */ - RETURN: 13, - /** Key constant @type Number */ - SHIFT: 16, - /** Key constant @type Number */ - CTRL: 17, - /** Key constant @type Number */ - ALT: 18, - /** Key constant @type Number */ - PAUSE: 19, - /** Key constant @type Number */ - CAPS_LOCK: 20, - /** Key constant @type Number */ - ESC: 27, - /** Key constant @type Number */ - SPACE: 32, - /** Key constant @type Number */ - PAGE_UP: 33, - /** Key constant @type Number */ - PAGE_DOWN: 34, - /** Key constant @type Number */ - END: 35, - /** Key constant @type Number */ - HOME: 36, - /** Key constant @type Number */ - LEFT: 37, - /** Key constant @type Number */ - UP: 38, - /** Key constant @type Number */ - RIGHT: 39, - /** Key constant @type Number */ - DOWN: 40, - /** Key constant @type Number */ - PRINT_SCREEN: 44, - /** Key constant @type Number */ - INSERT: 45, - /** Key constant @type Number */ - DELETE: 46, - /** Key constant @type Number */ - ZERO: 48, - /** Key constant @type Number */ - ONE: 49, - /** Key constant @type Number */ - TWO: 50, - /** Key constant @type Number */ - THREE: 51, - /** Key constant @type Number */ - FOUR: 52, - /** Key constant @type Number */ - FIVE: 53, - /** Key constant @type Number */ - SIX: 54, - /** Key constant @type Number */ - SEVEN: 55, - /** Key constant @type Number */ - EIGHT: 56, - /** Key constant @type Number */ - NINE: 57, - /** Key constant @type Number */ - A: 65, - /** Key constant @type Number */ - B: 66, - /** Key constant @type Number */ - C: 67, - /** Key constant @type Number */ - D: 68, - /** Key constant @type Number */ - E: 69, - /** Key constant @type Number */ - F: 70, - /** Key constant @type Number */ - G: 71, - /** Key constant @type Number */ - H: 72, - /** Key constant @type Number */ - I: 73, - /** Key constant @type Number */ - J: 74, - /** Key constant @type Number */ - K: 75, - /** Key constant @type Number */ - L: 76, - /** Key constant @type Number */ - M: 77, - /** Key constant @type Number */ - N: 78, - /** Key constant @type Number */ - O: 79, - /** Key constant @type Number */ - P: 80, - /** Key constant @type Number */ - Q: 81, - /** Key constant @type Number */ - R: 82, - /** Key constant @type Number */ - S: 83, - /** Key constant @type Number */ - T: 84, - /** Key constant @type Number */ - U: 85, - /** Key constant @type Number */ - V: 86, - /** Key constant @type Number */ - W: 87, - /** Key constant @type Number */ - X: 88, - /** Key constant @type Number */ - Y: 89, - /** Key constant @type Number */ - Z: 90, - /** Key constant @type Number */ - CONTEXT_MENU: 93, - /** Key constant @type Number */ - NUM_ZERO: 96, - /** Key constant @type Number */ - NUM_ONE: 97, - /** Key constant @type Number */ - NUM_TWO: 98, - /** Key constant @type Number */ - NUM_THREE: 99, - /** Key constant @type Number */ - NUM_FOUR: 100, - /** Key constant @type Number */ - NUM_FIVE: 101, - /** Key constant @type Number */ - NUM_SIX: 102, - /** Key constant @type Number */ - NUM_SEVEN: 103, - /** Key constant @type Number */ - NUM_EIGHT: 104, - /** Key constant @type Number */ - NUM_NINE: 105, - /** Key constant @type Number */ - NUM_MULTIPLY: 106, - /** Key constant @type Number */ - NUM_PLUS: 107, - /** Key constant @type Number */ - NUM_MINUS: 109, - /** Key constant @type Number */ - NUM_PERIOD: 110, - /** Key constant @type Number */ - NUM_DIVISION: 111, - /** Key constant @type Number */ - F1: 112, - /** Key constant @type Number */ - F2: 113, - /** Key constant @type Number */ - F3: 114, - /** Key constant @type Number */ - F4: 115, - /** Key constant @type Number */ - F5: 116, - /** Key constant @type Number */ - F6: 117, - /** Key constant @type Number */ - F7: 118, - /** Key constant @type Number */ - F8: 119, - /** Key constant @type Number */ - F9: 120, - /** Key constant @type Number */ - F10: 121, - /** Key constant @type Number */ - F11: 122, - /** Key constant @type Number */ - F12: 123 -}; - -module.exports = keyCode; diff --git a/spm_modules/bui-common/1.1.2/src/observable.js b/spm_modules/bui-common/1.1.2/src/observable.js deleted file mode 100644 index 04e84b7..0000000 --- a/spm_modules/bui-common/1.1.2/src/observable.js +++ /dev/null @@ -1,387 +0,0 @@ -/** - * @fileOverview 观察者模式实现事件 - * @ignore - */ - -var $ = require('jquery'); - -var BUI = require('./util'), - ArrayUtil = require('./array'); -/** - * @private - * @class BUI.Observable.Callbacks - * jquery 1.7 时存在 $.Callbacks,但是fireWith的返回结果是$.Callbacks 对象, - * 而我们想要的效果是:当其中有一个函数返回为false时,阻止后面的执行,并返回false - */ -var Callbacks = function() { - this._init(); -}; - -BUI.augment(Callbacks, { - - _functions: null, - - _init: function() { - var _self = this; - - _self._functions = []; - }, - /** - * 添加回调函数 - * @param {Function} fn 回调函数 - */ - add: function(fn) { - this._functions.push(fn); - }, - /** - * 移除回调函数 - * @param {Function} fn 回调函数 - */ - remove: function(fn) { - var functions = this._functions; - index = ArrayUtil.indexOf(fn, functions); - if (index >= 0) { - functions.splice(index, 1); - } - }, - /** - * 清空事件 - */ - empty: function() { - var length = this._functions.length; //ie6,7下,必须指定需要删除的数量 - this._functions.splice(0, length); - }, - /** - * 暂停事件 - */ - pause: function() { - this._paused = true; - }, - /** - * 唤醒事件 - */ - resume: function() { - this._paused = false; - }, - /** - * 触发回调 - * @param {Object} scope 上下文 - * @param {Array} args 回调函数的参数 - * @return {Boolean|undefined} 当其中有一个函数返回为false时,阻止后面的执行,并返回false - */ - fireWith: function(scope, args) { - var _self = this, - rst; - if (_self._paused) { - return; - } - BUI.each(_self._functions, function(fn) { - rst = fn.apply(scope, args); - if (rst === false) { - return false; - } - }); - return rst; - } -}); - -function getCallbacks() { - return new Callbacks(); -} -/** - * 支持事件的对象,参考观察者模式 - * - 此类提供事件绑定 - * - 提供事件冒泡机制 - * - *
    
    - *   var control = new Control();
    - *   control.on('click',function(ev){
    - *
    - *   });
    - *
    - *   control.off();  //移除所有事件
    - * 
    - * @class BUI.Observable - * @abstract - * @param {Object} config 配置项键值对 - */ -var Observable = function(config) { - this._events = []; - this._eventMap = {}; - this._bubblesEvents = []; - this._initEvents(config); -}; - -BUI.augment(Observable, { - - /** - * @cfg {Object} listeners - * 初始化事件,快速注册事件 - *
    
    -   *    var list = new BUI.List.SimpleList({
    -   *      listeners : {
    -   *        itemclick : function(ev){},
    -   *        itemrendered : function(ev){}
    -   *      },
    -   *      items : []
    -   *    });
    -   *    list.render();
    -   *  
    - */ - - /** - * @cfg {Function} handler - * 点击事件的处理函数,快速配置点击事件而不需要写listeners属性 - *
    
    -   *    var list = new BUI.List.SimpleList({
    -   *      handler : function(ev){} //click 事件
    -   *    });
    -   *    list.render();
    -   *  
    - */ - - /** - * 支持的事件名列表 - * @private - */ - _events: [], - - /** - * 绑定的事件 - * @private - */ - _eventMap: {}, - - _bubblesEvents: [], - - _bubbleTarget: null, - - //获取回调集合 - _getCallbacks: function(eventType) { - var _self = this, - eventMap = _self._eventMap; - return eventMap[eventType]; - }, - //初始化事件列表 - _initEvents: function(config) { - var _self = this, - listeners = null; - - if (!config) { - return; - } - listeners = config.listeners || {}; - if (config.handler) { - listeners.click = config.handler; - } - if (listeners) { - for (var name in listeners) { - if (listeners.hasOwnProperty(name)) { - _self.on(name, listeners[name]); - } - }; - } - }, - //事件是否支持冒泡 - _isBubbles: function(eventType) { - return ArrayUtil.indexOf(eventType, this._bubblesEvents) >= 0; - }, - /** - * 添加冒泡的对象 - * @protected - * @param {Object} target 冒泡的事件源 - */ - addTarget: function(target) { - this._bubbleTarget = target; - }, - /** - * 添加支持的事件 - * @protected - * @param {String|String[]} events 事件 - */ - addEvents: function(events) { - var _self = this, - existEvents = _self._events, - eventMap = _self._eventMap; - - function addEvent(eventType) { - if (ArrayUtil.indexOf(eventType, existEvents) === -1) { - eventMap[eventType] = getCallbacks(); - existEvents.push(eventType); - } - } - if (BUI.isArray(events)) { - BUI.each(events, function(eventType) { - addEvent(eventType); - }); - } else { - addEvent(events); - } - }, - /** - * 移除所有绑定的事件 - * @protected - */ - clearListeners: function() { - var _self = this, - eventMap = _self._eventMap; - for (var name in eventMap) { - if (eventMap.hasOwnProperty(name)) { - eventMap[name].empty(); - } - } - }, - /** - * 触发事件 - *
    
    -   *   //绑定事件
    -   *   list.on('itemclick',function(ev){
    -   *     alert('21');
    -   *   });
    -   *   //触发事件
    -   *   list.fire('itemclick');
    -   * 
    - * @param {String} eventType 事件类型 - * @param {Object} eventData 事件触发时传递的数据 - * @return {Boolean|undefined} 如果其中一个事件处理器返回 false , 则返回 false, 否则返回最后一个事件处理器的返回值 - */ - fire: function(eventType, eventData) { - var _self = this, - callbacks = _self._getCallbacks(eventType), - args = $.makeArray(arguments), - result; - if (!eventData) { - eventData = {}; - args.push(eventData); - } - if (!eventData.target) { - eventData.target = _self; - } - if (callbacks) { - result = callbacks.fireWith(_self, Array.prototype.slice.call(args, 1)); - } - if (_self._isBubbles(eventType)) { - var bubbleTarget = _self._bubbleTarget; - if (bubbleTarget && bubbleTarget.fire) { - bubbleTarget.fire(eventType, eventData); - } - } - return result; - }, - /** - * 暂停事件的执行 - *
    
    -   *  list.pauseEvent('itemclick');
    -   * 
    - * @param {String} eventType 事件类型 - */ - pauseEvent: function(eventType) { - var _self = this, - callbacks = _self._getCallbacks(eventType); - callbacks && callbacks.pause(); - }, - /** - * 唤醒事件 - *
    
    -   *  list.resumeEvent('itemclick');
    -   * 
    - * @param {String} eventType 事件类型 - */ - resumeEvent: function(eventType) { - var _self = this, - callbacks = _self._getCallbacks(eventType); - callbacks && callbacks.resume(); - }, - /** - * 添加绑定事件 - *
    
    -   *   //绑定单个事件
    -   *   list.on('itemclick',function(ev){
    -   *     alert('21');
    -   *   });
    -   *   //绑定多个事件
    -   *   list.on('itemrendered itemupdated',function(){
    -   *     //列表项创建、更新时触发操作
    -   *   });
    -   * 
    - * @param {String} eventType 事件类型 - * @param {Function} fn 回调函数 - */ - on: function(eventType, fn) { - //一次监听多个事件 - var arr = eventType.split(' '), - _self = this, - callbacks = null; - if (arr.length > 1) { - BUI.each(arr, function(name) { - _self.on(name, fn); - }); - } else { - callbacks = _self._getCallbacks(eventType); - if (callbacks) { - callbacks.add(fn); - } else { - _self.addEvents(eventType); - _self.on(eventType, fn); - } - } - return _self; - }, - /** - * 移除绑定的事件 - *
    
    -   *  //移除所有事件
    -   *  list.off();
    -   *
    -   *  //移除特定事件
    -   *  function callback(ev){}
    -   *  list.on('click',callback);
    -   *
    -   *  list.off('click',callback);//需要保存回调函数的引用
    -   *
    -   * 
    - * @param {String} eventType 事件类型 - * @param {Function} fn 回调函数 - */ - off: function(eventType, fn) { - if (!eventType && !fn) { - this.clearListeners(); - return this; - } - var _self = this, - callbacks = _self._getCallbacks(eventType); - if (callbacks) { - if (fn) { - callbacks.remove(fn); - } else { - callbacks.empty(); - } - - } - return _self; - }, - /** - * 配置事件是否允许冒泡 - * @protected - * @param {String} eventType 支持冒泡的事件 - * @param {Object} cfg 配置项 - * @param {Boolean} cfg.bubbles 是否支持冒泡 - */ - publish: function(eventType, cfg) { - var _self = this, - bubblesEvents = _self._bubblesEvents; - - if (cfg.bubbles) { - if (BUI.Array.indexOf(eventType, bubblesEvents) === -1) { - bubblesEvents.push(eventType); - } - } else { - var index = BUI.Array.indexOf(eventType, bubblesEvents); - if (index !== -1) { - bubblesEvents.splice(index, 1); - } - } - } -}); - -module.exports = Observable; diff --git a/spm_modules/bui-common/1.1.2/src/ua.js b/spm_modules/bui-common/1.1.2/src/ua.js deleted file mode 100644 index f3c3300..0000000 --- a/spm_modules/bui-common/1.1.2/src/ua.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @fileOverview UA,jQuery的 $.browser 对象非常难使用 - * @ignore - * @author dxq613@gmail.com - */ - -var $ = require('jquery'); - -function numberify(s) { - var c = 0; - // convert '1.2.3.4' to 1.234 - return parseFloat(s.replace(/\./g, function() { - return (c++ === 0) ? '.' : ''; - })); -}; - -function uaMatch(s) { - s = s.toLowerCase(); - var r = /(chrome)[ \/]([\w.]+)/.exec(s) || /(webkit)[ \/]([\w.]+)/.exec(s) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(s) || /(msie) ([\w.]+)/.exec(s) || s.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(s) || [], - a = { - browser: r[1] || "", - version: r[2] || "0" - }, - b = {}; - a.browser && (b[a.browser] = !0, b.version = a.version), - b.chrome ? b.webkit = !0 : b.webkit && (b.safari = !0); - return b; -} - -var UA = $.UA || (function() { - var browser = $.browser || uaMatch(navigator.userAgent), - versionNumber = numberify(browser.version), - /** - * 浏览器版本检测 - * @class BUI.UA - * @singleton - */ - ua = { - /** - * ie 版本 - * @type {Number} - */ - ie: browser.msie && versionNumber, - - /** - * webkit 版本 - * @type {Number} - */ - webkit: browser.webkit && versionNumber, - /** - * opera 版本 - * @type {Number} - */ - opera: browser.opera && versionNumber, - /** - * mozilla 火狐版本 - * @type {Number} - */ - mozilla: browser.mozilla && versionNumber - }; - return ua; -})(); - -module.exports = UA; diff --git a/spm_modules/bui-common/1.1.2/src/util.js b/spm_modules/bui-common/1.1.2/src/util.js deleted file mode 100644 index 036eb8d..0000000 --- a/spm_modules/bui-common/1.1.2/src/util.js +++ /dev/null @@ -1,704 +0,0 @@ -/** - * @class BUI - * 控件库的工具方法,这些工具方法直接绑定到BUI对象上 - *
    
    - *   BUI.isString(str);
    - *
    - *   BUI.extend(A,B);
    - *
    - *   BUI.mix(A,{a:'a'});
    - * 
    - * @singleton - */ - -var $ = require('jquery'); - -//兼容jquery 1.6以下 -(function($) { - if ($.fn) { - $.fn.on = $.fn.on || $.fn.bind; - $.fn.off = $.fn.off || $.fn.unbind; - } -})($); -/** - * @ignore - * 处于效率的目的,复制属性 - */ -function mixAttrs(to, from) { - - for (var c in from) { - if (from.hasOwnProperty(c)) { - to[c] = to[c] || {}; - mixAttr(to[c], from[c]); - } - } - -} -//合并属性 -function mixAttr(attr, attrConfig) { - for (var p in attrConfig) { - if (attrConfig.hasOwnProperty(p)) { - if (p == 'value') { - if (BUI.isObject(attrConfig[p])) { - attr[p] = attr[p] || {}; - BUI.mix( /*true,*/ attr[p], attrConfig[p]); - } else if (BUI.isArray(attrConfig[p])) { - attr[p] = attr[p] || []; - //BUI.mix(/*true,*/attr[p], attrConfig[p]); - attr[p] = attr[p].concat(attrConfig[p]); - } else { - attr[p] = attrConfig[p]; - } - } else { - attr[p] = attrConfig[p]; - } - } - }; -} - -var win = window, - doc = document, - objectPrototype = Object.prototype, - toString = objectPrototype.toString, - BODY = 'body', - DOC_ELEMENT = 'documentElement', - SCROLL = 'scroll', - SCROLL_WIDTH = SCROLL + 'Width', - SCROLL_HEIGHT = SCROLL + 'Height', - ATTRS = 'ATTRS', - PARSER = 'PARSER', - GUID_DEFAULT = 'guid'; - -window.BUI = window.BUI || {}; - -$.extend(BUI, { - /** - * 版本号 - * @memberOf BUI - * @type {Number} - */ - version: '1.1.0', - /** - * 是否为函数 - * @param {*} fn 对象 - * @return {Boolean} 是否函数 - */ - isFunction: function(fn) { - return typeof(fn) === 'function'; - }, - /** - * 是否数组 - * @method - * @param {*} obj 是否数组 - * @return {Boolean} 是否数组 - */ - isArray: ('isArray' in Array) ? Array.isArray : function(value) { - return toString.call(value) === '[object Array]'; - }, - /** - * 是否日期 - * @param {*} value 对象 - * @return {Boolean} 是否日期 - */ - isDate: function(value) { - return toString.call(value) === '[object Date]'; - }, - /** - * 是否是javascript对象 - * @param {Object} value The value to test - * @return {Boolean} - * @method - */ - isObject: (toString.call(null) === '[object Object]') ? - function(value) { - // check ownerDocument here as well to exclude DOM nodes - return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined; - } : function(value) { - return toString.call(value) === '[object Object]'; - }, - /** - * 是否是数字或者数字字符串 - * @param {String} value 数字字符串 - * @return {Boolean} 是否是数字或者数字字符串 - */ - isNumeric: function(value) { - return !isNaN(parseFloat(value)) && isFinite(value); - }, - /** - * 将指定的方法或属性放到构造函数的原型链上, - * 函数支持多于2个变量,后面的变量同s1一样将其成员复制到构造函数的原型链上。 - * @param {Function} r 构造函数 - * @param {Object} s1 将s1 的成员复制到构造函数的原型链上 - * @example - * BUI.augment(class1,{ - * method1: function(){ - * - * } - * }); - */ - augment: function(r, s1) { - if (!BUI.isFunction(r)) { - return r; - } - for (var i = 1; i < arguments.length; i++) { - BUI.mix(r.prototype, arguments[i].prototype || arguments[i]); - }; - return r; - }, - /** - * 拷贝对象 - * @param {Object} obj 要拷贝的对象 - * @return {Object} 拷贝生成的对象 - */ - cloneObject: function(obj) { - var result = BUI.isArray(obj) ? [] : {}; - - return BUI.mix(true, result, obj); - }, - /** - * 抛出错误 - */ - error: function(msg) { - if (BUI.debug) { - throw msg; - } - }, - - /** - * 实现类的继承,通过父类生成子类 - * @param {Function} subclass - * @param {Function} superclass 父类构造函数 - * @param {Object} overrides 子类的属性或者方法 - * @return {Function} 返回的子类构造函数 - * 示例: - * @example - * //父类 - * function base(){ - * - * } - * - * function sub(){ - * - * } - * //子类 - * BUI.extend(sub,base,{ - * method : function(){ - * - * } - * }); - * - * //或者 - * var sub = BUI.extend(base,{}); - */ - extend: function(subclass, superclass, overrides, staticOverrides) { - //如果只提供父类构造函数,则自动生成子类构造函数 - if (!BUI.isFunction(superclass)) { - - overrides = superclass; - superclass = subclass; - subclass = function() {}; - } - - var create = Object.create ? - function(proto, c) { - return Object.create(proto, { - constructor: { - value: c - } - }); - } : - function(proto, c) { - function F() {} - - F.prototype = proto; - - var o = new F(); - o.constructor = c; - return o; - }; - var superObj = create(superclass.prototype, subclass); //new superclass(),//实例化父类作为子类的prototype - subclass.prototype = BUI.mix(superObj, subclass.prototype); //指定子类的prototype - subclass.superclass = create(superclass.prototype, superclass); - BUI.mix(superObj, overrides); - BUI.mix(subclass, staticOverrides); - return subclass; - }, - /** - * 生成唯一的Id - * @method - * @param {String} prefix 前缀 - * @default 'bui-guid' - * @return {String} 唯一的编号 - */ - guid: (function() { - var map = {}; - return function(prefix) { - prefix = prefix || BUI.prefix + GUID_DEFAULT; - if (!map[prefix]) { - map[prefix] = 1; - } else { - map[prefix] += 1; - } - return prefix + map[prefix]; - }; - })(), - /** - * 判断是否是字符串 - * @return {Boolean} 是否是字符串 - */ - isString: function(value) { - return typeof value === 'string'; - }, - /** - * 判断是否数字,由于$.isNumberic方法会把 '123'认为数字 - * @return {Boolean} 是否数字 - */ - isNumber: function(value) { - return typeof value === 'number'; - }, - /** - * 是否是布尔类型 - * - * @param {Object} value 测试的值 - * @return {Boolean} - */ - isBoolean: function(value) { - return typeof value === 'boolean'; - }, - /** - * 控制台输出日志 - * @param {Object} obj 输出的数据 - */ - log: function(obj) { - if (BUI.debug && win.console && win.console.log) { - win.console.log(obj); - } - }, - /** - * 将多个对象的属性复制到一个新的对象 - */ - merge: function() { - var args = $.makeArray(arguments), - first = args[0]; - if (BUI.isBoolean(first)) { - args.shift(); - args.unshift({}); - args.unshift(first); - } else { - args.unshift({}); - } - - return BUI.mix.apply(null, args); - - }, - /** - * 封装 jQuery.extend 方法,将多个对象的属性merge到第一个对象中 - * @return {Object} - */ - mix: function() { - return $.extend.apply(null, arguments); - }, - /** - * 创造顶层的命名空间,附加到window对象上, - * 包含namespace方法 - */ - app: function(name) { - if (!window[name]) { - window[name] = { - namespace: function(nsName) { - return BUI.namespace(nsName, window[name]); - } - }; - } - return window[name]; - }, - - mixAttrs: mixAttrs, - - mixAttr: mixAttr, - - /** - * 将其他类作为mixin集成到指定类上面 - * @param {Function} c 构造函数 - * @param {Array} mixins 扩展类 - * @param {Array} attrs 扩展的静态属性,默认为['ATTRS'] - * @return {Function} 传入的构造函数 - */ - mixin: function(c, mixins, attrs) { - attrs = attrs || [ATTRS, PARSER]; - var extensions = mixins; - if (extensions) { - c.mixins = extensions; - - var desc = { - // ATTRS: - // HTML_PARSER: - }, - constructors = extensions['concat'](c); - - // [ex1,ex2],扩展类后面的优先,ex2 定义的覆盖 ex1 定义的 - // 主类最优先 - BUI.each(constructors, function(ext) { - if (ext) { - // 合并 ATTRS/HTML_PARSER 到主类 - BUI.each(attrs, function(K) { - if (ext[K]) { - desc[K] = desc[K] || {}; - // 不覆盖主类上的定义,因为继承层次上扩展类比主类层次高 - // 但是值是对象的话会深度合并 - // 注意:最好值是简单对象,自定义 new 出来的对象就会有问题(用 function return 出来)! - if (K == 'ATTRS') { - //BUI.mix(true,desc[K], ext[K]); - mixAttrs(desc[K], ext[K]); - } else { - BUI.mix(desc[K], ext[K]); - } - - } - }); - } - }); - - BUI.each(desc, function(v, k) { - c[k] = v; - }); - - var prototype = {}; - - // 主类最优先 - BUI.each(constructors, function(ext) { - if (ext) { - var proto = ext.prototype; - // 合并功能代码到主类,不覆盖 - for (var p in proto) { - // 不覆盖主类,但是主类的父类还是覆盖吧 - if (proto.hasOwnProperty(p)) { - prototype[p] = proto[p]; - } - } - } - }); - - BUI.each(prototype, function(v, k) { - c.prototype[k] = v; - }); - } - return c; - }, - /** - * 生成命名空间 - * @param {String} name 命名空间的名称 - * @param {Object} baseNS 在已有的命名空间上创建命名空间,默认“BUI” - * @return {Object} 返回的命名空间对象 - * @example - * BUI.namespace("Grid"); // BUI.Grid - */ - namespace: function(name, baseNS) { - baseNS = baseNS || BUI; - if (!name) { - return baseNS; - } - var list = name.split('.'), - //firstNS = win[list[0]], - curNS = baseNS; - - for (var i = 0; i < list.length; i++) { - var nsName = list[i]; - if (!curNS[nsName]) { - curNS[nsName] = {}; - } - curNS = curNS[nsName]; - }; - return curNS; - }, - /** - * BUI 控件的公用前缀 - * @type {String} - */ - prefix: 'bui-', - /** - * 替换字符串中的字段. - * @param {String} str 模版字符串 - * @param {Object} o json data - * @param {RegExp} [regexp] 匹配字符串的正则表达式 - */ - substitute: function(str, o, regexp) { - if (!BUI.isString(str) || (!BUI.isObject(o)) && !BUI.isArray(o)) { - return str; - } - - return str.replace(regexp || /\\?\{([^{}]+)\}/g, function(match, name) { - if (match.charAt(0) === '\\') { - return match.slice(1); - } - return (o[name] === undefined) ? '' : o[name]; - }); - }, - /** - * 将$.param的反操作 - * jquery只提供param方法 - * @return {[type]} [description] - */ - unparam: function(str){ - if (typeof str != 'string' || !(str = $.trim(str))) { - return {}; - } - var pairs = str.split('&'), - pairsArr, - rst = {}; - for(var i = pairs.length - 1; i >= 0; i--) { - pairsArr = pairs[i].split('='); - rst[pairsArr[0]] = decodeURIComponent(pairsArr[1]); - } - return rst; - }, - /** - * 使第一个字母变成大写 - * @param {String} s 字符串 - * @return {String} 首字母大写后的字符串 - */ - ucfirst: function(s) { - s += ''; - return s.charAt(0).toUpperCase() + s.substring(1); - }, - /** - * 页面上的一点是否在用户的视图内 - * @param {Object} offset 坐标,left,top - * @return {Boolean} 是否在视图内 - */ - isInView: function(offset) { - var left = offset.left, - top = offset.top, - viewWidth = BUI.viewportWidth(), - wiewHeight = BUI.viewportHeight(), - scrollTop = BUI.scrollTop(), - scrollLeft = BUI.scrollLeft(); - //判断横坐标 - if (left < scrollLeft || left > scrollLeft + viewWidth) { - return false; - } - //判断纵坐标 - if (top < scrollTop || top > scrollTop + wiewHeight) { - return false; - } - return true; - }, - /** - * 页面上的一点纵向坐标是否在用户的视图内 - * @param {Object} top 纵坐标 - * @return {Boolean} 是否在视图内 - */ - isInVerticalView: function(top) { - var wiewHeight = BUI.viewportHeight(), - scrollTop = BUI.scrollTop(); - - //判断纵坐标 - if (top < scrollTop || top > scrollTop + wiewHeight) { - return false; - } - return true; - }, - /** - * 页面上的一点横向坐标是否在用户的视图内 - * @param {Object} left 横坐标 - * @return {Boolean} 是否在视图内 - */ - isInHorizontalView: function(left) { - var viewWidth = BUI.viewportWidth(), - scrollLeft = BUI.scrollLeft(); - //判断横坐标 - if (left < scrollLeft || left > scrollLeft + viewWidth) { - return false; - } - return true; - }, - /** - * 获取窗口可视范围宽度 - * @return {Number} 可视区宽度 - */ - viewportWidth: function() { - return $(window).width(); - }, - /** - * 获取窗口可视范围高度 - * @return {Number} 可视区高度 - */ - viewportHeight: function() { - return $(window).height(); - }, - /** - * 滚动到窗口的left位置 - */ - scrollLeft: function() { - return $(window).scrollLeft(); - }, - /** - * 滚动到横向位置 - */ - scrollTop: function() { - return $(window).scrollTop(); - }, - /** - * 窗口宽度 - * @return {Number} 窗口宽度 - */ - docWidth: function() { - return Math.max(this.viewportWidth(), doc[DOC_ELEMENT][SCROLL_WIDTH], doc[BODY][SCROLL_WIDTH]); - }, - /** - * 窗口高度 - * @return {Number} 窗口高度 - */ - docHeight: function() { - return Math.max(this.viewportHeight(), doc[DOC_ELEMENT][SCROLL_HEIGHT], doc[BODY][SCROLL_HEIGHT]); - }, - /** - * 遍历数组或者对象 - * @param {Object|Array} element/Object 数组中的元素或者对象的值 - * @param {Function} func 遍历的函数 function(elememt,index){} 或者 function(value,key){} - */ - each: function(elements, func) { - if (!elements) { - return; - } - $.each(elements, function(k, v) { - return func(v, k); - }); - }, - /** - * 封装事件,便于使用上下文this,和便于解除事件时使用 - * @protected - * @param {Object} self 对象 - * @param {String} action 事件名称 - */ - wrapBehavior: function(self, action) { - return self['__bui_wrap_' + action] = function(e) { - if (!self.get('disabled')) { - self[action](e); - } - }; - }, - /** - * 获取封装的事件 - * @protected - * @param {Object} self 对象 - * @param {String} action 事件名称 - */ - getWrapBehavior: function(self, action) { - return self['__bui_wrap_' + action]; - }, - /** - * 获取页面上使用了此id的控件 - * @param {String} id 控件id - * @return {BUI.Component.Controller} 查找的控件 - */ - getControl: function(id) { - return BUI.Component.Manager.getComponent(id); - } - -}); - -/** - * 表单帮助类,序列化、反序列化,设置值 - * @class BUI.FormHelper - * @singleton - */ -var FormHelper = { - /** - * 将表单格式化成键值对形式 - * @param {HTMLElement} form 表单 - * @return {Object} 键值对的对象 - */ - serializeToObject: function(form) { - var array = $(form).serializeArray(), - result = {}; - BUI.each(array, function(item) { - var name = item.name; - if (!result[name]) { //如果是单个值,直接赋值 - result[name] = item.value; - } else { //多值使用数组 - if (!BUI.isArray(result[name])) { - result[name] = [result[name]]; - } - result[name].push(item.value); - } - }); - return result; - }, - /** - * 设置表单的值 - * @param {HTMLElement} form 表单 - * @param {Object} obj 键值对 - */ - setFields: function(form, obj) { - for (var name in obj) { - if (obj.hasOwnProperty(name)) { - BUI.FormHelper.setField(form, name, obj[name]); - } - } - }, - /** - * 清空表单 - * @param {HTMLElement} form 表单元素 - */ - clear: function(form) { - var elements = $.makeArray(form.elements); - - BUI.each(elements, function(element) { - if (element.type === 'checkbox' || element.type === 'radio') { - $(element).attr('checked', false); - } else { - $(element).val(''); - } - $(element).change(); - }); - }, - /** - * 设置表单字段 - * @param {HTMLElement} form 表单元素 - * @param {string} field 字段名 - * @param {string} value 字段值 - */ - setField: function(form, fieldName, value) { - var fields = form.elements[fieldName]; - if (fields && fields.type) { - formHelper._setFieldValue(fields, value); - } else if (BUI.isArray(fields) || (fields && fields.length)) { - BUI.each(fields, function(field) { - formHelper._setFieldValue(field, value); - }); - } - }, - //设置字段的值 - _setFieldValue: function(field, value) { - if (field.type === 'checkbox') { - if (field.value == '' + value || (BUI.isArray(value) && BUI.Array.indexOf(field.value, value) !== -1)) { - $(field).attr('checked', true); - } else { - $(field).attr('checked', false); - } - } else if (field.type === 'radio') { - if (field.value == '' + value) { - $(field).attr('checked', true); - } else { - $(field).attr('checked', false); - } - } else { - $(field).val(value); - } - }, - /** - * 获取表单字段值 - * @param {HTMLElement} form 表单元素 - * @param {string} field 字段名 - * @return {String} 字段值 - */ - getField: function(form, fieldName) { - return BUI.FormHelper.serializeToObject(form)[fieldName]; - } -}; - - -BUI.FormHelper = FormHelper; - -module.exports = BUI; diff --git a/spm_modules/expect.js/0.3.1/.gitignore b/spm_modules/expect.js/0.3.1/.gitignore deleted file mode 100644 index fd4f2b0..0000000 --- a/spm_modules/expect.js/0.3.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -.DS_Store diff --git a/spm_modules/expect.js/0.3.1/.npmignore b/spm_modules/expect.js/0.3.1/.npmignore deleted file mode 100644 index 26ef5d8..0000000 --- a/spm_modules/expect.js/0.3.1/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -support -test -Makefile diff --git a/spm_modules/expect.js/0.3.1/History.md b/spm_modules/expect.js/0.3.1/History.md deleted file mode 100644 index e03f91f..0000000 --- a/spm_modules/expect.js/0.3.1/History.md +++ /dev/null @@ -1,54 +0,0 @@ - -0.3.0 / 2014-02-20 -================== - - * renmaed to `index.js` - * added repository to package.json - * remove unused variable and merge - * simpify isDate() and remove unnecessary semicolon. - * Add .withArgs() syntax for building scenario - * eql(): fix wrong order of actual vs. expected. - * Added formatting for Error objects - * Add support for 'regexp' type and eql comparison of regular expressions. - * Better to follow the same coding style - * Use 'showDiff' flag - * Add 'actual' & 'expected' property to the thrown error - * Pass .fail() unit test - * Ignore 'script*' global leak in chrome - * Exposed object stringification function - * Use isRegExp in Assertion::throwException. Fix #25 - * Cleaned up local variables - -0.2.0 / 2012-10-19 -================== - - * fix isRegExp bug in some edge cases - * add closure to all assertion messages deferring costly inspects - until there is actually a failure - * fix `make test` for recent mochas - * add inspect() case for DOM elements - * relax failure msg null check - * add explicit failure through `expect().fail()` - * clarified all `empty` functionality in README example - * added docs for throwException fn/regexp signatures - -0.1.2 / 2012-02-04 -================== - - * Added regexp matching support for exceptions. - * Added support for throwException callback. - * Added `throwError` synonym to `throwException`. - * Added object support for `.empty`. - * Fixed `.a('object')` with nulls, and english error in error message. - * Fix bug `indexOf` (IE). [hokaccha] - * Fixed object property checking with `undefined` as value. [vovik] - -0.1.1 / 2011-12-18 -================== - - * Fixed typo - -0.1.0 / 2011-12-18 -================== - - * Initial import diff --git a/spm_modules/expect.js/0.3.1/Makefile b/spm_modules/expect.js/0.3.1/Makefile deleted file mode 100644 index fa83171..0000000 --- a/spm_modules/expect.js/0.3.1/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -REPORTER = dot - -test: - @./node_modules/.bin/mocha \ - --require ./test/common \ - --reporter $(REPORTER) \ - --growl \ - test/expect.js - -test-browser: - @./node_modules/.bin/serve . - -.PHONY: test diff --git a/spm_modules/expect.js/0.3.1/README.md b/spm_modules/expect.js/0.3.1/README.md deleted file mode 100644 index 5e6a88f..0000000 --- a/spm_modules/expect.js/0.3.1/README.md +++ /dev/null @@ -1,263 +0,0 @@ -# Expect - -Minimalistic BDD assertion toolkit based on -[should.js](http://github.com/visionmedia/should.js) - -```js -expect(window.r).to.be(undefined); -expect({ a: 'b' }).to.eql({ a: 'b' }) -expect(5).to.be.a('number'); -expect([]).to.be.an('array'); -expect(window).not.to.be.an(Image); -``` - -## Features - -- Cross-browser: works on IE6+, Firefox, Safari, Chrome, Opera. -- Compatible with all test frameworks. -- Node.JS ready (`require('expect.js')`). -- Standalone. Single global with no prototype extensions or shims. - -## How to use - -### Node - -Install it with NPM or add it to your `package.json`: - -``` -$ npm install expect.js -``` - -Then: - -```js -var expect = require('expect.js'); -``` - -### Browser - -Expose the `index.js` found at the top level of this repository. - -```html - -``` - -## API - -**ok**: asserts that the value is _truthy_ or not - -```js -expect(1).to.be.ok(); -expect(true).to.be.ok(); -expect({}).to.be.ok(); -expect(0).to.not.be.ok(); -``` - -**be** / **equal**: asserts `===` equality - -```js -expect(1).to.be(1) -expect(NaN).not.to.equal(NaN); -expect(1).not.to.be(true) -expect('1').to.not.be(1); -``` - -**eql**: asserts loose equality that works with objects - -```js -expect({ a: 'b' }).to.eql({ a: 'b' }); -expect(1).to.eql('1'); -``` - -**a**/**an**: asserts `typeof` with support for `array` type and `instanceof` - -```js -// typeof with optional `array` -expect(5).to.be.a('number'); -expect([]).to.be.an('array'); // works -expect([]).to.be.an('object'); // works too, since it uses `typeof` - -// constructors -expect(5).to.be.a(Number); -expect([]).to.be.an(Array); -expect(tobi).to.be.a(Ferret); -expect(person).to.be.a(Mammal); -``` - -**match**: asserts `String` regular expression match - -```js -expect(program.version).to.match(/[0-9]+\.[0-9]+\.[0-9]+/); -``` - -**contain**: asserts indexOf for an array or string - -```js -expect([1, 2]).to.contain(1); -expect('hello world').to.contain('world'); -``` - -**length**: asserts array `.length` - -```js -expect([]).to.have.length(0); -expect([1,2,3]).to.have.length(3); -``` - -**empty**: asserts that an array is empty or not - -```js -expect([]).to.be.empty(); -expect({}).to.be.empty(); -expect({ length: 0, duck: 'typing' }).to.be.empty(); -expect({ my: 'object' }).to.not.be.empty(); -expect([1,2,3]).to.not.be.empty(); -``` - -**property**: asserts presence of an own property (and value optionally) - -```js -expect(window).to.have.property('expect') -expect(window).to.have.property('expect', expect) -expect({a: 'b'}).to.have.property('a'); -``` - -**key**/**keys**: asserts the presence of a key. Supports the `only` modifier - -```js -expect({ a: 'b' }).to.have.key('a'); -expect({ a: 'b', c: 'd' }).to.only.have.keys('a', 'c'); -expect({ a: 'b', c: 'd' }).to.only.have.keys(['a', 'c']); -expect({ a: 'b', c: 'd' }).to.not.only.have.key('a'); -``` - -**throwException**/**throwError**: asserts that the `Function` throws or not when called - -```js -expect(fn).to.throwError(); // synonym of throwException -expect(fn).to.throwException(function (e) { // get the exception object - expect(e).to.be.a(SyntaxError); -}); -expect(fn).to.throwException(/matches the exception message/); -expect(fn2).to.not.throwException(); -``` - -**withArgs**: creates anonymous function to call fn with arguments - -```js -expect(fn).withArgs(invalid, arg).to.throwException(); -expect(fn).withArgs(valid, arg).to.not.throwException(); -``` - -**within**: asserts a number within a range - -```js -expect(1).to.be.within(0, Infinity); -``` - -**greaterThan**/**above**: asserts `>` - -```js -expect(3).to.be.above(0); -expect(5).to.be.greaterThan(3); -``` - -**lessThan**/**below**: asserts `<` - -```js -expect(0).to.be.below(3); -expect(1).to.be.lessThan(3); -``` - -**fail**: explicitly forces failure. - -```js -expect().fail() -expect().fail("Custom failure message") -``` - -## Using with a test framework - -For example, if you create a test suite with -[mocha](http://github.com/visionmedia/mocha). - -Let's say we wanted to test the following program: - -**math.js** - -```js -function add (a, b) { return a + b; }; -``` - -Our test file would look like this: - -```js -describe('test suite', function () { - it('should expose a function', function () { - expect(add).to.be.a('function'); - }); - - it('should do math', function () { - expect(add(1, 3)).to.equal(4); - }); -}); -``` - -If a certain expectation fails, an exception will be raised which gets captured -and shown/processed by the test runner. - -## Differences with should.js - -- No need for static `should` methods like `should.strictEqual`. For example, - `expect(obj).to.be(undefined)` works well. -- Some API simplifications / changes. -- API changes related to browser compatibility. - -## Running tests - -Clone the repository and install the developer dependencies: - -``` -git clone git://github.com/LearnBoost/expect.js.git expect -cd expect && npm install -``` - -### Node - -`make test` - -### Browser - -`make test-browser` - -and point your browser(s) to `http://localhost:3000/test/` - -## Credits - -(The MIT License) - -Copyright (c) 2011 Guillermo Rauch <guillermo@learnboost.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -### 3rd-party - -Heavily borrows from [should.js](http://github.com/visionmedia/should.js) by TJ -Holowaychuck - MIT. diff --git a/spm_modules/expect.js/0.3.1/index.js b/spm_modules/expect.js/0.3.1/index.js deleted file mode 100644 index b1e921d..0000000 --- a/spm_modules/expect.js/0.3.1/index.js +++ /dev/null @@ -1,1284 +0,0 @@ -(function (global, module) { - - var exports = module.exports; - - /** - * Exports. - */ - - module.exports = expect; - expect.Assertion = Assertion; - - /** - * Exports version. - */ - - expect.version = '0.3.1'; - - /** - * Possible assertion flags. - */ - - var flags = { - not: ['to', 'be', 'have', 'include', 'only'] - , to: ['be', 'have', 'include', 'only', 'not'] - , only: ['have'] - , have: ['own'] - , be: ['an'] - }; - - function expect (obj) { - return new Assertion(obj); - } - - /** - * Constructor - * - * @api private - */ - - function Assertion (obj, flag, parent) { - this.obj = obj; - this.flags = {}; - - if (undefined != parent) { - this.flags[flag] = true; - - for (var i in parent.flags) { - if (parent.flags.hasOwnProperty(i)) { - this.flags[i] = true; - } - } - } - - var $flags = flag ? flags[flag] : keys(flags) - , self = this; - - if ($flags) { - for (var i = 0, l = $flags.length; i < l; i++) { - // avoid recursion - if (this.flags[$flags[i]]) continue; - - var name = $flags[i] - , assertion = new Assertion(this.obj, name, this) - - if ('function' == typeof Assertion.prototype[name]) { - // clone the function, make sure we dont touch the prot reference - var old = this[name]; - this[name] = function () { - return old.apply(self, arguments); - }; - - for (var fn in Assertion.prototype) { - if (Assertion.prototype.hasOwnProperty(fn) && fn != name) { - this[name][fn] = bind(assertion[fn], assertion); - } - } - } else { - this[name] = assertion; - } - } - } - } - - /** - * Performs an assertion - * - * @api private - */ - - Assertion.prototype.assert = function (truth, msg, error, expected) { - var msg = this.flags.not ? error : msg - , ok = this.flags.not ? !truth : truth - , err; - - if (!ok) { - err = new Error(msg.call(this)); - if (arguments.length > 3) { - err.actual = this.obj; - err.expected = expected; - err.showDiff = true; - } - throw err; - } - - this.and = new Assertion(this.obj); - }; - - /** - * Check if the value is truthy - * - * @api public - */ - - Assertion.prototype.ok = function () { - this.assert( - !!this.obj - , function(){ return 'expected ' + i(this.obj) + ' to be truthy' } - , function(){ return 'expected ' + i(this.obj) + ' to be falsy' }); - }; - - /** - * Creates an anonymous function which calls fn with arguments. - * - * @api public - */ - - Assertion.prototype.withArgs = function() { - expect(this.obj).to.be.a('function'); - var fn = this.obj; - var args = Array.prototype.slice.call(arguments); - return expect(function() { fn.apply(null, args); }); - }; - - /** - * Assert that the function throws. - * - * @param {Function|RegExp} callback, or regexp to match error string against - * @api public - */ - - Assertion.prototype.throwError = - Assertion.prototype.throwException = function (fn) { - expect(this.obj).to.be.a('function'); - - var thrown = false - , not = this.flags.not; - - try { - this.obj(); - } catch (e) { - if (isRegExp(fn)) { - var subject = 'string' == typeof e ? e : e.message; - if (not) { - expect(subject).to.not.match(fn); - } else { - expect(subject).to.match(fn); - } - } else if ('function' == typeof fn) { - fn(e); - } - thrown = true; - } - - if (isRegExp(fn) && not) { - // in the presence of a matcher, ensure the `not` only applies to - // the matching. - this.flags.not = false; - } - - var name = this.obj.name || 'fn'; - this.assert( - thrown - , function(){ return 'expected ' + name + ' to throw an exception' } - , function(){ return 'expected ' + name + ' not to throw an exception' }); - }; - - /** - * Checks if the array is empty. - * - * @api public - */ - - Assertion.prototype.empty = function () { - var expectation; - - if ('object' == typeof this.obj && null !== this.obj && !isArray(this.obj)) { - if ('number' == typeof this.obj.length) { - expectation = !this.obj.length; - } else { - expectation = !keys(this.obj).length; - } - } else { - if ('string' != typeof this.obj) { - expect(this.obj).to.be.an('object'); - } - - expect(this.obj).to.have.property('length'); - expectation = !this.obj.length; - } - - this.assert( - expectation - , function(){ return 'expected ' + i(this.obj) + ' to be empty' } - , function(){ return 'expected ' + i(this.obj) + ' to not be empty' }); - return this; - }; - - /** - * Checks if the obj exactly equals another. - * - * @api public - */ - - Assertion.prototype.be = - Assertion.prototype.equal = function (obj) { - this.assert( - obj === this.obj - , function(){ return 'expected ' + i(this.obj) + ' to equal ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) }); - return this; - }; - - /** - * Checks if the obj sortof equals another. - * - * @api public - */ - - Assertion.prototype.eql = function (obj) { - this.assert( - expect.eql(this.obj, obj) - , function(){ return 'expected ' + i(this.obj) + ' to sort of equal ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) } - , obj); - return this; - }; - - /** - * Assert within start to finish (inclusive). - * - * @param {Number} start - * @param {Number} finish - * @api public - */ - - Assertion.prototype.within = function (start, finish) { - var range = start + '..' + finish; - this.assert( - this.obj >= start && this.obj <= finish - , function(){ return 'expected ' + i(this.obj) + ' to be within ' + range } - , function(){ return 'expected ' + i(this.obj) + ' to not be within ' + range }); - return this; - }; - - /** - * Assert typeof / instance of - * - * @api public - */ - - Assertion.prototype.a = - Assertion.prototype.an = function (type) { - if ('string' == typeof type) { - // proper english in error msg - var n = /^[aeiou]/.test(type) ? 'n' : ''; - - // typeof with support for 'array' - this.assert( - 'array' == type ? isArray(this.obj) : - 'regexp' == type ? isRegExp(this.obj) : - 'object' == type - ? 'object' == typeof this.obj && null !== this.obj - : type == typeof this.obj - , function(){ return 'expected ' + i(this.obj) + ' to be a' + n + ' ' + type } - , function(){ return 'expected ' + i(this.obj) + ' not to be a' + n + ' ' + type }); - } else { - // instanceof - var name = type.name || 'supplied constructor'; - this.assert( - this.obj instanceof type - , function(){ return 'expected ' + i(this.obj) + ' to be an instance of ' + name } - , function(){ return 'expected ' + i(this.obj) + ' not to be an instance of ' + name }); - } - - return this; - }; - - /** - * Assert numeric value above _n_. - * - * @param {Number} n - * @api public - */ - - Assertion.prototype.greaterThan = - Assertion.prototype.above = function (n) { - this.assert( - this.obj > n - , function(){ return 'expected ' + i(this.obj) + ' to be above ' + n } - , function(){ return 'expected ' + i(this.obj) + ' to be below ' + n }); - return this; - }; - - /** - * Assert numeric value below _n_. - * - * @param {Number} n - * @api public - */ - - Assertion.prototype.lessThan = - Assertion.prototype.below = function (n) { - this.assert( - this.obj < n - , function(){ return 'expected ' + i(this.obj) + ' to be below ' + n } - , function(){ return 'expected ' + i(this.obj) + ' to be above ' + n }); - return this; - }; - - /** - * Assert string value matches _regexp_. - * - * @param {RegExp} regexp - * @api public - */ - - Assertion.prototype.match = function (regexp) { - this.assert( - regexp.exec(this.obj) - , function(){ return 'expected ' + i(this.obj) + ' to match ' + regexp } - , function(){ return 'expected ' + i(this.obj) + ' not to match ' + regexp }); - return this; - }; - - /** - * Assert property "length" exists and has value of _n_. - * - * @param {Number} n - * @api public - */ - - Assertion.prototype.length = function (n) { - expect(this.obj).to.have.property('length'); - var len = this.obj.length; - this.assert( - n == len - , function(){ return 'expected ' + i(this.obj) + ' to have a length of ' + n + ' but got ' + len } - , function(){ return 'expected ' + i(this.obj) + ' to not have a length of ' + len }); - return this; - }; - - /** - * Assert property _name_ exists, with optional _val_. - * - * @param {String} name - * @param {Mixed} val - * @api public - */ - - Assertion.prototype.property = function (name, val) { - if (this.flags.own) { - this.assert( - Object.prototype.hasOwnProperty.call(this.obj, name) - , function(){ return 'expected ' + i(this.obj) + ' to have own property ' + i(name) } - , function(){ return 'expected ' + i(this.obj) + ' to not have own property ' + i(name) }); - return this; - } - - if (this.flags.not && undefined !== val) { - if (undefined === this.obj[name]) { - throw new Error(i(this.obj) + ' has no property ' + i(name)); - } - } else { - var hasProp; - try { - hasProp = name in this.obj - } catch (e) { - hasProp = undefined !== this.obj[name] - } - - this.assert( - hasProp - , function(){ return 'expected ' + i(this.obj) + ' to have a property ' + i(name) } - , function(){ return 'expected ' + i(this.obj) + ' to not have a property ' + i(name) }); - } - - if (undefined !== val) { - this.assert( - val === this.obj[name] - , function(){ return 'expected ' + i(this.obj) + ' to have a property ' + i(name) - + ' of ' + i(val) + ', but got ' + i(this.obj[name]) } - , function(){ return 'expected ' + i(this.obj) + ' to not have a property ' + i(name) - + ' of ' + i(val) }); - } - - this.obj = this.obj[name]; - return this; - }; - - /** - * Assert that the array contains _obj_ or string contains _obj_. - * - * @param {Mixed} obj|string - * @api public - */ - - Assertion.prototype.string = - Assertion.prototype.contain = function (obj) { - if ('string' == typeof this.obj) { - this.assert( - ~this.obj.indexOf(obj) - , function(){ return 'expected ' + i(this.obj) + ' to contain ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) }); - } else { - this.assert( - ~indexOf(this.obj, obj) - , function(){ return 'expected ' + i(this.obj) + ' to contain ' + i(obj) } - , function(){ return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) }); - } - return this; - }; - - /** - * Assert exact keys or inclusion of keys by using - * the `.own` modifier. - * - * @param {Array|String ...} keys - * @api public - */ - - Assertion.prototype.key = - Assertion.prototype.keys = function ($keys) { - var str - , ok = true; - - $keys = isArray($keys) - ? $keys - : Array.prototype.slice.call(arguments); - - if (!$keys.length) throw new Error('keys required'); - - var actual = keys(this.obj) - , len = $keys.length; - - // Inclusion - ok = every($keys, function (key) { - return ~indexOf(actual, key); - }); - - // Strict - if (!this.flags.not && this.flags.only) { - ok = ok && $keys.length == actual.length; - } - - // Key string - if (len > 1) { - $keys = map($keys, function (key) { - return i(key); - }); - var last = $keys.pop(); - str = $keys.join(', ') + ', and ' + last; - } else { - str = i($keys[0]); - } - - // Form - str = (len > 1 ? 'keys ' : 'key ') + str; - - // Have / include - str = (!this.flags.only ? 'include ' : 'only have ') + str; - - // Assertion - this.assert( - ok - , function(){ return 'expected ' + i(this.obj) + ' to ' + str } - , function(){ return 'expected ' + i(this.obj) + ' to not ' + str }); - - return this; - }; - - /** - * Assert a failure. - * - * @param {String ...} custom message - * @api public - */ - Assertion.prototype.fail = function (msg) { - var error = function() { return msg || "explicit failure"; } - this.assert(false, error, error); - return this; - }; - - /** - * Function bind implementation. - */ - - function bind (fn, scope) { - return function () { - return fn.apply(scope, arguments); - } - } - - /** - * Array every compatibility - * - * @see bit.ly/5Fq1N2 - * @api public - */ - - function every (arr, fn, thisObj) { - var scope = thisObj || global; - for (var i = 0, j = arr.length; i < j; ++i) { - if (!fn.call(scope, arr[i], i, arr)) { - return false; - } - } - return true; - } - - /** - * Array indexOf compatibility. - * - * @see bit.ly/a5Dxa2 - * @api public - */ - - function indexOf (arr, o, i) { - if (Array.prototype.indexOf) { - return Array.prototype.indexOf.call(arr, o, i); - } - - if (arr.length === undefined) { - return -1; - } - - for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0 - ; i < j && arr[i] !== o; i++); - - return j <= i ? -1 : i; - } - - // https://gist.github.com/1044128/ - var getOuterHTML = function(element) { - if ('outerHTML' in element) return element.outerHTML; - var ns = "http://www.w3.org/1999/xhtml"; - var container = document.createElementNS(ns, '_'); - var xmlSerializer = new XMLSerializer(); - var html; - if (document.xmlVersion) { - return xmlSerializer.serializeToString(element); - } else { - container.appendChild(element.cloneNode(false)); - html = container.innerHTML.replace('><', '>' + element.innerHTML + '<'); - container.innerHTML = ''; - return html; - } - }; - - // Returns true if object is a DOM element. - var isDOMElement = function (object) { - if (typeof HTMLElement === 'object') { - return object instanceof HTMLElement; - } else { - return object && - typeof object === 'object' && - object.nodeType === 1 && - typeof object.nodeName === 'string'; - } - }; - - /** - * Inspects an object. - * - * @see taken from node.js `util` module (copyright Joyent, MIT license) - * @api private - */ - - function i (obj, showHidden, depth) { - var seen = []; - - function stylize (str) { - return str; - } - - function format (value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (value && typeof value.inspect === 'function' && - // Filter out the util module, it's inspect function is special - value !== exports && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - return value.inspect(recurseTimes); - } - - // Primitive types cannot have properties - switch (typeof value) { - case 'undefined': - return stylize('undefined', 'undefined'); - - case 'string': - var simple = '\'' + json.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return stylize(simple, 'string'); - - case 'number': - return stylize('' + value, 'number'); - - case 'boolean': - return stylize('' + value, 'boolean'); - } - // For some reason typeof null is "object", so special case here. - if (value === null) { - return stylize('null', 'null'); - } - - if (isDOMElement(value)) { - return getOuterHTML(value); - } - - // Look up the keys of the object. - var visible_keys = keys(value); - var $keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys; - - // Functions without properties can be shortcutted. - if (typeof value === 'function' && $keys.length === 0) { - if (isRegExp(value)) { - return stylize('' + value, 'regexp'); - } else { - var name = value.name ? ': ' + value.name : ''; - return stylize('[Function' + name + ']', 'special'); - } - } - - // Dates without properties can be shortcutted - if (isDate(value) && $keys.length === 0) { - return stylize(value.toUTCString(), 'date'); - } - - // Error objects can be shortcutted - if (value instanceof Error) { - return stylize("["+value.toString()+"]", 'Error'); - } - - var base, type, braces; - // Determine the object type - if (isArray(value)) { - type = 'Array'; - braces = ['[', ']']; - } else { - type = 'Object'; - braces = ['{', '}']; - } - - // Make functions say that they are functions - if (typeof value === 'function') { - var n = value.name ? ': ' + value.name : ''; - base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']'; - } else { - base = ''; - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + value.toUTCString(); - } - - if ($keys.length === 0) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return stylize('' + value, 'regexp'); - } else { - return stylize('[Object]', 'special'); - } - } - - seen.push(value); - - var output = map($keys, function (key) { - var name, str; - if (value.__lookupGetter__) { - if (value.__lookupGetter__(key)) { - if (value.__lookupSetter__(key)) { - str = stylize('[Getter/Setter]', 'special'); - } else { - str = stylize('[Getter]', 'special'); - } - } else { - if (value.__lookupSetter__(key)) { - str = stylize('[Setter]', 'special'); - } - } - } - if (indexOf(visible_keys, key) < 0) { - name = '[' + key + ']'; - } - if (!str) { - if (indexOf(seen, value[key]) < 0) { - if (recurseTimes === null) { - str = format(value[key]); - } else { - str = format(value[key], recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (isArray(value)) { - str = map(str.split('\n'), function (line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + map(str.split('\n'), function (line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = stylize('[Circular]', 'special'); - } - } - if (typeof name === 'undefined') { - if (type === 'Array' && key.match(/^\d+$/)) { - return str; - } - name = json.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = stylize(name, 'string'); - } - } - - return name + ': ' + str; - }); - - seen.pop(); - - var numLinesEst = 0; - var length = reduce(output, function (prev, cur) { - numLinesEst++; - if (indexOf(cur, '\n') >= 0) numLinesEst++; - return prev + cur.length + 1; - }, 0); - - if (length > 50) { - output = braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - - } else { - output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; - } - - return output; - } - return format(obj, (typeof depth === 'undefined' ? 2 : depth)); - } - - expect.stringify = i; - - function isArray (ar) { - return Object.prototype.toString.call(ar) === '[object Array]'; - } - - function isRegExp(re) { - var s; - try { - s = '' + re; - } catch (e) { - return false; - } - - return re instanceof RegExp || // easy case - // duck-type for context-switching evalcx case - typeof(re) === 'function' && - re.constructor.name === 'RegExp' && - re.compile && - re.test && - re.exec && - s.match(/^\/.*\/[gim]{0,3}$/); - } - - function isDate(d) { - return d instanceof Date; - } - - function keys (obj) { - if (Object.keys) { - return Object.keys(obj); - } - - var keys = []; - - for (var i in obj) { - if (Object.prototype.hasOwnProperty.call(obj, i)) { - keys.push(i); - } - } - - return keys; - } - - function map (arr, mapper, that) { - if (Array.prototype.map) { - return Array.prototype.map.call(arr, mapper, that); - } - - var other= new Array(arr.length); - - for (var i= 0, n = arr.length; i= 2) { - var rv = arguments[1]; - } else { - do { - if (i in this) { - rv = this[i++]; - break; - } - - // if array contains no values, no initial value to return - if (++i >= len) - throw new TypeError(); - } while (true); - } - - for (; i < len; i++) { - if (i in this) - rv = fun.call(null, rv, this[i], i, this); - } - - return rv; - } - - /** - * Asserts deep equality - * - * @see taken from node.js `assert` module (copyright Joyent, MIT license) - * @api private - */ - - expect.eql = function eql(actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - } else if ('undefined' != typeof Buffer - && Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - - return true; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == "object", - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - // If both are regular expression use the special `regExpEquiv` method - // to determine equivalence. - } else if (isRegExp(actual) && isRegExp(expected)) { - return regExpEquiv(actual, expected); - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical "prototype" property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } - }; - - function isUndefinedOrNull (value) { - return value === null || value === undefined; - } - - function isArguments (object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; - } - - function regExpEquiv (a, b) { - return a.source === b.source && a.global === b.global && - a.ignoreCase === b.ignoreCase && a.multiline === b.multiline; - } - - function objEquiv (a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical "prototype" property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return expect.eql(a, b); - } - try{ - var ka = keys(a), - kb = keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!expect.eql(a[key], b[key])) - return false; - } - return true; - } - - var json = (function () { - "use strict"; - - if ('object' == typeof JSON && JSON.parse && JSON.stringify) { - return { - parse: nativeJSON.parse - , stringify: nativeJSON.stringify - } - } - - var JSON = {}; - - function f(n) { - // Format integers to have at least two digits. - return n < 10 ? '0' + n : n; - } - - function date(d, key) { - return isFinite(d.valueOf()) ? - d.getUTCFullYear() + '-' + - f(d.getUTCMonth() + 1) + '-' + - f(d.getUTCDate()) + 'T' + - f(d.getUTCHours()) + ':' + - f(d.getUTCMinutes()) + ':' + - f(d.getUTCSeconds()) + 'Z' : null; - } - - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }, - rep; - - - function quote(string) { - - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable.lastIndex = 0; - return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; - } - - - function str(key, holder) { - - // Produce a string from holder[key]. - - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - // If the value has a toJSON method, call it to obtain a replacement value. - - if (value instanceof Date) { - value = date(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - - // JSON numbers must be finite. Encode non-finite numbers as null. - - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - - return String(value); - - // If the type is 'object', we might be dealing with an object or an array or - // null. - - case 'object': - - // Due to a specification blunder in ECMAScript, typeof null is 'object', - // so watch out for that case. - - if (!value) { - return 'null'; - } - - // Make an array to hold the partial results of stringifying this object value. - - gap += indent; - partial = []; - - // Is the value an array? - - if (Object.prototype.toString.apply(value) === '[object Array]') { - - // The value is an array. Stringify every element. Use null as a placeholder - // for non-JSON values. - - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and wrap them in - // brackets. - - v = partial.length === 0 ? '[]' : gap ? - '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be stringified. - - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - if (typeof rep[i] === 'string') { - k = rep[i]; - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } else { - - // Otherwise, iterate through all of the keys in the object. - - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 ? '{}' : gap ? - '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : - '{' + partial.join(',') + '}'; - gap = mind; - return v; - } - } - - // If the JSON object does not yet have a stringify method, give it one. - - JSON.stringify = function (value, replacer, space) { - - // The stringify method takes a value and an optional replacer, and an optional - // space parameter, and returns a JSON text. The replacer can be a function - // that can replace values, or an array of strings that will select the keys. - // A default replacer method can be provided. Use of the space parameter can - // produce text that is more easily readable. - - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - - // If the space parameter is a string, it will be used as the indent string. - - } else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - - rep = replacer; - if (replacer && typeof replacer !== 'function' && - (typeof replacer !== 'object' || - typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - - return str('', {'': value}); - }; - - // If the JSON object does not yet have a parse method, give it one. - - JSON.parse = function (text, reviver) { - // The parse method takes a text and an optional reviver function, and returns - // a JavaScript value if the text is a valid JSON text. - - var j; - - function walk(holder, key) { - - // The walk method is used to recursively walk the resulting structure so - // that modifications can be made. - - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - } - - - // Parsing happens in four stages. In the first stage, we replace certain - // Unicode characters with escape sequences. JavaScript handles many characters - // incorrectly, either silently deleting them, or treating them as line endings. - - text = String(text); - cx.lastIndex = 0; - if (cx.test(text)) { - text = text.replace(cx, function (a) { - return '\\u' + - ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }); - } - - // In the second stage, we run the text against regular expressions that look - // for non-JSON patterns. We are especially concerned with '()' and 'new' - // because they can cause invocation, and '=' because it can cause mutation. - // But just to be safe, we want to reject all unexpected forms. - - // We split the second stage into 4 regexp operations in order to work around - // crippling inefficiencies in IE's and Safari's regexp engines. First we - // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we - // replace all simple value tokens with ']' characters. Third, we delete all - // open brackets that follow a colon or comma or that begin the text. Finally, - // we look to see that the remaining characters are only whitespace or ']' or - // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. - - if (/^[\],:{}\s]*$/ - .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') - .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') - .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { - - // In the third stage we use the eval function to compile the text into a - // JavaScript structure. The '{' operator is subject to a syntactic ambiguity - // in JavaScript: it can begin a block or an object literal. We wrap the text - // in parens to eliminate the ambiguity. - - j = eval('(' + text + ')'); - - // In the optional fourth stage, we recursively walk the new structure, passing - // each name/value pair to a reviver function for possible transformation. - - return typeof reviver === 'function' ? - walk({'': j}, '') : j; - } - - // If the text is not JSON parseable, then a SyntaxError is thrown. - - throw new SyntaxError('JSON.parse'); - }; - - return JSON; - })(); - - if ('undefined' != typeof window) { - window.expect = module.exports; - } - -})( - this - , 'undefined' != typeof module ? module : {exports: {}} -); diff --git a/spm_modules/expect.js/0.3.1/package.json b/spm_modules/expect.js/0.3.1/package.json deleted file mode 100644 index 8b3cf76..0000000 --- a/spm_modules/expect.js/0.3.1/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "expect.js" - , "version": "0.3.1" - , "description": "BDD style assertions for node and the browser." - , "repository": { - "type": "git", - "url": "git://github.com/LearnBoost/expect.js.git" - } - , "devDependencies": { - "mocha": "*" - , "serve": "*" - } - , "spm": { - "main": "index.js" - } -} diff --git a/spm_modules/expect.js/0.3.1/support/jquery.js b/spm_modules/expect.js/0.3.1/support/jquery.js deleted file mode 100644 index 034f412..0000000 --- a/spm_modules/expect.js/0.3.1/support/jquery.js +++ /dev/null @@ -1,9266 +0,0 @@ -/*! - * jQuery JavaScript Library v1.7.1 - * http://jquery.com/ - * - * Copyright 2011, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Mon Nov 21 21:11:03 2011 -0500 - */ -(function( window, undefined ) { - -// Use the correct document accordingly with window argument (sandbox) -var document = window.document, - navigator = window.navigator, - location = window.location; -var jQuery = (function() { - -// Define a local copy of jQuery -var jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - - // Map over the $ in case of overwrite - _$ = window.$, - - // A central reference to the root jQuery(document) - rootjQuery, - - // A simple way to check for HTML strings or ID strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, - - // Check if a string has a non-whitespace character in it - rnotwhite = /\S/, - - // Used for trimming whitespace - trimLeft = /^\s+/, - trimRight = /\s+$/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, - rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - - // Useragent RegExp - rwebkit = /(webkit)[ \/]([\w.]+)/, - ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, - rmsie = /(msie) ([\w.]+)/, - rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, - - // Matches dashed string for camelizing - rdashAlpha = /-([a-z]|[0-9])/ig, - rmsPrefix = /^-ms-/, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return ( letter + "" ).toUpperCase(); - }, - - // Keep a UserAgent string for use with jQuery.browser - userAgent = navigator.userAgent, - - // For matching the engine and version of the browser - browserMatch, - - // The deferred used on DOM ready - readyList, - - // The ready event handler - DOMContentLoaded, - - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - push = Array.prototype.push, - slice = Array.prototype.slice, - trim = String.prototype.trim, - indexOf = Array.prototype.indexOf, - - // [[Class]] -> type pairs - class2type = {}; - -jQuery.fn = jQuery.prototype = { - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem, ret, doc; - - // Handle $(""), $(null), or $(undefined) - if ( !selector ) { - return this; - } - - // Handle $(DOMElement) - if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - } - - // The body element only exists once, optimize finding it - if ( selector === "body" && !context && document.body ) { - this.context = document; - this[0] = document.body; - this.selector = selector; - this.length = 1; - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - // Are we dealing with HTML string or an ID? - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = quickExpr.exec( selector ); - } - - // Verify a match, and that no context was specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - doc = ( context ? context.ownerDocument || context : document ); - - // If a single string is passed in and it's a single tag - // just do a createElement and skip the rest - ret = rsingleTag.exec( selector ); - - if ( ret ) { - if ( jQuery.isPlainObject( context ) ) { - selector = [ document.createElement( ret[1] ) ]; - jQuery.fn.attr.call( selector, context, true ); - - } else { - selector = [ doc.createElement( ret[1] ) ]; - } - - } else { - ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); - selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; - } - - return jQuery.merge( this, selector ); - - // HANDLE: $("#id") - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The current version of jQuery being used - jquery: "1.7.1", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return slice.call( this, 0 ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems, name, selector ) { - // Build a new jQuery matched element set - var ret = this.constructor(); - - if ( jQuery.isArray( elems ) ) { - push.apply( ret, elems ); - - } else { - jQuery.merge( ret, elems ); - } - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - - ret.context = this.context; - - if ( name === "find" ) { - ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; - } else if ( name ) { - ret.selector = this.selector + "." + name + "(" + selector + ")"; - } - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Attach the listeners - jQuery.bindReady(); - - // Add the callback - readyList.add( fn ); - - return this; - }, - - eq: function( i ) { - i = +i; - return i === -1 ? - this.slice( i ) : - this.slice( i, i + 1 ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - slice: function() { - return this.pushStack( slice.apply( this, arguments ), - "slice", slice.call(arguments).join(",") ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - // Either a released hold or an DOMready/load event and not yet ready - if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready, 1 ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.fireWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).off( "ready" ); - } - } - }, - - bindReady: function() { - if ( readyList ) { - return; - } - - readyList = jQuery.Callbacks( "once memory" ); - - // Catch cases where $(document).ready() is called after the - // browser event has already occurred. - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout( jQuery.ready, 1 ); - } - - // Mozilla, Opera and webkit nightlies currently support this event - if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", jQuery.ready, false ); - - // If IE event model is used - } else if ( document.attachEvent ) { - // ensure firing before onload, - // maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", DOMContentLoaded ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", jQuery.ready ); - - // If IE and not a frame - // continually check to see if the document is ready - var toplevel = false; - - try { - toplevel = window.frameElement == null; - } catch(e) {} - - if ( document.documentElement.doScroll && toplevel ) { - doScrollCheck(); - } - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - // A crude way of determining if an object is a window - isWindow: function( obj ) { - return obj && typeof obj === "object" && "setInterval" in obj; - }, - - isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - - type: function( obj ) { - return obj == null ? - String( obj ) : - class2type[ toString.call(obj) ] || "object"; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - // Not own constructor property must be Object - if ( obj.constructor && - !hasOwn.call(obj, "constructor") && - !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - for ( var name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw new Error( msg ); - }, - - parseJSON: function( data ) { - if ( typeof data !== "string" || !data ) { - return null; - } - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return ( new Function( "return " + data ) )(); - - } - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && rnotwhite.test( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); - }, - - // args is for internal usage only - each: function( object, callback, args ) { - var name, i = 0, - length = object.length, - isObj = length === undefined || jQuery.isFunction( object ); - - if ( args ) { - if ( isObj ) { - for ( name in object ) { - if ( callback.apply( object[ name ], args ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.apply( object[ i++ ], args ) === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isObj ) { - for ( name in object ) { - if ( callback.call( object[ name ], name, object[ name ] ) === false ) { - break; - } - } - } else { - for ( ; i < length; ) { - if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { - break; - } - } - } - } - - return object; - }, - - // Use native String.trim function wherever possible - trim: trim ? - function( text ) { - return text == null ? - "" : - trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); - }, - - // results is for internal usage only - makeArray: function( array, results ) { - var ret = results || []; - - if ( array != null ) { - // The window, strings (and functions) also have 'length' - // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type( array ); - - if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { - push.call( ret, array ); - } else { - jQuery.merge( ret, array ); - } - } - - return ret; - }, - - inArray: function( elem, array, i ) { - var len; - - if ( array ) { - if ( indexOf ) { - return indexOf.call( array, elem, i ); - } - - len = array.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in array && array[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var i = first.length, - j = 0; - - if ( typeof second.length === "number" ) { - for ( var l = second.length; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var ret = [], retVal; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( var i = 0, length = elems.length; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, key, ret = [], - i = 0, - length = elems.length, - // jquery objects are treated as arrays - isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( key in elems ) { - value = callback( elems[ key ], key, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return ret.concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - if ( typeof context === "string" ) { - var tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - var args = slice.call( arguments, 2 ), - proxy = function() { - return fn.apply( context, args.concat( slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; - - return proxy; - }, - - // Mutifunctional method to get and set values to a collection - // The value/s can optionally be executed if it's a function - access: function( elems, key, value, exec, fn, pass ) { - var length = elems.length; - - // Setting many attributes - if ( typeof key === "object" ) { - for ( var k in key ) { - jQuery.access( elems, k, key[k], exec, fn, value ); - } - return elems; - } - - // Setting one attribute - if ( value !== undefined ) { - // Optionally, function values get executed if exec is true - exec = !pass && exec && jQuery.isFunction(value); - - for ( var i = 0; i < length; i++ ) { - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); - } - - return elems; - } - - // Getting an attribute - return length ? fn( elems[0], key ) : undefined; - }, - - now: function() { - return ( new Date() ).getTime(); - }, - - // Use of jQuery.browser is frowned upon. - // More details: http://docs.jquery.com/Utilities/jQuery.browser - uaMatch: function( ua ) { - ua = ua.toLowerCase(); - - var match = rwebkit.exec( ua ) || - ropera.exec( ua ) || - rmsie.exec( ua ) || - ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || - []; - - return { browser: match[1] || "", version: match[2] || "0" }; - }, - - sub: function() { - function jQuerySub( selector, context ) { - return new jQuerySub.fn.init( selector, context ); - } - jQuery.extend( true, jQuerySub, this ); - jQuerySub.superclass = this; - jQuerySub.fn = jQuerySub.prototype = this(); - jQuerySub.fn.constructor = jQuerySub; - jQuerySub.sub = this.sub; - jQuerySub.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { - context = jQuerySub( context ); - } - - return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); - }; - jQuerySub.fn.init.prototype = jQuerySub.fn; - var rootjQuerySub = jQuerySub(document); - return jQuerySub; - }, - - browser: {} -}); - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -browserMatch = jQuery.uaMatch( userAgent ); -if ( browserMatch.browser ) { - jQuery.browser[ browserMatch.browser ] = true; - jQuery.browser.version = browserMatch.version; -} - -// Deprecated, use jQuery.browser.webkit instead -if ( jQuery.browser.webkit ) { - jQuery.browser.safari = true; -} - -// IE doesn't match non-breaking spaces with \s -if ( rnotwhite.test( "\xA0" ) ) { - trimLeft = /^[\s\xA0]+/; - trimRight = /[\s\xA0]+$/; -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); - -// Cleanup functions for the document ready method -if ( document.addEventListener ) { - DOMContentLoaded = function() { - document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - jQuery.ready(); - }; - -} else if ( document.attachEvent ) { - DOMContentLoaded = function() { - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( document.readyState === "complete" ) { - document.detachEvent( "onreadystatechange", DOMContentLoaded ); - jQuery.ready(); - } - }; -} - -// The DOM ready check for Internet Explorer -function doScrollCheck() { - if ( jQuery.isReady ) { - return; - } - - try { - // If IE is used, use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - document.documentElement.doScroll("left"); - } catch(e) { - setTimeout( doScrollCheck, 1 ); - return; - } - - // and execute any waiting functions - jQuery.ready(); -} - -return jQuery; - -})(); - - -// String to Object flags format cache -var flagsCache = {}; - -// Convert String-formatted flags into Object-formatted ones and store in cache -function createFlags( flags ) { - var object = flagsCache[ flags ] = {}, - i, length; - flags = flags.split( /\s+/ ); - for ( i = 0, length = flags.length; i < length; i++ ) { - object[ flags[i] ] = true; - } - return object; -} - -/* - * Create a callback list using the following parameters: - * - * flags: an optional list of space-separated flags that will change how - * the callback list behaves - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible flags: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( flags ) { - - // Convert flags from String-formatted to Object-formatted - // (we check in cache first) - flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; - - var // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = [], - // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // Add one or several callbacks to the list - add = function( args ) { - var i, - length, - elem, - type, - actual; - for ( i = 0, length = args.length; i < length; i++ ) { - elem = args[ i ]; - type = jQuery.type( elem ); - if ( type === "array" ) { - // Inspect recursively - add( elem ); - } else if ( type === "function" ) { - // Add if not in unique mode and callback is not in - if ( !flags.unique || !self.has( elem ) ) { - list.push( elem ); - } - } - } - }, - // Fire callbacks - fire = function( context, args ) { - args = args || []; - memory = !flags.memory || [ context, args ]; - firing = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { - memory = true; // Mark as halted - break; - } - } - firing = false; - if ( list ) { - if ( !flags.once ) { - if ( stack && stack.length ) { - memory = stack.shift(); - self.fireWith( memory[ 0 ], memory[ 1 ] ); - } - } else if ( memory === true ) { - self.disable(); - } else { - list = []; - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - var length = list.length; - add( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away, unless previous - // firing was halted (stopOnFalse) - } else if ( memory && memory !== true ) { - firingStart = length; - fire( memory[ 0 ], memory[ 1 ] ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - var args = arguments, - argIndex = 0, - argLength = args.length; - for ( ; argIndex < argLength ; argIndex++ ) { - for ( var i = 0; i < list.length; i++ ) { - if ( args[ argIndex ] === list[ i ] ) { - // Handle firingIndex and firingLength - if ( firing ) { - if ( i <= firingLength ) { - firingLength--; - if ( i <= firingIndex ) { - firingIndex--; - } - } - } - // Remove the element - list.splice( i--, 1 ); - // If we have some unicity property then - // we only need to do this once - if ( flags.unique ) { - break; - } - } - } - } - } - return this; - }, - // Control if a given callback is in the list - has: function( fn ) { - if ( list ) { - var i = 0, - length = list.length; - for ( ; i < length; i++ ) { - if ( fn === list[ i ] ) { - return true; - } - } - } - return false; - }, - // Remove all callbacks from the list - empty: function() { - list = []; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory || memory === true ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - if ( stack ) { - if ( firing ) { - if ( !flags.once ) { - stack.push( [ context, args ] ); - } - } else if ( !( flags.once && memory ) ) { - fire( context, args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!memory; - } - }; - - return self; -}; - - - - -var // Static reference to slice - sliceDeferred = [].slice; - -jQuery.extend({ - - Deferred: function( func ) { - var doneList = jQuery.Callbacks( "once memory" ), - failList = jQuery.Callbacks( "once memory" ), - progressList = jQuery.Callbacks( "memory" ), - state = "pending", - lists = { - resolve: doneList, - reject: failList, - notify: progressList - }, - promise = { - done: doneList.add, - fail: failList.add, - progress: progressList.add, - - state: function() { - return state; - }, - - // Deprecated - isResolved: doneList.fired, - isRejected: failList.fired, - - then: function( doneCallbacks, failCallbacks, progressCallbacks ) { - deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); - return this; - }, - always: function() { - deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); - return this; - }, - pipe: function( fnDone, fnFail, fnProgress ) { - return jQuery.Deferred(function( newDefer ) { - jQuery.each( { - done: [ fnDone, "resolve" ], - fail: [ fnFail, "reject" ], - progress: [ fnProgress, "notify" ] - }, function( handler, data ) { - var fn = data[ 0 ], - action = data[ 1 ], - returned; - if ( jQuery.isFunction( fn ) ) { - deferred[ handler ](function() { - returned = fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); - } - }); - } else { - deferred[ handler ]( newDefer[ action ] ); - } - }); - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - if ( obj == null ) { - obj = promise; - } else { - for ( var key in promise ) { - obj[ key ] = promise[ key ]; - } - } - return obj; - } - }, - deferred = promise.promise({}), - key; - - for ( key in lists ) { - deferred[ key ] = lists[ key ].fire; - deferred[ key + "With" ] = lists[ key ].fireWith; - } - - // Handle state - deferred.done( function() { - state = "resolved"; - }, failList.disable, progressList.lock ).fail( function() { - state = "rejected"; - }, doneList.disable, progressList.lock ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( firstParam ) { - var args = sliceDeferred.call( arguments, 0 ), - i = 0, - length = args.length, - pValues = new Array( length ), - count = length, - pCount = length, - deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? - firstParam : - jQuery.Deferred(), - promise = deferred.promise(); - function resolveFunc( i ) { - return function( value ) { - args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; - if ( !( --count ) ) { - deferred.resolveWith( deferred, args ); - } - }; - } - function progressFunc( i ) { - return function( value ) { - pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; - deferred.notifyWith( promise, pValues ); - }; - } - if ( length > 1 ) { - for ( ; i < length; i++ ) { - if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { - args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); - } else { - --count; - } - } - if ( !count ) { - deferred.resolveWith( deferred, args ); - } - } else if ( deferred !== firstParam ) { - deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); - } - return promise; - } -}); - - - - -jQuery.support = (function() { - - var support, - all, - a, - select, - opt, - input, - marginDiv, - fragment, - tds, - events, - eventName, - i, - isSupported, - div = document.createElement( "div" ), - documentElement = document.documentElement; - - // Preliminary tests - div.setAttribute("className", "t"); - div.innerHTML = "
    a"; - - all = div.getElementsByTagName( "*" ); - a = div.getElementsByTagName( "a" )[ 0 ]; - - // Can't get basic test support - if ( !all || !all.length || !a ) { - return {}; - } - - // First batch of supports tests - select = document.createElement( "select" ); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName( "input" )[ 0 ]; - - support = { - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: ( div.firstChild.nodeType === 3 ), - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: ( a.getAttribute("href") === "/a" ), - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.55/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Make sure that if no value is specified for a checkbox - // that it defaults to "on". - // (WebKit defaults to "" instead) - checkOn: ( input.value === "on" ), - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // Tests for enctype support on a form(#6743) - enctype: !!document.createElement("form").enctype, - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", - - // Will be defined later - submitBubbles: true, - changeBubbles: true, - focusinBubbles: false, - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Test to see if it's possible to delete an expando from an element - // Fails in Internet Explorer - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { - div.attachEvent( "onclick", function() { - // Cloning a node shouldn't copy over any - // bound event handlers (IE does this) - support.noCloneEvent = false; - }); - div.cloneNode( true ).fireEvent( "onclick" ); - } - - // Check if a radio maintains its value - // after being appended to the DOM - input = document.createElement("input"); - input.value = "t"; - input.setAttribute("type", "radio"); - support.radioValue = input.value === "t"; - - input.setAttribute("checked", "checked"); - div.appendChild( input ); - fragment = document.createDocumentFragment(); - fragment.appendChild( div.lastChild ); - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - fragment.removeChild( input ); - fragment.appendChild( div ); - - div.innerHTML = ""; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. For more - // info see bug #3333 - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - if ( window.getComputedStyle ) { - marginDiv = document.createElement( "div" ); - marginDiv.style.width = "0"; - marginDiv.style.marginRight = "0"; - div.style.width = "2px"; - div.appendChild( marginDiv ); - support.reliableMarginRight = - ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; - } - - // Technique from Juriy Zaytsev - // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ - // We only care about the case where non-standard event systems - // are used, namely in IE. Short-circuiting here helps us to - // avoid an eval call (in setAttribute) which can cause CSP - // to go haywire. See: https://developer.mozilla.org/en/Security/CSP - if ( div.attachEvent ) { - for( i in { - submit: 1, - change: 1, - focusin: 1 - }) { - eventName = "on" + i; - isSupported = ( eventName in div ); - if ( !isSupported ) { - div.setAttribute( eventName, "return;" ); - isSupported = ( typeof div[ eventName ] === "function" ); - } - support[ i + "Bubbles" ] = isSupported; - } - } - - fragment.removeChild( div ); - - // Null elements to avoid leaks in IE - fragment = select = opt = marginDiv = div = input = null; - - // Run tests that need a body at doc ready - jQuery(function() { - var container, outer, inner, table, td, offsetSupport, - conMarginTop, ptlm, vb, style, html, - body = document.getElementsByTagName("body")[0]; - - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } - - conMarginTop = 1; - ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"; - vb = "visibility:hidden;border:0;"; - style = "style='" + ptlm + "border:5px solid #000;padding:0;'"; - html = "
    " + - "" + - "
    "; - - container = document.createElement("div"); - container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; - body.insertBefore( container, body.firstChild ); - - // Construct the test element - div = document.createElement("div"); - container.appendChild( div ); - - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - // (only IE 8 fails this test) - div.innerHTML = "
    t
    "; - tds = div.getElementsByTagName( "td" ); - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Check if empty table cells still have offsetWidth/Height - // (IE <= 8 fail this test) - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - - // Figure out if the W3C box model works as expected - div.innerHTML = ""; - div.style.width = div.style.paddingLeft = "1px"; - jQuery.boxModel = support.boxModel = div.offsetWidth === 2; - - if ( typeof div.style.zoom !== "undefined" ) { - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - // (IE < 8 does this) - div.style.display = "inline"; - div.style.zoom = 1; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); - - // Check if elements with layout shrink-wrap their children - // (IE 6 does this) - div.style.display = ""; - div.innerHTML = "
    "; - support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); - } - - div.style.cssText = ptlm + vb; - div.innerHTML = html; - - outer = div.firstChild; - inner = outer.firstChild; - td = outer.nextSibling.firstChild.firstChild; - - offsetSupport = { - doesNotAddBorder: ( inner.offsetTop !== 5 ), - doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) - }; - - inner.style.position = "fixed"; - inner.style.top = "20px"; - - // safari subtracts parent border width here which is 5px - offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); - inner.style.position = inner.style.top = ""; - - outer.style.overflow = "hidden"; - outer.style.position = "relative"; - - offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); - offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); - - body.removeChild( container ); - div = container = null; - - jQuery.extend( support, offsetSupport ); - }); - - return support; -})(); - - - - -var rbrace = /^(?:\{.*\}|\[.*\])$/, - rmultiDash = /([A-Z])/g; - -jQuery.extend({ - cache: {}, - - // Please use with caution - uuid: 0, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var privateCache, thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, - isEvents = name === "events"; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ internalKey ] = id = ++jQuery.uuid; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - privateCache = thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Users should not attempt to inspect the internal events object using jQuery.data, - // it is undocumented and subject to change. But does anyone listen? No. - if ( isEvents && !thisCache[ name ] ) { - return privateCache.events; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( getByName ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; - }, - - removeData: function( elem, name, pvt /* Internal Use Only */ ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, i, l, - - // Reference to internal data cache key - internalKey = jQuery.expando, - - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - - // See jQuery.data for more information - id = isNode ? elem[ internalKey ] : internalKey; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split( " " ); - } - } - } - - for ( i = 0, l = name.length; i < l; i++ ) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject(cache[ id ]) ) { - return; - } - } - - // Browsers that fail expando deletion also refuse to delete expandos on - // the window, but it will allow it on all other JS objects; other browsers - // don't care - // Ensure that `cache` is not a window object #10080 - if ( jQuery.support.deleteExpando || !cache.setInterval ) { - delete cache[ id ]; - } else { - cache[ id ] = null; - } - - // We destroyed the cache and need to eliminate the expando on the node to avoid - // false lookups in the cache for entries that no longer exist - if ( isNode ) { - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( jQuery.support.deleteExpando ) { - delete elem[ internalKey ]; - } else if ( elem.removeAttribute ) { - elem.removeAttribute( internalKey ); - } else { - elem[ internalKey ] = null; - } - } - }, - - // For internal use only. - _data: function( elem, name, data ) { - return jQuery.data( elem, name, data, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - if ( elem.nodeName ) { - var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; - - if ( match ) { - return !(match === true || elem.getAttribute("classid") !== match); - } - } - - return true; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var parts, attr, name, - data = null; - - if ( typeof key === "undefined" ) { - if ( this.length ) { - data = jQuery.data( this[0] ); - - if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { - attr = this[0].attributes; - for ( var i = 0, l = attr.length; i < l; i++ ) { - name = attr[i].name; - - if ( name.indexOf( "data-" ) === 0 ) { - name = jQuery.camelCase( name.substring(5) ); - - dataAttr( this[0], name, data[ name ] ); - } - } - jQuery._data( this[0], "parsedAttrs", true ); - } - } - - return data; - - } else if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - parts = key.split("."); - parts[1] = parts[1] ? "." + parts[1] : ""; - - if ( value === undefined ) { - data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); - - // Try to fetch any internally stored data first - if ( data === undefined && this.length ) { - data = jQuery.data( this[0], key ); - data = dataAttr( this[0], key, data ); - } - - return data === undefined && parts[1] ? - this.data( parts[0] ) : - data; - - } else { - return this.each(function() { - var self = jQuery( this ), - args = [ parts[0], value ]; - - self.triggerHandler( "setData" + parts[1] + "!", args ); - jQuery.data( this, key, value ); - self.triggerHandler( "changeData" + parts[1] + "!", args ); - }); - } - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - jQuery.isNumeric( data ) ? parseFloat( data ) : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - for ( var name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} - - - - -function handleQueueMarkDefer( elem, type, src ) { - var deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - defer = jQuery._data( elem, deferDataKey ); - if ( defer && - ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && - ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { - // Give room for hard-coded callbacks to fire first - // and eventually mark/queue something else on the element - setTimeout( function() { - if ( !jQuery._data( elem, queueDataKey ) && - !jQuery._data( elem, markDataKey ) ) { - jQuery.removeData( elem, deferDataKey, true ); - defer.fire(); - } - }, 0 ); - } -} - -jQuery.extend({ - - _mark: function( elem, type ) { - if ( elem ) { - type = ( type || "fx" ) + "mark"; - jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); - } - }, - - _unmark: function( force, elem, type ) { - if ( force !== true ) { - type = elem; - elem = force; - force = false; - } - if ( elem ) { - type = type || "fx"; - var key = type + "mark", - count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); - if ( count ) { - jQuery._data( elem, key, count ); - } else { - jQuery.removeData( elem, key, true ); - handleQueueMarkDefer( elem, type, "mark" ); - } - } - }, - - queue: function( elem, type, data ) { - var q; - if ( elem ) { - type = ( type || "fx" ) + "queue"; - q = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !q || jQuery.isArray(data) ) { - q = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - q.push( data ); - } - } - return q || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - fn = queue.shift(), - hooks = {}; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - } - - if ( fn ) { - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - jQuery._data( elem, type + ".run", hooks ); - fn.call( elem, function() { - jQuery.dequeue( elem, type ); - }, hooks ); - } - - if ( !queue.length ) { - jQuery.removeData( elem, type + "queue " + type + ".run", true ); - handleQueueMarkDefer( elem, type, "queue" ); - } - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - } - - if ( data === undefined ) { - return jQuery.queue( this[0], type ); - } - return this.each(function() { - var queue = jQuery.queue( this, type, data ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, object ) { - if ( typeof type !== "string" ) { - object = type; - type = undefined; - } - type = type || "fx"; - var defer = jQuery.Deferred(), - elements = this, - i = elements.length, - count = 1, - deferDataKey = type + "defer", - queueDataKey = type + "queue", - markDataKey = type + "mark", - tmp; - function resolve() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - } - while( i-- ) { - if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || - ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || - jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && - jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { - count++; - tmp.add( resolve ); - } - } - resolve(); - return defer.promise(); - } -}); - - - - -var rclass = /[\n\t\r]/g, - rspace = /\s+/, - rreturn = /\r/g, - rtype = /^(?:button|input)$/i, - rfocusable = /^(?:button|input|object|select|textarea)$/i, - rclickable = /^a(?:rea)?$/i, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - nodeHook, boolHook, fixSpecified; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.attr ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, name, value, true, jQuery.prop ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - var classNames, i, l, elem, - setClass, c, cl; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call(this, j, this.className) ); - }); - } - - if ( value && typeof value === "string" ) { - classNames = value.split( rspace ); - - for ( i = 0, l = this.length; i < l; i++ ) { - elem = this[ i ]; - - if ( elem.nodeType === 1 ) { - if ( !elem.className && classNames.length === 1 ) { - elem.className = value; - - } else { - setClass = " " + elem.className + " "; - - for ( c = 0, cl = classNames.length; c < cl; c++ ) { - if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { - setClass += classNames[ c ] + " "; - } - } - elem.className = jQuery.trim( setClass ); - } - } - } - } - - return this; - }, - - removeClass: function( value ) { - var classNames, i, l, elem, className, c, cl; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call(this, j, this.className) ); - }); - } - - if ( (value && typeof value === "string") || value === undefined ) { - classNames = ( value || "" ).split( rspace ); - - for ( i = 0, l = this.length; i < l; i++ ) { - elem = this[ i ]; - - if ( elem.nodeType === 1 && elem.className ) { - if ( value ) { - className = (" " + elem.className + " ").replace( rclass, " " ); - for ( c = 0, cl = classNames.length; c < cl; c++ ) { - className = className.replace(" " + classNames[ c ] + " ", " "); - } - elem.className = jQuery.trim( className ); - - } else { - elem.className = ""; - } - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.split( rspace ); - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space seperated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - } else if ( type === "undefined" || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // toggle whole className - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var hooks, ret, isFunction, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return; - } - - isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var self = jQuery(this), val; - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, self.val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function( elem ) { - var value, i, max, option, - index = elem.selectedIndex, - values = [], - options = elem.options, - one = elem.type === "select-one"; - - // Nothing was selected - if ( index < 0 ) { - return null; - } - - // Loop through all the selected options - i = one ? index : 0; - max = one ? index + 1 : options.length; - for ( ; i < max; i++ ) { - option = options[ i ]; - - // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - // Fixes Bug #2551 -- select.val() broken in IE after form.reset() - if ( one && !values.length && options.length ) { - return jQuery( options[ index ] ).val(); - } - - return values; - }, - - set: function( elem, value ) { - var values = jQuery.makeArray( value ); - - jQuery(elem).find("option").each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - attrFn: { - val: true, - css: true, - html: true, - text: true, - data: true, - width: true, - height: true, - offset: true - }, - - attr: function( elem, name, value, pass ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - if ( pass && name in jQuery.attrFn ) { - return jQuery( elem )[ name ]( value ); - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === "undefined" ) { - return jQuery.prop( elem, name, value ); - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( notxml ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - return; - - } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, "" + value ); - return value; - } - - } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - - ret = elem.getAttribute( name ); - - // Non-existent attributes return null, we normalize to undefined - return ret === null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var propName, attrNames, name, l, - i = 0; - - if ( value && elem.nodeType === 1 ) { - attrNames = value.toLowerCase().split( rspace ); - l = attrNames.length; - - for ( ; i < l; i++ ) { - name = attrNames[ i ]; - - if ( name ) { - propName = jQuery.propFix[ name ] || name; - - // See #9699 for explanation of this approach (setting first, then removal) - jQuery.attr( elem, name, "" ); - elem.removeAttribute( getSetAttribute ? name : propName ); - - // Set corresponding property to false for boolean attributes - if ( rboolean.test( name ) && propName in elem ) { - elem[ propName ] = false; - } - } - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - // We can't allow the type property to be changed (since it causes problems in IE) - if ( rtype.test( elem.nodeName ) && elem.parentNode ) { - jQuery.error( "type property can't be changed" ); - } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to it's default in case type is set after value - // This is for element creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - }, - // Use the value property for back compat - // Use the nodeHook for button elements in IE6/7 (#1954) - value: { - get: function( elem, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.get( elem, name ); - } - return name in elem ? - elem.value : - null; - }, - set: function( elem, value, name ) { - if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { - return nodeHook.set( elem, value, name ); - } - // Does not return so that setAttribute is also used - elem.value = value; - } - } - }, - - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - return ( elem[ name ] = value ); - } - - } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabindex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - } - } -}); - -// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) -jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; - -// Hook for boolean attributes -boolHook = { - get: function( elem, name ) { - // Align boolean attributes with corresponding properties - // Fall back to attribute presence where some booleans are not supported - var attrNode, - property = jQuery.prop( elem, name ); - return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - var propName; - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else { - // value is true since we know at this point it's type boolean and not false - // Set boolean attributes to the same name and set the DOM property - propName = jQuery.propFix[ name ] || name; - if ( propName in elem ) { - // Only set the IDL specifically if it already exists on the element - elem[ propName ] = true; - } - - elem.setAttribute( name, name.toLowerCase() ); - } - return name; - } -}; - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - fixSpecified = { - name: true, - id: true - }; - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = jQuery.valHooks.button = { - get: function( elem, name ) { - var ret; - ret = elem.getAttributeNode( name ); - return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? - ret.nodeValue : - undefined; - }, - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - ret = document.createAttribute( name ); - elem.setAttributeNode( ret ); - } - return ( ret.nodeValue = value + "" ); - } - }; - - // Apply the nodeHook to tabindex - jQuery.attrHooks.tabindex.set = nodeHook.set; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }); - }); - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function( elem, value, name ) { - if ( value === "" ) { - value = "false"; - } - nodeHook.set( elem, value, name ); - } - }; -} - - -// Some attributes require a special call on IE -if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - get: function( elem ) { - var ret = elem.getAttribute( name, 2 ); - return ret === null ? undefined : ret; - } - }); - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Normalize to lowercase since IE uppercases css property names - return elem.style.cssText.toLowerCase() || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = "" + value ); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }); -} - -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - -// Radios and checkboxes getter/setter -if ( !jQuery.support.checkOn ) { - jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - get: function( elem ) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); -} -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); - } - } - }); -}); - - - - -var rformElems = /^(?:textarea|input|select)$/i, - rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, - rhoverHack = /\bhover(\.\S+)?\b/, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, - quickParse = function( selector ) { - var quick = rquickIs.exec( selector ); - if ( quick ) { - // 0 1 2 3 - // [ _, tag, id, class ] - quick[1] = ( quick[1] || "" ).toLowerCase(); - quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); - } - return quick; - }, - quickIs = function( elem, m ) { - var attrs = elem.attributes || {}; - return ( - (!m[1] || elem.nodeName.toLowerCase() === m[1]) && - (!m[2] || (attrs.id || {}).value === m[2]) && - (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) - ); - }, - hoverHack = function( events ) { - return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); - }; - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - add: function( elem, types, handler, data, selector ) { - - var elemData, eventHandle, events, - t, tns, type, namespaces, handleObj, - handleObjIn, quick, handlers, special; - - // Don't attach events to noData or text/comment nodes (allow plain objects tho) - if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - events = elemData.events; - if ( !events ) { - elemData.events = events = {}; - } - eventHandle = elemData.handle; - if ( !eventHandle ) { - elemData.handle = eventHandle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = jQuery.trim( hoverHack(types) ).split( " " ); - for ( t = 0; t < types.length; t++ ) { - - tns = rtypenamespace.exec( types[t] ) || []; - type = tns[1]; - namespaces = ( tns[2] || "" ).split( "." ).sort(); - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: tns[1], - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - quick: quickParse( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); - - // Init the event handler queue if we're the first - handlers = events[ type ]; - if ( !handlers ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - global: {}, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - - var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), - t, tns, type, origType, namespaces, origCount, - j, events, special, handle, eventType, handleObj; - - if ( !elemData || !(events = elemData.events) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = jQuery.trim( hoverHack( types || "" ) ).split(" "); - for ( t = 0; t < types.length; t++ ) { - tns = rtypenamespace.exec( types[t] ) || []; - type = origType = tns[1]; - namespaces = tns[2]; - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector? special.delegateType : special.bindType ) || type; - eventType = events[ type ] || []; - origCount = eventType.length; - namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - - // Remove matching events - for ( j = 0; j < eventType.length; j++ ) { - handleObj = eventType[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !namespaces || namespaces.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - eventType.splice( j--, 1 ); - - if ( handleObj.selector ) { - eventType.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( eventType.length === 0 && origCount !== eventType.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - handle = elemData.handle; - if ( handle ) { - handle.elem = null; - } - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery.removeData( elem, [ "events", "handle" ], true ); - } - }, - - // Events that are safe to short-circuit if no handlers are attached. - // Native DOM events should not be added, they may have inline handlers. - customEvent: { - "getData": true, - "setData": true, - "changeData": true - }, - - trigger: function( event, data, elem, onlyHandlers ) { - // Don't do events on text and comment nodes - if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { - return; - } - - // Event object or event type - var type = event.type || event, - namespaces = [], - cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf( "!" ) >= 0 ) { - // Exclusive events trigger only for the exact event (no namespaces) - type = type.slice(0, -1); - exclusive = true; - } - - if ( type.indexOf( "." ) >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - - if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { - // No jQuery handlers for this event type, and it can't have inline handlers - return; - } - - // Caller can pass in an Event, Object, or just an event type string - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - new jQuery.Event( type, event ) : - // Just the event type (string) - new jQuery.Event( type ); - - event.type = type; - event.isTrigger = true; - event.exclusive = exclusive; - event.namespace = namespaces.join( "." ); - event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; - ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; - - // Handle a global trigger - if ( !elem ) { - - // TODO: Stop taunting the data cache; remove global events and always attach to document - cache = jQuery.cache; - for ( i in cache ) { - if ( cache[ i ].events && cache[ i ].events[ type ] ) { - jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); - } - } - return; - } - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data != null ? jQuery.makeArray( data ) : []; - data.unshift( event ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - eventPath = [[ elem, special.bindType || type ]]; - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; - old = null; - for ( ; cur; cur = cur.parentNode ) { - eventPath.push([ cur, bubbleType ]); - old = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( old && old === elem.ownerDocument ) { - eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); - } - } - - // Fire handlers on the event path - for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { - - cur = eventPath[i][0]; - event.type = eventPath[i][1]; - - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - // Note that this is a bare JS function and not a jQuery handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && - !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - // IE<9 dies on focus/blur to hidden element (#1486) - if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - old = elem[ ontype ]; - - if ( old ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - elem[ type ](); - jQuery.event.triggered = undefined; - - if ( old ) { - elem[ ontype ] = old; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event || window.event ); - - var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), - delegateCount = handlers.delegateCount, - args = [].slice.call( arguments, 0 ), - run_all = !event.exclusive && !event.namespace, - handlerQueue = [], - i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Determine handlers that should run if there are delegated events - // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) - if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { - - // Pregenerate a single jQuery object for reuse with .is() - jqcur = jQuery(this); - jqcur.context = this.ownerDocument || this; - - for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { - selMatch = {}; - matches = []; - jqcur[0] = cur; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - sel = handleObj.selector; - - if ( selMatch[ sel ] === undefined ) { - selMatch[ sel ] = ( - handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) - ); - } - if ( selMatch[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, matches: matches }); - } - } - } - - // Add the remaining (directly-bound) handlers - if ( handlers.length > delegateCount ) { - handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); - } - - // Run delegates first; they may want to stop propagation beneath us - for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { - matched = handlerQueue[ i ]; - event.currentTarget = matched.elem; - - for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { - handleObj = matched.matches[ j ]; - - // Triggered event must either 1) be non-exclusive and have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { - - event.data = handleObj.data; - event.handleObj = handleObj; - - ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) - .apply( matched.elem, args ); - - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - return event.result; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** - props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var eventDoc, doc, body, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, - originalEvent = event, - fixHook = jQuery.event.fixHooks[ event.type ] || {}, - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = jQuery.Event( originalEvent ); - - for ( i = copy.length; i; ) { - prop = copy[ --i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Target should not be a text node (#504, Safari) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) - if ( event.metaKey === undefined ) { - event.metaKey = event.ctrlKey; - } - - return fixHook.filter? fixHook.filter( event, originalEvent ) : event; - }, - - special: { - ready: { - // Make sure the ready event is setup - setup: jQuery.bindReady - }, - - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - - focus: { - delegateType: "focusin" - }, - blur: { - delegateType: "focusout" - }, - - beforeunload: { - setup: function( data, namespaces, eventHandle ) { - // We only want to do this special case on windows - if ( jQuery.isWindow( this ) ) { - this.onbeforeunload = eventHandle; - } - }, - - teardown: function( namespaces, eventHandle ) { - if ( this.onbeforeunload === eventHandle ) { - this.onbeforeunload = null; - } - } - } - }, - - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { type: type, - isSimulated: true, - originalEvent: {} - } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -// Some plugins are using, but it's undocumented/deprecated and will be removed. -// The 1.7 special event interface should provide all the hooks needed now. -jQuery.event.handle = jQuery.event.dispatch; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - if ( elem.detachEvent ) { - elem.detachEvent( "on" + type, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -function returnFalse() { - return false; -} -function returnTrue() { - return true; -} - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - preventDefault: function() { - this.isDefaultPrevented = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - - // if preventDefault exists run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // otherwise set the returnValue property of the original event to false (IE) - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - this.isPropagationStopped = returnTrue; - - var e = this.originalEvent; - if ( !e ) { - return; - } - // if stopPropagation exists run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - // otherwise set the cancelBubble property of the original event to true (IE) - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - }, - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var target = this, - related = event.relatedTarget, - handleObj = event.handleObj, - selector = handleObj.selector, - ret; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -}); - -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !form._submit_attached ) { - jQuery.event.add( form, "submit._submit", function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - }); - form._submit_attached = true; - } - }); - // return undefined since we don't need an event listener - }, - - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; - } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; - jQuery.event.simulate( "change", this, event, true ); - } - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - elem._change_attached = true; - } - }); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return rformElems.test( this.nodeName ); - } - }; -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - }); -} - -jQuery.fn.extend({ - - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var origFn, type; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - // ( types-Object, data ) - data = selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } - - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on.call( this, types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - var handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( var type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); - }, - - bind: function( types, data, fn ) { - return this.on( types, null, data, fn ); - }, - unbind: function( types, fn ) { - return this.off( types, null, fn ); - }, - - live: function( types, data, fn ) { - jQuery( this.context ).on( types, this.selector, data, fn ); - return this; - }, - die: function( types, fn ) { - jQuery( this.context ).off( types, this.selector || "**", fn ); - return this; - }, - - delegate: function( selector, types, data, fn ) { - return this.on( types, selector, data, fn ); - }, - undelegate: function( selector, types, fn ) { - // ( namespace ) or ( selector, types [, fn] ) - return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - if ( this[0] ) { - return jQuery.event.trigger( type, data, this[0], true ); - } - }, - - toggle: function( fn ) { - // Save reference to arguments for access in closure - var args = arguments, - guid = fn.guid || jQuery.guid++, - i = 0, - toggler = function( event ) { - // Figure out which function to execute - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); - - // Make sure that clicks stop - event.preventDefault(); - - // and execute the function - return args[ lastToggle ].apply( this, arguments ) || false; - }; - - // link all the functions, so any of them can unbind this click handler - toggler.guid = guid; - while ( i < args.length ) { - args[ i++ ].guid = guid; - } - - return this.click( toggler ); - }, - - hover: function( fnOver, fnOut ) { - return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); - } -}); - -jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + - "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + - "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { - - // Handle event binding - jQuery.fn[ name ] = function( data, fn ) { - if ( fn == null ) { - fn = data; - data = null; - } - - return arguments.length > 0 ? - this.on( name, null, data, fn ) : - this.trigger( name ); - }; - - if ( jQuery.attrFn ) { - jQuery.attrFn[ name ] = true; - } - - if ( rkeyEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; - } - - if ( rmouseEvent.test( name ) ) { - jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; - } -}); - - - -/*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - expando = "sizcache" + (Math.random() + '').replace('.', ''), - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rReturn = /\r\n/g, - rNonWord = /\W/; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); - -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; - - var origContext = context; - - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); - - if ( m ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; - } - } - } while ( m ); - - if ( parts.length > 1 && origPOS.exec( selector ) ) { - - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context, seed ); - - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); - - while ( parts.length ) { - selector = parts.shift(); - - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); - } - - set = posProcess( selector, set, seed ); - } - } - - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { - - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; - } - - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); - - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; - - if ( parts.length > 0 ) { - checkSet = makeArray( set ); - - } else { - prune = false; - } - - while ( parts.length ) { - cur = parts.pop(); - pop = cur; - - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } - - if ( pop == null ) { - pop = context; - } - - Expr.relative[ cur ]( checkSet, pop, contextXML ); - } - - } else { - checkSet = parts = []; - } - } - - if ( !checkSet ) { - checkSet = set; - } - - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } - - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); - - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); - } - } - - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } - } - } - - } else { - makeArray( checkSet, results ); - } - - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } - - return results; -}; - -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } - } - } - - return results; -}; - -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; - -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; - -Sizzle.find = function( expr, context, isXML ) { - var set, i, len, match, type, left; - - if ( !expr ) { - return []; - } - - for ( i = 0, len = Expr.order.length; i < len; i++ ) { - type = Expr.order[i]; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - left = match[1]; - match.splice( 1, 1 ); - - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace( rBackslash, "" ); - set = Expr.find[ type ]( match, context, isXML ); - - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } - } - } - - if ( !set ) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( "*" ) : - []; - } - - return { set: set, expr: expr }; -}; - -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - type, found, item, filter, left, - i, pass, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); - - while ( expr && set.length ) { - for ( type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - filter = Expr.filter[ type ]; - left = match[1]; - - anyFound = false; - - match.splice(1,1); - - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } - - if ( curLoop === result ) { - result = []; - } - - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); - - if ( !match ) { - anyFound = found = true; - - } else if ( match === true ) { - continue; - } - } - - if ( match ) { - for ( i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - pass = not ^ found; - - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; - - } else { - curLoop[i] = false; - } - - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } - - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } - - expr = expr.replace( Expr.match[ type ], "" ); - - if ( !anyFound ) { - return []; - } - - break; - } - } - } - - // Improper expression - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); - - } else { - break; - } - } - - old = expr; - } - - return curLoop; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -/** - * Utility function for retreiving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -var getText = Sizzle.getText = function( elem ) { - var i, node, - nodeType = elem.nodeType, - ret = ""; - - if ( nodeType ) { - if ( nodeType === 1 || nodeType === 9 ) { - // Use textContent || innerText for elements - if ( typeof elem.textContent === 'string' ) { - return elem.textContent; - } else if ( typeof elem.innerText === 'string' ) { - // Replace IE's carriage returns - return elem.innerText.replace( rReturn, '' ); - } else { - // Traverse it's children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - } else { - - // If no nodeType, this is expected to be an array - for ( i = 0; (node = elem[i]); i++ ) { - // Do not traverse comment nodes - if ( node.nodeType !== 8 ) { - ret += getText( node ); - } - } - } - return ret; -}; - -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, - - leftMatch: {}, - - attrMap: { - "class": "className", - "for": "htmlFor" - }, - - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - }, - type: function( elem ) { - return elem.getAttribute( "type" ); - } - }, - - relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test( part ), - isPartStrNotTag = isPartStr && !isTag; - - if ( isTag ) { - part = part.toLowerCase(); - } - - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } - } - - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } - }, - - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if ( isPartStr && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } - } - }, - - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); - }, - - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, - - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }, - - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); - - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } - - return ret.length === 0 ? null : ret; - } - }, - - TAG: function( match, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( match[1] ); - } - } - }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace( rBackslash, "" ) + " "; - - if ( isXML ) { - return match; - } - - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } - - } else if ( inplace ) { - curLoop[i] = false; - } - } - } - - return false; - }, - - ID: function( match ) { - return match[1].replace( rBackslash, "" ); - }, - - TAG: function( match, curLoop ) { - return match[1].replace( rBackslash, "" ).toLowerCase(); - }, - - CHILD: function( match ) { - if ( match[1] === "nth" ) { - if ( !match[2] ) { - Sizzle.error( match[0] ); - } - - match[2] = match[2].replace(/^\+|\s*/g, ''); - - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); - - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if ( match[2] ) { - Sizzle.error( match[0] ); - } - - // TODO: Move to normal caching system - match[0] = done++; - - return match; - }, - - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace( rBackslash, "" ); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } - - // Handle if an un-quoted value was used - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); - - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } - - return match; - }, - - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - // If we're dealing with a complex expression, or a simple one - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if ( !inplace ) { - result.push.apply( result, ret ); - } - - return false; - } - - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; - }, - - POS: function( match ) { - match.unshift( true ); - - return match; - } - }, - - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, - - disabled: function( elem ) { - return elem.disabled === true; - }, - - checked: function( elem ) { - return elem.checked === true; - }, - - selected: function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - parent: function( elem ) { - return !!elem.firstChild; - }, - - empty: function( elem ) { - return !elem.firstChild; - }, - - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, - - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, - - text: function( elem ) { - var attr = elem.getAttribute( "type" ), type = elem.type; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); - }, - - radio: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, - - checkbox: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, - - file: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; - }, - - password: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; - }, - - submit: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; - }, - - image: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; - }, - - reset: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; - }, - - button: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; - }, - - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - }, - - focus: function( elem ) { - return elem === elem.ownerDocument.activeElement; - } - }, - setFilters: { - first: function( elem, i ) { - return i === 0; - }, - - last: function( elem, i, match, array ) { - return i === array.length - 1; - }, - - even: function( elem, i ) { - return i % 2 === 0; - }, - - odd: function( elem, i ) { - return i % 2 === 1; - }, - - lt: function( elem, i, match ) { - return i < match[3] - 0; - }, - - gt: function( elem, i, match ) { - return i > match[3] - 0; - }, - - nth: function( elem, i, match ) { - return match[3] - 0 === i; - }, - - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } - } - - return true; - - } else { - Sizzle.error( name ); - } - }, - - CHILD: function( elem, match ) { - var first, last, - doneName, parent, cache, - count, diff, - type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } - - node = elem; - - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - return true; - - case "nth": - first = match[2]; - last = match[3]; - - if ( first === 1 && last === 0 ) { - return true; - } - - doneName = match[0]; - parent = elem.parentNode; - - if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { - count = 0; - - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } - - parent[ expando ] = doneName; - } - - diff = elem.nodeIndex - last; - - if ( first === 0 ) { - return diff === 0; - - } else { - return ( diff % first === 0 && diff / first >= 0 ); - } - } - }, - - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; - }, - - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, - - ATTR: function( elem, match ) { - var name = match[1], - result = Sizzle.attr ? - Sizzle.attr( elem, name ) : - Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - !type && Sizzle.attr ? - result != null : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } - } - } -}; - -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; - -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); -} - -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; - } - - return array; -}; - -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; - -// Provide a fallback method if it does not work -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; - - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); - - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } - - } else { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } - - return ret; - }; -} - -var sortOrder, siblingCheck; - -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; - } - - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - -} else { - sortOrder = function( a, b ) { - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } - - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // If the nodes are siblings (or identical) we can do a quick check - if ( aup === bup ) { - return siblingCheck( a, b ); - - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; - - } else if ( !bup ) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } - - cur = bup; - - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; - } - - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; - }; -} - -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) -(function(){ - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = ""; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore( form, root.firstChild ); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - - // release memory in IE - root = form = null; -})(); - -(function(){ - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - // Make sure no comments are found - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - // Filter out possible comments - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } - } - - results = tmp; - } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = ""; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; - } - - // release memory in IE - div = null; -})(); - -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "

    "; - - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function( query, context, extra, seed ) { - context = context || document; - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if ( !seed && !Sizzle.isXML(context) ) { - // See if we find a selector to speed up - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); - - if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { - // Speed-up: Sizzle("TAG") - if ( match[1] ) { - return makeArray( context.getElementsByTagName( query ), extra ); - - // Speed-up: Sizzle(".CLASS") - } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { - return makeArray( context.getElementsByClassName( match[2] ), extra ); - } - } - - if ( context.nodeType === 9 ) { - // Speed-up: Sizzle("body") - // The body element only exists once, optimize finding it - if ( query === "body" && context.body ) { - return makeArray( [ context.body ], extra ); - - // Speed-up: Sizzle("#ID") - } else if ( match && match[3] ) { - var elem = context.getElementById( match[3] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id === match[3] ) { - return makeArray( [ elem ], extra ); - } - - } else { - return makeArray( [], extra ); - } - } - - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var oldContext = context, - old = context.getAttribute( "id" ), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test( query ); - - if ( !old ) { - context.setAttribute( "id", nid ); - } else { - nid = nid.replace( /'/g, "\\$&" ); - } - if ( relativeHierarchySelector && hasParent ) { - context = context.parentNode; - } - - try { - if ( !relativeHierarchySelector || hasParent ) { - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); - } - - } catch(pseudoError) { - } finally { - if ( !old ) { - oldContext.removeAttribute( "id" ); - } - } - } - } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - // release memory in IE - div = null; - })(); -} - -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; - - if ( matches ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9 fails this) - var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), - pseudoWorks = false; - - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( document.documentElement, "[test!='']:sizzle" ); - - } catch( pseudoError ) { - pseudoWorks = true; - } - - Sizzle.matchesSelector = function( node, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - var ret = matches.call( node, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || !disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9, so check for that - node.document && node.document.nodeType !== 11 ) { - return ret; - } - } - } catch(e) {} - } - - return Sizzle(expr, null, null, [node]).length > 0; - }; - } -})(); - -(function(){ - var div = document.createElement("div"); - - div.innerHTML = "
    "; - - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; - } - - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) { - return; - } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem[ expando ] === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 && !isXML ){ - elem[ expando ] = doneName; - elem.sizset = i; - } - - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem[ expando ] === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem[ expando ] = doneName; - elem.sizset = i; - } - - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; -} - -Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -var posProcess = function( selector, context, seed ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet, seed ); - } - - return Sizzle.filter( later, tmpSet ); -}; - -// EXPOSE -// Override sizzle attribute retrieval -Sizzle.attr = jQuery.attr; -Sizzle.selectors.attrMap = {}; -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.filters; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})(); - - -var runtil = /Until$/, - rparentsprev = /^(?:parents|prevUntil|prevAll)/, - // Note: This RegExp should be improved, or likely pulled from Sizzle - rmultiselector = /,/, - isSimple = /^.[^:#\[\.,]*$/, - slice = Array.prototype.slice, - POS = jQuery.expr.match.POS, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var self = this, - i, l; - - if ( typeof selector !== "string" ) { - return jQuery( selector ).filter(function() { - for ( i = 0, l = self.length; i < l; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }); - } - - var ret = this.pushStack( "", "find", selector ), - length, n, r; - - for ( i = 0, l = this.length; i < l; i++ ) { - length = ret.length; - jQuery.find( selector, this[i], ret ); - - if ( i > 0 ) { - // Make sure that the results are unique - for ( n = length; n < ret.length; n++ ) { - for ( r = 0; r < length; r++ ) { - if ( ret[r] === ret[n] ) { - ret.splice(n--, 1); - break; - } - } - } - } - } - - return ret; - }, - - has: function( target ) { - var targets = jQuery( target ); - return this.filter(function() { - for ( var i = 0, l = targets.length; i < l; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false), "not", selector); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true), "filter", selector ); - }, - - is: function( selector ) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - POS.test( selector ) ? - jQuery( selector, this.context ).index( this[0] ) >= 0 : - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); - }, - - closest: function( selectors, context ) { - var ret = [], i, l, cur = this[0]; - - // Array (deprecated as of jQuery 1.7) - if ( jQuery.isArray( selectors ) ) { - var level = 1; - - while ( cur && cur.ownerDocument && cur !== context ) { - for ( i = 0; i < selectors.length; i++ ) { - - if ( jQuery( cur ).is( selectors[ i ] ) ) { - ret.push({ selector: selectors[ i ], elem: cur, level: level }); - } - } - - cur = cur.parentNode; - level++; - } - - return ret; - } - - // String - var pos = POS.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( i = 0, l = this.length; i < l; i++ ) { - cur = this[i]; - - while ( cur ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - - } else { - cur = cur.parentNode; - if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { - break; - } - } - } - } - - ret = ret.length > 1 ? jQuery.unique( ret ) : ret; - - return this.pushStack( ret, "closest", selectors ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? - all : - jQuery.unique( all ) ); - }, - - andSelf: function() { - return this.add( this.prevObject ); - } -}); - -// A painfully simple check to see if an element is disconnected -// from a document (should be improved, where feasible). -function isDisconnected( node ) { - return !node || !node.parentNode || node.parentNode.nodeType === 11; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return jQuery.nth( elem, 2, "nextSibling" ); - }, - prev: function( elem ) { - return jQuery.nth( elem, 2, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( elem.parentNode.firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.makeArray( elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - - if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret, name, slice.call( arguments ).join(",") ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - nth: function( cur, result, dir, elem ) { - result = result || 1; - var num = 0; - - for ( ; cur; cur = cur[dir] ) { - if ( cur.nodeType === 1 && ++num === result ) { - break; - } - } - - return cur; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem, i ) { - return ( elem === qualifier ) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem, i ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; - }); -} - - - - -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - -var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" + - "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", - rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, - rtagName = /<([\w:]+)/, - rtbody = /", "" ], - legend: [ 1, "
    ", "
    " ], - thead: [ 1, "", "
    " ], - tr: [ 2, "", "
    " ], - td: [ 3, "", "
    " ], - col: [ 2, "", "
    " ], - area: [ 1, "", "" ], - _default: [ 0, "", "" ] - }, - safeFragment = createSafeFragment( document ); - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -// IE can't serialize and - - - - - - - -
    - - diff --git a/spm_modules/jquery/1.9.1/.gitignore b/spm_modules/jquery/1.9.1/.gitignore deleted file mode 100644 index 378eac2..0000000 --- a/spm_modules/jquery/1.9.1/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/spm_modules/jquery/1.9.1/README.md b/spm_modules/jquery/1.9.1/README.md deleted file mode 100644 index ee4907f..0000000 --- a/spm_modules/jquery/1.9.1/README.md +++ /dev/null @@ -1,4 +0,0 @@ -jQuery Component -================ - -Shim repository for jQuery. diff --git a/spm_modules/jquery/1.9.1/component.json b/spm_modules/jquery/1.9.1/component.json deleted file mode 100644 index 7fdbee9..0000000 --- a/spm_modules/jquery/1.9.1/component.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "jquery", - "version": "1.9.1", - "description": "jQuery component", - "keywords": [ - "jquery", - "component" - ], - "scripts": [ - "jquery.js" - ], - "license": "MIT" -} diff --git a/spm_modules/jquery/1.9.1/composer.json b/spm_modules/jquery/1.9.1/composer.json deleted file mode 100644 index c617840..0000000 --- a/spm_modules/jquery/1.9.1/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "components/jquery", - "description": "jQuery JavaScript Library", - "type": "component", - "homepage": "http://jquery.com", - "license": "MIT", - "support": { - "irc": "irc://irc.freenode.org/jquery", - "issues": "http://bugs.jquery.com", - "forum": "http://forum.jquery.com", - "wiki": "http://docs.jquery.com/", - "source": "https://github.com/jquery/jquery" - }, - "authors": [ - { - "name": "John Resig", - "email": "jeresig@gmail.com" - } - ], - "require": { - "robloach/component-installer": "*" - }, - "extra": { - "component": { - "scripts": [ - "jquery.js" - ], - "files": [ - "jquery.min.js", - "jquery-migrate.js", - "jquery-migrate.min.js" - ] - } - } -} diff --git a/spm_modules/jquery/1.9.1/jquery-migrate.js b/spm_modules/jquery/1.9.1/jquery-migrate.js deleted file mode 100644 index 3185ed1..0000000 --- a/spm_modules/jquery/1.9.1/jquery-migrate.js +++ /dev/null @@ -1,496 +0,0 @@ -/*! - * jQuery Migrate - v1.1.0 - 2013-01-31 - * https://github.com/jquery/jquery-migrate - * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT - */ -(function( jQuery, window, undefined ) { -"use strict"; - - -var warnedAbout = {}; - -// List of warnings already given; public read only -jQuery.migrateWarnings = []; - -// Set to true to prevent console output; migrateWarnings still maintained -// jQuery.migrateMute = false; - -// Show a message on the console so devs know we're active -if ( !jQuery.migrateMute && window.console && console.log ) { - console.log("JQMIGRATE: Logging is active"); -} - -// Set to false to disable traces that appear with warnings -if ( jQuery.migrateTrace === undefined ) { - jQuery.migrateTrace = true; -} - -// Forget any warnings we've already given; public -jQuery.migrateReset = function() { - warnedAbout = {}; - jQuery.migrateWarnings.length = 0; -}; - -function migrateWarn( msg) { - if ( !warnedAbout[ msg ] ) { - warnedAbout[ msg ] = true; - jQuery.migrateWarnings.push( msg ); - if ( window.console && console.warn && !jQuery.migrateMute ) { - console.warn( "JQMIGRATE: " + msg ); - if ( jQuery.migrateTrace && console.trace ) { - console.trace(); - } - } - } -} - -function migrateWarnProp( obj, prop, value, msg ) { - if ( Object.defineProperty ) { - // On ES5 browsers (non-oldIE), warn if the code tries to get prop; - // allow property to be overwritten in case some other plugin wants it - try { - Object.defineProperty( obj, prop, { - configurable: true, - enumerable: true, - get: function() { - migrateWarn( msg ); - return value; - }, - set: function( newValue ) { - migrateWarn( msg ); - value = newValue; - } - }); - return; - } catch( err ) { - // IE8 is a dope about Object.defineProperty, can't warn there - } - } - - // Non-ES5 (or broken) browser; just set the property - jQuery._definePropertyBroken = true; - obj[ prop ] = value; -} - -if ( document.compatMode === "BackCompat" ) { - // jQuery has never supported or tested Quirks Mode - migrateWarn( "jQuery is not compatible with Quirks Mode" ); -} - - -var attrFn = {}, - oldAttr = jQuery.attr, - valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || - function() { return null; }, - valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || - function() { return undefined; }, - rnoType = /^(?:input|button)$/i, - rnoAttrNodeType = /^[238]$/, - rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, - ruseDefault = /^(?:checked|selected)$/i; - -// jQuery.attrFn -migrateWarnProp( jQuery, "attrFn", attrFn, "jQuery.attrFn is deprecated" ); - -jQuery.attr = function( elem, name, value, pass ) { - var lowerName = name.toLowerCase(), - nType = elem && elem.nodeType; - - // Since pass is used internally, we only warn and shim for new jQuery - // versions where there isn't a pass arg in the formal params - if ( pass && oldAttr.length < 4 ) { - migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); - if ( elem && !rnoAttrNodeType.test( nType ) && jQuery.isFunction( jQuery.fn[ name ] ) ) { - return jQuery( elem )[ name ]( value ); - } - } - - // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking - // for disconnected elements we don't warn on $( "