guy 7 years ago
parent
commit
306fbea7a4
  1. 20047
      dist/bundle.js
  2. 4
      dist/bundle.min.js
  3. 22289
      dist/core.js
  4. 14
      src/core/action/action.js
  5. 12
      src/core/adapter/adapter.floatsection.js
  6. 396
      src/core/alias.js
  7. 188
      src/core/base.js
  8. 4
      src/core/behavior/behavior.highlight.js
  9. 14
      src/core/behavior/behavior.js
  10. 10
      src/core/behavior/behavior.redmark.js
  11. 8
      src/core/controller.js
  12. 2
      src/core/controller/controller.broadcast.js
  13. 4
      src/core/controller/controller.floatbox.js
  14. 2
      src/core/controller/controller.layer.js
  15. 6
      src/core/controller/controller.resizer.js
  16. 4
      src/core/controller/controller.tooltips.js
  17. 130
      src/core/events.js
  18. 52
      src/core/func/dom.js
  19. 39
      src/core/func/function.js
  20. 31
      src/core/inject.js
  21. 18746
      src/core/jquery.js
  22. 2
      src/core/listener/listener.show.js
  23. 6
      src/core/loader/loader.style.js
  24. 2
      src/core/logic/logic.js
  25. 8
      src/core/logic/logic.layout.js
  26. 14
      src/core/ob.js
  27. 5
      src/core/plugin.js
  28. 78
      src/core/proto/date.js
  29. 4
      src/core/proto/function.js
  30. 35
      src/core/proto/jquery.js
  31. 80
      src/core/proto/number.js
  32. 8
      src/core/proto/string.js
  33. 456
      src/core/underscore.js
  34. 2
      src/core/utils/aspect.js
  35. 4
      src/core/utils/base64.js
  36. 6
      src/core/utils/cache.js
  37. 52
      src/core/utils/cellSizeAndPositionManager.js
  38. 752
      src/core/utils/chinesePY.js
  39. 87
      src/core/utils/detectElementResize.js
  40. 24
      src/core/utils/events/eventlistener.js
  41. 10
      src/core/utils/events/mousemovetracker.js
  42. 36
      src/core/utils/events/wheelhandler.js
  43. 6
      src/core/utils/heap.js
  44. 14
      src/core/utils/helper.scroll.js
  45. 22
      src/core/utils/integerBufferSet.js
  46. 10
      src/core/utils/linkedHashMap.js
  47. 24
      src/core/utils/load.js
  48. 14
      src/core/utils/lru.js
  49. 13
      src/core/utils/md5.js
  50. 16
      src/core/utils/prefixIntervalTree.js
  51. 14
      src/core/utils/queue.js
  52. 16
      src/core/utils/sectionManager.js
  53. 16
      src/core/utils/tableRowBuffer.js
  54. 38
      src/core/utils/tree.js
  55. 12
      src/core/utils/vector.js
  56. 102
      src/core/var.js
  57. 20
      src/core/widget.js
  58. 58
      src/core/wrapper/layout.js
  59. 14
      src/core/wrapper/layout/adapt/absolute.center.js
  60. 10
      src/core/wrapper/layout/adapt/absolute.horizontal.js
  61. 14
      src/core/wrapper/layout/adapt/absolute.vertical.js
  62. 34
      src/core/wrapper/layout/adapt/adapt.center.js
  63. 28
      src/core/wrapper/layout/adapt/adapt.horizontal.js
  64. 18
      src/core/wrapper/layout/adapt/adapt.leftrightvertical.js
  65. 32
      src/core/wrapper/layout/adapt/adapt.vertical.js
  66. 14
      src/core/wrapper/layout/adapt/auto.horizontal.js
  67. 6
      src/core/wrapper/layout/adapt/float.center.js
  68. 2
      src/core/wrapper/layout/adapt/float.horizontal.js
  69. 4
      src/core/wrapper/layout/flex/flex.center.js
  70. 12
      src/core/wrapper/layout/flex/flex.horizontal.js
  71. 12
      src/core/wrapper/layout/flex/flex.vertical.center.js
  72. 6
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js
  73. 14
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js
  74. 12
      src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js
  75. 34
      src/core/wrapper/layout/layout.absolute.js
  76. 32
      src/core/wrapper/layout/layout.adaptive.js
  77. 40
      src/core/wrapper/layout/layout.border.js
  78. 30
      src/core/wrapper/layout/layout.card.js
  79. 10
      src/core/wrapper/layout/layout.default.js
  80. 30
      src/core/wrapper/layout/layout.division.js
  81. 20
      src/core/wrapper/layout/layout.flow.js
  82. 28
      src/core/wrapper/layout/layout.grid.js
  83. 42
      src/core/wrapper/layout/layout.horizontal.js
  84. 8
      src/core/wrapper/layout/layout.lattice.js
  85. 30
      src/core/wrapper/layout/layout.table.js
  86. 48
      src/core/wrapper/layout/layout.tape.js
  87. 42
      src/core/wrapper/layout/layout.td.js
  88. 12
      src/core/wrapper/layout/layout.vertical.js
  89. 40
      src/core/wrapper/layout/layout.window.js
  90. 6
      src/core/wrapper/layout/middle/middle.center.js
  91. 8
      src/core/wrapper/layout/middle/middle.float.center.js
  92. 8
      src/core/wrapper/layout/middle/middle.horizontal.js
  93. 8
      src/core/wrapper/layout/middle/middle.vertical.js

20047
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

4
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

22289
dist/core.js vendored

File diff suppressed because one or more lines are too long

14
src/core/action/action.js

@ -6,34 +6,34 @@
* @abstract * @abstract
*/ */
BI.Action = BI.inherit(BI.OB, { BI.Action = BI.inherit(BI.OB, {
_defaultConfig: function() { _defaultConfig: function () {
return BI.extend(BI.Action.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.Action.superclass._defaultConfig.apply(this, arguments), {
src: null, src: null,
tar: null tar: null
}); });
}, },
_init : function() { _init: function () {
BI.Action.superclass._init.apply(this, arguments); BI.Action.superclass._init.apply(this, arguments);
}, },
actionPerformed: function(src, tar, callback){ actionPerformed: function (src, tar, callback) {
}, },
actionBack: function(tar, src, callback){ actionBack: function (tar, src, callback) {
} }
}); });
BI.ActionFactory = { BI.ActionFactory = {
createAction: function(key, options){ createAction: function (key, options) {
var action; var action;
switch (key){ switch (key) {
case "show": case "show":
action = BI.ShowAction; action = BI.ShowAction;
break; break;
} }
return new action(options); return new action(options);
} }
} };

12
src/core/adapter/adapter.floatsection.js

@ -5,21 +5,21 @@
* @abstract * @abstract
*/ */
BI.PopoverSection = BI.inherit(BI.Widget, { BI.PopoverSection = BI.inherit(BI.Widget, {
_init : function() { _init: function () {
BI.PopoverSection.superclass._init.apply(this, arguments); BI.PopoverSection.superclass._init.apply(this, arguments);
}, },
rebuildNorth : function(north) { rebuildNorth: function (north) {
return true; return true;
}, },
rebuildCenter : function(center) {}, rebuildCenter: function (center) {},
rebuildSouth : function(south) { rebuildSouth: function (south) {
return false; return false;
}, },
close: function(){ close: function () {
this.fireEvent(BI.PopoverSection.EVENT_CLOSE); this.fireEvent(BI.PopoverSection.EVENT_CLOSE);
}, },
end: function(){ end: function () {
} }
}); });

396
src/core/alias.js

@ -1,41 +1,41 @@
;(function () { (function () {
if (!window.BI) { if (!window.BI) {
window.BI = {}; window.BI = {};
} }
function isEmpty(value) { function isEmpty (value) {
// 判断是否为空值 // 判断是否为空值
var result = value === "" || value === null || value === undefined; var result = value === "" || value === null || value === undefined;
return result; return result;
} }
// 判断是否是无效的日期 // 判断是否是无效的日期
function isInvalidDate(date) { function isInvalidDate (date) {
return date == "Invalid Date" || date == "NaN"; return date == "Invalid Date" || date == "NaN";
} }
/** /**
* 科学计数格式 * 科学计数格式
*/ */
function _eFormat(text, fmt) { function _eFormat (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)) {
text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright) text = BI._numberFormat(0.0, eleft) + "E" + BI._numberFormat(0, eright);
} else { } else {
var isNegative = text < 0; var isNegative = text < 0;
if (isNegative) { if (isNegative) {
text = text.substr(1); text = text.substr(1);
} }
var elvl = (eleft.split('.')[0] || '').length; var elvl = (eleft.split(".")[0] || "").length;
var point = text.indexOf("."); var point = text.indexOf(".");
if (point < 0) { if (point < 0) {
point = text.length; point = text.length;
} }
var i = 0; //第一个不为0的数的位置 var i = 0; // 第一个不为0的数的位置
text = text.replace('.', ''); text = text.replace(".", "");
for (var len = text.length; i < len; i++) { for (var len = text.length; i < len; i++) {
var ech = text.charAt(i); var ech = text.charAt(i);
if (ech <= '9' && ech >= '1') { if (ech <= "9" && ech >= "1") {
break; break;
} }
} }
@ -43,20 +43,20 @@
var left = text.substr(i, elvl); var left = text.substr(i, elvl);
var dis = i + elvl - text.length; var dis = i + elvl - text.length;
if (dis > 0) { if (dis > 0) {
//末位补全0 // 末位补全0
for (var k = 0; k < dis; k++) { for (var k = 0; k < dis; k++) {
left += '0'; left += "0";
} }
} else { } else {
left += '.' + text.substr(i + elvl); left += "." + text.substr(i + elvl);
} }
left = left.replace(/^[0]+/, ''); left = left.replace(/^[0]+/, "");
if (right < 0 && eright.indexOf('-') < 0) { if (right < 0 && eright.indexOf("-") < 0) {
eright += ';-' + eright; eright += ";-" + eright;
} }
text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright); text = BI._numberFormat(left, eleft) + "E" + BI._numberFormat(right, eright);
if (isNegative) { if (isNegative) {
text = '-' + text; text = "-" + text;
} }
} }
return text; return text;
@ -65,50 +65,50 @@
/** /**
* 数字格式 * 数字格式
*/ */
function _numberFormat(text, format) { function _numberFormat (text, format) {
var text = text + ''; var text = text + "";
//数字格式,区分正负数 // 数字格式,区分正负数
var numMod = format.indexOf(';'); var numMod = format.indexOf(";");
if (numMod > -1) { if (numMod > -1) {
if (text >= 0) { if (text >= 0) {
return _numberFormat(text + "", format.substring(0, numMod)); return _numberFormat(text + "", format.substring(0, numMod));
} else {
return _numberFormat((-text) + "", format.substr(numMod + 1));
}
} else {
//兼容格式处理负数的情况(copy:fr-jquery.format.js)
if (+text < 0 && format.charAt(0) !== '-') {
return _numberFormat((-text) + "", '-' + format);
} }
return _numberFormat((-text) + "", format.substr(numMod + 1));
} }
var tp = text.split('.'), fp = format.split('.'), // 兼容格式处理负数的情况(copy:fr-jquery.format.js)
tleft = tp[0] || '', fleft = fp[0] || '', if (+text < 0 && format.charAt(0) !== "-") {
tright = tp[1] || '', fright = fp[1] || ''; return _numberFormat((-text) + "", "-" + format);
//百分比,千分比的小数点移位处理 }
var tp = text.split("."), fp = format.split("."),
tleft = tp[0] || "", fleft = fp[0] || "",
tright = tp[1] || "", fright = fp[1] || "";
// 百分比,千分比的小数点移位处理
if (/[%‰]$/.test(format)) { if (/[%‰]$/.test(format)) {
var paddingZero = /[%]$/.test(format) ? '00' : '000'; var paddingZero = /[%]$/.test(format) ? "00" : "000";
tright += paddingZero; tright += paddingZero;
tleft += tright.substr(0, paddingZero.length); tleft += tright.substr(0, paddingZero.length);
tleft = tleft.replace(/^0+/gi, ''); tleft = tleft.replace(/^0+/gi, "");
tright = tright.substr(paddingZero.length).replace(/0+$/gi, ''); tright = tright.substr(paddingZero.length).replace(/0+$/gi, "");
} }
var right = _dealWithRight(tright, fright); var right = _dealWithRight(tright, fright);
if (right.leftPlus) { if (right.leftPlus) {
//小数点后有进位 // 小数点后有进位
tleft = parseInt(tleft) + 1 + ''; tleft = parseInt(tleft) + 1 + "";
tleft = isNaN(tleft) ? '1' : tleft; tleft = isNaN(tleft) ? "1" : tleft;
} }
right = right.num; right = right.num;
var left = _dealWithLeft(tleft, fleft); var left = _dealWithLeft(tleft, fleft);
if (!(/[0-9]/.test(left))) { if (!(/[0-9]/.test(left))) {
left = left + '0'; left = left + "0";
} }
if (!(/[0-9]/.test(right))) { if (!(/[0-9]/.test(right))) {
return left + right; return left + right;
} else {
return left + '.' + right;
} }
return left + "." + right;
} }
/** /**
@ -118,20 +118,20 @@
* @returns {JSON} 返回处理结果和整数部分是否需要进位 * @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private * @private
*/ */
function _dealWithRight(tright, fright) { function _dealWithRight (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 (isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = "0";
} }
right += c; right += c;
j++; j++;
break; break;
case '#': case "#":
right += c; right += c;
j++; j++;
break; break;
@ -143,18 +143,18 @@
var rll = tright.substr(j); var rll = tright.substr(j);
var result = {}; var result = {};
if (!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]+/);
if (numReg) { if (numReg) {
var num = numReg[0]; var num = numReg[0];
var orilen = num.length; var orilen = num.length;
var newnum = parseInt(num) + 1 + ''; var newnum = parseInt(num) + 1 + "";
//进位到整数部分 // 进位到整数部分
if (newnum.length > orilen) { if (newnum.length > orilen) {
newnum = newnum.substr(1); newnum = newnum.substr(1);
} else { } else {
newnum = String.leftPad(newnum, orilen, '0'); newnum = String.leftPad(newnum, orilen, "0");
result.leftPlus = false; result.leftPlus = false;
} }
right = right.replace(/^[0-9]+/, newnum); right = right.replace(/^[0-9]+/, newnum);
@ -171,8 +171,8 @@
* @returns {string} 返回处理结果 * @returns {string} 返回处理结果
* @private * @private
*/ */
function _dealWithLeft(tleft, fleft) { function _dealWithLeft (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;
var i = fleft.length - 1; var i = fleft.length - 1;
@ -180,27 +180,27 @@
var ch = fleft.charAt(i); var ch = fleft.charAt(i);
var c = tleft.charAt(j); var c = tleft.charAt(j);
switch (ch) { switch (ch) {
case '0': case "0":
if (isEmpty(c)) { if (isEmpty(c)) {
c = '0'; c = "0";
} }
last = -1; last = -1;
left = c + left; left = c + left;
j--; j--;
break; break;
case '#': case "#":
last = i; last = i;
left = c + left; left = c + left;
j--; j--;
break; break;
case ',': case ",":
if (!isEmpty(c)) { if (!isEmpty(c)) {
//计算一个,分隔区间的长度 // 计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/); var com = fleft.match(/,[#0]+/);
if (com) { if (com) {
combo = com[0].length - 1; combo = com[0].length - 1;
} }
left = ',' + left; left = "," + left;
} }
break; break;
default : default :
@ -209,22 +209,22 @@
} }
} }
if (last > -1) { if (last > -1) {
//处理剩余字符 // 处理剩余字符
var tll = tleft.substr(0, j + 1); var tll = tleft.substr(0, j + 1);
left = left.substr(0, last) + tll + left.substr(last); left = left.substr(0, last) + tll + left.substr(last);
} }
if (combo > 0) { if (combo > 0) {
//处理,分隔区间 // 处理,分隔区间
var res = left.match(/[0-9]+,/); var res = left.match(/[0-9]+,/);
if (res) { if (res) {
res = res[0]; res = res[0];
var newstr = '', n = res.length - 1 - combo; var newstr = "", n = res.length - 1 - combo;
for (; n >= 0; n = n - combo) { for (; n >= 0; n = n - combo) {
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 (!isEmpty(lres)) { if (!isEmpty(lres)) {
newstr = lres + ',' + newstr; newstr = lres + "," + newstr;
} }
} }
left = left.replace(/[0-9]+,/, newstr); left = left.replace(/[0-9]+,/, newstr);
@ -234,21 +234,21 @@
BI.cjkEncode = function (text) { BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的) // alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') { if (typeof text !== "string") {
return text; return text;
} }
var newText = ""; var newText = "";
for (var i = 0; i < text.length; i++) { for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt(i); var code = text.charCodeAt(i);
if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]". if (code >= 128 || code === 91 || code === 93) {// 91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]"; newText += "[" + code.toString(16) + "]";
} else { } else {
newText += text.charAt(i); newText += text.charAt(i);
} }
} }
return newText return newText;
}; };
/** /**
@ -262,19 +262,19 @@
if (text == null) { if (text == null) {
return ""; return "";
} }
//查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回. // 查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf('[') == -1) { if (!isNaN(text) || text.indexOf("[") == -1) {
return text; return text;
} }
var newText = ""; var newText = "";
for (var i = 0; i < text.length; i++) { for (var i = 0; i < text.length; i++) {
var ch = text.charAt(i); var ch = text.charAt(i);
if (ch == '[') { if (ch == "[") {
var rightIdx = text.indexOf(']', i + 1); var rightIdx = text.indexOf("]", i + 1);
if (rightIdx > i + 1) { if (rightIdx > i + 1) {
var subText = text.substring(i + 1, rightIdx); var subText = text.substring(i + 1, rightIdx);
//james:主要是考虑[CDATA[]]这样的值的出现 // james:主要是考虑[CDATA[]]这样的值的出现
if (subText.length > 0) { if (subText.length > 0) {
ch = String.fromCharCode(eval("0x" + subText)); ch = String.fromCharCode(eval("0x" + subText));
} }
@ -289,23 +289,23 @@
return newText; return newText;
}; };
//replace the html special tags // replace the html special tags
BI.htmlEncode = function (text) { BI.htmlEncode = function (text) {
return (text == null) ? '' : String(text).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); return (text == null) ? "" : String(text).replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}; };
//html decode // html decode
BI.htmlDecode = function (text) { BI.htmlDecode = function (text) {
return (text == null) ? '' : String(text).replace(/&amp;/g, '&').replace(/&quot;/g, '\"').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&nbsp;/g, ' '); return (text == null) ? "" : String(text).replace(/&amp;/g, "&").replace(/&quot;/g, "\"").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ");
}; };
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) {
if (!(typeof v == "string")) { if (!(typeof v === "string")) {
v = BI.jsonEncode(v); v = BI.jsonEncode(v);
} }
//wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。 // wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。
k = BI.cjkEncode(k); k = BI.cjkEncode(k);
result[k] = BI.cjkEncode(v); result[k] = BI.cjkEncode(v);
}); });
@ -315,36 +315,36 @@
}; };
BI.jsonEncode = function (o) { BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的 // james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false; var useHasOwn = !!{}.hasOwnProperty;
// crashes Safari in some instances // crashes Safari in some instances
//var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/; // var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/;
var m = { var m = {
"\b": '\\b', "\b": "\\b",
"\t": '\\t', "\t": "\\t",
"\n": '\\n', "\n": "\\n",
"\f": '\\f', "\f": "\\f",
"\r": '\\r', "\r": "\\r",
'"': '\\"', "\"": "\\\"",
"\\": '\\\\' "\\": "\\\\"
}; };
var encodeString = function (s) { var encodeString = function (s) {
if (/["\\\x00-\x1f]/.test(s)) { if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) { return "\"" + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
var c = m[b]; var c = m[b];
if (c) { if (c) {
return c; return c;
} }
c = b.charCodeAt(); c = b.charCodeAt();
return "\\u00" + return "\\u00" +
Math.floor(c / 16).toString(16) + Math.floor(c / 16).toString(16) +
(c % 16).toString(16); (c % 16).toString(16);
}) + '"'; }) + "\"";
} }
return '"' + s + '"'; return "\"" + s + "\"";
}; };
var encodeArray = function (o) { var encodeArray = function (o) {
@ -358,7 +358,7 @@
break; break;
default: default:
if (b) { if (b) {
a.push(','); a.push(",");
} }
a.push(v === null ? "null" : BI.jsonEncode(v)); a.push(v === null ? "null" : BI.jsonEncode(v));
b = true; b = true;
@ -368,7 +368,7 @@
return a.join(""); return a.join("");
}; };
if (typeof o == "undefined" || o === null) { if (typeof o === "undefined" || o === null) {
return "null"; return "null";
} else if (BI.isArray(o)) { } else if (BI.isArray(o)) {
return encodeArray(o); return encodeArray(o);
@ -379,44 +379,44 @@
*/ */
return BI.jsonEncode({ return BI.jsonEncode({
__time__: o.getTime() __time__: o.getTime()
}) });
} else if (typeof o == "string") { } else if (typeof o === "string") {
return encodeString(o); return encodeString(o);
} else if (typeof o == "number") { } else if (typeof o === "number") {
return isFinite(o) ? String(o) : "null"; return isFinite(o) ? String(o) : "null";
} else if (typeof o == "boolean") { } else if (typeof o === "boolean") {
return String(o); return String(o);
} else if (BI.isFunction(o)) { } else if (BI.isFunction(o)) {
return String(o); return String(o);
} else { }
var a = ["{"], b, i, v; var a = ["{"], b, i, v;
for (i in o) { for (i in o) {
if (!useHasOwn || o.hasOwnProperty(i)) { if (!useHasOwn || o.hasOwnProperty(i)) {
v = o[i]; v = o[i];
switch (typeof v) { switch (typeof v) {
case "undefined": case "undefined":
case "unknown": case "unknown":
break; break;
default: default:
if (b) { if (b) {
a.push(','); a.push(",");
} }
a.push(BI.jsonEncode(i), ":", a.push(BI.jsonEncode(i), ":",
v === null ? "null" : BI.jsonEncode(v)); v === null ? "null" : BI.jsonEncode(v));
b = true; b = true;
}
} }
} }
a.push("}");
return a.join("");
} }
a.push("}");
return a.join("");
}; };
BI.jsonDecode = function (text) { BI.jsonDecode = function (text) {
try { try {
// 注意0啊 // 注意0啊
//var jo = $.parseJSON(text) || {}; // var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text); var jo = $.parseJSON(text);
if (jo == null) { if (jo == null) {
jo = {}; jo = {};
@ -429,7 +429,7 @@
try { try {
jo = new Function("return " + text)() || {}; jo = new Function("return " + text)() || {};
} catch (e) { } catch (e) {
//do nothing // do nothing
} }
if (jo == null) { if (jo == null) {
jo = []; jo = [];
@ -439,7 +439,7 @@
return jo; return jo;
} }
function _hasDateInJson(json) { function _hasDateInJson (json) {
if (!json || typeof json !== "string") { if (!json || typeof json !== "string") {
return false; return false;
} }
@ -454,7 +454,7 @@
return new Date(o.__time__); return new Date(o.__time__);
} }
for (var a in o) { for (var a in o) {
if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) { if (o[a] == o || typeof o[a] === "object" || $.isFunction(o[a])) {
break; break;
} }
o[a] = arguments.callee(o[a]); o[a] = arguments.callee(o[a]);
@ -466,25 +466,25 @@
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) { if (isEmpty(cv)) {
//原值为空,返回空字符 // 原值为空,返回空字符
return ''; return "";
} }
var text = cv.toString(); var text = cv.toString();
if (isEmpty(fmt)) { if (isEmpty(fmt)) {
//格式为空,返回原字符 // 格式为空,返回原字符
return text; return text;
} }
if (fmt.match(/^T/)) { if (fmt.match(/^T/)) {
//T - 文本格式 // T - 文本格式
return text; return text;
} else if (fmt.match(/^D/)) { } else if (fmt.match(/^D/)) {
//D - 日期(时间)格式 // D - 日期(时间)格式
if (!(cv instanceof Date)) { if (!(cv instanceof Date)) {
if (typeof cv === 'number') { if (typeof cv === "number") {
//毫秒数类型 // 毫秒数类型
cv = new Date(cv); cv = new Date(cv);
} else { } else {
//字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构 // 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long); cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long);
} }
} }
@ -493,14 +493,14 @@
text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1)); text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1));
} }
} else if (fmt.match(/E/)) { } else if (fmt.match(/E/)) {
//科学计数格式 // 科学计数格式
text = _eFormat(text, fmt); text = _eFormat(text, fmt);
} else { } else {
//数字格式 // 数字格式
text = _numberFormat(text, fmt); text = _numberFormat(text, fmt);
} }
//¤ - 货币格式 // ¤ - 货币格式
text = text.replace(/¤/g, '¥'); text = text.replace(/¤/g, "¥");
return text; return text;
}; };
@ -518,19 +518,19 @@
*/ */
BI.date2Str = function (date, format) { BI.date2Str = function (date, format) {
if (!date) { if (!date) {
return ''; return "";
} }
// O(len(format)) // O(len(format))
var len = format.length, result = ''; var len = format.length, result = "";
if (len > 0) { if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch; var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) { for (var i = 1; i < len; i++) {
var ch = format.charAt(i); var ch = format.charAt(i);
if (flagch !== ch) { if (flagch !== ch) {
result += compileJFmt({ result += compileJFmt({
'char': flagch, char: flagch,
'str': str, str: str,
'len': i - start len: i - start
}, date); }, date);
flagch = ch; flagch = ch;
start = i; start = i;
@ -540,78 +540,78 @@
} }
} }
result += compileJFmt({ result += compileJFmt({
'char': flagch, char: flagch,
'str': str, str: str,
'len': len - start len: len - start
}, date); }, date);
} }
return result; return result;
function compileJFmt(jfmt, date) { function compileJFmt (jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; var str = jfmt.str, len = jfmt.len, ch = jfmt["char"];
switch (ch) { switch (ch) {
case 'E': //星期 case "E": // 星期
str = Date._DN[date.getDay()]; str = Date._DN[date.getDay()];
break; break;
case 'y': //年 case "y": //
if (len <= 3) { if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4); str = (date.getFullYear() + "").slice(2, 4);
} else { } else {
str = date.getFullYear(); str = date.getFullYear();
} }
break; break;
case 'M': //月 case "M": //
if (len > 2) { if (len > 2) {
str = Date._MN[date.getMonth()]; str = Date._MN[date.getMonth()];
} else if (len < 2) { } else if (len < 2) {
str = date.getMonth() + 1; str = date.getMonth() + 1;
} else { } else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); str = String.leftPad(date.getMonth() + 1 + "", 2, "0");
} }
break; break;
case 'd': //日 case "d": //
if (len > 1) { if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0'); str = String.leftPad(date.getDate() + "", 2, "0");
} else { } else {
str = date.getDate(); str = date.getDate();
} }
break; break;
case 'h': //时(12) case "h": // 时(12)
var hour = date.getHours() % 12; var hour = date.getHours() % 12;
if (hour === 0) { if (hour === 0) {
hour = 12; hour = 12;
} }
if (len > 1) { if (len > 1) {
str = String.leftPad(hour + '', 2, '0'); str = String.leftPad(hour + "", 2, "0");
} else { } else {
str = hour; str = hour;
} }
break; break;
case 'H': //时(24) case "H": // 时(24)
if (len > 1) { if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0'); str = String.leftPad(date.getHours() + "", 2, "0");
} else { } else {
str = date.getHours(); str = date.getHours();
} }
break; break;
case 'm': case "m":
if (len > 1) { if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0'); str = String.leftPad(date.getMinutes() + "", 2, "0");
} else { } else {
str = date.getMinutes(); str = date.getMinutes();
} }
break; break;
case 's': case "s":
if (len > 1) { if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0'); str = String.leftPad(date.getSeconds() + "", 2, "0");
} else { } else {
str = date.getSeconds(); str = date.getSeconds();
} }
break; break;
case 'a': case "a":
str = date.getHours() < 12 ? 'am' : 'pm'; str = date.getHours() < 12 ? "am" : "pm";
break; break;
case 'z': case "z":
str = date.getTimezone(); str = date.getTimezone();
break; break;
default: default:
@ -626,16 +626,16 @@
if (value == null) { if (value == null) {
return 0; return 0;
} }
if (typeof value == 'number') { if (typeof value === "number") {
return value; return value;
} else {
var str = value + "";
if (str.indexOf(".") === -1) {
return parseInt(str);
} else {
return parseFloat(str);
}
} }
var str = value + "";
if (str.indexOf(".") === -1) {
return parseInt(str);
}
return parseFloat(str);
}; };
BI.object2Date = function (obj) { BI.object2Date = function (obj) {
@ -644,18 +644,18 @@
} }
if (obj instanceof Date) { if (obj instanceof Date) {
return obj; return obj;
} else if (typeof obj == 'number') { } else if (typeof obj === "number") {
return new Date(obj); return new Date(obj);
} else {
var str = obj + "";
str = str.replace(/-/g, '/');
var dt = new Date(str);
if (!isInvalidDate(dt)) {
return dt;
}
return new Date();
} }
var str = obj + "";
str = str.replace(/-/g, "/");
var dt = new Date(str);
if (!isInvalidDate(dt)) {
return dt;
}
return new Date();
}; };
BI.object2Time = function (obj) { BI.object2Time = function (obj) {
@ -664,24 +664,24 @@
} }
if (obj instanceof Date) { if (obj instanceof Date) {
return obj; return obj;
} else { }
var str = obj + ""; var str = obj + "";
str = str.replace(/-/g, '/'); str = str.replace(/-/g, "/");
var dt = new Date(str); var dt = new Date(str);
if (!isInvalidDate(dt)) { if (!isInvalidDate(dt)) {
return dt; return dt;
} }
if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) { if (str.indexOf("/") === -1 && str.indexOf(":") !== -1) {
dt = new Date("1970/01/01 " + str); dt = new Date("1970/01/01 " + str);
if (!isInvalidDate(dt)) {
return dt;
}
}
dt = BI.str2Date(str, "HH:mm:ss");
if (!isInvalidDate(dt)) { if (!isInvalidDate(dt)) {
return dt; return dt;
} }
return new Date();
} }
dt = BI.str2Date(str, "HH:mm:ss");
if (!isInvalidDate(dt)) {
return dt;
}
return new Date();
}; };
})(); })();

