Browse Source

Merge pull request #10 in FUI/fineui from ~GUY/fineui:2.0 to 2.0

* commit '10c8300f34008693321eba812fa074f2fa1f3243':
  add
  add
  add
  add
  add
  add
  add
  补方法
  delete
  ajax
  update
  add
  add
  整理
  update
  update
  update
  add
  add
es6
guy 8 years ago
parent
commit
a29ab8b879
  1. 5
      bi/base.css
  2. 48
      bi/base.js
  3. 2
      bi/case.js
  4. 1037
      bi/core.js
  5. 12
      bi/widget.css
  6. 9
      bi/widget.js
  7. 1
      demo/js/core/abstract/demo.virtual_group.js
  8. 4
      demo/version.js
  9. 5
      dist/base.css
  10. 48
      dist/base.js
  11. 2
      dist/case.js
  12. 1071
      dist/core.js
  13. 12
      dist/widget.css
  14. 9
      dist/widget.js
  15. 4
      src/base/base.js
  16. 22
      src/base/combination/group.button.js
  17. 16
      src/base/combination/group.virtual.js
  18. 4
      src/base/single/input/file.js
  19. 2
      src/case/pager/pager.all.count.js
  20. 529
      src/core/alias.js
  21. 179
      src/core/base.js
  22. 5
      src/core/controller/controller.broadcast.js
  23. 4
      src/core/controller/controller.floatbox.js
  24. 5
      src/core/controller/controller.resizer.js
  25. 80
      src/core/proto/date.js
  26. 20
      src/core/view.js
  27. 13
      src/core/widget.js
  28. 60
      src/core/wrapper/layout.js
  29. 36
      src/core/wrapper/layout/layout.card.js
  30. 2
      src/css/base/single/text.css
  31. 3
      src/css/base/table/table.grid.quick.css
  32. 4
      src/css/widget/finetuningnumbereditor/finetuning.number.editor.css
  33. 8
      src/css/widget/responsivetable/responsivetable.css
  34. 2
      src/less/base/single/text.less
  35. 4
      src/less/base/table/table.grid.quick.less
  36. 4
      src/less/widget/finetuningnumbereditor/finetuning.number.editor.less
  37. 11
      src/less/widget/responsivetable/responsivetable.less
  38. 3
      src/widget/date/trigger.date.js
  39. 4
      src/widget/exceltable/exceltable.js
  40. 2
      src/widget/year/trigger.year.js

5
bi/base.css

