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;
},
_setEnable: function (b) {
_setEnable: function (enable) {
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) {
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++) {
var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width;
@ -2676,9 +2682,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: datum.width,
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));
},
_populate: function () {
_populate: function (items) {
var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) {
this.container.setWidth(this._width);
this.container.setHeight(this._height);
@ -2839,10 +2849,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop();
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -2851,10 +2872,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
this.restore();
}
this._populate();
this._populate(items);
}
});
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
@ -14753,6 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14761,6 +14782,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size;
@ -14776,9 +14798,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
@ -14802,7 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
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));
},
_populate: function () {
_populate: function (items) {
var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) {
this.columnCount = o.items[0].length;
this.rowCount = o.items.length;
@ -14935,10 +14960,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height;
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -14947,10 +14983,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this.restore();
}
this._populate();
this._populate(items);
}
});
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
@ -28704,7 +28739,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateScrollbar: function () {
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();
BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28745,7 +28781,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () {
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();
BI.each(o.columnSize, function (i, size) {
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.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader);
this.topRightCollection.populate(rightHeader);
this.bottomLeftCollection.populate(leftItems);
this.bottomRightCollection.populate(rightItems);
this.topLeftCollection._populate(leftHeader);
this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection._populate(rightItems);
},
_digest: function () {
@ -28956,8 +28993,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._digest();
}
this._isNeedDigest = false;
this._populateTable();
this._populateScrollbar();
},
@ -29052,6 +29091,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore();
},
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () {
this._restore();
}
@ -29654,16 +29700,20 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.contextLayout.attr("items", items);
this.contextLayout.resize();
this.topLeftGrid.populate(this.header[0]);
this.topRightGrid.populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]);
this.topLeftGrid._populate(this.header[0]);
this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid._populate(this.items[1]);
},
_populate: function () {
if (this._width <= 0 || this._height <= 0) {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable();
this._populateScrollbar();
},
@ -29721,10 +29771,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) {
this.options.columnSize = columnSize;
this._isNeedDigest = true;
},
setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
},
getColumnSize: function () {
@ -29737,11 +29789,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items;
this.items = this._getItems();
this._restore();
}
if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header;
this.header = this._getHeader();
this._restore();
@ -29756,6 +29810,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore();
},
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () {
this._restore();
}
@ -32349,8 +32410,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
};
var stop = function (j, size) {
self.resizer.setVisible(false);
o.columnSize[j] = size;
self.table.setColumnSize(o.columnSize);
var columnSize = o.columnSize.slice();
columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate();
self._populate();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);

2
bi/case.js

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

273
bi/core.js