188
src/core/base.js

@ -7,27 +7,27 @@
if (!window.BI) { if (!window.BI) {
window.BI = {}; window.BI = {};
} }
;
!(function ($, undefined) { !(function ($, undefined) {
var traverse = function (func, context) { var traverse = function (func, context) {
return function (value, key, obj) { return function (value, key, obj) {
return func.call(context, key, value, obj); return func.call(context, key, value, obj);
} };
}; };
var _apply = function (name) { var _apply = function (name) {
return function () { return function () {
return _[name].apply(_, arguments); return _[name].apply(_, arguments);
} };
}; };
var _applyFunc = function (name) { var _applyFunc = function (name) {
return function () { return function () {
var args = Array.prototype.slice.call(arguments, 0); var args = Array.prototype.slice.call(arguments, 0);
args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1]; args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
return _[name].apply(_, args); return _[name].apply(_, args);
} };
}; };
//Utility // Utility
_.extend(BI, { _.extend(BI, {
i18nText: function (key) { i18nText: function (key) {
var localeText = (BI.i18n && BI.i18n[key]) || ""; var localeText = (BI.i18n && BI.i18n[key]) || "";
@ -61,11 +61,11 @@ if (!window.BI) {
}, },
warn: function (message) { warn: function (message) {
console.warn(message) console.warn(message);
}, },
UUID: function () { UUID: function () {
var f = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; var f = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
var str = ""; var str = "";
for (var i = 0; i < 16; i++) { for (var i = 0; i < 16; i++) {
var r = parseInt(f.length * Math.random(), 10); var r = parseInt(f.length * Math.random(), 10);
@ -80,7 +80,7 @@ if (!window.BI) {
createWidgets: function (items, options) { createWidgets: function (items, options) {
if (!BI.isArray(items)) { if (!BI.isArray(items)) {
throw new Error("cannot create Widgets") throw new Error("cannot create Widgets");
} }
return BI.map(BI.flatten(items), function (i, item) { return BI.map(BI.flatten(items), function (i, item) {
return BI.createWidget(item, BI.deepClone(options)); return BI.createWidget(item, BI.deepClone(options));
@ -104,7 +104,7 @@ if (!window.BI) {
outerAttr.shift(); outerAttr.shift();
return BI.extend({}, item, { return BI.extend({}, item, {
el: innerAttr.shift() el: innerAttr.shift()
}) });
} }
if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) { if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) {
innerAttr.shift(); innerAttr.shift();
@ -113,15 +113,15 @@ if (!window.BI) {
if (item.el) { if (item.el) {
return BI.extend({}, outerAttr.shift(), item, { return BI.extend({}, outerAttr.shift(), item, {
el: BI.extend({}, innerAttr.shift(), item.el) el: BI.extend({}, innerAttr.shift(), item.el)
}) });
} }
return BI.extend({}, outerAttr.shift(), { return BI.extend({}, outerAttr.shift(), {
el: BI.extend({}, innerAttr.shift(), item) el: BI.extend({}, innerAttr.shift(), item)
}) });
}) });
}, },
//用容器包装items // 用容器包装items
packageItems: function (items, layouts) { packageItems: function (items, layouts) {
for (var i = layouts.length - 1; i >= 0; i--) { for (var i = layouts.length - 1; i >= 0; i--) {
items = BI.map(items, function (k, it) { items = BI.map(items, function (k, it) {
@ -131,8 +131,8 @@ if (!window.BI) {
el: it el: it
}) })
] ]
}) });
}) });
} }
return items; return items;
}, },
@ -146,7 +146,7 @@ if (!window.BI) {
}; };
}, },
//剥开EL // 剥开EL
stripEL: function (obj) { stripEL: function (obj) {
return obj.type && obj || obj.el || obj; return obj.type && obj || obj.el || obj;
}, },
@ -158,13 +158,13 @@ if (!window.BI) {
} }
}); });
//集合相关方法 // 集合相关方法
_.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) { _.each(["where", "findWhere", "contains", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) {
BI[name] = _apply(name) BI[name] = _apply(name);
}); });
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", _.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition"], function (name) { "sortBy", "groupBy", "indexBy", "countBy", "partition"], function (name) {
BI[name] = _applyFunc(name) BI[name] = _applyFunc(name);
}); });
_.extend(BI, { _.extend(BI, {
clamp: function (value, minValue, maxValue) { clamp: function (value, minValue, maxValue) {
@ -176,7 +176,7 @@ if (!window.BI) {
} }
return value; return value;
}, },
//数数 // 数数
count: function (from, to, predicate) { count: function (from, to, predicate) {
var t; var t;
if (predicate) { if (predicate) {
@ -187,7 +187,7 @@ if (!window.BI) {
return to - from; return to - from;
}, },
//倒数 // 倒数
inverse: function (from, to, predicate) { inverse: function (from, to, predicate) {
return BI.count(to, from, predicate); return BI.count(to, from, predicate);
}, },
@ -326,7 +326,7 @@ if (!window.BI) {
}, },
string2Array: function (str) { string2Array: function (str) {
return str.split('&-&'); return str.split("&-&");
}, },
array2String: function (array) { array2String: function (array) {
@ -334,7 +334,7 @@ if (!window.BI) {
}, },
abc2Int: function (str) { abc2Int: function (str) {
var idx = 0, start = 'A', str = str.toUpperCase(); var idx = 0, start = "A", str = str.toUpperCase();
for (var i = 0, len = str.length; i < len; ++i) { for (var i = 0, len = str.length; i < len; ++i) {
idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1; idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1;
if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) { if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) {
@ -345,7 +345,7 @@ if (!window.BI) {
}, },
int2Abc: function (num) { int2Abc: function (num) {
var DIGITS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; var DIGITS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
var idx = num, str = ""; var idx = num, str = "";
if (num === 0) { if (num === 0) {
return ""; return "";
@ -362,16 +362,16 @@ if (!window.BI) {
} }
}); });
//数组相关的方法 // 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection", _.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range"], function (name) { "difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range"], function (name) {
BI[name] = _apply(name) BI[name] = _apply(name);
}); });
_.each(["findIndex", "findLastIndex"], function (name) { _.each(["findIndex", "findLastIndex"], function (name) {
BI[name] = _applyFunc(name) BI[name] = _applyFunc(name);
}); });
_.extend(BI, { _.extend(BI, {
//构建一个长度为length的数组 // 构建一个长度为length的数组
makeArray: function (length, value) { makeArray: function (length, value) {
var res = []; var res = [];
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
@ -425,20 +425,20 @@ if (!window.BI) {
} }
}); });
//对象相关方法 // 对象相关方法
_.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", _.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
"defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty", "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
"isElement", "isNumber", "isString", "isArray", "isObject", "isArguments", "isFunction", "isFinite", "isElement", "isNumber", "isString", "isArray", "isObject", "isArguments", "isFunction", "isFinite",
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined"], function (name) { "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined"], function (name) {
BI[name] = _apply(name) BI[name] = _apply(name);
}); });
_.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) { _.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) {
BI[name] = _applyFunc(name) BI[name] = _applyFunc(name);
}); });
_.extend(BI, { _.extend(BI, {
inherit: function (sb, sp, overrides) { inherit: function (sb, sp, overrides) {
if (typeof sp == 'object') { if (typeof sp === "object") {
overrides = sp; overrides = sp;
sp = sb; sp = sb;
sb = function () { sb = function () {
@ -446,7 +446,7 @@ if (!window.BI) {
}; };
} }
var F = function () { var F = function () {
}, spp = sp.prototype; }, spp = sp.prototype;
F.prototype = spp; F.prototype = spp;
sb.prototype = new F(); sb.prototype = new F();
sb.superclass = spp; sb.superclass = spp;
@ -468,12 +468,12 @@ if (!window.BI) {
return _.has.apply(_, arguments); return _.has.apply(_, arguments);
}, },
//数字和字符串可以作为key // 数字和字符串可以作为key
isKey: function (key) { isKey: function (key) {
return BI.isNumber(key) || (BI.isString(key) && key.length > 0); return BI.isNumber(key) || (BI.isString(key) && key.length > 0);
}, },
//忽略大小写的等于 // 忽略大小写的等于
isCapitalEqual: function (a, b) { isCapitalEqual: function (a, b) {
a = BI.isNull(a) ? a : ("" + a).toLowerCase(); a = BI.isNull(a) ? a : ("" + a).toLowerCase();
b = BI.isNull(b) ? b : ("" + b).toLowerCase(); b = BI.isNull(b) ? b : ("" + b).toLowerCase();
@ -481,10 +481,10 @@ if (!window.BI) {
}, },
isWidthOrHeight: function (w) { isWidthOrHeight: function (w) {
if (typeof w == 'number') { if (typeof w === "number") {
return w >= 0; return w >= 0;
} else if (typeof w == 'string') { } else if (typeof w === "string") {
return /^\d{1,3}%$/.exec(w) || w == 'auto' || /^\d+px$/.exec(w); return /^\d{1,3}%$/.exec(w) || w == "auto" || /^\d+px$/.exec(w);
} }
}, },
@ -529,7 +529,7 @@ if (!window.BI) {
} }
}); });
//deep方法 // deep方法
_.extend(BI, { _.extend(BI, {
/** /**
*完全克隆<EFBFBD>?个js对象 *完全克隆<EFBFBD>?个js对象
@ -544,14 +544,14 @@ if (!window.BI) {
var type = Object.prototype.toString.call(obj); var type = Object.prototype.toString.call(obj);
// Date // Date
if (type === '[object Date]') { if (type === "[object Date]") {
return Date.getDate(obj.getTime()); return Date.getDate(obj.getTime());
} }
var i, clone, key; var i, clone, key;
// Array // Array
if (type === '[object Array]') { if (type === "[object Array]") {
i = obj.length; i = obj.length;
clone = []; clone = [];
@ -561,7 +561,7 @@ if (!window.BI) {
} }
} }
// Object // Object
else if (type === '[object Object]' && obj.constructor === Object) { else if (type === "[object Object]" && obj.constructor === Object) {
clone = {}; clone = {};
for (var i in obj) { for (var i in obj) {
@ -595,7 +595,7 @@ if (!window.BI) {
if (BI.isEqual(v, copy)) { if (BI.isEqual(v, copy)) {
return true; return true;
} }
}) });
} }
return BI.contains(obj, copy); return BI.contains(obj, copy);
}, },
@ -639,15 +639,15 @@ if (!window.BI) {
} }
} }
return result; return result;
} else {
var result = {};
BI.each(obj, function (i, v) {
if (!BI.isEqual(target, obj[i])) {
result[i] = v;
}
});
return result;
} }
var result = {};
BI.each(obj, function (i, v) {
if (!BI.isEqual(target, obj[i])) {
result[i] = v;
}
});
return result;
}, },
deepUnique: function (array) { deepUnique: function (array) {
@ -660,7 +660,7 @@ if (!window.BI) {
return result; return result;
}, },
//比较两个对象得出不一样的key值 // 比较两个对象得出不一样的key值
deepDiff: function (object, other) { deepDiff: function (object, other) {
object || (object = {}); object || (object = {});
other || (other = {}); other || (other = {});
@ -683,18 +683,18 @@ if (!window.BI) {
} }
}); });
//通用方法 // 通用方法
_.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape"], function (name) { _.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape"], function (name) {
BI[name] = function () { BI[name] = function () {
return _[name].apply(_, arguments); return _[name].apply(_, arguments);
} };
}); });
//事件相关方法 // 事件相关方法
_.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) { _.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) {
BI[name] = function () { BI[name] = function () {
return _[name].apply(_, arguments); return _[name].apply(_, arguments);
} };
}); });
_.extend(BI, { _.extend(BI, {
@ -703,7 +703,7 @@ if (!window.BI) {
var pending = false; var pending = false;
var timerFunc; var timerFunc;
function nextTickHandler() { function nextTickHandler () {
pending = false; pending = false;
var copies = callbacks.slice(0); var copies = callbacks.slice(0);
callbacks = []; callbacks = [];
@ -712,15 +712,15 @@ if (!window.BI) {
} }
} }
if (typeof Promise !== 'undefined') { if (typeof Promise !== "undefined") {
var p = Promise.resolve(); var p = Promise.resolve();
timerFunc = function () { timerFunc = function () {
p.then(nextTickHandler); p.then(nextTickHandler);
} };
} else } else
/* istanbul ignore if */ /* istanbul ignore if */
if (typeof MutationObserver !== 'undefined') { if (typeof MutationObserver !== "undefined") {
var counter = 1; var counter = 1;
var observer = new MutationObserver(nextTickHandler); var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(counter + ""); var textNode = document.createTextNode(counter + "");
@ -730,13 +730,13 @@ if (!window.BI) {
timerFunc = function () { timerFunc = function () {
counter = (counter + 1) % 2; counter = (counter + 1) % 2;
textNode.data = counter + ""; textNode.data = counter + "";
} };
} else { } else {
timerFunc = function () { timerFunc = function () {
setTimeout(nextTickHandler, 0) setTimeout(nextTickHandler, 0);
} };
} }
return function queueNextTick(cb) { return function queueNextTick (cb) {
var _resolve; var _resolve;
var args = [].slice.call(arguments, 1); var args = [].slice.call(arguments, 1);
callbacks.push(function () { callbacks.push(function () {
@ -751,34 +751,34 @@ if (!window.BI) {
pending = true; pending = true;
timerFunc(); timerFunc();
} }
if (!cb && typeof Promise !== 'undefined') { if (!cb && typeof Promise !== "undefined") {
return new Promise(function (resolve) { return new Promise(function (resolve) {
_resolve = resolve _resolve = resolve;
}) });
} }
} };
})() })()
}); });
//数字相关方法 // 数字相关方法
_.each(["random"], function (name) { _.each(["random"], function (name) {
BI[name] = _apply(name) BI[name] = _apply(name);
}); });
_.extend(BI, { _.extend(BI, {
getTime: function () { getTime: function () {
if (window.performance && window.performance.now) { if (window.performance && window.performance.now) {
return window.performance.now(); return window.performance.now();
} else {
if (window.performance && window.performance.webkitNow) {
return window.performance.webkitNow();
} else {
if (Date.now) {
return Date.now();
} else {
return Date.getDate().getTime();
}
}
} }
if (window.performance && window.performance.webkitNow) {
return window.performance.webkitNow();
}
if (Date.now) {
return Date.now();
}
return Date.getDate().getTime();
}, },
parseInt: function (number) { parseInt: function (number) {
@ -881,7 +881,7 @@ if (!window.BI) {
} }
}); });
//字符串相关方法 // 字符串相关方法
_.extend(BI, { _.extend(BI, {
trim: function () { trim: function () {
return $.trim.apply($, arguments); return $.trim.apply($, arguments);
@ -900,28 +900,28 @@ if (!window.BI) {
}, },
isLiteral: function (exp) { isLiteral: function (exp) {
var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/ var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/;
return literalValueRE.test(exp) return literalValueRE.test(exp);
}, },
stripQuotes: function (str) { stripQuotes: function (str) {
var a = str.charCodeAt(0) var a = str.charCodeAt(0);
var b = str.charCodeAt(str.length - 1) var b = str.charCodeAt(str.length - 1);
return a === b && (a === 0x22 || a === 0x27) return a === b && (a === 0x22 || a === 0x27)
? str.slice(1, -1) ? str.slice(1, -1)
: str : str;
}, },
//background-color => backgroundColor // background-color => backgroundColor
camelize: function (str) { camelize: function (str) {
return str.replace(/-(.)/g, function (_, character) { return str.replace(/-(.)/g, function (_, character) {
return character.toUpperCase(); return character.toUpperCase();
}); });
}, },
//backgroundColor => background-color // backgroundColor => background-color
hyphenate: function (str) { hyphenate: function (str) {
return str.replace(/([A-Z])/g, '-$1').toLowerCase(); return str.replace(/([A-Z])/g, "-$1").toLowerCase();
}, },
isNotEmptyString: function (str) { isNotEmptyString: function (str) {
@ -965,7 +965,7 @@ if (!window.BI) {
alert("Algorithm cannot find a suitable hash. Please choose a different password. \nPossible considerations are to choose a more complex or longer password."); alert("Algorithm cannot find a suitable hash. Please choose a different password. \nPossible considerations are to choose a more complex or longer password.");
return null; return null;
} }
// var salt = Math.round(Math.random() * 1000000000) % 100000000; // var salt = Math.round(Math.random() * 1000000000) % 100000000;
var salt = 101; var salt = 101;
prand += salt; prand += salt;
while (prand.length > 10) { while (prand.length > 10) {
@ -1042,7 +1042,7 @@ if (!window.BI) {
} }
}); });
//浏览器相关方法 // 浏览器相关方法
_.extend(BI, { _.extend(BI, {
isIE: function () { isIE: function () {
if (this.__isIE == null) { if (this.__isIE == null) {
@ -1111,7 +1111,7 @@ if (!window.BI) {
}, },
isSupportCss3: function (style) { isSupportCss3: function (style) {
var prefix = ['webkit', 'Moz', 'ms', 'o'], var prefix = ["webkit", "Moz", "ms", "o"],
i, len, i, len,
humpString = [], humpString = [],
htmlStyle = document.documentElement.style, htmlStyle = document.documentElement.style,
@ -1122,7 +1122,7 @@ if (!window.BI) {
}; };
for (i in prefix) { for (i in prefix) {
humpString.push(_toHumb(prefix[i] + '-' + style)); humpString.push(_toHumb(prefix[i] + "-" + style));
} }
humpString.push(_toHumb(style)); humpString.push(_toHumb(style));
@ -1134,7 +1134,7 @@ if (!window.BI) {
return false; return false;
} }
}); });
//BI请求 // BI请求
_.extend(BI, { _.extend(BI, {
ajax: function (option) { ajax: function (option) {

4
src/core/behavior/behavior.highlight.js

@ -21,7 +21,7 @@ BI.HighlightBehavior = BI.inherit(BI.Behavior, {
if (item instanceof BI.Single) { if (item instanceof BI.Single) {
var rule = o.rule(item.getValue(), item); var rule = o.rule(item.getValue(), item);
function doBe(run) { function doBe (run) {
if (run === true) { if (run === true) {
item.doHighLight.apply(item, args); item.doHighLight.apply(item, args);
} else { } else {
@ -37,6 +37,6 @@ BI.HighlightBehavior = BI.inherit(BI.Behavior, {
} else { } else {
item.doBehavior.apply(item, args); item.doBehavior.apply(item, args);
} }
}) });
} }
}); });

14
src/core/behavior/behavior.js

@ -1,7 +1,7 @@
BI.BehaviorFactory = { BI.BehaviorFactory = {
createBehavior: function(key, options){ createBehavior: function (key, options) {
var behavior; var behavior;
switch (key){ switch (key) {
case "highlight": case "highlight":
behavior = BI.HighlightBehavior; behavior = BI.HighlightBehavior;
break; break;
@ -11,7 +11,7 @@ BI.BehaviorFactory = {
} }
return new behavior(options); return new behavior(options);
} }
} };
/** /**
* guy * guy
@ -20,18 +20,18 @@ BI.BehaviorFactory = {
* @extends BI.OB * @extends BI.OB
*/ */
BI.Behavior = BI.inherit(BI.OB, { BI.Behavior = BI.inherit(BI.OB, {
_defaultConfig: function() { _defaultConfig: function () {
return BI.extend(BI.Behavior.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.Behavior.superclass._defaultConfig.apply(this, arguments), {
rule: function(){return true;} rule: function () {return true;}
}); });
}, },
_init : function() { _init: function () {
BI.Behavior.superclass._init.apply(this, arguments); BI.Behavior.superclass._init.apply(this, arguments);
}, },
doBehavior: function(){ doBehavior: function () {
} }
}); });

10
src/core/behavior/behavior.redmark.js

@ -5,21 +5,21 @@
* @extends BI.Behavior * @extends BI.Behavior
*/ */
BI.RedMarkBehavior = BI.inherit(BI.Behavior, { BI.RedMarkBehavior = BI.inherit(BI.Behavior, {
_defaultConfig: function() { _defaultConfig: function () {
return BI.extend(BI.RedMarkBehavior.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RedMarkBehavior.superclass._defaultConfig.apply(this, arguments), {
}); });
}, },
_init : function() { _init: function () {
BI.RedMarkBehavior.superclass._init.apply(this, arguments); BI.RedMarkBehavior.superclass._init.apply(this, arguments);
}, },
doBehavior: function(items){ doBehavior: function (items) {
var args = Array.prototype.slice.call(arguments, 1), var args = Array.prototype.slice.call(arguments, 1),
o = this.options; o = this.options;
BI.each(items, function(i, item){ BI.each(items, function (i, item) {
if(item instanceof BI.Single) { if(item instanceof BI.Single) {
if (o.rule(item.getValue(), item)) { if (o.rule(item.getValue(), item)) {
item.doRedMark.apply(item, args); item.doRedMark.apply(item, args);
@ -29,6 +29,6 @@ BI.RedMarkBehavior = BI.inherit(BI.Behavior, {
} else { } else {
item.doBehavior.apply(item, args); item.doBehavior.apply(item, args);
} }
}) });
} }
}); });

8
src/core/controller.js

@ -7,16 +7,16 @@
* @abstract * @abstract
*/ */
BI.Controller = BI.inherit(BI.OB, { BI.Controller = BI.inherit(BI.OB, {
_defaultConfig: function() { _defaultConfig: function () {
return BI.extend(BI.Controller.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.Controller.superclass._defaultConfig.apply(this, arguments), {
}) });
}, },
_init : function() { _init: function () {
BI.Controller.superclass._init.apply(this, arguments); BI.Controller.superclass._init.apply(this, arguments);
}, },
destroy: function(){ destroy: function () {
} }
}); });

2
src/core/controller/controller.broadcast.js

@ -22,7 +22,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
this._broadcasts[name].push(fn); this._broadcasts[name].push(fn);
return function () { return function () {
self.remove(name, fn); self.remove(name, fn);
} };
}, },
send: function (name) { send: function (name) {

4
src/core/controller/controller.floatbox.js

@ -50,7 +50,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
cls: "bi-popup-view", cls: "bi-popup-view",
items: [{ items: [{
el: (this.floatLayer[name] = BI.createWidget({ el: (this.floatLayer[name] = BI.createWidget({
type: 'bi.absolute', type: "bi.absolute",
items: [floatbox] items: [floatbox]
})), })),
left: 0, left: 0,
@ -63,7 +63,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
(function (key) { (function (key) {
floatbox.on(BI.FloatBox.EVENT_FLOAT_BOX_CLOSED, function () { floatbox.on(BI.FloatBox.EVENT_FLOAT_BOX_CLOSED, function () {
self.close(key); self.close(key);
}) });
})(name); })(name);
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",

2
src/core/controller/controller.layer.js

@ -24,7 +24,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
if (layer.element.is(":visible")) { if (layer.element.is(":visible")) {
layer.element.trigger("__resize__"); layer.element.trigger("__resize__");
} }
}) });
}, },
make: function (name, container, op) { make: function (name, container, op) {

6
src/core/controller/controller.resizer.js

@ -14,9 +14,9 @@ BI.ResizeController = BI.inherit(BI.Controller, {
var self = this; var self = this;
this.resizerManger = {}; this.resizerManger = {};
var fn = BI.debounce(function (ev) { var fn = BI.debounce(function (ev) {
//if (BI.isWindow(ev.target)) { // if (BI.isWindow(ev.target)) {
self._resize(ev); self._resize(ev);
//} // }
}, 30); }, 30);
$(window).resize(fn); $(window).resize(fn);
}, },
@ -37,7 +37,7 @@ BI.ResizeController = BI.inherit(BI.Controller, {
resizer(ev); resizer(ev);
return; return;
} }
}) });
}, },
add: function (name, resizer) { add: function (name, resizer) {

4
src/core/controller/controller.tooltips.js

@ -18,7 +18,7 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
_init: function () { _init: function () {
BI.TooltipsController.superclass._init.apply(this, arguments); BI.TooltipsController.superclass._init.apply(this, arguments);
this.tooltipsManager = {}; this.tooltipsManager = {};
this.showingTips = {};//存储正在显示的tooltip this.showingTips = {};// 存储正在显示的tooltip
}, },
_createTooltip: function (text, level) { _createTooltip: function (text, level) {
@ -57,7 +57,7 @@ BI.TooltipsController = BI.inherit(BI.Controller, {
return this.get(name); return this.get(name);
}, },
//opt: {container: '', belowMouse: false} // opt: {container: '', belowMouse: false}
show: function (e, name, text, level, context, opt) { show: function (e, name, text, level, context, opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;

130
src/core/events.js

@ -33,61 +33,61 @@ _.extend(BI, {
* @static * @static
* @property 确定事件 * @property 确定事件
*/ */
CONFIRM: '_CONFIRM', CONFIRM: "_CONFIRM",
/** /**
* @static * @static
* @property 错误事件 * @property 错误事件
*/ */
ERROR: '_ERROR', ERROR: "_ERROR",
/** /**
* @static * @static
* @property 暂停事件 * @property 暂停事件
*/ */
PAUSE: '_PAUSE', PAUSE: "_PAUSE",
/** /**
* @static * @static
* @property destroy事件 * @property destroy事件
*/ */
DESTROY: '_DESTROY', DESTROY: "_DESTROY",
/** /**
* @static * @static
* @property 取消挂载事件 * @property 取消挂载事件
*/ */
UNMOUNT: '_UNMOUNT', UNMOUNT: "_UNMOUNT",
/** /**
* @static * @static
* @property 清除选择 * @property 清除选择
*/ */
CLEAR: '_CLEAR', CLEAR: "_CLEAR",
/** /**
* @static * @static
* @property 添加数据 * @property 添加数据
*/ */
ADD: '_ADD', ADD: "_ADD",
/** /**
* @static * @static
* @property 正在编辑状态事件 * @property 正在编辑状态事件
*/ */
EDITING: '_EDITING', EDITING: "_EDITING",
/** /**
* @static * @static
* @property 空状态事件 * @property 空状态事件
*/ */
EMPTY: '_EMPTY', EMPTY: "_EMPTY",
/** /**
* @static * @static
* @property 显示隐藏事件 * @property 显示隐藏事件
*/ */
VIEW: '_VIEW', VIEW: "_VIEW",
/** /**
* @static * @static
@ -99,334 +99,334 @@ _.extend(BI, {
* @static * @static
* @property 编辑前事件 * @property 编辑前事件
*/ */
BEFOREEDIT: '_BEFOREEDIT', BEFOREEDIT: "_BEFOREEDIT",
/** /**
* @static * @static
* @property 编辑后事件 * @property 编辑后事件
*/ */
AFTEREDIT: '_AFTEREDIT', AFTEREDIT: "_AFTEREDIT",
/** /**
* @static * @static
* @property 开始编辑事件 * @property 开始编辑事件
*/ */
STARTEDIT: '_STARTEDIT', STARTEDIT: "_STARTEDIT",
/** /**
* @static * @static
* @property 停止编辑事件 * @property 停止编辑事件
*/ */
STOPEDIT: '_STOPEDIT', STOPEDIT: "_STOPEDIT",
/** /**
* @static * @static
* @property 值改变事件 * @property 值改变事件
*/ */
CHANGE: '_CHANGE', CHANGE: "_CHANGE",
/** /**
* @static * @static
* @property 下拉弹出菜单事件 * @property 下拉弹出菜单事件
*/ */
EXPAND: '_EXPAND', EXPAND: "_EXPAND",
/** /**
* @static * @static
* @property 关闭下拉菜单事件 * @property 关闭下拉菜单事件
*/ */
COLLAPSE: '_COLLAPSE', COLLAPSE: "_COLLAPSE",
/** /**
* @static * @static
* @property 回调事件 * @property 回调事件
*/ */
CALLBACK: '_CALLBACK', CALLBACK: "_CALLBACK",
/** /**
* @static * @static
* @property 点击事件 * @property 点击事件
*/ */
CLICK: '_CLICK', CLICK: "_CLICK",
/** /**
* @static * @static
* @property 状态改变事件一般是用在复选按钮和单选按钮 * @property 状态改变事件一般是用在复选按钮和单选按钮
*/ */
STATECHANGE: '_STATECHANGE', STATECHANGE: "_STATECHANGE",
/** /**
* @static * @static
* @property 状态改变前事件 * @property 状态改变前事件
*/ */
BEFORESTATECHANGE: '_BEFORESTATECHANGE', BEFORESTATECHANGE: "_BEFORESTATECHANGE",
/** /**
* @static * @static
* @property 初始化事件 * @property 初始化事件
*/ */
INIT: '_INIT', INIT: "_INIT",
/** /**
* @static * @static
* @property 初始化后事件 * @property 初始化后事件
*/ */
AFTERINIT: '_AFTERINIT', AFTERINIT: "_AFTERINIT",
/** /**
* @static * @static
* @property 滚动条滚动事件 * @property 滚动条滚动事件
*/ */
SCROLL: '_SCROLL', SCROLL: "_SCROLL",
/** /**
* @static * @static
* @property 开始加载事件 * @property 开始加载事件
*/ */
STARTLOAD: '_STARTLOAD', STARTLOAD: "_STARTLOAD",
/** /**
* @static * @static
* @property 加载后事件 * @property 加载后事件
*/ */
AFTERLOAD: '_AFTERLOAD', AFTERLOAD: "_AFTERLOAD",
/** /**
* @static * @static
* @property 提交前事件 * @property 提交前事件
*/ */
BS: 'beforesubmit', BS: "beforesubmit",
/** /**
* @static * @static
* @property 提交后事件 * @property 提交后事件
*/ */
AS: 'aftersubmit', AS: "aftersubmit",
/** /**
* @static * @static
* @property 提交完成事件 * @property 提交完成事件
*/ */
SC: 'submitcomplete', SC: "submitcomplete",
/** /**
* @static * @static
* @property 提交失败事件 * @property 提交失败事件
*/ */
SF: 'submitfailure', SF: "submitfailure",
/** /**
* @static * @static
* @property 提交成功事件 * @property 提交成功事件
*/ */
SS: 'submitsuccess', SS: "submitsuccess",
/** /**
* @static * @static
* @property 校验提交前事件 * @property 校验提交前事件
*/ */
BVW: 'beforeverifywrite', BVW: "beforeverifywrite",
/** /**
* @static * @static
* @property 校验提交后事件 * @property 校验提交后事件
*/ */
AVW: 'afterverifywrite', AVW: "afterverifywrite",
/** /**
* @static * @static
* @property 校验后事件 * @property 校验后事件
*/ */
AV: 'afterverify', AV: "afterverify",
/** /**
* @static * @static
* @property 填报前事件 * @property 填报前事件
*/ */
BW: 'beforewrite', BW: "beforewrite",
/** /**
* @static * @static
* @property 填报后事件 * @property 填报后事件
*/ */
AW: 'afterwrite', AW: "afterwrite",
/** /**
* @static * @static
* @property 填报成功事件 * @property 填报成功事件
*/ */
WS: 'writesuccess', WS: "writesuccess",
/** /**
* @static * @static
* @property 填报失败事件 * @property 填报失败事件
*/ */
WF: 'writefailure', WF: "writefailure",
/** /**
* @static * @static
* @property 添加行前事件 * @property 添加行前事件
*/ */
BA: 'beforeappend', BA: "beforeappend",
/** /**
* @static * @static
* @property 添加行后事件 * @property 添加行后事件
*/ */
AA: 'afterappend', AA: "afterappend",
/** /**
* @static * @static
* @property 删除行前事件 * @property 删除行前事件
*/ */
BD: 'beforedelete', BD: "beforedelete",
/** /**
* @static * @static
* @property 删除行后事件 * @property 删除行后事件
*/ */
AD: 'beforedelete', AD: "beforedelete",
/** /**
* @static * @static
* @property 未提交离开事件 * @property 未提交离开事件
*/ */
UC: 'unloadcheck', UC: "unloadcheck",
/** /**
* @static * @static
* @property PDF导出前事件 * @property PDF导出前事件
*/ */
BTOPDF: 'beforetopdf', BTOPDF: "beforetopdf",
/** /**
* @static * @static
* @property PDF导出后事件 * @property PDF导出后事件
*/ */
ATOPDF: 'aftertopdf', ATOPDF: "aftertopdf",
/** /**
* @static * @static
* @property Excel导出前事件 * @property Excel导出前事件
*/ */
BTOEXCEL: 'beforetoexcel', BTOEXCEL: "beforetoexcel",
/** /**
* @static * @static
* @property Excel导出后事件 * @property Excel导出后事件
*/ */
ATOEXCEL: 'aftertoexcel', ATOEXCEL: "aftertoexcel",
/** /**
* @static * @static
* @property Word导出前事件 * @property Word导出前事件
*/ */
BTOWORD: 'beforetoword', BTOWORD: "beforetoword",
/** /**
* @static * @static
* @property Word导出后事件 * @property Word导出后事件
*/ */
ATOWORD: 'aftertoword', ATOWORD: "aftertoword",
/** /**
* @static * @static
* @property 图片导出前事件 * @property 图片导出前事件
*/ */
BTOIMAGE: 'beforetoimage', BTOIMAGE: "beforetoimage",
/** /**
* @static * @static
* @property 图片导出后事件 * @property 图片导出后事件
*/ */
ATOIMAGE: 'aftertoimage', ATOIMAGE: "aftertoimage",
/** /**
* @static * @static
* @property HTML导出前事件 * @property HTML导出前事件
*/ */
BTOHTML: 'beforetohtml', BTOHTML: "beforetohtml",
/** /**
* @static * @static
* @property HTML导出后事件 * @property HTML导出后事件
*/ */
ATOHTML: 'aftertohtml', ATOHTML: "aftertohtml",
/** /**
* @static * @static
* @property Excel导入前事件 * @property Excel导入前事件
*/ */
BIMEXCEL: 'beforeimportexcel', BIMEXCEL: "beforeimportexcel",
/** /**
* @static * @static
* @property Excel导出后事件 * @property Excel导出后事件
*/ */
AIMEXCEL: 'afterimportexcel', AIMEXCEL: "afterimportexcel",
/** /**
* @static * @static
* @property PDF打印前事件 * @property PDF打印前事件
*/ */
BPDFPRINT: 'beforepdfprint', BPDFPRINT: "beforepdfprint",
/** /**
* @static * @static
* @property PDF打印后事件 * @property PDF打印后事件
*/ */
APDFPRINT: 'afterpdfprint', APDFPRINT: "afterpdfprint",
/** /**
* @static * @static
* @property Flash打印前事件 * @property Flash打印前事件
*/ */
BFLASHPRINT: 'beforeflashprint', BFLASHPRINT: "beforeflashprint",
/** /**
* @static * @static
* @property Flash打印后事件 * @property Flash打印后事件
*/ */
AFLASHPRINT: 'afterflashprint', AFLASHPRINT: "afterflashprint",
/** /**
* @static * @static
* @property Applet打印前事件 * @property Applet打印前事件
*/ */
BAPPLETPRINT: 'beforeappletprint', BAPPLETPRINT: "beforeappletprint",
/** /**
* @static * @static
* @property Applet打印后事件 * @property Applet打印后事件
*/ */
AAPPLETPRINT: 'afterappletprint', AAPPLETPRINT: "afterappletprint",
/** /**
* @static * @static
* @property 服务器打印前事件 * @property 服务器打印前事件
*/ */
BSEVERPRINT: 'beforeserverprint', BSEVERPRINT: "beforeserverprint",
/** /**
* @static * @static
* @property 服务器打印后事件 * @property 服务器打印后事件
*/ */
ASERVERPRINT: 'afterserverprint', ASERVERPRINT: "afterserverprint",
/** /**
* @static * @static
* @property 邮件发送前事件 * @property 邮件发送前事件
*/ */
BEMAIL: 'beforeemail', BEMAIL: "beforeemail",
/** /**
* @static * @static
* @property 邮件发送后事件 * @property 邮件发送后事件
*/ */
AEMAIL: 'afteremail' AEMAIL: "afteremail"
} }
}); });

52
src/core/func/dom.js

@ -7,7 +7,7 @@ BI.extend(jQuery.fn, {
destroy: function () { destroy: function () {
this.remove(); this.remove();
if (BI.isIE() === true) { if (BI.isIE() === true) {
this[0].outerHTML = ''; this[0].outerHTML = "";
} }
}, },
/** /**
@ -74,17 +74,17 @@ BI.extend(jQuery.fn, {
return height; return height;
}, },
//是否有竖直滚动条 // 是否有竖直滚动条
hasVerticalScroll: function () { hasVerticalScroll: function () {
return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth; return this.height() > 0 && this[0].clientWidth < this[0].offsetWidth;
}, },
//是否有水平滚动条 // 是否有水平滚动条
hasHorizonScroll: function () { hasHorizonScroll: function () {
return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight; return this.width() > 0 && this[0].clientHeight < this[0].offsetHeight;
}, },
//获取计算后的样式 // 获取计算后的样式
getStyle: function (name) { getStyle: function (name) {
var node = this[0]; var node = this[0];
var computedStyle = void 0; var computedStyle = void 0;
@ -104,13 +104,13 @@ BI.extend(jQuery.fn, {
if (computedStyle) { if (computedStyle) {
return computedStyle.getPropertyValue(BI.hyphenate(name)); return computedStyle.getPropertyValue(BI.hyphenate(name));
} }
if (name === 'display') { if (name === "display") {
return 'none'; return "none";
} }
} }
// Internet Explorer // Internet Explorer
if (node.currentStyle) { if (node.currentStyle) {
if (name === 'float') { if (name === "float") {
return node.currentStyle.cssFloat || node.currentStyle.styleFloat; return node.currentStyle.cssFloat || node.currentStyle.styleFloat;
} }
return node.currentStyle[BI.camelize(name)]; return node.currentStyle[BI.camelize(name)];
@ -121,7 +121,7 @@ BI.extend(jQuery.fn, {
__isMouseInBounds__: function (e) { __isMouseInBounds__: function (e) {
var offset2Body = this.offset(); var offset2Body = this.offset();
return !(e.pageX < offset2Body.left || e.pageX > offset2Body.left + this.outerWidth() return !(e.pageX < offset2Body.left || e.pageX > offset2Body.left + this.outerWidth()
|| e.pageY < offset2Body.top || e.pageY > offset2Body.top + this.outerHeight()) || e.pageY < offset2Body.top || e.pageY > offset2Body.top + this.outerHeight());
}, },
__hasZIndexMask__: function (zindex) { __hasZIndexMask__: function (zindex) {
@ -129,8 +129,8 @@ BI.extend(jQuery.fn, {
}, },
__buildZIndexMask__: function (zindex, domArray) { __buildZIndexMask__: function (zindex, domArray) {
this.zIndexMask = this.zIndexMask || {};//存储z-index的mask this.zIndexMask = this.zIndexMask || {};// 存储z-index的mask
this.indexMask = this.indexMask || [];//存储mask this.indexMask = this.indexMask || [];// 存储mask
var mask = BI.createWidget({ var mask = BI.createWidget({
type: "bi.center_adapt", type: "bi.center_adapt",
cls: "bi-z-index-mask", cls: "bi-z-index-mask",
@ -178,7 +178,7 @@ BI.extend(jQuery, {
var el = combo.element; var el = combo.element;
return { return {
left: el.offset().left + el.outerWidth() + (extraWidth || 0) left: el.offset().left + el.outerWidth() + (extraWidth || 0)
} };
}, },
getTopPosition: function (combo, popup, extraHeight) { getTopPosition: function (combo, popup, extraHeight) {
@ -233,7 +233,7 @@ BI.extend(jQuery, {
} }
return { return {
left: left left: left
} };
}, },
getLeftAdaptPosition: function (combo, popup, extraWidth) { getLeftAdaptPosition: function (combo, popup, extraWidth) {
@ -242,7 +242,7 @@ BI.extend(jQuery, {
} }
return { return {
left: 0 left: 0
} };
}, },
getRightAlignPosition: function (combo, popup, extraWidth) { getRightAlignPosition: function (combo, popup, extraWidth) {
@ -253,7 +253,7 @@ BI.extend(jQuery, {
} }
return { return {
left: left left: left
} };
}, },
getRightAdaptPosition: function (combo, popup, extraWidth) { getRightAdaptPosition: function (combo, popup, extraWidth) {
@ -262,7 +262,7 @@ BI.extend(jQuery, {
} }
return { return {
left: $("body").bounds().width - popup.element.bounds().width left: $("body").bounds().width - popup.element.bounds().width
} };
}, },
getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
@ -289,7 +289,7 @@ BI.extend(jQuery, {
adaptHeight: adaptHeight adaptHeight: adaptHeight
} : { } : {
top: top top: top
} };
}, },
getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { getTopAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
@ -301,17 +301,17 @@ BI.extend(jQuery, {
return { return {
top: 0, top: 0,
adaptHeight: combo.element.offset().top - extraHeight adaptHeight: combo.element.offset().top - extraHeight
} };
} }
if (popupBounds.height + extraHeight > windowBounds.height) { if (popupBounds.height + extraHeight > windowBounds.height) {
return { return {
top: 0, top: 0,
adaptHeight: windowBounds.height - extraHeight adaptHeight: windowBounds.height - extraHeight
} };
} }
return { return {
top: 0 top: 0
} };
}, },
getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) {
@ -338,7 +338,7 @@ BI.extend(jQuery, {
adaptHeight: adaptHeight adaptHeight: adaptHeight
} : { } : {
top: top top: top
} };
}, },
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
@ -352,17 +352,17 @@ BI.extend(jQuery, {
return { return {
top: comboOffset.top + comboBounds.height + extraHeight, top: comboOffset.top + comboBounds.height + extraHeight,
adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight adaptHeight: windowBounds.height - comboOffset.top - comboBounds.height - extraHeight
} };
} }
if (popupBounds.height + extraHeight > windowBounds.height) { if (popupBounds.height + extraHeight > windowBounds.height) {
return { return {
top: extraHeight, top: extraHeight,
adaptHeight: windowBounds.height - extraHeight adaptHeight: windowBounds.height - extraHeight
} };
} }
return { return {
top: windowBounds.height - popupBounds.height - extraHeight top: windowBounds.height - popupBounds.height - extraHeight
} };
}, },
getCenterAdaptPosition: function (combo, popup) { getCenterAdaptPosition: function (combo, popup) {
@ -380,7 +380,7 @@ BI.extend(jQuery, {
} }
return { return {
left: left left: left
} };
}, },
getMiddleAdaptPosition: function (combo, popup) { getMiddleAdaptPosition: function (combo, popup) {
@ -398,7 +398,7 @@ BI.extend(jQuery, {
} }
return { return {
top: top top: top
} };
}, },
getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) { getComboPositionByDirections: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions) {
@ -561,7 +561,7 @@ BI.extend(jQuery, {
var bodyHeight = $("body").bounds().height - extraHeight; var bodyHeight = $("body").bounds().height - extraHeight;
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight); var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight);
popup.resetHeight && popup.resetHeight(maxHeight); popup.resetHeight && popup.resetHeight(maxHeight);
var position = $.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ['bottom', 'top', 'right', 'left']); var position = $.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"]);
switch (offsetStyle) { switch (offsetStyle) {
case "center": case "center":
if (position.change) { if (position.change) {

39
src/core/func/function.js

@ -15,8 +15,8 @@ BI.extend(BI.Func, {
name = name || ""; name = name || "";
while (true) { while (true) {
if (BI.every(array, function (i, item) { if (BI.every(array, function (i, item) {
return item.name !== name; return item.name !== name;
})) { })) {
break; break;
} }
name = src + (idx++); name = src + (idx++);
@ -67,7 +67,7 @@ BI.extend(BI.Func, {
return { return {
matched: matched, matched: matched,
finded: finded finded: finded
} };
} }
}); });
@ -98,11 +98,11 @@ BI.extend(BI.DOM, {
return $("body").find(obj.element).length > 0; return $("body").find(obj.element).length > 0;
}, },
//预加载图片 // 预加载图片
preloadImages: function (srcArray, onload) { preloadImages: function (srcArray, onload) {
var count = 0, images = []; var count = 0, images = [];
function complete() { function complete () {
count++; count++;
if (count >= srcArray.length) { if (count >= srcArray.length) {
onload(); onload();
@ -113,10 +113,10 @@ BI.extend(BI.DOM, {
images[i] = new Image(); images[i] = new Image();
images[i].src = src; images[i].src = src;
images[i].onload = function () { images[i].onload = function () {
complete() complete();
}; };
images[i].onerror = function () { images[i].onerror = function () {
complete() complete();
}; };
}); });
}, },
@ -145,13 +145,13 @@ BI.extend(BI.DOM, {
} }
var rgb = this.rgb2json(this.hex2rgb(hex)); var rgb = this.rgb2json(this.hex2rgb(hex));
var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114); var grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/**网上给的是140**/) { if (grayLevel < 192/** 网上给的是140**/) {
return true; return true;
} }
return false; return false;
}, },
//获取对比颜色 // 获取对比颜色
getContrastColor: function (color) { getContrastColor: function (color) {
if (!color || !this.isColor(color)) { if (!color || !this.isColor(color)) {
return ""; return "";
@ -219,9 +219,9 @@ BI.extend(BI.DOM, {
}, },
int2hex: function (strNum) { int2hex: function (strNum) {
var hexdig = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; var hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return hexdig[strNum >>> 4] + '' + hexdig[strNum & 15]; return hexdig[strNum >>> 4] + "" + hexdig[strNum & 15];
}, },
hex2rgb: function (color) { hex2rgb: function (color) {
@ -234,14 +234,13 @@ BI.extend(BI.DOM, {
var tempValue = "rgb(", colorArray; var tempValue = "rgb(", colorArray;
if (color.length === 7) { if (color.length === 7) {
colorArray = [BI.parseInt('0x' + color.substring(1, 3)), colorArray = [BI.parseInt("0x" + color.substring(1, 3)),
BI.parseInt('0x' + color.substring(3, 5)), BI.parseInt("0x" + color.substring(3, 5)),
BI.parseInt('0x' + color.substring(5, 7))]; BI.parseInt("0x" + color.substring(5, 7))];
} } else if (color.length === 4) {
else if (color.length === 4) { colorArray = [BI.parseInt("0x" + color.substring(1, 2)),
colorArray = [BI.parseInt('0x' + color.substring(1, 2)), BI.parseInt("0x" + color.substring(2, 3)),
BI.parseInt('0x' + color.substring(2, 3)), BI.parseInt("0x" + color.substring(3, 4))];
BI.parseInt('0x' + color.substring(3, 4))];
} }
tempValue += colorArray[0] + ","; tempValue += colorArray[0] + ",";
tempValue += colorArray[1] + ","; tempValue += colorArray[1] + ",";
@ -287,7 +286,7 @@ BI.extend(BI.DOM, {
return width; return width;
}, },
//获取滚动条的宽度 // 获取滚动条的宽度
getScrollWidth: function () { getScrollWidth: function () {
if (this._scrollWidth == null) { if (this._scrollWidth == null) {
var ul = $("<div>").width(50).height(50).css({ var ul = $("<div>").width(50).height(50).css({

31
src/core/inject.js

@ -1,4 +1,4 @@
;(function () { (function () {
var constantInjection = {}; var constantInjection = {};
BI.constant = function (xtype, cls) { BI.constant = function (xtype, cls) {
if (constantInjection[xtype] != null) { if (constantInjection[xtype] != null) {
@ -47,35 +47,36 @@
if (!providers[type]) { if (!providers[type]) {
providers[type] = new providerInjection[type](); providers[type] = new providerInjection[type]();
} }
return configFn(providers[type]) return configFn(providers[type]);
} }
} BI.Plugin.registerWidget(type, configFn);
};
var actions = {} var actions = {};
BI.action = function (type, actionFn) { BI.action = function (type, actionFn) {
if (!actions[type]) { if (!actions[type]) {
actions[type] = []; actions[type] = [];
} }
actions[type].push(actionFn) actions[type].push(actionFn);
return function () { return function () {
actions[type].remove(actionFn); actions[type].remove(actionFn);
if (actions[type].length === 0) { if (actions[type].length === 0) {
delete actions[type]; delete actions[type];
} }
} };
} };
BI.Constants = { BI.Constants = {
getConstant: function (type) { getConstant: function (type) {
return constantInjection[type]; return constantInjection[type];
} }
} };
BI.Models = { BI.Models = {
getModel: function (type, config) { getModel: function (type, config) {
return new modelInjection[type](config); return new modelInjection[type](config);
} }
} };
var stores = {}; var stores = {};
@ -89,7 +90,7 @@
releaseStore: function (type) { releaseStore: function (type) {
delete stores[type]; delete stores[type];
} }
} };
var services = {}; var services = {};
@ -103,9 +104,9 @@
releaseService: function (type) { releaseService: function (type) {
delete services[type]; delete services[type];
} }
} };
var providers = {}, providerInstance = {} var providers = {}, providerInstance = {};
BI.Providers = { BI.Providers = {
getProvider: function (type, config) { getProvider: function (type, config) {
@ -121,13 +122,13 @@
delete providers[type]; delete providers[type];
delete providerInstance[type]; delete providerInstance[type];
} }
} };
BI.Actions = { BI.Actions = {
runAction: function (type, config) { runAction: function (type, config) {
BI.each(actions[type], function (i, act) { BI.each(actions[type], function (i, act) {
act(config); act(config);
}) });
} }
} };
})(); })();

18746
src/core/jquery.js vendored

File diff suppressed because it is too large Load Diff

2
src/core/listener/listener.show.js

@ -41,7 +41,7 @@ BI.ShowListener = BI.inherit(BI.OB, {
self.fireEvent(BI.ShowListener.EVENT_CHANGE, cardName); self.fireEvent(BI.ShowListener.EVENT_CHANGE, cardName);
}); });
} }
}) });
} }
}); });
BI.ShowListener.EVENT_CHANGE = "ShowListener.EVENT_CHANGE"; BI.ShowListener.EVENT_CHANGE = "ShowListener.EVENT_CHANGE";

6
src/core/loader/loader.style.js

@ -15,9 +15,9 @@ BI.StyleLoaderManager = BI.inherit(BI.OB, {
}, },
loadStyle: function (name, styleString) { loadStyle: function (name, styleString) {
var d = document, styles = d.createElement('style'); var d = document, styles = d.createElement("style");
d.getElementsByTagName('head')[0].appendChild(styles); d.getElementsByTagName("head")[0].appendChild(styles);
styles.setAttribute('type', 'text/css'); styles.setAttribute("type", "text/css");
if (styles.styleSheet) { if (styles.styleSheet) {
styles.styleSheet.cssText = styleString; styles.styleSheet.cssText = styleString;
} else { } else {

2
src/core/logic/logic.js

@ -59,7 +59,7 @@ BI.LogicFactory = {
el: item, el: item,
width: item.options.width, width: item.options.width,
height: item.options.height height: item.options.height
} };
} }
return item; return item;
}); });

8
src/core/logic/logic.layout.js

@ -42,7 +42,7 @@ BI.VerticalLayoutLogic = BI.inherit(BI.Logic, {
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
items: o.items items: o.items
} };
}, },
_init: function () { _init: function () {
@ -95,7 +95,7 @@ BI.HorizontalLayoutLogic = BI.inherit(BI.Logic, {
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
items: o.items items: o.items
} };
}, },
_init: function () { _init: function () {
@ -147,7 +147,7 @@ BI.TableLayoutLogic = BI.inherit(BI.Logic, {
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
items: o.items items: o.items
} };
}, },
_init: function () { _init: function () {
@ -203,7 +203,7 @@ BI.HorizontalFillLayoutLogic = BI.inherit(BI.Logic, {
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
items: o.items items: o.items
} };
}, },
_init: function () { _init: function () {

14
src/core/ob.js

@ -30,14 +30,14 @@ $.extend(BI.OB.prototype, {
var self = this; var self = this;
if (this.options.listeners != null) { if (this.options.listeners != null) {
$.each(this.options.listeners, function (i, lis) { $.each(this.options.listeners, function (i, lis) {
(lis.target ? lis.target : self)[lis.once ? 'once' : 'on'] (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
(lis.eventName, _.bind(lis.action, self)) (lis.eventName, _.bind(lis.action, self));
}); });
delete this.options.listeners; delete this.options.listeners;
} }
}, },
//获得一个当前对象的引用 // 获得一个当前对象的引用
_initRef: function () { _initRef: function () {
if (this.options.ref) { if (this.options.ref) {
this.options.ref.call(this, this); this.options.ref.call(this, this);
@ -46,7 +46,7 @@ $.extend(BI.OB.prototype, {
_getEvents: function () { _getEvents: function () {
if (!$.isArray(this.events)) { if (!$.isArray(this.events)) {
this.events = [] this.events = [];
} }
return this.events; return this.events;
}, },
@ -86,7 +86,7 @@ $.extend(BI.OB.prototype, {
un: function (eventName, fn) { un: function (eventName, fn) {
eventName = eventName.toLowerCase(); eventName = eventName.toLowerCase();
/*alex:如果fn是null,就是把eventName上面所有方法都un掉*/ /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
if (fn == null) { if (fn == null) {
delete this._getEvents()[eventName]; delete this._getEvents()[eventName];
} else { } else {
@ -97,7 +97,7 @@ $.extend(BI.OB.prototype, {
if (ifn != fn) { if (ifn != fn) {
newFns.push(ifn); newFns.push(ifn);
} }
}) });
this._getEvents()[eventName] = newFns; this._getEvents()[eventName] = newFns;
} }
} }
@ -106,7 +106,7 @@ $.extend(BI.OB.prototype, {
* 清除观察者的所有事件绑定 * 清除观察者的所有事件绑定
*/ */
purgeListeners: function () { purgeListeners: function () {
/*alex:清空events*/ /* alex:清空events*/
this.events = []; this.events = [];
}, },
/** /**

5
src/core/plugin.js

@ -1,6 +1,5 @@
BI.Plugin = BI.Plugin || {}; BI.Plugin = BI.Plugin || {};
; !(function () {
(function () {
var _WidgetsPlugin = {}; var _WidgetsPlugin = {};
var _ObjectPlugin = {}; var _ObjectPlugin = {};
BI.extend(BI.Plugin, { BI.extend(BI.Plugin, {
@ -8,7 +7,7 @@ BI.Plugin = BI.Plugin || {};
getWidget: function (type, options) { getWidget: function (type, options) {
if (_WidgetsPlugin[type]) { if (_WidgetsPlugin[type]) {
var res; var res;
for (var i = _WidgetsPlugin[type].length-1; i >=0; i--) { for (var i = _WidgetsPlugin[type].length - 1; i >= 0; i--) {
if (res = _WidgetsPlugin[type][i](options)) { if (res = _WidgetsPlugin[type][i](options)) {
return res; return res;
} }

78
src/core/proto/date.js

@ -1,5 +1,5 @@
$(function () { $(function () {
//牵扯到国际化这些常量在页面加载后再生效 // 牵扯到国际化这些常量在页面加载后再生效
// full day names // full day names
Date._DN = [BI.i18nText("BI-Basic_Sunday"), Date._DN = [BI.i18nText("BI-Basic_Sunday"),
BI.i18nText("BI-Basic_Monday"), BI.i18nText("BI-Basic_Monday"),
@ -59,10 +59,10 @@ $(function () {
/** Adds the number of days array to the Date object. */ /** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
}) });
/** Constants used for time computations */ /** Constants used for time computations */
Date.SECOND = 1000 /* milliseconds */; Date.SECOND = 1000;
Date.MINUTE = 60 * Date.SECOND; Date.MINUTE = 60 * Date.SECOND;
Date.HOUR = 60 * Date.MINUTE; Date.HOUR = 60 * Date.MINUTE;
Date.DAY = 24 * Date.HOUR; Date.DAY = 24 * Date.HOUR;
@ -79,14 +79,14 @@ Date.prototype.getTimezone = function () {
/** Returns the number of days in the current month */ /** Returns the number of days in the current month */
Date.prototype.getMonthDays = function (month) { Date.prototype.getMonthDays = function (month) {
var year = this.getFullYear(); var year = this.getFullYear();
if (typeof month == "undefined") { if (typeof month === "undefined") {
month = this.getMonth(); month = this.getMonth();
} }
if (((0 == (year % 4)) && ( (0 != (year % 100)) || (0 == (year % 400)))) && month == 1) { if (((0 == (year % 4)) && ( (0 != (year % 100)) || (0 == (year % 400)))) && month == 1) {
return 29; return 29;
} else {
return Date._MD[month];
} }
return Date._MD[month];
}; };
/** /**
@ -108,9 +108,9 @@ Date.prototype.getDayOfYear = function () {
/** Returns the number of the week in year, as defined in ISO 8601. */ /** Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function () { Date.prototype.getWeekNumber = function () {
var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0); var d = Date.getDate(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
//周一是一周第一天 // 周一是一周第一天
var week = d.getDay() === 0 ? 7 : d.getDay(); var week = d.getDay() === 0 ? 7 : d.getDay();
//var week = d.getDay(); // var week = d.getDay();
if (this.getMonth() === 0 && this.getDate() <= week) { if (this.getMonth() === 0 && this.getDate() <= week) {
return 1; return 1;
} }
@ -129,7 +129,7 @@ Date.prototype.getQuarter = function () {
return Math.floor(this.getMonth() / 3) + 1; return Math.floor(this.getMonth() / 3) + 1;
}; };
//离当前时间多少天的时间 // 离当前时间多少天的时间
Date.prototype.getOffsetDate = function (offset) { Date.prototype.getOffsetDate = function (offset) {
return Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()) + offset * 864e5); return Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()) + offset * 864e5);
}; };
@ -139,13 +139,13 @@ Date.prototype.getAfterMulQuarter = function (n) {
dt.setMonth(dt.getMonth() + n * 3); dt.setMonth(dt.getMonth() + n * 3);
return dt; return dt;
}; };
//获得n个季度前的日期 // 获得n个季度前的日期
Date.prototype.getBeforeMulQuarter = function (n) { Date.prototype.getBeforeMulQuarter = function (n) {
var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds())); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
dt.setMonth(dt.getMonth() - n * 3); dt.setMonth(dt.getMonth() - n * 3);
return dt; return dt;
}; };
//得到本季度的起始月份 // 得到本季度的起始月份
Date.prototype.getQuarterStartMonth = function () { Date.prototype.getQuarterStartMonth = function () {
var quarterStartMonth = 0; var quarterStartMonth = 0;
var nowMonth = this.getMonth(); var nowMonth = this.getMonth();
@ -163,11 +163,11 @@ Date.prototype.getQuarterStartMonth = function () {
} }
return quarterStartMonth; return quarterStartMonth;
}; };
//获得本季度的起始日期 // 获得本季度的起始日期
Date.prototype.getQuarterStartDate = function () { Date.prototype.getQuarterStartDate = function () {
return Date.getDate(this.getFullYear(), this.getQuarterStartMonth(), 1); return Date.getDate(this.getFullYear(), this.getQuarterStartMonth(), 1);
}; };
//得到本季度的结束日期 // 得到本季度的结束日期
Date.prototype.getQuarterEndDate = function () { Date.prototype.getQuarterEndDate = function () {
var quarterEndMonth = this.getQuarterStartMonth() + 2; var quarterEndMonth = this.getQuarterStartMonth() + 2;
return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth)); return Date.getDate(this.getFullYear(), quarterEndMonth, this.getMonthDays(quarterEndMonth));
@ -183,7 +183,7 @@ Date.prototype.getBeforeMultiMonth = function (n) {
return dt; return dt;
}; };
//指定日期n个月之前或之后的日期 // 指定日期n个月之前或之后的日期
Date.prototype.getOffsetMonth = function (n) { Date.prototype.getOffsetMonth = function (n) {
var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds())); var dt = Date.getDate(Date.getTime(this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()));
var day = dt.getDate(); var day = dt.getDate();
@ -196,12 +196,12 @@ Date.prototype.getOffsetMonth = function (n) {
return dt; return dt;
}; };
//获得本周的起始日期 // 获得本周的起始日期
Date.prototype.getWeekStartDate = function () { Date.prototype.getWeekStartDate = function () {
var w = this.getDay(); var w = this.getDay();
return this.getOffsetDate(w === 0 ? -6 : 1 - w); return this.getOffsetDate(w === 0 ? -6 : 1 - w);
}; };
//得到本周的结束日期 // 得到本周的结束日期
Date.prototype.getWeekEndDate = function () { Date.prototype.getWeekEndDate = function () {
var w = this.getDay(); var w = this.getDay();
return this.getOffsetDate(w === 0 ? 0 : 7 - w); return this.getOffsetDate(w === 0 ? 0 : 7 - w);
@ -259,7 +259,7 @@ Date.prototype.print = function (str) {
s["%k"] = hr; // hour, range 0 to 23 (24h format) s["%k"] = hr; // hour, range 0 to 23 (24h format)
s["%l"] = ir; // hour, range 1 to 12 (12h format) s["%l"] = ir; // hour, range 1 to 12 (12h format)
s["%X"] = (m < 9) ? ("0" + (1 + m)) : (1 + m); // month, range 01 to 12 s["%X"] = (m < 9) ? ("0" + (1 + m)) : (1 + m); // month, range 01 to 12
s["%x"] = m + 1 // month, range 1 to 12 s["%x"] = m + 1; // month, range 1 to 12
s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59 s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
s["%n"] = "\n"; // a newline character s["%n"] = "\n"; // a newline character
s["%p"] = pm ? "PM" : "AM"; s["%p"] = pm ? "PM" : "AM";
@ -275,7 +275,7 @@ Date.prototype.print = function (str) {
s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN) s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
// FIXME: %x : preferred date representation for the current locale without the time // FIXME: %x : preferred date representation for the current locale without the time
// FIXME: %X : preferred time representation for the current locale without the date // FIXME: %X : preferred time representation for the current locale without the date
s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99) s["%y"] = ("" + y).substr(2, 2); // year without the century (range 00 to 99)
s["%Y"] = y; // year with the century s["%Y"] = y; // year with the century
s["%%"] = "%"; // a literal '%' character s["%%"] = "%"; // a literal '%' character
s["%Q"] = qr; s["%Q"] = qr;
@ -291,7 +291,7 @@ Date.prototype.print = function (str) {
for (var i = 0; i < a.length; i++) { for (var i = 0; i < a.length; i++) {
var tmp = s[a[i]]; var tmp = s[a[i]];
if (tmp) { if (tmp) {
re = new RegExp(a[i], 'g'); re = new RegExp(a[i], "g");
str = str.replace(re, tmp); str = str.replace(re, tmp);
} }
} }
@ -326,25 +326,25 @@ Date.checkVoid = function (YY, MM, DD, minDate, maxDate) {
minDate = BI.isString(minDate) ? minDate.match(/\d+/g) : minDate; minDate = BI.isString(minDate) ? minDate.match(/\d+/g) : minDate;
maxDate = BI.isString(maxDate) ? maxDate.match(/\d+/g) : maxDate; maxDate = BI.isString(maxDate) ? maxDate.match(/\d+/g) : maxDate;
if (YY < minDate[0]) { if (YY < minDate[0]) {
back = ['y']; back = ["y"];
} else if (YY > maxDate[0]) { } else if (YY > maxDate[0]) {
back = ['y', 1]; back = ["y", 1];
} else if (YY >= minDate[0] && YY <= maxDate[0]) { } else if (YY >= minDate[0] && YY <= maxDate[0]) {
if (YY == minDate[0]) { if (YY == minDate[0]) {
if (MM < minDate[1]) { if (MM < minDate[1]) {
back = ['m']; back = ["m"];
} else if (MM == minDate[1]) { } else if (MM == minDate[1]) {
if (DD < minDate[2]) { if (DD < minDate[2]) {
back = ['d']; back = ["d"];
} }
} }
} }
if (YY == maxDate[0]) { if (YY == maxDate[0]) {
if (MM > maxDate[1]) { if (MM > maxDate[1]) {
back = ['m', 1]; back = ["m", 1];
} else if (MM == maxDate[1]) { } else if (MM == maxDate[1]) {
if (DD > maxDate[2]) { if (DD > maxDate[2]) {
back = ['d', 1]; back = ["d", 1];
} }
} }
} }
@ -371,9 +371,9 @@ Date.parseDateTime = function (str, fmt) {
var y = 0; var y = 0;
var m = 0; var m = 0;
var d = 1; var d = 1;
//wei : 对于fmt为‘YYYYMM’或者‘YYYYMMdd’的格式,str的值为类似'201111'的形式,因为年月之间没有分隔符,所以正则表达式分割无效,导致bug7376。 // wei : 对于fmt为‘YYYYMM’或者‘YYYYMMdd’的格式,str的值为类似'201111'的形式,因为年月之间没有分隔符,所以正则表达式分割无效,导致bug7376。
var a = str.split(/\W+/); var a = str.split(/\W+/);
if (fmt.toLowerCase() == '%y%x' || fmt.toLowerCase() == '%y%x%d') { if (fmt.toLowerCase() == "%y%x" || fmt.toLowerCase() == "%y%x%d") {
var yearlength = 4; var yearlength = 4;
var otherlength = 2; var otherlength = 2;
a[0] = str.substring(0, yearlength); a[0] = str.substring(0, yearlength);
@ -438,9 +438,9 @@ Date.parseDateTime = function (str, fmt) {
break; break;
} }
} }
// if (!a[i]) { // if (!a[i]) {
// continue; // continue;
// } // }
if (isNaN(y)) { if (isNaN(y)) {
y = today.getFullYear(); y = today.getFullYear();
} }
@ -500,21 +500,21 @@ Date.parseDateTime = function (str, fmt) {
Date.getDate = function () { Date.getDate = function () {
var dt = new (Function.prototype.bind.apply(Date, BI.concat([null], [].slice.apply(arguments))))(); var dt = new (Function.prototype.bind.apply(Date, BI.concat([null], [].slice.apply(arguments))))();
if(BI.isNotNull(Date.timeZone) && (arguments.length === 0 || (arguments.length === 1 && BI.isNumber(arguments[0])))){ if(BI.isNotNull(Date.timeZone) && (arguments.length === 0 || (arguments.length === 1 && BI.isNumber(arguments[0])))) {
var localTime = dt.getTime(); var localTime = dt.getTime();
var localOffset = dt.getTimezoneOffset() * 60000; //获得当地时间偏移的毫秒数 var localOffset = dt.getTimezoneOffset() * 60000; // 获得当地时间偏移的毫秒数
var utc = localTime + localOffset; //utc即GMT时间标准时区 var utc = localTime + localOffset; // utc即GMT时间标准时区
return new Date(utc + Date.timeZone);//+ Pool.timeZone.offset); return new Date(utc + Date.timeZone);// + Pool.timeZone.offset);
}else{
return dt;
} }
return dt;
}; };
Date.getTime = function () { Date.getTime = function () {
var dt = Function.prototype.bind.apply(Date.getDate, BI.concat([null], [].slice.apply(arguments)))(); var dt = Function.prototype.bind.apply(Date.getDate, BI.concat([null], [].slice.apply(arguments)))();
if(BI.isNotNull(Date.timeZone)){ if(BI.isNotNull(Date.timeZone)) {
return dt.getTime() - Date.timeZone - dt.getTimezoneOffset() * 60000; return dt.getTime() - Date.timeZone - dt.getTimezoneOffset() * 60000;
}else{
return dt.getTime();
} }
return dt.getTime();
}; };

4
src/core/proto/function.js

@ -5,7 +5,7 @@ Function.prototype.before = function (func) {
return false; return false;
} }
return __self.apply(this, arguments); return __self.apply(this, arguments);
} };
}; };
Function.prototype.after = function (func) { Function.prototype.after = function (func) {
@ -17,5 +17,5 @@ Function.prototype.after = function (func) {
} }
func.apply(this, arguments); func.apply(this, arguments);
return ret; return ret;
} };
}; };

35
src/core/proto/jquery.js vendored

@ -6,10 +6,10 @@ if (jQuery) {
var p = this.padding(), var p = this.padding(),
b = this.border(); b = this.border();
return { return {
'top': p.top, top: p.top,
'bottom': p.bottom + b.bottom + b.top, bottom: p.bottom + b.bottom + b.top,
'left': p.left, left: p.left,
'right': p.right + b.right + b.left right: p.right + b.right + b.left
}; };
}; };
} }
@ -30,30 +30,29 @@ if (jQuery) {
tmp.width = (value.width - (this.outerWidth(true) - this.width())); tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width; tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome // fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0; // tmp.width = (tmp.width >= 0) ? tmp.width : 0;
} }
if (value.height != null) { if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height()); tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height; tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome // fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0; // tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
} }
this.css(tmp); this.css(tmp);
return this; return this;
} }
else {
// richer:注意此方法只对可见元素有效 // richer:注意此方法只对可见元素有效
tmp = this.position(); tmp = this.position();
return { return {
'x': tmp.left, x: tmp.left,
'y': tmp.top, y: tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框 // richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(), width: this.outerWidth(),
'height': this.outerHeight() height: this.outerHeight()
}; };
}
}; };
} }
})(jQuery); })(jQuery);
} }
;

80
src/core/proto/number.js

@ -1,12 +1,12 @@
if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== "0.000" ||
(0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (0.9).toFixed(0) === "0" || (1.255).toFixed(2) !== "1.25" ||
(1000000000000000128).toFixed(0) !== "1000000000000000128") { (1000000000000000128).toFixed(0) !== "1000000000000000128") {
(function () { (function () {
var base, size, data, i; var base, size, data, i;
base = 1e7; base = 1e7;
size = 6; size = 6;
data = [0, 0, 0, 0, 0, 0]; data = [0, 0, 0, 0, 0, 0];
function multiply(n, c) { function multiply (n, c) {
var i = -1; var i = -1;
while (++i < size) { while (++i < size) {
c += n * data[i]; c += n * data[i];
@ -15,7 +15,7 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
} }
} }
function divide(n) { function divide (n) {
var i = size, c = 0; var i = size, c = 0;
while (--i >= 0) { while (--i >= 0) {
c += data[i]; c += data[i];
@ -24,28 +24,28 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
} }
} }
function toString() { function toString () {
var i = size; var i = size;
var s = ''; var s = "";
while (--i >= 0) { while (--i >= 0) {
if (s !== '' || i === 0 || data[i] !== 0) { if (s !== "" || i === 0 || data[i] !== 0) {
var t = String(data[i]); var t = String(data[i]);
if (s === '') { if (s === "") {
s = t; s = t;
} else { } else {
s += '0000000'.slice(0, 7 - t.length) + t; s += "0000000".slice(0, 7 - t.length) + t;
} }
} }
} }
return s; return s;
} }
function pow(x, n, acc) { function pow (x, n, acc) {
return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x)
: pow(x * x, n / 2, acc))); : pow(x * x, n / 2, acc)));
} }
function log(x) { function log (x) {
var n = 0; var n = 0;
while (x >= 4096) { while (x >= 4096) {
n += 12; n += 12;
@ -64,7 +64,7 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
f = f !== f ? 0 : Math.floor(f); f = f !== f ? 0 : Math.floor(f);
if (f < 0 || f > 20) { if (f < 0 || f > 20) {
throw new RangeError('Number.toFixed called with invalid number of decimals'); throw new RangeError("Number.toFixed called with invalid number of decimals");
} }
x = Number(this); x = Number(this);
@ -87,15 +87,15 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
m = "0"; m = "0";
if (x > 1e-21) { if (x > 1e-21) {
//1e-21<x<1e21 // 1e-21<x<1e21
//-70<log2(x)<70 // -70<log2(x)<70
e = log(x * pow(2, 69, 1)) - 69; e = log(x * pow(2, 69, 1)) - 69;
z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1)); z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
z *= 0x10000000000000;//Math.pow(2,52); z *= 0x10000000000000;// Math.pow(2,52);
e = 52 - e; e = 52 - e;
//-18<e<122 // -18<e<122
//x=z/2^e // x=z/2^e
if (e > 0) { if (e > 0) {
multiply(0, z); multiply(0, z);
j = f; j = f;
@ -119,7 +119,7 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
} else { } else {
multiply(0, z); multiply(0, z);
multiply(1 << (-e), 0); multiply(1 << (-e), 0);
m = toString() + '0.00000000000000000000'.slice(2, 2 + f); m = toString() + "0.00000000000000000000".slice(2, 2 + f);
} }
} }
@ -127,16 +127,16 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
k = m.length; k = m.length;
if (k <= f) { if (k <= f) {
m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m; m = s + "0.0000000000000000000".slice(0, f - k + 2) + m;
} else { } else {
m = s + m.slice(0, k - f) + '.' + m.slice(k - f); m = s + m.slice(0, k - f) + "." + m.slice(k - f);
} }
} else { } else {
m = s + m; m = s + m;
} }
return m; return m;
} };
})(); })();
} }
@ -148,18 +148,16 @@ if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
** 调用accAdd(arg1,arg2) ** 调用accAdd(arg1,arg2)
** 返回值arg1加上arg2的精确结果 ** 返回值arg1加上arg2的精确结果
**/ **/
function accAdd(arg1, arg2) { function accAdd (arg1, arg2) {
var r1, r2, m, c; var r1, r2, m, c;
try { try {
r1 = arg1.toString().split(".")[1].length; r1 = arg1.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
r1 = 0; r1 = 0;
} }
try { try {
r2 = arg2.toString().split(".")[1].length; r2 = arg2.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
r2 = 0; r2 = 0;
} }
c = Math.abs(r1 - r2); c = Math.abs(r1 - r2);
@ -180,7 +178,7 @@ function accAdd(arg1, arg2) {
return (arg1 + arg2) / m; return (arg1 + arg2) / m;
} }
//给Number类型增加一个add方法,调用起来更加方便。 // 给Number类型增加一个add方法,调用起来更加方便。
Number.prototype.add = function (arg) { Number.prototype.add = function (arg) {
return accAdd(arg, this); return accAdd(arg, this);
}; };
@ -190,21 +188,19 @@ Number.prototype.add = function (arg) {
** 调用accSub(arg1,arg2) ** 调用accSub(arg1,arg2)
** 返回值arg1加上arg2的精确结果 ** 返回值arg1加上arg2的精确结果
**/ **/
function accSub(arg1, arg2) { function accSub (arg1, arg2) {
var r1, r2, m, n; var r1, r2, m, n;
try { try {
r1 = arg1.toString().split(".")[1].length; r1 = arg1.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
r1 = 0; r1 = 0;
} }
try { try {
r2 = arg2.toString().split(".")[1].length; r2 = arg2.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
r2 = 0; r2 = 0;
} }
m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度 m = Math.pow(10, Math.max(r1, r2)); // last modify by deeka //动态控制精度长度
n = (r1 >= r2) ? r1 : r2; n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n); return ((arg1 * m - arg2 * m) / m).toFixed(n);
} }
@ -219,17 +215,15 @@ Number.prototype.sub = function (arg) {
** 调用accMul(arg1,arg2) ** 调用accMul(arg1,arg2)
** 返回值arg1乘以 arg2的精确结果 ** 返回值arg1乘以 arg2的精确结果
**/ **/
function accMul(arg1, arg2) { function accMul (arg1, arg2) {
var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
try { try {
m += s1.split(".")[1].length; m += s1.split(".")[1].length;
} } catch (e) {
catch (e) {
} }
try { try {
m += s2.split(".")[1].length; m += s2.split(".")[1].length;
} } catch (e) {
catch (e) {
} }
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
} }
@ -244,17 +238,15 @@ Number.prototype.mul = function (arg) {
** 调用accDiv(arg1,arg2) ** 调用accDiv(arg1,arg2)
** 返回值arg1除以arg2的精确结果 ** 返回值arg1除以arg2的精确结果
**/ **/
function accDiv(arg1, arg2) { function accDiv (arg1, arg2) {
var t1 = 0, t2 = 0, r1, r2; var t1 = 0, t2 = 0, r1, r2;
try { try {
t1 = arg1.toString().split(".")[1].length; t1 = arg1.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
} }
try { try {
t2 = arg2.toString().split(".")[1].length; t2 = arg2.toString().split(".")[1].length;
} } catch (e) {
catch (e) {
} }
with (Math) { with (Math) {
r1 = Number(arg1.toString().replace(".", "")); r1 = Number(arg1.toString().replace(".", ""));
@ -263,7 +255,7 @@ function accDiv(arg1, arg2) {
} }
} }
//给Number类型增加一个div方法,调用起来更加方便。 // 给Number类型增加一个div方法,调用起来更加方便。
Number.prototype.div = function (arg) { Number.prototype.div = function (arg) {
return accDiv(this, arg); return accDiv(this, arg);
}; };

8
src/core/proto/string.js

@ -61,7 +61,7 @@ $.extend(String.prototype, {
src += "&"; src += "&";
} }
$.each(paras, function (name, value) { $.each(paras, function (name, value) {
if (typeof(name) === 'string') { if (typeof(name) === "string") {
src += name + "=" + value + "&"; src += name + "=" + value + "&";
} }
}); });
@ -85,9 +85,9 @@ $.extend(String.prototype, {
perfectStart: function (start) { perfectStart: function (start) {
if (this.startWith(start)) { if (this.startWith(start)) {
return this; return this;
} else {
return start + this;
} }
return start + this;
}, },
/** /**
@ -96,7 +96,7 @@ $.extend(String.prototype, {
* @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组 * @return {Number[]} 子字符串在父字符串中出现的所有位置组成的数组
*/ */
allIndexOf: function (sub) { allIndexOf: function (sub) {
if (typeof sub != 'string') { if (typeof sub !== "string") {
return []; return [];
} }
var str = this; var str = this;

456
src/core/underscore.js

File diff suppressed because it is too large Load Diff

2
src/core/utils/aspect.js

@ -1,5 +1,5 @@
(function (window, undefined) { (function (window, undefined) {
function aspect(type) { function aspect (type) {
return function (target, methodName, advice) { return function (target, methodName, advice) {
var exist = target[methodName], var exist = target[methodName],
dispatcher; dispatcher;

4
src/core/utils/base64.js

@ -1,4 +1,4 @@
;
!(function () { !(function () {
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@ -126,5 +126,5 @@
return output; return output;
} }
}) });
})(); })();

6
src/core/utils/cache.js

@ -61,10 +61,8 @@ BI.Cache = {
}, },
getCookie: function (name) { getCookie: function (name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) if (arr = document.cookie.match(reg)) {return unescape(arr[2]);}
return unescape(arr[2]); return null;
else
return null;
}, },
deleteCookie: function (name, path) { deleteCookie: function (name, path) {
var date = new Date(); var date = new Date();

52
src/core/utils/cellSizeAndPositionManager.js

@ -57,14 +57,14 @@ BI.CellSizeAndPositionManager.prototype = {
return this._lastMeasuredIndex >= 0 return this._lastMeasuredIndex >= 0
? this._cellSizeAndPositionData[this._lastMeasuredIndex] ? this._cellSizeAndPositionData[this._lastMeasuredIndex]
: { : {
offset: 0, offset: 0,
size: 0 size: 0
} };
}, },
getTotalSize: function () { getTotalSize: function () {
var lastMeasuredCellSizeAndPosition = this.getSizeAndPositionOfLastMeasuredCell(); var lastMeasuredCellSizeAndPosition = this.getSizeAndPositionOfLastMeasuredCell();
return lastMeasuredCellSizeAndPosition.offset + lastMeasuredCellSizeAndPosition.size + (this._cellCount - this._lastMeasuredIndex - 1) * this._estimatedCellSize return lastMeasuredCellSizeAndPosition.offset + lastMeasuredCellSizeAndPosition.size + (this._cellCount - this._lastMeasuredIndex - 1) * this._estimatedCellSize;
}, },
getUpdatedOffsetForIndex: function (align, containerSize, currentOffset, targetIndex) { getUpdatedOffsetForIndex: function (align, containerSize, currentOffset, targetIndex) {
@ -75,13 +75,13 @@ BI.CellSizeAndPositionManager.prototype = {
var idealOffset; var idealOffset;
switch (align) { switch (align) {
case 'start': case "start":
idealOffset = maxOffset; idealOffset = maxOffset;
break; break;
case 'end': case "end":
idealOffset = minOffset; idealOffset = minOffset;
break; break;
case 'center': case "center":
idealOffset = maxOffset - ((containerSize - datum.size) / 2); idealOffset = maxOffset - ((containerSize - datum.size) / 2);
break; break;
default: default:
@ -98,7 +98,7 @@ BI.CellSizeAndPositionManager.prototype = {
var totalSize = this.getTotalSize(); var totalSize = this.getTotalSize();
if (totalSize === 0) { if (totalSize === 0) {
return {} return {};
} }
var maxOffset = offset + containerSize; var maxOffset = offset + containerSize;
@ -117,11 +117,11 @@ BI.CellSizeAndPositionManager.prototype = {
return { return {
start: start, start: start,
stop: stop stop: stop
} };
}, },
resetCell: function (index) { resetCell: function (index) {
this._lastMeasuredIndex = Math.min(this._lastMeasuredIndex, index - 1) this._lastMeasuredIndex = Math.min(this._lastMeasuredIndex, index - 1);
}, },
_binarySearch: function (high, low, offset) { _binarySearch: function (high, low, offset) {
@ -169,15 +169,15 @@ BI.CellSizeAndPositionManager.prototype = {
if (lastMeasuredCellSizeAndPosition.offset >= offset) { if (lastMeasuredCellSizeAndPosition.offset >= offset) {
return this._binarySearch(lastMeasuredIndex, 0, offset); return this._binarySearch(lastMeasuredIndex, 0, offset);
} else {
return this._exponentialSearch(lastMeasuredIndex, offset);
} }
return this._exponentialSearch(lastMeasuredIndex, offset);
} }
}; };
BI.ScalingCellSizeAndPositionManager = function (cellCount, cellSizeGetter, estimatedCellSize, maxScrollSize) { BI.ScalingCellSizeAndPositionManager = function (cellCount, cellSizeGetter, estimatedCellSize, maxScrollSize) {
this._cellSizeAndPositionManager = new BI.CellSizeAndPositionManager(cellCount, cellSizeGetter, estimatedCellSize); this._cellSizeAndPositionManager = new BI.CellSizeAndPositionManager(cellCount, cellSizeGetter, estimatedCellSize);
this._maxScrollSize = maxScrollSize || 10000000 this._maxScrollSize = maxScrollSize || 10000000;
}; };
BI.ScalingCellSizeAndPositionManager.prototype = { BI.ScalingCellSizeAndPositionManager.prototype = {
@ -188,15 +188,15 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}, },
getCellCount: function () { getCellCount: function () {
return this._cellSizeAndPositionManager.getCellCount() return this._cellSizeAndPositionManager.getCellCount();
}, },
getEstimatedCellSize: function () { getEstimatedCellSize: function () {
return this._cellSizeAndPositionManager.getEstimatedCellSize() return this._cellSizeAndPositionManager.getEstimatedCellSize();
}, },
getLastMeasuredIndex: function () { getLastMeasuredIndex: function () {
return this._cellSizeAndPositionManager.getLastMeasuredIndex() return this._cellSizeAndPositionManager.getLastMeasuredIndex();
}, },
getOffsetAdjustment: function (containerSize, offset) { getOffsetAdjustment: function (containerSize, offset) {
@ -234,13 +234,13 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
}, },
resetCell: function (index) { resetCell: function (index) {
this._cellSizeAndPositionManager.resetCell(index) this._cellSizeAndPositionManager.resetCell(index);
}, },
_getOffsetPercentage: function (containerSize, offset, totalSize) { _getOffsetPercentage: function (containerSize, offset, totalSize) {
return totalSize <= containerSize return totalSize <= containerSize
? 0 ? 0
: offset / (totalSize - containerSize) : offset / (totalSize - containerSize);
}, },
_offsetToSafeOffset: function (containerSize, offset) { _offsetToSafeOffset: function (containerSize, offset) {
@ -249,11 +249,11 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
if (totalSize === safeTotalSize) { if (totalSize === safeTotalSize) {
return offset; return offset;
} else {
var offsetPercentage = this._getOffsetPercentage(containerSize, offset, totalSize);
return Math.round(offsetPercentage * (safeTotalSize - containerSize));
} }
var offsetPercentage = this._getOffsetPercentage(containerSize, offset, totalSize);
return Math.round(offsetPercentage * (safeTotalSize - containerSize));
}, },
_safeOffsetToOffset: function (containerSize, offset) { _safeOffsetToOffset: function (containerSize, offset) {
@ -262,10 +262,10 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
if (totalSize === safeTotalSize) { if (totalSize === safeTotalSize) {
return offset; return offset;
} else {
var offsetPercentage = this._getOffsetPercentage(containerSize, offset, safeTotalSize);
return Math.round(offsetPercentage * (totalSize - containerSize));
} }
var offsetPercentage = this._getOffsetPercentage(containerSize, offset, safeTotalSize);
return Math.round(offsetPercentage * (totalSize - containerSize));
} }
}; };

752
src/core/utils/chinesePY.js

File diff suppressed because one or more lines are too long

87
src/core/utils/detectElementResize.js

@ -9,16 +9,16 @@
**/ **/
!(function () { !(function () {
// Check `document` and `window` in case of server-side rendering // Check `document` and `window` in case of server-side rendering
var _window var _window;
if (typeof window !== 'undefined') { if (typeof window !== "undefined") {
_window = window _window = window;
} else if (typeof self !== 'undefined') { } else if (typeof self !== "undefined") {
_window = self _window = self;
} else { } else {
_window = this _window = this;
} }
var addEventListener = typeof document !== 'undefined' && document.addEventListener; var addEventListener = typeof document !== "undefined" && document.addEventListener;
var stylesCreated = false; var stylesCreated = false;
if (addEventListener) { if (addEventListener) {
@ -47,8 +47,8 @@
expandChild = expand.firstElementChild; expandChild = expand.firstElementChild;
contract.scrollLeft = contract.scrollWidth; contract.scrollLeft = contract.scrollWidth;
contract.scrollTop = contract.scrollHeight; contract.scrollTop = contract.scrollHeight;
expandChild.style.width = expand.offsetWidth + 1 + 'px'; expandChild.style.width = expand.offsetWidth + 1 + "px";
expandChild.style.height = expand.offsetHeight + 1 + 'px'; expandChild.style.height = expand.offsetHeight + 1 + "px";
expand.scrollLeft = expand.scrollWidth; expand.scrollLeft = expand.scrollWidth;
expand.scrollTop = expand.scrollHeight; expand.scrollTop = expand.scrollHeight;
}; };
@ -56,7 +56,7 @@
var checkTriggers = function (element) { var checkTriggers = function (element) {
return element.offsetWidth !== element.__resizeLast__.width || return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height; element.offsetHeight !== element.__resizeLast__.height;
} };
var scrollListener = function (e) { var scrollListener = function (e) {
var element = this; var element = this;
@ -75,24 +75,24 @@
/* Detect CSS Animations support to detect element display/re-attach */ /* Detect CSS Animations support to detect element display/re-attach */
var animation = false, var animation = false,
animationstring = 'animation', animationstring = "animation",
keyframeprefix = '', keyframeprefix = "",
animationstartevent = 'animationstart', animationstartevent = "animationstart",
domPrefixes = 'Webkit Moz O ms'.split(' '), domPrefixes = "Webkit Moz O ms".split(" "),
startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '), startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),
pfx = ''; pfx = "";
{ {
var elm = document.createElement('fakeelement'); var elm = document.createElement("fakeelement");
if (elm.style.animationName !== undefined) { if (elm.style.animationName !== undefined) {
animation = true; animation = true;
} }
if (animation === false) { if (animation === false) {
for (var i = 0; i < domPrefixes.length; i++) { for (var i = 0; i < domPrefixes.length; i++) {
if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) { if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) {
pfx = domPrefixes[i]; pfx = domPrefixes[i];
animationstring = pfx + 'Animation'; animationstring = pfx + "Animation";
keyframeprefix = '-' + pfx.toLowerCase() + '-'; keyframeprefix = "-" + pfx.toLowerCase() + "-";
animationstartevent = startEvents[i]; animationstartevent = startEvents[i];
animation = true; animation = true;
break; break;
@ -101,21 +101,21 @@
} }
} }
var animationName = 'resizeanim'; var animationName = "resizeanim";
var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } '; var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ";
var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; '; var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
} }
var createStyles = function () { var createStyles = function () {
if (!stylesCreated) { if (!stylesCreated) {
//opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360 // opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
var css = (animationKeyframes ? animationKeyframes : '') + var css = (animationKeyframes ? animationKeyframes : "") +
'.resize-triggers { ' + (animationStyle ? animationStyle : '') + 'visibility: hidden; opacity: 0; } ' + ".resize-triggers { " + (animationStyle ? animationStyle : "") + "visibility: hidden; opacity: 0; } " +
'.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', ".resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }",
head = document.head || document.getElementsByTagName('head')[0], head = document.head || document.getElementsByTagName("head")[0],
style = document.createElement('style'); style = document.createElement("style");
style.type = 'text/css'; style.type = "text/css";
if (style.styleSheet) { if (style.styleSheet) {
style.styleSheet.cssText = css; style.styleSheet.cssText = css;
} else { } else {
@ -125,32 +125,31 @@
head.appendChild(style); head.appendChild(style);
stylesCreated = true; stylesCreated = true;
} }
} };
var addResizeListener = function (element, fn) { var addResizeListener = function (element, fn) {
if (addEventListener){ if (addEventListener) {
if (!element.__resizeTriggers__) { if (!element.__resizeTriggers__) {
if (getComputedStyle(element).position === 'static') element.style.position = 'relative'; if (getComputedStyle(element).position === "static") element.style.position = "relative";
createStyles(); createStyles();
element.__resizeLast__ = {}; element.__resizeLast__ = {};
element.__resizeListeners__ = []; element.__resizeListeners__ = [];
(element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers'; (element.__resizeTriggers__ = document.createElement("div")).className = "resize-triggers";
element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + element.__resizeTriggers__.innerHTML = "<div class=\"expand-trigger\"><div></div></div>" +
'<div class="contract-trigger"></div>'; "<div class=\"contract-trigger\"></div>";
element.appendChild(element.__resizeTriggers__); element.appendChild(element.__resizeTriggers__);
resetTriggers(element); resetTriggers(element);
element.addEventListener('scroll', scrollListener, true); element.addEventListener("scroll", scrollListener, true);
/* Listen for a css animation to detect element display/re-attach */ /* Listen for a css animation to detect element display/re-attach */
animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) { animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
if (e.animationName === animationName) if (e.animationName === animationName) {resetTriggers(element);}
resetTriggers(element);
}); });
} }
element.__resizeListeners__.push(fn); element.__resizeListeners__.push(fn);
} else { } else {
element.attachEvent('onresize', fn); element.attachEvent("onresize", fn);
} }
}; };
@ -158,11 +157,11 @@
if (addEventListener) { if (addEventListener) {
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) { if (!element.__resizeListeners__.length) {
element.removeEventListener('scroll', scrollListener, true); element.removeEventListener("scroll", scrollListener, true);
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
} }
} else { } else {
element.detachEvent('onresize', fn); element.detachEvent("onresize", fn);
} }
}; };
@ -171,7 +170,7 @@
addResizeListener(widget.element[0], fn); addResizeListener(widget.element[0], fn);
return function () { return function () {
removeResizeListener(widget.element[0], fn); removeResizeListener(widget.element[0], fn);
} };
}, },
removeResizeListener: function (widget, fn) { removeResizeListener: function (widget, fn) {
removeResizeListener(widget.element[0], fn); removeResizeListener(widget.element[0], fn);

24
src/core/utils/events/eventlistener.js

@ -1,37 +1,37 @@
BI.EventListener = { BI.EventListener = {
listen: function listen(target, eventType, callback) { listen: function listen (target, eventType, callback) {
if (target.addEventListener) { if (target.addEventListener) {
target.addEventListener(eventType, callback, false); target.addEventListener(eventType, callback, false);
return { return {
remove: function remove() { remove: function remove () {
target.removeEventListener(eventType, callback, false); target.removeEventListener(eventType, callback, false);
} }
}; };
} else if (target.attachEvent) { } else if (target.attachEvent) {
target.attachEvent('on' + eventType, callback); target.attachEvent("on" + eventType, callback);
return { return {
remove: function remove() { remove: function remove () {
target.detachEvent('on' + eventType, callback); target.detachEvent("on" + eventType, callback);
} }
}; };
} }
}, },
capture: function capture(target, eventType, callback) { capture: function capture (target, eventType, callback) {
if (target.addEventListener) { if (target.addEventListener) {
target.addEventListener(eventType, callback, true); target.addEventListener(eventType, callback, true);
return { return {
remove: function remove() { remove: function remove () {
target.removeEventListener(eventType, callback, true); target.removeEventListener(eventType, callback, true);
} }
}; };
} else {
return {
remove: BI.emptyFn
};
} }
return {
remove: BI.emptyFn
};
}, },
registerDefault: function registerDefault() { registerDefault: function registerDefault () {
} }
}; };

10
src/core/utils/events/mousemovetracker.js

@ -23,16 +23,16 @@
}; };
BI.MouseMoveTracker.prototype = { BI.MouseMoveTracker.prototype = {
constructor: BI.MouseMoveTracker, constructor: BI.MouseMoveTracker,
captureMouseMoves: function (/*object*/ event) { captureMouseMoves: function (/* object*/ event) {
if (!this._eventMoveToken && !this._eventUpToken) { if (!this._eventMoveToken && !this._eventUpToken) {
this._eventMoveToken = BI.EventListener.listen( this._eventMoveToken = BI.EventListener.listen(
this._domNode, this._domNode,
'mousemove', "mousemove",
this._onMouseMove this._onMouseMove
); );
this._eventUpToken = BI.EventListener.listen( this._eventUpToken = BI.EventListener.listen(
this._domNode, this._domNode,
'mouseup', "mouseup",
this._onMouseUp this._onMouseUp
); );
} }
@ -67,11 +67,11 @@
} }
}, },
isDragging: function () /*boolean*/ { isDragging: function () /* boolean*/ {
return this._isDragging; return this._isDragging;
}, },
_onMouseMove: function (/*object*/ event) { _onMouseMove: function (/* object*/ event) {
var x = event.clientX; var x = event.clientX;
var y = event.clientY; var y = event.clientY;

36
src/core/utils/events/wheelhandler.js

@ -4,7 +4,7 @@
var PAGE_HEIGHT = 800; var PAGE_HEIGHT = 800;
var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout; var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || window.setTimeout;
function normalizeWheel(/*object*/event) /*object*/ { function normalizeWheel (/* object*/event) /* object*/ {
var sX = 0, var sX = 0,
sY = 0, sY = 0,
// spinX, spinY // spinX, spinY
@ -12,21 +12,21 @@
pY = 0; // pixelX, pixelY pY = 0; // pixelX, pixelY
// Legacy // Legacy
if ('detail' in event) { if ("detail" in event) {
sY = event.detail; sY = event.detail;
} }
if ('wheelDelta' in event) { if ("wheelDelta" in event) {
sY = -event.wheelDelta / 120; sY = -event.wheelDelta / 120;
} }
if ('wheelDeltaY' in event) { if ("wheelDeltaY" in event) {
sY = -event.wheelDeltaY / 120; sY = -event.wheelDeltaY / 120;
} }
if ('wheelDeltaX' in event) { if ("wheelDeltaX" in event) {
sX = -event.wheelDeltaX / 120; sX = -event.wheelDeltaX / 120;
} }
// side scrolling on FF with DOMMouseScroll // side scrolling on FF with DOMMouseScroll
if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) { if ("axis" in event && event.axis === event.HORIZONTAL_AXIS) {
sX = sY; sX = sY;
sY = 0; sY = 0;
} }
@ -34,10 +34,10 @@
pX = sX * PIXEL_STEP; pX = sX * PIXEL_STEP;
pY = sY * PIXEL_STEP; pY = sY * PIXEL_STEP;
if ('deltaY' in event) { if ("deltaY" in event) {
pY = event.deltaY; pY = event.deltaY;
} }
if ('deltaX' in event) { if ("deltaX" in event) {
pX = event.deltaX; pX = event.deltaX;
} }
@ -74,33 +74,33 @@
this._deltaX = 0; this._deltaX = 0;
this._deltaY = 0; this._deltaY = 0;
this._didWheel = BI.bind(this._didWheel, this); this._didWheel = BI.bind(this._didWheel, this);
if (typeof handleScrollX !== 'function') { if (typeof handleScrollX !== "function") {
handleScrollX = handleScrollX ? handleScrollX = handleScrollX ?
function () { function () {
return true return true;
} : } :
function () { function () {
return false return false;
}; };
} }
if (typeof handleScrollY !== 'function') { if (typeof handleScrollY !== "function") {
handleScrollY = handleScrollY ? handleScrollY = handleScrollY ?
function () { function () {
return true return true;
} : } :
function () { function () {
return false return false;
}; };
} }
if (typeof stopPropagation !== 'function') { if (typeof stopPropagation !== "function") {
stopPropagation = stopPropagation ? stopPropagation = stopPropagation ?
function () { function () {
return true return true;
} : } :
function () { function () {
return false return false;
}; };
} }
@ -112,7 +112,7 @@
}; };
BI.WheelHandler.prototype = { BI.WheelHandler.prototype = {
constructor: BI.WheelHandler, constructor: BI.WheelHandler,
onWheel: function (/*object*/ event) { onWheel: function (/* object*/ event) {
var normalizedEvent = normalizeWheel(event); var normalizedEvent = normalizeWheel(event);
var deltaX = this._deltaX + normalizedEvent.pixelX; var deltaX = this._deltaX + normalizedEvent.pixelX;
var deltaY = this._deltaY + normalizedEvent.pixelY; var deltaY = this._deltaY + normalizedEvent.pixelY;

6
src/core/utils/heap.js

@ -1,6 +1,6 @@
;
(function () { (function () {
function defaultComparator(a, b) { function defaultComparator (a, b) {
return a < b; return a < b;
} }
@ -111,5 +111,5 @@
index = swapIndex; index = swapIndex;
} }
} }
} };
})(); })();

14
src/core/utils/helper.scroll.js

@ -1,4 +1,4 @@
;(function () { (function () {
var clamp = function (min, value, max) { var clamp = function (min, value, max) {
if (value < min) { if (value < min) {
return min; return min;
@ -18,9 +18,9 @@
}; };
BI.TableScrollHelper = function (rowCount, BI.TableScrollHelper = function (rowCount,
defaultRowHeight, defaultRowHeight,
viewportHeight, viewportHeight,
rowHeightGetter) { rowHeightGetter) {
this._rowOffsets = BI.PrefixIntervalTree.uniform(rowCount, defaultRowHeight); this._rowOffsets = BI.PrefixIntervalTree.uniform(rowCount, defaultRowHeight);
this._storedHeights = new Array(rowCount); this._storedHeights = new Array(rowCount);
for (var i = 0; i < rowCount; ++i) { for (var i = 0; i < rowCount; ++i) {
@ -32,8 +32,8 @@
this._defaultRowHeight = defaultRowHeight; this._defaultRowHeight = defaultRowHeight;
this._rowHeightGetter = rowHeightGetter ? this._rowHeightGetter = rowHeightGetter ?
rowHeightGetter : function () { rowHeightGetter : function () {
return defaultRowHeight return defaultRowHeight;
}; };
this._viewportHeight = viewportHeight; this._viewportHeight = viewportHeight;
this._updateHeightsInViewport(0, 0); this._updateHeightsInViewport(0, 0);
@ -54,7 +54,7 @@
}, },
_updateHeightsInViewport: function (firstRowIndex, _updateHeightsInViewport: function (firstRowIndex,
firstRowOffset) { firstRowOffset) {
var top = firstRowOffset; var top = firstRowOffset;
var index = firstRowIndex; var index = firstRowIndex;
while (top <= this._viewportHeight && index < this._rowCount) { while (top <= this._viewportHeight && index < this._rowCount) {

22
src/core/utils/integerBufferSet.js

@ -25,18 +25,18 @@ BI.IntegerBufferSet = function () {
BI.IntegerBufferSet.prototype = { BI.IntegerBufferSet.prototype = {
constructor: BI.IntegerBufferSet, constructor: BI.IntegerBufferSet,
getSize: function () /*number*/ { getSize: function () /* number*/ {
return this._size; return this._size;
}, },
getValuePosition: function (/*number*/ value) /*?number*/ { getValuePosition: function (/* number*/ value) /* ?number*/ {
if (this._valueToPositionMap[value] === undefined) { if (this._valueToPositionMap[value] === undefined) {
return null; return null;
} }
return this._valueToPositionMap[value]; return this._valueToPositionMap[value];
}, },
getNewPositionForValue: function (/*number*/ value) /*number*/ { getNewPositionForValue: function (/* number*/ value) /* number*/ {
var newPosition = this._size; var newPosition = this._size;
this._size++; this._size++;
this._pushToHeaps(newPosition, value); this._pushToHeaps(newPosition, value);
@ -44,9 +44,9 @@ BI.IntegerBufferSet.prototype = {
return newPosition; return newPosition;
}, },
replaceFurthestValuePosition: function (/*number*/ lowValue, replaceFurthestValuePosition: function (/* number*/ lowValue,
/*number*/ highValue, /* number*/ highValue,
/*number*/ newValue) /*?number*/ { /* number*/ newValue) /* ?number*/ {
this._cleanHeaps(); this._cleanHeaps();
if (this._smallValues.empty() || this._largeValues.empty()) { if (this._smallValues.empty() || this._largeValues.empty()) {
// Threre are currently no values stored. We will have to create new // Threre are currently no values stored. We will have to create new
@ -78,10 +78,10 @@ BI.IntegerBufferSet.prototype = {
return position; return position;
}, },
_pushToHeaps: function (/*number*/ position, /*number*/ value) { _pushToHeaps: function (/* number*/ position, /* number*/ value) {
var element = { var element = {
position: position, position: position,
value:value value: value
}; };
// We can reuse the same object in both heaps, because we don't mutate them // We can reuse the same object in both heaps, because we don't mutate them
this._smallValues.push(element); this._smallValues.push(element);
@ -128,18 +128,18 @@ BI.IntegerBufferSet.prototype = {
this._largeValues = newLargeValues; this._largeValues = newLargeValues;
}, },
_cleanHeap: function (/*object*/ heap) { _cleanHeap: function (/* object*/ heap) {
while (!heap.empty() && while (!heap.empty() &&
this._valueToPositionMap[heap.peek().value] === undefined) { this._valueToPositionMap[heap.peek().value] === undefined) {
heap.pop(); heap.pop();
} }
}, },
_smallerComparator: function (/*object*/ lhs, /*object*/ rhs) /*boolean*/ { _smallerComparator: function (/* object*/ lhs, /* object*/ rhs) /* boolean*/ {
return lhs.value < rhs.value; return lhs.value < rhs.value;
}, },
_greaterComparator: function (/*object*/ lhs, /*object*/ rhs) /*boolean*/ { _greaterComparator: function (/* object*/ lhs, /* object*/ rhs) /* boolean*/ {
return lhs.value > rhs.value; return lhs.value > rhs.value;
} }
}; };

10
src/core/utils/linkedHashMap.js

@ -1,4 +1,4 @@
;
!(function () { !(function () {
BI.LinkHashMap = function () { BI.LinkHashMap = function () {
this.array = []; this.array = [];
@ -14,7 +14,7 @@
}, },
add: function (key, value) { add: function (key, value) {
if (typeof key == 'undefined') { if (typeof key === "undefined") {
return; return;
} }
if (key in this.map) { if (key in this.map) {
@ -44,7 +44,7 @@
each: function (fn, scope) { each: function (fn, scope) {
var scope = scope || window; var scope = scope || window;
var fn = fn || null; var fn = fn || null;
if (fn == null || typeof (fn) != "function") { if (fn == null || typeof (fn) !== "function") {
return; return;
} }
for (var i = 0; i < this.array.length; i++) { for (var i = 0; i < this.array.length; i++) {
@ -65,8 +65,8 @@
var array = []; var array = [];
this.each(function (key, value) { this.each(function (key, value) {
array.push(value); array.push(value);
}) });
return array; return array;
} }
} };
})(); })();

24
src/core/utils/load.js

@ -5,24 +5,24 @@ $.extend(BI, {
var config; var config;
if (BI.isObject(options)) { if (BI.isObject(options)) {
config = $.extend({ config = $.extend({
op: 'resource', op: "resource",
path: null, path: null,
type: null, type: null,
must: false must: false
}, options); }, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path; config.url = BI.servletURL + "?op=" + config.op + "&resource=" + config.path;
} else { } else {
config = { config = {
url: BI.servletURL + "?op=resource&resource=" + options, url: BI.servletURL + "?op=resource&resource=" + options,
type: arguments[1], type: arguments[1],
must: arguments[2] must: arguments[2]
} };
} }
this.$import(config.url, config.type, config.must); this.$import(config.url, config.type, config.must);
}, },
$import: function () { $import: function () {
var _LOADED = {}; // alex:保存加载过的 var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) { function loadReady (src, must) {
var $scripts = $("head script, body script"); var $scripts = $("head script, body script");
$.each($scripts, function (i, item) { $.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) { if (item.src.indexOf(src) != -1) {
@ -45,12 +45,12 @@ $.extend(BI, {
if (_LOADED[src] === true) { if (_LOADED[src] === true) {
return; return;
} }
if (ext === 'css') { if (ext === "css") {
var link = document.createElement('link'); var link = document.createElement("link");
link.rel = 'stylesheet'; link.rel = "stylesheet";
link.type = 'text/css'; link.type = "text/css";
link.href = src; link.href = src;
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName("head")[0];
head.appendChild(link); head.appendChild(link);
_LOADED[src] = true; _LOADED[src] = true;
} else { } else {
@ -65,12 +65,12 @@ $.extend(BI, {
* alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval * alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval
* 所以当status为success时就不需要再把其中的内容加到script里面去了 * 所以当status为success时就不需要再把其中的内容加到script里面去了
*/ */
if (status == 'success') { if (status == "success") {
_LOADED[src] = true; _LOADED[src] = true;
} }
} }
}) });
} }
} };
}() }()
}); });

14
src/core/utils/lru.js

@ -1,4 +1,4 @@
;
!(function () { !(function () {
BI.LRU = function (limit) { BI.LRU = function (limit) {
this.size = 0; this.size = 0;
@ -23,9 +23,9 @@
this._keymap[key] = entry; this._keymap[key] = entry;
if (this.tail) { if (this.tail) {
this.tail.newer = entry; this.tail.newer = entry;
entry.older = this.tail entry.older = this.tail;
} else { } else {
this.head = entry this.head = entry;
} }
this.tail = entry; this.tail = entry;
this.size++; this.size++;
@ -54,7 +54,7 @@
if (entry === this.tail) { if (entry === this.tail) {
return returnEntry return returnEntry
? entry ? entry
: entry.value : entry.value;
} }
// HEAD--------------TAIL // HEAD--------------TAIL
// <.older .newer> // <.older .newer>
@ -62,7 +62,7 @@
// A B C <D> E // A B C <D> E
if (entry.newer) { if (entry.newer) {
if (entry === this.head) { if (entry === this.head) {
this.head = entry.newer this.head = entry.newer;
} }
entry.newer.older = entry.older; // C <-- E. entry.newer.older = entry.older; // C <-- E.
} }
@ -77,10 +77,10 @@
this.tail = entry; this.tail = entry;
return returnEntry return returnEntry
? entry ? entry
: entry.value : entry.value;
}; };
p.has = function (key) { p.has = function (key) {
return this._keymap[key] != null; return this._keymap[key] != null;
} };
})(); })();

13
src/core/utils/md5.js

@ -1,4 +1,4 @@
;
!(function () { !(function () {
var MD5 = function (hexcase) { var MD5 = function (hexcase) {
this.hexcase = !hexcase ? 0 : 1; this.hexcase = !hexcase ? 0 : 1;
@ -167,8 +167,7 @@
*/ */
MD5.prototype.core_hmac_md5 = function (key, data) { MD5.prototype.core_hmac_md5 = function (key, data) {
var bkey = this.str2binl(key); var bkey = this.str2binl(key);
if (bkey.length > 16) if (bkey.length > 16) {bkey = this.core_md5(bkey, key.length * this.chrsz);}
bkey = this.core_md5(bkey, key.length * this.chrsz);
var ipad = Array(16), opad = Array(16); var ipad = Array(16), opad = Array(16);
for (var i = 0; i < 16; i++) { for (var i = 0; i < 16; i++) {
@ -204,8 +203,7 @@
MD5.prototype.str2binl = function (str) { MD5.prototype.str2binl = function (str) {
var bin = Array(); var bin = Array();
var mask = (1 << this.chrsz) - 1; var mask = (1 << this.chrsz) - 1;
for (var i = 0; i < str.length * this.chrsz; i += this.chrsz) for (var i = 0; i < str.length * this.chrsz; i += this.chrsz) {bin[i >> 5] |= (str.charCodeAt(i / this.chrsz) & mask) << (i % 32);}
bin[i >> 5] |= (str.charCodeAt(i / this.chrsz) & mask) << (i % 32);
return bin; return bin;
}; };
@ -233,10 +231,7 @@
| (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8)
| ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF); | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
for (var j = 0; j < 4; j++) { for (var j = 0; j < 4; j++) {
if (i * 8 + j * 6 > binarray.length * 32) if (i * 8 + j * 6 > binarray.length * 32) {str += this.b64pad;} else {str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);}
str += this.b64pad;
else
str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
} }
} }
return str; return str;

16
src/core/utils/prefixIntervalTree.js

@ -1,16 +1,16 @@
//线段树 // 线段树
;(function () { (function () {
var parent = function (node) { var parent = function (node) {
return Math.floor(node / 2); return Math.floor(node / 2);
}; };
var Int32Array = window.Int32Array || function (size) { var Int32Array = window.Int32Array || function (size) {
var xs = []; var xs = [];
for (var i = size - 1; i >= 0; --i) { for (var i = size - 1; i >= 0; --i) {
xs[i] = 0; xs[i] = 0;
} }
return xs; return xs;
}; };
var ceilLog2 = function (x) { var ceilLog2 = function (x) {
var y = 1; var y = 1;

14
src/core/utils/queue.js

@ -1,4 +1,4 @@
;
!(function () { !(function () {
BI.Queue = function (capacity) { BI.Queue = function (capacity) {
this.capacity = capacity; this.capacity = capacity;
@ -15,7 +15,7 @@
return this.array.contains(v); return this.array.contains(v);
}, },
getElementByIndex: function(index) { getElementByIndex: function (index) {
return this.array[index]; return this.array[index];
}, },
@ -45,11 +45,11 @@
this.array.remove(v); this.array.remove(v);
}, },
splice: function() { splice: function () {
this.array.splice.apply(this.array, arguments); this.array.splice.apply(this.array, arguments);
}, },
slice: function() { slice: function () {
this.array.slice.apply(this.array, arguments); this.array.slice.apply(this.array, arguments);
}, },
@ -60,7 +60,7 @@
each: function (fn, scope) { each: function (fn, scope) {
var scope = scope || window; var scope = scope || window;
var fn = fn || null; var fn = fn || null;
if (fn == null || typeof (fn) != "function") { if (fn == null || typeof (fn) !== "function") {
return; return;
} }
for (var i = 0; i < this.array.length; i++) { for (var i = 0; i < this.array.length; i++) {
@ -79,11 +79,11 @@
var self = this; var self = this;
BI.each(array, function (i, v) { BI.each(array, function (i, v) {
self.push(v); self.push(v);
}) });
}, },
clear: function () { clear: function () {
this.array.clear(); this.array.clear();
} }
} };
})(); })();

16
src/core/utils/sectionManager.js

@ -19,7 +19,7 @@
}, },
getCellIndices: function () { getCellIndices: function () {
return this._indices return this._indices;
} }
}; };
@ -37,12 +37,12 @@
BI.each(this.getSections(height, width, x, y), function (i, section) { BI.each(this.getSections(height, width, x, y), function (i, section) {
BI.each(section.getCellIndices(), function (j, index) { BI.each(section.getCellIndices(), function (j, index) {
indices[index] = index indices[index] = index;
}) });
}); });
return BI.map(BI.keys(indices), function (i, index) { return BI.map(BI.keys(indices), function (i, index) {
return indices[index] return indices[index];
}); });
}, },
@ -63,14 +63,14 @@
var key = sectionX + "." + sectionY; var key = sectionX + "." + sectionY;
if (!this._sections[key]) { if (!this._sections[key]) {
this._sections[key] = new Section(this._sectionSize, this._sectionSize, sectionX * this._sectionSize, sectionY * this._sectionSize) this._sections[key] = new Section(this._sectionSize, this._sectionSize, sectionX * this._sectionSize, sectionY * this._sectionSize);
} }
sections.push(this._sections[key]) sections.push(this._sections[key]);
} }
} }
return sections return sections;
}, },
getTotalSectionCount: function () { getTotalSectionCount: function () {
@ -84,5 +84,5 @@
section.addCellIndex(index); section.addCellIndex(index);
}); });
} }
} };
})(); })();

16
src/core/utils/tableRowBuffer.js

@ -1,4 +1,4 @@
;
(function () { (function () {
var clamp = function (value, min, max) { var clamp = function (value, min, max) {
if (value < min) { if (value < min) {
@ -13,9 +13,9 @@
var MAX_BUFFER_ROWS = 10; var MAX_BUFFER_ROWS = 10;
BI.TableRowBuffer = function (rowsCount, BI.TableRowBuffer = function (rowsCount,
defaultRowHeight, defaultRowHeight,
viewportHeight, viewportHeight,
rowHeightGetter) { rowHeightGetter) {
this._bufferSet = new BI.IntegerBufferSet(); this._bufferSet = new BI.IntegerBufferSet();
this._defaultRowHeight = defaultRowHeight; this._defaultRowHeight = defaultRowHeight;
this._viewportRowsBegin = 0; this._viewportRowsBegin = 0;
@ -63,7 +63,7 @@
}, },
getRows: function (firstRowIndex, getRows: function (firstRowIndex,
firstRowOffset) { firstRowOffset) {
var top = firstRowOffset; var top = firstRowOffset;
var totalHeight = top; var totalHeight = top;
var rowIndex = firstRowIndex; var rowIndex = firstRowIndex;
@ -89,8 +89,8 @@
}, },
_addRowToBuffer: function (rowIndex, _addRowToBuffer: function (rowIndex,
firstViewportRowIndex, firstViewportRowIndex,
lastViewportRowIndex) { lastViewportRowIndex) {
var rowPosition = this._bufferSet.getValuePosition(rowIndex); var rowPosition = this._bufferSet.getValuePosition(rowIndex);
var viewportRowsCount = lastViewportRowIndex - firstViewportRowIndex + 1; var viewportRowsCount = lastViewportRowIndex - firstViewportRowIndex + 1;
var allowedRowsCount = viewportRowsCount + this._bufferRowsCount * 2; var allowedRowsCount = viewportRowsCount + this._bufferRowsCount * 2;
@ -114,6 +114,6 @@
this._rows[rowPosition] = rowIndex; this._rows[rowPosition] = rowIndex;
} }
} }
} };
})(); })();

38
src/core/utils/tree.js

@ -1,4 +1,4 @@
;
(function () { (function () {
BI.Tree = function () { BI.Tree = function () {
this.root = new BI.Node(BI.UUID()); this.root = new BI.Node(BI.UUID());
@ -46,7 +46,7 @@
n.set("data", child); n.set("data", child);
queue.push(n); queue.push(n);
self.addNode(parent, n); self.addNode(parent, n);
}) });
} }
}, },
@ -59,8 +59,8 @@
return BI.extend({ return BI.extend({
id: node.id id: node.id
}, BI.deepClone(node.get("data")), (children.length > 0 ? { }, BI.deepClone(node.get("data")), (children.length > 0 ? {
children: children children: children
} : {})); } : {}));
}, },
toJSON: function (node) { toJSON: function (node) {
@ -82,8 +82,8 @@
}, BI.deepClone(node.get("data")), { }, BI.deepClone(node.get("data")), {
node: node node: node
}, (children.length > 0 ? { }, (children.length > 0 ? {
children: children children: children
} : {})); } : {}));
}, },
toJSONWithNode: function (node) { toJSONWithNode: function (node) {
@ -161,7 +161,7 @@
this._inOrderTraverse(this.root, callback); this._inOrderTraverse(this.root, callback);
}, },
//中序遍历(递归) // 中序遍历(递归)
_inOrderTraverse: function (node, callback) { _inOrderTraverse: function (node, callback) {
if (node != null) { if (node != null) {
this._inOrderTraverse(node.getLeft()); this._inOrderTraverse(node.getLeft());
@ -170,7 +170,7 @@
} }
}, },
//中序遍历(非递归) // 中序遍历(非递归)
nrInOrderTraverse: function (callback) { nrInOrderTraverse: function (callback) {
var stack = []; var stack = [];
@ -190,7 +190,7 @@
this._preOrderTraverse(this.root, callback); this._preOrderTraverse(this.root, callback);
}, },
//先序遍历(递归) // 先序遍历(递归)
_preOrderTraverse: function (node, callback) { _preOrderTraverse: function (node, callback) {
if (node != null) { if (node != null) {
callback && callback(node); callback && callback(node);
@ -199,7 +199,7 @@
} }
}, },
//先序遍历(非递归) // 先序遍历(非递归)
nrPreOrderTraverse: function (callback) { nrPreOrderTraverse: function (callback) {
var stack = []; var stack = [];
@ -221,7 +221,7 @@
this._postOrderTraverse(this.root, callback); this._postOrderTraverse(this.root, callback);
}, },
//后序遍历(递归) // 后序遍历(递归)
_postOrderTraverse: function (node, callback) { _postOrderTraverse: function (node, callback) {
if (node != null) { if (node != null) {
this._postOrderTraverse(node.getLeft()); this._postOrderTraverse(node.getLeft());
@ -230,12 +230,12 @@
} }
}, },
//后续遍历(非递归) // 后续遍历(非递归)
nrPostOrderTraverse: function (callback) { nrPostOrderTraverse: function (callback) {
var stack = []; var stack = [];
var node = this.root; var node = this.root;
var preNode = null;//表示最近一次访问的节点 var preNode = null;// 表示最近一次访问的节点
while (node != null || !BI.isEmpty(stack)) { while (node != null || !BI.isEmpty(stack)) {
@ -465,9 +465,9 @@
delete tmpMap[sNodes[i].id].pId; delete tmpMap[sNodes[i].id].pId;
} }
return r; return r;
} else {
return [sNodes];
} }
return [sNodes];
}, },
treeFormat: function (sNodes) { treeFormat: function (sNodes) {
@ -496,9 +496,9 @@
} }
} }
return r; return r;
} else {
return [sNodes];
} }
return [sNodes];
}, },
traversal: function (array, callback) { traversal: function (array, callback) {
@ -511,7 +511,7 @@
return true; return true;
} }
self.traversal(item.children, callback); self.traversal(item.children, callback);
}) });
} }
}) });
})(); })();

