guy 7 years ago
parent
commit
306fbea7a4
  1. 20033
      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. 18
      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

20033
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
*/
BI.Action = BI.inherit(BI.OB, {
_defaultConfig: function() {
_defaultConfig: function () {
return BI.extend(BI.Action.superclass._defaultConfig.apply(this, arguments), {
src: null,
tar: null
});
},
_init : function() {
_init: function () {
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 = {
createAction: function(key, options){
createAction: function (key, options) {
var action;
switch (key){
switch (key) {
case "show":
action = BI.ShowAction;
break;
}
return new action(options);
}
}
};

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

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

396
src/core/alias.js

@ -1,41 +1,41 @@
;(function () {
(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
function isEmpty (value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
return result;
}
// 判断是否是无效的日期
function isInvalidDate(date) {
function isInvalidDate (date) {
return date == "Invalid Date" || date == "NaN";
}
/**
* 科学计数格式
*/
function _eFormat(text, fmt) {
function _eFormat (text, fmt) {
var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) {
text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright)
text = BI._numberFormat(0.0, eleft) + "E" + BI._numberFormat(0, eright);
} else {
var isNegative = text < 0;
if (isNegative) {
text = text.substr(1);
}
var elvl = (eleft.split('.')[0] || '').length;
var elvl = (eleft.split(".")[0] || "").length;
var point = text.indexOf(".");
if (point < 0) {
point = text.length;
}
var i = 0; //第一个不为0的数的位置
text = text.replace('.', '');
var i = 0; // 第一个不为0的数的位置
text = text.replace(".", "");
for (var len = text.length; i < len; i++) {
var ech = text.charAt(i);
if (ech <= '9' && ech >= '1') {
if (ech <= "9" && ech >= "1") {
break;
}
}
@ -43,20 +43,20 @@
var left = text.substr(i, elvl);
var dis = i + elvl - text.length;
if (dis > 0) {
//末位补全0
// 末位补全0
for (var k = 0; k < dis; k++) {
left += '0';
left += "0";
}
} else {
left += '.' + text.substr(i + elvl);
left += "." + text.substr(i + elvl);
}
left = left.replace(/^[0]+/, '');
if (right < 0 && eright.indexOf('-') < 0) {
eright += ';-' + eright;
left = left.replace(/^[0]+/, "");
if (right < 0 && eright.indexOf("-") < 0) {
eright += ";-" + eright;
}
text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright);
text = BI._numberFormat(left, eleft) + "E" + BI._numberFormat(right, eright);
if (isNegative) {
text = '-' + text;
text = "-" + text;
}
}
return text;
@ -65,50 +65,50 @@
/**
* 数字格式
*/
function _numberFormat(text, format) {
var text = text + '';
//数字格式,区分正负数
var numMod = format.indexOf(';');
function _numberFormat (text, format) {
var text = text + "";
// 数字格式,区分正负数
var numMod = format.indexOf(";");
if (numMod > -1) {
if (text >= 0) {
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('.'),
tleft = tp[0] || '', fleft = fp[0] || '',
tright = tp[1] || '', fright = fp[1] || '';
//百分比,千分比的小数点移位处理
// 兼容格式处理负数的情况(copy:fr-jquery.format.js)
if (+text < 0 && format.charAt(0) !== "-") {
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)) {
var paddingZero = /[%]$/.test(format) ? '00' : '000';
var paddingZero = /[%]$/.test(format) ? "00" : "000";
tright += paddingZero;
tleft += tright.substr(0, paddingZero.length);
tleft = tleft.replace(/^0+/gi, '');
tright = tright.substr(paddingZero.length).replace(/0+$/gi, '');
tleft = tleft.replace(/^0+/gi, "");
tright = tright.substr(paddingZero.length).replace(/0+$/gi, "");
}
var right = _dealWithRight(tright, fright);
if (right.leftPlus) {
//小数点后有进位
tleft = parseInt(tleft) + 1 + '';
// 小数点后有进位
tleft = parseInt(tleft) + 1 + "";
tleft = isNaN(tleft) ? '1' : tleft;
tleft = isNaN(tleft) ? "1" : tleft;
}
right = right.num;
var left = _dealWithLeft(tleft, fleft);
if (!(/[0-9]/.test(left))) {
left = left + '0';
left = left + "0";
}
if (!(/[0-9]/.test(right))) {
return left + right;
} else {
return left + '.' + right;
}
return left + "." + right;
}
/**
@ -118,20 +118,20 @@
* @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private
*/
function _dealWithRight(tright, fright) {
var right = '', j = 0, i = 0;
function _dealWithRight (tright, fright) {
var right = "", j = 0, i = 0;
for (var len = fright.length; i < len; i++) {
var ch = fright.charAt(i);
var c = tright.charAt(j);
switch (ch) {
case '0':
case "0":
if (isEmpty(c)) {
c = '0';
c = "0";
}
right += c;
j++;
break;
case '#':
case "#":
right += c;
j++;
break;
@ -143,18 +143,18 @@
var rll = tright.substr(j);
var result = {};
if (!isEmpty(rll) && rll.charAt(0) > 4) {
//有多余字符,需要四舍五入
// 有多余字符,需要四舍五入
result.leftPlus = true;
var numReg = right.match(/^[0-9]+/);
if (numReg) {
var num = numReg[0];
var orilen = num.length;
var newnum = parseInt(num) + 1 + '';
//进位到整数部分
var newnum = parseInt(num) + 1 + "";
// 进位到整数部分
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = String.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, "0");
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -171,8 +171,8 @@
* @returns {string} 返回处理结果
* @private
*/
function _dealWithLeft(tleft, fleft) {
var left = '';
function _dealWithLeft (tleft, fleft) {
var left = "";
var j = tleft.length - 1;
var combo = -1, last = -1;
var i = fleft.length - 1;
@ -180,27 +180,27 @@
var ch = fleft.charAt(i);
var c = tleft.charAt(j);
switch (ch) {
case '0':
case "0":
if (isEmpty(c)) {
c = '0';
c = "0";
}
last = -1;
left = c + left;
j--;
break;
case '#':
case "#":
last = i;
left = c + left;
j--;
break;
case ',':
case ",":
if (!isEmpty(c)) {
//计算一个,分隔区间的长度
// 计算一个,分隔区间的长度
var com = fleft.match(/,[#0]+/);
if (com) {
combo = com[0].length - 1;
}
left = ',' + left;
left = "," + left;
}
break;
default :
@ -209,22 +209,22 @@
}
}
if (last > -1) {
//处理剩余字符
// 处理剩余字符
var tll = tleft.substr(0, j + 1);
left = left.substr(0, last) + tll + left.substr(last);
}
if (combo > 0) {
//处理,分隔区间
// 处理,分隔区间
var res = left.match(/[0-9]+,/);
if (res) {
res = res[0];
var newstr = '', n = res.length - 1 - combo;
var newstr = "", n = res.length - 1 - 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);
if (!isEmpty(lres)) {
newstr = lres + ',' + newstr;
newstr = lres + "," + newstr;
}
}
left = left.replace(/[0-9]+,/, newstr);
@ -234,21 +234,21 @@
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
if (typeof text !== "string") {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt(i);
if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]".
if (code >= 128 || code === 91 || code === 93) {// 91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]";
} else {
newText += text.charAt(i);
}
}
return newText
return newText;
};
/**
@ -262,19 +262,19 @@
if (text == null) {
return "";
}
//查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf('[') == -1) {
// 查找没有 "[", 直接返回. kunsnat:数字的时候, 不支持indexOf方法, 也是直接返回.
if (!isNaN(text) || text.indexOf("[") == -1) {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var ch = text.charAt(i);
if (ch == '[') {
var rightIdx = text.indexOf(']', i + 1);
if (ch == "[") {
var rightIdx = text.indexOf("]", i + 1);
if (rightIdx > i + 1) {
var subText = text.substring(i + 1, rightIdx);
//james:主要是考虑[CDATA[]]这样的值的出现
// james:主要是考虑[CDATA[]]这样的值的出现
if (subText.length > 0) {
ch = String.fromCharCode(eval("0x" + subText));
}
@ -289,23 +289,23 @@
return newText;
};
//replace the html special tags
// replace the html special tags
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) {
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) {
if (BI.isPlainObject(o)) {
var result = {};
$.each(o, function (k, v) {
if (!(typeof v == "string")) {
if (!(typeof v === "string")) {
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);
result[k] = BI.cjkEncode(v);
});
@ -315,36 +315,36 @@
};
BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false;
// james:这个Encode是抄的EXT的
var useHasOwn = !!{}.hasOwnProperty;
// 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 = {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"': '\\"',
"\\": '\\\\'
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
"\"": "\\\"",
"\\": "\\\\"
};
var encodeString = function (s) {
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
var c = m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return "\\u00" +
return "\"" + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
var c = m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}) + "\"";
}
return '"' + s + '"';
return "\"" + s + "\"";
};
var encodeArray = function (o) {
@ -358,7 +358,7 @@
break;
default:
if (b) {
a.push(',');
a.push(",");
}
a.push(v === null ? "null" : BI.jsonEncode(v));
b = true;
@ -368,7 +368,7 @@
return a.join("");
};
if (typeof o == "undefined" || o === null) {
if (typeof o === "undefined" || o === null) {
return "null";
} else if (BI.isArray(o)) {
return encodeArray(o);
@ -379,44 +379,44 @@
*/
return BI.jsonEncode({
__time__: o.getTime()
})
} else if (typeof o == "string") {
});
} else if (typeof o === "string") {
return encodeString(o);
} else if (typeof o == "number") {
} else if (typeof o === "number") {
return isFinite(o) ? String(o) : "null";
} else if (typeof o == "boolean") {
} else if (typeof o === "boolean") {
return String(o);
} else if (BI.isFunction(o)) {
return String(o);
} else {
var a = ["{"], b, i, v;
for (i in o) {
if (!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(BI.jsonEncode(i), ":",
v === null ? "null" : BI.jsonEncode(v));
b = true;
}
}
var a = ["{"], b, i, v;
for (i in o) {
if (!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "unknown":
break;
default:
if (b) {
a.push(",");
}
a.push(BI.jsonEncode(i), ":",
v === null ? "null" : BI.jsonEncode(v));
b = true;
}
}
a.push("}");
return a.join("");
}
a.push("}");
return a.join("");
};
BI.jsonDecode = function (text) {
try {
// 注意0啊
//var jo = $.parseJSON(text) || {};
// var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text);
if (jo == null) {
jo = {};
@ -429,7 +429,7 @@
try {
jo = new Function("return " + text)() || {};
} catch (e) {
//do nothing
// do nothing
}
if (jo == null) {
jo = [];
@ -439,7 +439,7 @@
return jo;
}
function _hasDateInJson(json) {
function _hasDateInJson (json) {
if (!json || typeof json !== "string") {
return false;
}
@ -454,7 +454,7 @@
return new Date(o.__time__);
}
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;
}
o[a] = arguments.callee(o[a]);
@ -466,25 +466,25 @@
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
// 原值为空,返回空字符
return "";
}
var text = cv.toString();
if (isEmpty(fmt)) {
//格式为空,返回原字符
// 格式为空,返回原字符
return text;
}
if (fmt.match(/^T/)) {
//T - 文本格式
// T - 文本格式
return text;
} else if (fmt.match(/^D/)) {
//D - 日期(时间)格式
// D - 日期(时间)格式
if (!(cv instanceof Date)) {
if (typeof cv === 'number') {
//毫秒数类型
if (typeof cv === "number") {
// 毫秒数类型
cv = new Date(cv);
} else {
//字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
// 字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long);
}
}
@ -493,14 +493,14 @@
text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1));
}
} else if (fmt.match(/E/)) {
//科学计数格式
// 科学计数格式
text = _eFormat(text, fmt);
} else {
//数字格式
// 数字格式
text = _numberFormat(text, fmt);
}
//¤ - 货币格式
text = text.replace(/¤/g, '¥');
// ¤ - 货币格式
text = text.replace(/¤/g, "¥");
return text;
};
@ -518,19 +518,19 @@
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
return "";
}
// O(len(format))
var len = format.length, result = '';
var len = format.length, result = "";
if (len > 0) {
var flagch = format.charAt(0), start = 0, str = flagch;
for (var i = 1; i < len; i++) {
var ch = format.charAt(i);
if (flagch !== ch) {
result += compileJFmt({
'char': flagch,
'str': str,
'len': i - start
char: flagch,
str: str,
len: i - start
}, date);
flagch = ch;
start = i;
@ -540,78 +540,78 @@
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
char: flagch,
str: str,
len: len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
function compileJFmt (jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt["char"];
switch (ch) {
case 'E': //星期
case "E": // 星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
case "y": //
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
str = (date.getFullYear() + "").slice(2, 4);
} else {
str = date.getFullYear();
}
break;
case 'M': //月
case "M": //
if (len > 2) {
str = Date._MN[date.getMonth()];
} else if (len < 2) {
str = date.getMonth() + 1;
} else {
str = String.leftPad(date.getMonth() + 1 + '', 2, '0');
str = String.leftPad(date.getMonth() + 1 + "", 2, "0");
}
break;
case 'd': //日
case "d": //
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
str = String.leftPad(date.getDate() + "", 2, "0");
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
case "h": // 时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
str = String.leftPad(hour + "", 2, "0");
} else {
str = hour;
}
break;
case 'H': //时(24)
case "H": // 时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
str = String.leftPad(date.getHours() + "", 2, "0");
} else {
str = date.getHours();
}
break;
case 'm':
case "m":
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
str = String.leftPad(date.getMinutes() + "", 2, "0");
} else {
str = date.getMinutes();
}
break;
case 's':
case "s":
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
str = String.leftPad(date.getSeconds() + "", 2, "0");
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
case "a":
str = date.getHours() < 12 ? "am" : "pm";
break;
case 'z':
case "z":
str = date.getTimezone();
break;
default:
@ -626,16 +626,16 @@
if (value == null) {
return 0;
}
if (typeof value == 'number') {
if (typeof value === "number") {
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) {
@ -644,18 +644,18 @@
}
if (obj instanceof Date) {
return obj;
} else if (typeof obj == 'number') {
} else if (typeof obj === "number") {
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) {
@ -664,24 +664,24 @@
}
if (obj instanceof Date) {
return obj;
} else {
var str = obj + "";
str = str.replace(/-/g, '/');
var dt = new Date(str);
if (!isInvalidDate(dt)) {
return dt;
}
if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) {
dt = new Date("1970/01/01 " + str);
if (!isInvalidDate(dt)) {
return dt;
}
}
dt = BI.str2Date(str, "HH:mm:ss");
}
var str = obj + "";
str = str.replace(/-/g, "/");
var dt = new Date(str);
if (!isInvalidDate(dt)) {
return dt;
}
if (str.indexOf("/") === -1 && str.indexOf(":") !== -1) {
dt = new Date("1970/01/01 " + str);
if (!isInvalidDate(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) {
window.BI = {};
}
;
!(function ($, undefined) {
var traverse = function (func, context) {
return function (value, key, obj) {
return func.call(context, key, value, obj);
}
};
};
var _apply = function (name) {
return function () {
return _[name].apply(_, arguments);
}
};
};
var _applyFunc = function (name) {
return function () {
var args = Array.prototype.slice.call(arguments, 0);
args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1];
return _[name].apply(_, args);
}
};
};
//Utility
// Utility
_.extend(BI, {
i18nText: function (key) {
var localeText = (BI.i18n && BI.i18n[key]) || "";
@ -61,11 +61,11 @@ if (!window.BI) {
},
warn: function (message) {
console.warn(message)
console.warn(message);
},
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 = "";
for (var i = 0; i < 16; i++) {
var r = parseInt(f.length * Math.random(), 10);
@ -80,7 +80,7 @@ if (!window.BI) {
createWidgets: function (items, options) {
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.createWidget(item, BI.deepClone(options));
@ -104,7 +104,7 @@ if (!window.BI) {
outerAttr.shift();
return BI.extend({}, item, {
el: innerAttr.shift()
})
});
}
if (item.el instanceof BI.Widget || (BI.View && item.el instanceof BI.View)) {
innerAttr.shift();
@ -113,15 +113,15 @@ if (!window.BI) {
if (item.el) {
return BI.extend({}, outerAttr.shift(), item, {
el: BI.extend({}, innerAttr.shift(), item.el)
})
});
}
return BI.extend({}, outerAttr.shift(), {
el: BI.extend({}, innerAttr.shift(), item)
})
})
});
});
},
//用容器包装items
// 用容器包装items
packageItems: function (items, layouts) {
for (var i = layouts.length - 1; i >= 0; i--) {
items = BI.map(items, function (k, it) {
@ -131,8 +131,8 @@ if (!window.BI) {
el: it
})
]
})
})
});
});
}
return items;
},
@ -146,7 +146,7 @@ if (!window.BI) {
};
},
//剥开EL
// 剥开EL
stripEL: function (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) {
BI[name] = _apply(name)
BI[name] = _apply(name);
});
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition"], function (name) {
BI[name] = _applyFunc(name)
BI[name] = _applyFunc(name);
});
_.extend(BI, {
clamp: function (value, minValue, maxValue) {
@ -176,7 +176,7 @@ if (!window.BI) {
}
return value;
},
//数数
// 数数
count: function (from, to, predicate) {
var t;
if (predicate) {
@ -187,7 +187,7 @@ if (!window.BI) {
return to - from;
},
//倒数
// 倒数
inverse: function (from, to, predicate) {
return BI.count(to, from, predicate);
},
@ -326,7 +326,7 @@ if (!window.BI) {
},
string2Array: function (str) {
return str.split('&-&');
return str.split("&-&");
},
array2String: function (array) {
@ -334,7 +334,7 @@ if (!window.BI) {
},
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) {
idx = str.charAt(i).charCodeAt(0) - start.charCodeAt(0) + 26 * idx + 1;
if (idx > (2147483646 - str.charAt(i).charCodeAt(0) + start.charCodeAt(0)) / 26) {
@ -345,7 +345,7 @@ if (!window.BI) {
},
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 = "";
if (num === 0) {
return "";
@ -362,16 +362,16 @@ if (!window.BI) {
}
});
//数组相关的方法
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range"], function (name) {
BI[name] = _apply(name)
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
BI[name] = _applyFunc(name)
BI[name] = _applyFunc(name);
});
_.extend(BI, {
//构建一个长度为length的数组
// 构建一个长度为length的数组
makeArray: function (length, value) {
var res = [];
for (var i = 0; i < length; i++) {
@ -425,20 +425,20 @@ if (!window.BI) {
}
});
//对象相关方法
// 对象相关方法
_.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn",
"defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty",
"isElement", "isNumber", "isString", "isArray", "isObject", "isArguments", "isFunction", "isFinite",
"isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined"], function (name) {
BI[name] = _apply(name)
BI[name] = _apply(name);
});
_.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) {
BI[name] = _applyFunc(name)
BI[name] = _applyFunc(name);
});
_.extend(BI, {
inherit: function (sb, sp, overrides) {
if (typeof sp == 'object') {
if (typeof sp === "object") {
overrides = sp;
sp = sb;
sb = function () {
@ -446,7 +446,7 @@ if (!window.BI) {
};
}
var F = function () {
}, spp = sp.prototype;
}, spp = sp.prototype;
F.prototype = spp;
sb.prototype = new F();
sb.superclass = spp;
@ -468,12 +468,12 @@ if (!window.BI) {
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key
// 数字和字符串可以作为key
isKey: function (key) {
return BI.isNumber(key) || (BI.isString(key) && key.length > 0);
},
//忽略大小写的等于
// 忽略大小写的等于
isCapitalEqual: function (a, b) {
a = BI.isNull(a) ? a : ("" + a).toLowerCase();
b = BI.isNull(b) ? b : ("" + b).toLowerCase();
@ -481,10 +481,10 @@ if (!window.BI) {
},
isWidthOrHeight: function (w) {
if (typeof w == 'number') {
if (typeof w === "number") {
return w >= 0;
} else if (typeof w == 'string') {
return /^\d{1,3}%$/.exec(w) || w == 'auto' || /^\d+px$/.exec(w);
} else if (typeof w === "string") {
return /^\d{1,3}%$/.exec(w) || w == "auto" || /^\d+px$/.exec(w);
}
},
@ -529,7 +529,7 @@ if (!window.BI) {
}
});
//deep方法
// deep方法
_.extend(BI, {
/**
*完全克隆<EFBFBD>?个js对象
@ -544,14 +544,14 @@ if (!window.BI) {
var type = Object.prototype.toString.call(obj);
// Date
if (type === '[object Date]') {
if (type === "[object Date]") {
return Date.getDate(obj.getTime());
}
var i, clone, key;
// Array
if (type === '[object Array]') {
if (type === "[object Array]") {
i = obj.length;
clone = [];
@ -561,7 +561,7 @@ if (!window.BI) {
}
}
// Object
else if (type === '[object Object]' && obj.constructor === Object) {
else if (type === "[object Object]" && obj.constructor === Object) {
clone = {};
for (var i in obj) {
@ -595,7 +595,7 @@ if (!window.BI) {
if (BI.isEqual(v, copy)) {
return true;
}
})
});
}
return BI.contains(obj, copy);
},
@ -639,15 +639,15 @@ if (!window.BI) {
}
}
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) {
@ -660,7 +660,7 @@ if (!window.BI) {
return result;
},
//比较两个对象得出不一样的key值
// 比较两个对象得出不一样的key值
deepDiff: function (object, other) {
object || (object = {});
other || (other = {});
@ -683,18 +683,18 @@ if (!window.BI) {
}
});
//通用方法
// 通用方法
_.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape"], function (name) {
BI[name] = function () {
return _[name].apply(_, arguments);
}
};
});
//事件相关方法
// 事件相关方法
_.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) {
BI[name] = function () {
return _[name].apply(_, arguments);
}
};
});
_.extend(BI, {
@ -703,7 +703,7 @@ if (!window.BI) {
var pending = false;
var timerFunc;
function nextTickHandler() {
function nextTickHandler () {
pending = false;
var copies = callbacks.slice(0);
callbacks = [];
@ -712,15 +712,15 @@ if (!window.BI) {
}
}
if (typeof Promise !== 'undefined') {
if (typeof Promise !== "undefined") {
var p = Promise.resolve();
timerFunc = function () {
p.then(nextTickHandler);
}
};
} else
/* istanbul ignore if */
if (typeof MutationObserver !== 'undefined') {
if (typeof MutationObserver !== "undefined") {
var counter = 1;
var observer = new MutationObserver(nextTickHandler);
var textNode = document.createTextNode(counter + "");
@ -730,13 +730,13 @@ if (!window.BI) {
timerFunc = function () {
counter = (counter + 1) % 2;
textNode.data = counter + "";
}
};
} else {
timerFunc = function () {
setTimeout(nextTickHandler, 0)
}
setTimeout(nextTickHandler, 0);
};
}
return function queueNextTick(cb) {
return function queueNextTick (cb) {
var _resolve;
var args = [].slice.call(arguments, 1);
callbacks.push(function () {
@ -751,34 +751,34 @@ if (!window.BI) {
pending = true;
timerFunc();
}
if (!cb && typeof Promise !== 'undefined') {
if (!cb && typeof Promise !== "undefined") {
return new Promise(function (resolve) {
_resolve = resolve
})
_resolve = resolve;
});
}
}
};
})()
});
//数字相关方法
// 数字相关方法
_.each(["random"], function (name) {
BI[name] = _apply(name)
BI[name] = _apply(name);
});
_.extend(BI, {
getTime: function () {
if (window.performance && 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) {
@ -881,7 +881,7 @@ if (!window.BI) {
}
});
//字符串相关方法
// 字符串相关方法
_.extend(BI, {
trim: function () {
return $.trim.apply($, arguments);
@ -900,28 +900,28 @@ if (!window.BI) {
},
isLiteral: function (exp) {
var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/
return literalValueRE.test(exp)
var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/;
return literalValueRE.test(exp);
},
stripQuotes: function (str) {
var a = str.charCodeAt(0)
var b = str.charCodeAt(str.length - 1)
var a = str.charCodeAt(0);
var b = str.charCodeAt(str.length - 1);
return a === b && (a === 0x22 || a === 0x27)
? str.slice(1, -1)
: str
: str;
},
//background-color => backgroundColor
// background-color => backgroundColor
camelize: function (str) {
return str.replace(/-(.)/g, function (_, character) {
return character.toUpperCase();
});
},
//backgroundColor => background-color
// backgroundColor => background-color
hyphenate: function (str) {
return str.replace(/([A-Z])/g, '-$1').toLowerCase();
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
},
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.");
return null;
}
// var salt = Math.round(Math.random() * 1000000000) % 100000000;
// var salt = Math.round(Math.random() * 1000000000) % 100000000;
var salt = 101;
prand += salt;
while (prand.length > 10) {
@ -1042,7 +1042,7 @@ if (!window.BI) {
}
});
//浏览器相关方法
// 浏览器相关方法
_.extend(BI, {
isIE: function () {
if (this.__isIE == null) {
@ -1111,7 +1111,7 @@ if (!window.BI) {
},
isSupportCss3: function (style) {
var prefix = ['webkit', 'Moz', 'ms', 'o'],
var prefix = ["webkit", "Moz", "ms", "o"],
i, len,
humpString = [],
htmlStyle = document.documentElement.style,
@ -1122,7 +1122,7 @@ if (!window.BI) {
};
for (i in prefix) {
humpString.push(_toHumb(prefix[i] + '-' + style));
humpString.push(_toHumb(prefix[i] + "-" + style));
}
humpString.push(_toHumb(style));
@ -1134,7 +1134,7 @@ if (!window.BI) {
return false;
}
});
//BI请求
// BI请求
_.extend(BI, {
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) {
var rule = o.rule(item.getValue(), item);
function doBe(run) {
function doBe (run) {
if (run === true) {
item.doHighLight.apply(item, args);
} else {
@ -37,6 +37,6 @@ BI.HighlightBehavior = BI.inherit(BI.Behavior, {
} else {
item.doBehavior.apply(item, args);
}
})
});
}
});

14
src/core/behavior/behavior.js

@ -1,7 +1,7 @@
BI.BehaviorFactory = {
createBehavior: function(key, options){
createBehavior: function (key, options) {
var behavior;
switch (key){
switch (key) {
case "highlight":
behavior = BI.HighlightBehavior;
break;
@ -11,7 +11,7 @@ BI.BehaviorFactory = {
}
return new behavior(options);
}
}
};
/**
* guy
@ -20,18 +20,18 @@ BI.BehaviorFactory = {
* @extends BI.OB
*/
BI.Behavior = BI.inherit(BI.OB, {
_defaultConfig: function() {
_defaultConfig: function () {
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);
},
doBehavior: function(){
doBehavior: function () {
}
});

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

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

8
src/core/controller.js

@ -7,16 +7,16 @@
* @abstract
*/
BI.Controller = BI.inherit(BI.OB, {
_defaultConfig: function() {
_defaultConfig: function () {
return BI.extend(BI.Controller.superclass._defaultConfig.apply(this, arguments), {
})
});
},
_init : function() {
_init: function () {
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);
return function () {
self.remove(name, fn);
}
};
},
send: function (name) {

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

@ -50,7 +50,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
cls: "bi-popup-view",
items: [{
el: (this.floatLayer[name] = BI.createWidget({
type: 'bi.absolute',
type: "bi.absolute",
items: [floatbox]
})),
left: 0,
@ -63,7 +63,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
(function (key) {
floatbox.on(BI.FloatBox.EVENT_FLOAT_BOX_CLOSED, function () {
self.close(key);
})
});
})(name);
BI.createWidget({
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")) {
layer.element.trigger("__resize__");
}
})
});
},
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;
this.resizerManger = {};
var fn = BI.debounce(function (ev) {
//if (BI.isWindow(ev.target)) {
// if (BI.isWindow(ev.target)) {
self._resize(ev);
//}
// }
}, 30);
$(window).resize(fn);
},
@ -37,7 +37,7 @@ BI.ResizeController = BI.inherit(BI.Controller, {
resizer(ev);
return;
}
})
});
},
add: function (name, resizer) {

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

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

130
src/core/events.js

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

52
src/core/func/dom.js

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

39
src/core/func/function.js

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

31
src/core/inject.js

@ -1,4 +1,4 @@
;(function () {
(function () {
var constantInjection = {};
BI.constant = function (xtype, cls) {
if (constantInjection[xtype] != null) {
@ -47,35 +47,36 @@
if (!providers[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) {
if (!actions[type]) {
actions[type] = [];
}
actions[type].push(actionFn)
actions[type].push(actionFn);
return function () {
actions[type].remove(actionFn);
if (actions[type].length === 0) {
delete actions[type];
}
}
}
};
};
BI.Constants = {
getConstant: function (type) {
return constantInjection[type];
}
}
};
BI.Models = {
getModel: function (type, config) {
return new modelInjection[type](config);
}
}
};
var stores = {};
@ -89,7 +90,7 @@
releaseStore: function (type) {
delete stores[type];
}
}
};
var services = {};
@ -103,9 +104,9 @@
releaseService: function (type) {
delete services[type];
}
}
};
var providers = {}, providerInstance = {}
var providers = {}, providerInstance = {};
BI.Providers = {
getProvider: function (type, config) {
@ -121,13 +122,13 @@
delete providers[type];
delete providerInstance[type];
}
}
};
BI.Actions = {
runAction: function (type, config) {
BI.each(actions[type], function (i, act) {
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);
});
}
})
});
}
});
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) {
var d = document, styles = d.createElement('style');
d.getElementsByTagName('head')[0].appendChild(styles);
styles.setAttribute('type', 'text/css');
var d = document, styles = d.createElement("style");
d.getElementsByTagName("head")[0].appendChild(styles);
styles.setAttribute("type", "text/css");
if (styles.styleSheet) {
styles.styleSheet.cssText = styleString;
} else {

2
src/core/logic/logic.js

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

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

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

14
src/core/ob.js

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

5
src/core/plugin.js

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

78
src/core/proto/date.js

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

35
src/core/proto/jquery.js vendored

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

80
src/core/proto/number.js

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

8
src/core/proto/string.js

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

4
src/core/utils/base64.js

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

6
src/core/utils/cache.js

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

52
src/core/utils/cellSizeAndPositionManager.js

@ -57,14 +57,14 @@ BI.CellSizeAndPositionManager.prototype = {
return this._lastMeasuredIndex >= 0
? this._cellSizeAndPositionData[this._lastMeasuredIndex]
: {
offset: 0,
size: 0
}
offset: 0,
size: 0
};
},
getTotalSize: function () {
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) {
@ -75,13 +75,13 @@ BI.CellSizeAndPositionManager.prototype = {
var idealOffset;
switch (align) {
case 'start':
case "start":
idealOffset = maxOffset;
break;
case 'end':
case "end":
idealOffset = minOffset;
break;
case 'center':
case "center":
idealOffset = maxOffset - ((containerSize - datum.size) / 2);
break;
default:
@ -98,7 +98,7 @@ BI.CellSizeAndPositionManager.prototype = {
var totalSize = this.getTotalSize();
if (totalSize === 0) {
return {}
return {};
}
var maxOffset = offset + containerSize;
@ -117,11 +117,11 @@ BI.CellSizeAndPositionManager.prototype = {
return {
start: start,
stop: stop
}
};
},
resetCell: function (index) {
this._lastMeasuredIndex = Math.min(this._lastMeasuredIndex, index - 1)
this._lastMeasuredIndex = Math.min(this._lastMeasuredIndex, index - 1);
},
_binarySearch: function (high, low, offset) {
@ -169,15 +169,15 @@ BI.CellSizeAndPositionManager.prototype = {
if (lastMeasuredCellSizeAndPosition.offset >= 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) {
this._cellSizeAndPositionManager = new BI.CellSizeAndPositionManager(cellCount, cellSizeGetter, estimatedCellSize);
this._maxScrollSize = maxScrollSize || 10000000
this._maxScrollSize = maxScrollSize || 10000000;
};
BI.ScalingCellSizeAndPositionManager.prototype = {
@ -188,15 +188,15 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
},
getCellCount: function () {
return this._cellSizeAndPositionManager.getCellCount()
return this._cellSizeAndPositionManager.getCellCount();
},
getEstimatedCellSize: function () {
return this._cellSizeAndPositionManager.getEstimatedCellSize()
return this._cellSizeAndPositionManager.getEstimatedCellSize();
},
getLastMeasuredIndex: function () {
return this._cellSizeAndPositionManager.getLastMeasuredIndex()
return this._cellSizeAndPositionManager.getLastMeasuredIndex();
},
getOffsetAdjustment: function (containerSize, offset) {
@ -234,13 +234,13 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
},
resetCell: function (index) {
this._cellSizeAndPositionManager.resetCell(index)
this._cellSizeAndPositionManager.resetCell(index);
},
_getOffsetPercentage: function (containerSize, offset, totalSize) {
return totalSize <= containerSize
? 0
: offset / (totalSize - containerSize)
: offset / (totalSize - containerSize);
},
_offsetToSafeOffset: function (containerSize, offset) {
@ -249,11 +249,11 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
if (totalSize === safeTotalSize) {
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) {
@ -262,10 +262,10 @@ BI.ScalingCellSizeAndPositionManager.prototype = {
if (totalSize === safeTotalSize) {
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 () {
// Check `document` and `window` in case of server-side rendering
var _window
if (typeof window !== 'undefined') {
_window = window
} else if (typeof self !== 'undefined') {
_window = self
var _window;
if (typeof window !== "undefined") {
_window = window;
} else if (typeof self !== "undefined") {
_window = self;
} else {
_window = this
_window = this;
}
var addEventListener = typeof document !== 'undefined' && document.addEventListener;
var addEventListener = typeof document !== "undefined" && document.addEventListener;
var stylesCreated = false;
if (addEventListener) {
@ -47,8 +47,8 @@
expandChild = expand.firstElementChild;
contract.scrollLeft = contract.scrollWidth;
contract.scrollTop = contract.scrollHeight;
expandChild.style.width = expand.offsetWidth + 1 + 'px';
expandChild.style.height = expand.offsetHeight + 1 + 'px';
expandChild.style.width = expand.offsetWidth + 1 + "px";
expandChild.style.height = expand.offsetHeight + 1 + "px";
expand.scrollLeft = expand.scrollWidth;
expand.scrollTop = expand.scrollHeight;
};
@ -56,7 +56,7 @@
var checkTriggers = function (element) {
return element.offsetWidth !== element.__resizeLast__.width ||
element.offsetHeight !== element.__resizeLast__.height;
}
};
var scrollListener = function (e) {
var element = this;
@ -75,24 +75,24 @@
/* Detect CSS Animations support to detect element display/re-attach */
var animation = false,
animationstring = 'animation',
keyframeprefix = '',
animationstartevent = 'animationstart',
domPrefixes = 'Webkit Moz O ms'.split(' '),
startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '),
pfx = '';
animationstring = "animation",
keyframeprefix = "",
animationstartevent = "animationstart",
domPrefixes = "Webkit Moz O ms".split(" "),
startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),
pfx = "";
{
var elm = document.createElement('fakeelement');
var elm = document.createElement("fakeelement");
if (elm.style.animationName !== undefined) {
animation = true;
}
if (animation === false) {
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];
animationstring = pfx + 'Animation';
keyframeprefix = '-' + pfx.toLowerCase() + '-';
animationstring = pfx + "Animation";
keyframeprefix = "-" + pfx.toLowerCase() + "-";
animationstartevent = startEvents[i];
animation = true;
break;
@ -101,21 +101,21 @@
}
}
var animationName = 'resizeanim';
var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } ';
var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; ';
var animationName = "resizeanim";
var animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ";
var animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
}
var createStyles = function () {
if (!stylesCreated) {
//opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
var css = (animationKeyframes ? animationKeyframes : '') +
'.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%; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
// opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360
var css = (animationKeyframes ? animationKeyframes : "") +
".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%; }",
head = document.head || document.getElementsByTagName("head")[0],
style = document.createElement("style");
style.type = "text/css";
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
@ -125,32 +125,31 @@
head.appendChild(style);
stylesCreated = true;
}
}
};
var addResizeListener = function (element, fn) {
if (addEventListener){
if (addEventListener) {
if (!element.__resizeTriggers__) {
if (getComputedStyle(element).position === 'static') element.style.position = 'relative';
if (getComputedStyle(element).position === "static") element.style.position = "relative";
createStyles();
element.__resizeLast__ = {};
element.__resizeListeners__ = [];
(element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers';
element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' +
'<div class="contract-trigger"></div>';
(element.__resizeTriggers__ = document.createElement("div")).className = "resize-triggers";
element.__resizeTriggers__.innerHTML = "<div class=\"expand-trigger\"><div></div></div>" +
"<div class=\"contract-trigger\"></div>";
element.appendChild(element.__resizeTriggers__);
resetTriggers(element);
element.addEventListener('scroll', scrollListener, true);
element.addEventListener("scroll", scrollListener, true);
/* Listen for a css animation to detect element display/re-attach */
animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function (e) {
if (e.animationName === animationName)
resetTriggers(element);
if (e.animationName === animationName) {resetTriggers(element);}
});
}
element.__resizeListeners__.push(fn);
} else {
element.attachEvent('onresize', fn);
element.attachEvent("onresize", fn);
}
};
@ -158,11 +157,11 @@
if (addEventListener) {
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
if (!element.__resizeListeners__.length) {
element.removeEventListener('scroll', scrollListener, true);
element.removeEventListener("scroll", scrollListener, true);
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
}
} else {
element.detachEvent('onresize', fn);
element.detachEvent("onresize", fn);
}
};
@ -171,7 +170,7 @@
addResizeListener(widget.element[0], fn);
return function () {
removeResizeListener(widget.element[0], fn);
}
};
},
removeResizeListener: function (widget, fn) {
removeResizeListener(widget.element[0], fn);

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

@ -1,37 +1,37 @@
BI.EventListener = {
listen: function listen(target, eventType, callback) {
listen: function listen (target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function remove() {
remove: function remove () {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, callback);
target.attachEvent("on" + eventType, callback);
return {
remove: function remove() {
target.detachEvent('on' + eventType, callback);
remove: function remove () {
target.detachEvent("on" + eventType, callback);
}
};
}
},
capture: function capture(target, eventType, callback) {
capture: function capture (target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, true);
return {
remove: function remove() {
remove: function remove () {
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 = {
constructor: BI.MouseMoveTracker,
captureMouseMoves: function (/*object*/ event) {
captureMouseMoves: function (/* object*/ event) {
if (!this._eventMoveToken && !this._eventUpToken) {
this._eventMoveToken = BI.EventListener.listen(
this._domNode,
'mousemove',
"mousemove",
this._onMouseMove
);
this._eventUpToken = BI.EventListener.listen(
this._domNode,
'mouseup',
"mouseup",
this._onMouseUp
);
}
@ -67,11 +67,11 @@
}
},
isDragging: function () /*boolean*/ {
isDragging: function () /* boolean*/ {
return this._isDragging;
},
_onMouseMove: function (/*object*/ event) {
_onMouseMove: function (/* object*/ event) {
var x = event.clientX;
var y = event.clientY;

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

@ -4,7 +4,7 @@
var PAGE_HEIGHT = 800;
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,
sY = 0,
// spinX, spinY
@ -12,21 +12,21 @@
pY = 0; // pixelX, pixelY
// Legacy
if ('detail' in event) {
if ("detail" in event) {
sY = event.detail;
}
if ('wheelDelta' in event) {
if ("wheelDelta" in event) {
sY = -event.wheelDelta / 120;
}
if ('wheelDeltaY' in event) {
if ("wheelDeltaY" in event) {
sY = -event.wheelDeltaY / 120;
}
if ('wheelDeltaX' in event) {
if ("wheelDeltaX" in event) {
sX = -event.wheelDeltaX / 120;
}
// 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;
sY = 0;
}
@ -34,10 +34,10 @@
pX = sX * PIXEL_STEP;
pY = sY * PIXEL_STEP;
if ('deltaY' in event) {
if ("deltaY" in event) {
pY = event.deltaY;
}
if ('deltaX' in event) {
if ("deltaX" in event) {
pX = event.deltaX;
}
@ -74,33 +74,33 @@
this._deltaX = 0;
this._deltaY = 0;
this._didWheel = BI.bind(this._didWheel, this);
if (typeof handleScrollX !== 'function') {
if (typeof handleScrollX !== "function") {
handleScrollX = handleScrollX ?
function () {
return true
return true;
} :
function () {
return false
return false;
};
}
if (typeof handleScrollY !== 'function') {
if (typeof handleScrollY !== "function") {
handleScrollY = handleScrollY ?
function () {
return true
return true;
} :
function () {
return false
return false;
};
}
if (typeof stopPropagation !== 'function') {
if (typeof stopPropagation !== "function") {
stopPropagation = stopPropagation ?
function () {
return true
return true;
} :
function () {
return false
return false;
};
}
@ -112,7 +112,7 @@
};
BI.WheelHandler.prototype = {
constructor: BI.WheelHandler,
onWheel: function (/*object*/ event) {
onWheel: function (/* object*/ event) {
var normalizedEvent = normalizeWheel(event);
var deltaX = this._deltaX + normalizedEvent.pixelX;
var deltaY = this._deltaY + normalizedEvent.pixelY;

6
src/core/utils/heap.js

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

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

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

22
src/core/utils/integerBufferSet.js

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

10
src/core/utils/linkedHashMap.js

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

24
src/core/utils/load.js

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

14
src/core/utils/lru.js

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

13
src/core/utils/md5.js

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

16
src/core/utils/prefixIntervalTree.js

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

18
src/core/utils/queue.js

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

16
src/core/utils/sectionManager.js

@ -19,7 +19,7 @@
},
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(section.getCellIndices(), function (j, index) {
indices[index] = index
})
indices[index] = index;
});
});
return BI.map(BI.keys(indices), function (i, index) {
return indices[index]
return indices[index];
});
},
@ -63,14 +63,14 @@
var key = sectionX + "." + sectionY;
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 () {
@ -84,5 +84,5 @@
section.addCellIndex(index);
});
}
}
};
})();

16
src/core/utils/tableRowBuffer.js

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

38
src/core/utils/tree.js

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

12
src/core/utils/vector.js

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

102
src/core/var.js

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

20
src/core/widget.js

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

58
src/core/wrapper/layout.js

@ -11,9 +11,9 @@
BI.Layout = BI.inherit(BI.Widget, {
props: function () {
return {
scrollable: null, //true, false, null
scrollx: false, //true, false
scrolly: false, //true, false
scrollable: null, // true, false, null
scrollx: false, // true, false
scrolly: false, // true, false
items: []
};
},
@ -25,16 +25,16 @@ BI.Layout = BI.inherit(BI.Widget, {
_init4Margin: function () {
if (this.options.top) {
this.element.css('top', this.options.top);
this.element.css("top", this.options.top);
}
if (this.options.left) {
this.element.css('left', this.options.left);
this.element.css("left", this.options.left);
}
if (this.options.bottom) {
this.element.css('bottom', this.options.bottom);
this.element.css("bottom", this.options.bottom);
}
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;
return eq(item1, item2);
//不比较函数
function eq(a, b, aStack, bStack) {
// 不比较函数
function eq (a, b, aStack, bStack) {
if (a === 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);
switch (className) {
case '[object RegExp]':
case '[object String]':
return '' + a === '' + b;
case '[object Number]':
case "[object RegExp]":
case "[object String]":
return "" + a === "" + b;
case "[object Number]":
if (+a !== +a) {
return +b !== +b;
}
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
case "[object Date]":
case "[object Boolean]":
return +a === +b;
}
var areArrays = className === '[object Array]';
var areArrays = className === "[object Array]";
if (!areArrays) {
if (BI.isFunction(a) && BI.isFunction(b)) {
return true;
@ -306,7 +306,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this._getWrapper().append(fragment);
BI.each(added, function (i, w) {
w._mount();
})
});
},
prependItems: function (items) {
@ -325,7 +325,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this._getWrapper().prepend(fragment);
BI.each(added, function (i, w) {
w._mount();
})
});
},
getValue: function () {
@ -346,7 +346,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child = self._children[self._getChildName(i)]) {
child.setValue(v);
}
})
});
},
setText: function (v) {
@ -355,7 +355,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child = self._children[self._getChildName(i)]) {
child.setText(v);
}
})
});
},
patchItem: function (oldVnode, vnode, index) {
@ -433,31 +433,31 @@ BI.Layout = BI.inherit(BI.Widget, {
self._children[self._getChildName(i)] = children[key];
});
function sameVnode(vnode1, vnode2, oldIndex, newIndex) {
function sameVnode (vnode1, vnode2, oldIndex, newIndex) {
vnode1 = self._getOptions(vnode1);
vnode2 = self._getOptions(vnode2);
if (BI.isKey(vnode1.key)) {
return vnode1.key === vnode2.key;
}
if (oldIndex >= 0) {
return oldIndex === newIndex
return oldIndex === newIndex;
}
}
function addNode(vnode, index) {
function addNode (vnode, index) {
var opt = self._getOptions(vnode);
var key = opt.key == null ? index : opt.key;
return children[key] = self._addElement(key, vnode);
}
function addVnodes(before, vnodes, startIdx, endIdx) {
function addVnodes (before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = addNode(vnodes[startIdx], startIdx);
insertBefore(node, before, false, startIdx);
}
}
function removeVnodes(vnodes, startIdx, endIdx) {
function removeVnodes (vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var node = self._getOptions(vnodes[startIdx]);
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);
before = before && self._getOptions(before);
var insertKey = BI.isKey(insert.key) ? insert.key : index;
@ -523,7 +523,7 @@ BI.Layout = BI.inherit(BI.Widget, {
stroke: function (items) {
var self = this;
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
self._addElement(i, item);
}
});
@ -536,7 +536,7 @@ BI.Layout = BI.inherit(BI.Widget, {
if (child === nameOrWidget) {
removeIndex = name;
}
})
});
} else {
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 w = BI.AbsoluteCenterLayout.superclass._addElement.apply(this, arguments);
w.element.css({
"position": "absolute",
"left": o.hgap + o.lgap + (item.lgap || 0),
"right": o.hgap + o.rgap + (item.rgap || 0),
"top": o.vgap + o.tgap + (item.tgap || 0),
"bottom": o.vgap + o.bgap + (item.bgap || 0),
"margin": "auto"
position: "absolute",
left: o.hgap + o.lgap + (item.lgap || 0),
right: o.hgap + o.rgap + (item.rgap || 0),
top: o.vgap + o.tgap + (item.tgap || 0),
bottom: o.vgap + o.bgap + (item.bgap || 0),
margin: "auto"
});
return w;
},
@ -44,4 +44,4 @@ BI.AbsoluteCenterLayout = BI.inherit(BI.Layout, {
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 w = BI.AbsoluteHorizontalLayout.superclass._addElement.apply(this, arguments);
w.element.css({
"position": "absolute",
"left": o.hgap + o.lgap + (item.lgap || 0),
"right": o.hgap + o.rgap + (item.rgap || 0),
"margin": "auto"
position: "absolute",
left: o.hgap + o.lgap + (item.lgap || 0),
right: o.hgap + o.rgap + (item.rgap || 0),
margin: "auto"
});
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css("top", o.vgap + o.tgap + (item.tgap || 0));
@ -48,4 +48,4 @@ BI.AbsoluteHorizontalLayout = BI.inherit(BI.Layout, {
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 w = BI.AbsoluteVerticalLayout.superclass._addElement.apply(this, arguments);
w.element.css({
"position": "absolute",
"left": item.lgap,
"right": item.rgap,
"top": o.vgap + o.tgap + (item.tgap || 0),
"bottom": o.vgap + o.bgap + (item.bgap || 0),
"margin": "auto"
position: "absolute",
left: item.lgap,
right: item.rgap,
top: o.vgap + o.tgap + (item.tgap || 0),
bottom: o.vgap + o.bgap + (item.bgap || 0),
margin: "auto"
});
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css("left", o.hgap + o.lgap + (item.lgap || 0));
@ -50,4 +50,4 @@ BI.AbsoluteVerticalLayout = BI.inherit(BI.Layout, {
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 () {
BI.CenterAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
"height": "100%",
this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
position: "relative",
width: "100%",
height: "100%",
"white-space": "nowrap",
"border-spacing": "0px",
"border": "none",
border: "none",
"border-collapse": "separate"
});
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];
if (!this.hasWidget(this._getChildName(i))) {
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({
type: "bi.default",
tagName: "td",
@ -57,32 +57,32 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element");
}
td.element.css({
"position": "relative",
"height": "100%",
position: "relative",
height: "100%",
"vertical-align": "middle",
"margin": "0",
"padding": "0",
"border": "none"
margin: "0",
padding: "0",
border: "none"
});
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return td;
},
@ -107,7 +107,7 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
// console.log("center_adapt布局不需要resize");
},
_getWrapper: function(){
_getWrapper: function () {
return this.$tr;
},
@ -116,4 +116,4 @@ BI.CenterAdaptLayout = BI.inherit(BI.Layout, {
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 () {
BI.HorizontalAdaptLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
position: "relative",
width: "100%",
"white-space": "nowrap",
"border-spacing": "0px",
"border": "none",
border: "none",
"border-collapse": "separate"
});
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];
if (!this.hasWidget(this._getChildName(i))) {
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({
type: "bi.default",
tagName: "td",
@ -57,31 +57,31 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element");
}
td.element.css({
"position": "relative",
position: "relative",
"vertical-align": o.verticalAlign,
"margin": "0",
"padding": "0",
"border": "none"
margin: "0",
padding: "0",
border: "none"
});
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return td;
},
@ -115,4 +115,4 @@ BI.HorizontalAdaptLayout = BI.inherit(BI.Layout, {
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 () {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -73,7 +73,7 @@ BI.LeftRightVerticalAdaptLayout = BI.inherit(BI.Layout, {
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, {
@ -96,8 +96,8 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
addItem: function () {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -122,7 +122,7 @@ BI.LeftVerticalAdaptLayout = BI.inherit(BI.Layout, {
this._mount();
}
});
BI.shortcut('bi.left_vertical_adapt', BI.LeftVerticalAdaptLayout);
BI.shortcut("bi.left_vertical_adapt", BI.LeftVerticalAdaptLayout);
BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
props: function () {
@ -144,8 +144,8 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
},
addItem: function () {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -170,4 +170,4 @@ BI.RightVerticalAdaptLayout = BI.inherit(BI.Layout, {
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 () {
BI.VerticalAdaptLayout.superclass.render.apply(this, arguments);
var o = this.options;
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": o.horizontalAlign === BI.HorizontalAlign.Stretch ? "100%" : "auto",
"height": "100%",
this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
position: "relative",
width: o.horizontalAlign === BI.HorizontalAlign.Stretch ? "100%" : "auto",
height: "100%",
"white-space": "nowrap",
"border-spacing": "0px",
"border": "none",
border: "none",
"border-collapse": "separate"
});
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];
if (!this.hasWidget(this._getChildName(i))) {
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({
type: "bi.default",
tagName: "td",
@ -57,32 +57,32 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element");
}
td.element.css({
"position": "relative",
"height": "100%",
position: "relative",
height: "100%",
"vertical-align": "middle",
"margin": "0",
"padding": "0",
"border": "none"
margin: "0",
padding: "0",
border: "none"
});
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return td;
},
@ -116,4 +116,4 @@ BI.VerticalAdaptLayout = BI.inherit(BI.Layout, {
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 w = BI.HorizontalAutoLayout.superclass._addElement.apply(this, arguments);
w.element.css({
"position": "relative",
"margin": "0px auto"
position: "relative",
margin: "0px auto"
});
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -60,4 +60,4 @@ BI.HorizontalAutoLayout = BI.inherit(BI.Layout, {
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 () {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
mounted: function () {
@ -71,4 +71,4 @@ BI.FloatCenterAdaptLayout = BI.inherit(BI.Layout, {
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();
}
});
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) {
var o = this.options;
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;
},
@ -32,4 +32,4 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -63,4 +63,4 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -62,4 +62,4 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
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) {
var o = this.options;
var w = BI.FlexCenterLayout.superclass._addElement.apply(this, arguments);
w.element.css({"position": "relative"});
w.element.css({position: "relative"});
return w;
},
@ -40,7 +40,7 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
}
},
_getWrapper: function(){
_getWrapper: function () {
return this.$wrapper;
},
@ -53,4 +53,4 @@ BI.FlexCenterLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -70,7 +70,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
}
},
_getWrapper: function(){
_getWrapper: function () {
return this.$wrapper;
},
@ -83,4 +83,4 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -83,4 +83,4 @@ BI.FlexVerticalCenter = BI.inherit(BI.Layout, {
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 left = 0, right = 0, top = 0, bottom = 0;
if (BI.isNotNull(item.left)) {
w.element.css({"left": item.left});
w.element.css({left: item.left});
left += item.left;
}
if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right});
w.element.css({right: item.right});
right += item.right;
}
if (BI.isNotNull(item.top)) {
w.element.css({"top": item.top});
w.element.css({top: item.top});
top += item.top;
}
if (BI.isNotNull(item.bottom)) {
w.element.css({"bottom": item.bottom});
w.element.css({bottom: item.bottom});
bottom += item.bottom;
}
if (BI.isNotNull(o.hgap)) {
left += o.hgap;
w.element.css({"left": left});
w.element.css({left: left});
right += o.hgap;
w.element.css({"right": right});
w.element.css({right: right});
}
if (BI.isNotNull(o.vgap)) {
top += o.vgap;
w.element.css({"top": top});
w.element.css({top: top});
bottom += o.vgap;
w.element.css({"bottom": bottom});
w.element.css({bottom: bottom});
}
if (BI.isNotNull(o.lgap)) {
left += o.lgap;
w.element.css({"left": left});
w.element.css({left: left});
}
if (BI.isNotNull(o.rgap)) {
right += o.rgap;
w.element.css({"right": right});
w.element.css({right: right});
}
if (BI.isNotNull(o.tgap)) {
top += o.tgap;
w.element.css({"top": top});
w.element.css({top: top});
}
if (BI.isNotNull(o.bgap)) {
bottom += o.bgap;
w.element.css({"bottom": bottom});
w.element.css({bottom: bottom});
}
if (BI.isNotNull(item.width)) {
w.element.css({"width": item.width});
w.element.css({width: item.width});
}
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;
},
@ -90,7 +90,7 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
this.options.items = items || [];
var self = this;
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
if (!BI.isWidget(item) && !item.el) {
throw new Error("el must be exist");
}
@ -104,4 +104,4 @@ BI.AbsoluteLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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;
if (BI.isNotNull(item.left)) {
w.element.css({
"margin-left": item.left
})
});
}
if (BI.isNotNull(item.right)) {
w.element.css({
"margin-right": item.right
})
});
}
if (BI.isNotNull(item.top)) {
w.element.css({
"margin-top": item.top
})
});
}
if (BI.isNotNull(item.bottom)) {
w.element.css({
"margin-bottom": item.bottom
})
});
}
if (BI.isNotNull(o.hgap)) {
left += o.hgap;
w.element.css({"left": left});
w.element.css({left: left});
right += o.hgap;
w.element.css({"right": right});
w.element.css({right: right});
}
if (BI.isNotNull(o.vgap)) {
top += o.vgap;
w.element.css({"top": top});
w.element.css({top: top});
bottom += o.vgap;
w.element.css({"bottom": bottom});
w.element.css({bottom: bottom});
}
if (BI.isNotNull(o.lgap)) {
left += o.lgap;
w.element.css({"left": left});
w.element.css({left: left});
}
if (BI.isNotNull(o.rgap)) {
right += o.rgap;
w.element.css({"right": right});
w.element.css({right: right});
}
if (BI.isNotNull(o.tgap)) {
top += o.tgap;
w.element.css({"top": top});
w.element.css({top: top});
}
if (BI.isNotNull(o.bgap)) {
bottom += o.bgap;
w.element.css({"bottom": bottom});
w.element.css({bottom: bottom});
}
if (BI.isNotNull(item.width)) {
w.element.css({"width": item.width});
w.element.css({width: item.width});
}
if (BI.isNotNull(item.height)) {
w.element.css({"height": item.height});
w.element.css({height: item.height});
}
return w;
},
@ -89,4 +89,4 @@ BI.AdaptiveLayout = BI.inherit(BI.Layout, {
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) {
// do nothing
throw new Error("cannot be added")
throw new Error("cannot be added");
},
stroke: function(regions){
stroke: function (regions) {
var item;
var top = 0;
var bottom = 0;
@ -41,11 +41,11 @@ BI.BorderLayout = BI.inherit(BI.Layout, {
}
this.getWidgetByName(this.getName() + "north").element.height(item.height)
.css({
"position": "absolute",
"top": (item.top || 0),
"left": (item.left || 0),
"right": (item.right || 0),
"bottom": "initial"
position: "absolute",
top: (item.top || 0),
left: (item.left || 0),
right: (item.right || 0),
bottom: "initial"
});
}
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)
.css({
"position": "absolute",
"bottom": (item.bottom || 0),
"left": (item.left || 0),
"right": (item.right || 0),
"top": "initial"
position: "absolute",
bottom: (item.bottom || 0),
left: (item.left || 0),
right: (item.right || 0),
top: "initial"
});
}
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)
.css({
"position": "absolute",
"left": (item.left || 0),
position: "absolute",
left: (item.left || 0),
top: top,
bottom: bottom,
"right": "initial"
right: "initial"
});
}
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)
.css({
"position": "absolute",
"right": (item.right || 0),
position: "absolute",
right: (item.right || 0),
top: top,
bottom: bottom,
"left": "initial"
left: "initial"
});
}
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.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();
}
});
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;
this.showIndex = void 0;
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
if (!self.hasWidget(item.cardName)) {
var w = BI.createWidget(item);
w.on(BI.Events.DESTROY, function () {
@ -41,7 +41,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
} else {
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);
}
});
@ -100,11 +100,11 @@ BI.CardLayout = BI.inherit(BI.Layout, {
}
var widget = BI.createWidget(cardItem);
widget.element.css({
"position": "relative",
"top": "0",
"left": "0",
"width": "100%",
"height": "100%"
position: "relative",
top: "0",
left: "0",
width: "100%",
height: "100%"
}).appendTo(this.element);
widget.invisible();
this.addWidget(cardName, widget);
@ -114,7 +114,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
showCardByName: function (name, action, callback) {
var self = this;
//name不存在的时候全部隐藏
// name不存在的时候全部隐藏
var exist = this.isCardExisted(name);
if (this.showIndex != null) {
this.lastShowIndex = this.showIndex;
@ -125,10 +125,10 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var el = self._children[item.cardName];
if (el) {
if (name != item.cardName) {
//动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了
// 动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了
!flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible();
} else {
(BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback())
(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;
BI.each(this.options.items, function (i, item) {
self._children[item.cardName].setVisible(self.showIndex == i);
})
});
},
setDefaultShowName: function (name) {
@ -154,7 +154,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
getAllCardNames: function () {
return BI.map(this.options.items, function (i, item) {
return item.cardName;
})
});
},
getShowingCard: function () {
@ -168,7 +168,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var self = this;
BI.each(this.getAllCardNames(), function (i, name) {
self.deleteCardByName(name);
})
});
},
hideAllCard: function () {
@ -197,7 +197,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (child === nameOrWidget) {
removeName = name;
}
})
});
} else {
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) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -56,4 +56,4 @@ BI.DefaultLayout = BI.inherit(BI.Layout, {
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,
// el: {type: 'bi.button', text: 'button3'}
// }
//]
// ]
});
},
render: function () {
@ -47,16 +47,16 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
addItem: function (item) {
// 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 rows = o.rows || o.items.length, columns = o.columns || ((o.items[0] && o.items[0].length) | 0);
var map = BI.makeArray(rows), widths = {}, heights = {};
function firstElement(item, row, col) {
function firstElement (item, row, col) {
if (row === 0) {
item.addClass("first-row")
item.addClass("first-row");
}
if (col === 0) {
item.addClass("first-col");
@ -66,7 +66,7 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
item.addClass("center-element");
}
function firstObject(item, row, col) {
function firstObject (item, row, col) {
var cls = "";
if (row === 0) {
cls += " first-row";
@ -79,13 +79,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element";
}
function first(item, row, col) {
function first (item, row, col) {
if (item instanceof BI.Widget) {
firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col);
} else if (item.el) {
firstObject(item.el, row, col)
firstObject(item.el, row, col);
} else {
firstObject(item, row, col);
}
@ -119,13 +119,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
w = this.getWidgetByName(this.getName() + i + "_" + j);
}
var left = totalW * 100 / widths[i];
w.element.css({"position": "absolute", "left": left + "%"});
w.element.css({position: "absolute", left: left + "%"});
if (j > 0) {
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) {
w.element.css({"right": "0%"});
w.element.css({right: "0%"});
}
first(w, i, j);
totalW += map[i][j].width;
@ -136,13 +136,13 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < o.rows; i++) {
var w = this.getWidgetByName(this.getName() + i + "_" + j);
var top = totalH * 100 / heights[j];
w.element.css({"top": top + "%"});
w.element.css({top: top + "%"});
if (i > 0) {
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) {
w.element.css({"bottom": "0%"});
w.element.css({bottom: "0%"});
}
totalH += map[i][j].height;
}
@ -154,4 +154,4 @@ BI.DivisionLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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)) {
w.element.css({"left": item.left});
w.element.css({left: item.left});
}
if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right});
w.element.css({right: item.right});
}
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) {
w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
@ -61,7 +61,7 @@ BI.FloatLeftLayout = BI.inherit(BI.Layout, {
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) {
var o = this.options;
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)) {
w.element.css({"left": item.left});
w.element.css({left: item.left});
}
if (BI.isNotNull(item.right)) {
w.element.css({"right": item.right});
w.element.css({right: item.right});
}
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) {
w.element.css("margin-left", (item.lgap || 0) + o.hgap + o.lgap);
@ -126,4 +126,4 @@ BI.FloatRightLayout = BI.inherit(BI.Layout, {
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,
rows: null,
items: []
/*[
/* [
{
column: 0,
row: 0,
@ -40,8 +40,8 @@ BI.GridLayout = BI.inherit(BI.Layout, {
},
addItem: function () {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -52,9 +52,9 @@ BI.GridLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < rows; i++) {
els[i] = [];
}
function firstElement(item, row, col) {
function firstElement (item, row, col) {
if (row === 0) {
item.addClass("first-row")
item.addClass("first-row");
}
if (col === 0) {
item.addClass("first-col");
@ -64,7 +64,7 @@ BI.GridLayout = BI.inherit(BI.Layout, {
item.addClass("center-element");
}
function firstObject(item, row, col) {
function firstObject (item, row, col) {
var cls = "";
if (row === 0) {
cls += " first-row";
@ -77,13 +77,13 @@ BI.GridLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element";
}
function first(item, row, col) {
function first (item, row, col) {
if (item instanceof BI.Widget) {
firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col);
} else if (item.el) {
firstObject(item.el, row, col)
firstObject(item.el, row, col);
} else {
firstObject(item, row, col);
}
@ -107,11 +107,11 @@ BI.GridLayout = BI.inherit(BI.Layout, {
}
first(els[i][j], i, j);
els[i][j].element.css({
"position": "absolute",
"top": height * i + "%",
"left": width * j + "%",
"right": (100 - (width * (j + 1))) + "%",
"bottom": (100 - (height * (i + 1))) + "%"
position: "absolute",
top: height * i + "%",
left: width * j + "%",
right: (100 - (width * (j + 1))) + "%",
bottom: (100 - (height * (i + 1))) + "%"
});
this.addWidget(els[i][j]);
}
@ -123,4 +123,4 @@ BI.GridLayout = BI.inherit(BI.Layout, {
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 () {
BI.HorizontalLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
position: "relative",
"white-space": "nowrap",
"border-spacing": "0px",
"border": "none",
border: "none",
"border-collapse": "separate"
});
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];
if (!this.hasWidget(this._getChildName(i))) {
var w = BI.createWidget(item);
w.element.css({"position": "relative", "margin": "0px auto"});
w.element.css({position: "relative", margin: "0px auto"});
td = BI.createWidget({
type: "bi.default",
tagName: "td",
@ -57,31 +57,31 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
td.element.addClass("first-element");
}
td.element.css({
"position": "relative",
position: "relative",
"vertical-align": o.verticalAlign,
"margin": "0",
"padding": "0",
"border": "none"
margin: "0",
padding: "0",
border: "none"
});
if (o.hgap + o.lgap + (item.lgap || 0) > 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.tgap + (item.tgap || 0) > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return td;
},
@ -107,7 +107,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
// console.log("horizontal layout do not need to resize");
},
_getWrapper: function(){
_getWrapper: function () {
return this.$tr;
},
@ -116,7 +116,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, {
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 () {
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);
},
_addElement: function (i, item) {
var o = this.options;
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) {
w.element.css({
"margin-left": o.hgap + o.lgap + "px"
})
});
}
if (o.hgap + o.rgap > 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + "px"
})
});
}
if (o.vgap + o.tgap > 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + "px"
})
});
}
if (o.vgap + o.bgap > 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + "px"
})
});
}
return w;
},
@ -178,4 +178,4 @@ BI.HorizontalCellLayout = BI.inherit(BI.Layout, {
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 () {
return BI.extend(BI.LatticeLayout.superclass.props.apply(this, arguments), {
baseCls: "bi-lattice-layout clearfix"
//columnSize: [0.2, 0.2, 0.6],
// columnSize: [0.2, 0.2, 0.6],
});
},
render: function () {
@ -25,9 +25,9 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
if (o.columnSize && o.columnSize[i]) {
var width = o.columnSize[i] / BI.sum(o.columnSize) * 100 + "%";
} 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;
},
@ -52,4 +52,4 @@ BI.LatticeLayout = BI.inherit(BI.Layout, {
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), {
baseCls: "bi-table-layout",
scrolly: true,
columnSize: [200, 200, 'fill'],
rowSize: 30, //or [30,30,30]
columnSize: [200, 200, "fill"],
rowSize: 30, // or [30,30,30]
hgap: 0,
vgap: 0,
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 abs = [], left = 0, right = 0, i, j;
function firstElement(item, row, col) {
function firstElement (item, row, col) {
if (row === 0) {
item.addClass("first-row")
item.addClass("first-row");
}
if (col === 0) {
item.addClass("first-col");
@ -48,7 +48,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
item.addClass("center-element");
}
function firstObject(item, row, col) {
function firstObject (item, row, col) {
var cls = "";
if (row === 0) {
cls += " first-row";
@ -61,13 +61,13 @@ BI.TableLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element";
}
function first(item, row, col) {
function first (item, row, col) {
if (item instanceof BI.Widget) {
firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col);
} else if (item.el) {
firstObject(item.el, row, col)
firstObject(item.el, row, col);
} else {
firstObject(item, row, col);
}
@ -95,7 +95,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
bottom: 0,
right: o.columnSize[j] <= 1 ? right * 100 + "%" : right,
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);
} else {
throw new Error("item with fill can only be one");
@ -108,7 +108,7 @@ BI.TableLayout = BI.inherit(BI.Layout, {
bottom: 0,
left: left <= 1 ? left * 100 + "%" : left,
right: right <= 1 ? right * 100 + "%" : right
}, arr[i]))
}, arr[i]));
}
var w = BI.createWidget({
type: "bi.absolute",
@ -118,10 +118,10 @@ BI.TableLayout = BI.inherit(BI.Layout, {
if (this.rows > 0) {
this.getWidgetByName(this.getName() + (this.rows - 1)).element.css({
"margin-bottom": o.vgap
})
});
}
w.element.css({
"position": "relative"
position: "relative"
});
this.addWidget(this.getName() + (this.rows++), w);
return w;
@ -143,4 +143,4 @@ BI.TableLayout = BI.inherit(BI.Layout, {
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: [
{
width: 100,
el: {type: 'bi.button', text: 'button1'}
el: {type: "bi.button", text: "button1"}
},
{
width: 'fill',
el: {type: 'bi.button', text: 'button2'}
width: "fill",
el: {type: "bi.button", text: "button2"}
},
{
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) {
// do nothing
throw new Error("cannot be added")
throw new Error("cannot be added");
},
stroke: function (items) {
@ -52,7 +52,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
} else {
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 = {};
@ -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;
}
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 {
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 : ""
});
}
@ -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;
}
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 {
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 : ""
});
}
if (!BI.isNumber(item.width)) {
return true;
}
})
});
},
populate: function (items) {
@ -100,7 +100,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, {
this._mount();
}
});
BI.shortcut('bi.htape', BI.HTapeLayout);
BI.shortcut("bi.htape", BI.HTapeLayout);
/**
* 垂直tape布局
@ -120,15 +120,15 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
items: [
{
height: 100,
el: {type: 'bi.button', text: 'button1'}
el: {type: "bi.button", text: "button1"}
},
{
height: 'fill',
el: {type: 'bi.button', text: 'button2'}
height: "fill",
el: {type: "bi.button", text: "button2"}
},
{
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) {
// do nothing
throw new Error("cannot be added")
throw new Error("cannot be added");
},
stroke: function (items) {
@ -157,7 +157,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
} else {
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 = {};
@ -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;
}
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 {
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 : ""
});
}
@ -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;
}
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 {
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 : ""
});
}
if (!BI.isNumber(item.height)) {
return true;
}
})
});
},
populate: function (items) {
@ -205,4 +205,4 @@ BI.VTapeLayout = BI.inherit(BI.Layout, {
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,
items: [[
{
el: {text: 'label1'}
el: {text: "label1"}
},
{
el: {text: 'label2'}
el: {text: "label2"}
},
{
el: {text: 'label3'}
el: {text: "label3"}
}
]]
});
},
render: function () {
BI.TdLayout.superclass.render.apply(this, arguments);
this.$table = $("<table>").attr({"cellspacing": 0, "cellpadding": 0}).css({
"position": "relative",
"width": "100%",
"height": "100%",
this.$table = $("<table>").attr({cellspacing: 0, cellpadding: 0}).css({
position: "relative",
width: "100%",
height: "100%",
"border-spacing": "0px",
"border": "none",
border: "none",
"border-collapse": "separate"
});
this.rows = 0;
@ -40,9 +40,9 @@ BI.TdLayout = BI.inherit(BI.Layout, {
_addElement: function (idx, arr) {
var o = this.options;
function firstElement(item, row, col) {
function firstElement (item, row, col) {
if (row === 0) {
item.addClass("first-row")
item.addClass("first-row");
}
if (col === 0) {
item.addClass("first-col");
@ -52,7 +52,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
item.addClass("center-element");
}
function firstObject(item, row, col) {
function firstObject (item, row, col) {
var cls = "";
if (row === 0) {
cls += " first-row";
@ -65,13 +65,13 @@ BI.TdLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element";
}
function first(item, row, col) {
function first (item, row, col) {
if (item instanceof BI.Widget) {
firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col);
} else if (item.el) {
firstObject(item.el, row, col)
firstObject(item.el, row, col);
} else {
firstObject(item, row, col);
}
@ -84,7 +84,7 @@ BI.TdLayout = BI.inherit(BI.Layout, {
for (var i = 0; i < arr.length; 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) {
w.element.css({"margin-left": arr[i].lgap + "px"});
}
@ -99,19 +99,19 @@ BI.TdLayout = BI.inherit(BI.Layout, {
}
first(w, this.rows++, i);
var td = BI.createWidget({
type: 'bi.default',
type: "bi.default",
attributes: {
width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]
},
tagName: 'td',
tagName: "td",
items: [w]
});
td.element.css({
"position": "relative",
position: "relative",
"vertical-align": "middle",
"margin": "0",
"padding": "0",
"border": "none"
margin: "0",
padding: "0",
border: "none"
});
tr.addItem(td);
}
@ -151,4 +151,4 @@ BI.TdLayout = BI.inherit(BI.Layout, {
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 w = BI.VerticalLayout.superclass._addElement.apply(this, arguments);
w.element.css({
"position": "relative"
position: "relative"
});
if (o.vgap + o.tgap + (item.tgap || 0) !== 0) {
w.element.css({
"margin-top": o.vgap + o.tgap + (item.tgap || 0) + "px"
})
});
}
if (o.hgap + o.lgap + (item.lgap || 0) !== 0) {
w.element.css({
"margin-left": o.hgap + o.lgap + (item.lgap || 0) + "px"
})
});
}
if (o.hgap + o.rgap + (item.rgap || 0) !== 0) {
w.element.css({
"margin-right": o.hgap + o.rgap + (item.rgap || 0) + "px"
})
});
}
if (o.vgap + o.bgap + (item.bgap || 0) !== 0) {
w.element.css({
"margin-bottom": o.vgap + o.bgap + (item.bgap || 0) + "px"
})
});
}
return w;
},
@ -59,4 +59,4 @@ BI.VerticalLayout = BI.inherit(BI.Layout, {
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"],
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) {
// do nothing
throw new Error("cannot be added")
throw new Error("cannot be added");
},
stroke: function (items) {
@ -52,9 +52,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.columnSize)) {
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) {
item.addClass("first-row")
item.addClass("first-row");
}
if (col === 0) {
item.addClass("first-col");
@ -64,7 +64,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
item.addClass("center-element");
}
function firstObject(item, row, col) {
function firstObject (item, row, col) {
var cls = "";
if (row === 0) {
cls += " first-row";
@ -77,13 +77,13 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
item.cls = (item.cls || "") + cls + " center-element";
}
function first(item, row, col) {
function first (item, row, col) {
if (item instanceof BI.Widget) {
firstElement(item.element, row, col);
} else if (item.el instanceof BI.Widget) {
firstElement(item.el.element, row, col);
} else if (item.el) {
firstObject(item.el, row, col)
firstObject(item.el, row, col);
} else {
firstObject(item, row, col);
}
@ -96,7 +96,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
}
if (!this.hasWidget(this.getName() + 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);
}
}
@ -106,7 +106,7 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
top[0] = 0;
right[o.columns - 1] = 0;
bottom[o.rows - 1] = 0;
//从上到下
// 从上到下
for (var i = 0; i < o.rows; i++) {
for (var j = 0; j < o.columns; 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])) {
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);
}
if (!BI.isNumber(o.rowSize[i])) {
break;
}
}
//从下到上
// 从下到上
for (var i = o.rows - 1; i >= 0; i--) {
for (var j = 0; j < o.columns; 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])) {
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);
}
if (!BI.isNumber(o.rowSize[i])) {
break;
}
}
//从左到右
// 从左到右
for (var j = 0; j < o.columns; j++) {
for (var i = 0; i < o.rows; i++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + j);
@ -153,25 +153,25 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
if (BI.isNumber(o.columnSize[j])) {
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);
}
if (!BI.isNumber(o.columnSize[j])) {
break;
}
}
//从右到左
// 从右到左
for (var j = o.columns - 1; j >= 0; j--) {
for (var i = 0; i < o.rows; i++) {
var wi = this.getWidgetByName(this.getName() + i + "_" + 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 = "";
if (BI.isNumber(o.columnSize[j])) {
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);
}
if (!BI.isNumber(o.columnSize[j])) {
@ -185,4 +185,4 @@ BI.WindowLayout = BI.inherit(BI.Layout, {
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) {
//do nothing
// do nothing
throw new Error("cannot be added");
},
@ -44,7 +44,7 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
});
});
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
var w = BI.createWidget(item);
w.element.css({
position: "absolute",
@ -72,4 +72,4 @@ BI.CenterLayout = BI.inherit(BI.Layout, {
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) {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -45,7 +45,7 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
});
});
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
var w = BI.createWidget(item);
w.element.css({
position: "absolute",
@ -71,4 +71,4 @@ BI.FloatCenterLayout = BI.inherit(BI.Layout, {
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) {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -43,7 +43,7 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
});
});
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
var w = BI.createWidget(item);
w.element.css({
position: "absolute",
@ -70,4 +70,4 @@ BI.HorizontalCenterLayout = BI.inherit(BI.Layout, {
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) {
//do nothing
throw new Error("cannot be added")
// do nothing
throw new Error("cannot be added");
},
stroke: function (items) {
@ -43,7 +43,7 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
});
});
BI.each(items, function (i, item) {
if (!!item) {
if (item) {
var w = BI.createWidget(item);
w.element.css({
position: "absolute",
@ -70,4 +70,4 @@ BI.VerticalCenterLayout = BI.inherit(BI.Layout, {
this._mount();
}
});
BI.shortcut('bi.vertical_center', BI.VerticalCenterLayout);
BI.shortcut("bi.vertical_center", BI.VerticalCenterLayout);
Loading…
Cancel
Save