guy 8 years ago
parent
commit
c774adafec
  1. 97
      bi/core.js
  2. 29
      bi/widget.js
  3. 97
      dist/core.js
  4. 29
      dist/widget.js
  5. 96
      src/core/alias.js
  6. 29
      src/widget/adaptivearrangement/adaptivearrangement.js

97
bi/core.js

@ -3181,7 +3181,14 @@ if (!window.BI) {
} }
} }
}); });
})(jQuery);BI.cjkEncode = function (text) { })(jQuery);;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') { if (typeof text !== 'string') {
return text; return text;
@ -3198,9 +3205,9 @@ if (!window.BI) {
} }
return newText return newText
}; };
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
$.each(o, function (k, v) { $.each(o, function (k, v) {
@ -3214,9 +3221,9 @@ BI.cjkEncodeDO = function (o) {
return result; return result;
} }
return o; return o;
}; };
BI.jsonEncode = function (o) { BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的 //james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false; var useHasOwn = {}.hasOwnProperty ? true : false;
@ -3312,15 +3319,15 @@ BI.jsonEncode = function (o) {
a.push("}"); a.push("}");
return a.join(""); return a.join("");
} }
}; };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) { if (isEmpty(cv)) {
//原值为空,返回空字符 //原值为空,返回空字符
return ''; return '';
} }
var text = cv.toString(); var text = cv.toString();
if (BI.isEmpty(fmt)) { if (isEmpty(fmt)) {
//格式为空,返回原字符 //格式为空,返回原字符
return text; return text;
} }
@ -3352,9 +3359,9 @@ BI.contentFormat = function (cv, fmt) {
//¤ - 货币格式 //¤ - 货币格式
text = text.replace(/¤/g, '¥'); text = text.replace(/¤/g, '¥');
return text; return text;
}; };
/** /**
* 把日期对象按照指定格式转化成字符串 * 把日期对象按照指定格式转化成字符串
* *
* @example * @example
@ -3366,7 +3373,7 @@ BI.contentFormat = function (cv, fmt) {
* @param format 日期格式 * @param format 日期格式
* @returns {String} * @returns {String}
*/ */
date2Str = function (date, format) { date2Str = function (date, format) {
if (!date) { if (!date) {
return ''; return '';
} }
@ -3470,12 +3477,12 @@ date2Str = function (date, format) {
} }
return str; return str;
} }
}; };
/** /**
* 数字格式 * 数字格式
*/ */
BI._numberFormat = function (text, format) { BI._numberFormat = function (text, format) {
var text = text + ''; var text = text + '';
//数字格式,区分正负数 //数字格式,区分正负数
var numMod = format.indexOf(';'); var numMod = format.indexOf(';');
@ -3514,22 +3521,22 @@ BI._numberFormat = function (text, format) {
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; };
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
* @param fright 右边格式 * @param fright 右边格式
* @returns {JSON} 返回处理结果和整数部分是否需要进位 * @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private * @private
*/ */
BI._dealWithRight = function (tright, fright) { BI._dealWithRight = function (tright, fright) {
var right = '', j = 0, i = 0; var right = '', j = 0, i = 0;
for (var len = fright.length; i < len; i++) { for (var len = fright.length; i < len; i++) {
var ch = fright.charAt(i); var ch = fright.charAt(i);
var c = tright.charAt(j); var c = tright.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
right += c; right += c;
@ -3546,7 +3553,7 @@ BI._dealWithRight = function (tright, fright) {
} }
var rll = tright.substr(j); var rll = tright.substr(j);
var result = {}; var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) { if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入 //有多余字符,需要四舍五入
result.leftPlus = true; result.leftPlus = true;
var numReg = right.match(/^[0-9]+/); var numReg = right.match(/^[0-9]+/);
@ -3566,13 +3573,13 @@ BI._dealWithRight = function (tright, fright) {
} }
result.num = right; result.num = right;
return result; return result;
}; };
BI.parseINT = function (str) { BI.parseINT = function (str) {
return parseInt(str, 10); return parseInt(str, 10);
}; };
BI.leftPad = function (val, size, ch) { BI.leftPad = function (val, size, ch) {
var result = String(val); var result = String(val);
if (!ch) { if (!ch) {
ch = " "; ch = " ";
@ -3581,16 +3588,16 @@ BI.leftPad = function (val, size, ch) {
result = ch + result; result = ch + result;
} }
return result.toString(); return result.toString();
}; };
/** /**
* 处理小数点左边整数部分 * 处理小数点左边整数部分
* @param tleft 左边内容 * @param tleft 左边内容
* @param fleft 左边格式 * @param fleft 左边格式
* @returns {string} 返回处理结果 * @returns {string} 返回处理结果
* @private * @private
*/ */
BI._dealWithLeft = function (tleft, fleft) { BI._dealWithLeft = function (tleft, fleft) {
var left = ''; var left = '';
var j = tleft.length - 1; var j = tleft.length - 1;
var combo = -1, last = -1; var combo = -1, last = -1;
@ -3600,7 +3607,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j); var c = tleft.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
last = -1; last = -1;
@ -3613,7 +3620,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--; j--;
break; break;
case ',': case ',':
if (!BI.isEmpty(c)) { if (!isEmpty(c)) {
//计算一个,分隔区间的长度 //计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/); var com = fleft.match(/,[#0]+/);
if (com) { if (com) {
@ -3642,16 +3649,16 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr; newstr = res.substr(n, combo) + ',' + newstr;
} }
var lres = res.substr(0, n + combo); var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) { if (!isEmpty(lres)) {
newstr = lres + ',' + newstr; newstr = lres + ',' + newstr;
} }
} }
left = left.replace(/[0-9]+,/, newstr); left = left.replace(/[0-9]+,/, newstr);
} }
return left; return left;
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {
if (value == null) { if (value == null) {
return 0; return 0;
} }
@ -3665,9 +3672,9 @@ BI.object2Number = function (value) {
return parseFloat(str); return parseFloat(str);
} }
} }
}; };
BI.object2Date = function (obj) { BI.object2Date = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -3685,13 +3692,13 @@ BI.object2Date = function (obj) {
return new Date(); return new Date();
} }
}; };
BI.isArray = function (a) { BI.isArray = function (a) {
return Object.prototype.toString.call(a) == '[object Array]'; return Object.prototype.toString.call(a) == '[object Array]';
}; };
BI.object2Time = function (obj) { BI.object2Time = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -3716,18 +3723,18 @@ BI.object2Time = function (obj) {
} }
return new Date(); return new Date();
} }
}; };
// 判断是否是无效的日期 // 判断是否是无效的日期
BI.isInvalidDate = function (date) { BI.isInvalidDate = function (date) {
return date == "Invalid Date" || date == "NaN"; return date == "Invalid Date" || date == "NaN";
}; };
/** /**
* 科学计数格式 * 科学计数格式
*/ */
BI._eFormat = function (text, fmt) { BI._eFormat = function (text, fmt) {
var e = fmt.indexOf("E"); var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) { if (/^[0\.-]+$/.test(text)) {
@ -3771,7 +3778,9 @@ BI._eFormat = function (text, fmt) {
} }
} }
return text; return text;
};/** };
})();
/**
* 事件集合 * 事件集合
* @class BI.Events * @class BI.Events
*/ */