12
src/core/utils/vector.js

@ -1,4 +1,4 @@
//向量操作 // 向量操作
BI.Vector = function (x, y) { BI.Vector = function (x, y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
@ -20,7 +20,7 @@ BI.Region = function (x, y, w, h) {
}; };
BI.Region.prototype = { BI.Region.prototype = {
constructor: BI.Region, constructor: BI.Region,
//判断两个区域是否相交,若相交,则要么顶点互相包含,要么矩形边界(或对角线)相交 // 判断两个区域是否相交,若相交,则要么顶点互相包含,要么矩形边界(或对角线)相交
isIntersects: function (obj) { isIntersects: function (obj) {
if (this.isPointInside(obj.x, obj.y) || if (this.isPointInside(obj.x, obj.y) ||
this.isPointInside(obj.x + obj.w, obj.y) || this.isPointInside(obj.x + obj.w, obj.y) ||
@ -32,9 +32,9 @@ BI.Region.prototype = {
obj.isPointInside(this.x, this.y + this.h) || obj.isPointInside(this.x, this.y + this.h) ||
obj.isPointInside(this.x + this.w, this.y + this.h)) { obj.isPointInside(this.x + this.w, this.y + this.h)) {
return true; return true;
} else if (obj.x != null && obj.y != null)//判断矩形对角线相交 |v1 X v2||v1 X v3| < 0 } else if (obj.x != null && obj.y != null)// 判断矩形对角线相交 |v1 X v2||v1 X v3| < 0
{ {
var vector1 = new BI.Vector(this.w, this.h);//矩形对角线向量 var vector1 = new BI.Vector(this.w, this.h);// 矩形对角线向量
var vector2 = new BI.Vector(obj.x - this.x, obj.y - this.y); var vector2 = new BI.Vector(obj.x - this.x, obj.y - this.y);
var vector3 = new BI.Vector(vector2.x + obj.w, vector2.y + obj.h); var vector3 = new BI.Vector(vector2.x + obj.w, vector2.y + obj.h);
if ((vector1.cross(vector2) * vector1.cross(vector3)) < 0) { if ((vector1.cross(vector2) * vector1.cross(vector3)) < 0) {
@ -43,7 +43,7 @@ BI.Region.prototype = {
} }
return false; return false;
}, },
//判断一个点是否在这个区域内部 // 判断一个点是否在这个区域内部
isPointInside: function (x, y) { isPointInside: function (x, y) {
if (this.x == null || this.y == null) { if (this.x == null || this.y == null) {
return false; return false;
@ -53,7 +53,7 @@ BI.Region.prototype = {
} }
return false; return false;
}, },
//返回区域的重心,因为是矩形所以返回中点 // 返回区域的重心,因为是矩形所以返回中点
getPosition: function () { getPosition: function () {
var pos = []; var pos = [];
pos.push(this.x + this.w / 2); pos.push(this.x + this.w / 2);

102
src/core/var.js

@ -16,57 +16,57 @@ _.extend(BI, {
}, },
empty: null, empty: null,
Key: { Key: {
"48": "0", 48: "0",
"49": "1", 49: "1",
"50": "2", 50: "2",
"51": "3", 51: "3",
"52": "4", 52: "4",
"53": "5", 53: "5",
"54": "6", 54: "6",
"55": "7", 55: "7",
"56": "8", 56: "8",
"57": "9", 57: "9",
"65": "a", 65: "a",
"66": "b", 66: "b",
"67": "c", 67: "c",
"68": "d", 68: "d",
"69": "e", 69: "e",
"70": "f", 70: "f",
"71": "g", 71: "g",
"72": "h", 72: "h",
"73": "i", 73: "i",
"74": "j", 74: "j",
"75": "k", 75: "k",
"76": "l", 76: "l",
"77": "m", 77: "m",
"78": "n", 78: "n",
"79": "o", 79: "o",
"80": "p", 80: "p",
"81": "q", 81: "q",
"82": "r", 82: "r",
"83": "s", 83: "s",
"84": "t", 84: "t",
"85": "u", 85: "u",
"86": "v", 86: "v",
"87": "w", 87: "w",
"88": "x", 88: "x",
"89": "y", 89: "y",
"90": "z", 90: "z",
"96": "0", 96: "0",
"97": "1", 97: "1",
"98": "2", 98: "2",
"99": "3", 99: "3",
"100": "4", 100: "4",
"101": "5", 101: "5",
"102": "6", 102: "6",
"103": "7", 103: "7",
"104": "8", 104: "8",
"105": "9", 105: "9",
"106": "*", 106: "*",
"107": "+", 107: "+",
"109": "-", 109: "-",
"110": ".", 110: ".",
"111": "/" 111: "/"
}, },
KeyCode: { KeyCode: {
BACKSPACE: 8, BACKSPACE: 8,

20
src/core/widget.js

@ -20,10 +20,10 @@ BI.Widget = BI.inherit(BI.OB, {
baseCls: "", baseCls: "",
extraCls: "", extraCls: "",
cls: "" cls: ""
}) });
}, },
//生命周期函数 // 生命周期函数
beforeCreate: null, beforeCreate: null,
created: null, created: null,
@ -111,7 +111,7 @@ BI.Widget = BI.inherit(BI.OB, {
_initVisual: function () { _initVisual: function () {
var o = this.options; var o = this.options;
if (o.invisible) { if (o.invisible) {
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none"); this.element.css("display", "none");
} }
}, },
@ -142,8 +142,8 @@ BI.Widget = BI.inherit(BI.OB, {
BI.each(els, function (i, el) { BI.each(els, function (i, el) {
BI.createWidget(el, { BI.createWidget(el, {
element: self element: self
}) });
}) });
} }
// if (this._isRoot === true || !(this instanceof BI.Layout)) { // if (this._isRoot === true || !(this instanceof BI.Layout)) {
this._mount(); this._mount();
@ -201,7 +201,7 @@ BI.Widget = BI.inherit(BI.OB, {
} else if (enable === false) { } else if (enable === false) {
this.options.disabled = true; this.options.disabled = true;
} }
//递归将所有子组件使能 // 递归将所有子组件使能
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
!child._manualSetEnable && child._setEnable && child._setEnable(enable); !child._manualSetEnable && child._setEnable && child._setEnable(enable);
}); });
@ -213,7 +213,7 @@ BI.Widget = BI.inherit(BI.OB, {
} else if (valid === false) { } else if (valid === false) {
this.options.invalid = true; this.options.invalid = true;
} }
//递归将所有子组件使有效 // 递归将所有子组件使有效
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
!child._manualSetValid && child._setValid && child._setValid(valid); !child._manualSetValid && child._setValid && child._setValid(valid);
}); });
@ -240,7 +240,7 @@ BI.Widget = BI.inherit(BI.OB, {
setVisible: function (visible) { setVisible: function (visible) {
this._setVisible(visible); this._setVisible(visible);
if (visible === true) { if (visible === true) {
//用this.element.show()会把display属性改成block // 用this.element.show()会把display属性改成block
this.element.css("display", ""); this.element.css("display", "");
this._mount(); this._mount();
} else if (visible === false) { } else if (visible === false) {
@ -261,7 +261,7 @@ BI.Widget = BI.inherit(BI.OB, {
doBehavior: function () { doBehavior: function () {
var args = arguments; var args = arguments;
//递归将所有子组件使有效 // 递归将所有子组件使有效
BI.each(this._children, function (i, child) { BI.each(this._children, function (i, child) {
child.doBehavior && child.doBehavior.apply(child, args); child.doBehavior && child.doBehavior.apply(child, args);
}); });
@ -350,7 +350,7 @@ BI.Widget = BI.inherit(BI.OB, {
if (BI.isPlainObject(key)) { if (BI.isPlainObject(key)) {
BI.each(key, function (k, v) { BI.each(key, function (k, v) {
self.attr(k, v); self.attr(k, v);
}) });
return; return;
} }
if (BI.isNotNull(value)) { if (BI.isNotNull(value)) {

58
src/core/wrapper/layout.js

@ -11,9 +11,9 @@
BI.Layout = BI.inherit(BI.Widget, { BI.Layout = BI.inherit(BI.Widget, {
props: function () { props: function () {
return { return {
scrollable: null, //true, false, null scrollable: null, // true, false, null
scrollx: false, //true, false scrollx: false, // true, false
scrolly: false, //true, false scrolly: false, // true, false
items: [] items: []
}; };
}, },
@ -25,16 +25,16 @@ BI.Layout = BI.inherit(BI.Widget, {
_init4Margin: function () { _init4Margin: function () {
if (this.options.top) { if (this.options.top) {
this.element.css('top', this.options.top); this.element.css("top", this.options.top);
} }
if (this.options.left) { if (this.options.left) {
this.element.css('left', this.options.left); this.element.css("left", this.options.left);
} }
if (this.options.bottom) { if (this.options.bottom) {
this.element.css('bottom', this.options.bottom); this.element.css("bottom", this.options.bottom);
} }
if (this.options.right) { if (this.options.right) {
this.element.css('right', this.options.right); this.element.css("right", this.options.right);
} }
}, },
@ -116,8 +116,8 @@ BI.Layout = BI.inherit(BI.Widget, {
var self = this; var self = this;
return eq(item1, item2); return eq(item1, item2);
//不比较函数 // 不比较函数
function eq(a, b, aStack, bStack) { function eq (a, b, aStack, bStack) {
if (a === b) { if (a === b) {
return a !== 0 || 1 / a === 1 / b; return a !== 0 || 1 / a === 1 / b;
} }
@ -126,20 +126,20 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
var className = Object.prototype.toString.call(a); var className = Object.prototype.toString.call(a);
switch (className) { switch (className) {
case '[object RegExp]': case "[object RegExp]":
case '[object String]': case "[object String]":
return '' + a === '' + b; return "" + a === "" + b;
case '[object Number]': case "[object Number]":
if (+a !== +a) { if (+a !== +a) {
return +b !== +b; return +b !== +b;
} }
return +a === 0 ? 1 / +a === 1 / b : +a === +b; return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]': case "[object Date]":
case '[object Boolean]': case "[object Boolean]":
return +a === +b; return +a === +b;
} }
var areArrays = className === '[object Array]'; var areArrays = className === "[object Array]";
if (!areArrays) { if (!areArrays) {
if (BI.isFunction(a) && BI.isFunction(b)) { if (BI.isFunction(a) && BI.isFunction(b)) {
return true; return true;
@ -306,7 +306,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this._getWrapper().append(fragment); this._getWrapper().append(fragment);
BI.each(added, function (i, w) { BI.each(added, function (i, w) {
w._mount(); w._mount();
}) });
}, },
prependItems: function (items) { prependItems: function (items) {
@ -325,7 +325,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this._getWrapper().prepend(fragment); this._getWrapper().prepend(fragment);
BI.each(added, function (i, w) { BI.each(added, function (i, w) {
w._mount(); w._mount();
}) });
}, },
getValue: function () { getValue: function () {
@ -346,7 +346,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child = self._children[self._getChildName(i)]) { if (child = self._children[self._getChildName(i)]) {
child.setValue(v); child.setValue(v);
} }
}) });
}, },
setText: function (v) { setText: function (v) {
@ -355,7 +355,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child = self._children[self._getChildName(i)]) { if (child = self._children[self._getChildName(i)]) {
child.setText(v); child.setText(v);
} }
}) });
}, },
patchItem: function (oldVnode, vnode, index) { patchItem: function (oldVnode, vnode, index) {
@ -433,31 +433,31 @@ BI.Layout = BI.inherit(BI.Widget, {
self._children[self._getChildName(i)] = children[key]; self._children[self._getChildName(i)] = children[key];
}); });
function sameVnode(vnode1, vnode2, oldIndex, newIndex) { function sameVnode (vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1); vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2); vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) { if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key; return vnode1.key === vnode2.key;
} }
if (oldIndex >= 0) { if (oldIndex >= 0) {
return oldIndex === newIndex return oldIndex === newIndex;
} }
} }
function addNode(vnode, index) { function addNode (vnode, index) {
var opt = self._getOptions(vnode); var opt = self._getOptions(vnode);
var key = opt.key == null ? index : opt.key; var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode); return children[key] = self._addElement(key, vnode);
} }
function addVnodes(before, vnodes, startIdx, endIdx) { function addVnodes (before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) { for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx); var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before, false, startIdx); insertBefore(node, before, false, startIdx);
} }
} }
function removeVnodes(vnodes, startIdx, endIdx) { function removeVnodes (vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) { for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]); var node = self._getOptions(vnodes[startIdx]);
var key = node.key == null ? startIdx : node.key; var key = node.key == null ? startIdx : node.key;
@ -465,7 +465,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
} }
function insertBefore(insert, before, isNext, index) { function insertBefore (insert, before, isNext, index) {
insert = self._getOptions(insert); insert = self._getOptions(insert);
before = before && self._getOptions(before); before = before && self._getOptions(before);
var insertKey = BI.isKey(insert.key) ? insert.key : index; var insertKey = BI.isKey(insert.key) ? insert.key : index;
@ -523,7 +523,7 @@ BI.Layout = BI.inherit(BI.Widget, {
stroke: function (items) { stroke: function (items) {
var self = this; var self = this;
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
self._addElement(i, item); self._addElement(i, item);
} }
}); });
@ -536,7 +536,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child === nameOrWidget) { if (child === nameOrWidget) {
removeIndex = name; removeIndex = name;
} }
}) });
} else { } else {
removeIndex = nameOrWidget; removeIndex = nameOrWidget;
} }
@ -570,4 +570,4 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
}); });
BI.shortcut('bi.layout', BI.Layout); BI.shortcut("bi.layout", BI.Layout);

