Browse Source

Merge pull request #47 in FUI/fineui from ~GUY/fineui:master to master

* commit 'e93655a1c1fc9c7d29b398b039ff3d9c106fd261':
  add
  性能优化
  update
  add
  bug
  add
  function
  function
  add
  enable
es6
guy 8 years ago
parent
commit
e02eab60d2
  1. 119
      bi/base.js
  2. 2
      bi/case.js
  3. 273
      bi/core.js
  4. 380
      bi/widget.js
  5. 119
      docs/base.js
  6. 2
      docs/case.js
  7. 273
      docs/core.js
  8. 380
      docs/widget.js
  9. 29
      src/base/collection/collection.js
  10. 29
      src/base/grid/grid.js
  11. 9
      src/base/single/button/button.basic.js
  12. 23
      src/base/table/table.collection.js
  13. 23
      src/base/table/table.grid.js
  14. 6
      src/base/table/table.resizable.js
  15. 2
      src/case/table/table.adaptive.js
  16. 249
      src/core/alias.js
  17. 4
      src/core/func/function.js
  18. 1
      src/core/proto/date.js
  19. 2
      src/core/view.js
  20. 14
      src/core/widget.js
  21. 164
      src/widget/multistringlist/multistringlist.js
  22. 200
      src/widget/multitreelist/multitreelist.js
  23. 16
      src/widget/multitreelist/multitreelist.popup.js

119
bi/base.js

