diff --git a/bi/base.css b/bi/base.css index a97667728a..d9a49fee4a 100644 --- a/bi/base.css +++ b/bi/base.css @@ -1035,7 +1035,7 @@ li.CodeMirror-hint-active { overflow-x: hidden; overflow-y: hidden; white-space: nowrap; - word-break: break-all; + word-break: break-word; } /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ @@ -1197,9 +1197,6 @@ li.CodeMirror-hint-active { .bi-grid-table-cell.first-col { border-left: 1px solid #eaeaea; } -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ .scrollbar-layout-main { box-sizing: border-box; outline: none; diff --git a/bi/base.js b/bi/base.js index 2d39187d1d..41d9f2b6f2 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { self.setValue([]); break; } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); + } else { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); btn.on(BI.Events.DESTROY, function () { BI.remove(self.buttons, btn); @@ -1118,9 +1120,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { @@ -2354,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController(); BI.Tooltips = new BI.TooltipsController(); BI.Popovers = new BI.FloatBoxController(); BI.Broadcasts = new BI.BroadcastController(); -BI.StyleLoaders = new BI.StyleLoaderManager(); - -BI.servletURL = "dist/"; -BI.resourceURL = "dist/resource/"; -BI.i18n = {};/** +BI.StyleLoaders = new BI.StyleLoaderManager();/** * canvas绘图 * * Created by GUY on 2015/11/18. @@ -3609,18 +3619,30 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); + }, + + empty: function () { + this.layouts.empty(); }, populate: function (items) { var self = this; items = items || []; this.options.items = items; - items = this._packageItems(items, this._packageBtns(items)); + items = this._packageBtns(items); if (!this.layouts) { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); } else { - this.layouts.populate(this._packageLayout(items).items); + this.layouts.populate(items); } } }); @@ -18237,7 +18259,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, false ); - xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true); + xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true); if (!xhr.upload) { var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true}; rpe.interval = setInterval(function () { @@ -18686,7 +18708,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); + BI.File.superclass.setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { diff --git a/bi/case.js b/bi/case.js index e4215d7248..af310f6c84 100644 --- a/bi/case.js +++ b/bi/case.js @@ -8520,7 +8520,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, { hgap: 4, vgap: 0, value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), width: 30, height: 20 }); diff --git a/bi/core.js b/bi/core.js index bc36f84a65..e47cc4482b 100644 --- a/bi/core.js +++ b/bi/core.js @@ -2036,7 +2036,7 @@ if (!window.BI) { }, formatEL: function (obj) { - if (obj && obj.el) { + if (obj && !obj.type && obj.el) { return obj; } return { @@ -2971,100 +2971,24 @@ if (!window.BI) { //encode encodeBIParam(option.data); - var async = true; - if (BI.isNotNull(option.async)) { - async = option.async; - } - - if (BI.isNull(loading)) { - loading = BI.createWidget({ - type: "bi.request_loading" - }); - } + var async = option.async; - if (BI.isNull(timeoutToast)) { - timeoutToast = BI.createWidget({ - type: "bi.timeout_toast" - }); - timeoutToast.setCallback(function (op) { - decodeBIParam(op.data); - BI.ajax(op); - }); - } - timeoutToast.addReq(option); + option.data = BI.cjkEncodeDO(option.data); - option.data = BI.cjkEncodeDO(option.data); - - - $.ajax({ url: option.url, type: "POST", data: option.data, async: async, - error: function () { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //失败 取消、重新加载 - loading.setCallback(function () { - decodeBIParam(option.data); - BI.ajax(option); - }); - loading.showError(); - }, + error: option.error, complete: function (res, status) { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //登录超时 - if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("fs-login-content") > -1 && - res.responseText.indexOf("fs-login-input-password-confirm") === -1) { - if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) { - return; - } - if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) { - BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID); - return; - } - var loginTimeout = BI.createWidget({ - type: "bi.login_timeout" - }); - loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () { - decodeBIParam(option.data); - BI.ajax(option); - BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID); - }); - BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, { - width: 600, - height: 400 - }).open(BI.LoginTimeOut.POPOVER_ID); - } else if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("script") > -1 && - res.responseText.indexOf("Session Timeout...") > -1) { - //登录失效 - loading.setCallback(function () { - location.reload(); - }); - loading.showError(); - - } else if (status === "success" && BI.isFunction(option.success)) { - option.success(BI.jsonDecode(res.responseText)); - } if (BI.isFunction(option.complete)) { option.complete(BI.jsonDecode(res.responseText), status); } } }); - return function cancel() { - timeoutToast.removeReq(option); - }; - function encodeBIParam(data) { for (var key in data) { if (_.isObject(data[key])) { @@ -3084,102 +3008,7 @@ if (!window.BI) { } } } - })(), - - /** - * 异步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参数 - * @param {Function} callback 回调函数 - * @param {Function} complete 回调 - */ - requestAsync: function (op, cmd, data, callback, complete) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi" || op === "fr_bi_configure") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - return (BI.ajax)({ - url: url, - type: 'POST', - data: data, - error: function () { - // BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - success: function (res) { - if (BI.isFunction(callback)) { - callback(res); - } - }, - complete: function (res, status) { - if (BI.isFunction(complete)) { - complete(res); - } - } - }); - }, - - /** - * 同步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参�? - * @returns {Object} ajax同步请求返回的JSON对象 - */ - requestSync: function (op, cmd, data) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - var result = {}; - (BI.ajax)({ - url: url, - type: 'POST', - async: false, - data: data, - error: function () { - BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - complete: function (res, status) { - if (status === 'success') { - result = res; - } - } - }); - return result; - }, - - /** - * 请求方法 - * @param cmd 命令 - * @param data 数据 - * @param extend 参数 - * @returns {*} - */ - request: function (cmd, data, extend) { - extend = extend || {}; - data = data || {}; - var op = extend.op; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - if (extend.async === true) { - BI.requestAsync(op, cmd, data, extend.complete || extend.success); - } else { - return BI.requestSync(op, cmd, data); - } - } + })() }); })(jQuery);;(function () { function isEmpty(value) { @@ -3188,178 +3017,59 @@ if (!window.BI) { return result; } - BI.cjkEncode = function (text) { - // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) - if (typeof text !== 'string') { - return text; - } + // 判断是否是无效的日期 + function isInvalidDate(date) { + return date == "Invalid Date" || date == "NaN"; + } - var newText = ""; - for (var i = 0; i < text.length; i++) { - var code = text.charCodeAt(i); - if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". - newText += "[" + code.toString(16) + "]"; - } else { - newText += text.charAt(i); + /** + * 科学计数格式 + */ + function _eFormat(text, fmt) { + var e = fmt.indexOf("E"); + var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); + if (/^[0\.-]+$/.test(text)) { + text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) + } else { + var isNegative = text < 0; + if (isNegative) { + text = text.substr(1); } - } - - return newText - }; - - BI.cjkEncodeDO = function (o) { - if (BI.isPlainObject(o)) { - var result = {}; - $.each(o, function (k, v) { - if (!(typeof v == "string")) { - v = BI.jsonEncode(v); - } - //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 - k = BI.cjkEncode(k); - result[k] = BI.cjkEncode(v); - }); - return result; - } - return o; - }; - - BI.jsonEncode = function (o) { - //james:这个Encode是抄的EXT的 - var useHasOwn = {}.hasOwnProperty ? true : false; - - // crashes Safari in some instances - //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; - - var m = { - "\b": '\\b', - "\t": '\\t', - "\n": '\\n', - "\f": '\\f', - "\r": '\\r', - '"': '\\"', - "\\": '\\\\' - }; - - var encodeString = function (s) { - if (/["\\\x00-\x1f]/.test(s)) { - return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { - var c = m[b]; - if (c) { - return c; - } - c = b.charCodeAt(); - return "\\u00" + - Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"'; + var elvl = (eleft.split('.')[0] || '').length; + var point = text.indexOf("."); + if (point < 0) { + point = text.length; } - return '"' + s + '"'; - }; - - var encodeArray = function (o) { - var a = ["["], b, i, l = o.length, v; - for (i = 0; i < l; i += 1) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "function": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(v === null ? "null" : BI.jsonEncode(v)); - b = true; + var i = 0; //第一个不为0的数的位置 + text = text.replace('.', ''); + for (var len = text.length; i < len; i++) { + var ech = text.charAt(i); + if (ech <= '9' && ech >= '1') { + break; } } - a.push("]"); - return a.join(""); - }; - - if (typeof o == "undefined" || o === null) { - return "null"; - } else if (BI.isArray(o)) { - return encodeArray(o); - } else if (o instanceof Date) { - /* - * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode - * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 - */ - return BI.jsonEncode({ - __time__: o.getTime() - }) - } else if (typeof o == "string") { - return encodeString(o); - } else if (typeof o == "number") { - return isFinite(o) ? String(o) : "null"; - } else if (typeof o == "boolean") { - return String(o); - } else if (BI.isFunction(o)) { - return String(o); - } else { - var a = ["{"], b, i, v; - for (i in o) { - if (!useHasOwn || o.hasOwnProperty(i)) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(BI.jsonEncode(i), ":", - v === null ? "null" : BI.jsonEncode(v)); - b = true; - } + var right = point - i - elvl; + var left = text.substr(i, elvl); + var dis = i + elvl - text.length; + if (dis > 0) { + //末位补全0 + for (var k = 0; k < dis; k++) { + left += '0'; } + } else { + left += '.' + text.substr(i + elvl); } - a.push("}"); - return a.join(""); - } - }; - - BI.contentFormat = function (cv, fmt) { - if (isEmpty(cv)) { - //原值为空,返回空字符 - return ''; - } - var text = cv.toString(); - if (isEmpty(fmt)) { - //格式为空,返回原字符 - return text; - } - if (fmt.match(/^T/)) { - //T - 文本格式 - return text; - } else if (fmt.match(/^D/)) { - //D - 日期(时间)格式 - if (!(cv instanceof Date)) { - if (typeof cv === 'number') { - //毫秒数类型 - cv = new Date(cv); - } else { - //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); - } + left = left.replace(/^[0]+/, ''); + if (right < 0 && eright.indexOf('-') < 0) { + eright += ';-' + eright; } - if (!BI.isNull(cv)) { - var needTrim = fmt.match(/^DT/); - text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); + if (isNegative) { + text = '-' + text; } - } else if (fmt.match(/E/)) { - //科学计数格式 - text = BI._eFormat(text, fmt); - } else { - //数字格式 - text = BI._numberFormat(text, fmt); } - //¤ - 货币格式 - text = text.replace(/¤/g, '¥'); return text; - }; + } /** * 把日期对象按照指定格式转化成字符串 @@ -3373,7 +3083,7 @@ if (!window.BI) { * @param format 日期格式 * @returns {String} */ - date2Str = function (date, format) { + function date2Str(date, format) { if (!date) { return ''; } @@ -3482,15 +3192,15 @@ if (!window.BI) { /** * 数字格式 */ - BI._numberFormat = function (text, format) { + function _numberFormat(text, format) { var text = text + ''; //数字格式,区分正负数 var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), @@ -3504,7 +3214,7 @@ if (!window.BI) { tleft = tleft.replace(/^0+/gi, ''); tright = tright.substr(paddingZero.length).replace(/0+$/gi, ''); } - var right = BI._dealWithRight(tright, fright); + var right = _dealWithRight(tright, fright); if (right.leftPlus) { //小数点后有进位 tleft = parseInt(tleft) + 1 + ''; @@ -3512,7 +3222,7 @@ if (!window.BI) { tleft = isNaN(tleft) ? '1' : tleft; } right = right.num; - var left = BI._dealWithLeft(tleft, fleft); + var left = _dealWithLeft(tleft, fleft); if (!(/[0-9]/.test(left))) { left = left + '0'; } @@ -3529,7 +3239,7 @@ if (!window.BI) { * @returns {JSON} 返回处理结果和整数部分是否需要进位 * @private */ - BI._dealWithRight = function (tright, fright) { + function _dealWithRight(tright, fright) { var right = '', j = 0, i = 0; for (var len = fright.length; i < len; i++) { var ch = fright.charAt(i); @@ -3551,32 +3261,321 @@ if (!window.BI) { break; } } - var rll = tright.substr(j); - var result = {}; - if (!isEmpty(rll) && rll.charAt(0) > 4) { - //有多余字符,需要四舍五入 - result.leftPlus = true; - var numReg = right.match(/^[0-9]+/); - if (numReg) { - var num = numReg[0]; - var orilen = num.length; - var newnum = BI.parseINT(num) + 1 + ''; - //进位到整数部分 - if (newnum.length > orilen) { - newnum = newnum.substr(1); + var rll = tright.substr(j); + var result = {}; + if (!isEmpty(rll) && rll.charAt(0) > 4) { + //有多余字符,需要四舍五入 + result.leftPlus = true; + var numReg = right.match(/^[0-9]+/); + if (numReg) { + var num = numReg[0]; + var orilen = num.length; + var newnum = BI.parseInt(num) + 1 + ''; + //进位到整数部分 + if (newnum.length > orilen) { + newnum = newnum.substr(1); + } else { + newnum = BI.leftPad(newnum, orilen, '0'); + result.leftPlus = false; + } + right = right.replace(/^[0-9]+/, newnum); + } + } + result.num = right; + return result; + } + + /** + * 处理小数点左边整数部分 + * @param tleft 左边内容 + * @param fleft 左边格式 + * @returns {string} 返回处理结果 + * @private + */ + function _dealWithLeft(tleft, fleft) { + var left = ''; + var j = tleft.length - 1; + var combo = -1, last = -1; + var i = fleft.length - 1; + for (; i >= 0; i--) { + var ch = fleft.charAt(i); + var c = tleft.charAt(j); + switch (ch) { + case '0': + if (isEmpty(c)) { + c = '0'; + } + last = -1; + left = c + left; + j--; + break; + case '#': + last = i; + left = c + left; + j--; + break; + case ',': + if (!isEmpty(c)) { + //计算一个,分隔区间的长度 + var com = fleft.match(/,[#0]+/); + if (com) { + combo = com[0].length - 1; + } + left = ',' + left; + } + break; + default : + left = ch + left; + break; + } + } + if (last > -1) { + //处理剩余字符 + var tll = tleft.substr(0, j + 1); + left = left.substr(0, last) + tll + left.substr(last); + } + if (combo > 0) { + //处理,分隔区间 + var res = left.match(/[0-9]+,/); + if (res) { + res = res[0]; + var newstr = '', n = res.length - 1 - combo; + for (; n >= 0; n = n - combo) { + newstr = res.substr(n, combo) + ',' + newstr; + } + var lres = res.substr(0, n + combo); + if (!isEmpty(lres)) { + newstr = lres + ',' + newstr; + } + } + left = left.replace(/[0-9]+,/, newstr); + } + return left; + } + + BI.cjkEncode = function (text) { + // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) + if (typeof text !== 'string') { + return text; + } + + var newText = ""; + for (var i = 0; i < text.length; i++) { + var code = text.charCodeAt(i); + if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". + newText += "[" + code.toString(16) + "]"; + } else { + newText += text.charAt(i); + } + } + + return newText + }; + + BI.cjkEncodeDO = function (o) { + if (BI.isPlainObject(o)) { + var result = {}; + $.each(o, function (k, v) { + if (!(typeof v == "string")) { + v = BI.jsonEncode(v); + } + //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 + k = BI.cjkEncode(k); + result[k] = BI.cjkEncode(v); + }); + return result; + } + return o; + }; + + BI.jsonEncode = function (o) { + //james:这个Encode是抄的EXT的 + var useHasOwn = {}.hasOwnProperty ? true : false; + + // crashes Safari in some instances + //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; + + var m = { + "\b": '\\b', + "\t": '\\t', + "\n": '\\n', + "\f": '\\f', + "\r": '\\r', + '"': '\\"', + "\\": '\\\\' + }; + + var encodeString = function (s) { + if (/["\\\x00-\x1f]/.test(s)) { + return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { + var c = m[b]; + if (c) { + return c; + } + c = b.charCodeAt(); + return "\\u00" + + Math.floor(c / 16).toString(16) + + (c % 16).toString(16); + }) + '"'; + } + return '"' + s + '"'; + }; + + var encodeArray = function (o) { + var a = ["["], b, i, l = o.length, v; + for (i = 0; i < l; i += 1) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "function": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + a.push("]"); + return a.join(""); + }; + + if (typeof o == "undefined" || o === null) { + return "null"; + } else if (BI.isArray(o)) { + return encodeArray(o); + } else if (o instanceof Date) { + /* + * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode + * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 + */ + return BI.jsonEncode({ + __time__: o.getTime() + }) + } else if (typeof o == "string") { + return encodeString(o); + } else if (typeof o == "number") { + return isFinite(o) ? String(o) : "null"; + } else if (typeof o == "boolean") { + return String(o); + } else if (BI.isFunction(o)) { + return String(o); + } else { + var a = ["{"], b, i, v; + for (i in o) { + if (!useHasOwn || o.hasOwnProperty(i)) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(BI.jsonEncode(i), ":", + v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + } + a.push("}"); + return a.join(""); + } + }; + + BI.jsonDecode = function (text) { + + try { + // 注意0啊 + //var jo = $.parseJSON(text) || {}; + var jo = $.parseJSON(text); + if (jo == null) { + jo = {}; + } + } catch (e) { + /* + * richie:浏览器只支持标准的JSON字符串转换,而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析 + * 比如:var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常 + */ + try { + jo = new Function("return " + text)() || {}; + } catch (e) { + //do nothing + } + if (jo == null) { + jo = []; + } + } + if (!_hasDateInJson(text)) { + return jo; + } + + function _hasDateInJson(json) { + if (!json || typeof json !== "string") { + return false; + } + return json.indexOf("__time__") != -1; + } + + return (function (o) { + if (typeof o === "string") { + return o; + } + if (o && o.__time__ != null) { + return new Date(o.__time__); + } + for (var a in o) { + if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) { + break; + } + o[a] = arguments.callee(o[a]); + } + + return o; + })(jo); + } + + BI.contentFormat = function (cv, fmt) { + if (isEmpty(cv)) { + //原值为空,返回空字符 + return ''; + } + var text = cv.toString(); + if (isEmpty(fmt)) { + //格式为空,返回原字符 + return text; + } + if (fmt.match(/^T/)) { + //T - 文本格式 + return text; + } else if (fmt.match(/^D/)) { + //D - 日期(时间)格式 + if (!(cv instanceof Date)) { + if (typeof cv === 'number') { + //毫秒数类型 + cv = new Date(cv); } else { - newnum = BI.leftPad(newnum, orilen, '0'); - result.leftPlus = false; + //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 + cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); } - right = right.replace(/^[0-9]+/, newnum); } + if (!BI.isNull(cv)) { + var needTrim = fmt.match(/^DT/); + text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + } + } else if (fmt.match(/E/)) { + //科学计数格式 + text = _eFormat(text, fmt); + } else { + //数字格式 + text = _numberFormat(text, fmt); } - result.num = right; - return result; - }; - - BI.parseINT = function (str) { - return parseInt(str, 10); + //¤ - 货币格式 + text = text.replace(/¤/g, '¥'); + return text; }; BI.leftPad = function (val, size, ch) { @@ -3590,74 +3589,6 @@ if (!window.BI) { return result.toString(); }; - /** - * 处理小数点左边整数部分 - * @param tleft 左边内容 - * @param fleft 左边格式 - * @returns {string} 返回处理结果 - * @private - */ - BI._dealWithLeft = function (tleft, fleft) { - var left = ''; - var j = tleft.length - 1; - var combo = -1, last = -1; - var i = fleft.length - 1; - for (; i >= 0; i--) { - var ch = fleft.charAt(i); - var c = tleft.charAt(j); - switch (ch) { - case '0': - if (isEmpty(c)) { - c = '0'; - } - last = -1; - left = c + left; - j--; - break; - case '#': - last = i; - left = c + left; - j--; - break; - case ',': - if (!isEmpty(c)) { - //计算一个,分隔区间的长度 - var com = fleft.match(/,[#0]+/); - if (com) { - combo = com[0].length - 1; - } - left = ',' + left; - } - break; - default : - left = ch + left; - break; - } - } - if (last > -1) { - //处理剩余字符 - var tll = tleft.substr(0, j + 1); - left = left.substr(0, last) + tll + left.substr(last); - } - if (combo > 0) { - //处理,分隔区间 - var res = left.match(/[0-9]+,/); - if (res) { - res = res[0]; - var newstr = '', n = res.length - 1 - combo; - for (; n >= 0; n = n - combo) { - newstr = res.substr(n, combo) + ',' + newstr; - } - var lres = res.substr(0, n + combo); - if (!isEmpty(lres)) { - newstr = lres + ',' + newstr; - } - } - left = left.replace(/[0-9]+,/, newstr); - } - return left; - }; - BI.object2Number = function (value) { if (value == null) { return 0; @@ -3686,7 +3617,7 @@ if (!window.BI) { var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } @@ -3694,10 +3625,6 @@ if (!window.BI) { } }; - BI.isArray = function (a) { - return Object.prototype.toString.call(a) == '[object Array]'; - }; - BI.object2Time = function (obj) { if (obj == null) { return new Date(); @@ -3708,77 +3635,22 @@ if (!window.BI) { var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) { dt = new Date("1970/01/01 " + str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } } dt = BI.str2Date(str, "HH:mm:ss"); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } return new Date(); } }; - -// 判断是否是无效的日期 - BI.isInvalidDate = function (date) { - return date == "Invalid Date" || date == "NaN"; - }; - - - /** - * 科学计数格式 - */ - BI._eFormat = function (text, fmt) { - var e = fmt.indexOf("E"); - var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); - if (/^[0\.-]+$/.test(text)) { - text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) - } else { - var isNegative = text < 0; - if (isNegative) { - text = text.substr(1); - } - var elvl = (eleft.split('.')[0] || '').length; - var point = text.indexOf("."); - if (point < 0) { - point = text.length; - } - var i = 0; //第一个不为0的数的位置 - text = text.replace('.', ''); - for (var len = text.length; i < len; i++) { - var ech = text.charAt(i); - if (ech <= '9' && ech >= '1') { - break; - } - } - var right = point - i - elvl; - var left = text.substr(i, elvl); - var dis = i + elvl - text.length; - if (dis > 0) { - //末位补全0 - for (var k = 0; k < dis; k++) { - left += '0'; - } - } else { - left += '.' + text.substr(i + elvl); - } - left = left.replace(/^[0]+/, ''); - if (right < 0 && eright.indexOf('-') < 0) { - eright += ';-' + eright; - } - text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); - if (isNegative) { - text = '-' + text; - } - } - return text; - }; })(); /** * 事件集合 @@ -4458,7 +4330,8 @@ BI.Widget = BI.inherit(BI.OB, { mounted: null, - update: null, + update: function () { + }, destroyed: null, @@ -4682,7 +4555,7 @@ BI.Widget = BI.inherit(BI.OB, { } widget._setParent && widget._setParent(this); widget.on(BI.Events.DESTROY, function () { - delete self._children[name] + BI.remove(self._children, this); }); return (this._children[name] = widget); }, @@ -4711,11 +4584,7 @@ BI.Widget = BI.inherit(BI.OB, { removeWidget: function (nameOrWidget) { var self = this; if (BI.isWidget(nameOrWidget)) { - BI.each(this._children, function (name, widget) { - if (widget === nameOrWidget) { - delete self._children[name]; - } - }) + BI.remove(this._children, nameOrWidget); } else { delete this._children[nameOrWidget]; } @@ -4795,8 +4664,8 @@ BI.Widget = BI.inherit(BI.OB, { isolate: function () { if (this._parent) { this._parent.removeWidget(this); - BI.DOM.hang([this]); } + BI.DOM.hang([this]); }, empty: function () { @@ -5607,7 +5476,7 @@ BI.View = BI.inherit(BI.V, { } //采用静默方式读数据,该数据变化不引起data的change事件触发 var success = options.success; - this.read(BI.extend({ + this.model.read(BI.extend({ silent: true }, options, { success: function (data, model) { @@ -5649,22 +5518,10 @@ BI.View = BI.inherit(BI.V, { return this.model.getEditing(); }, - read: function (options) { - this.model.read(options) - }, - - update: function (options) { - this.model.update(options); - }, - - patch: function (options) { - this.model.patch(options); - }, - reading: function (options) { var self = this; var name = BI.UUID(); - this.read(BI.extend({}, options, { + this.model.read(BI.extend({}, options, { beforeSend: function () { var loading = BI.createWidget({ type: 'bi.vertical', @@ -5687,7 +5544,7 @@ BI.View = BI.inherit(BI.V, { updating: function (options) { var self = this; var name = BI.UUID(); - this.update(BI.extend({}, options, { + this.model.update(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ @@ -5711,7 +5568,7 @@ BI.View = BI.inherit(BI.V, { patching: function (options) { var self = this; var name = BI.UUID(); - this.patch(BI.extend({}, options, { + this.model.patch(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ @@ -6317,56 +6174,56 @@ BI.Cache = { document.cookie = cookieString; } };// full day names -Date._DN = [BI.i18nText("BI-Sunday"), - BI.i18nText("BI-Monday"), - BI.i18nText("BI-Tuesday"), - BI.i18nText("BI-Wednesday"), - BI.i18nText("BI-Thursday"), - BI.i18nText("BI-Friday"), - BI.i18nText("BI-Saturday"), - BI.i18nText("BI-Sunday")]; +Date._DN = [BI.i18nText("BI-Basic_Sunday"), + BI.i18nText("BI-Basic_Monday"), + BI.i18nText("BI-Basic_Tuesday"), + BI.i18nText("BI-Basic_Wednesday"), + BI.i18nText("BI-Basic_Thursday"), + BI.i18nText("BI-Basic_Friday"), + BI.i18nText("BI-Basic_Saturday"), + BI.i18nText("BI-Basic_Sunday")]; // short day names -Date._SDN = ['', - '', - '', - '', - '', - '', - '', - '']; +Date._SDN = [BI.i18nText("BI-Day_Ri"), + BI.i18nText("BI-Basic_One"), + BI.i18nText("BI-Basic_Two"), + BI.i18nText("BI-Basic_Three"), + BI.i18nText("BI-Basic_Four"), + BI.i18nText("BI-Basic_Five"), + BI.i18nText("BI-Basic_Six"), + BI.i18nText("BI-Day_Ri")]; // Monday first, etc. Date._FD = 1; // full month names Date._MN = [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; + BI.i18nText("BI-Basic_January"), + BI.i18nText("BI-Basic_February"), + BI.i18nText("BI-Basic_March"), + BI.i18nText("BI-Basic_April"), + BI.i18nText("BI-Basic_May"), + BI.i18nText("BI-Basic_June"), + BI.i18nText("BI-Basic_July"), + BI.i18nText("BI-Basic_August"), + BI.i18nText("BI-Basic_September"), + BI.i18nText("BI-Basic_October"), + BI.i18nText("BI-Basic_November"), + BI.i18nText("BI-Basic_December")]; // short month names -Date._SMN = ['', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; +Date._SMN = [0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11]; Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_2"), @@ -11273,6 +11130,7 @@ BI.Layout = BI.inherit(BI.Widget, { w.on(BI.Events.DESTROY, function () { BI.each(self._children, function (name, child) { if (child === w) { + BI.remove(self._children, child); self.removeItemAt(name | 0); } }); @@ -11419,13 +11277,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + child && deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { @@ -11434,9 +11303,9 @@ BI.Layout = BI.inherit(BI.Widget, { } var child = this._children[this._getChildName(index)]; - if (child.update) { - child.update(this._getOptions(item)); - return true; + var updated; + if (updated = child.update(this._getOptions(item))) { + return updated; } var del = this._children[this._getChildName(index)]; delete this._children[this._getChildName(index)]; @@ -11490,33 +11359,39 @@ BI.Layout = BI.inherit(BI.Widget, { }, getValue: function () { - var self = this, value = []; + var self = this, value = [], child; BI.each(this.options.items, function (i) { - var v = self._children[self._getChildName(i)].getValue(); - v = BI.isArray(v) ? v : [v]; - value = value.concat(v); + if (child = self._children[self._getChildName(i)]) { + var v = child.getValue(); + v = BI.isArray(v) ? v : [v]; + value = value.concat(v); + } }); return value; }, setValue: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setValue(v); + if (child = self._children[self._getChildName(i)]) { + child.setValue(v); + } }) }, setText: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setText(v); + if (child = self._children[self._getChildName(i)]) { + child.setText(v); + } }) }, update: function (item) { var o = this.options; - var items = item.items; - var updated = false, i, len; + var items = item.items || []; + var updated, i, len; for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) { if (!this._compare(o.items[i], items[i])) { updated = this.updateItemAt(i, items[i]) || updated; @@ -11526,7 +11401,9 @@ BI.Layout = BI.inherit(BI.Widget, { var deleted = []; for (i = items.length; i < o.items.length; i++) { deleted.push(this._children[this._getChildName(i)]); + delete this._children[this._getChildName(i)]; } + o.items.splice(items.length); BI.each(deleted, function (i, w) { w.destroy(); }) @@ -11535,7 +11412,6 @@ BI.Layout = BI.inherit(BI.Widget, { this.addItemAt(i, items[i]); } } - this.options.items = items; return updated; }, @@ -11569,6 +11445,11 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = []; }, + destroy: function () { + BI.Layout.superclass.destroy.apply(this, arguments); + this.options.items = []; + }, + populate: function (items) { var self = this, o = this.options; items = items || []; @@ -13360,7 +13241,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { if (!self.hasWidget(item.cardName)) { var w = BI.createWidget(item); w.on(BI.Events.DESTROY, function () { - var index = BI.findKey(o.items, function (i, tItem) { + var index = BI.findIndex(o.items, function (i, tItem) { return tItem.cardName == item.cardName; }); if (index > -1) { @@ -13404,17 +13285,23 @@ BI.CardLayout = BI.inherit(BI.Layout, { return this._children[cardName]; }, - deleteCardByName: function (cardName) { - if (!this.isCardExisted(cardName)) { - throw new Error("cardName is not exist"); - } - var index = BI.findKey(this.options.items, function (i, item) { + _deleteCardByName: function (cardName) { + delete this._children[cardName]; + var index = BI.findIndex(this.options.items, function (i, item) { return item.cardName == cardName; }); if (index > -1) { this.options.items.splice(index, 1); } + }, + + deleteCardByName: function (cardName) { + if (!this.isCardExisted(cardName)) { + throw new Error("cardName is not exist"); + } + var child = this._children[cardName]; + this._deleteCardByName(cardName); child && child.destroy(); }, @@ -13447,11 +13334,13 @@ BI.CardLayout = BI.inherit(BI.Layout, { var flag = false; BI.each(this.options.items, function (i, item) { var el = self._children[item.cardName]; - if (name != item.cardName) { - //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 - !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); - } else { - (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + if (el) { + if (name != item.cardName) { + //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 + !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); + } else { + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + } } }); }, @@ -13510,6 +13399,22 @@ BI.CardLayout = BI.inherit(BI.Layout, { } }); return flag; + }, + + removeWidget: function (nameOrWidget) { + var removeName; + if (BI.isWidget(nameOrWidget)) { + BI.each(this._children, function (name, child) { + if (child === nameOrWidget) { + removeName = name; + } + }) + } else { + removeName = nameOrWidget; + } + if (removeName) { + this._deleteCardByName(removeName); + } } }); BI.shortcut('bi.card', BI.CardLayout);/** @@ -15463,7 +15368,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -15477,6 +15382,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } @@ -15779,28 +15687,30 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - var container = this.floatContainer[name]; - container.element.css("zIndex", this.zindex++); - this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); - this.zindexMap[name] = this.zindex; - this.modal && container.element.__buildZIndexMask__(this.zindex++); - this.get(name).setZindex(this.zindex++); - this.floatContainer[name].visible(); - var floatbox = this.get(name); - floatbox.show(); - var W = $(this.options.render).width(), H = $(this.options.render).height(); - var w = floatbox.element.width(), h = floatbox.element.height(); - var left = (W - w) / 2, top = (H - h) / 2; - if (left < 0) { - left = 0; - } - if (top < 0) { - top = 0; + if (!this.floatContainer[name].isVisible()) { + var container = this.floatContainer[name]; + container.element.css("zIndex", this.zindex++); + this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); + this.zindexMap[name] = this.zindex; + this.modal && container.element.__buildZIndexMask__(this.zindex++); + this.get(name).setZindex(this.zindex++); + this.floatContainer[name].visible(); + var floatbox = this.get(name); + floatbox.show(); + var W = $(this.options.render).width(), H = $(this.options.render).height(); + var w = floatbox.element.width(), h = floatbox.element.height(); + var left = (W - w) / 2, top = (H - h) / 2; + if (left < 0) { + left = 0; + } + if (top < 0) { + top = 0; + } + floatbox.element.css({ + left: left + "px", + top: top + "px" + }); } - floatbox.element.css({ - left: left + "px", - top: top + "px" - }); return this; }, @@ -15808,8 +15718,10 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - this.floatContainer[name].invisible(); - this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + if (this.floatContainer[name].isVisible()) { + this.floatContainer[name].invisible(); + this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + } return this; }, @@ -16059,11 +15971,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) { diff --git a/bi/widget.css b/bi/widget.css index 51d0750008..39a07dbd61 100644 --- a/bi/widget.css +++ b/bi/widget.css @@ -233,11 +233,13 @@ } .bi-fine-tuning-number-editor .top-button { border-left: 1px solid #d4dadd; - border-bottom: 1px solid #d4dadd; } .bi-fine-tuning-number-editor .bottom-button { border-left: 1px solid #d4dadd; } +.bi-fine-tuning-number-editor .split-line { + background-color: #d4dadd; +} /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ @@ -632,14 +634,6 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ -.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col, -.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col, -.bi-responsive-table > div > div > table > * > * > td.last-col { - min-width: 80px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ .bi-sequence-table-dynamic-number .sequence-table-title-cell { overflow: hidden; overflow-x: hidden; diff --git a/bi/widget.js b/bi/widget.js index fec31d1b5f..b375c5c3a6 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -4857,7 +4857,6 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge hgap: 4, vgap: 2, triggerWidth: 30, - watermark: BI.i18nText("BI-Unrestricted"), yearLength: 4, yearMonthLength: 7 }, @@ -4891,7 +4890,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge hgap: c.hgap, vgap: c.vgap, allowBlank: true, - watermark: c.watermark, + watermark: BI.i18nText("BI-Unrestricted"), errorText: function () { if (self.editor.isEditing()) { return BI.i18nText("BI-Date_Trigger_Error_Text"); @@ -6158,7 +6157,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, { return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-excel-table", el: { - type: "bi.adaptive_table" + type: "bi.responsive_table" }, isNeedResize: false, @@ -6192,8 +6191,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.table_view", element: this, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, isNeedFreeze: false, @@ -16791,7 +16788,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, { hgap: 4, vgap: 2, triggerWidth: 25, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") }, diff --git a/demo/js/core/abstract/demo.virtual_group.js b/demo/js/core/abstract/demo.virtual_group.js index c933aa7b62..eb75071389 100644 --- a/demo/js/core/abstract/demo.virtual_group.js +++ b/demo/js/core/abstract/demo.virtual_group.js @@ -66,6 +66,7 @@ Demo.Item = BI.inherit(BI.Widget, { update: function (item) { this.label.setText(item.value); console.log("更新了一项"); + return true; }, created: function () { diff --git a/demo/version.js b/demo/version.js index 51c96d1785..5e16777ec5 100644 --- a/demo/version.js +++ b/demo/version.js @@ -4,4 +4,8 @@ Demo = { BI.i18n = { "BI-Basic_OK": "确定" -}; \ No newline at end of file +}; + +BI.servletURL = "dist/"; +BI.resourceURL = "dist/resource/"; +BI.i18n = {}; \ No newline at end of file diff --git a/dist/base.css b/dist/base.css index a97667728a..d9a49fee4a 100644 --- a/dist/base.css +++ b/dist/base.css @@ -1035,7 +1035,7 @@ li.CodeMirror-hint-active { overflow-x: hidden; overflow-y: hidden; white-space: nowrap; - word-break: break-all; + word-break: break-word; } /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ @@ -1197,9 +1197,6 @@ li.CodeMirror-hint-active { .bi-grid-table-cell.first-col { border-left: 1px solid #eaeaea; } -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ .scrollbar-layout-main { box-sizing: border-box; outline: none; diff --git a/dist/base.js b/dist/base.js index 2d39187d1d..41d9f2b6f2 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { self.setValue([]); break; } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); + } else { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); btn.on(BI.Events.DESTROY, function () { BI.remove(self.buttons, btn); @@ -1118,9 +1120,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { @@ -2354,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController(); BI.Tooltips = new BI.TooltipsController(); BI.Popovers = new BI.FloatBoxController(); BI.Broadcasts = new BI.BroadcastController(); -BI.StyleLoaders = new BI.StyleLoaderManager(); - -BI.servletURL = "dist/"; -BI.resourceURL = "dist/resource/"; -BI.i18n = {};/** +BI.StyleLoaders = new BI.StyleLoaderManager();/** * canvas绘图 * * Created by GUY on 2015/11/18. @@ -3609,18 +3619,30 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); + }, + + empty: function () { + this.layouts.empty(); }, populate: function (items) { var self = this; items = items || []; this.options.items = items; - items = this._packageItems(items, this._packageBtns(items)); + items = this._packageBtns(items); if (!this.layouts) { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); } else { - this.layouts.populate(this._packageLayout(items).items); + this.layouts.populate(items); } } }); @@ -18237,7 +18259,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, false ); - xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true); + xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true); if (!xhr.upload) { var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true}; rpe.interval = setInterval(function () { @@ -18686,7 +18708,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); + BI.File.superclass.setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { diff --git a/dist/case.js b/dist/case.js index e4215d7248..af310f6c84 100644 --- a/dist/case.js +++ b/dist/case.js @@ -8520,7 +8520,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, { hgap: 4, vgap: 0, value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), width: 30, height: 20 }); diff --git a/dist/core.js b/dist/core.js index 18bd9eefae..9c8a9f4bfe 100644 --- a/dist/core.js +++ b/dist/core.js @@ -13052,7 +13052,7 @@ if (!window.BI) { }, formatEL: function (obj) { - if (obj && obj.el) { + if (obj && !obj.type && obj.el) { return obj; } return { @@ -13987,100 +13987,24 @@ if (!window.BI) { //encode encodeBIParam(option.data); - var async = true; - if (BI.isNotNull(option.async)) { - async = option.async; - } - - if (BI.isNull(loading)) { - loading = BI.createWidget({ - type: "bi.request_loading" - }); - } + var async = option.async; - if (BI.isNull(timeoutToast)) { - timeoutToast = BI.createWidget({ - type: "bi.timeout_toast" - }); - timeoutToast.setCallback(function (op) { - decodeBIParam(op.data); - BI.ajax(op); - }); - } - timeoutToast.addReq(option); + option.data = BI.cjkEncodeDO(option.data); - option.data = BI.cjkEncodeDO(option.data); - - - $.ajax({ url: option.url, type: "POST", data: option.data, async: async, - error: function () { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //失败 取消、重新加载 - loading.setCallback(function () { - decodeBIParam(option.data); - BI.ajax(option); - }); - loading.showError(); - }, + error: option.error, complete: function (res, status) { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //登录超时 - if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("fs-login-content") > -1 && - res.responseText.indexOf("fs-login-input-password-confirm") === -1) { - if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) { - return; - } - if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) { - BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID); - return; - } - var loginTimeout = BI.createWidget({ - type: "bi.login_timeout" - }); - loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () { - decodeBIParam(option.data); - BI.ajax(option); - BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID); - }); - BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, { - width: 600, - height: 400 - }).open(BI.LoginTimeOut.POPOVER_ID); - } else if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("script") > -1 && - res.responseText.indexOf("Session Timeout...") > -1) { - //登录失效 - loading.setCallback(function () { - location.reload(); - }); - loading.showError(); - - } else if (status === "success" && BI.isFunction(option.success)) { - option.success(BI.jsonDecode(res.responseText)); - } if (BI.isFunction(option.complete)) { option.complete(BI.jsonDecode(res.responseText), status); } } }); - return function cancel() { - timeoutToast.removeReq(option); - }; - function encodeBIParam(data) { for (var key in data) { if (_.isObject(data[key])) { @@ -14100,102 +14024,7 @@ if (!window.BI) { } } } - })(), - - /** - * 异步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参数 - * @param {Function} callback 回调函数 - * @param {Function} complete 回调 - */ - requestAsync: function (op, cmd, data, callback, complete) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi" || op === "fr_bi_configure") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - return (BI.ajax)({ - url: url, - type: 'POST', - data: data, - error: function () { - // BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - success: function (res) { - if (BI.isFunction(callback)) { - callback(res); - } - }, - complete: function (res, status) { - if (BI.isFunction(complete)) { - complete(res); - } - } - }); - }, - - /** - * 同步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参�? - * @returns {Object} ajax同步请求返回的JSON对象 - */ - requestSync: function (op, cmd, data) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - var result = {}; - (BI.ajax)({ - url: url, - type: 'POST', - async: false, - data: data, - error: function () { - BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - complete: function (res, status) { - if (status === 'success') { - result = res; - } - } - }); - return result; - }, - - /** - * 请求方法 - * @param cmd 命令 - * @param data 数据 - * @param extend 参数 - * @returns {*} - */ - request: function (cmd, data, extend) { - extend = extend || {}; - data = data || {}; - var op = extend.op; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - if (extend.async === true) { - BI.requestAsync(op, cmd, data, extend.complete || extend.success); - } else { - return BI.requestSync(op, cmd, data); - } - } + })() }); })(jQuery);/** * 客户端观察者,主要处理事件的添加、删除、执行等 @@ -14370,7 +14199,8 @@ BI.Widget = BI.inherit(BI.OB, { mounted: null, - update: null, + update: function () { + }, destroyed: null, @@ -14594,7 +14424,7 @@ BI.Widget = BI.inherit(BI.OB, { } widget._setParent && widget._setParent(this); widget.on(BI.Events.DESTROY, function () { - delete self._children[name] + BI.remove(self._children, this); }); return (this._children[name] = widget); }, @@ -14623,11 +14453,7 @@ BI.Widget = BI.inherit(BI.OB, { removeWidget: function (nameOrWidget) { var self = this; if (BI.isWidget(nameOrWidget)) { - BI.each(this._children, function (name, widget) { - if (widget === nameOrWidget) { - delete self._children[name]; - } - }) + BI.remove(this._children, nameOrWidget); } else { delete this._children[nameOrWidget]; } @@ -14707,8 +14533,8 @@ BI.Widget = BI.inherit(BI.OB, { isolate: function () { if (this._parent) { this._parent.removeWidget(this); - BI.DOM.hang([this]); } + BI.DOM.hang([this]); }, empty: function () { @@ -15519,7 +15345,7 @@ BI.View = BI.inherit(BI.V, { } //采用静默方式读数据,该数据变化不引起data的change事件触发 var success = options.success; - this.read(BI.extend({ + this.model.read(BI.extend({ silent: true }, options, { success: function (data, model) { @@ -15561,22 +15387,10 @@ BI.View = BI.inherit(BI.V, { return this.model.getEditing(); }, - read: function (options) { - this.model.read(options) - }, - - update: function (options) { - this.model.update(options); - }, - - patch: function (options) { - this.model.patch(options); - }, - reading: function (options) { var self = this; var name = BI.UUID(); - this.read(BI.extend({}, options, { + this.model.read(BI.extend({}, options, { beforeSend: function () { var loading = BI.createWidget({ type: 'bi.vertical', @@ -15599,7 +15413,7 @@ BI.View = BI.inherit(BI.V, { updating: function (options) { var self = this; var name = BI.UUID(); - this.update(BI.extend({}, options, { + this.model.update(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ @@ -15623,7 +15437,7 @@ BI.View = BI.inherit(BI.V, { patching: function (options) { var self = this; var name = BI.UUID(); - this.patch(BI.extend({}, options, { + this.model.patch(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ @@ -19406,6 +19220,7 @@ BI.Layout = BI.inherit(BI.Widget, { w.on(BI.Events.DESTROY, function () { BI.each(self._children, function (name, child) { if (child === w) { + BI.remove(self._children, child); self.removeItemAt(name | 0); } }); @@ -19552,13 +19367,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + child && deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { @@ -19567,9 +19393,9 @@ BI.Layout = BI.inherit(BI.Widget, { } var child = this._children[this._getChildName(index)]; - if (child.update) { - child.update(this._getOptions(item)); - return true; + var updated; + if (updated = child.update(this._getOptions(item))) { + return updated; } var del = this._children[this._getChildName(index)]; delete this._children[this._getChildName(index)]; @@ -19623,33 +19449,39 @@ BI.Layout = BI.inherit(BI.Widget, { }, getValue: function () { - var self = this, value = []; + var self = this, value = [], child; BI.each(this.options.items, function (i) { - var v = self._children[self._getChildName(i)].getValue(); - v = BI.isArray(v) ? v : [v]; - value = value.concat(v); + if (child = self._children[self._getChildName(i)]) { + var v = child.getValue(); + v = BI.isArray(v) ? v : [v]; + value = value.concat(v); + } }); return value; }, setValue: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setValue(v); + if (child = self._children[self._getChildName(i)]) { + child.setValue(v); + } }) }, setText: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setText(v); + if (child = self._children[self._getChildName(i)]) { + child.setText(v); + } }) }, update: function (item) { var o = this.options; - var items = item.items; - var updated = false, i, len; + var items = item.items || []; + var updated, i, len; for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) { if (!this._compare(o.items[i], items[i])) { updated = this.updateItemAt(i, items[i]) || updated; @@ -19659,7 +19491,9 @@ BI.Layout = BI.inherit(BI.Widget, { var deleted = []; for (i = items.length; i < o.items.length; i++) { deleted.push(this._children[this._getChildName(i)]); + delete this._children[this._getChildName(i)]; } + o.items.splice(items.length); BI.each(deleted, function (i, w) { w.destroy(); }) @@ -19668,7 +19502,6 @@ BI.Layout = BI.inherit(BI.Widget, { this.addItemAt(i, items[i]); } } - this.options.items = items; return updated; }, @@ -19702,6 +19535,11 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = []; }, + destroy: function () { + BI.Layout.superclass.destroy.apply(this, arguments); + this.options.items = []; + }, + populate: function (items) { var self = this, o = this.options; items = items || []; @@ -19857,178 +19695,59 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { return result; } - BI.cjkEncode = function (text) { - // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) - if (typeof text !== 'string') { - return text; - } + // 判断是否是无效的日期 + function isInvalidDate(date) { + return date == "Invalid Date" || date == "NaN"; + } - var newText = ""; - for (var i = 0; i < text.length; i++) { - var code = text.charCodeAt(i); - if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". - newText += "[" + code.toString(16) + "]"; - } else { - newText += text.charAt(i); + /** + * 科学计数格式 + */ + function _eFormat(text, fmt) { + var e = fmt.indexOf("E"); + var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); + if (/^[0\.-]+$/.test(text)) { + text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) + } else { + var isNegative = text < 0; + if (isNegative) { + text = text.substr(1); } - } - - return newText - }; - - BI.cjkEncodeDO = function (o) { - if (BI.isPlainObject(o)) { - var result = {}; - $.each(o, function (k, v) { - if (!(typeof v == "string")) { - v = BI.jsonEncode(v); - } - //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 - k = BI.cjkEncode(k); - result[k] = BI.cjkEncode(v); - }); - return result; - } - return o; - }; - - BI.jsonEncode = function (o) { - //james:这个Encode是抄的EXT的 - var useHasOwn = {}.hasOwnProperty ? true : false; - - // crashes Safari in some instances - //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; - - var m = { - "\b": '\\b', - "\t": '\\t', - "\n": '\\n', - "\f": '\\f', - "\r": '\\r', - '"': '\\"', - "\\": '\\\\' - }; - - var encodeString = function (s) { - if (/["\\\x00-\x1f]/.test(s)) { - return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { - var c = m[b]; - if (c) { - return c; - } - c = b.charCodeAt(); - return "\\u00" + - Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"'; + var elvl = (eleft.split('.')[0] || '').length; + var point = text.indexOf("."); + if (point < 0) { + point = text.length; } - return '"' + s + '"'; - }; - - var encodeArray = function (o) { - var a = ["["], b, i, l = o.length, v; - for (i = 0; i < l; i += 1) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "function": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(v === null ? "null" : BI.jsonEncode(v)); - b = true; + var i = 0; //第一个不为0的数的位置 + text = text.replace('.', ''); + for (var len = text.length; i < len; i++) { + var ech = text.charAt(i); + if (ech <= '9' && ech >= '1') { + break; } } - a.push("]"); - return a.join(""); - }; - - if (typeof o == "undefined" || o === null) { - return "null"; - } else if (BI.isArray(o)) { - return encodeArray(o); - } else if (o instanceof Date) { - /* - * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode - * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 - */ - return BI.jsonEncode({ - __time__: o.getTime() - }) - } else if (typeof o == "string") { - return encodeString(o); - } else if (typeof o == "number") { - return isFinite(o) ? String(o) : "null"; - } else if (typeof o == "boolean") { - return String(o); - } else if (BI.isFunction(o)) { - return String(o); - } else { - var a = ["{"], b, i, v; - for (i in o) { - if (!useHasOwn || o.hasOwnProperty(i)) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(BI.jsonEncode(i), ":", - v === null ? "null" : BI.jsonEncode(v)); - b = true; - } + var right = point - i - elvl; + var left = text.substr(i, elvl); + var dis = i + elvl - text.length; + if (dis > 0) { + //末位补全0 + for (var k = 0; k < dis; k++) { + left += '0'; } + } else { + left += '.' + text.substr(i + elvl); } - a.push("}"); - return a.join(""); - } - }; - - BI.contentFormat = function (cv, fmt) { - if (isEmpty(cv)) { - //原值为空,返回空字符 - return ''; - } - var text = cv.toString(); - if (isEmpty(fmt)) { - //格式为空,返回原字符 - return text; - } - if (fmt.match(/^T/)) { - //T - 文本格式 - return text; - } else if (fmt.match(/^D/)) { - //D - 日期(时间)格式 - if (!(cv instanceof Date)) { - if (typeof cv === 'number') { - //毫秒数类型 - cv = new Date(cv); - } else { - //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); - } + left = left.replace(/^[0]+/, ''); + if (right < 0 && eright.indexOf('-') < 0) { + eright += ';-' + eright; } - if (!BI.isNull(cv)) { - var needTrim = fmt.match(/^DT/); - text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); + if (isNegative) { + text = '-' + text; } - } else if (fmt.match(/E/)) { - //科学计数格式 - text = BI._eFormat(text, fmt); - } else { - //数字格式 - text = BI._numberFormat(text, fmt); } - //¤ - 货币格式 - text = text.replace(/¤/g, '¥'); return text; - }; + } /** * 把日期对象按照指定格式转化成字符串 @@ -20042,7 +19761,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { * @param format 日期格式 * @returns {String} */ - date2Str = function (date, format) { + function date2Str(date, format) { if (!date) { return ''; } @@ -20151,15 +19870,15 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { /** * 数字格式 */ - BI._numberFormat = function (text, format) { + function _numberFormat(text, format) { var text = text + ''; //数字格式,区分正负数 var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), @@ -20173,7 +19892,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { tleft = tleft.replace(/^0+/gi, ''); tright = tright.substr(paddingZero.length).replace(/0+$/gi, ''); } - var right = BI._dealWithRight(tright, fright); + var right = _dealWithRight(tright, fright); if (right.leftPlus) { //小数点后有进位 tleft = parseInt(tleft) + 1 + ''; @@ -20181,7 +19900,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { tleft = isNaN(tleft) ? '1' : tleft; } right = right.num; - var left = BI._dealWithLeft(tleft, fleft); + var left = _dealWithLeft(tleft, fleft); if (!(/[0-9]/.test(left))) { left = left + '0'; } @@ -20198,7 +19917,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { * @returns {JSON} 返回处理结果和整数部分是否需要进位 * @private */ - BI._dealWithRight = function (tright, fright) { + function _dealWithRight(tright, fright) { var right = '', j = 0, i = 0; for (var len = fright.length; i < len; i++) { var ch = fright.charAt(i); @@ -20208,44 +19927,333 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { if (isEmpty(c)) { c = '0'; } - right += c; - j++; - break; - case '#': - right += c; - j++; - break; - default : - right += ch; + right += c; + j++; + break; + case '#': + right += c; + j++; + break; + default : + right += ch; + break; + } + } + var rll = tright.substr(j); + var result = {}; + if (!isEmpty(rll) && rll.charAt(0) > 4) { + //有多余字符,需要四舍五入 + result.leftPlus = true; + var numReg = right.match(/^[0-9]+/); + if (numReg) { + var num = numReg[0]; + var orilen = num.length; + var newnum = BI.parseInt(num) + 1 + ''; + //进位到整数部分 + if (newnum.length > orilen) { + newnum = newnum.substr(1); + } else { + newnum = BI.leftPad(newnum, orilen, '0'); + result.leftPlus = false; + } + right = right.replace(/^[0-9]+/, newnum); + } + } + result.num = right; + return result; + } + + /** + * 处理小数点左边整数部分 + * @param tleft 左边内容 + * @param fleft 左边格式 + * @returns {string} 返回处理结果 + * @private + */ + function _dealWithLeft(tleft, fleft) { + var left = ''; + var j = tleft.length - 1; + var combo = -1, last = -1; + var i = fleft.length - 1; + for (; i >= 0; i--) { + var ch = fleft.charAt(i); + var c = tleft.charAt(j); + switch (ch) { + case '0': + if (isEmpty(c)) { + c = '0'; + } + last = -1; + left = c + left; + j--; + break; + case '#': + last = i; + left = c + left; + j--; + break; + case ',': + if (!isEmpty(c)) { + //计算一个,分隔区间的长度 + var com = fleft.match(/,[#0]+/); + if (com) { + combo = com[0].length - 1; + } + left = ',' + left; + } + break; + default : + left = ch + left; + break; + } + } + if (last > -1) { + //处理剩余字符 + var tll = tleft.substr(0, j + 1); + left = left.substr(0, last) + tll + left.substr(last); + } + if (combo > 0) { + //处理,分隔区间 + var res = left.match(/[0-9]+,/); + if (res) { + res = res[0]; + var newstr = '', n = res.length - 1 - combo; + for (; n >= 0; n = n - combo) { + newstr = res.substr(n, combo) + ',' + newstr; + } + var lres = res.substr(0, n + combo); + if (!isEmpty(lres)) { + newstr = lres + ',' + newstr; + } + } + left = left.replace(/[0-9]+,/, newstr); + } + return left; + } + + BI.cjkEncode = function (text) { + // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) + if (typeof text !== 'string') { + return text; + } + + var newText = ""; + for (var i = 0; i < text.length; i++) { + var code = text.charCodeAt(i); + if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". + newText += "[" + code.toString(16) + "]"; + } else { + newText += text.charAt(i); + } + } + + return newText + }; + + BI.cjkEncodeDO = function (o) { + if (BI.isPlainObject(o)) { + var result = {}; + $.each(o, function (k, v) { + if (!(typeof v == "string")) { + v = BI.jsonEncode(v); + } + //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 + k = BI.cjkEncode(k); + result[k] = BI.cjkEncode(v); + }); + return result; + } + return o; + }; + + BI.jsonEncode = function (o) { + //james:这个Encode是抄的EXT的 + var useHasOwn = {}.hasOwnProperty ? true : false; + + // crashes Safari in some instances + //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; + + var m = { + "\b": '\\b', + "\t": '\\t', + "\n": '\\n', + "\f": '\\f', + "\r": '\\r', + '"': '\\"', + "\\": '\\\\' + }; + + var encodeString = function (s) { + if (/["\\\x00-\x1f]/.test(s)) { + return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { + var c = m[b]; + if (c) { + return c; + } + c = b.charCodeAt(); + return "\\u00" + + Math.floor(c / 16).toString(16) + + (c % 16).toString(16); + }) + '"'; + } + return '"' + s + '"'; + }; + + var encodeArray = function (o) { + var a = ["["], b, i, l = o.length, v; + for (i = 0; i < l; i += 1) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "function": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + a.push("]"); + return a.join(""); + }; + + if (typeof o == "undefined" || o === null) { + return "null"; + } else if (BI.isArray(o)) { + return encodeArray(o); + } else if (o instanceof Date) { + /* + * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode + * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 + */ + return BI.jsonEncode({ + __time__: o.getTime() + }) + } else if (typeof o == "string") { + return encodeString(o); + } else if (typeof o == "number") { + return isFinite(o) ? String(o) : "null"; + } else if (typeof o == "boolean") { + return String(o); + } else if (BI.isFunction(o)) { + return String(o); + } else { + var a = ["{"], b, i, v; + for (i in o) { + if (!useHasOwn || o.hasOwnProperty(i)) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(BI.jsonEncode(i), ":", + v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + } + a.push("}"); + return a.join(""); + } + }; + + BI.jsonDecode = function (text) { + + try { + // 注意0啊 + //var jo = $.parseJSON(text) || {}; + var jo = $.parseJSON(text); + if (jo == null) { + jo = {}; + } + } catch (e) { + /* + * richie:浏览器只支持标准的JSON字符串转换,而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析 + * 比如:var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常 + */ + try { + jo = new Function("return " + text)() || {}; + } catch (e) { + //do nothing + } + if (jo == null) { + jo = []; + } + } + if (!_hasDateInJson(text)) { + return jo; + } + + function _hasDateInJson(json) { + if (!json || typeof json !== "string") { + return false; + } + return json.indexOf("__time__") != -1; + } + + return (function (o) { + if (typeof o === "string") { + return o; + } + if (o && o.__time__ != null) { + return new Date(o.__time__); + } + for (var a in o) { + if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) { break; + } + o[a] = arguments.callee(o[a]); } + + return o; + })(jo); + } + + BI.contentFormat = function (cv, fmt) { + if (isEmpty(cv)) { + //原值为空,返回空字符 + return ''; } - var rll = tright.substr(j); - var result = {}; - if (!isEmpty(rll) && rll.charAt(0) > 4) { - //有多余字符,需要四舍五入 - result.leftPlus = true; - var numReg = right.match(/^[0-9]+/); - if (numReg) { - var num = numReg[0]; - var orilen = num.length; - var newnum = BI.parseINT(num) + 1 + ''; - //进位到整数部分 - if (newnum.length > orilen) { - newnum = newnum.substr(1); + var text = cv.toString(); + if (isEmpty(fmt)) { + //格式为空,返回原字符 + return text; + } + if (fmt.match(/^T/)) { + //T - 文本格式 + return text; + } else if (fmt.match(/^D/)) { + //D - 日期(时间)格式 + if (!(cv instanceof Date)) { + if (typeof cv === 'number') { + //毫秒数类型 + cv = new Date(cv); } else { - newnum = BI.leftPad(newnum, orilen, '0'); - result.leftPlus = false; + //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 + cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); } - right = right.replace(/^[0-9]+/, newnum); } + if (!BI.isNull(cv)) { + var needTrim = fmt.match(/^DT/); + text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + } + } else if (fmt.match(/E/)) { + //科学计数格式 + text = _eFormat(text, fmt); + } else { + //数字格式 + text = _numberFormat(text, fmt); } - result.num = right; - return result; - }; - - BI.parseINT = function (str) { - return parseInt(str, 10); + //¤ - 货币格式 + text = text.replace(/¤/g, '¥'); + return text; }; BI.leftPad = function (val, size, ch) { @@ -20259,74 +20267,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { return result.toString(); }; - /** - * 处理小数点左边整数部分 - * @param tleft 左边内容 - * @param fleft 左边格式 - * @returns {string} 返回处理结果 - * @private - */ - BI._dealWithLeft = function (tleft, fleft) { - var left = ''; - var j = tleft.length - 1; - var combo = -1, last = -1; - var i = fleft.length - 1; - for (; i >= 0; i--) { - var ch = fleft.charAt(i); - var c = tleft.charAt(j); - switch (ch) { - case '0': - if (isEmpty(c)) { - c = '0'; - } - last = -1; - left = c + left; - j--; - break; - case '#': - last = i; - left = c + left; - j--; - break; - case ',': - if (!isEmpty(c)) { - //计算一个,分隔区间的长度 - var com = fleft.match(/,[#0]+/); - if (com) { - combo = com[0].length - 1; - } - left = ',' + left; - } - break; - default : - left = ch + left; - break; - } - } - if (last > -1) { - //处理剩余字符 - var tll = tleft.substr(0, j + 1); - left = left.substr(0, last) + tll + left.substr(last); - } - if (combo > 0) { - //处理,分隔区间 - var res = left.match(/[0-9]+,/); - if (res) { - res = res[0]; - var newstr = '', n = res.length - 1 - combo; - for (; n >= 0; n = n - combo) { - newstr = res.substr(n, combo) + ',' + newstr; - } - var lres = res.substr(0, n + combo); - if (!isEmpty(lres)) { - newstr = lres + ',' + newstr; - } - } - left = left.replace(/[0-9]+,/, newstr); - } - return left; - }; - BI.object2Number = function (value) { if (value == null) { return 0; @@ -20355,7 +20295,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } @@ -20363,10 +20303,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { } }; - BI.isArray = function (a) { - return Object.prototype.toString.call(a) == '[object Array]'; - }; - BI.object2Time = function (obj) { if (obj == null) { return new Date(); @@ -20377,77 +20313,22 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) { dt = new Date("1970/01/01 " + str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } } dt = BI.str2Date(str, "HH:mm:ss"); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } return new Date(); } }; - -// 判断是否是无效的日期 - BI.isInvalidDate = function (date) { - return date == "Invalid Date" || date == "NaN"; - }; - - - /** - * 科学计数格式 - */ - BI._eFormat = function (text, fmt) { - var e = fmt.indexOf("E"); - var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); - if (/^[0\.-]+$/.test(text)) { - text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) - } else { - var isNegative = text < 0; - if (isNegative) { - text = text.substr(1); - } - var elvl = (eleft.split('.')[0] || '').length; - var point = text.indexOf("."); - if (point < 0) { - point = text.length; - } - var i = 0; //第一个不为0的数的位置 - text = text.replace('.', ''); - for (var len = text.length; i < len; i++) { - var ech = text.charAt(i); - if (ech <= '9' && ech >= '1') { - break; - } - } - var right = point - i - elvl; - var left = text.substr(i, elvl); - var dis = i + elvl - text.length; - if (dis > 0) { - //末位补全0 - for (var k = 0; k < dis; k++) { - left += '0'; - } - } else { - left += '.' + text.substr(i + elvl); - } - left = left.replace(/^[0]+/, ''); - if (right < 0 && eright.indexOf('-') < 0) { - eright += ';-' + eright; - } - text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); - if (isNegative) { - text = '-' + text; - } - } - return text; - }; })(); /** * guy @@ -20560,7 +20441,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -20574,6 +20455,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } @@ -20876,28 +20760,30 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - var container = this.floatContainer[name]; - container.element.css("zIndex", this.zindex++); - this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); - this.zindexMap[name] = this.zindex; - this.modal && container.element.__buildZIndexMask__(this.zindex++); - this.get(name).setZindex(this.zindex++); - this.floatContainer[name].visible(); - var floatbox = this.get(name); - floatbox.show(); - var W = $(this.options.render).width(), H = $(this.options.render).height(); - var w = floatbox.element.width(), h = floatbox.element.height(); - var left = (W - w) / 2, top = (H - h) / 2; - if (left < 0) { - left = 0; - } - if (top < 0) { - top = 0; + if (!this.floatContainer[name].isVisible()) { + var container = this.floatContainer[name]; + container.element.css("zIndex", this.zindex++); + this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); + this.zindexMap[name] = this.zindex; + this.modal && container.element.__buildZIndexMask__(this.zindex++); + this.get(name).setZindex(this.zindex++); + this.floatContainer[name].visible(); + var floatbox = this.get(name); + floatbox.show(); + var W = $(this.options.render).width(), H = $(this.options.render).height(); + var w = floatbox.element.width(), h = floatbox.element.height(); + var left = (W - w) / 2, top = (H - h) / 2; + if (left < 0) { + left = 0; + } + if (top < 0) { + top = 0; + } + floatbox.element.css({ + left: left + "px", + top: top + "px" + }); } - floatbox.element.css({ - left: left + "px", - top: top + "px" - }); return this; }, @@ -20905,8 +20791,10 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - this.floatContainer[name].invisible(); - this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + if (this.floatContainer[name].isVisible()) { + this.floatContainer[name].invisible(); + this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + } return this; }, @@ -21156,11 +21044,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) { @@ -23664,56 +23555,56 @@ BI.Cache = { document.cookie = cookieString; } };// full day names -Date._DN = [BI.i18nText("BI-Sunday"), - BI.i18nText("BI-Monday"), - BI.i18nText("BI-Tuesday"), - BI.i18nText("BI-Wednesday"), - BI.i18nText("BI-Thursday"), - BI.i18nText("BI-Friday"), - BI.i18nText("BI-Saturday"), - BI.i18nText("BI-Sunday")]; +Date._DN = [BI.i18nText("BI-Basic_Sunday"), + BI.i18nText("BI-Basic_Monday"), + BI.i18nText("BI-Basic_Tuesday"), + BI.i18nText("BI-Basic_Wednesday"), + BI.i18nText("BI-Basic_Thursday"), + BI.i18nText("BI-Basic_Friday"), + BI.i18nText("BI-Basic_Saturday"), + BI.i18nText("BI-Basic_Sunday")]; // short day names -Date._SDN = ['', - '', - '', - '', - '', - '', - '', - '']; +Date._SDN = [BI.i18nText("BI-Day_Ri"), + BI.i18nText("BI-Basic_One"), + BI.i18nText("BI-Basic_Two"), + BI.i18nText("BI-Basic_Three"), + BI.i18nText("BI-Basic_Four"), + BI.i18nText("BI-Basic_Five"), + BI.i18nText("BI-Basic_Six"), + BI.i18nText("BI-Day_Ri")]; // Monday first, etc. Date._FD = 1; // full month names Date._MN = [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; + BI.i18nText("BI-Basic_January"), + BI.i18nText("BI-Basic_February"), + BI.i18nText("BI-Basic_March"), + BI.i18nText("BI-Basic_April"), + BI.i18nText("BI-Basic_May"), + BI.i18nText("BI-Basic_June"), + BI.i18nText("BI-Basic_July"), + BI.i18nText("BI-Basic_August"), + BI.i18nText("BI-Basic_September"), + BI.i18nText("BI-Basic_October"), + BI.i18nText("BI-Basic_November"), + BI.i18nText("BI-Basic_December")]; // short month names -Date._SMN = ['', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; +Date._SMN = [0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11]; Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_2"), @@ -26774,7 +26665,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { if (!self.hasWidget(item.cardName)) { var w = BI.createWidget(item); w.on(BI.Events.DESTROY, function () { - var index = BI.findKey(o.items, function (i, tItem) { + var index = BI.findIndex(o.items, function (i, tItem) { return tItem.cardName == item.cardName; }); if (index > -1) { @@ -26818,17 +26709,23 @@ BI.CardLayout = BI.inherit(BI.Layout, { return this._children[cardName]; }, - deleteCardByName: function (cardName) { - if (!this.isCardExisted(cardName)) { - throw new Error("cardName is not exist"); - } - var index = BI.findKey(this.options.items, function (i, item) { + _deleteCardByName: function (cardName) { + delete this._children[cardName]; + var index = BI.findIndex(this.options.items, function (i, item) { return item.cardName == cardName; }); if (index > -1) { this.options.items.splice(index, 1); } + }, + + deleteCardByName: function (cardName) { + if (!this.isCardExisted(cardName)) { + throw new Error("cardName is not exist"); + } + var child = this._children[cardName]; + this._deleteCardByName(cardName); child && child.destroy(); }, @@ -26861,11 +26758,13 @@ BI.CardLayout = BI.inherit(BI.Layout, { var flag = false; BI.each(this.options.items, function (i, item) { var el = self._children[item.cardName]; - if (name != item.cardName) { - //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 - !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); - } else { - (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + if (el) { + if (name != item.cardName) { + //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 + !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); + } else { + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + } } }); }, @@ -26924,6 +26823,22 @@ BI.CardLayout = BI.inherit(BI.Layout, { } }); return flag; + }, + + removeWidget: function (nameOrWidget) { + var removeName; + if (BI.isWidget(nameOrWidget)) { + BI.each(this._children, function (name, child) { + if (child === nameOrWidget) { + removeName = name; + } + }) + } else { + removeName = nameOrWidget; + } + if (removeName) { + this._deleteCardByName(removeName); + } } }); BI.shortcut('bi.card', BI.CardLayout);/** diff --git a/dist/widget.css b/dist/widget.css index 51d0750008..39a07dbd61 100644 --- a/dist/widget.css +++ b/dist/widget.css @@ -233,11 +233,13 @@ } .bi-fine-tuning-number-editor .top-button { border-left: 1px solid #d4dadd; - border-bottom: 1px solid #d4dadd; } .bi-fine-tuning-number-editor .bottom-button { border-left: 1px solid #d4dadd; } +.bi-fine-tuning-number-editor .split-line { + background-color: #d4dadd; +} /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ @@ -632,14 +634,6 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ -.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col, -.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col, -.bi-responsive-table > div > div > table > * > * > td.last-col { - min-width: 80px; -} -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ .bi-sequence-table-dynamic-number .sequence-table-title-cell { overflow: hidden; overflow-x: hidden; diff --git a/dist/widget.js b/dist/widget.js index fec31d1b5f..b375c5c3a6 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -4857,7 +4857,6 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge hgap: 4, vgap: 2, triggerWidth: 30, - watermark: BI.i18nText("BI-Unrestricted"), yearLength: 4, yearMonthLength: 7 }, @@ -4891,7 +4890,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge hgap: c.hgap, vgap: c.vgap, allowBlank: true, - watermark: c.watermark, + watermark: BI.i18nText("BI-Unrestricted"), errorText: function () { if (self.editor.isEditing()) { return BI.i18nText("BI-Date_Trigger_Error_Text"); @@ -6158,7 +6157,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, { return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-excel-table", el: { - type: "bi.adaptive_table" + type: "bi.responsive_table" }, isNeedResize: false, @@ -6192,8 +6191,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.table_view", element: this, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, isNeedFreeze: false, @@ -16791,7 +16788,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, { hgap: 4, vgap: 2, triggerWidth: 25, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") }, diff --git a/src/base/base.js b/src/base/base.js index 1198a5d522..49c5b21091 100644 --- a/src/base/base.js +++ b/src/base/base.js @@ -5,8 +5,4 @@ BI.Bubbles = new BI.BubblesController(); BI.Tooltips = new BI.TooltipsController(); BI.Popovers = new BI.FloatBoxController(); BI.Broadcasts = new BI.BroadcastController(); -BI.StyleLoaders = new BI.StyleLoaderManager(); - -BI.servletURL = "dist/"; -BI.resourceURL = "dist/resource/"; -BI.i18n = {}; \ No newline at end of file +BI.StyleLoaders = new BI.StyleLoaderManager(); \ No newline at end of file diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index f680af2cc7..353f18cd0f 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -57,9 +57,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { self.setValue([]); break; } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); + } else { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }); btn.on(BI.Events.DESTROY, function () { BI.remove(self.buttons, btn); @@ -155,9 +157,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts.addItems(this._packageLayout(items).items); }, - removeItemAt: function (index) { - this.buttons[index].destroy(); - this.layouts.removeItemAt(index); + removeItemAt: function (indexes) { + BI.remove(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.remove(this.buttons, deleted); + this.layouts.removeItemAt(deleted); }, populate: function (items) { diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index 2a959d710e..9ece43c4c9 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -52,18 +52,30 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { }, prependItems: function (items) { - this.layouts.prependItems(items); + this.layouts.prependItems(items); + }, + + setValue: function (v) { + this.layouts.setValue(v); + }, + + getValue: function () { + return this.layouts.getValue(); + }, + + empty: function () { + this.layouts.empty(); }, populate: function (items) { var self = this; items = items || []; this.options.items = items; - items = this._packageItems(items, this._packageBtns(items)); + items = this._packageBtns(items); if (!this.layouts) { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); } else { - this.layouts.populate(this._packageLayout(items).items); + this.layouts.populate(items); } } }); diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index ea592bb9d2..001770c554 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -153,7 +153,7 @@ }, false ); - xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true); + xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true); if (!xhr.upload) { var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true}; rpe.interval = setInterval(function () { @@ -602,7 +602,7 @@ }, setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); + BI.File.superclass.setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { diff --git a/src/case/pager/pager.all.count.js b/src/case/pager/pager.all.count.js index 42ab6eaca6..f15903fecb 100644 --- a/src/case/pager/pager.all.count.js +++ b/src/case/pager/pager.all.count.js @@ -25,7 +25,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, { hgap: 4, vgap: 0, value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), width: 30, height: 20 }); diff --git a/src/core/alias.js b/src/core/alias.js index b507b66f1f..0abe30e403 100644 --- a/src/core/alias.js +++ b/src/core/alias.js @@ -5,178 +5,59 @@ return result; } - BI.cjkEncode = function (text) { - // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) - if (typeof text !== 'string') { - return text; - } + // 判断是否是无效的日期 + function isInvalidDate(date) { + return date == "Invalid Date" || date == "NaN"; + } - var newText = ""; - for (var i = 0; i < text.length; i++) { - var code = text.charCodeAt(i); - if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". - newText += "[" + code.toString(16) + "]"; - } else { - newText += text.charAt(i); + /** + * 科学计数格式 + */ + function _eFormat(text, fmt) { + var e = fmt.indexOf("E"); + var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); + if (/^[0\.-]+$/.test(text)) { + text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) + } else { + var isNegative = text < 0; + if (isNegative) { + text = text.substr(1); } - } - - return newText - }; - - BI.cjkEncodeDO = function (o) { - if (BI.isPlainObject(o)) { - var result = {}; - $.each(o, function (k, v) { - if (!(typeof v == "string")) { - v = BI.jsonEncode(v); - } - //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 - k = BI.cjkEncode(k); - result[k] = BI.cjkEncode(v); - }); - return result; - } - return o; - }; - - BI.jsonEncode = function (o) { - //james:这个Encode是抄的EXT的 - var useHasOwn = {}.hasOwnProperty ? true : false; - - // crashes Safari in some instances - //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; - - var m = { - "\b": '\\b', - "\t": '\\t', - "\n": '\\n', - "\f": '\\f', - "\r": '\\r', - '"': '\\"', - "\\": '\\\\' - }; - - var encodeString = function (s) { - if (/["\\\x00-\x1f]/.test(s)) { - return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { - var c = m[b]; - if (c) { - return c; - } - c = b.charCodeAt(); - return "\\u00" + - Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - }) + '"'; + var elvl = (eleft.split('.')[0] || '').length; + var point = text.indexOf("."); + if (point < 0) { + point = text.length; } - return '"' + s + '"'; - }; - - var encodeArray = function (o) { - var a = ["["], b, i, l = o.length, v; - for (i = 0; i < l; i += 1) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "function": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(v === null ? "null" : BI.jsonEncode(v)); - b = true; + var i = 0; //第一个不为0的数的位置 + text = text.replace('.', ''); + for (var len = text.length; i < len; i++) { + var ech = text.charAt(i); + if (ech <= '9' && ech >= '1') { + break; } } - a.push("]"); - return a.join(""); - }; - - if (typeof o == "undefined" || o === null) { - return "null"; - } else if (BI.isArray(o)) { - return encodeArray(o); - } else if (o instanceof Date) { - /* - * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode - * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 - */ - return BI.jsonEncode({ - __time__: o.getTime() - }) - } else if (typeof o == "string") { - return encodeString(o); - } else if (typeof o == "number") { - return isFinite(o) ? String(o) : "null"; - } else if (typeof o == "boolean") { - return String(o); - } else if (BI.isFunction(o)) { - return String(o); - } else { - var a = ["{"], b, i, v; - for (i in o) { - if (!useHasOwn || o.hasOwnProperty(i)) { - v = o[i]; - switch (typeof v) { - case "undefined": - case "unknown": - break; - default: - if (b) { - a.push(','); - } - a.push(BI.jsonEncode(i), ":", - v === null ? "null" : BI.jsonEncode(v)); - b = true; - } + var right = point - i - elvl; + var left = text.substr(i, elvl); + var dis = i + elvl - text.length; + if (dis > 0) { + //末位补全0 + for (var k = 0; k < dis; k++) { + left += '0'; } + } else { + left += '.' + text.substr(i + elvl); } - a.push("}"); - return a.join(""); - } - }; - - BI.contentFormat = function (cv, fmt) { - if (isEmpty(cv)) { - //原值为空,返回空字符 - return ''; - } - var text = cv.toString(); - if (isEmpty(fmt)) { - //格式为空,返回原字符 - return text; - } - if (fmt.match(/^T/)) { - //T - 文本格式 - return text; - } else if (fmt.match(/^D/)) { - //D - 日期(时间)格式 - if (!(cv instanceof Date)) { - if (typeof cv === 'number') { - //毫秒数类型 - cv = new Date(cv); - } else { - //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 - cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); - } + left = left.replace(/^[0]+/, ''); + if (right < 0 && eright.indexOf('-') < 0) { + eright += ';-' + eright; } - if (!BI.isNull(cv)) { - var needTrim = fmt.match(/^DT/); - text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); + if (isNegative) { + text = '-' + text; } - } else if (fmt.match(/E/)) { - //科学计数格式 - text = BI._eFormat(text, fmt); - } else { - //数字格式 - text = BI._numberFormat(text, fmt); } - //¤ - 货币格式 - text = text.replace(/¤/g, '¥'); return text; - }; + } /** * 把日期对象按照指定格式转化成字符串 @@ -190,7 +71,7 @@ * @param format 日期格式 * @returns {String} */ - date2Str = function (date, format) { + function date2Str(date, format) { if (!date) { return ''; } @@ -299,15 +180,15 @@ /** * 数字格式 */ - BI._numberFormat = function (text, format) { + function _numberFormat(text, format) { var text = text + ''; //数字格式,区分正负数 var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), @@ -321,7 +202,7 @@ tleft = tleft.replace(/^0+/gi, ''); tright = tright.substr(paddingZero.length).replace(/0+$/gi, ''); } - var right = BI._dealWithRight(tright, fright); + var right = _dealWithRight(tright, fright); if (right.leftPlus) { //小数点后有进位 tleft = parseInt(tleft) + 1 + ''; @@ -329,7 +210,7 @@ tleft = isNaN(tleft) ? '1' : tleft; } right = right.num; - var left = BI._dealWithLeft(tleft, fleft); + var left = _dealWithLeft(tleft, fleft); if (!(/[0-9]/.test(left))) { left = left + '0'; } @@ -346,7 +227,7 @@ * @returns {JSON} 返回处理结果和整数部分是否需要进位 * @private */ - BI._dealWithRight = function (tright, fright) { + function _dealWithRight(tright, fright) { var right = '', j = 0, i = 0; for (var len = fright.length; i < len; i++) { var ch = fright.charAt(i); @@ -377,7 +258,7 @@ if (numReg) { var num = numReg[0]; var orilen = num.length; - var newnum = BI.parseINT(num) + 1 + ''; + var newnum = BI.parseInt(num) + 1 + ''; //进位到整数部分 if (newnum.length > orilen) { newnum = newnum.substr(1); @@ -390,22 +271,7 @@ } result.num = right; return result; - }; - - BI.parseINT = function (str) { - return parseInt(str, 10); - }; - - BI.leftPad = function (val, size, ch) { - var result = String(val); - if (!ch) { - ch = " "; - } - while (result.length < size) { - result = ch + result; - } - return result.toString(); - }; + } /** * 处理小数点左边整数部分 @@ -414,7 +280,7 @@ * @returns {string} 返回处理结果 * @private */ - BI._dealWithLeft = function (tleft, fleft) { + function _dealWithLeft(tleft, fleft) { var left = ''; var j = tleft.length - 1; var combo = -1, last = -1; @@ -473,6 +339,242 @@ left = left.replace(/[0-9]+,/, newstr); } return left; + } + + BI.cjkEncode = function (text) { + // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) + if (typeof text !== 'string') { + return text; + } + + var newText = ""; + for (var i = 0; i < text.length; i++) { + var code = text.charCodeAt(i); + if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". + newText += "[" + code.toString(16) + "]"; + } else { + newText += text.charAt(i); + } + } + + return newText + }; + + BI.cjkEncodeDO = function (o) { + if (BI.isPlainObject(o)) { + var result = {}; + $.each(o, function (k, v) { + if (!(typeof v == "string")) { + v = BI.jsonEncode(v); + } + //wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 + k = BI.cjkEncode(k); + result[k] = BI.cjkEncode(v); + }); + return result; + } + return o; + }; + + BI.jsonEncode = function (o) { + //james:这个Encode是抄的EXT的 + var useHasOwn = {}.hasOwnProperty ? true : false; + + // crashes Safari in some instances + //var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; + + var m = { + "\b": '\\b', + "\t": '\\t', + "\n": '\\n', + "\f": '\\f', + "\r": '\\r', + '"': '\\"', + "\\": '\\\\' + }; + + var encodeString = function (s) { + if (/["\\\x00-\x1f]/.test(s)) { + return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { + var c = m[b]; + if (c) { + return c; + } + c = b.charCodeAt(); + return "\\u00" + + Math.floor(c / 16).toString(16) + + (c % 16).toString(16); + }) + '"'; + } + return '"' + s + '"'; + }; + + var encodeArray = function (o) { + var a = ["["], b, i, l = o.length, v; + for (i = 0; i < l; i += 1) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "function": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + a.push("]"); + return a.join(""); + }; + + if (typeof o == "undefined" || o === null) { + return "null"; + } else if (BI.isArray(o)) { + return encodeArray(o); + } else if (o instanceof Date) { + /* + * alex:原来只是把年月日时分秒简单地拼成一个String,无法decode + * 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下 + */ + return BI.jsonEncode({ + __time__: o.getTime() + }) + } else if (typeof o == "string") { + return encodeString(o); + } else if (typeof o == "number") { + return isFinite(o) ? String(o) : "null"; + } else if (typeof o == "boolean") { + return String(o); + } else if (BI.isFunction(o)) { + return String(o); + } else { + var a = ["{"], b, i, v; + for (i in o) { + if (!useHasOwn || o.hasOwnProperty(i)) { + v = o[i]; + switch (typeof v) { + case "undefined": + case "unknown": + break; + default: + if (b) { + a.push(','); + } + a.push(BI.jsonEncode(i), ":", + v === null ? "null" : BI.jsonEncode(v)); + b = true; + } + } + } + a.push("}"); + return a.join(""); + } + }; + + BI.jsonDecode = function (text) { + + try { + // 注意0啊 + //var jo = $.parseJSON(text) || {}; + var jo = $.parseJSON(text); + if (jo == null) { + jo = {}; + } + } catch (e) { + /* + * richie:浏览器只支持标准的JSON字符串转换,而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析 + * 比如:var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常 + */ + try { + jo = new Function("return " + text)() || {}; + } catch (e) { + //do nothing + } + if (jo == null) { + jo = []; + } + } + if (!_hasDateInJson(text)) { + return jo; + } + + function _hasDateInJson(json) { + if (!json || typeof json !== "string") { + return false; + } + return json.indexOf("__time__") != -1; + } + + return (function (o) { + if (typeof o === "string") { + return o; + } + if (o && o.__time__ != null) { + return new Date(o.__time__); + } + for (var a in o) { + if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) { + break; + } + o[a] = arguments.callee(o[a]); + } + + return o; + })(jo); + } + + BI.contentFormat = function (cv, fmt) { + if (isEmpty(cv)) { + //原值为空,返回空字符 + return ''; + } + var text = cv.toString(); + if (isEmpty(fmt)) { + //格式为空,返回原字符 + return text; + } + if (fmt.match(/^T/)) { + //T - 文本格式 + return text; + } else if (fmt.match(/^D/)) { + //D - 日期(时间)格式 + if (!(cv instanceof Date)) { + if (typeof cv === 'number') { + //毫秒数类型 + cv = new Date(cv); + } else { + //字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 + cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); + } + } + if (!BI.isNull(cv)) { + var needTrim = fmt.match(/^DT/); + text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); + } + } else if (fmt.match(/E/)) { + //科学计数格式 + text = _eFormat(text, fmt); + } else { + //数字格式 + text = _numberFormat(text, fmt); + } + //¤ - 货币格式 + text = text.replace(/¤/g, '¥'); + return text; + }; + + BI.leftPad = function (val, size, ch) { + var result = String(val); + if (!ch) { + ch = " "; + } + while (result.length < size) { + result = ch + result; + } + return result.toString(); }; BI.object2Number = function (value) { @@ -503,7 +605,7 @@ var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } @@ -511,10 +613,6 @@ } }; - BI.isArray = function (a) { - return Object.prototype.toString.call(a) == '[object Array]'; - }; - BI.object2Time = function (obj) { if (obj == null) { return new Date(); @@ -525,75 +623,20 @@ var str = obj + ""; str = str.replace(/-/g, '/'); var dt = new Date(str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) { dt = new Date("1970/01/01 " + str); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } } dt = BI.str2Date(str, "HH:mm:ss"); - if (!BI.isInvalidDate(dt)) { + if (!isInvalidDate(dt)) { return dt; } return new Date(); } }; - -// 判断是否是无效的日期 - BI.isInvalidDate = function (date) { - return date == "Invalid Date" || date == "NaN"; - }; - - - /** - * 科学计数格式 - */ - BI._eFormat = function (text, fmt) { - var e = fmt.indexOf("E"); - var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); - if (/^[0\.-]+$/.test(text)) { - text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) - } else { - var isNegative = text < 0; - if (isNegative) { - text = text.substr(1); - } - var elvl = (eleft.split('.')[0] || '').length; - var point = text.indexOf("."); - if (point < 0) { - point = text.length; - } - var i = 0; //第一个不为0的数的位置 - text = text.replace('.', ''); - for (var len = text.length; i < len; i++) { - var ech = text.charAt(i); - if (ech <= '9' && ech >= '1') { - break; - } - } - var right = point - i - elvl; - var left = text.substr(i, elvl); - var dis = i + elvl - text.length; - if (dis > 0) { - //末位补全0 - for (var k = 0; k < dis; k++) { - left += '0'; - } - } else { - left += '.' + text.substr(i + elvl); - } - left = left.replace(/^[0]+/, ''); - if (right < 0 && eright.indexOf('-') < 0) { - eright += ';-' + eright; - } - text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); - if (isNegative) { - text = '-' + text; - } - } - return text; - }; })(); diff --git a/src/core/base.js b/src/core/base.js index ddfe30fa98..cdee5f2d50 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -141,7 +141,7 @@ if (!window.BI) { }, formatEL: function (obj) { - if (obj && obj.el) { + if (obj && !obj.type && obj.el) { return obj; } return { @@ -1076,100 +1076,24 @@ if (!window.BI) { //encode encodeBIParam(option.data); - var async = true; - if (BI.isNotNull(option.async)) { - async = option.async; - } + var async = option.async; - if (BI.isNull(loading)) { - loading = BI.createWidget({ - type: "bi.request_loading" - }); - } - - if (BI.isNull(timeoutToast)) { - timeoutToast = BI.createWidget({ - type: "bi.timeout_toast" - }); - timeoutToast.setCallback(function (op) { - decodeBIParam(op.data); - BI.ajax(op); - }); - } - timeoutToast.addReq(option); + option.data = BI.cjkEncodeDO(option.data); - option.data = BI.cjkEncodeDO(option.data); - - - $.ajax({ url: option.url, type: "POST", data: option.data, async: async, - error: function () { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //失败 取消、重新加载 - loading.setCallback(function () { - decodeBIParam(option.data); - BI.ajax(option); - }); - loading.showError(); - }, + error: option.error, complete: function (res, status) { - if (!timeoutToast.hasReq(option)) { - return; - } - timeoutToast.removeReq(option); - //登录超时 - if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("fs-login-content") > -1 && - res.responseText.indexOf("fs-login-input-password-confirm") === -1) { - if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) { - return; - } - if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) { - BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID); - return; - } - var loginTimeout = BI.createWidget({ - type: "bi.login_timeout" - }); - loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () { - decodeBIParam(option.data); - BI.ajax(option); - BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID); - }); - BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, { - width: 600, - height: 400 - }).open(BI.LoginTimeOut.POPOVER_ID); - } else if (BI.isNotNull(res.responseText) && - res.responseText.indexOf("script") > -1 && - res.responseText.indexOf("Session Timeout...") > -1) { - //登录失效 - loading.setCallback(function () { - location.reload(); - }); - loading.showError(); - - } else if (status === "success" && BI.isFunction(option.success)) { - option.success(BI.jsonDecode(res.responseText)); - } if (BI.isFunction(option.complete)) { option.complete(BI.jsonDecode(res.responseText), status); } } }); - return function cancel() { - timeoutToast.removeReq(option); - }; - function encodeBIParam(data) { for (var key in data) { if (_.isObject(data[key])) { @@ -1189,101 +1113,6 @@ if (!window.BI) { } } } - })(), - - /** - * 异步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参数 - * @param {Function} callback 回调函数 - * @param {Function} complete 回调 - */ - requestAsync: function (op, cmd, data, callback, complete) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi" || op === "fr_bi_configure") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - return (BI.ajax)({ - url: url, - type: 'POST', - data: data, - error: function () { - // BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - success: function (res) { - if (BI.isFunction(callback)) { - callback(res); - } - }, - complete: function (res, status) { - if (BI.isFunction(complete)) { - complete(res); - } - } - }); - }, - - /** - * 同步ajax请求 - * @param {String} op op参数 - * @param {String} cmd cmd参数 - * @param {JSON} data ajax请求的参�? - * @returns {Object} ajax同步请求返回的JSON对象 - */ - requestSync: function (op, cmd, data) { - data = data || {}; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random(); - var result = {}; - (BI.ajax)({ - url: url, - type: 'POST', - async: false, - data: data, - error: function () { - BI.Msg.toast(BI.i18nText("BI-Ajax_Error")); - }, - complete: function (res, status) { - if (status === 'success') { - result = res; - } - } - }); - return result; - }, - - /** - * 请求方法 - * @param cmd 命令 - * @param data 数据 - * @param extend 参数 - * @returns {*} - */ - request: function (cmd, data, extend) { - extend = extend || {}; - data = data || {}; - var op = extend.op; - if (!BI.isKey(op)) { - op = 'fr_bi_dezi'; - } - if (op === "fr_bi_dezi") { - data.sessionID = Data.SharingPool.get("sessionID"); - } - if (extend.async === true) { - BI.requestAsync(op, cmd, data, extend.complete || extend.success); - } else { - return BI.requestSync(op, cmd, data); - } - } + })() }); })(jQuery); \ No newline at end of file diff --git a/src/core/controller/controller.broadcast.js b/src/core/controller/controller.broadcast.js index 7b7c43984f..202f2432e5 100644 --- a/src/core/controller/controller.broadcast.js +++ b/src/core/controller/controller.broadcast.js @@ -21,7 +21,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -35,6 +35,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } diff --git a/src/core/controller/controller.floatbox.js b/src/core/controller/controller.floatbox.js index 3179694817..b06e9723b0 100644 --- a/src/core/controller/controller.floatbox.js +++ b/src/core/controller/controller.floatbox.js @@ -82,28 +82,30 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - var container = this.floatContainer[name]; - container.element.css("zIndex", this.zindex++); - this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); - this.zindexMap[name] = this.zindex; - this.modal && container.element.__buildZIndexMask__(this.zindex++); - this.get(name).setZindex(this.zindex++); - this.floatContainer[name].visible(); - var floatbox = this.get(name); - floatbox.show(); - var W = $(this.options.render).width(), H = $(this.options.render).height(); - var w = floatbox.element.width(), h = floatbox.element.height(); - var left = (W - w) / 2, top = (H - h) / 2; - if (left < 0) { - left = 0; + if (!this.floatContainer[name].isVisible()) { + var container = this.floatContainer[name]; + container.element.css("zIndex", this.zindex++); + this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]); + this.zindexMap[name] = this.zindex; + this.modal && container.element.__buildZIndexMask__(this.zindex++); + this.get(name).setZindex(this.zindex++); + this.floatContainer[name].visible(); + var floatbox = this.get(name); + floatbox.show(); + var W = $(this.options.render).width(), H = $(this.options.render).height(); + var w = floatbox.element.width(), h = floatbox.element.height(); + var left = (W - w) / 2, top = (H - h) / 2; + if (left < 0) { + left = 0; + } + if (top < 0) { + top = 0; + } + floatbox.element.css({ + left: left + "px", + top: top + "px" + }); } - if (top < 0) { - top = 0; - } - floatbox.element.css({ - left: left + "px", - top: top + "px" - }); return this; }, @@ -111,8 +113,10 @@ BI.FloatBoxController = BI.inherit(BI.Controller, { if (!this._check(name)) { return this; } - this.floatContainer[name].invisible(); - this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + if (this.floatContainer[name].isVisible()) { + this.floatContainer[name].invisible(); + this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]); + } return this; }, diff --git a/src/core/controller/controller.resizer.js b/src/core/controller/controller.resizer.js index 04ad57869b..d45b13bc9c 100644 --- a/src/core/controller/controller.resizer.js +++ b/src/core/controller/controller.resizer.js @@ -41,11 +41,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) { diff --git a/src/core/proto/date.js b/src/core/proto/date.js index 636fafdc70..d1c240377c 100644 --- a/src/core/proto/date.js +++ b/src/core/proto/date.js @@ -1,54 +1,54 @@ // full day names -Date._DN = [BI.i18nText("BI-Sunday"), - BI.i18nText("BI-Monday"), - BI.i18nText("BI-Tuesday"), - BI.i18nText("BI-Wednesday"), - BI.i18nText("BI-Thursday"), - BI.i18nText("BI-Friday"), - BI.i18nText("BI-Saturday"), - BI.i18nText("BI-Sunday")]; +Date._DN = [BI.i18nText("BI-Basic_Sunday"), + BI.i18nText("BI-Basic_Monday"), + BI.i18nText("BI-Basic_Tuesday"), + BI.i18nText("BI-Basic_Wednesday"), + BI.i18nText("BI-Basic_Thursday"), + BI.i18nText("BI-Basic_Friday"), + BI.i18nText("BI-Basic_Saturday"), + BI.i18nText("BI-Basic_Sunday")]; // short day names -Date._SDN = ['', - '', - '', - '', - '', - '', - '', - '']; +Date._SDN = [BI.i18nText("BI-Day_Ri"), + BI.i18nText("BI-Basic_One"), + BI.i18nText("BI-Basic_Two"), + BI.i18nText("BI-Basic_Three"), + BI.i18nText("BI-Basic_Four"), + BI.i18nText("BI-Basic_Five"), + BI.i18nText("BI-Basic_Six"), + BI.i18nText("BI-Day_Ri")]; // Monday first, etc. Date._FD = 1; // full month names Date._MN = [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; + BI.i18nText("BI-Basic_January"), + BI.i18nText("BI-Basic_February"), + BI.i18nText("BI-Basic_March"), + BI.i18nText("BI-Basic_April"), + BI.i18nText("BI-Basic_May"), + BI.i18nText("BI-Basic_June"), + BI.i18nText("BI-Basic_July"), + BI.i18nText("BI-Basic_August"), + BI.i18nText("BI-Basic_September"), + BI.i18nText("BI-Basic_October"), + BI.i18nText("BI-Basic_November"), + BI.i18nText("BI-Basic_December")]; // short month names -Date._SMN = ['', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '']; +Date._SMN = [0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11]; Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_2"), diff --git a/src/core/view.js b/src/core/view.js index 5dcab2c4ff..c0ae68237d 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -327,7 +327,7 @@ BI.View = BI.inherit(BI.V, { } //采用静默方式读数据,该数据变化不引起data的change事件触发 var success = options.success; - this.read(BI.extend({ + this.model.read(BI.extend({ silent: true }, options, { success: function (data, model) { @@ -369,22 +369,10 @@ BI.View = BI.inherit(BI.V, { return this.model.getEditing(); }, - read: function (options) { - this.model.read(options) - }, - - update: function (options) { - this.model.update(options); - }, - - patch: function (options) { - this.model.patch(options); - }, - reading: function (options) { var self = this; var name = BI.UUID(); - this.read(BI.extend({}, options, { + this.model.read(BI.extend({}, options, { beforeSend: function () { var loading = BI.createWidget({ type: 'bi.vertical', @@ -407,7 +395,7 @@ BI.View = BI.inherit(BI.V, { updating: function (options) { var self = this; var name = BI.UUID(); - this.update(BI.extend({}, options, { + this.model.update(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ @@ -431,7 +419,7 @@ BI.View = BI.inherit(BI.V, { patching: function (options) { var self = this; var name = BI.UUID(); - this.patch(BI.extend({}, options, { + this.model.patch(BI.extend({}, options, { noset: true, beforeSend: function () { var loading = BI.createWidget({ diff --git a/src/core/widget.js b/src/core/widget.js index 2f4f3d3902..693734fc91 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -34,7 +34,8 @@ BI.Widget = BI.inherit(BI.OB, { mounted: null, - update: null, + update: function () { + }, destroyed: null, @@ -258,7 +259,7 @@ BI.Widget = BI.inherit(BI.OB, { } widget._setParent && widget._setParent(this); widget.on(BI.Events.DESTROY, function () { - delete self._children[name] + BI.remove(self._children, this); }); return (this._children[name] = widget); }, @@ -287,11 +288,7 @@ BI.Widget = BI.inherit(BI.OB, { removeWidget: function (nameOrWidget) { var self = this; if (BI.isWidget(nameOrWidget)) { - BI.each(this._children, function (name, widget) { - if (widget === nameOrWidget) { - delete self._children[name]; - } - }) + BI.remove(this._children, nameOrWidget); } else { delete this._children[nameOrWidget]; } @@ -371,8 +368,8 @@ BI.Widget = BI.inherit(BI.OB, { isolate: function () { if (this._parent) { this._parent.removeWidget(this); - BI.DOM.hang([this]); } + BI.DOM.hang([this]); }, empty: function () { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 4074b3fd74..cf23c39745 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -74,6 +74,7 @@ BI.Layout = BI.inherit(BI.Widget, { w.on(BI.Events.DESTROY, function () { BI.each(self._children, function (name, child) { if (child === w) { + BI.remove(self._children, child); self.removeItemAt(name | 0); } }); @@ -220,13 +221,24 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, - removeItemAt: function (index) { - if (index < 0 || index > this.options.items.length - 1) { - return; + removeItemAt: function (indexes) { + indexes = BI.isArray(indexes) ? indexes : [indexes]; + var deleted = []; + var newItems = [], newChildren = {}; + for (var i = 0, len = this.options.items.length; i < len; i++) { + var child = this._children[this._getChildName(i)]; + if (indexes.contains(i)) { + child && deleted.push(child); + } else { + newChildren[this._getChildName(newItems.length)] = child; + newItems.push(this.options.items[i]); + } } - var child = this._children[this._getChildName(index)]; - this._removeItemAt(index); - child.destroy(); + this.options.items = newItems; + this._children = newChildren; + BI.each(deleted, function (i, c) { + c.destroy(); + }); }, updateItemAt: function (index, item) { @@ -235,9 +247,9 @@ BI.Layout = BI.inherit(BI.Widget, { } var child = this._children[this._getChildName(index)]; - if (child.update) { - child.update(this._getOptions(item)); - return true; + var updated; + if (updated = child.update(this._getOptions(item))) { + return updated; } var del = this._children[this._getChildName(index)]; delete this._children[this._getChildName(index)]; @@ -291,33 +303,39 @@ BI.Layout = BI.inherit(BI.Widget, { }, getValue: function () { - var self = this, value = []; + var self = this, value = [], child; BI.each(this.options.items, function (i) { - var v = self._children[self._getChildName(i)].getValue(); - v = BI.isArray(v) ? v : [v]; - value = value.concat(v); + if (child = self._children[self._getChildName(i)]) { + var v = child.getValue(); + v = BI.isArray(v) ? v : [v]; + value = value.concat(v); + } }); return value; }, setValue: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setValue(v); + if (child = self._children[self._getChildName(i)]) { + child.setValue(v); + } }) }, setText: function (v) { - var self = this; + var self = this, child; BI.each(this.options.items, function (i) { - self._children[self._getChildName(i)].setText(v); + if (child = self._children[self._getChildName(i)]) { + child.setText(v); + } }) }, update: function (item) { var o = this.options; - var items = item.items; - var updated = false, i, len; + var items = item.items || []; + var updated, i, len; for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) { if (!this._compare(o.items[i], items[i])) { updated = this.updateItemAt(i, items[i]) || updated; @@ -327,7 +345,9 @@ BI.Layout = BI.inherit(BI.Widget, { var deleted = []; for (i = items.length; i < o.items.length; i++) { deleted.push(this._children[this._getChildName(i)]); + delete this._children[this._getChildName(i)]; } + o.items.splice(items.length); BI.each(deleted, function (i, w) { w.destroy(); }) @@ -336,7 +356,6 @@ BI.Layout = BI.inherit(BI.Widget, { this.addItemAt(i, items[i]); } } - this.options.items = items; return updated; }, @@ -370,6 +389,11 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = []; }, + destroy: function () { + BI.Layout.superclass.destroy.apply(this, arguments); + this.options.items = []; + }, + populate: function (items) { var self = this, o = this.options; items = items || []; diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index 9711da9e2e..aa0921291d 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -30,7 +30,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { if (!self.hasWidget(item.cardName)) { var w = BI.createWidget(item); w.on(BI.Events.DESTROY, function () { - var index = BI.findKey(o.items, function (i, tItem) { + var index = BI.findIndex(o.items, function (i, tItem) { return tItem.cardName == item.cardName; }); if (index > -1) { @@ -74,17 +74,23 @@ BI.CardLayout = BI.inherit(BI.Layout, { return this._children[cardName]; }, - deleteCardByName: function (cardName) { - if (!this.isCardExisted(cardName)) { - throw new Error("cardName is not exist"); - } - var index = BI.findKey(this.options.items, function (i, item) { + _deleteCardByName: function (cardName) { + delete this._children[cardName]; + var index = BI.findIndex(this.options.items, function (i, item) { return item.cardName == cardName; }); if (index > -1) { this.options.items.splice(index, 1); } + }, + + deleteCardByName: function (cardName) { + if (!this.isCardExisted(cardName)) { + throw new Error("cardName is not exist"); + } + var child = this._children[cardName]; + this._deleteCardByName(cardName); child && child.destroy(); }, @@ -117,11 +123,13 @@ BI.CardLayout = BI.inherit(BI.Layout, { var flag = false; BI.each(this.options.items, function (i, item) { var el = self._children[item.cardName]; - if (name != item.cardName) { - //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 - !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); - } else { - (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + if (el) { + if (name != item.cardName) { + //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 + !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); + } else { + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) + } } }); }, @@ -180,6 +188,22 @@ BI.CardLayout = BI.inherit(BI.Layout, { } }); return flag; + }, + + removeWidget: function (nameOrWidget) { + var removeName; + if (BI.isWidget(nameOrWidget)) { + BI.each(this._children, function (name, child) { + if (child === nameOrWidget) { + removeName = name; + } + }) + } else { + removeName = nameOrWidget; + } + if (removeName) { + this._deleteCardByName(removeName); + } } }); BI.shortcut('bi.card', BI.CardLayout); \ No newline at end of file diff --git a/src/css/base/single/text.css b/src/css/base/single/text.css index 34613e8aa1..ce71f6ee51 100644 --- a/src/css/base/single/text.css +++ b/src/css/base/single/text.css @@ -6,5 +6,5 @@ overflow-x: hidden; overflow-y: hidden; white-space: nowrap; - word-break: break-all; + word-break: break-word; } diff --git a/src/css/base/table/table.grid.quick.css b/src/css/base/table/table.grid.quick.css deleted file mode 100644 index 2f6491e13f..0000000000 --- a/src/css/base/table/table.grid.quick.css +++ /dev/null @@ -1,3 +0,0 @@ -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ diff --git a/src/css/widget/finetuningnumbereditor/finetuning.number.editor.css b/src/css/widget/finetuningnumbereditor/finetuning.number.editor.css index d8afcf2390..69e34450ae 100644 --- a/src/css/widget/finetuningnumbereditor/finetuning.number.editor.css +++ b/src/css/widget/finetuningnumbereditor/finetuning.number.editor.css @@ -9,8 +9,10 @@ } .bi-fine-tuning-number-editor .top-button { border-left: 1px solid #d4dadd; - border-bottom: 1px solid #d4dadd; } .bi-fine-tuning-number-editor .bottom-button { border-left: 1px solid #d4dadd; } +.bi-fine-tuning-number-editor .split-line { + background-color: #d4dadd; +} diff --git a/src/css/widget/responsivetable/responsivetable.css b/src/css/widget/responsivetable/responsivetable.css deleted file mode 100644 index e19ce6816c..0000000000 --- a/src/css/widget/responsivetable/responsivetable.css +++ /dev/null @@ -1,8 +0,0 @@ -/****添加计算宽度的--运算符直接需要space****/ -/****** common color(常用颜色,可用于普遍场景) *****/ -/**** custom color(自定义颜色,用于特定场景) ****/ -.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col, -.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col, -.bi-responsive-table > div > div > table > * > * > td.last-col { - min-width: 80px; -} diff --git a/src/less/base/single/text.less b/src/less/base/single/text.less index 568122a9c2..a6f1d83cd4 100644 --- a/src/less/base/single/text.less +++ b/src/less/base/single/text.less @@ -2,5 +2,5 @@ .bi-text{ .overflow-dot(); - word-break: break-all; + word-break: break-word; } \ No newline at end of file diff --git a/src/less/base/table/table.grid.quick.less b/src/less/base/table/table.grid.quick.less deleted file mode 100644 index a5355da479..0000000000 --- a/src/less/base/table/table.grid.quick.less +++ /dev/null @@ -1,4 +0,0 @@ -@import "../../bibase"; - -.bi-quick-grid-table { -} \ No newline at end of file diff --git a/src/less/widget/finetuningnumbereditor/finetuning.number.editor.less b/src/less/widget/finetuningnumbereditor/finetuning.number.editor.less index 2f7905f81a..3074def162 100644 --- a/src/less/widget/finetuningnumbereditor/finetuning.number.editor.less +++ b/src/less/widget/finetuningnumbereditor/finetuning.number.editor.less @@ -5,9 +5,11 @@ .border-radius(2px); & .top-button { border-left: 1px solid @border-color-normal; - border-bottom: 1px solid @border-color-normal; } & .bottom-button { border-left: 1px solid @border-color-normal; } + & .split-line{ + background-color: @border-color-normal; + } } \ No newline at end of file diff --git a/src/less/widget/responsivetable/responsivetable.less b/src/less/widget/responsivetable/responsivetable.less deleted file mode 100644 index 87cbfb2890..0000000000 --- a/src/less/widget/responsivetable/responsivetable.less +++ /dev/null @@ -1,11 +0,0 @@ -@import "../../bibase"; - -.bi-responsive-table { - & > div.bottom-left > div > div > table, & > div.bottom-right > div > div > table, > div > div > table { - & > * > * > td { - &.last-col { - min-width: 80px; - } - } - } -} \ No newline at end of file diff --git a/src/widget/date/trigger.date.js b/src/widget/date/trigger.date.js index a425ce6f8a..75f51a86ae 100644 --- a/src/widget/date/trigger.date.js +++ b/src/widget/date/trigger.date.js @@ -3,7 +3,6 @@ BI.DateTrigger = BI.inherit(BI.Trigger, { hgap: 4, vgap: 2, triggerWidth: 30, - watermark: BI.i18nText("BI-Unrestricted"), yearLength: 4, yearMonthLength: 7 }, @@ -37,7 +36,7 @@ BI.DateTrigger = BI.inherit(BI.Trigger, { hgap: c.hgap, vgap: c.vgap, allowBlank: true, - watermark: c.watermark, + watermark: BI.i18nText("BI-Unrestricted"), errorText: function () { if (self.editor.isEditing()) { return BI.i18nText("BI-Date_Trigger_Error_Text"); diff --git a/src/widget/exceltable/exceltable.js b/src/widget/exceltable/exceltable.js index 6a4becdc23..91d034a31c 100644 --- a/src/widget/exceltable/exceltable.js +++ b/src/widget/exceltable/exceltable.js @@ -11,7 +11,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, { return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-excel-table", el: { - type: "bi.adaptive_table" + type: "bi.responsive_table" }, isNeedResize: false, @@ -45,8 +45,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, { this.table = BI.createWidget(o.el, { type: "bi.table_view", element: this, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, isNeedFreeze: false, diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 093dcfdde4..f87b1614a2 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -10,7 +10,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, { hgap: 4, vgap: 2, triggerWidth: 25, - errorText: BI.i18nText("BI-Please_Input_Integer"), + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") },