14
src/core/wrapper/layout/adapt/absolute.center.js

@ -25,12 +25,12 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments); var w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments);
w.element.css({ w.element.css({
"position": "absolute", position: "absolute",
"left": o.hgap + o.lgap + (item.lgap || 0), left: o.hgap + o.lgap + (item.lgap || 0),
"right": o.hgap + o.rgap + (item.rgap || 0), right: o.hgap + o.rgap + (item.rgap || 0),
"top": o.vgap + o.tgap + (item.tgap || 0), top: o.vgap + o.tgap + (item.tgap || 0),
"bottom": o.vgap + o.bgap + (item.bgap || 0), bottom: o.vgap + o.bgap + (item.bgap || 0),
"margin": "auto" margin: "auto"
}); });
return w; return w;
}, },
@ -44,4 +44,4 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.absolute_center_adapt', BI.AbsoluteCenterLayout); BI.shortcut("bi.absolute_center_adapt", BI.AbsoluteCenterLayout);

10
src/core/wrapper/layout/adapt/absolute.horizontal.js

@ -25,10 +25,10 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.AbsoluteHorizontalLayout.superclass._addElement.apply(this, arguments); var w = BI.AbsoluteHorizontalLayout.superclass._addElement.apply(this, arguments);
w.element.css({ w.element.css({
"position": "absolute", position: "absolute",
"left": o.hgap + o.lgap + (item.lgap || 0), left: o.hgap + o.lgap + (item.lgap || 0),
"right": o.hgap + o.rgap + (item.rgap || 0), right: o.hgap + o.rgap + (item.rgap || 0),
"margin": "auto" margin: "auto"
}); });
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css("top", o.vgap + o.tgap + (item.tgap || 0)); w.element.css("top", o.vgap + o.tgap + (item.tgap || 0));
@ -48,4 +48,4 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.absolute_horizontal_adapt', BI.AbsoluteHorizontalLayout); BI.shortcut("bi.absolute_horizontal_adapt", BI.AbsoluteHorizontalLayout);