@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text; return this.options.text;
}, },
_setEnable: function (b) { _setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments); BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (!b) { if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) { if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }
@ -2661,6 +2666,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
var datum = childrenToDisplay[i]; var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index); var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) { if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) { if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width; this.renderedCells[index]._width = datum.width;
@ -2676,9 +2682,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) { if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px"); this.renderedCells[index].el.element.css("top", datum.y + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: datum.width, width: datum.width,
height: datum.height height: datum.height
@ -2769,8 +2775,12 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var o = this.options; var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.container.setWidth(this._width); this.container.setWidth(this._width);
this.container.setHeight(this._height); this.container.setHeight(this._height);
@ -2839,10 +2849,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop(); return this._getMaxScrollTop();
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -2851,10 +2872,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items; this.restore();
this._calculateSizeAndPositionData();
} }
this._populate(); this._populate(items);
} }
}); });
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
@ -14753,6 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14761,6 +14782,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key); var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) { if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) { if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size; this.renderedCells[index]._width = columnDatum.size;
@ -14776,9 +14798,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) { if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px"); this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: columnDatum.size, width: columnDatum.size,
height: rowDatum.size height: rowDatum.size
@ -14802,7 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child; renderedWidgets[count++] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -14849,8 +14871,11 @@ BI.GridView = BI.inherit(BI.Widget, {
return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var self = this, o = this.options; var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.columnCount = o.items[0].length; this.columnCount = o.items[0].length;
this.rowCount = o.items.length; this.rowCount = o.items.length;
@ -14935,10 +14960,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height; this.options.estimatedRowSize = height;
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -14947,10 +14983,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items;
this.restore(); this.restore();
} }
this._populate(); this._populate(items);
} }
}); });
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
@ -28704,7 +28739,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateScrollbar: function () { _populateScrollbar: function () {
var o = this.options; var o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28745,7 +28781,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28833,10 +28870,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
run(this.bottomLeftItems, o.items, leftItems); run(this.bottomLeftItems, o.items, leftItems);
run(this.bottomRightItems, o.items, rightItems); run(this.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader); this.topLeftCollection._populate(leftHeader);
this.topRightCollection.populate(rightHeader); this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection.populate(leftItems); this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection.populate(rightItems); this.bottomRightCollection._populate(rightItems);
}, },
_digest: function () { _digest: function () {
@ -28956,8 +28993,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return; return;
} }
if (this._isNeedDigest === true) { if (this._isNeedDigest === true) {
this._reRange();
this._digest(); this._digest();
} }
this._isNeedDigest = false;
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -29052,6 +29091,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore(); this.bottomRightCollection.restore();
}, },
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }
@ -29654,16 +29700,20 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.contextLayout.attr("items", items); this.contextLayout.attr("items", items);
this.contextLayout.resize(); this.contextLayout.resize();
this.topLeftGrid.populate(this.header[0]); this.topLeftGrid._populate(this.header[0]);
this.topRightGrid.populate(this.header[1]); this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]); this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]); this.bottomRightGrid._populate(this.items[1]);
}, },
_populate: function () { _populate: function () {
if (this._width <= 0 || this._height <= 0) { if (this._width <= 0 || this._height <= 0) {
return; return;
} }
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -29721,10 +29771,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) { setColumnSize: function (columnSize) {
this.options.columnSize = columnSize; this.options.columnSize = columnSize;
this._isNeedDigest = true;
}, },
setRegionColumnSize: function (regionColumnSize) { setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize; this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
}, },
getColumnSize: function () { getColumnSize: function () {
@ -29737,11 +29789,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) { populate: function (items, header) {
if (items && this.options.items !== items) { if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items; this.options.items = items;
this.items = this._getItems(); this.items = this._getItems();
this._restore(); this._restore();
} }
if (header && this.options.header !== header) { if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header; this.options.header = header;
this.header = this._getHeader(); this.header = this._getHeader();
this._restore(); this._restore();
@ -29756,6 +29810,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore(); this.bottomRightGrid.restore();
}, },
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }
@ -32349,8 +32410,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
}; };
var stop = function (j, size) { var stop = function (j, size) {
self.resizer.setVisible(false); self.resizer.setVisible(false);
o.columnSize[j] = size; var columnSize = o.columnSize.slice();
self.table.setColumnSize(o.columnSize); columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate(); self.table.populate();
self._populate(); self._populate();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);

2
bi/case.js

@ -8762,7 +8762,7 @@ BI.AdaptiveTable = BI.inherit(BI.Widget, {
freezeCols = []; freezeCols = [];
} }
if (!BI.isNumber(columnSize[0])) { if (!BI.isNumber(columnSize[0])) {
columnSize = o.minColumnSize; columnSize = o.minColumnSize.slice();
} }
var summaryFreezeColumnSize = 0, summaryColumnSize = 0; var summaryFreezeColumnSize = 0, summaryColumnSize = 0;
BI.each(columnSize, function (i, size) { BI.each(columnSize, function (i, size) {

273
bi/core.js

@ -3042,6 +3042,9 @@ if (!window.BI) {
} }
}); });
})(jQuery);;(function () { })(jQuery);;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) { function isEmpty(value) {
// 判断是否为空值 // 判断是否为空值
var result = value === "" || value === null || value === undefined; var result = value === "" || value === null || value === undefined;
@ -3102,124 +3105,6 @@ if (!window.BI) {
return text; return text;
} }
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/** /**
* 数字格式 * 数字格式
*/ */
@ -3262,7 +3147,8 @@ if (!window.BI) {
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; }
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
@ -3306,7 +3192,7 @@ if (!window.BI) {
if (newnum.length > orilen) { if (newnum.length > orilen) {
newnum = newnum.substr(1); newnum = newnum.substr(1);
} else { } else {
newnum = BI.leftPad(newnum, orilen, '0'); newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false; result.leftPlus = false;
} }
right = right.replace(/^[0-9]+/, newnum); right = right.replace(/^[0-9]+/, newnum);
@ -3567,7 +3453,7 @@ if (!window.BI) {
return o; return o;
})(jo); })(jo);
} };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) { if (isEmpty(cv)) {
@ -3609,15 +3495,122 @@ if (!window.BI) {
return text; return text;
}; };
BI.leftPad = function (val, size, ch) { /**
var result = String(val); * 把日期对象按照指定格式转化成字符串
if (!ch) { *
ch = " "; * @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
} }
while (result.length < size) { // O(len(format))
result = ch + 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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
} }
return result.toString();
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {
@ -4492,6 +4485,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false); !self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(); widget._mount && widget._mount();
}); });
this.mounted && this.mounted(); this.mounted && this.mounted();
@ -4525,6 +4519,18 @@ BI.Widget = BI.inherit(BI.OB, {
}); });
}, },
_setValid: function (valid) {
if (valid === true) {
this.options.invalid = false;
} else if (valid === false) {
this.options.invalid = true;
}
//递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { setEnable: function (enable) {
this._setEnable(enable); this._setEnable(enable);
if (enable === true) { if (enable === true) {
@ -4549,6 +4555,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) { setValid: function (valid) {
this.options.invalid = !valid; this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) { if (valid === true) {
this.element.removeClass("base-invalid invalid"); this.element.removeClass("base-invalid invalid");
} else if (valid === false) { } else if (valid === false) {
@ -5377,7 +5384,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) { BI.each(cardNames, function (i, name) {
delete self._cards[name]; delete self._cards[name];
}); });
this._cardLayouts[key] && this._cardLayouts[key].destroy(); this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this; return this;
}, },
@ -6026,7 +6033,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")]; BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */ /** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@ -6500,7 +6506,8 @@ Date.parseDateTime = function (str, fmt) {
return new Date(y, m, d, hr, min, sec); return new Date(y, m, d, hr, min, sec);
} }
return today; return today;
};/* };
/*
* 给jQuery.Event对象添加的工具方法 * 给jQuery.Event对象添加的工具方法
*/ */
$.extend($.Event.prototype, { $.extend($.Event.prototype, {
@ -16615,9 +16622,7 @@ BI.extend(jQuery, {
* 基本的函数 * 基本的函数
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
*/ */
$(function () {
BI.Func = {}; BI.Func = {};
var formulas = {};
BI.extend(BI.Func, { BI.extend(BI.Func, {
/** /**
@ -16637,7 +16642,6 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
@ -16892,7 +16896,6 @@ $(function () {
} }
return this._scrollWidth; return this._scrollWidth;
} }
});
});/** });/**
* guy * guy
* 检测某个Widget的EventChange事件然后去show某个card * 检测某个Widget的EventChange事件然后去show某个card

380
bi/widget.js

@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.adapter = BI.createWidget({
this.popup = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
}, },
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
}); });
}); }
function showCounter() { }, {
if (isSearching()) { eventName: BI.Searcher.EVENT_CHANGE,
self.storeValue = {value: self.trigger.getValue()}; action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.popup.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.trigger.setValue(self.storeValue); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
} }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { eventName: BI.Searcher.EVENT_PAUSE,
if (want2showCounter === false) { action: function () {
want2showCounter = true; self._showAdapter();
}
if (isInit === true) {
want2showCounter = null;
showCounter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init: function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号 //closeMIn:最小值的符号,closeMax:最大值的符号
/** /**
* Created by roy on 15/9/17. * Created by roy on 15/9/17.

119
docs/base.js

@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text; return this.options.text;
}, },
_setEnable: function (b) { _setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments); BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (!b) { if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) { if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }
@ -2661,6 +2666,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
var datum = childrenToDisplay[i]; var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index); var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) { if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) { if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width; this.renderedCells[index]._width = datum.width;
@ -2676,9 +2682,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) { if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px"); this.renderedCells[index].el.element.css("top", datum.y + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: datum.width, width: datum.width,
height: datum.height height: datum.height
@ -2769,8 +2775,12 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var o = this.options; var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.container.setWidth(this._width); this.container.setWidth(this._width);
this.container.setHeight(this._height); this.container.setHeight(this._height);
@ -2839,10 +2849,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop(); return this._getMaxScrollTop();
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -2851,10 +2872,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items; this.restore();
this._calculateSizeAndPositionData();
} }
this._populate(); this._populate(items);
} }
}); });
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
@ -14753,6 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14761,6 +14782,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key); var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) { if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) { if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size; this.renderedCells[index]._width = columnDatum.size;
@ -14776,9 +14798,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) { if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px"); this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: columnDatum.size, width: columnDatum.size,
height: rowDatum.size height: rowDatum.size
@ -14802,7 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child; renderedWidgets[count++] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -14849,8 +14871,11 @@ BI.GridView = BI.inherit(BI.Widget, {
return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var self = this, o = this.options; var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.columnCount = o.items[0].length; this.columnCount = o.items[0].length;
this.rowCount = o.items.length; this.rowCount = o.items.length;
@ -14935,10 +14960,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height; this.options.estimatedRowSize = height;
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -14947,10 +14983,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items;
this.restore(); this.restore();
} }
this._populate(); this._populate(items);
} }
}); });
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
@ -28704,7 +28739,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateScrollbar: function () { _populateScrollbar: function () {
var o = this.options; var o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28745,7 +28781,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28833,10 +28870,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
run(this.bottomLeftItems, o.items, leftItems); run(this.bottomLeftItems, o.items, leftItems);
run(this.bottomRightItems, o.items, rightItems); run(this.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader); this.topLeftCollection._populate(leftHeader);
this.topRightCollection.populate(rightHeader); this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection.populate(leftItems); this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection.populate(rightItems); this.bottomRightCollection._populate(rightItems);
}, },
_digest: function () { _digest: function () {
@ -28956,8 +28993,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return; return;
} }
if (this._isNeedDigest === true) { if (this._isNeedDigest === true) {
this._reRange();
this._digest(); this._digest();
} }
this._isNeedDigest = false;
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -29052,6 +29091,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore(); this.bottomRightCollection.restore();
}, },
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }
@ -29654,16 +29700,20 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.contextLayout.attr("items", items); this.contextLayout.attr("items", items);
this.contextLayout.resize(); this.contextLayout.resize();
this.topLeftGrid.populate(this.header[0]); this.topLeftGrid._populate(this.header[0]);
this.topRightGrid.populate(this.header[1]); this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]); this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]); this.bottomRightGrid._populate(this.items[1]);
}, },
_populate: function () { _populate: function () {
if (this._width <= 0 || this._height <= 0) { if (this._width <= 0 || this._height <= 0) {
return; return;
} }
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -29721,10 +29771,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) { setColumnSize: function (columnSize) {
this.options.columnSize = columnSize; this.options.columnSize = columnSize;
this._isNeedDigest = true;
}, },
setRegionColumnSize: function (regionColumnSize) { setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize; this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
}, },
getColumnSize: function () { getColumnSize: function () {
@ -29737,11 +29789,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) { populate: function (items, header) {
if (items && this.options.items !== items) { if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items; this.options.items = items;
this.items = this._getItems(); this.items = this._getItems();
this._restore(); this._restore();
} }
if (header && this.options.header !== header) { if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header; this.options.header = header;
this.header = this._getHeader(); this.header = this._getHeader();
this._restore(); this._restore();
@ -29756,6 +29810,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore(); this.bottomRightGrid.restore();
}, },
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }
@ -32349,8 +32410,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
}; };
var stop = function (j, size) { var stop = function (j, size) {
self.resizer.setVisible(false); self.resizer.setVisible(false);
o.columnSize[j] = size; var columnSize = o.columnSize.slice();
self.table.setColumnSize(o.columnSize); columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate(); self.table.populate();
self._populate(); self._populate();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);

2
docs/case.js

@ -8762,7 +8762,7 @@ BI.AdaptiveTable = BI.inherit(BI.Widget, {
freezeCols = []; freezeCols = [];
} }
if (!BI.isNumber(columnSize[0])) { if (!BI.isNumber(columnSize[0])) {
columnSize = o.minColumnSize; columnSize = o.minColumnSize.slice();
} }
var summaryFreezeColumnSize = 0, summaryColumnSize = 0; var summaryFreezeColumnSize = 0, summaryColumnSize = 0;
BI.each(columnSize, function (i, size) { BI.each(columnSize, function (i, size) {

273
docs/core.js

@ -14487,6 +14487,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false); !self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(); widget._mount && widget._mount();
}); });
this.mounted && this.mounted(); this.mounted && this.mounted();
@ -14520,6 +14521,18 @@ BI.Widget = BI.inherit(BI.OB, {
}); });
}, },
_setValid: function (valid) {
if (valid === true) {
this.options.invalid = false;
} else if (valid === false) {
this.options.invalid = true;
}
//递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { setEnable: function (enable) {
this._setEnable(enable); this._setEnable(enable);
if (enable === true) { if (enable === true) {
@ -14544,6 +14557,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) { setValid: function (valid) {
this.options.invalid = !valid; this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) { if (valid === true) {
this.element.removeClass("base-invalid invalid"); this.element.removeClass("base-invalid invalid");
} else if (valid === false) { } else if (valid === false) {
@ -15372,7 +15386,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) { BI.each(cardNames, function (i, name) {
delete self._cards[name]; delete self._cards[name];
}); });
this._cardLayouts[key] && this._cardLayouts[key].destroy(); this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this; return this;
}, },
@ -19906,6 +19920,9 @@ BI.PopoverSection = BI.inherit(BI.Widget, {
} }
}); });
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) { function isEmpty(value) {
// 判断是否为空值 // 判断是否为空值
var result = value === "" || value === null || value === undefined; var result = value === "" || value === null || value === undefined;
@ -19966,124 +19983,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return text; return text;
} }
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/** /**
* 数字格式 * 数字格式
*/ */
@ -20126,7 +20025,8 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; }
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
@ -20170,7 +20070,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (newnum.length > orilen) { if (newnum.length > orilen) {
newnum = newnum.substr(1); newnum = newnum.substr(1);
} else { } else {
newnum = BI.leftPad(newnum, orilen, '0'); newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false; result.leftPlus = false;
} }
right = right.replace(/^[0-9]+/, newnum); right = right.replace(/^[0-9]+/, newnum);
@ -20431,7 +20331,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return o; return o;
})(jo); })(jo);
} };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) { if (isEmpty(cv)) {
@ -20473,15 +20373,122 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return text; return text;
}; };
BI.leftPad = function (val, size, ch) { /**
var result = String(val); * 把日期对象按照指定格式转化成字符串
if (!ch) { *
ch = " "; * @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
} }
while (result.length < size) { // O(len(format))
result = ch + 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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
} }
return result.toString();
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {
@ -22638,9 +22645,7 @@ BI.extend(jQuery, {
* 基本的函数 * 基本的函数
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
*/ */
$(function () {
BI.Func = {}; BI.Func = {};
var formulas = {};
BI.extend(BI.Func, { BI.extend(BI.Func, {
/** /**
@ -22660,7 +22665,6 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
@ -22915,7 +22919,6 @@ $(function () {
} }
return this._scrollWidth; return this._scrollWidth;
} }
});
});/** });/**
* guy * guy
* 检测某个Widget的EventChange事件然后去show某个card * 检测某个Widget的EventChange事件然后去show某个card
@ -23528,7 +23531,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")]; BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */ /** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@ -24002,7 +24004,8 @@ Date.parseDateTime = function (str, fmt) {
return new Date(y, m, d, hr, min, sec); return new Date(y, m, d, hr, min, sec);
} }
return today; return today;
};/* };
/*
* 给jQuery.Event对象添加的工具方法 * 给jQuery.Event对象添加的工具方法
*/ */
$.extend($.Event.prototype, { $.extend($.Event.prototype, {

380
docs/widget.js

@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.adapter = BI.createWidget({
this.popup = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
}, },
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
}); });
}); }
function showCounter() { }, {
if (isSearching()) { eventName: BI.Searcher.EVENT_CHANGE,
self.storeValue = {value: self.trigger.getValue()}; action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.popup.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.trigger.setValue(self.storeValue); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
} }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { eventName: BI.Searcher.EVENT_PAUSE,
if (want2showCounter === false) { action: function () {
want2showCounter = true; self._showAdapter();
}
if (isInit === true) {
want2showCounter = null;
showCounter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init: function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号 //closeMIn:最小值的符号,closeMax:最大值的符号
/** /**
* Created by roy on 15/9/17. * Created by roy on 15/9/17.

29
src/base/collection/collection.js

@ -156,6 +156,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
var datum = childrenToDisplay[i]; var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index); var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) { if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) { if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width; this.renderedCells[index]._width = datum.width;
@ -171,9 +172,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) { if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px"); this.renderedCells[index].el.element.css("top", datum.y + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: datum.width, width: datum.width,
height: datum.height height: datum.height
@ -264,8 +265,12 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var o = this.options; var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.container.setWidth(this._width); this.container.setWidth(this._width);
this.container.setHeight(this._height); this.container.setHeight(this._height);
@ -334,10 +339,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop(); return this._getMaxScrollTop();
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -346,10 +362,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items; this.restore();
this._calculateSizeAndPositionData();
} }
this._populate(); this._populate(items);
} }
}); });
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";

29
src/base/grid/grid.js

@ -123,6 +123,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -131,6 +132,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex); var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key); var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) { if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) { if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size; this.renderedCells[index]._width = columnDatum.size;
@ -146,9 +148,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) { if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px"); this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
} }
renderedCells.push(this.renderedCells[index]); renderedCells.push(child = this.renderedCells[index]);
} else { } else {
var child = BI.createWidget(BI.extend({ child = BI.createWidget(BI.extend({
type: "bi.label", type: "bi.label",
width: columnDatum.size, width: columnDatum.size,
height: rowDatum.size height: rowDatum.size
@ -172,7 +174,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child; renderedWidgets[count++] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -219,8 +221,11 @@ BI.GridView = BI.inherit(BI.Widget, {
return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
}, },
_populate: function () { _populate: function (items) {
var self = this, o = this.options; var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) { if (o.items.length > 0) {
this.columnCount = o.items[0].length; this.columnCount = o.items[0].length;
this.rowCount = o.items.length; this.rowCount = o.items.length;
@ -305,10 +310,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height; this.options.estimatedRowSize = height;
}, },
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () { restore: function () {
BI.each(this.renderedCells, function (i, cell) { BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy(); cell.el._destroy();
}); });
this._clearChildren();
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
@ -317,10 +333,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) { populate: function (items) {
if (items && items !== this.options.items) { if (items && items !== this.options.items) {
this.options.items = items;
this.restore(); this.restore();
} }
this._populate(); this._populate(items);
} }
}); });
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";

9
src/base/single/button/button.basic.js

@ -298,9 +298,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
return this.options.text; return this.options.text;
}, },
_setEnable: function (b) { _setEnable: function (enable) {
BI.BasicButton.superclass._setEnable.apply(this, arguments); BI.BasicButton.superclass._setEnable.apply(this, arguments);
if (!b) { if (enable === true) {
this.element.removeClass("base-disabled disabled");
} else if (enable === false) {
this.element.addClass("base-disabled disabled");
}
if (!enable) {
if (this.options.shadow) { if (this.options.shadow) {
this.$mask && this.$mask.setVisible(false); this.$mask && this.$mask.setVisible(false);
} }

23
src/base/table/table.collection.js

@ -175,7 +175,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateScrollbar: function () { _populateScrollbar: function () {
var o = this.options; var o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -216,7 +217,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () { _populateTable: function () {
var self = this, o = this.options; var self = this, o = this.options;
var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0,
summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize;
var freezeColLength = this._getFreezeColLength(); var freezeColLength = this._getFreezeColLength();
BI.each(o.columnSize, function (i, size) { BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -304,10 +306,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
run(this.bottomLeftItems, o.items, leftItems); run(this.bottomLeftItems, o.items, leftItems);
run(this.bottomRightItems, o.items, rightItems); run(this.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader); this.topLeftCollection._populate(leftHeader);
this.topRightCollection.populate(rightHeader); this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection.populate(leftItems); this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection.populate(rightItems); this.bottomRightCollection._populate(rightItems);
}, },
_digest: function () { _digest: function () {
@ -427,8 +429,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return; return;
} }
if (this._isNeedDigest === true) { if (this._isNeedDigest === true) {
this._reRange();
this._digest(); this._digest();
} }
this._isNeedDigest = false;
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -523,6 +527,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore(); this.bottomRightCollection.restore();
}, },
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }

23
src/base/table/table.grid.js

@ -347,16 +347,20 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.contextLayout.attr("items", items); this.contextLayout.attr("items", items);
this.contextLayout.resize(); this.contextLayout.resize();
this.topLeftGrid.populate(this.header[0]); this.topLeftGrid._populate(this.header[0]);
this.topRightGrid.populate(this.header[1]); this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]); this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]); this.bottomRightGrid._populate(this.items[1]);
}, },
_populate: function () { _populate: function () {
if (this._width <= 0 || this._height <= 0) { if (this._width <= 0 || this._height <= 0) {
return; return;
} }
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable(); this._populateTable();
this._populateScrollbar(); this._populateScrollbar();
}, },
@ -414,10 +418,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) { setColumnSize: function (columnSize) {
this.options.columnSize = columnSize; this.options.columnSize = columnSize;
this._isNeedDigest = true;
}, },
setRegionColumnSize: function (regionColumnSize) { setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize; this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
}, },
getColumnSize: function () { getColumnSize: function () {
@ -430,11 +436,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) { populate: function (items, header) {
if (items && this.options.items !== items) { if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items; this.options.items = items;
this.items = this._getItems(); this.items = this._getItems();
this._restore(); this._restore();
} }
if (header && this.options.header !== header) { if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header; this.options.header = header;
this.header = this._getHeader(); this.header = this._getHeader();
this._restore(); this._restore();
@ -449,6 +457,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore(); this.bottomRightGrid.restore();
}, },
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () { restore: function () {
this._restore(); this._restore();
} }

6
src/base/table/table.resizable.js

@ -219,8 +219,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
}; };
var stop = function (j, size) { var stop = function (j, size) {
self.resizer.setVisible(false); self.resizer.setVisible(false);
o.columnSize[j] = size; var columnSize = o.columnSize.slice();
self.table.setColumnSize(o.columnSize); columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate(); self.table.populate();
self._populate(); self._populate();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE); self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);

2
src/case/table/table.adaptive.js

@ -115,7 +115,7 @@ BI.AdaptiveTable = BI.inherit(BI.Widget, {
freezeCols = []; freezeCols = [];
} }
if (!BI.isNumber(columnSize[0])) { if (!BI.isNumber(columnSize[0])) {
columnSize = o.minColumnSize; columnSize = o.minColumnSize.slice();
} }
var summaryFreezeColumnSize = 0, summaryColumnSize = 0; var summaryFreezeColumnSize = 0, summaryColumnSize = 0;
BI.each(columnSize, function (i, size) { BI.each(columnSize, function (i, size) {

249
src/core/alias.js

@ -1,4 +1,7 @@
;(function () { ;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) { function isEmpty(value) {
// 判断是否为空值 // 判断是否为空值
var result = value === "" || value === null || value === undefined; var result = value === "" || value === null || value === undefined;
@ -59,124 +62,6 @@
return text; return text;
} }
/**
* 把日期对象按照指定格式转化成字符串
*
* @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
function date2Str(date, format) {
if (!date) {
return '';
}
// O(len(format))
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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
}
break;
case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
}
};
/** /**
* 数字格式 * 数字格式
*/ */
@ -219,7 +104,8 @@
} else { } else {
return left + '.' + right; return left + '.' + right;
} }
}; }
/** /**
* 处理小数点右边小数部分 * 处理小数点右边小数部分
* @param tright 右边内容 * @param tright 右边内容
@ -263,7 +149,7 @@
if (newnum.length > orilen) { if (newnum.length > orilen) {
newnum = newnum.substr(1); newnum = newnum.substr(1);
} else { } else {
newnum = BI.leftPad(newnum, orilen, '0'); newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false; result.leftPlus = false;
} }
right = right.replace(/^[0-9]+/, newnum); right = right.replace(/^[0-9]+/, newnum);
@ -524,7 +410,7 @@
return o; return o;
})(jo); })(jo);
} };
BI.contentFormat = function (cv, fmt) { BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) { if (isEmpty(cv)) {
@ -566,15 +452,122 @@
return text; return text;
}; };
BI.leftPad = function (val, size, ch) { /**
var result = String(val); * 把日期对象按照指定格式转化成字符串
if (!ch) { *
ch = " "; * @example
* var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800');
* var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12
*
* @class BI.date2Str
* @param date 日期
* @param format 日期格式
* @returns {String}
*/
BI.date2Str = function (date, format) {
if (!date) {
return '';
}
// O(len(format))
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
}, date);
flagch = ch;
start = i;
str = flagch;
} else {
str += ch;
}
}
result += compileJFmt({
'char': flagch,
'str': str,
'len': len - start
}, date);
}
return result;
function compileJFmt(jfmt, date) {
var str = jfmt.str, len = jfmt.len, ch = jfmt['char'];
switch (ch) {
case 'E': //星期
str = Date._DN[date.getDay()];
break;
case 'y': //年
if (len <= 3) {
str = (date.getFullYear() + '').slice(2, 4);
} else {
str = date.getFullYear();
}
break;
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');
}
break;
case 'd': //日
if (len > 1) {
str = String.leftPad(date.getDate() + '', 2, '0');
} else {
str = date.getDate();
} }
while (result.length < size) { break;
result = ch + result; case 'h': //时(12)
var hour = date.getHours() % 12;
if (hour === 0) {
hour = 12;
}
if (len > 1) {
str = String.leftPad(hour + '', 2, '0');
} else {
str = hour;
}
break;
case 'H': //时(24)
if (len > 1) {
str = String.leftPad(date.getHours() + '', 2, '0');
} else {
str = date.getHours();
}
break;
case 'm':
if (len > 1) {
str = String.leftPad(date.getMinutes() + '', 2, '0');
} else {
str = date.getMinutes();
}
break;
case 's':
if (len > 1) {
str = String.leftPad(date.getSeconds() + '', 2, '0');
} else {
str = date.getSeconds();
}
break;
case 'a':
str = date.getHours() < 12 ? 'am' : 'pm';
break;
case 'z':
str = date.getTimezone();
break;
default:
str = jfmt.str;
break;
}
return str;
} }
return result.toString();
}; };
BI.object2Number = function (value) { BI.object2Number = function (value) {

4
src/core/func/function.js

@ -2,9 +2,7 @@
* 基本的函数 * 基本的函数
* Created by GUY on 2015/6/24. * Created by GUY on 2015/6/24.
*/ */
$(function () {
BI.Func = {}; BI.Func = {};
var formulas = {};
BI.extend(BI.Func, { BI.extend(BI.Func, {
/** /**
@ -24,7 +22,6 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
@ -280,4 +277,3 @@ $(function () {
return this._scrollWidth; return this._scrollWidth;
} }
}); });
});

1
src/core/proto/date.js

@ -55,7 +55,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")]; BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */ /** Adds the number of days array to the Date object. */
Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

2
src/core/view.js

@ -168,7 +168,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) { BI.each(cardNames, function (i, name) {
delete self._cards[name]; delete self._cards[name];
}); });
this._cardLayouts[key] && this._cardLayouts[key].destroy(); this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this; return this;
}, },

14
src/core/widget.js

@ -165,6 +165,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren(); this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) { BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false); !self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount(); widget._mount && widget._mount();
}); });
this.mounted && this.mounted(); this.mounted && this.mounted();
@ -198,6 +199,18 @@ BI.Widget = BI.inherit(BI.OB, {
}); });
}, },
_setValid: function (valid) {
if (valid === true) {
this.options.invalid = false;
} else if (valid === false) {
this.options.invalid = true;
}
//递归将所有子组件使有效
BI.each(this._children, function (i, child) {
child._setValid && child._setValid(valid);
});
},
setEnable: function (enable) { setEnable: function (enable) {
this._setEnable(enable); this._setEnable(enable);
if (enable === true) { if (enable === true) {
@ -222,6 +235,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) { setValid: function (valid) {
this.options.invalid = !valid; this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) { if (valid === true) {
this.element.removeClass("base-invalid invalid"); this.element.removeClass("base-invalid invalid");
} else if (valid === false) { } else if (valid === false) {

164
src/widget/multistringlist/multistringlist.js

@ -1,5 +1,5 @@
/** /**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -7,33 +7,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.popup = BI.createWidget({ this.adapter = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -41,74 +38,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -118,13 +133,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -132,16 +144,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
}, },
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -186,7 +219,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -275,22 +308,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -301,7 +333,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });

200
src/widget/multitreelist/multitreelist.js

@ -1,128 +1,94 @@
/** /**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
});
}); });
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
} else {
self.storeValue = {value: self.popup.getValue()};
} }
self.trigger.setValue(self.storeValue); }, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
} }
if (isInit === true) { }, {
want2showCounter = null; eventName: BI.Searcher.EVENT_PAUSE,
showCounter(); action: function () {
self._showAdapter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -130,29 +96,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, { }, {
el: div, el: this.adapter,
height: 2
}, {
el: this.popup,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -166,8 +148,8 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList); BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);

16
src/widget/multitreelist/multitreelist.popup.js

@ -1,15 +1,15 @@
/** /**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init: function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -18,10 +18,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -43,6 +43,6 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup); BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);
Loading…
Cancel
Save