@ -1035,7 +1035,7 @@ li.CodeMirror-hint-active {
overflow-x: hidden;
overflow-y: hidden;
white-space: nowrap;
word-break: break-all;
word-break: break-word;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
@ -1197,9 +1197,6 @@ li.CodeMirror-hint-active {
.bi-grid-table-cell.first-col {
border-left: 1px solid #eaeaea;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.scrollbar-layout-main {
box-sizing: border-box;
outline: none;

48
bi/base.js

@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]);
break;
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
}
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
});
btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn);
@ -1118,9 +1120,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts.addItems(this._packageLayout(items).items);
},
removeItemAt: function (index) {
this.buttons[index].destroy();
this.layouts.removeItemAt(index);
removeItemAt: function (indexes) {
BI.remove(this.buttons, indexes);
this.layouts.removeItemAt(indexes);
},
removeItems: function (values) {
values = BI.isArray(values) ? values : [values];
var deleted = [];
BI.each(this.buttons, function (i, button) {
if (BI.deepContains(values, button.getValue())) {
deleted.push(i);
}
});
BI.remove(this.buttons, deleted);
this.layouts.removeItemAt(deleted);
},
populate: function (items) {
@ -2354,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};/**
BI.StyleLoaders = new BI.StyleLoaderManager();/**
* canvas绘图
*
* Created by GUY on 2015/11/18.
@ -3612,15 +3622,27 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
this.layouts.prependItems(items);
},
setValue: function (v) {
this.layouts.setValue(v);
},
getValue: function () {
return this.layouts.getValue();
},
empty: function () {
this.layouts.empty();
},
populate: function (items) {
var self = this;
items = items || [];
this.options.items = items;
items = this._packageItems(items, this._packageBtns(items));
items = this._packageBtns(items);
if (!this.layouts) {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
} else {
this.layouts.populate(this._packageLayout(items).items);
this.layouts.populate(items);
}
}
});
@ -18237,7 +18259,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
},
false
);
xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true);
xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true);
if (!xhr.upload) {
var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true};
rpe.interval = setInterval(function () {
@ -18686,7 +18708,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
BI.File.superclass.setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {

2
bi/case.js

@ -8520,7 +8520,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, {
hgap: 4,
vgap: 0,
value: o.curr,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
width: 30,
height: 20
});

1037
bi/core.js

File diff suppressed because it is too large Load Diff

12
bi/widget.css

@ -233,11 +233,13 @@
}
.bi-fine-tuning-number-editor .top-button {
border-left: 1px solid #d4dadd;
border-bottom: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .bottom-button {
border-left: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .split-line {
background-color: #d4dadd;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
@ -632,14 +634,6 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

9
bi/widget.js

@ -4857,7 +4857,6 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
hgap: 4,
vgap: 2,
triggerWidth: 30,
watermark: BI.i18nText("BI-Unrestricted"),
yearLength: 4,
yearMonthLength: 7
},
@ -4891,7 +4890,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: c.watermark,
watermark: BI.i18nText("BI-Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");
@ -6158,7 +6157,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-excel-table",
el: {
type: "bi.adaptive_table"
type: "bi.responsive_table"
},
isNeedResize: false,
@ -6192,8 +6191,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
this.table = BI.createWidget(o.el, {
type: "bi.table_view",
element: this,
isNeedResize: o.isNeedResize,
isResizeAdapt: o.isResizeAdapt,
isNeedFreeze: false,
@ -16791,7 +16788,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
hgap: 4,
vgap: 2,
triggerWidth: 25,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
},

1
demo/js/core/abstract/demo.virtual_group.js

@ -66,6 +66,7 @@ Demo.Item = BI.inherit(BI.Widget, {
update: function (item) {
this.label.setText(item.value);
console.log("更新了一项");
return true;
},
created: function () {

4
demo/version.js

@ -5,3 +5,7 @@ Demo = {
BI.i18n = {
"BI-Basic_OK": "确定"
};
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};

5
dist/base.css vendored

@ -1035,7 +1035,7 @@ li.CodeMirror-hint-active {
overflow-x: hidden;
overflow-y: hidden;
white-space: nowrap;
word-break: break-all;
word-break: break-word;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
@ -1197,9 +1197,6 @@ li.CodeMirror-hint-active {
.bi-grid-table-cell.first-col {
border-left: 1px solid #eaeaea;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.scrollbar-layout-main {
box-sizing: border-box;
outline: none;

48
dist/base.js vendored

@ -1020,9 +1020,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]);
break;
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
}
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
});
btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn);
@ -1118,9 +1120,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts.addItems(this._packageLayout(items).items);
},
removeItemAt: function (index) {
this.buttons[index].destroy();
this.layouts.removeItemAt(index);
removeItemAt: function (indexes) {
BI.remove(this.buttons, indexes);
this.layouts.removeItemAt(indexes);
},
removeItems: function (values) {
values = BI.isArray(values) ? values : [values];
var deleted = [];
BI.each(this.buttons, function (i, button) {
if (BI.deepContains(values, button.getValue())) {
deleted.push(i);
}
});
BI.remove(this.buttons, deleted);
this.layouts.removeItemAt(deleted);
},
populate: function (items) {
@ -2354,11 +2368,7 @@ BI.Bubbles = new BI.BubblesController();
BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};/**
BI.StyleLoaders = new BI.StyleLoaderManager();/**
* canvas绘图
*
* Created by GUY on 2015/11/18.
@ -3612,15 +3622,27 @@ BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Wid
this.layouts.prependItems(items);
},
setValue: function (v) {
this.layouts.setValue(v);
},
getValue: function () {
return this.layouts.getValue();
},
empty: function () {
this.layouts.empty();
},
populate: function (items) {
var self = this;
items = items || [];
this.options.items = items;
items = this._packageItems(items, this._packageBtns(items));
items = this._packageBtns(items);
if (!this.layouts) {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
} else {
this.layouts.populate(this._packageLayout(items).items);
this.layouts.populate(items);
}
}
});
@ -18237,7 +18259,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
},
false
);
xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true);
xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true);
if (!xhr.upload) {
var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true};
rpe.interval = setInterval(function () {
@ -18686,7 +18708,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/**
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
BI.File.superclass.setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {

2
dist/case.js vendored

@ -8520,7 +8520,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, {
hgap: 4,
vgap: 0,
value: o.curr,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
width: 30,
height: 20
});

1071
dist/core.js vendored

File diff suppressed because it is too large Load Diff

12
dist/widget.css vendored

@ -233,11 +233,13 @@
}
.bi-fine-tuning-number-editor .top-button {
border-left: 1px solid #d4dadd;
border-bottom: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .bottom-button {
border-left: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .split-line {
background-color: #d4dadd;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
@ -632,14 +634,6 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-sequence-table-dynamic-number .sequence-table-title-cell {
overflow: hidden;
overflow-x: hidden;

9
dist/widget.js vendored

@ -4857,7 +4857,6 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
hgap: 4,
vgap: 2,
triggerWidth: 30,
watermark: BI.i18nText("BI-Unrestricted"),
yearLength: 4,
yearMonthLength: 7
},
@ -4891,7 +4890,7 @@ BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigge
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: c.watermark,
watermark: BI.i18nText("BI-Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");
@ -6158,7 +6157,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-excel-table",
el: {
type: "bi.adaptive_table"
type: "bi.responsive_table"
},
isNeedResize: false,
@ -6192,8 +6191,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
this.table = BI.createWidget(o.el, {
type: "bi.table_view",
element: this,
isNeedResize: o.isNeedResize,
isResizeAdapt: o.isResizeAdapt,
isNeedFreeze: false,
@ -16791,7 +16788,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
hgap: 4,
vgap: 2,
triggerWidth: 25,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
},

4
src/base/base.js

@ -6,7 +6,3 @@ BI.Tooltips = new BI.TooltipsController();
BI.Popovers = new BI.FloatBoxController();
BI.Broadcasts = new BI.BroadcastController();
BI.StyleLoaders = new BI.StyleLoaderManager();
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.i18n = {};

22
src/base/combination/group.button.js

@ -57,9 +57,11 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
self.setValue([]);
break;
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj);
}
} else {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
});
btn.on(BI.Events.DESTROY, function () {
BI.remove(self.buttons, btn);
@ -155,9 +157,21 @@ BI.ButtonGroup = BI.inherit(BI.Widget, {
this.layouts.addItems(this._packageLayout(items).items);
},
removeItemAt: function (index) {
this.buttons[index].destroy();
this.layouts.removeItemAt(index);
removeItemAt: function (indexes) {
BI.remove(this.buttons, indexes);
this.layouts.removeItemAt(indexes);
},
removeItems: function (values) {
values = BI.isArray(values) ? values : [values];
var deleted = [];
BI.each(this.buttons, function (i, button) {
if (BI.deepContains(values, button.getValue())) {
deleted.push(i);
}
});
BI.remove(this.buttons, deleted);
this.layouts.removeItemAt(deleted);
},
populate: function (items) {

16
src/base/combination/group.virtual.js

@ -55,15 +55,27 @@ BI.VirtualGroup = BI.inherit(BI.Widget, {
this.layouts.prependItems(items);
},
setValue: function (v) {
this.layouts.setValue(v);
},
getValue: function () {
return this.layouts.getValue();
},
empty: function () {
this.layouts.empty();
},
populate: function (items) {
var self = this;
items = items || [];
this.options.items = items;
items = this._packageItems(items, this._packageBtns(items));
items = this._packageBtns(items);
if (!this.layouts) {
this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
} else {
this.layouts.populate(this._packageLayout(items).items);
this.layouts.populate(items);
}
}
});

4
src/base/single/input/file.js

@ -153,7 +153,7 @@
},
false
);
xhr.open("post", handler.url + '&filename=' + BI.cjkEncode(handler.file.fileName), true);
xhr.open("post", handler.url + '&filename=' + window.encodeURIComponent(handler.file.fileName), true);
if (!xhr.upload) {
var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true};
rpe.interval = setInterval(function () {
@ -602,7 +602,7 @@
},
setEnable: function (enable) {
BI.MultiFile.superclass.setEnable.apply(this, arguments);
BI.File.superclass.setEnable.apply(this, arguments);
if (enable === true) {
this.element.attr("disabled", "disabled");
} else {

2
src/case/pager/pager.all.count.js

@ -25,7 +25,7 @@ BI.AllCountPager = BI.inherit(BI.Widget, {
hgap: 4,
vgap: 0,
value: o.curr,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
width: 30,
height: 20
});

529
src/core/alias.js

@ -5,178 +5,59 @@
return result;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
return text;
// 判断是否是无效的日期
function isInvalidDate(date) {
return date == "Invalid Date" || date == "NaN";
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt(i);
if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]";
/**
* 科学计数格式
*/
function _eFormat(text, fmt) {
var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) {
text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright)
} else {
newText += text.charAt(i);
}
}
return newText
};
BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) {
var result = {};
$.each(o, function (k, v) {
if (!(typeof v == "string")) {
v = BI.jsonEncode(v);
}
//wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。
k = BI.cjkEncode(k);
result[k] = BI.cjkEncode(v);
});
return result;
}
return o;
};
BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false;
// crashes Safari in some instances
//var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/;
var m = {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"': '\\"',
"\\": '\\\\'
};
var encodeString = function (s) {
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
var c = m[b];
if (c) {
return c;
var isNegative = text < 0;
if (isNegative) {
text = text.substr(1);
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
var elvl = (eleft.split('.')[0] || '').length;
var point = text.indexOf(".");
if (point < 0) {
point = text.length;
}
return '"' + s + '"';
};
var encodeArray = function (o) {
var a = ["["], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
var i = 0; //第一个不为0的数的位置
text = text.replace('.', '');
for (var len = text.length; i < len; i++) {
var ech = text.charAt(i);
if (ech <= '9' && ech >= '1') {
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : BI.jsonEncode(v));
b = true;
}
var right = point - i - elvl;
var left = text.substr(i, elvl);
var dis = i + elvl - text.length;
if (dis > 0) {
//末位补全0
for (var k = 0; k < dis; k++) {
left += '0';
}
a.push("]");
return a.join("");
};
if (typeof o == "undefined" || o === null) {
return "null";
} else if (BI.isArray(o)) {
return encodeArray(o);
} else if (o instanceof Date) {
/*
* alex:原来只是把年月日时分秒简单地拼成一个String,无法decode
* 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下
*/
return BI.jsonEncode({
__time__: o.getTime()
})
} else if (typeof o == "string") {
return encodeString(o);
} else if (typeof o == "number") {
return isFinite(o) ? String(o) : "null";
} else if (typeof o == "boolean") {
return String(o);
} else if (BI.isFunction(o)) {
return String(o);
} else {
var a = ["{"], b, i, v;
for (i in o) {
if (!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(BI.jsonEncode(i), ":",
v === null ? "null" : BI.jsonEncode(v));
b = true;
}
left += '.' + text.substr(i + elvl);
}
left = left.replace(/^[0]+/, '');
if (right < 0 && eright.indexOf('-') < 0) {
eright += ';-' + eright;
}
a.push("}");
return a.join("");
text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright);
if (isNegative) {
text = '-' + text;
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
}
var text = cv.toString();
if (isEmpty(fmt)) {
//格式为空,返回原字符
return text;
}
if (fmt.match(/^T/)) {
//T - 文本格式
return text;
} else if (fmt.match(/^D/)) {
//D - 日期(时间)格式
if (!(cv instanceof Date)) {
if (typeof cv === 'number') {
//毫秒数类型
cv = new Date(cv);
} else {
//字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long);
}
}
if (!BI.isNull(cv)) {
var needTrim = fmt.match(/^DT/);
text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1));
}
} else if (fmt.match(/E/)) {
//科学计数格式
text = BI._eFormat(text, fmt);
} else {
//数字格式
text = BI._numberFormat(text, fmt);
}
//¤ - 货币格式
text = text.replace(/¤/g, '¥');
return text;
};
/**
* 把日期对象按照指定格式转化成字符串
@ -190,7 +71,7 @@
* @param format 日期格式
* @returns {String}
*/
date2Str = function (date, format) {
function date2Str(date, format) {
if (!date) {
return '';
}
@ -299,15 +180,15 @@
/**
* 数字格式
*/
BI._numberFormat = function (text, format) {
function _numberFormat(text, format) {
var text = text + '';
//数字格式,区分正负数
var numMod = format.indexOf(';');
if (numMod > -1) {
if (text >= 0) {
return BI._numberFormat(text + "", format.substring(0, numMod));
return _numberFormat(text + "", format.substring(0, numMod));
} else {
return BI._numberFormat((-text) + "", format.substr(numMod + 1));
return _numberFormat((-text) + "", format.substr(numMod + 1));
}
}
var tp = text.split('.'), fp = format.split('.'),
@ -321,7 +202,7 @@
tleft = tleft.replace(/^0+/gi, '');
tright = tright.substr(paddingZero.length).replace(/0+$/gi, '');
}
var right = BI._dealWithRight(tright, fright);
var right = _dealWithRight(tright, fright);
if (right.leftPlus) {
//小数点后有进位
tleft = parseInt(tleft) + 1 + '';
@ -329,7 +210,7 @@
tleft = isNaN(tleft) ? '1' : tleft;
}
right = right.num;
var left = BI._dealWithLeft(tleft, fleft);
var left = _dealWithLeft(tleft, fleft);
if (!(/[0-9]/.test(left))) {
left = left + '0';
}
@ -346,7 +227,7 @@
* @returns {JSON} 返回处理结果和整数部分是否需要进位
* @private
*/
BI._dealWithRight = function (tright, fright) {
function _dealWithRight(tright, fright) {
var right = '', j = 0, i = 0;
for (var len = fright.length; i < len; i++) {
var ch = fright.charAt(i);
@ -377,7 +258,7 @@
if (numReg) {
var num = numReg[0];
var orilen = num.length;
var newnum = BI.parseINT(num) + 1 + '';
var newnum = BI.parseInt(num) + 1 + '';
//进位到整数部分
if (newnum.length > orilen) {
newnum = newnum.substr(1);
@ -390,22 +271,7 @@
}
result.num = right;
return result;
};
BI.parseINT = function (str) {
return parseInt(str, 10);
};
BI.leftPad = function (val, size, ch) {
var result = String(val);
if (!ch) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result.toString();
};
/**
* 处理小数点左边整数部分
@ -414,7 +280,7 @@
* @returns {string} 返回处理结果
* @private
*/
BI._dealWithLeft = function (tleft, fleft) {
function _dealWithLeft(tleft, fleft) {
var left = '';
var j = tleft.length - 1;
var combo = -1, last = -1;
@ -473,6 +339,242 @@
left = left.replace(/[0-9]+,/, newstr);
}
return left;
}
BI.cjkEncode = function (text) {
// alex:如果非字符串,返回其本身(cjkEncode(234) 返回 ""是不对的)
if (typeof text !== 'string') {
return text;
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt(i);
if (code >= 128 || code === 91 || code === 93) {//91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]";
} else {
newText += text.charAt(i);
}
}
return newText
};
BI.cjkEncodeDO = function (o) {
if (BI.isPlainObject(o)) {
var result = {};
$.each(o, function (k, v) {
if (!(typeof v == "string")) {
v = BI.jsonEncode(v);
}
//wei:bug 43338,如果key是中文,cjkencode后o的长度就加了1,ie9以下版本死循环,所以新建对象result。
k = BI.cjkEncode(k);
result[k] = BI.cjkEncode(v);
});
return result;
}
return o;
};
BI.jsonEncode = function (o) {
//james:这个Encode是抄的EXT的
var useHasOwn = {}.hasOwnProperty ? true : false;
// crashes Safari in some instances
//var validRE = /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/;
var m = {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"': '\\"',
"\\": '\\\\'
};
var encodeString = function (s) {
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function (a, b) {
var c = m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
};
var encodeArray = function (o) {
var a = ["["], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : BI.jsonEncode(v));
b = true;
}
}
a.push("]");
return a.join("");
};
if (typeof o == "undefined" || o === null) {
return "null";
} else if (BI.isArray(o)) {
return encodeArray(o);
} else if (o instanceof Date) {
/*
* alex:原来只是把年月日时分秒简单地拼成一个String,无法decode
* 现在这么处理就可以decode了,但是JS.jsonDecode和Java.JSONObject也要跟着改一下
*/
return BI.jsonEncode({
__time__: o.getTime()
})
} else if (typeof o == "string") {
return encodeString(o);
} else if (typeof o == "number") {
return isFinite(o) ? String(o) : "null";
} else if (typeof o == "boolean") {
return String(o);
} else if (BI.isFunction(o)) {
return String(o);
} else {
var a = ["{"], b, i, v;
for (i in o) {
if (!useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(BI.jsonEncode(i), ":",
v === null ? "null" : BI.jsonEncode(v));
b = true;
}
}
}
a.push("}");
return a.join("");
}
};
BI.jsonDecode = function (text) {
try {
// 注意0啊
//var jo = $.parseJSON(text) || {};
var jo = $.parseJSON(text);
if (jo == null) {
jo = {};
}
} catch (e) {
/*
* richie:浏览器只支持标准的JSON字符串转换而jQuery会默认调用浏览器的window.JSON.parse()函数进行解析
* 比如var str = "{'a':'b'}",这种形式的字符串转换为JSON就会抛异常
*/
try {
jo = new Function("return " + text)() || {};
} catch (e) {
//do nothing
}
if (jo == null) {
jo = [];
}
}
if (!_hasDateInJson(text)) {
return jo;
}
function _hasDateInJson(json) {
if (!json || typeof json !== "string") {
return false;
}
return json.indexOf("__time__") != -1;
}
return (function (o) {
if (typeof o === "string") {
return o;
}
if (o && o.__time__ != null) {
return new Date(o.__time__);
}
for (var a in o) {
if (o[a] == o || typeof o[a] == 'object' || $.isFunction(o[a])) {
break;
}
o[a] = arguments.callee(o[a]);
}
return o;
})(jo);
}
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
//原值为空,返回空字符
return '';
}
var text = cv.toString();
if (isEmpty(fmt)) {
//格式为空,返回原字符
return text;
}
if (fmt.match(/^T/)) {
//T - 文本格式
return text;
} else if (fmt.match(/^D/)) {
//D - 日期(时间)格式
if (!(cv instanceof Date)) {
if (typeof cv === 'number') {
//毫秒数类型
cv = new Date(cv);
} else {
//字符串类型,如yyyyMMdd、MMddyyyy等这样无分隔符的结构
cv = Date.parseDate(cv + "", Date.patterns.ISO8601Long);
}
}
if (!BI.isNull(cv)) {
var needTrim = fmt.match(/^DT/);
text = BI.date2Str(cv, fmt.substring(needTrim ? 2 : 1));
}
} else if (fmt.match(/E/)) {
//科学计数格式
text = _eFormat(text, fmt);
} else {
//数字格式
text = _numberFormat(text, fmt);
}
//¤ - 货币格式
text = text.replace(/¤/g, '¥');
return text;
};
BI.leftPad = function (val, size, ch) {
var result = String(val);
if (!ch) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result.toString();
};
BI.object2Number = function (value) {
@ -503,7 +605,7 @@
var str = obj + "";
str = str.replace(/-/g, '/');
var dt = new Date(str);
if (!BI.isInvalidDate(dt)) {
if (!isInvalidDate(dt)) {
return dt;
}
@ -511,10 +613,6 @@
}
};
BI.isArray = function (a) {
return Object.prototype.toString.call(a) == '[object Array]';
};
BI.object2Time = function (obj) {
if (obj == null) {
return new Date();
@ -525,75 +623,20 @@
var str = obj + "";
str = str.replace(/-/g, '/');
var dt = new Date(str);
if (!BI.isInvalidDate(dt)) {
if (!isInvalidDate(dt)) {
return dt;
}
if (str.indexOf('/') === -1 && str.indexOf(':') !== -1) {
dt = new Date("1970/01/01 " + str);
if (!BI.isInvalidDate(dt)) {
if (!isInvalidDate(dt)) {
return dt;
}
}
dt = BI.str2Date(str, "HH:mm:ss");
if (!BI.isInvalidDate(dt)) {
if (!isInvalidDate(dt)) {
return dt;
}
return new Date();
}
};
// 判断是否是无效的日期
BI.isInvalidDate = function (date) {
return date == "Invalid Date" || date == "NaN";
};
/**
* 科学计数格式
*/
BI._eFormat = function (text, fmt) {
var e = fmt.indexOf("E");
var eleft = fmt.substr(0, e), eright = fmt.substr(e + 1);
if (/^[0\.-]+$/.test(text)) {
text = BI._numberFormat(0.0, eleft) + 'E' + BI._numberFormat(0, eright)
} else {
var isNegative = text < 0;
if (isNegative) {
text = text.substr(1);
}
var elvl = (eleft.split('.')[0] || '').length;
var point = text.indexOf(".");
if (point < 0) {
point = text.length;
}
var i = 0; //第一个不为0的数的位置
text = text.replace('.', '');
for (var len = text.length; i < len; i++) {
var ech = text.charAt(i);
if (ech <= '9' && ech >= '1') {
break;
}
}
var right = point - i - elvl;
var left = text.substr(i, elvl);
var dis = i + elvl - text.length;
if (dis > 0) {
//末位补全0
for (var k = 0; k < dis; k++) {
left += '0';
}
} else {
left += '.' + text.substr(i + elvl);
}
left = left.replace(/^[0]+/, '');
if (right < 0 && eright.indexOf('-') < 0) {
eright += ';-' + eright;
}
text = BI._numberFormat(left, eleft) + 'E' + BI._numberFormat(right, eright);
if (isNegative) {
text = '-' + text;
}
}
return text;
};
})();

179
src/core/base.js

@ -141,7 +141,7 @@ if (!window.BI) {
},
formatEL: function (obj) {
if (obj && obj.el) {
if (obj && !obj.type && obj.el) {
return obj;
}
return {
@ -1076,100 +1076,24 @@ if (!window.BI) {
//encode
encodeBIParam(option.data);
var async = true;
if (BI.isNotNull(option.async)) {
async = option.async;
}
if (BI.isNull(loading)) {
loading = BI.createWidget({
type: "bi.request_loading"
});
}
if (BI.isNull(timeoutToast)) {
timeoutToast = BI.createWidget({
type: "bi.timeout_toast"
});
timeoutToast.setCallback(function (op) {
decodeBIParam(op.data);
BI.ajax(op);
});
}
timeoutToast.addReq(option);
var async = option.async;
option.data = BI.cjkEncodeDO(option.data);
$.ajax({
url: option.url,
type: "POST",
data: option.data,
async: async,
error: function () {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//失败 取消、重新加载
loading.setCallback(function () {
decodeBIParam(option.data);
BI.ajax(option);
});
loading.showError();
},
error: option.error,
complete: function (res, status) {
if (!timeoutToast.hasReq(option)) {
return;
}
timeoutToast.removeReq(option);
//登录超时
if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("fs-login-content") > -1 &&
res.responseText.indexOf("fs-login-input-password-confirm") === -1) {
if (BI.Popovers.isVisible(BI.LoginTimeOut.POPOVER_ID)) {
return;
}
if (BI.isNotNull(BI.Popovers.get(BI.LoginTimeOut.POPOVER_ID))) {
BI.Popovers.open(BI.LoginTimeOut.POPOVER_ID);
return;
}
var loginTimeout = BI.createWidget({
type: "bi.login_timeout"
});
loginTimeout.on(BI.LoginTimeOut.EVENT_LOGIN, function () {
decodeBIParam(option.data);
BI.ajax(option);
BI.Popovers.remove(BI.LoginTimeOut.POPOVER_ID);
});
BI.Popovers.create(BI.LoginTimeOut.POPOVER_ID, loginTimeout, {
width: 600,
height: 400
}).open(BI.LoginTimeOut.POPOVER_ID);
} else if (BI.isNotNull(res.responseText) &&
res.responseText.indexOf("script") > -1 &&
res.responseText.indexOf("Session Timeout...") > -1) {
//登录失效
loading.setCallback(function () {
location.reload();
});
loading.showError();
} else if (status === "success" && BI.isFunction(option.success)) {
option.success(BI.jsonDecode(res.responseText));
}
if (BI.isFunction(option.complete)) {
option.complete(BI.jsonDecode(res.responseText), status);
}
}
});
return function cancel() {
timeoutToast.removeReq(option);
};
function encodeBIParam(data) {
for (var key in data) {
if (_.isObject(data[key])) {
@ -1189,101 +1113,6 @@ if (!window.BI) {
}
}
}
})(),
/**
* 异步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参数
* @param {Function} callback 回调函数
* @param {Function} complete 回调
*/
requestAsync: function (op, cmd, data, callback, complete) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi" || op === "fr_bi_configure") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
return (BI.ajax)({
url: url,
type: 'POST',
data: data,
error: function () {
// BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
success: function (res) {
if (BI.isFunction(callback)) {
callback(res);
}
},
complete: function (res, status) {
if (BI.isFunction(complete)) {
complete(res);
}
}
});
},
/**
* 同步ajax请求
* @param {String} op op参数
* @param {String} cmd cmd参数
* @param {JSON} data ajax请求的参<EFBFBD>?
* @returns {Object} ajax同步请求返回的JSON对象
*/
requestSync: function (op, cmd, data) {
data = data || {};
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
var url = BI.servletURL + '?op=' + op + '&cmd=' + cmd + "&_=" + Math.random();
var result = {};
(BI.ajax)({
url: url,
type: 'POST',
async: false,
data: data,
error: function () {
BI.Msg.toast(BI.i18nText("BI-Ajax_Error"));
},
complete: function (res, status) {
if (status === 'success') {
result = res;
}
}
});
return result;
},
/**
* 请求方法
* @param cmd 命令
* @param data 数据
* @param extend 参数
* @returns {*}
*/
request: function (cmd, data, extend) {
extend = extend || {};
data = data || {};
var op = extend.op;
if (!BI.isKey(op)) {
op = 'fr_bi_dezi';
}
if (op === "fr_bi_dezi") {
data.sessionID = Data.SharingPool.get("sessionID");
}
if (extend.async === true) {
BI.requestAsync(op, cmd, data, extend.complete || extend.success);
} else {
return BI.requestSync(op, cmd, data);
}
}
})()
});
})(jQuery);