14
src/core/wrapper/layout/adapt/absolute.vertical.js

@ -25,12 +25,12 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.AbsoluteVerticalLayout.superclass._addElement.apply(this, arguments); var w = BI.AbsoluteVerticalLayout.superclass._addElement.apply(this, arguments);
w.element.css({ w.element.css({
"position": "absolute", position: "absolute",
"left": item.lgap, left: item.lgap,
"right": item.rgap, right: item.rgap,
"top": o.vgap + o.tgap + (item.tgap || 0), top: o.vgap + o.tgap + (item.tgap || 0),
"bottom": o.vgap + o.bgap + (item.bgap || 0), bottom: o.vgap + o.bgap + (item.bgap || 0),
"margin": "auto" margin: "auto"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css("left", o.hgap + o.lgap + (item.lgap || 0)); w.element.css("left", o.hgap + o.lgap + (item.lgap || 0));
@ -50,4 +50,4 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.absolute_vertical_adapt', BI.AbsoluteVerticalLayout); BI.shortcut("bi.absolute_vertical_adapt", BI.AbsoluteVerticalLayout);

34
src/core/wrapper/layout/adapt/adapt.center.js

@ -18,13 +18,13 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
}, },
render: function () { render: function () {
BI.CenterAdaptLayout.superclass.render.apply(this, arguments); BI.CenterAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({ this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
"position": "relative", position: "relative",
"width": "100%", width: "100%",
"height": "100%", height: "100%",
"white-space": "nowrap", "white-space": "nowrap",
"border-spacing": "0px", "border-spacing": "0px",
"border": "none", border: "none",
"border-collapse": "separate" "border-collapse": "separate"
}); });
this.$tr = $("<tr>"); this.$tr = $("<tr>");
@ -38,7 +38,7 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) { if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({ td = BI.createWidget({
type: "bi.default", type: "bi.default",
tagName: "td", tagName: "td",
@ -57,32 +57,32 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element"); td.element.addClass("first-element");
} }
td.element.css({ td.element.css({
"position": "relative", position: "relative",
"height": "100%", height: "100%",
"vertical-align": "middle", "vertical-align": "middle",
"margin": "0", margin: "0",
"padding": "0", padding: "0",
"border": "none" border: "none"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return td; return td;
}, },
@ -107,7 +107,7 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
// console.log("center_adapt布局不需要resize"); // console.log("center_adapt布局不需要resize");
}, },
_getWrapper: function(){ _getWrapper: function () {
return this.$tr; return this.$tr;
}, },
@ -116,4 +116,4 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.center_adapt', BI.CenterAdaptLayout); BI.shortcut("bi.center_adapt", BI.CenterAdaptLayout);

28
src/core/wrapper/layout/adapt/adapt.horizontal.js

@ -19,12 +19,12 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
}, },
render: function () { render: function () {
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments); BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({ this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
"position": "relative", position: "relative",
"width": "100%", width: "100%",
"white-space": "nowrap", "white-space": "nowrap",
"border-spacing": "0px", "border-spacing": "0px",
"border": "none", border: "none",
"border-collapse": "separate" "border-collapse": "separate"
}); });
this.$tr = $("<tr>"); this.$tr = $("<tr>");
@ -38,7 +38,7 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) { if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({ td = BI.createWidget({
type: "bi.default", type: "bi.default",
tagName: "td", tagName: "td",
@ -57,31 +57,31 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element"); td.element.addClass("first-element");
} }
td.element.css({ td.element.css({
"position": "relative", position: "relative",
"vertical-align": o.verticalAlign, "vertical-align": o.verticalAlign,
"margin": "0", margin: "0",
"padding": "0", padding: "0",
"border": "none" border: "none"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return td; return td;
}, },
@ -115,4 +115,4 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal_adapt', BI.HorizontalAdaptLayout); BI.shortcut("bi.horizontal_adapt", BI.HorizontalAdaptLayout);

18
src/core/wrapper/layout/adapt/adapt.leftrightvertical.js

@ -30,8 +30,8 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
addItem: function () { addItem: function () {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -73,7 +73,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.left_right_vertical_adapt', BI.LeftRightVerticalAdaptLayout); BI.shortcut("bi.left_right_vertical_adapt", BI.LeftRightVerticalAdaptLayout);
BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, { BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
@ -96,8 +96,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
addItem: function () { addItem: function () {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -122,7 +122,7 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.left_vertical_adapt', BI.LeftVerticalAdaptLayout); BI.shortcut("bi.left_vertical_adapt", BI.LeftVerticalAdaptLayout);
BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, { BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
props: function () { props: function () {
@ -144,8 +144,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
}, },
addItem: function () { addItem: function () {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -170,4 +170,4 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.right_vertical_adapt', BI.RightVerticalAdaptLayout); BI.shortcut("bi.right_vertical_adapt", BI.RightVerticalAdaptLayout);

32
src/core/wrapper/layout/adapt/adapt.vertical.js

@ -18,13 +18,13 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
render: function () { render: function () {
BI.VerticalAdaptLayout.superclass.render.apply(this, arguments); BI.VerticalAdaptLayout.superclass.render.apply(this, arguments);
var o = this.options; var o = this.options;
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({ this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
"position": "relative", position: "relative",
"width": o.horizontalAlign === BI.HorizontalAlign.Stretch ? "100%" : "auto", width: o.horizontalAlign === BI.HorizontalAlign.Stretch ? "100%" : "auto",
"height": "100%", height: "100%",
"white-space": "nowrap", "white-space": "nowrap",
"border-spacing": "0px", "border-spacing": "0px",
"border": "none", border: "none",
"border-collapse": "separate" "border-collapse": "separate"
}); });
this.$tr = $("<tr>"); this.$tr = $("<tr>");
@ -38,7 +38,7 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) { if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
td = BI.createWidget({ td = BI.createWidget({
type: "bi.default", type: "bi.default",
tagName: "td", tagName: "td",
@ -57,32 +57,32 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element"); td.element.addClass("first-element");
} }
td.element.css({ td.element.css({
"position": "relative", position: "relative",
"height": "100%", height: "100%",
"vertical-align": "middle", "vertical-align": "middle",
"margin": "0", margin: "0",
"padding": "0", padding: "0",
"border": "none" border: "none"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return td; return td;
}, },
@ -116,4 +116,4 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.vertical_adapt', BI.VerticalAdaptLayout); BI.shortcut("bi.vertical_adapt", BI.VerticalAdaptLayout);

14
src/core/wrapper/layout/adapt/auto.horizontal.js

@ -25,28 +25,28 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.HorizontalAutoLayout.superclass._addElement.apply(this, arguments); var w = BI.HorizontalAutoLayout.superclass._addElement.apply(this, arguments);
w.element.css({ w.element.css({
"position": "relative", position: "relative",
"margin": "0px auto" margin: "0px auto"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -60,4 +60,4 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal_auto', BI.HorizontalAutoLayout); BI.shortcut("bi.horizontal_auto", BI.HorizontalAutoLayout);

6
src/core/wrapper/layout/adapt/float.center.js

@ -24,8 +24,8 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
}, },
addItem: function () { addItem: function () {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
mounted: function () { mounted: function () {
@ -71,4 +71,4 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.float_center_adapt', BI.FloatCenterAdaptLayout); BI.shortcut("bi.float_center_adapt", BI.FloatCenterAdaptLayout);

2
src/core/wrapper/layout/adapt/float.horizontal.js

@ -67,4 +67,4 @@ BI.FloatHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal_float', BI.FloatHorizontalLayout); BI.shortcut("bi.horizontal_float", BI.FloatHorizontalLayout);

4
src/core/wrapper/layout/flex/flex.center.js

@ -19,7 +19,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments); var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "flex-shrink": "0"}); w.element.css({position: "relative", "flex-shrink": "0"});
return w; return w;
}, },
@ -32,4 +32,4 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_center', BI.FlexCenterLayout); BI.shortcut("bi.flex_center", BI.FlexCenterLayout);

12
src/core/wrapper/layout/flex/flex.horizontal.js

@ -30,26 +30,26 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments); var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "flex-shrink": "0"}); w.element.css({position: "relative", "flex-shrink": "0"});
if (o.hgap + o.lgap + (item.lgap || 0) > 0) { if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) > 0) { if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) > 0) { if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) > 0) { if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -63,4 +63,4 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_horizontal', BI.FlexHorizontalLayout); BI.shortcut("bi.flex_horizontal", BI.FlexHorizontalLayout);

12
src/core/wrapper/layout/flex/flex.vertical.center.js

@ -29,26 +29,26 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments); var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "flex-shrink": "0"}); w.element.css({position: "relative", "flex-shrink": "0"});
if (o.hgap + o.lgap + (item.lgap || 0) > 0) { if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) > 0) { if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) > 0) { if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) > 0) { if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -62,4 +62,4 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_vertical_center', BI.FlexVerticalCenter); BI.shortcut("bi.flex_vertical_center", BI.FlexVerticalCenter);

6
src/core/wrapper/layout/flex/wrapper/flex.wrapper.center.js

@ -20,7 +20,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments); var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative"}); w.element.css({position: "relative"});
return w; return w;
}, },
@ -40,7 +40,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
} }
}, },
_getWrapper: function(){ _getWrapper: function () {
return this.$wrapper; return this.$wrapper;
}, },
@ -53,4 +53,4 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_wrapper_center', BI.FlexCenterLayout); BI.shortcut("bi.flex_wrapper_center", BI.FlexCenterLayout);

14
src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js

@ -30,26 +30,26 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments); var w = BI.FlexHorizontalLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative"}); w.element.css({position: "relative"});
if (o.hgap + o.lgap + (item.lgap || 0) > 0) { if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) > 0) { if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) > 0) { if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) > 0) { if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -70,7 +70,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
} }
}, },
_getWrapper: function(){ _getWrapper: function () {
return this.$wrapper; return this.$wrapper;
}, },
@ -83,4 +83,4 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_wrapper_horizontal', BI.FlexHorizontalLayout); BI.shortcut("bi.flex_wrapper_horizontal", BI.FlexHorizontalLayout);