29
bi/widget.js

@ -419,8 +419,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) { if (o.isNeedResizeContainer) {
var isResizing = false; var isResizing = false;
var needEnd = false;
var height; var height;
var interval; var interval;
var startSize;
var resize = function (e, ui) { var resize = function (e, ui) {
if (isResizing) { if (isResizing) {
return; return;
@ -442,20 +444,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20, minHeight: 20,
helper: "bi-resizer", helper: "bi-resizer",
autoHide: true, autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) { resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) { if (ui.size.height >= startSize.height - 10) {
resize(e, ui); resize(e, ui);
} else { } else {
interval && clearInterval(interval); interval && clearInterval(interval);
needEnd = true;
} }
}, },
stop: function (e, ui) { stop: function (e, ui) {
var size = ui.size; var size = ui.size;
if (isResizing) { if (isResizing && !needEnd) {
size.height = height; size.height = height;
} }
self.arrangement.setContainerSize(ui.size); self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false; isResizing = false;
startSize = null;
interval && clearInterval(interval); interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
} }
@ -484,17 +492,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments); return this.arrangement._isEqual.apply(this.arrangement, arguments);
}, },
_initResizable: function (item) { _setSelect: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
if (!item.element.hasClass("selected")) { if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex); item.element.css("zIndex", ++this.zIndex);
BI.each(self.getAllRegions(), function (i, region) { BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected"); region.el.element.removeClass("selected");
}); });
item.element.addClass("selected"); item.element.addClass("selected");
} }
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
}); });
o.resizable && item.element.resizable({ o.resizable && item.element.resizable({
handles: "e, s, se", handles: "e, s, se",
@ -663,6 +675,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) { addRegion: function (region, position) {
this._initResizable(region.el); this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag; var self = this, flag;
var old = this.arrangement.getAllRegions(); var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) { if (BI.isNotNull(this.position)) {

97
dist/core.js vendored

@ -19846,7 +19846,14 @@ BI.PopoverSection = BI.inherit(BI.Widget, {
} }
}); });
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";BI.cjkEncode = function (text) { BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') { if (typeof text !== 'string') {
return text; return text;
@ -19863,9 +19870,9 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";BI.cjkEncode = function (text) {
} }
return newText return newText
}; };
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
$.each(o, function (k, v) { $.each(o, function (k, v) {
@ -19879,9 +19886,9 @@ BI.cjkEncodeDO = function (o) {
return result; return result;
} }
return o; return o;
}; };
BI.jsonEncode = function (o) { BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的 //james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false; var useHasOwn = {}.hasOwnProperty ? true : false;
@ -19977,15 +19984,15 @@ BI.jsonEncode = function (o) {
a.push("}"); a.push("}");
return a.join(""); return a.join("");
} }
}; };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) { if (isEmpty(cv)) {
//原值为空,返回空字符 //原值为空,返回空字符
return ''; return '';
} }
var text = cv.toString(); var text = cv.toString();
if (BI.isEmpty(fmt)) { if (isEmpty(fmt)) {
//格式为空,返回原字符 //格式为空,返回原字符
return text; return text;
} }
@ -20017,9 +20024,9 @@ BI.contentFormat = function (cv, fmt) {
//¤ - 货币格式 //¤ - 货币格式
text = text.replace(/¤/g, '¥'); text = text.replace(/¤/g, '¥');
return text; return text;
}; };
/** /**
* 把日期对象按照指定格式转化成字符串 * 把日期对象按照指定格式转化成字符串
* *
* @example * @example
@ -20031,7 +20038,7 @@ BI.contentFormat = function (cv, fmt) {
* @param format 日期格式 * @param format 日期格式
* @returns {String} * @returns {String}
*/ */
date2Str = function (date, format) { date2Str = function (date, format) {
if (!date) { if (!date) {
return ''; return '';
} }
@ -20135,12 +20142,12 @@ date2Str = function (date, format) {
} }
return str; return str;
} }
}; };
/** /**
* 数字格式 * 数字格式
*/ */
BI._numberFormat = function (text, format) { BI._numberFormat = function (text, format) {
var text = text + ''; var text = text + '';
//数字格式,区分正负数 //数字格式,区分正负数
var numMod = format.indexOf(';'); var numMod = format.indexOf(';');
@ -20179,22 +20186,22 @@ BI._numberFormat = function (text, format) {
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; };
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
* @param fright 右边格式 * @param fright 右边格式
* @returns {JSON} 返回处理结果和整数部分是否需要进位 * @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private * @private
*/ */
BI._dealWithRight = function (tright, fright) { BI._dealWithRight = function (tright, fright) {
var right = '', j = 0, i = 0; var right = '', j = 0, i = 0;
for (var len = fright.length; i < len; i++) { for (var len = fright.length; i < len; i++) {
var ch = fright.charAt(i); var ch = fright.charAt(i);
var c = tright.charAt(j); var c = tright.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
right += c; right += c;
@ -20211,7 +20218,7 @@ BI._dealWithRight = function (tright, fright) {
} }
var rll = tright.substr(j); var rll = tright.substr(j);
var result = {}; var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) { if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入 //有多余字符,需要四舍五入
result.leftPlus = true; result.leftPlus = true;
var numReg = right.match(/^[0-9]+/); var numReg = right.match(/^[0-9]+/);
@ -20231,13 +20238,13 @@ BI._dealWithRight = function (tright, fright) {
} }
result.num = right; result.num = right;
return result; return result;
}; };
BI.parseINT = function (str) { BI.parseINT = function (str) {
return parseInt(str, 10); return parseInt(str, 10);
}; };
BI.leftPad = function (val, size, ch) { BI.leftPad = function (val, size, ch) {
var result = String(val); var result = String(val);
if (!ch) { if (!ch) {
ch = " "; ch = " ";
@ -20246,16 +20253,16 @@ BI.leftPad = function (val, size, ch) {
result = ch + result; result = ch + result;
} }
return result.toString(); return result.toString();
}; };
/** /**
* 处理小数点左边整数部分 * 处理小数点左边整数部分
* @param tleft 左边内容 * @param tleft 左边内容
* @param fleft 左边格式 * @param fleft 左边格式
* @returns {string} 返回处理结果 * @returns {string} 返回处理结果
* @private * @private
*/ */
BI._dealWithLeft = function (tleft, fleft) { BI._dealWithLeft = function (tleft, fleft) {
var left = ''; var left = '';
var j = tleft.length - 1; var j = tleft.length - 1;
var combo = -1, last = -1; var combo = -1, last = -1;
@ -20265,7 +20272,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j); var c = tleft.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
last = -1; last = -1;
@ -20278,7 +20285,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--; j--;
break; break;
case ',': case ',':
if (!BI.isEmpty(c)) { if (!isEmpty(c)) {
//计算一个,分隔区间的长度 //计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/); var com = fleft.match(/,[#0]+/);
if (com) { if (com) {
@ -20307,16 +20314,16 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr; newstr = res.substr(n, combo) + ',' + newstr;
} }
var lres = res.substr(0, n + combo); var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) { if (!isEmpty(lres)) {
newstr = lres + ',' + newstr; newstr = lres + ',' + newstr;
} }
} }
left = left.replace(/[0-9]+,/, newstr); left = left.replace(/[0-9]+,/, newstr);
} }
return left; return left;
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {
if (value == null) { if (value == null) {
return 0; return 0;
} }
@ -20330,9 +20337,9 @@ BI.object2Number = function (value) {
return parseFloat(str); return parseFloat(str);
} }
} }
}; };
BI.object2Date = function (obj) { BI.object2Date = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -20350,13 +20357,13 @@ BI.object2Date = function (obj) {
return new Date(); return new Date();
} }
}; };
BI.isArray = function (a) { BI.isArray = function (a) {
return Object.prototype.toString.call(a) == '[object Array]'; return Object.prototype.toString.call(a) == '[object Array]';
}; };
BI.object2Time = function (obj) { BI.object2Time = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -20381,18 +20388,18 @@ BI.object2Time = function (obj) {
} }
return new Date(); return new Date();
} }
}; };
// 判断是否是无效的日期 // 判断是否是无效的日期
BI.isInvalidDate = function (date) { BI.isInvalidDate = function (date) {
return date == "Invalid Date" || date == "NaN"; return date == "Invalid Date" || date == "NaN";
}; };
/** /**
* 科学计数格式 * 科学计数格式
*/ */
BI._eFormat = function (text, fmt) { BI._eFormat = function (text, fmt) {
var e = fmt.indexOf("E"); var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) { if (/^[0\.-]+$/.test(text)) {
@ -20436,7 +20443,9 @@ BI._eFormat = function (text, fmt) {
} }
} }
return text; return text;
};/** };
})();
/**
* guy * guy
* *
* @class BI.HighlightBehavior * @class BI.HighlightBehavior

29
dist/widget.js vendored

@ -419,8 +419,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) { if (o.isNeedResizeContainer) {
var isResizing = false; var isResizing = false;
var needEnd = false;
var height; var height;
var interval; var interval;
var startSize;
var resize = function (e, ui) { var resize = function (e, ui) {
if (isResizing) { if (isResizing) {
return; return;
@ -442,20 +444,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20, minHeight: 20,
helper: "bi-resizer", helper: "bi-resizer",
autoHide: true, autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) { resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) { if (ui.size.height >= startSize.height - 10) {
resize(e, ui); resize(e, ui);
} else { } else {
interval && clearInterval(interval); interval && clearInterval(interval);
needEnd = true;
} }
}, },
stop: function (e, ui) { stop: function (e, ui) {
var size = ui.size; var size = ui.size;
if (isResizing) { if (isResizing && !needEnd) {
size.height = height; size.height = height;
} }
self.arrangement.setContainerSize(ui.size); self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false; isResizing = false;
startSize = null;
interval && clearInterval(interval); interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
} }
@ -484,17 +492,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments); return this.arrangement._isEqual.apply(this.arrangement, arguments);
}, },
_initResizable: function (item) { _setSelect: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
if (!item.element.hasClass("selected")) { if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex); item.element.css("zIndex", ++this.zIndex);
BI.each(self.getAllRegions(), function (i, region) { BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected"); region.el.element.removeClass("selected");
}); });
item.element.addClass("selected"); item.element.addClass("selected");
} }
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
}); });
o.resizable && item.element.resizable({ o.resizable && item.element.resizable({
handles: "e, s, se", handles: "e, s, se",
@ -663,6 +675,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) { addRegion: function (region, position) {
this._initResizable(region.el); this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag; var self = this, flag;
var old = this.arrangement.getAllRegions(); var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) { if (BI.isNotNull(this.position)) {

96
src/core/alias.js

@ -1,4 +1,11 @@
BI.cjkEncode = function (text) { ;(function () {
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') { if (typeof text !== 'string') {
return text; return text;
@ -15,9 +22,9 @@ BI.cjkEncode = function (text) {
} }
return newText return newText
}; };
BI.cjkEncodeDO = function (o) { BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) { if (BI.isPlainObject(o)) {
var result = {}; var result = {};
$.each(o, function (k, v) { $.each(o, function (k, v) {
@ -31,9 +38,9 @@ BI.cjkEncodeDO = function (o) {
return result; return result;
} }
return o; return o;
}; };
BI.jsonEncode = function (o) { BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的 //james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false; var useHasOwn = {}.hasOwnProperty ? true : false;
@ -129,15 +136,15 @@ BI.jsonEncode = function (o) {
a.push("}"); a.push("}");
return a.join(""); return a.join("");
} }
}; };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (BI.isEmpty(cv)) { if (isEmpty(cv)) {
//原值为空,返回空字符 //原值为空,返回空字符
return ''; return '';
} }
var text = cv.toString(); var text = cv.toString();
if (BI.isEmpty(fmt)) { if (isEmpty(fmt)) {
//格式为空,返回原字符 //格式为空,返回原字符
return text; return text;
} }
@ -169,9 +176,9 @@ BI.contentFormat = function (cv, fmt) {
//¤ - 货币格式 //¤ - 货币格式
text = text.replace(/¤/g, '¥'); text = text.replace(/¤/g, '¥');
return text; return text;
}; };
/** /**
* 把日期对象按照指定格式转化成字符串 * 把日期对象按照指定格式转化成字符串
* *
* @example * @example
@ -183,7 +190,7 @@ BI.contentFormat = function (cv, fmt) {
* @param format 日期格式 * @param format 日期格式
* @returns {String} * @returns {String}
*/ */
date2Str = function (date, format) { date2Str = function (date, format) {
if (!date) { if (!date) {
return ''; return '';
} }
@ -287,12 +294,12 @@ date2Str = function (date, format) {
} }
return str; return str;
} }
}; };
/** /**
* 数字格式 * 数字格式
*/ */
BI._numberFormat = function (text, format) { BI._numberFormat = function (text, format) {
var text = text + ''; var text = text + '';
//数字格式,区分正负数 //数字格式,区分正负数
var numMod = format.indexOf(';'); var numMod = format.indexOf(';');
@ -331,22 +338,22 @@ BI._numberFormat = function (text, format) {
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; };
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
* @param fright 右边格式 * @param fright 右边格式
* @returns {JSON} 返回处理结果和整数部分是否需要进位 * @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private * @private
*/ */
BI._dealWithRight = function (tright, fright) { BI._dealWithRight = function (tright, fright) {
var right = '', j = 0, i = 0; var right = '', j = 0, i = 0;
for (var len = fright.length; i < len; i++) { for (var len = fright.length; i < len; i++) {
var ch = fright.charAt(i); var ch = fright.charAt(i);
var c = tright.charAt(j); var c = tright.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
right += c; right += c;
@ -363,7 +370,7 @@ BI._dealWithRight = function (tright, fright) {
} }
var rll = tright.substr(j); var rll = tright.substr(j);
var result = {}; var result = {};
if (!BI.isEmpty(rll) && rll.charAt(0) > 4) { if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入 //有多余字符,需要四舍五入
result.leftPlus = true; result.leftPlus = true;
var numReg = right.match(/^[0-9]+/); var numReg = right.match(/^[0-9]+/);
@ -383,13 +390,13 @@ BI._dealWithRight = function (tright, fright) {
} }
result.num = right; result.num = right;
return result; return result;
}; };
BI.parseINT = function (str) { BI.parseINT = function (str) {
return parseInt(str, 10); return parseInt(str, 10);
}; };
BI.leftPad = function (val, size, ch) { BI.leftPad = function (val, size, ch) {
var result = String(val); var result = String(val);
if (!ch) { if (!ch) {
ch = " "; ch = " ";
@ -398,16 +405,16 @@ BI.leftPad = function (val, size, ch) {
result = ch + result; result = ch + result;
} }
return result.toString(); return result.toString();
}; };
/** /**
* 处理小数点左边整数部分 * 处理小数点左边整数部分
* @param tleft 左边内容 * @param tleft 左边内容
* @param fleft 左边格式 * @param fleft 左边格式
* @returns {string} 返回处理结果 * @returns {string} 返回处理结果
* @private * @private
*/ */
BI._dealWithLeft = function (tleft, fleft) { BI._dealWithLeft = function (tleft, fleft) {
var left = ''; var left = '';
var j = tleft.length - 1; var j = tleft.length - 1;
var combo = -1, last = -1; var combo = -1, last = -1;
@ -417,7 +424,7 @@ BI._dealWithLeft = function (tleft, fleft) {
var c = tleft.charAt(j); var c = tleft.charAt(j);
switch (ch) { switch (ch) {
case '0': case '0':
if (BI.isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = '0';
} }
last = -1; last = -1;
@ -430,7 +437,7 @@ BI._dealWithLeft = function (tleft, fleft) {
j--; j--;
break; break;
case ',': case ',':
if (!BI.isEmpty(c)) { if (!isEmpty(c)) {
//计算一个,分隔区间的长度 //计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/); var com = fleft.match(/,[#0]+/);
if (com) { if (com) {
@ -459,16 +466,16 @@ BI._dealWithLeft = function (tleft, fleft) {
newstr = res.substr(n, combo) + ',' + newstr; newstr = res.substr(n, combo) + ',' + newstr;
} }
var lres = res.substr(0, n + combo); var lres = res.substr(0, n + combo);
if (!BI.isEmpty(lres)) { if (!isEmpty(lres)) {
newstr = lres + ',' + newstr; newstr = lres + ',' + newstr;
} }
} }
left = left.replace(/[0-9]+,/, newstr); left = left.replace(/[0-9]+,/, newstr);
} }
return left; return left;
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {
if (value == null) { if (value == null) {
return 0; return 0;
} }
@ -482,9 +489,9 @@ BI.object2Number = function (value) {
return parseFloat(str); return parseFloat(str);
} }
} }
}; };
BI.object2Date = function (obj) { BI.object2Date = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -502,13 +509,13 @@ BI.object2Date = function (obj) {
return new Date(); return new Date();
} }
}; };
BI.isArray = function (a) { BI.isArray = function (a) {
return Object.prototype.toString.call(a) == '[object Array]'; return Object.prototype.toString.call(a) == '[object Array]';
}; };
BI.object2Time = function (obj) { BI.object2Time = function (obj) {
if (obj == null) { if (obj == null) {
return new Date(); return new Date();
} }
@ -533,18 +540,18 @@ BI.object2Time = function (obj) {
} }
return new Date(); return new Date();
} }
}; };
// 判断是否是无效的日期 // 判断是否是无效的日期
BI.isInvalidDate = function (date) { BI.isInvalidDate = function (date) {
return date == "Invalid Date" || date == "NaN"; return date == "Invalid Date" || date == "NaN";
}; };
/** /**
* 科学计数格式 * 科学计数格式
*/ */
BI._eFormat = function (text, fmt) { BI._eFormat = function (text, fmt) {
var e = fmt.indexOf("E"); var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1); var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) { if (/^[0\.-]+$/.test(text)) {
@ -588,4 +595,5 @@ BI._eFormat = function (text, fmt) {
} }
} }
return text; return text;
}; };
})();