5
src/core/controller/controller.broadcast.js

@ -21,7 +21,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
}
this._broadcasts[name].push(fn);
return function () {
self._broadcasts[name].remove(fn);
self.remove(name, fn);
}
},
@ -35,6 +35,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, {
remove: function (name, fn) {
if (fn) {
this._broadcasts[name].remove(fn);
if (this._broadcasts[name].length === 0) {
delete this._broadcasts[name];
}
} else {
delete this._broadcasts[name];
}

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

@ -82,6 +82,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
if (!this._check(name)) {
return this;
}
if (!this.floatContainer[name].isVisible()) {
var container = this.floatContainer[name];
container.element.css("zIndex", this.zindex++);
this.modal && container.element.__hasZIndexMask__(this.zindexMap[name]) && container.element.__releaseZIndexMask__(this.zindexMap[name]);
@ -104,6 +105,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
left: left + "px",
top: top + "px"
});
}
return this;
},
@ -111,8 +113,10 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
if (!this._check(name)) {
return this;
}
if (this.floatContainer[name].isVisible()) {
this.floatContainer[name].invisible();
this.modal && this.floatContainer[name].element.__releaseZIndexMask__(this.zindexMap[name]);
}
return this;
},

5
src/core/controller/controller.resizer.js

@ -41,11 +41,14 @@ BI.ResizeController = BI.inherit(BI.Controller, {
},
add: function (name, resizer) {
var self = this;
if (this.has(name)) {
return this;
}
this.resizerManger[name] = resizer;
return this;
return function () {
self.remove(name);
};
},
get: function (name) {

80
src/core/proto/date.js

@ -1,54 +1,54 @@
// full day names
Date._DN = [BI.i18nText("BI-Sunday"),
BI.i18nText("BI-Monday"),
BI.i18nText("BI-Tuesday"),
BI.i18nText("BI-Wednesday"),
BI.i18nText("BI-Thursday"),
BI.i18nText("BI-Friday"),
BI.i18nText("BI-Saturday"),
BI.i18nText("BI-Sunday")];
Date._DN = [BI.i18nText("BI-Basic_Sunday"),
BI.i18nText("BI-Basic_Monday"),
BI.i18nText("BI-Basic_Tuesday"),
BI.i18nText("BI-Basic_Wednesday"),
BI.i18nText("BI-Basic_Thursday"),
BI.i18nText("BI-Basic_Friday"),
BI.i18nText("BI-Basic_Saturday"),
BI.i18nText("BI-Basic_Sunday")];
// short day names
Date._SDN = ['',
'',
'',
'',
'',
'',
'',
''];
Date._SDN = [BI.i18nText("BI-Day_Ri"),
BI.i18nText("BI-Basic_One"),
BI.i18nText("BI-Basic_Two"),
BI.i18nText("BI-Basic_Three"),
BI.i18nText("BI-Basic_Four"),
BI.i18nText("BI-Basic_Five"),
BI.i18nText("BI-Basic_Six"),
BI.i18nText("BI-Day_Ri")];
// Monday first, etc.
Date._FD = 1;
// full month names
Date._MN = [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''];
BI.i18nText("BI-Basic_January"),
BI.i18nText("BI-Basic_February"),
BI.i18nText("BI-Basic_March"),
BI.i18nText("BI-Basic_April"),
BI.i18nText("BI-Basic_May"),
BI.i18nText("BI-Basic_June"),
BI.i18nText("BI-Basic_July"),
BI.i18nText("BI-Basic_August"),
BI.i18nText("BI-Basic_September"),
BI.i18nText("BI-Basic_October"),
BI.i18nText("BI-Basic_November"),
BI.i18nText("BI-Basic_December")];
// short month names
Date._SMN = ['',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
''];
Date._SMN = [0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11];
Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_2"),

20
src/core/view.js

@ -327,7 +327,7 @@ BI.View = BI.inherit(BI.V, {
}
//采用静默方式读数据,该数据变化不引起data的change事件触发
var success = options.success;
this.read(BI.extend({
this.model.read(BI.extend({
silent: true
}, options, {
success: function (data, model) {
@ -369,22 +369,10 @@ BI.View = BI.inherit(BI.V, {
return this.model.getEditing();
},
read: function (options) {
this.model.read(options)
},
update: function (options) {
this.model.update(options);
},
patch: function (options) {
this.model.patch(options);
},
reading: function (options) {
var self = this;
var name = BI.UUID();
this.read(BI.extend({}, options, {
this.model.read(BI.extend({}, options, {
beforeSend: function () {
var loading = BI.createWidget({
type: 'bi.vertical',
@ -407,7 +395,7 @@ BI.View = BI.inherit(BI.V, {
updating: function (options) {
var self = this;
var name = BI.UUID();
this.update(BI.extend({}, options, {
this.model.update(BI.extend({}, options, {
noset: true,
beforeSend: function () {
var loading = BI.createWidget({
@ -431,7 +419,7 @@ BI.View = BI.inherit(BI.V, {
patching: function (options) {
var self = this;
var name = BI.UUID();
this.patch(BI.extend({}, options, {
this.model.patch(BI.extend({}, options, {
noset: true,
beforeSend: function () {
var loading = BI.createWidget({

13
src/core/widget.js

@ -34,7 +34,8 @@ BI.Widget = BI.inherit(BI.OB, {
mounted: null,
update: null,
update: function () {
},
destroyed: null,
@ -258,7 +259,7 @@ BI.Widget = BI.inherit(BI.OB, {
}
widget._setParent && widget._setParent(this);
widget.on(BI.Events.DESTROY, function () {
delete self._children[name]
BI.remove(self._children, this);
});
return (this._children[name] = widget);
},
@ -287,11 +288,7 @@ BI.Widget = BI.inherit(BI.OB, {
removeWidget: function (nameOrWidget) {
var self = this;
if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, widget) {
if (widget === nameOrWidget) {
delete self._children[name];
}
})
BI.remove(this._children, nameOrWidget);
} else {
delete this._children[nameOrWidget];
}
@ -371,8 +368,8 @@ BI.Widget = BI.inherit(BI.OB, {
isolate: function () {
if (this._parent) {
this._parent.removeWidget(this);
BI.DOM.hang([this]);
}
BI.DOM.hang([this]);
},
empty: function () {

60
src/core/wrapper/layout.js

@ -74,6 +74,7 @@ BI.Layout = BI.inherit(BI.Widget, {
w.on(BI.Events.DESTROY, function () {
BI.each(self._children, function (name, child) {
if (child === w) {
BI.remove(self._children, child);
self.removeItemAt(name | 0);
}
});
@ -220,13 +221,24 @@ BI.Layout = BI.inherit(BI.Widget, {
return w;
},
removeItemAt: function (index) {
if (index < 0 || index > this.options.items.length - 1) {
return;
removeItemAt: function (indexes) {
indexes = BI.isArray(indexes) ? indexes : [indexes];
var deleted = [];
var newItems = [], newChildren = {};
for (var i = 0, len = this.options.items.length; i < len; i++) {
var child = this._children[this._getChildName(i)];
if (indexes.contains(i)) {
child && deleted.push(child);
} else {
newChildren[this._getChildName(newItems.length)] = child;
newItems.push(this.options.items[i]);
}
var child = this._children[this._getChildName(index)];
this._removeItemAt(index);
child.destroy();
}
this.options.items = newItems;
this._children = newChildren;
BI.each(deleted, function (i, c) {
c.destroy();
});
},
updateItemAt: function (index, item) {
@ -235,9 +247,9 @@ BI.Layout = BI.inherit(BI.Widget, {
}
var child = this._children[this._getChildName(index)];
if (child.update) {
child.update(this._getOptions(item));
return true;
var updated;
if (updated = child.update(this._getOptions(item))) {
return updated;
}
var del = this._children[this._getChildName(index)];
delete this._children[this._getChildName(index)];
@ -291,33 +303,39 @@ BI.Layout = BI.inherit(BI.Widget, {
},
getValue: function () {
var self = this, value = [];
var self = this, value = [], child;
BI.each(this.options.items, function (i) {
var v = self._children[self._getChildName(i)].getValue();
if (child = self._children[self._getChildName(i)]) {
var v = child.getValue();
v = BI.isArray(v) ? v : [v];
value = value.concat(v);
}
});
return value;
},
setValue: function (v) {
var self = this;
var self = this, child;
BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setValue(v);
if (child = self._children[self._getChildName(i)]) {
child.setValue(v);
}
})
},
setText: function (v) {
var self = this;
var self = this, child;
BI.each(this.options.items, function (i) {
self._children[self._getChildName(i)].setText(v);
if (child = self._children[self._getChildName(i)]) {
child.setText(v);
}
})
},
update: function (item) {
var o = this.options;
var items = item.items;
var updated = false, i, len;
var items = item.items || [];
var updated, i, len;
for (i = 0, len = Math.min(o.items.length, items.length); i < len; i++) {
if (!this._compare(o.items[i], items[i])) {
updated = this.updateItemAt(i, items[i]) || updated;
@ -327,7 +345,9 @@ BI.Layout = BI.inherit(BI.Widget, {
var deleted = [];
for (i = items.length; i < o.items.length; i++) {
deleted.push(this._children[this._getChildName(i)]);
delete this._children[this._getChildName(i)];
}
o.items.splice(items.length);
BI.each(deleted, function (i, w) {
w.destroy();
})
@ -336,7 +356,6 @@ BI.Layout = BI.inherit(BI.Widget, {
this.addItemAt(i, items[i]);
}
}
this.options.items = items;
return updated;
},
@ -370,6 +389,11 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = [];
},
destroy: function () {
BI.Layout.superclass.destroy.apply(this, arguments);
this.options.items = [];
},
populate: function (items) {
var self = this, o = this.options;
items = items || [];

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

@ -30,7 +30,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
if (!self.hasWidget(item.cardName)) {
var w = BI.createWidget(item);
w.on(BI.Events.DESTROY, function () {
var index = BI.findKey(o.items, function (i, tItem) {
var index = BI.findIndex(o.items, function (i, tItem) {
return tItem.cardName == item.cardName;
});
if (index > -1) {
@ -74,17 +74,23 @@ BI.CardLayout = BI.inherit(BI.Layout, {
return this._children[cardName];
},
deleteCardByName: function (cardName) {
if (!this.isCardExisted(cardName)) {
throw new Error("cardName is not exist");
}
var index = BI.findKey(this.options.items, function (i, item) {
_deleteCardByName: function (cardName) {
delete this._children[cardName];
var index = BI.findIndex(this.options.items, function (i, item) {
return item.cardName == cardName;
});
if (index > -1) {
this.options.items.splice(index, 1);
}
},
deleteCardByName: function (cardName) {
if (!this.isCardExisted(cardName)) {
throw new Error("cardName is not exist");
}
var child = this._children[cardName];
this._deleteCardByName(cardName);
child && child.destroy();
},
@ -117,12 +123,14 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var flag = false;
BI.each(this.options.items, function (i, item) {
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())
}
}
});
},
@ -180,6 +188,22 @@ BI.CardLayout = BI.inherit(BI.Layout, {
}
});
return flag;
},
removeWidget: function (nameOrWidget) {
var removeName;
if (BI.isWidget(nameOrWidget)) {
BI.each(this._children, function (name, child) {
if (child === nameOrWidget) {
removeName = name;
}
})
} else {
removeName = nameOrWidget;
}
if (removeName) {
this._deleteCardByName(removeName);
}
}
});
BI.shortcut('bi.card', BI.CardLayout);

2
src/css/base/single/text.css

@ -6,5 +6,5 @@
overflow-x: hidden;
overflow-y: hidden;
white-space: nowrap;
word-break: break-all;
word-break: break-word;
}

3
src/css/base/table/table.grid.quick.css

@ -1,3 +0,0 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/

4
src/css/widget/finetuningnumbereditor/finetuning.number.editor.css

@ -9,8 +9,10 @@
}
.bi-fine-tuning-number-editor .top-button {
border-left: 1px solid #d4dadd;
border-bottom: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .bottom-button {
border-left: 1px solid #d4dadd;
}
.bi-fine-tuning-number-editor .split-line {
background-color: #d4dadd;
}

8
src/css/widget/responsivetable/responsivetable.css

@ -1,8 +0,0 @@
/****添加计算宽度的--运算符直接需要space****/
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
.bi-responsive-table > div.bottom-left > div > div > table > * > * > td.last-col,
.bi-responsive-table > div.bottom-right > div > div > table > * > * > td.last-col,
.bi-responsive-table > div > div > table > * > * > td.last-col {
min-width: 80px;
}

2
src/less/base/single/text.less

@ -2,5 +2,5 @@
.bi-text{
.overflow-dot();
word-break: break-all;
word-break: break-word;
}

4
src/less/base/table/table.grid.quick.less

@ -1,4 +0,0 @@
@import "../../bibase";
.bi-quick-grid-table {
}

4
src/less/widget/finetuningnumbereditor/finetuning.number.editor.less

@ -5,9 +5,11 @@
.border-radius(2px);
& .top-button {
border-left: 1px solid @border-color-normal;
border-bottom: 1px solid @border-color-normal;
}
& .bottom-button {
border-left: 1px solid @border-color-normal;
}
& .split-line{
background-color: @border-color-normal;
}
}

11
src/less/widget/responsivetable/responsivetable.less

@ -1,11 +0,0 @@
@import "../../bibase";
.bi-responsive-table {
& > div.bottom-left > div > div > table, & > div.bottom-right > div > div > table, > div > div > table {
& > * > * > td {
&.last-col {
min-width: 80px;
}
}
}
}

3
src/widget/date/trigger.date.js

@ -3,7 +3,6 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
hgap: 4,
vgap: 2,
triggerWidth: 30,
watermark: BI.i18nText("BI-Unrestricted"),
yearLength: 4,
yearMonthLength: 7
},
@ -37,7 +36,7 @@ BI.DateTrigger = BI.inherit(BI.Trigger, {
hgap: c.hgap,
vgap: c.vgap,
allowBlank: true,
watermark: c.watermark,
watermark: BI.i18nText("BI-Unrestricted"),
errorText: function () {
if (self.editor.isEditing()) {
return BI.i18nText("BI-Date_Trigger_Error_Text");

4
src/widget/exceltable/exceltable.js

@ -11,7 +11,7 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
return BI.extend(BI.ExcelTable.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-excel-table",
el: {
type: "bi.adaptive_table"
type: "bi.responsive_table"
},
isNeedResize: false,
@ -45,8 +45,6 @@ BI.ExcelTable = BI.inherit(BI.Widget, {
this.table = BI.createWidget(o.el, {
type: "bi.table_view",
element: this,
isNeedResize: o.isNeedResize,
isResizeAdapt: o.isResizeAdapt,
isNeedFreeze: false,

2
src/widget/year/trigger.year.js

@ -10,7 +10,7 @@ BI.YearTrigger = BI.inherit(BI.Trigger, {
hgap: 4,
vgap: 2,
triggerWidth: 25,
errorText: BI.i18nText("BI-Please_Input_Integer"),
errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text")
},

Loading…
Cancel
Save