12
src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.center.js

@ -30,26 +30,26 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments); var w = BI.FlexVerticalCenter.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative"}); w.element.css({position: "relative"});
if (o.hgap + o.lgap + (item.lgap || 0) > 0) { if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) > 0) { if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) > 0) { if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) > 0) { if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -83,4 +83,4 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.flex_wrapper_vertical_center', BI.FlexVerticalCenter); BI.shortcut("bi.flex_wrapper_vertical_center", BI.FlexVerticalCenter);

34
src/core/wrapper/layout/layout.absolute.js

@ -25,60 +25,60 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
var w = BI.AbsoluteLayout.superclass._addElement.apply(this, arguments); var w = BI.AbsoluteLayout.superclass._addElement.apply(this, arguments);
var left = 0, right = 0, top = 0, bottom = 0; var left = 0, right = 0, top = 0, bottom = 0;
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({"left": item.left}); w.element.css({left: item.left});
left += item.left; left += item.left;
} }
if (BI.isNotNull(item.right)) { if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right}); w.element.css({right: item.right});
right += item.right; right += item.right;
} }
if (BI.isNotNull(item.top)) { if (BI.isNotNull(item.top)) {
w.element.css({"top": item.top}); w.element.css({top: item.top});
top += item.top; top += item.top;
} }
if (BI.isNotNull(item.bottom)) { if (BI.isNotNull(item.bottom)) {
w.element.css({"bottom": item.bottom}); w.element.css({bottom: item.bottom});
bottom += item.bottom; bottom += item.bottom;
} }
if (BI.isNotNull(o.hgap)) { if (BI.isNotNull(o.hgap)) {
left += o.hgap; left += o.hgap;
w.element.css({"left": left}); w.element.css({left: left});
right += o.hgap; right += o.hgap;
w.element.css({"right": right}); w.element.css({right: right});
} }
if (BI.isNotNull(o.vgap)) { if (BI.isNotNull(o.vgap)) {
top += o.vgap; top += o.vgap;
w.element.css({"top": top}); w.element.css({top: top});
bottom += o.vgap; bottom += o.vgap;
w.element.css({"bottom": bottom}); w.element.css({bottom: bottom});
} }
if (BI.isNotNull(o.lgap)) { if (BI.isNotNull(o.lgap)) {
left += o.lgap; left += o.lgap;
w.element.css({"left": left}); w.element.css({left: left});
} }
if (BI.isNotNull(o.rgap)) { if (BI.isNotNull(o.rgap)) {
right += o.rgap; right += o.rgap;
w.element.css({"right": right}); w.element.css({right: right});
} }
if (BI.isNotNull(o.tgap)) { if (BI.isNotNull(o.tgap)) {
top += o.tgap; top += o.tgap;
w.element.css({"top": top}); w.element.css({top: top});
} }
if (BI.isNotNull(o.bgap)) { if (BI.isNotNull(o.bgap)) {
bottom += o.bgap; bottom += o.bgap;
w.element.css({"bottom": bottom}); w.element.css({bottom: bottom});
} }
if (BI.isNotNull(item.width)) { if (BI.isNotNull(item.width)) {
w.element.css({"width": item.width}); w.element.css({width: item.width});
} }
if (BI.isNotNull(item.height)) { if (BI.isNotNull(item.height)) {
w.element.css({"height": item.height}); w.element.css({height: item.height});
} }
w.element.css({"position": "absolute"}); w.element.css({position: "absolute"});
return w; return w;
}, },
@ -90,7 +90,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
this.options.items = items || []; this.options.items = items || [];
var self = this; var self = this;
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
if (!BI.isWidget(item) && !item.el) { if (!BI.isWidget(item) && !item.el) {
throw new Error("el must be exist"); throw new Error("el must be exist");
} }
@ -104,4 +104,4 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.absolute', BI.AbsoluteLayout); BI.shortcut("bi.absolute", BI.AbsoluteLayout);