29
src/widget/adaptivearrangement/adaptivearrangement.js

@ -37,8 +37,10 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
if (o.isNeedResizeContainer) { if (o.isNeedResizeContainer) {
var isResizing = false; var isResizing = false;
var needEnd = false;
var height; var height;
var interval; var interval;
var startSize;
var resize = function (e, ui) { var resize = function (e, ui) {
if (isResizing) { if (isResizing) {
return; return;
@ -60,20 +62,26 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
minHeight: 20, minHeight: 20,
helper: "bi-resizer", helper: "bi-resizer",
autoHide: true, autoHide: true,
start: function (e, ui) {
startSize = BI.clone(ui.size);
},
resize: function (e, ui) { resize: function (e, ui) {
if (ui.size.height >= self.arrangement.container.element.height()) { if (ui.size.height >= startSize.height - 10) {
resize(e, ui); resize(e, ui);
} else { } else {
interval && clearInterval(interval); interval && clearInterval(interval);
needEnd = true;
} }
}, },
stop: function (e, ui) { stop: function (e, ui) {
var size = ui.size; var size = ui.size;
if (isResizing) { if (isResizing && !needEnd) {
size.height = height; size.height = height;
} }
self.arrangement.setContainerSize(ui.size); self.arrangement.setContainerSize(ui.size);
needEnd = false;
isResizing = false; isResizing = false;
startSize = null;
interval && clearInterval(interval); interval && clearInterval(interval);
self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE);
} }
@ -102,17 +110,21 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
return this.arrangement._isEqual.apply(this.arrangement, arguments); return this.arrangement._isEqual.apply(this.arrangement, arguments);
}, },
_initResizable: function (item) { _setSelect: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
if (!item.element.hasClass("selected")) { if (!item.element.hasClass("selected")) {
item.element.css("zIndex", ++self.zIndex); item.element.css("zIndex", ++this.zIndex);
BI.each(self.getAllRegions(), function (i, region) { BI.each(this.getAllRegions(), function (i, region) {
region.el.element.removeClass("selected"); region.el.element.removeClass("selected");
}); });
item.element.addClass("selected"); item.element.addClass("selected");
} }
},
_initResizable: function (item) {
var self = this, o = this.options;
item.element.css("zIndex", ++this.zIndex);
item.element.mousedown(function () {
self._setSelect(item)
}); });
o.resizable && item.element.resizable({ o.resizable && item.element.resizable({
handles: "e, s, se", handles: "e, s, se",
@ -281,6 +293,7 @@ BI.AdaptiveArrangement = BI.inherit(BI.Widget, {
addRegion: function (region, position) { addRegion: function (region, position) {
this._initResizable(region.el); this._initResizable(region.el);
this._setSelect(region.el);
var self = this, flag; var self = this, flag;
var old = this.arrangement.getAllRegions(); var old = this.arrangement.getAllRegions();
if (BI.isNotNull(this.position)) { if (BI.isNotNull(this.position)) {

Loading…
Cancel
Save