@ -3042,6 +3042,9 @@ if (!window.BI) {
}
});
})(jQuery);;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -3102,124 +3105,6 @@ if (!window.BI) {
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 {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -3306,7 +3192,7 @@ if (!window.BI) {
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -3567,7 +3453,7 @@ if (!window.BI) {
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -3609,15 +3495,122 @@ if (!window.BI) {
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) {
result = ch + result;
// 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;
}
return result.toString();
};
BI.object2Number = function (value) {
@ -4492,6 +4485,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
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) {
this._setEnable(enable);
if (enable === true) {
@ -4549,6 +4555,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) {
this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) {
this.element.removeClass("base-invalid invalid");
} else if (valid === false) {
@ -5377,7 +5384,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},
@ -6026,7 +6033,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
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 today;
};/*
};
/*
* 给jQuery.Event对象添加的工具方法
*/
$.extend($.Event.prototype, {
@ -16615,9 +16622,7 @@ BI.extend(jQuery, {
* 基本的函数
* Created by GUY on 2015/6/24.
*/
$(function () {
BI.Func = {};
var formulas = {};
BI.extend(BI.Func, {
/**
@ -16637,7 +16642,6 @@ $(function () {
};
}
var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) {
@ -16892,7 +16896,6 @@ $(function () {
}
return this._scrollWidth;
}
});
});/**
* guy
* 检测某个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_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
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, {
_defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
self.adapter.populate();
});
});
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
}
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} 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 () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);/**
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_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",
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号
/**
* 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;
},
_setEnable: function (b) {
_setEnable: function (enable) {
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) {
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++) {
var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width;
@ -2676,9 +2682,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: datum.width,
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));
},
_populate: function () {
_populate: function (items) {
var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) {
this.container.setWidth(this._width);
this.container.setHeight(this._height);
@ -2839,10 +2849,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop();
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -2851,10 +2872,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
this.restore();
}
this._populate();
this._populate(items);
}
});
BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
@ -14753,6 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14761,6 +14782,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size;
@ -14776,9 +14798,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
@ -14802,7 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
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));
},
_populate: function () {
_populate: function (items) {
var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) {
this.columnCount = o.items[0].length;
this.rowCount = o.items.length;
@ -14935,10 +14960,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height;
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -14947,10 +14983,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this.restore();
}
this._populate();
this._populate(items);
}
});
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
@ -28704,7 +28739,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateScrollbar: function () {
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();
BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -28745,7 +28781,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () {
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();
BI.each(o.columnSize, function (i, size) {
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.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader);
this.topRightCollection.populate(rightHeader);
this.bottomLeftCollection.populate(leftItems);
this.bottomRightCollection.populate(rightItems);
this.topLeftCollection._populate(leftHeader);
this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection._populate(rightItems);
},
_digest: function () {
@ -28956,8 +28993,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._digest();
}
this._isNeedDigest = false;
this._populateTable();
this._populateScrollbar();
},
@ -29052,6 +29091,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore();
},
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () {
this._restore();
}
@ -29654,16 +29700,20 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.contextLayout.attr("items", items);
this.contextLayout.resize();
this.topLeftGrid.populate(this.header[0]);
this.topRightGrid.populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]);
this.topLeftGrid._populate(this.header[0]);
this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid._populate(this.items[1]);
},
_populate: function () {
if (this._width <= 0 || this._height <= 0) {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable();
this._populateScrollbar();
},
@ -29721,10 +29771,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) {
this.options.columnSize = columnSize;
this._isNeedDigest = true;
},
setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
},
getColumnSize: function () {
@ -29737,11 +29789,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items;
this.items = this._getItems();
this._restore();
}
if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header;
this.header = this._getHeader();
this._restore();
@ -29756,6 +29810,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore();
},
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () {
this._restore();
}
@ -32349,8 +32410,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
};
var stop = function (j, size) {
self.resizer.setVisible(false);
o.columnSize[j] = size;
self.table.setColumnSize(o.columnSize);
var columnSize = o.columnSize.slice();
columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate();
self._populate();
self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE);

2
docs/case.js

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

273
docs/core.js

@ -14487,6 +14487,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
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) {
this._setEnable(enable);
if (enable === true) {
@ -14544,6 +14557,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) {
this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) {
this.element.removeClass("base-invalid invalid");
} else if (valid === false) {
@ -15372,7 +15386,7 @@ BI.View = BI.inherit(BI.V, {
BI.each(cardNames, function (i, name) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},
@ -19906,6 +19920,9 @@ BI.PopoverSection = BI.inherit(BI.Widget, {
}
});
BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -19966,124 +19983,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
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 {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -20170,7 +20070,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -20431,7 +20331,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -20473,15 +20373,122 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () {
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) {
result = ch + result;
// 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;
}
return result.toString();
};
BI.object2Number = function (value) {
@ -22638,9 +22645,7 @@ BI.extend(jQuery, {
* 基本的函数
* Created by GUY on 2015/6/24.
*/
$(function () {
BI.Func = {};
var formulas = {};
BI.extend(BI.Func, {
/**
@ -22660,7 +22665,6 @@ $(function () {
};
}
var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) {
@ -22915,7 +22919,6 @@ $(function () {
}
return this._scrollWidth;
}
});
});/**
* guy
* 检测某个Widget的EventChange事件然后去show某个card
@ -23528,7 +23531,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"),
BI.i18nText("BI-Quarter_3"),
BI.i18nText("BI-Quarter_4")];
/** Adds the number of days array to the Date object. */
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 today;
};/*
};
/*
* 给jQuery.Event对象添加的工具方法
*/
$.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_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
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, {
_defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
self.adapter.populate();
});
});
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
}
}, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} 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 () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);/**
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_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",
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号
/**
* 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++) {
var datum = childrenToDisplay[i];
var index = BI.deepIndexOf(this.renderedKeys, datum.index);
var child;
if (index > -1) {
if (datum.width !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = datum.width;
@ -171,9 +172,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== datum.y) {
this.renderedCells[index].el.element.css("top", datum.y + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: datum.width,
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));
},
_populate: function () {
_populate: function (items) {
var o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
}
if (o.items.length > 0) {
this.container.setWidth(this._width);
this.container.setHeight(this._height);
@ -334,10 +339,21 @@ BI.CollectionView = BI.inherit(BI.Widget, {
return this._getMaxScrollTop();
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -346,10 +362,9 @@ BI.CollectionView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this._calculateSizeAndPositionData();
this.restore();
}
this._populate();
this._populate(items);
}
});
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 minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
var count = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -131,6 +132,7 @@ BI.GridView = BI.inherit(BI.Widget, {
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = BI.deepIndexOf(this.renderedKeys, key);
var child;
if (index > -1) {
if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size;
@ -146,9 +148,9 @@ BI.GridView = BI.inherit(BI.Widget, {
if (this.renderedCells[index].top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
}
renderedCells.push(this.renderedCells[index]);
renderedCells.push(child = this.renderedCells[index]);
} else {
var child = BI.createWidget(BI.extend({
child = BI.createWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
@ -172,7 +174,7 @@ BI.GridView = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
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));
},
_populate: function () {
_populate: function (items) {
var self = this, o = this.options;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (o.items.length > 0) {
this.columnCount = o.items[0].length;
this.rowCount = o.items.length;
@ -305,10 +310,21 @@ BI.GridView = BI.inherit(BI.Widget, {
this.options.estimatedRowSize = height;
},
//重新计算children
reRange: function () {
this.renderRange = {};
},
_clearChildren: function () {
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
BI.each(this.renderedCells, function (i, cell) {
cell.el.destroy();
cell.el._destroy();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
@ -317,10 +333,9 @@ BI.GridView = BI.inherit(BI.Widget, {
populate: function (items) {
if (items && items !== this.options.items) {
this.options.items = items;
this.restore();
}
this._populate();
this._populate(items);
}
});
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;
},
_setEnable: function (b) {
_setEnable: function (enable) {
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) {
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 () {
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();
BI.each(o.columnSize, function (i, size) {
if (o.isNeedFreeze === true && o.freezeCols.contains(i)) {
@ -216,7 +217,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
_populateTable: function () {
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();
BI.each(o.columnSize, function (i, size) {
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.bottomRightItems, o.items, rightItems);
this.topLeftCollection.populate(leftHeader);
this.topRightCollection.populate(rightHeader);
this.bottomLeftCollection.populate(leftItems);
this.bottomRightCollection.populate(rightItems);
this.topLeftCollection._populate(leftHeader);
this.topRightCollection._populate(rightHeader);
this.bottomLeftCollection._populate(leftItems);
this.bottomRightCollection._populate(rightItems);
},
_digest: function () {
@ -427,8 +429,10 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._digest();
}
this._isNeedDigest = false;
this._populateTable();
this._populateScrollbar();
},
@ -523,6 +527,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
this.bottomRightCollection.restore();
},
_reRange: function () {
this.topLeftCollection.reRange();
this.topRightCollection.reRange();
this.bottomLeftCollection.reRange();
this.bottomRightCollection.reRange();
},
restore: function () {
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.resize();
this.topLeftGrid.populate(this.header[0]);
this.topRightGrid.populate(this.header[1]);
this.bottomLeftGrid.populate(this.items[0]);
this.bottomRightGrid.populate(this.items[1]);
this.topLeftGrid._populate(this.header[0]);
this.topRightGrid._populate(this.header[1]);
this.bottomLeftGrid._populate(this.items[0]);
this.bottomRightGrid._populate(this.items[1]);
},
_populate: function () {
if (this._width <= 0 || this._height <= 0) {
return;
}
if (this._isNeedDigest === true) {
this._reRange();
this._isNeedDigest = false;
}
this._populateTable();
this._populateScrollbar();
},
@ -414,10 +418,12 @@ BI.GridTable = BI.inherit(BI.Widget, {
setColumnSize: function (columnSize) {
this.options.columnSize = columnSize;
this._isNeedDigest = true;
},
setRegionColumnSize: function (regionColumnSize) {
this.options.regionColumnSize = regionColumnSize;
this._isNeedDigest = true;
},
getColumnSize: function () {
@ -430,11 +436,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
populate: function (items, header) {
if (items && this.options.items !== items) {
this._isNeedDigest = true;
this.options.items = items;
this.items = this._getItems();
this._restore();
}
if (header && this.options.header !== header) {
this._isNeedDigest = true;
this.options.header = header;
this.header = this._getHeader();
this._restore();
@ -449,6 +457,13 @@ BI.GridTable = BI.inherit(BI.Widget, {
this.bottomRightGrid.restore();
},
_reRange: function () {
this.topLeftGrid.reRange();
this.topRightGrid.reRange();
this.bottomLeftGrid.reRange();
this.bottomRightGrid.reRange();
},
restore: function () {
this._restore();
}

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

@ -219,8 +219,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, {
};
var stop = function (j, size) {
self.resizer.setVisible(false);
o.columnSize[j] = size;
self.table.setColumnSize(o.columnSize);
var columnSize = o.columnSize.slice();
columnSize[j] = size;
o.columnSize = columnSize;
self.table.setColumnSize(columnSize);
self.table.populate();
self._populate();
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 = [];
}
if (!BI.isNumber(columnSize[0])) {
columnSize = o.minColumnSize;
columnSize = o.minColumnSize.slice();
}
var summaryFreezeColumnSize = 0, summaryColumnSize = 0;
BI.each(columnSize, function (i, size) {

249
src/core/alias.js

@ -1,4 +1,7 @@
;(function () {
if (!window.BI) {
window.BI = {};
}
function isEmpty(value) {
// 判断是否为空值
var result = value === "" || value === null || value === undefined;
@ -59,124 +62,6 @@
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 {
return left + '.' + right;
}
};
}
/**
* 处理小数点右边小数部分
* @param tright 右边内容
@ -263,7 +149,7 @@
if (newnum.length > orilen) {
newnum = newnum.substr(1);
} else {
newnum = BI.leftPad(newnum, orilen, '0');
newnum = String.leftPad(newnum, orilen, '0');
result.leftPlus = false;
}
right = right.replace(/^[0-9]+/, newnum);
@ -524,7 +410,7 @@
return o;
})(jo);
}
};
BI.contentFormat = function (cv, fmt) {
if (isEmpty(cv)) {
@ -566,15 +452,122 @@
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) {
result = ch + result;
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) {

4
src/core/func/function.js

@ -2,9 +2,7 @@
* 基本的函数
* Created by GUY on 2015/6/24.
*/
$(function () {
BI.Func = {};
var formulas = {};
BI.extend(BI.Func, {
/**
@ -24,7 +22,6 @@ $(function () {
};
}
var t, text, py;
keyword = keyword + "";
keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) {
@ -280,4 +277,3 @@ $(function () {
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_4")];
/** Adds the number of days array to the Date object. */
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) {
delete self._cards[name];
});
this._cardLayouts[key] && this._cardLayouts[key].destroy();
this._cardLayouts[key] && this._cardLayouts[key]._destroy();
return this;
},

14
src/core/widget.js

@ -165,6 +165,7 @@ BI.Widget = BI.inherit(BI.OB, {
this._mountChildren && this._mountChildren();
BI.each(this._children, function (i, widget) {
!self.isEnabled() && widget._setEnable(false);
!self.isValid() && widget._setValid(false);
widget._mount && widget._mount();
});
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) {
this._setEnable(enable);
if (enable === true) {
@ -222,6 +235,7 @@ BI.Widget = BI.inherit(BI.OB, {
setValid: function (valid) {
this.options.invalid = !valid;
this._setValid(valid);
if (valid === true) {
this.element.removeClass("base-invalid invalid");
} 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, {
_defaultConfig: function () {
@ -7,33 +7,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -41,74 +38,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -118,13 +133,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -132,16 +144,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -186,7 +219,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -275,22 +308,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -301,7 +333,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});

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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
});
self.adapter.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()};
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -130,29 +96,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
height: 30
}, {
el: div,
height: 2
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -166,8 +148,8 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
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.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_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",
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -18,10 +18,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);
Loading…
Cancel
Save