32
src/core/wrapper/layout/layout.adaptive.js

@ -18,64 +18,64 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments); var w = BI.AdaptiveLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative"}); w.element.css({position: "relative"});
var left = 0, right = 0, top = 0, bottom = 0; var left = 0, right = 0, top = 0, bottom = 0;
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({ w.element.css({
"margin-left": item.left "margin-left": item.left
}) });
} }
if (BI.isNotNull(item.right)) { if (BI.isNotNull(item.right)) {
w.element.css({ w.element.css({
"margin-right": item.right "margin-right": item.right
}) });
} }
if (BI.isNotNull(item.top)) { if (BI.isNotNull(item.top)) {
w.element.css({ w.element.css({
"margin-top": item.top "margin-top": item.top
}) });
} }
if (BI.isNotNull(item.bottom)) { if (BI.isNotNull(item.bottom)) {
w.element.css({ w.element.css({
"margin-bottom": item.bottom "margin-bottom": item.bottom
}) });
} }
if (BI.isNotNull(o.hgap)) { if (BI.isNotNull(o.hgap)) {
left += o.hgap; left += o.hgap;
w.element.css({"left": left}); w.element.css({left: left});
right += o.hgap; right += o.hgap;
w.element.css({"right": right}); w.element.css({right: right});
} }
if (BI.isNotNull(o.vgap)) { if (BI.isNotNull(o.vgap)) {
top += o.vgap; top += o.vgap;
w.element.css({"top": top}); w.element.css({top: top});
bottom += o.vgap; bottom += o.vgap;
w.element.css({"bottom": bottom}); w.element.css({bottom: bottom});
} }
if (BI.isNotNull(o.lgap)) { if (BI.isNotNull(o.lgap)) {
left += o.lgap; left += o.lgap;
w.element.css({"left": left}); w.element.css({left: left});
} }
if (BI.isNotNull(o.rgap)) { if (BI.isNotNull(o.rgap)) {
right += o.rgap; right += o.rgap;
w.element.css({"right": right}); w.element.css({right: right});
} }
if (BI.isNotNull(o.tgap)) { if (BI.isNotNull(o.tgap)) {
top += o.tgap; top += o.tgap;
w.element.css({"top": top}); w.element.css({top: top});
} }
if (BI.isNotNull(o.bgap)) { if (BI.isNotNull(o.bgap)) {
bottom += o.bgap; bottom += o.bgap;
w.element.css({"bottom": bottom}); w.element.css({bottom: bottom});
} }
if (BI.isNotNull(item.width)) { if (BI.isNotNull(item.width)) {
w.element.css({"width": item.width}); w.element.css({width: item.width});
} }
if (BI.isNotNull(item.height)) { if (BI.isNotNull(item.height)) {
w.element.css({"height": item.height}); w.element.css({height: item.height});
} }
return w; return w;
}, },
@ -89,4 +89,4 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.adaptive', BI.AdaptiveLayout); BI.shortcut("bi.adaptive", BI.AdaptiveLayout);

40
src/core/wrapper/layout/layout.border.js

@ -22,10 +22,10 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
addItem: function (item) { addItem: function (item) {
// do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function(regions){ stroke: function (regions) {
var item; var item;
var top = 0; var top = 0;
var bottom = 0; var bottom = 0;
@ -41,11 +41,11 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
} }
this.getWidgetByName(this.getName() + "north").element.height(item.height) this.getWidgetByName(this.getName() + "north").element.height(item.height)
.css({ .css({
"position": "absolute", position: "absolute",
"top": (item.top || 0), top: (item.top || 0),
"left": (item.left || 0), left: (item.left || 0),
"right": (item.right || 0), right: (item.right || 0),
"bottom": "initial" bottom: "initial"
}); });
} }
top = (item.height || 0) + (item.top || 0) + (item.bottom || 0); top = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
@ -61,11 +61,11 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
} }
this.getWidgetByName(this.getName() + "south").element.height(item.height) this.getWidgetByName(this.getName() + "south").element.height(item.height)
.css({ .css({
"position": "absolute", position: "absolute",
"bottom": (item.bottom || 0), bottom: (item.bottom || 0),
"left": (item.left || 0), left: (item.left || 0),
"right": (item.right || 0), right: (item.right || 0),
"top": "initial" top: "initial"
}); });
} }
bottom = (item.height || 0) + (item.top || 0) + (item.bottom || 0); bottom = (item.height || 0) + (item.top || 0) + (item.bottom || 0);
@ -81,11 +81,11 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
} }
this.getWidgetByName(this.getName() + "west").element.width(item.width) this.getWidgetByName(this.getName() + "west").element.width(item.width)
.css({ .css({
"position": "absolute", position: "absolute",
"left": (item.left || 0), left: (item.left || 0),
top: top, top: top,
bottom: bottom, bottom: bottom,
"right": "initial" right: "initial"
}); });
} }
left = (item.width || 0) + (item.left || 0) + (item.right || 0); left = (item.width || 0) + (item.left || 0) + (item.right || 0);
@ -101,11 +101,11 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
} }
this.getWidgetByName(this.getName() + "east").element.width(item.width) this.getWidgetByName(this.getName() + "east").element.width(item.width)
.css({ .css({
"position": "absolute", position: "absolute",
"right": (item.right || 0), right: (item.right || 0),
top: top, top: top,
bottom: bottom, bottom: bottom,
"left": "initial" left: "initial"
}); });
} }
right = (item.width || 0) + (item.left || 0) + (item.right || 0); right = (item.width || 0) + (item.left || 0) + (item.right || 0);
@ -119,7 +119,7 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
this.addWidget(this.getName() + "center", w); this.addWidget(this.getName() + "center", w);
} }
this.getWidgetByName(this.getName() + "center").element this.getWidgetByName(this.getName() + "center").element
.css({"position": "absolute", "top": top, "bottom": bottom, "left": left, "right": right}); .css({position: "absolute", top: top, bottom: bottom, left: left, right: right});
} }
} }
}, },
@ -129,4 +129,4 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.border', BI.BorderLayout); BI.shortcut("bi.border", BI.BorderLayout);

30
src/core/wrapper/layout/layout.card.js

@ -26,7 +26,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var self = this, o = this.options; var self = this, o = this.options;
this.showIndex = void 0; this.showIndex = void 0;
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
if (!self.hasWidget(item.cardName)) { if (!self.hasWidget(item.cardName)) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.on(BI.Events.DESTROY, function () { w.on(BI.Events.DESTROY, function () {
@ -41,7 +41,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
} else { } else {
var w = self.getWidgetByName(item.cardName); var w = self.getWidgetByName(item.cardName);
} }
w.element.css({"position": "absolute", "top": "0", "right": "0", "bottom": "0", "left": "0"}); w.element.css({position: "absolute", top: "0", right: "0", bottom: "0", left: "0"});
w.setVisible(false); w.setVisible(false);
} }
}); });
@ -100,11 +100,11 @@ BI.CardLayout = BI.inherit(BI.Layout, {
} }
var widget = BI.createWidget(cardItem); var widget = BI.createWidget(cardItem);
widget.element.css({ widget.element.css({
"position": "relative", position: "relative",
"top": "0", top: "0",
"left": "0", left: "0",
"width": "100%", width: "100%",
"height": "100%" height: "100%"
}).appendTo(this.element); }).appendTo(this.element);
widget.invisible(); widget.invisible();
this.addWidget(cardName, widget); this.addWidget(cardName, widget);
@ -114,7 +114,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
showCardByName: function (name, action, callback) { showCardByName: function (name, action, callback) {
var self = this; var self = this;
//name不存在的时候全部隐藏 // name不存在的时候全部隐藏
var exist = this.isCardExisted(name); var exist = this.isCardExisted(name);
if (this.showIndex != null) { if (this.showIndex != null) {
this.lastShowIndex = this.showIndex; this.lastShowIndex = this.showIndex;
@ -125,10 +125,10 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var el = self._children[item.cardName]; var el = self._children[item.cardName];
if (el) { if (el) {
if (name != item.cardName) { if (name != item.cardName) {
//动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 // 动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了
!flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible();
} else { } else {
(BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback());
} }
} }
}); });
@ -139,7 +139,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
this.showIndex = this.lastShowIndex; this.showIndex = this.lastShowIndex;
BI.each(this.options.items, function (i, item) { BI.each(this.options.items, function (i, item) {
self._children[item.cardName].setVisible(self.showIndex == i); self._children[item.cardName].setVisible(self.showIndex == i);
}) });
}, },
setDefaultShowName: function (name) { setDefaultShowName: function (name) {
@ -154,7 +154,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
getAllCardNames: function () { getAllCardNames: function () {
return BI.map(this.options.items, function (i, item) { return BI.map(this.options.items, function (i, item) {
return item.cardName; return item.cardName;
}) });
}, },
getShowingCard: function () { getShowingCard: function () {
@ -168,7 +168,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var self = this; var self = this;
BI.each(this.getAllCardNames(), function (i, name) { BI.each(this.getAllCardNames(), function (i, name) {
self.deleteCardByName(name); self.deleteCardByName(name);
}) });
}, },
hideAllCard: function () { hideAllCard: function () {
@ -197,7 +197,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (child === nameOrWidget) { if (child === nameOrWidget) {
removeName = name; removeName = name;
} }
}) });
} else { } else {
removeName = nameOrWidget; removeName = nameOrWidget;
} }
@ -206,4 +206,4 @@ BI.CardLayout = BI.inherit(BI.Layout, {
} }
} }
}); });
BI.shortcut('bi.card', BI.CardLayout); BI.shortcut("bi.card", BI.CardLayout);

10
src/core/wrapper/layout/layout.default.js

@ -27,22 +27,22 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -56,4 +56,4 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.default', BI.DefaultLayout); BI.shortcut("bi.default", BI.DefaultLayout);

30
src/core/wrapper/layout/layout.division.js

@ -33,7 +33,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
// height: 0.33, // height: 0.33,
// el: {type: 'bi.button', text: 'button3'} // el: {type: 'bi.button', text: 'button3'}
// } // }
//] // ]
}); });
}, },
render: function () { render: function () {
@ -47,16 +47,16 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
addItem: function (item) { addItem: function (item) {
// do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function(items){ stroke: function (items) {
var o = this.options; var o = this.options;
var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0); var rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
var map = BI.makeArray(rows), widths = {}, heights = {}; var map = BI.makeArray(rows), widths = {}, heights = {};
function firstElement(item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row") item.addClass("first-row");
} }
if (col === 0) { if (col === 0) {
item.addClass("first-col"); item.addClass("first-col");
@ -66,7 +66,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
item.addClass("center-element"); item.addClass("center-element");
} }
function firstObject(item, row, col) { function firstObject (item, row, col) {
var cls = ""; var cls = "";
if (row === 0) { if (row === 0) {
cls += " first-row"; cls += " first-row";
@ -79,13 +79,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element"; item.cls = (item.cls || "") + cls + " center-element";
} }
function first(item, row, col) { function first (item, row, col) {
if (item instanceof BI.Widget) { if (item instanceof BI.Widget) {
firstElement(item.element, row, col); firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) { } else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col); firstElement(item.el.element, row, col);
} else if (item.el) { } else if (item.el) {
firstObject(item.el, row, col) firstObject(item.el, row, col);
} else { } else {
firstObject(item, row, col); firstObject(item, row, col);
} }
@ -119,13 +119,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
w = this.getWidgetByName(this.getName() + i + "_" + j); w = this.getWidgetByName(this.getName() + i + "_" + j);
} }
var left = totalW * 100 / widths[i]; var left = totalW * 100 / widths[i];
w.element.css({"position": "absolute", "left": left + "%"}); w.element.css({position: "absolute", left: left + "%"});
if (j > 0) { if (j > 0) {
var lastW = this.getWidgetByName(this.getName() + i + "_" + (j - 1)); var lastW = this.getWidgetByName(this.getName() + i + "_" + (j - 1));
lastW.element.css({"right": (100 - left) + "%"}); lastW.element.css({right: (100 - left) + "%"});
} }
if (j == o.columns - 1) { if (j == o.columns - 1) {
w.element.css({"right": "0%"}); w.element.css({right: "0%"});
} }
first(w, i, j); first(w, i, j);
totalW += map[i][j].width; totalW += map[i][j].width;
@ -136,13 +136,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < o.rows; i++) { for (var i = 0; i < o.rows; i++) {
var w = this.getWidgetByName(this.getName() + i + "_" + j); var w = this.getWidgetByName(this.getName() + i + "_" + j);
var top = totalH * 100 / heights[j]; var top = totalH * 100 / heights[j];
w.element.css({"top": top + "%"}); w.element.css({top: top + "%"});
if (i > 0) { if (i > 0) {
var lastW = this.getWidgetByName(this.getName() + (i - 1) + "_" + j); var lastW = this.getWidgetByName(this.getName() + (i - 1) + "_" + j);
lastW.element.css({"bottom": (100 - top) + "%"}); lastW.element.css({bottom: (100 - top) + "%"});
} }
if (i == o.rows - 1) { if (i == o.rows - 1) {
w.element.css({"bottom": "0%"}); w.element.css({bottom: "0%"});
} }
totalH += map[i][j].height; totalH += map[i][j].height;
} }
@ -154,4 +154,4 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.division', BI.DivisionLayout); BI.shortcut("bi.division", BI.DivisionLayout);

20
src/core/wrapper/layout/layout.flow.js

@ -27,15 +27,15 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FloatLeftLayout.superclass._addElement.apply(this, arguments); var w = BI.FloatLeftLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "float": "left"}); w.element.css({position: "relative", float: "left"});
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({"left": item.left}); w.element.css({left: item.left});
} }
if (BI.isNotNull(item.right)) { if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right}); w.element.css({right: item.right});
} }
if (BI.isNotNull(item.top)) { if (BI.isNotNull(item.top)) {
w.element.css({"top": item.top}); w.element.css({top: item.top});
} }
if ((item.lgap || 0) + o.hgap + o.lgap !== 0) { if ((item.lgap || 0) + o.hgap + o.lgap !== 0) {
w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap); w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
@ -61,7 +61,7 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.left', BI.FloatLeftLayout); BI.shortcut("bi.left", BI.FloatLeftLayout);
/** /**
* 靠右对齐的自由浮动布局 * 靠右对齐的自由浮动布局
@ -92,15 +92,15 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments); var w = BI.FloatRightLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "float": "right"}); w.element.css({position: "relative", float: "right"});
if (BI.isNotNull(item.left)) { if (BI.isNotNull(item.left)) {
w.element.css({"left": item.left}); w.element.css({left: item.left});
} }
if (BI.isNotNull(item.right)) { if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right}); w.element.css({right: item.right});
} }
if (BI.isNotNull(item.top)) { if (BI.isNotNull(item.top)) {
w.element.css({"top": item.top}); w.element.css({top: item.top});
} }
if ((item.lgap || 0) + o.hgap + o.lgap !== 0) { if ((item.lgap || 0) + o.hgap + o.lgap !== 0) {
w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap); w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
@ -126,4 +126,4 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.right', BI.FloatRightLayout); BI.shortcut("bi.right", BI.FloatRightLayout);

28
src/core/wrapper/layout/layout.grid.js

@ -11,7 +11,7 @@ BI.GridLayout = BI.inherit(BI.Layout, {
columns: null, columns: null,
rows: null, rows: null,
items: [] items: []
/*[ /* [
{ {
column: 0, column: 0,
row: 0, row: 0,
@ -40,8 +40,8 @@ BI.GridLayout = BI.inherit(BI.Layout, {
}, },
addItem: function () { addItem: function () {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -52,9 +52,9 @@ BI.GridLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < rows; i++) { for (var i = 0; i < rows; i++) {
els[i] = []; els[i] = [];
} }
function firstElement(item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row") item.addClass("first-row");
} }
if (col === 0) { if (col === 0) {
item.addClass("first-col"); item.addClass("first-col");
@ -64,7 +64,7 @@ BI.GridLayout = BI.inherit(BI.Layout, {
item.addClass("center-element"); item.addClass("center-element");
} }
function firstObject(item, row, col) { function firstObject (item, row, col) {
var cls = ""; var cls = "";
if (row === 0) { if (row === 0) {
cls += " first-row"; cls += " first-row";
@ -77,13 +77,13 @@ BI.GridLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element"; item.cls = (item.cls || "") + cls + " center-element";
} }
function first(item, row, col) { function first (item, row, col) {
if (item instanceof BI.Widget) { if (item instanceof BI.Widget) {
firstElement(item.element, row, col); firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) { } else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col); firstElement(item.el.element, row, col);
} else if (item.el) { } else if (item.el) {
firstObject(item.el, row, col) firstObject(item.el, row, col);
} else { } else {
firstObject(item, row, col); firstObject(item, row, col);
} }
@ -107,11 +107,11 @@ BI.GridLayout = BI.inherit(BI.Layout, {
} }
first(els[i][j], i, j); first(els[i][j], i, j);
els[i][j].element.css({ els[i][j].element.css({
"position": "absolute", position: "absolute",
"top": height * i + "%", top: height * i + "%",
"left": width * j + "%", left: width * j + "%",
"right": (100 - (width * (j + 1))) + "%", right: (100 - (width * (j + 1))) + "%",
"bottom": (100 - (height * (i + 1))) + "%" bottom: (100 - (height * (i + 1))) + "%"
}); });
this.addWidget(els[i][j]); this.addWidget(els[i][j]);
} }
@ -123,4 +123,4 @@ BI.GridLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.grid', BI.GridLayout); BI.shortcut("bi.grid", BI.GridLayout);

42
src/core/wrapper/layout/layout.horizontal.js

@ -20,11 +20,11 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
}, },
render: function () { render: function () {
BI.HorizontalLayout.superclass.render.apply(this, arguments); BI.HorizontalLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({ this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
"position": "relative", position: "relative",
"white-space": "nowrap", "white-space": "nowrap",
"border-spacing": "0px", "border-spacing": "0px",
"border": "none", border: "none",
"border-collapse": "separate" "border-collapse": "separate"
}); });
this.$tr = $("<tr>"); this.$tr = $("<tr>");
@ -38,7 +38,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i];
if (!this.hasWidget(this._getChildName(i))) { if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({"position": "relative", "margin": "0px auto"}); w.element.css({position: "relative", margin: "0px auto"});
td = BI.createWidget({ td = BI.createWidget({
type: "bi.default", type: "bi.default",
tagName: "td", tagName: "td",
@ -57,31 +57,31 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element"); td.element.addClass("first-element");
} }
td.element.css({ td.element.css({
"position": "relative", position: "relative",
"vertical-align": o.verticalAlign, "vertical-align": o.verticalAlign,
"margin": "0", margin: "0",
"padding": "0", padding: "0",
"border": "none" border: "none"
}); });
if (o.hgap + o.lgap + (item.lgap || 0) > 0) { if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) > 0) { if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.tgap + (item.tgap || 0) > 0) { if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) > 0) { if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return td; return td;
}, },
@ -107,7 +107,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
// console.log("horizontal layout do not need to resize"); // console.log("horizontal layout do not need to resize");
}, },
_getWrapper: function(){ _getWrapper: function () {
return this.$tr; return this.$tr;
}, },
@ -116,7 +116,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal', BI.HorizontalLayout); BI.shortcut("bi.horizontal", BI.HorizontalLayout);
/** /**
* 水平布局 * 水平布局
@ -138,33 +138,33 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
}, },
render: function () { render: function () {
BI.HorizontalCellLayout.superclass.render.apply(this, arguments); BI.HorizontalCellLayout.superclass.render.apply(this, arguments);
this.element.css({"display": "table", "vertical-align": "top"}); this.element.css({display: "table", "vertical-align": "top"});
this.populate(this.options.items); this.populate(this.options.items);
}, },
_addElement: function (i, item) { _addElement: function (i, item) {
var o = this.options; var o = this.options;
var w = BI.HorizontalCellLayout.superclass._addElement.apply(this, arguments); var w = BI.HorizontalCellLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative", "display": "table-cell", "vertical-align": "middle"}); w.element.css({position: "relative", display: "table-cell", "vertical-align": "middle"});
if (o.hgap + o.lgap > 0) { if (o.hgap + o.lgap > 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + "px" "margin-left": o.hgap + o.lgap + "px"
}) });
} }
if (o.hgap + o.rgap > 0) { if (o.hgap + o.rgap > 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + "px" "margin-right": o.hgap + o.rgap + "px"
}) });
} }
if (o.vgap + o.tgap > 0) { if (o.vgap + o.tgap > 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + "px" "margin-top": o.vgap + o.tgap + "px"
}) });
} }
if (o.vgap + o.bgap > 0) { if (o.vgap + o.bgap > 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + "px" "margin-bottom": o.vgap + o.bgap + "px"
}) });
} }
return w; return w;
}, },
@ -178,4 +178,4 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal_cell', BI.HorizontalCellLayout); BI.shortcut("bi.horizontal_cell", BI.HorizontalCellLayout);

8
src/core/wrapper/layout/layout.lattice.js

@ -11,7 +11,7 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
props: function () { props: function () {
return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), { return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-lattice-layout clearfix" baseCls: "bi-lattice-layout clearfix"
//columnSize: [0.2, 0.2, 0.6], // columnSize: [0.2, 0.2, 0.6],
}); });
}, },
render: function () { render: function () {
@ -25,9 +25,9 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
if (o.columnSize && o.columnSize[i]) { if (o.columnSize && o.columnSize[i]) {
var width = o.columnSize[i] / BI.sum(o.columnSize) * 100 + "%"; var width = o.columnSize[i] / BI.sum(o.columnSize) * 100 + "%";
} else { } else {
var width = 1 / this.options.items.length * 100 + "%" var width = 1 / this.options.items.length * 100 + "%";
} }
w.element.css({"position": "relative", "float": "left", "width": width}); w.element.css({position: "relative", float: "left", width: width});
return w; return w;
}, },
@ -52,4 +52,4 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.lattice', BI.LatticeLayout); BI.shortcut("bi.lattice", BI.LatticeLayout);

30
src/core/wrapper/layout/layout.table.js

@ -9,19 +9,19 @@ BI.TableLayout = BI.inherit(BI.Layout, {
return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), { return BI.extend(BI.TableLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-table-layout", baseCls: "bi-table-layout",
scrolly: true, scrolly: true,
columnSize: [200, 200, 'fill'], columnSize: [200, 200, "fill"],
rowSize: 30, //or [30,30,30] rowSize: 30, // or [30,30,30]
hgap: 0, hgap: 0,
vgap: 0, vgap: 0,
items: [[ items: [[
{ {
el: {text: 'label1'} el: {text: "label1"}
}, },
{ {
el: {text: 'label2'} el: {text: "label2"}
}, },
{ {
el: {text: 'label3'} el: {text: "label3"}
} }
]] ]]
}); });
@ -36,9 +36,9 @@ BI.TableLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var abs = [], left = 0, right = 0, i, j; var abs = [], left = 0, right = 0, i, j;
function firstElement(item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row") item.addClass("first-row");
} }
if (col === 0) { if (col === 0) {
item.addClass("first-col"); item.addClass("first-col");
@ -48,7 +48,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
item.addClass("center-element"); item.addClass("center-element");
} }
function firstObject(item, row, col) { function firstObject (item, row, col) {
var cls = ""; var cls = "";
if (row === 0) { if (row === 0) {
cls += " first-row"; cls += " first-row";
@ -61,13 +61,13 @@ BI.TableLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element"; item.cls = (item.cls || "") + cls + " center-element";
} }
function first(item, row, col) { function first (item, row, col) {
if (item instanceof BI.Widget) { if (item instanceof BI.Widget) {
firstElement(item.element, row, col); firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) { } else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col); firstElement(item.el.element, row, col);
} else if (item.el) { } else if (item.el) {
firstObject(item.el, row, col) firstObject(item.el, row, col);
} else { } else {
firstObject(item, row, col); firstObject(item, row, col);
} }
@ -95,7 +95,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
bottom: 0, bottom: 0,
right: o.columnSize[j] <= 1 ? right * 100 + "%" : right, right: o.columnSize[j] <= 1 ? right * 100 + "%" : right,
width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j]
}, arr[j])) }, arr[j]));
right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap); right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap);
} else { } else {
throw new Error("item with fill can only be one"); throw new Error("item with fill can only be one");
@ -108,7 +108,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
bottom: 0, bottom: 0,
left: left <= 1 ? left * 100 + "%" : left, left: left <= 1 ? left * 100 + "%" : left,
right: right <= 1 ? right * 100 + "%" : right right: right <= 1 ? right * 100 + "%" : right
}, arr[i])) }, arr[i]));
} }
var w = BI.createWidget({ var w = BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -118,10 +118,10 @@ BI.TableLayout = BI.inherit(BI.Layout, {
if (this.rows > 0) { if (this.rows > 0) {
this.getWidgetByName(this.getName() + (this.rows - 1)).element.css({ this.getWidgetByName(this.getName() + (this.rows - 1)).element.css({
"margin-bottom": o.vgap "margin-bottom": o.vgap
}) });
} }
w.element.css({ w.element.css({
"position": "relative" position: "relative"
}); });
this.addWidget(this.getName() + (this.rows++), w); this.addWidget(this.getName() + (this.rows++), w);
return w; return w;
@ -143,4 +143,4 @@ BI.TableLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.table', BI.TableLayout); BI.shortcut("bi.table", BI.TableLayout);

48
src/core/wrapper/layout/layout.tape.js

@ -16,15 +16,15 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
items: [ items: [
{ {
width: 100, width: 100,
el: {type: 'bi.button', text: 'button1'} el: {type: "bi.button", text: "button1"}
}, },
{ {
width: 'fill', width: "fill",
el: {type: 'bi.button', text: 'button2'} el: {type: "bi.button", text: "button2"}
}, },
{ {
width: 200, width: 200,
el: {type: 'bi.button', text: 'button3'} el: {type: "bi.button", text: "button3"}
} }
] ]
}); });
@ -39,7 +39,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
}, },
addItem: function (item) { addItem: function (item) {
// do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -52,7 +52,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
} else { } else {
w = self.getWidgetByName(self.getName() + i + ""); w = self.getWidgetByName(self.getName() + i + "");
} }
w.element.css({"position": "absolute", top: o.vgap + o.tgap + "px", bottom: o.vgap + o.bgap + "px"}); w.element.css({position: "absolute", top: o.vgap + o.tgap + "px", bottom: o.vgap + o.bgap + "px"});
}); });
var left = {}, right = {}; var left = {}, right = {};
@ -65,10 +65,10 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
left[i] = left[i - 1] + items[i - 1].width + 2 * o.hgap + o.lgap + o.rgap; left[i] = left[i - 1] + items[i - 1].width + 2 * o.hgap + o.lgap + o.rgap;
} }
if (item.width < 1 && item.width >= 0) { if (item.width < 1 && item.width >= 0) {
w.element.css({"left": left[i] * 100 + "%", width: item.width * 100 + "%"}) w.element.css({left: left[i] * 100 + "%", width: item.width * 100 + "%"});
} else { } else {
w.element.css({ w.element.css({
"left": left[i] + o.hgap + o.lgap + "px", left: left[i] + o.hgap + o.lgap + "px",
width: BI.isNumber(item.width) ? item.width : "" width: BI.isNumber(item.width) ? item.width : ""
}); });
} }
@ -82,17 +82,17 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
right[i] = right[i + 1] + items[i + 1].width + 2 * o.hgap + o.lgap + o.rgap; right[i] = right[i + 1] + items[i + 1].width + 2 * o.hgap + o.lgap + o.rgap;
} }
if (item.width < 1 && item.width >= 0) { if (item.width < 1 && item.width >= 0) {
w.element.css({"right": right[i] * 100 + "%", width: item.width * 100 + "%"}) w.element.css({right: right[i] * 100 + "%", width: item.width * 100 + "%"});
} else { } else {
w.element.css({ w.element.css({
"right": right[i] + o.hgap + o.rgap + "px", right: right[i] + o.hgap + o.rgap + "px",
width: BI.isNumber(item.width) ? item.width : "" width: BI.isNumber(item.width) ? item.width : ""
}); });
} }
if (!BI.isNumber(item.width)) { if (!BI.isNumber(item.width)) {
return true; return true;
} }
}) });
}, },
populate: function (items) { populate: function (items) {
@ -100,7 +100,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.htape', BI.HTapeLayout); BI.shortcut("bi.htape", BI.HTapeLayout);
/** /**
* 垂直tape布局 * 垂直tape布局
@ -120,15 +120,15 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
items: [ items: [
{ {
height: 100, height: 100,
el: {type: 'bi.button', text: 'button1'} el: {type: "bi.button", text: "button1"}
}, },
{ {
height: 'fill', height: "fill",
el: {type: 'bi.button', text: 'button2'} el: {type: "bi.button", text: "button2"}
}, },
{ {
height: 200, height: 200,
el: {type: 'bi.button', text: 'button3'} el: {type: "bi.button", text: "button3"}
} }
] ]
}); });
@ -144,7 +144,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
addItem: function (item) { addItem: function (item) {
// do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -157,7 +157,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
} else { } else {
w = self.getWidgetByName(self.getName() + i + ""); w = self.getWidgetByName(self.getName() + i + "");
} }
w.element.css({"position": "absolute", left: o.hgap + o.lgap + "px", right: o.hgap + o.rgap + "px"}); w.element.css({position: "absolute", left: o.hgap + o.lgap + "px", right: o.hgap + o.rgap + "px"});
}); });
var top = {}, bottom = {}; var top = {}, bottom = {};
@ -170,10 +170,10 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
top[i] = top[i - 1] + items[i - 1].height + 2 * o.vgap + o.tgap + o.bgap; top[i] = top[i - 1] + items[i - 1].height + 2 * o.vgap + o.tgap + o.bgap;
} }
if (item.height < 1 && item.height >= 0) { if (item.height < 1 && item.height >= 0) {
w.element.css({"top": top[i] * 100 + "%", height: item.height * 100 + "%"}) w.element.css({top: top[i] * 100 + "%", height: item.height * 100 + "%"});
} else { } else {
w.element.css({ w.element.css({
"top": top[i] + o.vgap + o.tgap + "px", top: top[i] + o.vgap + o.tgap + "px",
height: BI.isNumber(item.height) ? item.height : "" height: BI.isNumber(item.height) ? item.height : ""
}); });
} }
@ -187,17 +187,17 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
bottom[i] = bottom[i + 1] + items[i + 1].height + 2 * o.vgap + o.tgap + o.bgap; bottom[i] = bottom[i + 1] + items[i + 1].height + 2 * o.vgap + o.tgap + o.bgap;
} }
if (item.height < 1 && item.height >= 0) { if (item.height < 1 && item.height >= 0) {
w.element.css({"bottom": bottom[i] * 100 + "%", height: item.height * 100 + "%"}) w.element.css({bottom: bottom[i] * 100 + "%", height: item.height * 100 + "%"});
} else { } else {
w.element.css({ w.element.css({
"bottom": bottom[i] + o.vgap + o.bgap + "px", bottom: bottom[i] + o.vgap + o.bgap + "px",
height: BI.isNumber(item.height) ? item.height : "" height: BI.isNumber(item.height) ? item.height : ""
}); });
} }
if (!BI.isNumber(item.height)) { if (!BI.isNumber(item.height)) {
return true; return true;
} }
}) });
}, },
populate: function (items) { populate: function (items) {
@ -205,4 +205,4 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.vtape', BI.VTapeLayout); BI.shortcut("bi.vtape", BI.VTapeLayout);

42
src/core/wrapper/layout/layout.td.js

@ -12,25 +12,25 @@ BI.TdLayout = BI.inherit(BI.Layout, {
vgap: 0, vgap: 0,
items: [[ items: [[
{ {
el: {text: 'label1'} el: {text: "label1"}
}, },
{ {
el: {text: 'label2'} el: {text: "label2"}
}, },
{ {
el: {text: 'label3'} el: {text: "label3"}
} }
]] ]]
}); });
}, },
render: function () { render: function () {
BI.TdLayout.superclass.render.apply(this, arguments); BI.TdLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({ this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
"position": "relative", position: "relative",
"width": "100%", width: "100%",
"height": "100%", height: "100%",
"border-spacing": "0px", "border-spacing": "0px",
"border": "none", border: "none",
"border-collapse": "separate" "border-collapse": "separate"
}); });
this.rows = 0; this.rows = 0;
@ -40,9 +40,9 @@ BI.TdLayout = BI.inherit(BI.Layout, {
_addElement: function (idx, arr) { _addElement: function (idx, arr) {
var o = this.options; var o = this.options;
function firstElement(item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row") item.addClass("first-row");
} }
if (col === 0) { if (col === 0) {
item.addClass("first-col"); item.addClass("first-col");
@ -52,7 +52,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
item.addClass("center-element"); item.addClass("center-element");
} }
function firstObject(item, row, col) { function firstObject (item, row, col) {
var cls = ""; var cls = "";
if (row === 0) { if (row === 0) {
cls += " first-row"; cls += " first-row";
@ -65,13 +65,13 @@ BI.TdLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element"; item.cls = (item.cls || "") + cls + " center-element";
} }
function first(item, row, col) { function first (item, row, col) {
if (item instanceof BI.Widget) { if (item instanceof BI.Widget) {
firstElement(item.element, row, col); firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) { } else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col); firstElement(item.el.element, row, col);
} else if (item.el) { } else if (item.el) {
firstObject(item.el, row, col) firstObject(item.el, row, col);
} else { } else {
firstObject(item, row, col); firstObject(item, row, col);
} }
@ -84,7 +84,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
var w = BI.createWidget(arr[i]); var w = BI.createWidget(arr[i]);
w.element.css({"position": "relative", "top": "0", "left": "0", "margin": "0px auto"}); w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"});
if (arr[i].lgap) { if (arr[i].lgap) {
w.element.css({"margin-left": arr[i].lgap + "px"}); w.element.css({"margin-left": arr[i].lgap + "px"});
} }
@ -99,19 +99,19 @@ BI.TdLayout = BI.inherit(BI.Layout, {
} }
first(w, this.rows++, i); first(w, this.rows++, i);
var td = BI.createWidget({ var td = BI.createWidget({
type: 'bi.default', type: "bi.default",
attributes: { attributes: {
width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i] width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]
}, },
tagName: 'td', tagName: "td",
items: [w] items: [w]
}); });
td.element.css({ td.element.css({
"position": "relative", position: "relative",
"vertical-align": "middle", "vertical-align": "middle",
"margin": "0", margin: "0",
"padding": "0", padding: "0",
"border": "none" border: "none"
}); });
tr.addItem(td); tr.addItem(td);
} }
@ -151,4 +151,4 @@ BI.TdLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.td', BI.TdLayout); BI.shortcut("bi.td", BI.TdLayout);

12
src/core/wrapper/layout/layout.vertical.js

@ -25,27 +25,27 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
var o = this.options; var o = this.options;
var w = BI.VerticalLayout.superclass._addElement.apply(this, arguments); var w = BI.VerticalLayout.superclass._addElement.apply(this, arguments);
w.element.css({ w.element.css({
"position": "relative" position: "relative"
}); });
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) { if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px" "margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
}) });
} }
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) { if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px" "margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
}) });
} }
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) { if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px" "margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
}) });
} }
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) { if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({ w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px" "margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
}) });
} }
return w; return w;
}, },
@ -59,4 +59,4 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.vertical', BI.VerticalLayout); BI.shortcut("bi.vertical", BI.VerticalLayout);

40
src/core/wrapper/layout/layout.window.js

@ -19,13 +19,13 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
rowSize: [100, "fill"], rowSize: [100, "fill"],
items: [[ items: [[
{ {
el: {type: 'bi.button', text: 'button1'} el: {type: "bi.button", text: "button1"}
}, },
{ {
el: {type: 'bi.button', text: 'button2'} el: {type: "bi.button", text: "button2"}
}, },
{ {
el: {type: 'bi.button', text: 'button3'} el: {type: "bi.button", text: "button3"}
} }
]] ]]
}); });
@ -41,7 +41,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
addItem: function (item) { addItem: function (item) {
// do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -52,9 +52,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.columnSize)) { if (BI.isNumber(o.columnSize)) {
o.columnSize = BI.makeArray(o.items[0].length, 1 / o.items[0].length); o.columnSize = BI.makeArray(o.items[0].length, 1 / o.items[0].length);
} }
function firstElement(item, row, col) { function firstElement (item, row, col) {
if (row === 0) { if (row === 0) {
item.addClass("first-row") item.addClass("first-row");
} }
if (col === 0) { if (col === 0) {
item.addClass("first-col"); item.addClass("first-col");
@ -64,7 +64,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
item.addClass("center-element"); item.addClass("center-element");
} }
function firstObject(item, row, col) { function firstObject (item, row, col) {
var cls = ""; var cls = "";
if (row === 0) { if (row === 0) {
cls += " first-row"; cls += " first-row";
@ -77,13 +77,13 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element"; item.cls = (item.cls || "") + cls + " center-element";
} }
function first(item, row, col) { function first (item, row, col) {
if (item instanceof BI.Widget) { if (item instanceof BI.Widget) {
firstElement(item.element, row, col); firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) { } else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col); firstElement(item.el.element, row, col);
} else if (item.el) { } else if (item.el) {
firstObject(item.el, row, col) firstObject(item.el, row, col);
} else { } else {
firstObject(item, row, col); firstObject(item, row, col);
} }
@ -96,7 +96,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
} }
if (!this.hasWidget(this.getName() + i + "_" + j)) { if (!this.hasWidget(this.getName() + i + "_" + j)) {
var w = BI.createWidget(o.items[i][j]); var w = BI.createWidget(o.items[i][j]);
w.element.css({"position": "absolute"}); w.element.css({position: "absolute"});
this.addWidget(this.getName() + i + "_" + j, w); this.addWidget(this.getName() + i + "_" + j, w);
} }
} }
@ -106,7 +106,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
top[0] = 0; top[0] = 0;
right[o.columns - 1] = 0; right[o.columns - 1] = 0;
bottom[o.rows - 1] = 0; bottom[o.rows - 1] = 0;
//从上到下 // 从上到下
for (var i = 0; i < o.rows; i++) { for (var i = 0; i < o.rows; i++) {
for (var j = 0; j < o.columns; j++) { for (var j = 0; j < o.columns; j++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + j); var wi = this.getWidgetByName(this.getName() + i + "_" + j);
@ -117,14 +117,14 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.rowSize[i])) { if (BI.isNumber(o.rowSize[i])) {
h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px"; h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px";
} }
wi.element.css({"top": t, height: h}); wi.element.css({top: t, height: h});
first(wi, i, j); first(wi, i, j);
} }
if (!BI.isNumber(o.rowSize[i])) { if (!BI.isNumber(o.rowSize[i])) {
break; break;
} }
} }
//从下到上 // 从下到上
for (var i = o.rows - 1; i >= 0; i--) { for (var i = o.rows - 1; i >= 0; i--) {
for (var j = 0; j < o.columns; j++) { for (var j = 0; j < o.columns; j++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + j); var wi = this.getWidgetByName(this.getName() + i + "_" + j);
@ -135,14 +135,14 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.rowSize[i])) { if (BI.isNumber(o.rowSize[i])) {
h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px"; h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] + "px";
} }
wi.element.css({"bottom": b, height: h}); wi.element.css({bottom: b, height: h});
first(wi, i, j); first(wi, i, j);
} }
if (!BI.isNumber(o.rowSize[i])) { if (!BI.isNumber(o.rowSize[i])) {
break; break;
} }
} }
//从左到右 // 从左到右
for (var j = 0; j < o.columns; j++) { for (var j = 0; j < o.columns; j++) {
for (var i = 0; i < o.rows; i++) { for (var i = 0; i < o.rows; i++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + j); var wi = this.getWidgetByName(this.getName() + i + "_" + j);
@ -153,25 +153,25 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.columnSize[j])) { if (BI.isNumber(o.columnSize[j])) {
w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px"; w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px";
} }
wi.element.css({"left": l, width: w}); wi.element.css({left: l, width: w});
first(wi, i, j); first(wi, i, j);
} }
if (!BI.isNumber(o.columnSize[j])) { if (!BI.isNumber(o.columnSize[j])) {
break; break;
} }
} }
//从右到左 // 从右到左
for (var j = o.columns - 1; j >= 0; j--) { for (var j = o.columns - 1; j >= 0; j--) {
for (var i = 0; i < o.rows; i++) { for (var i = 0; i < o.rows; i++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + j); var wi = this.getWidgetByName(this.getName() + i + "_" + j);
if (BI.isNull(right[j])) { if (BI.isNull(right[j])) {
right[j] = right[j + 1] + (o.columnSize[j + 1] < 1 ? o.columnSize[j + 1] : o.columnSize[j + 1] + o.hgap + o.lgap) right[j] = right[j + 1] + (o.columnSize[j + 1] < 1 ? o.columnSize[j + 1] : o.columnSize[j + 1] + o.hgap + o.lgap);
} }
var r = right[j] <= 1 ? right[j] * 100 + "%" : right[j] + o.hgap + o.rgap + "px", w = ""; var r = right[j] <= 1 ? right[j] * 100 + "%" : right[j] + o.hgap + o.rgap + "px", w = "";
if (BI.isNumber(o.columnSize[j])) { if (BI.isNumber(o.columnSize[j])) {
w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px"; w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + "px";
} }
wi.element.css({"right": r, width: w}); wi.element.css({right: r, width: w});
first(wi, i, j); first(wi, i, j);
} }
if (!BI.isNumber(o.columnSize[j])) { if (!BI.isNumber(o.columnSize[j])) {
@ -185,4 +185,4 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.window', BI.WindowLayout); BI.shortcut("bi.window", BI.WindowLayout);

6
src/core/wrapper/layout/middle/middle.center.js

@ -26,7 +26,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
}, },
addItem: function (item) { addItem: function (item) {
//do nothing // do nothing
throw new Error("cannot be added"); throw new Error("cannot be added");
}, },
@ -44,7 +44,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
}); });
}); });
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({ w.element.css({
position: "absolute", position: "absolute",
@ -72,4 +72,4 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.center', BI.CenterLayout); BI.shortcut("bi.center", BI.CenterLayout);

8
src/core/wrapper/layout/middle/middle.float.center.js

@ -25,8 +25,8 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
}, },
addItem: function (item) { addItem: function (item) {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -45,7 +45,7 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
}); });
}); });
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({ w.element.css({
position: "absolute", position: "absolute",
@ -71,4 +71,4 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.float_center', BI.FloatCenterLayout); BI.shortcut("bi.float_center", BI.FloatCenterLayout);

8
src/core/wrapper/layout/middle/middle.horizontal.js

@ -25,8 +25,8 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
}, },
addItem: function (item) { addItem: function (item) {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -43,7 +43,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
}); });
}); });
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({ w.element.css({
position: "absolute", position: "absolute",
@ -70,4 +70,4 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.horizontal_center', BI.HorizontalCenterLayout); BI.shortcut("bi.horizontal_center", BI.HorizontalCenterLayout);

8
src/core/wrapper/layout/middle/middle.vertical.js

@ -25,8 +25,8 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
}, },
addItem: function (item) { addItem: function (item) {
//do nothing // do nothing
throw new Error("cannot be added") throw new Error("cannot be added");
}, },
stroke: function (items) { stroke: function (items) {
@ -43,7 +43,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
}); });
}); });
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
if (!!item) { if (item) {
var w = BI.createWidget(item); var w = BI.createWidget(item);
w.element.css({ w.element.css({
position: "absolute", position: "absolute",
@ -70,4 +70,4 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
this._mount(); this._mount();
} }
}); });
BI.shortcut('bi.vertical_center', BI.VerticalCenterLayout); BI.shortcut("bi.vertical_center", BI.VerticalCenterLayout);
Loading…
Cancel
Save