").css({
position: "absolute",
zIndex: BI.zIndex_tip - 2,
top: 0,
left: 0,
right: 0,
bottom: 0,
opacity: 0.5
}).appendTo("body");
$pop = BI.Widget._renderEngine.createElement("
").css({
position: "absolute",
zIndex: BI.zIndex_tip - 1,
top: 0,
left: 0,
right: 0,
bottom: 0
}).appendTo("body");
var close = function () {
messageShow.destroy();
$mask.remove();
};
var controlItems = [];
if (hasCancel === true) {
controlItems.push({
el: {
type: "bi.button",
text: BI.i18nText("BI-Basic_Cancel"),
level: "ignore",
handler: function () {
close();
if (BI.isFunction(callback)) {
callback.apply(null, [false]);
}
}
}
});
}
controlItems.push({
el: {
type: "bi.button",
text: BI.i18nText("BI-Basic_OK"),
handler: function () {
close();
if (BI.isFunction(callback)) {
callback.apply(null, [true]);
}
}
}
});
var conf = {
element: $pop,
type: "bi.center_adapt",
items: [
{
type: "bi.border",
cls: "bi-message-content bi-card",
items: {
north: {
el: {
type: "bi.border",
cls: "bi-message-title bi-background",
items: {
center: {
el: {
type: "bi.label",
text: title || BI.i18nText("BI-Basic_Prompt"),
textAlign: "left",
hgap: 20,
height: 50
}
},
east: {
el: {
type: "bi.icon_button",
cls: "bi-message-close close-font",
// height: 50,
handler: function () {
close();
if (BI.isFunction(callback)) {
callback.apply(null, [false]);
}
}
},
width: 60
}
}
},
height: 50
},
center: {
el: {
type: "bi.text",
cls: "bi-message-text",
tgap: 60,
hgap: 20,
lineHeight: 30,
whiteSpace: "normal",
text: message
}
},
south: {
el: {
type: "bi.absolute",
items: [{
el: {
type: "bi.right_vertical_adapt",
hgap: 5,
items: controlItems
},
top: 0,
left: 20,
right: 20,
bottom: 0
}]
},
height: 60
}
},
width: 400,
height: 300
}
]
};
messageShow = BI.createWidget(conf);
}
};
}();/**
* GridView
*
* Created by GUY on 2016/1/11.
* @class BI.GridView
* @extends BI.Widget
*/
BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
overscanColumnCount: 0,
overscanRowCount: 0,
rowHeightGetter: BI.emptyFn, // number类型或function类型
columnWidthGetter: BI.emptyFn, // number类型或function类型
// estimatedColumnSize: 100, //columnWidthGetter为function时必设
// estimatedRowSize: 30, //rowHeightGetter为function时必设
scrollLeft: 0,
scrollTop: 0,
items: []
});
},
_init: function () {
BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
this._scrollLock = false;
this._debounceRelease = BI.debounce(function () {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI.createWidget({
type: "bi.absolute"
});
this.element.scroll(function () {
if (self._scrollLock === true) {
return;
}
o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender();
self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop
});
});
BI.createWidget({
type: "bi.vertical",
element: this,
scrollable: o.overflowX === true && o.overflowY === true,
scrolly: o.overflowX === false && o.overflowY === true,
scrollx: o.overflowX === true && o.overflowY === false,
items: [this.container]
});
if (o.items.length > 0) {
this._populate();
}
if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
BI.nextTick(function () {
self.element.scrollTop(o.scrollTop);
self.element.scrollLeft(o.scrollLeft);
});
}
},
_getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) {
return {
overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount)
};
},
_calculateChildrenToRender: function () {
var self = this, o = this.options;
var width = o.width, height = o.height, scrollLeft = BI.clamp(o.scrollLeft, 0, this._getMaxScrollLeft()),
scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop()),
overscanColumnCount = o.overscanColumnCount, overscanRowCount = o.overscanRowCount;
if (height > 0 && width > 0) {
var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft);
var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop);
if (BI.isEmpty(visibleColumnIndices) || BI.isEmpty(visibleRowIndices)) {
return;
}
var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft);
var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop);
this._renderedColumnStartIndex = visibleColumnIndices.start;
this._renderedColumnStopIndex = visibleColumnIndices.stop;
this._renderedRowStartIndex = visibleRowIndices.start;
this._renderedRowStopIndex = visibleRowIndices.stop;
var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex);
var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex);
var columnStartIndex = overscanColumnIndices.overscanStartIndex;
var columnStopIndex = overscanColumnIndices.overscanStopIndex;
var rowStartIndex = overscanRowIndices.overscanStartIndex;
var rowStopIndex = overscanRowIndices.overscanStopIndex;
// 算区间size
var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex);
var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex);
var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex);
var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex);
var top = minRowDatum.offset + verticalOffsetAdjustment;
var left = minColumnDatum.offset + horizontalOffsetAdjustment;
var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size;
var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size;
// 如果滚动的区间并没有超出渲染的范围
if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) {
return;
}
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);
for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
var key = rowIndex + "-" + columnIndex;
var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
var index = this.renderedKeys[key] && this.renderedKeys[key][2];
var child;
if (index >= 0) {
if (columnDatum.size !== this.renderedCells[index]._width) {
this.renderedCells[index]._width = columnDatum.size;
this.renderedCells[index].el.setWidth(columnDatum.size);
}
if (rowDatum.size !== this.renderedCells[index]._height) {
this.renderedCells[index]._height = rowDatum.size;
this.renderedCells[index].el.setHeight(rowDatum.size);
}
if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) + "px");
}
if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
}
renderedCells.push(child = this.renderedCells[index]);
} else {
child = BI.createWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size
}, o.items[rowIndex][columnIndex], {
cls: (o.items[rowIndex][columnIndex].cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""),
_rowIndex: rowIndex,
_columnIndex: columnIndex,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment
}));
renderedCells.push({
el: child,
left: columnDatum.offset + horizontalOffsetAdjustment,
top: rowDatum.offset + verticalOffsetAdjustment,
_left: columnDatum.offset + horizontalOffsetAdjustment,
_top: rowDatum.offset + verticalOffsetAdjustment,
_width: columnDatum.size,
_height: rowDatum.size
});
}
minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment);
maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size);
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys[key] = [rowIndex, columnIndex, count];
renderedWidgets[count] = child;
count++;
}
}
// 已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = [];
BI.each(renderedKeys, function (i, key) {
if (self.renderedKeys[i]) {
existSet[i] = key;
} else {
addSet[i] = key;
}
});
BI.each(this.renderedKeys, function (i, key) {
if (existSet[i]) {
return;
}
if (addSet[i]) {
return;
}
deleteArray.push(key[2]);
});
BI.each(deleteArray, function (i, index) {
// 性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
});
var addedItems = [];
BI.each(addSet, function (index, key) {
addedItems.push(renderedCells[key[2]]);
});
this.container.addItems(addedItems);
// 拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
}
},
/**
* 获取真实的可滚动的最大宽度
* 对于grid_view如果没有全部渲染过,this._columnSizeAndPositionManager.getTotalSize获取的宽度是不准确的
* 因此在调用setScrollLeft等函数时会造成没法移动到最右端(预估可移动具体太短)
*/
_getRealMaxScrollLeft: function () {
var o = this.options;
var totalWidth = 0;
BI.count(0, this.columnCount, function (index) {
totalWidth += o.columnWidthGetter(index);
});
return Math.max(0, totalWidth - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0));
},
_getMaxScrollLeft: function () {
return Math.max(0, this._columnSizeAndPositionManager.getTotalSize() - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0));
},
_getMaxScrollTop: function () {
return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
},
_populate: function (items) {
var self = this, o = this.options;
this._reRange();
this.columnCount = 0;
this.rowCount = 0;
if (items && items !== this.options.items) {
this.options.items = items;
}
if (BI.isNumber(o.columnCount)) {
this.columnCount = o.columnCount;
} else if (o.items.length > 0) {
this.columnCount = o.items[0].length;
}
if (BI.isNumber(o.rowCount)) {
this.rowCount = o.rowCount;
} else {
this.rowCount = o.items.length;
}
this.container.setWidth(this.columnCount * o.estimatedColumnSize);
this.container.setHeight(this.rowCount * o.estimatedRowSize);
this._columnSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.columnCount, o.columnWidthGetter, o.estimatedColumnSize);
this._rowSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.rowCount, o.rowHeightGetter, o.estimatedRowSize);
this._calculateChildrenToRender();
// 元素未挂载时不能设置scrollTop
try {
this.element.scrollTop(o.scrollTop);
this.element.scrollLeft(o.scrollLeft);
} catch (e) {
}
},
setScrollLeft: function (scrollLeft) {
if (this.options.scrollLeft === scrollLeft) {
return;
}
this._scrollLock = true;
this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getRealMaxScrollLeft());
this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollLeft(this.options.scrollLeft);
},
setScrollTop: function (scrollTop) {
if (this.options.scrollTop === scrollTop) {
return;
}
this._scrollLock = true;
this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop());
this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollTop(this.options.scrollTop);
},
setColumnCount: function (columnCount) {
this.options.columnCount = columnCount;
},
setRowCount: function (rowCount) {
this.options.rowCount = rowCount;
},
setOverflowX: function (b) {
var self = this;
if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b;
BI.nextTick(function () {
self.element.css({overflowX: b ? "auto" : "hidden"});
});
}
},
setOverflowY: function (b) {
var self = this;
if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b;
BI.nextTick(function () {
self.element.css({overflowY: b ? "auto" : "hidden"});
});
}
},
getScrollLeft: function () {
return this.options.scrollLeft;
},
getScrollTop: function () {
return this.options.scrollTop;
},
getMaxScrollLeft: function () {
return this._getMaxScrollLeft();
},
getMaxScrollTop: function () {
return this._getMaxScrollTop();
},
setEstimatedColumnSize: function (width) {
this.options.estimatedColumnSize = width;
},
setEstimatedRowSize: function (height) {
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();
});
this._clearChildren();
this.renderedCells = [];
this.renderedKeys = [];
this.renderRange = {};
this._scrollLock = false;
},
populate: function (items) {
if (items && items !== this.options.items) {
this.restore();
}
this._populate(items);
}
});
BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut("bi.grid_view", BI.GridView);/**
* Popover弹出层,
* @class BI.Popover
* @extends BI.Widget
*/
BI.Popover = BI.inherit(BI.Widget, {
_constant: {
SIZE: {
SMALL: "small",
NORMAL: "normal",
BIG: "big"
},
HEADER_HEIGHT: 40
},
_defaultConfig: function () {
return BI.extend(BI.Popover.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-popover bi-card",
// width: 600,
// height: 500,
size: "normal", // small, normal, big
header: null,
body: null,
footer: null
});
},
render: function () {
var self = this, o = this.options;
this.startX = 0;
this.startY = 0;
this.tracker = new BI.MouseMoveTracker(function (deltaX, deltaY) {
var size = self._calculateSize();
var W = BI.Widget._renderEngine.createElement("body").width(), H = BI.Widget._renderEngine.createElement("body").height();
self.startX += deltaX;
self.startY += deltaY;
self.element.css({
left: BI.clamp(self.startX, 0, W - size.width) + "px",
top: BI.clamp(self.startY, 0, H - size.height) + "px"
});
// BI-12134 没有什么特别好的方法
BI.Resizers._resize();
}, function () {
self.tracker.releaseMouseMoves();
}, _global);
var items = {
north: {
el: {
type: "bi.htape",
cls: "bi-message-title bi-header-background",
ref: function (_ref) {
self.dragger = _ref;
},
items: [{
type: "bi.absolute",
items: [{
el: BI.isPlainObject(o.header) ? BI.createWidget(o.header, {
extraCls: "bi-font-bold"
}) : {
type: "bi.label",
cls: "bi-font-bold",
height: this._constant.HEADER_HEIGHT,
text: o.header,
textAlign: "left"
},
left: 20,
top: 0,
right: 0,
bottom: 0
}]
}, {
el: {
type: "bi.icon_button",
cls: "bi-message-close close-font",
height: this._constant.HEADER_HEIGHT,
handler: function () {
self.close();
}
},
width: 56
}]
},
height: this._constant.HEADER_HEIGHT
},
center: {
el: {
type: "bi.absolute",
items: [{
el: BI.createWidget(o.body),
left: 20,
top: 10,
right: 20,
bottom: 0
}]
}
}
};
if (o.footer) {
items.south = {
el: {
type: "bi.absolute",
items: [{
el: BI.createWidget(o.footer),
left: 20,
top: 0,
right: 20,
bottom: 0
}]
},
height: 44
};
}
var size = this._calculateSize();
return {
type: "bi.border",
items: items,
width: size.width,
height: size.height
};
},
mounted: function () {
var self = this;
this.dragger.element.mousedown(function (e) {
var pos = self.element.offset();
self.startX = pos.left;
self.startY = pos.top;
self.tracker.captureMouseMoves(e);
});
},
_calculateSize: function () {
var o = this.options;
var size = {};
if (BI.isNotNull(o.size)) {
switch (o.size) {
case this._constant.SIZE.SMALL:
size.width = 450;
size.height = 220;
break;
case this._constant.SIZE.BIG:
size.width = 900;
size.height = 500;
break;
default:
size.width = 550;
size.height = 500;
}
}
return {
width: o.width || size.width,
height: o.height || size.height
};
},
hide: function () {
},
open: function () {
this.show();
this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
},
close: function () {
this.hide();
this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
},
setZindex: function (zindex) {
this.element.css({"z-index": zindex});
},
destroyed: function () {
}
});
BI.shortcut("bi.popover", BI.Popover);
BI.BarPopover = BI.inherit(BI.Popover, {
_defaultConfig: function () {
return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), {
btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))]
});
},
beforeCreate: function () {
var self = this, o = this.options;
o.footer || (o.footer = {
type: "bi.right_vertical_adapt",
lgap: 10,
items: [{
type: "bi.button",
text: this.options.btns[1],
value: 1,
level: "ignore",
handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CANCEL, v);
self.close(v);
}
}, {
type: "bi.button",
text: this.options.btns[0],
warningTitle: o.warningTitle,
value: 0,
handler: function (v) {
self.fireEvent(BI.Popover.EVENT_CONFIRM, v);
self.close(v);
}
}]
});
}
});
BI.shortcut("bi.bar_popover", BI.BarPopover);
BI.Popover.EVENT_CLOSE = "EVENT_CLOSE";
BI.Popover.EVENT_OPEN = "EVENT_OPEN";
BI.Popover.EVENT_CANCEL = "EVENT_CANCEL";
BI.Popover.EVENT_CONFIRM = "EVENT_CONFIRM";
/**
* 下拉框弹出层, zIndex在1000w
* @class BI.PopupView
* @extends BI.Widget
*/
BI.PopupView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-popup-view",
maxWidth: "auto",
minWidth: 100,
// maxHeight: 200,
minHeight: 24,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
vgap: 0,
hgap: 0,
innerVGap: 0,
direction: BI.Direction.Top, // 工具栏的方向
stopEvent: false, // 是否停止mousedown、mouseup事件
stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
logic: {
dynamic: true
},
tool: false, // 自定义工具栏
tabs: [], // 导航栏
buttons: [], // toolbar栏
el: {
type: "bi.button_group",
items: [],
chooseType: 0,
behaviors: {},
layouts: [{
type: "bi.vertical"
}]
}
});
},
_init: function () {
BI.PopupView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var fn = function (e) {
e.stopPropagation();
}, stop = function (e) {
e.stopEvent();
return false;
};
this.element.css({
"z-index": BI.zIndex_popup,
"min-width": o.minWidth + "px",
"max-width": o.maxWidth + "px"
}).bind({click: fn});
this.element.bind("mousewheel", fn);
o.stopPropagation && this.element.bind({mousedown: fn, mouseup: fn, mouseover: fn});
o.stopEvent && this.element.bind({mousedown: stop, mouseup: stop, mouseover: stop});
this.tool = this._createTool();
this.tab = this._createTab();
this.view = this._createView();
this.toolbar = this._createToolBar();
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.PopupView.EVENT_CHANGE);
}
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
scrolly: false,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
vgap: o.vgap,
hgap: o.hgap,
items: BI.LogicFactory.createLogicItemsByDirection(o.direction,
BI.extend({
cls: "list-view-outer bi-card list-view-shadow"
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar)
})))
)
}))));
},
_createView: function () {
var o = this.options;
this.button_group = BI.createWidget(o.el, {type: "bi.button_group", value: o.value});
this.button_group.element.css({"min-height": o.minHeight + "px", "padding-top": o.innerVGap + "px", "padding-bottom": o.innerVGap + "px"});
return this.button_group;
},
_createTool: function () {
var o = this.options;
if (false === o.tool) {
return;
}
return BI.createWidget(o.tool);
},
_createTab: function () {
var o = this.options;
if (o.tabs.length === 0) {
return;
}
return BI.createWidget({
type: "bi.center",
cls: "list-view-tab",
height: 25,
items: o.tabs,
value: o.value
});
},
_createToolBar: function () {
var o = this.options;
if (o.buttons.length === 0) {
return;
}
return BI.createWidget({
type: "bi.center",
cls: "list-view-toolbar bi-high-light bi-split-top",
height: 24,
items: BI.createItems(o.buttons, {
once: false,
shadow: true,
isShadowShowingOnSelected: true
})
});
},
getView: function () {
return this.button_group;
},
populate: function (items) {
this.button_group.populate.apply(this.button_group, arguments);
},
resetWidth: function (w) {
this.options.width = w;
this.element.width(w);
},
resetHeight: function (h) {
var tbHeight = this.toolbar ? (this.toolbar.attr("height") || 24) : 0,
tabHeight = this.tab ? (this.tab.attr("height") || 24) : 0,
toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVGap - 2;
this.view.resetHeight ? this.view.resetHeight(resetHeight) :
this.view.element.css({"max-height": resetHeight + "px"});
},
setValue: function (selectedValues) {
this.tab && this.tab.setValue(selectedValues);
this.button_group.setValue(selectedValues);
},
getValue: function () {
return this.button_group.getValue();
}
});
BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.popup_view", BI.PopupView);/**
* 搜索面板
*
* Created by GUY on 2015/9/28.
* @class BI.SearcherView
* @extends BI.Pane
*/
BI.SearcherView = BI.inherit(BI.Pane, {
_defaultConfig: function () {
var conf = BI.SearcherView.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-searcher-view bi-card",
tipText: BI.i18nText("BI-No_Select"),
chooseType: BI.Selection.Single,
matcher: {// 完全匹配的构造器
type: "bi.button_group",
behaviors: {
redmark: function () {
return true;
}
},
items: [],
layouts: [{
type: "bi.vertical"
}]
},
searcher: {
type: "bi.button_group",
behaviors: {
redmark: function () {
return true;
}
},
items: [],
layouts: [{
type: "bi.vertical"
}]
}
});
},
_init: function () {
BI.SearcherView.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.matcher = BI.createWidget(o.matcher, {
type: "bi.button_group",
chooseType: o.chooseType,
behaviors: {
redmark: function () {
return true;
}
},
layouts: [{
type: "bi.vertical"
}],
value: o.value
});
this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
}
});
this.spliter = BI.createWidget({
type: "bi.vertical",
height: 1,
hgap: 10,
items: [{
type: "bi.layout",
height: 1,
cls: "searcher-view-spliter bi-background"
}]
});
this.searcher = BI.createWidget(o.searcher, {
type: "bi.button_group",
chooseType: o.chooseType,
behaviors: {
redmark: function () {
return true;
}
},
layouts: [{
type: "bi.vertical"
}],
value: o.value
});
this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
if (type === BI.Events.CLICK) {
self.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
}
});
BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.matcher, this.spliter, this.searcher]
});
},
startSearch: function () {
},
stopSearch: function () {
},
setValue: function (v) {
this.matcher.setValue(v);
this.searcher.setValue(v);
},
getValue: function () {
return this.matcher.getValue().concat(this.searcher.getValue());
},
populate: function (searchResult, matchResult, keyword) {
searchResult || (searchResult = []);
matchResult || (matchResult = []);
this.setTipVisible(searchResult.length + matchResult.length === 0);
this.spliter.setVisible(BI.isNotEmptyArray(matchResult) && BI.isNotEmptyArray(searchResult));
this.matcher.populate(matchResult, keyword);
this.searcher.populate(searchResult, keyword);
},
empty: function () {
this.searcher.empty();
this.matcher.empty();
},
hasMatched: function () {
return this.matcher.getAllButtons().length > 0;
}
});
BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.searcher_view", BI.SearcherView);/**
* 表示当前对象
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
* @extends BI.Widget
*/
BI.ListView = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-list-view",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
el: {},
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [BI.extend({
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, o.el)],
element: this
};
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
restore: function () {
this.renderedIndex = -1;
this.container.empty();
this.cache = {};
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate(items);
},
destroyed: function () {
this.restore();
}
});
BI.shortcut("bi.list_view", BI.ListView);
/**
* 表示当前对象
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
*/
BI.VirtualList = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-virtual-list",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}],
element: this
};
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
var height = this.element.height();
var minContentHeightFrom = o.scrollTop - o.overscanHeight;
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var needDestroyed = [];
for (var i = 0; i < start; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
for (var i = end + 1; i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
var firstFragment = BI.Widget._renderEngine.createFragment(), lastFragment = BI.Widget._renderEngine.createFragment();
var currentFragment = firstFragment;
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
currentFragment = lastFragment;
}
if (this.cache[i].destroyed === true) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])));
currentFragment.appendChild(w.element[0]);
}
this.cache[i].destroyed = false;
}
}
this.container.element.prepend(firstFragment);
this.container.element.append(lastFragment);
this.topBlank.setHeight(this.cache[start < 0 ? 0 : start].scrollTop);
var lastCache = this.cache[Math.min(end, this.renderedIndex)];
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - lastCache.scrollTop - lastCache.height);
BI.each(needDestroyed, function (i, child) {
child && child._destroy();
});
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
_clearChildren: function () {
BI.each(this.container._children, function (i, cell) {
cell && cell.el._destroy();
});
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
this.renderedIndex = -1;
this._clearChildren();
this.cache = {};
this.options.scrollTop = 0;
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut("bi.virtual_list", BI.VirtualList);
/**
* 分页控件
*
* Created by GUY on 2015/8/31.
* @class BI.Pager
* @extends BI.Widget
*/
BI.Pager = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.Pager.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-pager",
behaviors: {},
layouts: [{
type: "bi.horizontal",
hgap: 10,
vgap: 0
}],
dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
// dynamicShow为false时以下两个有用
dynamicShowFirstLast: false, // 是否动态显示首页、尾页
dynamicShowPrevNext: false, // 是否动态显示上一页、下一页
pages: false, // 总页数
curr: function () {
return 1;
}, // 初始化当前页
groups: 0, // 连续显示分页数
jump: BI.emptyFn, // 分页的回调函数
first: false, // 是否显示首页
last: false, // 是否显示尾页
prev: "上一页",
next: "下一页",
firstPage: 1,
lastPage: function () { // 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法
return 1;
},
hasPrev: BI.emptyFn, // pages不可用时有效
hasNext: BI.emptyFn // pages不可用时有效
});
},
_init: function () {
BI.Pager.superclass._init.apply(this, arguments);
var self = this;
this.currPage = BI.result(this.options, "curr");
// 翻页太灵敏
// this._lock = false;
// this._debouce = BI.debounce(function () {
// self._lock = false;
// }, 300);
this._populate();
},
_populate: function () {
var self = this, o = this.options, view = [], dict = {};
this.empty();
var pages = BI.result(o, "pages");
var curr = BI.result(this, "currPage");
var groups = BI.result(o, "groups");
var first = BI.result(o, "first");
var last = BI.result(o, "last");
var prev = BI.result(o, "prev");
var next = BI.result(o, "next");
if (pages === false) {
groups = 0;
first = false;
last = false;
} else {
groups > pages && (groups = pages);
}
// 计算当前组
dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups));
// 当前页非首页,则输出上一页
if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) {
if (BI.isKey(prev)) {
view.push({
text: prev,
value: "prev",
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
});
} else {
view.push(BI.extend({
disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
}, prev));
}
}
// 当前组非首组,则输出首页
if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) {
view.push({
text: first,
value: "first",
disabled: !(dict.index > 1 && groups !== 0)
});
if (dict.index > 1 && groups !== 0) {
view.push({
type: "bi.label",
cls: "page-ellipsis",
text: "\u2026"
});
}
}
// 输出当前页组
dict.poor = Math.floor((groups - 1) / 2);
dict.start = dict.index > 1 ? curr - dict.poor : 1;
dict.end = dict.index > 1 ? (function () {
var max = curr + (groups - dict.poor - 1);
return max > pages ? pages : max;
}()) : groups;
if (dict.end - dict.start < groups - 1) { // 最后一组状态
dict.start = dict.end - groups + 1;
}
var s = dict.start, e = dict.end;
if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) {
s++;
e--;
}
for (; s <= e; s++) {
if (s === curr) {
view.push({
text: s,
value: s,
selected: true
});
} else {
view.push({
text: s,
value: s
});
}
}
// 总页数大于连续分页数,且当前组最大页小于总页,输出尾页
if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) {
if (pages > groups && dict.end < pages && groups !== 0) {
view.push({
type: "bi.label",
cls: "page-ellipsis",
text: "\u2026"
});
}
view.push({
text: last,
value: "last",
disabled: !(pages > groups && dict.end < pages && groups !== 0)
});
}
// 当前页不为尾页时,输出下一页
dict.flow = !prev && groups === 0;
if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) {
view.push((function () {
if (BI.isKey(next)) {
if (pages === false) {
return {text: next, value: "next", disabled: o.hasNext(curr) === false};
}
return (dict.flow && curr === pages)
?
{text: next, value: "next", disabled: true}
:
{text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)};
}
return BI.extend({
disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow)
}, next);
}()));
}
this.button_group = BI.createWidget({
type: "bi.button_group",
element: this,
items: BI.createItems(view, {
cls: "bi-list-item-select",
height: 23,
hgap: 10
}),
behaviors: o.behaviors,
layouts: o.layouts
});
this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
// if (self._lock === true) {
// return;
// }
// self._lock = true;
// self._debouce();
if (type === BI.Events.CLICK) {
var v = self.button_group.getValue()[0];
switch (v) {
case "first":
self.currPage = 1;
break;
case "last":
self.currPage = pages;
break;
case "prev":
self.currPage--;
break;
case "next":
self.currPage++;
break;
default:
self.currPage = v;
break;
}
o.jump.apply(self, [{
pages: pages,
curr: self.currPage
}]);
self._populate();
self.fireEvent(BI.Pager.EVENT_CHANGE, obj);
}
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.fireEvent(BI.Pager.EVENT_AFTER_POPULATE);
},
getCurrentPage: function () {
return this.currPage;
},
setAllPages: function (pages) {
this.options.pages = pages;
},
hasPrev: function (v) {
v || (v = 1);
var o = this.options;
var pages = this.options.pages;
return pages === false ? o.hasPrev(v) : v > 1;
},
hasNext: function (v) {
v || (v = 1);
var o = this.options;
var pages = this.options.pages;
return pages === false ? o.hasNext(v) : v < pages;
},
setValue: function (v) {
var o = this.options;
v = v | 0;
v = v < 1 ? 1 : v;
if (o.pages === false) {
var lastPage = BI.result(o, "lastPage"), firstPage = 1;
this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v));
} else {
v = v > o.pages ? o.pages : v;
this.currPage = v;
}
this._populate();
},
getValue: function () {
var val = this.button_group.getValue()[0];
switch (val) {
case "prev":
return -1;
case "next":
return 1;
case "first":
return BI.MIN;
case "last":
return BI.MAX;
default :
return val;
}
},
attr: function (key, value) {
BI.Pager.superclass.attr.apply(this, arguments);
if (key === "curr") {
this.currPage = BI.result(this.options, "curr");
}
},
populate: function () {
this._populate();
}
});
BI.Pager.EVENT_CHANGE = "EVENT_CHANGE";
BI.Pager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE";
BI.shortcut("bi.pager", BI.Pager);/**
* 超链接
*
* Created by GUY on 2015/9/9.
* @class BI.A
* @extends BI.Text
* @abstract
*/
BI.A = BI.inherit(BI.Text, {
_defaultConfig: function () {
var conf = BI.A.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-a display-block",
href: "",
target: "_blank",
el: null,
tagName: "a"
});
},
_init: function () {
var o = this.options;
BI.A.superclass._init.apply(this, arguments);
this.element.attr({href: o.href, target: o.target});
if (o.el) {
BI.createWidget(o.el, {
element: this
});
}
}
});
BI.shortcut("bi.a", BI.A);/**
* guy
* 加载条
* @type {*|void|Object}
*/
BI.LoadingBar = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.LoadingBar.superclass._defaultConfig.apply(this, arguments);
return BI.extend( conf, {
baseCls: (conf.baseCls || "") + " bi-loading-bar bi-tips",
height: 30,
handler: BI.emptyFn
});
},
_init: function () {
BI.LoadingBar.superclass._init.apply(this, arguments);
var self = this;
this.loaded = BI.createWidget({
type: "bi.text_button",
cls: "loading-text bi-list-item-simple",
text: BI.i18nText("BI-Load_More"),
width: 120,
handler: this.options.handler
});
this.loaded.on(BI.Controller.EVENT_CHANGE, function (type) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.loading = BI.createWidget({
type: "bi.layout",
width: this.options.height,
height: this.options.height,
cls: "loading-background cursor-default"
});
var loaded = BI.createWidget({
type: "bi.center_adapt",
items: [this.loaded]
});
var loading = BI.createWidget({
type: "bi.center_adapt",
items: [this.loading]
});
this.cardLayout = BI.createWidget({
type: "bi.card",
element: this,
items: [{
el: loaded,
cardName: "loaded"
}, {
el: loading,
cardName: "loading"
}]
});
this.invisible();
},
_reset: function () {
this.visible();
this.loaded.setText(BI.i18nText("BI-Load_More"));
this.loaded.enable();
},
setLoaded: function () {
this._reset();
this.cardLayout.showCardByName("loaded");
},
setEnd: function () {
this.setLoaded();
this.loaded.setText(BI.i18nText("BI-No_More_Data"));
this.loaded.disable();
},
setLoading: function () {
this._reset();
this.cardLayout.showCardByName("loading");
}
});
BI.shortcut("bi.loading_bar", BI.LoadingBar);/**
* @class BI.IconButton
* @extends BI.BasicButton
* 图标的button
*/
BI.IconButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.IconButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-button horizon-center",
iconWidth: null,
iconHeight: null
});
},
_init: function () {
BI.IconButton.superclass._init.apply(this, arguments);
var o = this.options;
this.element.css({
textAlign: "center"
});
this.icon = BI.createWidget({
type: "bi.icon",
width: o.iconWidth,
height: o.iconHeight
});
if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
this.element.css("lineHeight", o.height + "px");
BI.createWidget({
type: "bi.default",
element: this,
items: [this.icon]
});
} else {
this.element.css("lineHeight", "1");
BI.createWidget({
element: this,
type: "bi.center_adapt",
items: [this.icon]
});
}
},
doClick: function () {
BI.IconButton.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconButton.EVENT_CHANGE, this);
}
}
});
BI.IconButton.EVENT_CHANGE = "IconButton.EVENT_CHANGE";
BI.shortcut("bi.icon_button", BI.IconButton);/**
* 图片的button
*
* Created by GUY on 2016/1/27.
* @class BI.ImageButton
* @extends BI.BasicButton
*/
BI.ImageButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.ImageButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-image-button",
src: "",
iconWidth: "100%",
iconHeight: "100%"
});
},
_init: function () {
BI.ImageButton.superclass._init.apply(this, arguments);
var o = this.options;
this.image = BI.createWidget({
type: "bi.img",
width: o.iconWidth,
height: o.iconHeight,
src: o.src
});
if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) {
BI.createWidget({
type: "bi.center_adapt",
element: this,
items: [this.image]
});
} else {
BI.createWidget({
type: "bi.adaptive",
element: this,
items: [this.image],
scrollable: false
});
}
},
setWidth: function (w) {
BI.ImageButton.superclass.setWidth.apply(this, arguments);
this.options.width = w;
},
setHeight: function (h) {
BI.ImageButton.superclass.setHeight.apply(this, arguments);
this.options.height = h;
},
setImageWidth: function (w) {
this.image.setWidth(w);
},
setImageHeight: function (h) {
this.image.setHeight(h);
},
getImageWidth: function () {
return this.image.element.width();
},
getImageHeight: function () {
return this.image.element.height();
},
setSrc: function (src) {
this.options.src = src;
this.image.setSrc(src);
},
getSrc: function () {
return this.image.getSrc();
},
doClick: function () {
BI.ImageButton.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.ImageButton.EVENT_CHANGE, this);
}
}
});
BI.ImageButton.EVENT_CHANGE = "ImageButton.EVENT_CHANGE";
BI.shortcut("bi.image_button", BI.ImageButton);
/**
* 文字类型的按钮
* @class BI.Button
* @extends BI.BasicButton
*
* @cfg {JSON} options 配置属性
* @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型,用不同颜色强调不同的场景
*/
BI.Button = BI.inherit(BI.BasicButton, {
_defaultConfig: function (props) {
var conf = BI.Button.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-button",
minWidth: (props.block === true || props.clear === true) ? 0 : 80,
height: 24,
shadow: props.clear !== true,
isShadowShowingOnSelected: true,
readonly: true,
iconCls: "",
level: "common",
block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制
clear: false, // 是否去掉边框和背景
ghost: false, // 是否幽灵显示, 即正常状态无背景
textAlign: "center",
whiteSpace: "nowrap",
forceCenter: false,
textWidth: null,
textHeight: null,
hgap: props.clear ? 0 : 10,
vgap: 0,
tgap: 0,
bgap: 0,
lgap: 0,
rgap: 0
});
},
_init: function () {
BI.Button.superclass._init.apply(this, arguments);
var o = this.options, self = this;
if (BI.isNumber(o.height) && !o.clear && !o.block) {
this.element.css({height: o.height + "px", lineHeight: (o.height - 2) + "px"});
} else if (o.clear || o.block) {
this.element.css({lineHeight: o.height + "px"});
} else {
this.element.css({lineHeight: (o.height - 2) + "px"});
}
if (BI.isKey(o.iconCls)) {
this.icon = BI.createWidget({
type: "bi.icon",
width: 18,
height: o.height - 2
});
this.text = BI.createWidget({
type: "bi.label",
text: o.text,
value: o.value,
height: o.height - 2
});
BI.createWidget({
type: "bi.horizontal_auto",
cls: o.iconCls,
element: this,
hgap: o.hgap,
vgap: o.vgap,
tgap: o.tgap,
bgap: o.bgap,
lgap: o.lgap,
rgap: o.rgap,
items: [{
type: "bi.horizontal",
items: [this.icon, this.text]
}]
});
} else {
this.text = BI.createWidget({
type: "bi.label",
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
forceCenter: o.forceCenter,
textWidth: o.textWidth,
textHeight: o.textHeight,
hgap: o.hgap,
vgap: o.vgap,
tgap: o.tgap,
bgap: o.bgap,
lgap: o.lgap,
rgap: o.rgap,
element: this,
text: o.text,
value: o.value
});
}
if (o.block === true) {
this.element.addClass("block");
}
if (o.clear === true) {
this.element.addClass("clear");
}
if (o.ghost === true) {
this.element.addClass("ghost");
}
if (o.minWidth > 0) {
this.element.css({"min-width": o.minWidth + "px"});
}
},
doClick: function () {
BI.Button.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.Button.EVENT_CHANGE, this);
}
},
setText: function (text) {
BI.Button.superclass.setText.apply(this, arguments);
this.text.setText(text);
},
setValue: function (text) {
BI.Button.superclass.setValue.apply(this, arguments);
if (!this.isReadOnly()) {
this.text.setValue(text);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
destroy: function () {
BI.Button.superclass.destroy.apply(this, arguments);
}
});
BI.shortcut("bi.button", BI.Button);
BI.Button.EVENT_CHANGE = "EVENT_CHANGE";
/**
* guy
* 可以点击的一行文字
* @class BI.TextButton
* @extends BI.BasicButton
* 文字button
*/
BI.TextButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.TextButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-button",
textAlign: "center",
whiteSpace: "nowrap",
forceCenter: false,
textWidth: null,
textHeight: null,
hgap: 0,
lgap: 0,
rgap: 0,
text: "",
py: ""
});
},
_init: function () {
BI.TextButton.superclass._init.apply(this, arguments);
var o = this.options;
this.text = BI.createWidget({
type: "bi.label",
element: this,
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
textWidth: o.textWidth,
textHeight: o.textHeight,
forceCenter: o.forceCenter,
width: o.width,
height: o.height,
hgap: o.hgap,
lgap: o.lgap,
rgap: o.rgap,
text: o.text,
value: o.value,
py: o.py,
keyword: o.keyword
});
},
doClick: function () {
BI.TextButton.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.TextButton.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
setText: function (text) {
BI.TextButton.superclass.setText.apply(this, arguments);
text = BI.isArray(text) ? text.join(",") : text;
this.text.setText(text);
},
setStyle: function (style) {
this.text.setStyle(style);
},
setValue: function (text) {
BI.TextButton.superclass.setValue.apply(this, arguments);
if (!this.isReadOnly()) {
text = BI.isArray(text) ? text.join(",") : text;
this.text.setValue(text);
}
}
});
BI.TextButton.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_button", BI.TextButton);/**
* 带有一个占位
*
* Created by GUY on 2015/9/11.
* @class BI.BlankIconIconTextItem
* @extends BI.BasicButton
*/
BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.BlankIconIconTextItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item",
logic: {
dynamic: false
},
iconCls1: "close-ha-font",
iconCls2: "close-ha-font",
blankWidth: 0,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.BlankIconIconTextItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
var blank = BI.createWidget({
type: "bi.layout",
width: o.blankWidth,
height: o.height
});
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon1 = BI.createWidget({
type: "bi.icon_button",
cls: o.iconCls1,
forceNotSelected: true,
width: o.height,
height: o.height
});
this.icon2 = BI.createWidget({
type: "bi.icon_button",
cls: o.iconCls2,
forceNotSelected: true,
width: o.height,
height: o.height
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon1, this.icon2, this.text)
}))));
},
doClick: function () {
BI.BlankIconIconTextItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.BlankIconIconTextItem.EVENT_CHANGE, this.getValue(), this);
}
},
setSelected: function (b) {
BI.BlankIconIconTextItem.superclass.setSelected.apply(this, arguments);
this.icon1.setSelected(b);
this.icon2.setSelected(b);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
}
});
BI.BlankIconIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_icon_text_item", BI.BlankIconIconTextItem);/**
* guy
* 一个占位符和两个icon和一行数 组成的一行listitem
*
* Created by GUY on 2015/9/15.
* @class BI.BlankIconTextIconItem
* @extends BI.BasicButton
*/
BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.BlankIconTextIconItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item",
logic: {
dynamic: false
},
iconCls1: "close-ha-font",
iconCls2: "close-ha-font",
blankWidth: 0,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.BlankIconTextIconItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
var icon1 = BI.createWidget({
type: "bi.icon_label",
cls: o.iconCls1,
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.icon_label",
cls: o.iconCls2,
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
},
top: 0,
bottom: 0,
right: 0
}]
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", {
type: "bi.layout",
width: o.blankWidth
}, icon1, this.text, {
type: "bi.layout",
width: o.height
})
}))));
},
doClick: function () {
BI.BlankIconTextIconItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
}
});
BI.BlankIconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_text_icon_item", BI.BlankIconTextIconItem);/**
* 带有一个占位
*
* Created by GUY on 2015/9/11.
* @class BI.BlankIconTextItem
* @extends BI.BasicButton
*/
BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.BlankIconTextItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item",
logic: {
dynamic: false
},
cls: "close-ha-font",
blankWidth: 0,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.BlankIconTextItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
var blank = BI.createWidget({
type: "bi.layout",
width: o.blankWidth
});
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon = BI.createWidget({
type: "bi.icon_label",
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon, this.text)
}))));
},
doClick: function () {
BI.BlankIconTextItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.BlankIconTextItem.EVENT_CHANGE, this.getValue(), this);
}
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
}
});
BI.BlankIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.blank_icon_text_item", BI.BlankIconTextItem);/**
* guy
* 两个icon和一行数 组成的一行listitem
*
* Created by GUY on 2015/9/9.
* @class BI.IconTextIconItem
* @extends BI.BasicButton
*/
BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.IconTextIconItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item",
logic: {
dynamic: false
},
iconCls1: "close-ha-font",
iconCls2: "close-ha-font",
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.IconTextIconItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
var icon1 = BI.createWidget({
type: "bi.icon_label",
cls: o.iconCls1,
width: o.leftIconWrapperWidth,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
var blank = BI.createWidget({
type: "bi.layout",
width: o.height
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.icon_label",
cls: o.iconCls2,
width: o.rightIconWrapperWidth,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
},
top: 0,
bottom: 0,
right: 0
}]
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank)
}))));
},
doClick: function () {
BI.IconTextIconItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconTextIconItem.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
}
});
BI.IconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_icon_item", BI.IconTextIconItem);/**
* guy
*
* Created by GUY on 2015/9/9.
* @class BI.IconTextItem
* @extends BI.BasicButton
*/
BI.IconTextItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.IconTextItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-item",
direction: BI.Direction.Left,
logic: {
dynamic: false
},
iconWrapperWidth: null,
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.IconTextItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon = BI.createWidget({
type: "bi.icon_label",
width: o.iconWrapperWidth || o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.icon, this.text)
}))));
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doClick: function () {
BI.IconTextItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
}
});
BI.IconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_item", BI.IconTextItem);/**
*
* 图标的button
*
* Created by GUY on 2015/9/9.
* @class BI.TextIconItem
* @extends BI.BasicButton
*/
BI.TextIconItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.TextIconItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-item",
logic: {
dynamic: false
},
cls: "close-ha-font",
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.TextIconItem.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon = BI.createWidget({
type: "bi.icon_label",
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon)
}))));
},
doClick: function () {
BI.TextIconItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.TextIconItem.EVENT_CHANGE, this.getValue(), this);
}
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
}
});
BI.TextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_icon_item", BI.TextIconItem);/**
* guy
* 一个button和一行数 组成的一行listitem
*
* Created by GUY on 2015/9/9.
* @class BI.TextItem
* @extends BI.BasicButton
*/
BI.TextItem = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
var conf = BI.TextItem.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-item",
textAlign: "left",
whiteSpace: "nowrap",
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.TextItem.superclass._init.apply(this, arguments);
var o = this.options;
this.text = BI.createWidget({
type: "bi.label",
element: this,
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight,
height: o.height,
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
py: o.py
});
},
doClick: function () {
BI.TextItem.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.TextItem.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
doHighLight: function () {
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
}
});
BI.TextItem.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_item", BI.TextItem);/**
* guy
* Created by GUY on 2015/9/9.
* @class BI.IconTextIconNode
* @extends BI.NodeButton
*/
BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node",
logic: {
dynamic: false
},
iconCls1: "close-ha-font",
iconCls2: "close-ha-font",
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.IconTextIconNode.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
var icon1 = BI.createWidget({
type: "bi.icon_label",
cls: o.iconCls1,
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
var blank = BI.createWidget({
type: "bi.layout",
width: o.height,
height: o.height
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.icon_label",
cls: o.iconCls2,
width: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
},
top: 0,
bottom: 0,
right: 0
}]
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank)
}))));
},
doClick: function () {
BI.IconTextIconNode.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconTextIconNode.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
}
});
BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode);/**
* guy
* Created by GUY on 2015/9/9.
* @class BI.IconTextNode
* @extends BI.NodeButton
*/
BI.IconTextNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-icon-text-node",
logic: {
dynamic: false
},
cls: "close-ha-font",
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.IconTextNode.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon = BI.createWidget({
type: "bi.icon_label",
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon, this.text)
}))));
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doClick: function () {
BI.IconTextNode.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
}
});
BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.icon_text_node", BI.IconTextNode);/**
* Created by GUY on 2015/9/9.
* @class BI.TextIconNode
* @extends BI.NodeButton
*/
BI.TextIconNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-icon-node",
logic: {
dynamic: false
},
cls: "close-ha-font",
iconHeight: null,
iconWidth: null,
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.TextIconNode.superclass._init.apply(this, arguments);
var o = this.options, c = this._const;
this.text = BI.createWidget({
type: "bi.label",
cls: "list-item-text",
textAlign: "left",
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
height: o.height
});
this.icon = BI.createWidget({
type: "bi.icon_label",
width: o.height,
height: o.height,
iconWidth: o.iconWidth,
iconHeight: o.iconHeight
});
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon)
}))));
},
doClick: function () {
BI.TextIconNode.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.TextIconNode.EVENT_CHANGE, this.getValue(), this);
}
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
}
});
BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_icon_node", BI.TextIconNode);/**
* guy
*
* Created by GUY on 2015/9/9.
* @class BI.TextNode
* @extends BI.NodeButton
*/
BI.TextNode = BI.inherit(BI.NodeButton, {
_defaultConfig: function () {
var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-node",
textAlign: "left",
whiteSpace: "nowrap",
textHgap: 0,
textVgap: 0,
textLgap: 0,
textRgap: 0
});
},
_init: function () {
BI.TextNode.superclass._init.apply(this, arguments);
var o = this.options;
this.text = BI.createWidget({
type: "bi.label",
element: this,
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight,
height: o.height,
hgap: o.textHgap,
vgap: o.textVgap,
lgap: o.textLgap,
rgap: o.textRgap,
text: o.text,
value: o.value,
keyword: o.keyword,
py: o.py
});
},
doClick: function () {
BI.TextNode.superclass.doClick.apply(this, arguments);
if (this.isValid()) {
this.fireEvent(BI.TextNode.EVENT_CHANGE, this.getValue(), this);
}
},
doRedMark: function () {
this.text.doRedMark.apply(this.text, arguments);
},
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
setValue: function () {
if (!this.isReadOnly()) {
this.text.setValue.apply(this.text, arguments);
}
},
getValue: function () {
return this.text.getValue();
},
setText: function () {
this.text.setText.apply(this.text, arguments);
},
getText: function () {
return this.text.getText();
}
});
BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.text_node", BI.TextNode);/**
* Created by GUY on 2015/4/15.
* @class BI.Editor
* @extends BI.Single
*/
BI.Editor = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Editor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-editor bi-focus-shadow",
hgap: 4,
vgap: 2,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
// title,warningTitle这两个属性没用
tipType: "warning",
inputType: "text",
validationChecker: BI.emptyFn,
quitChecker: BI.emptyFn,
allowBlank: false,
watermark: "",
errorText: ""
});
},
_init: function () {
BI.Editor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = this.addWidget(BI.createWidget({
type: "bi.input",
element: "
",
root: true,
value: o.value,
watermark: o.watermark,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
allowBlank: o.allowBlank
}));
this.editor.element.css({
width: "100%",
height: "100%",
border: "none",
outline: "none",
padding: "0",
margin: "0"
});
if (BI.isKey(this.options.watermark)) {
this.watermark = BI.createWidget({
type: "bi.label",
cls: "bi-water-mark",
text: this.options.watermark,
forceCenter: true,
height: o.height - 2 * (o.vgap + o.tgap),
whiteSpace: "nowrap",
textAlign: "left"
});
this.watermark.element.bind({
mousedown: function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
}
});
this.watermark.element.bind("click", function (e) {
if (self.isEnabled()) {
self.editor.isEditing() || self.editor.focus();
} else {
self.editor.isEditing() && self.editor.blur();
}
e.stopEvent();
});
this.watermark.element.css({
position: "absolute",
left: "3px",
right: "3px",
top: "0px",
bottom: "0px"
});
}
var items = [{
el: {
type: "bi.default",
items: this.watermark ? [this.editor, this.watermark] : [this.editor]
},
left: o.hgap + o.lgap,
right: o.hgap + o.rgap,
top: o.vgap + o.tgap,
bottom: o.vgap + o.bgap
}];
BI.createWidget({
type: "bi.absolute",
element: this,
items: items
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Input.EVENT_FOCUS, function () {
self._checkError();
self.element.addClass("bi-editor-focus");
self.fireEvent(BI.Editor.EVENT_FOCUS, arguments);
});
this.editor.on(BI.Input.EVENT_BLUR, function () {
self._setErrorVisible(false);
self.element.removeClass("bi-editor-focus");
self.fireEvent(BI.Editor.EVENT_BLUR, arguments);
});
this.editor.on(BI.Input.EVENT_CLICK, function () {
self.fireEvent(BI.Editor.EVENT_CLICK, arguments);
});
this.editor.on(BI.Input.EVENT_CHANGE, function () {
self.fireEvent(BI.Editor.EVENT_CHANGE, arguments);
});
this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments);
});
this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) {
self.watermark && self.watermark.invisible();
});
this.editor.on(BI.Input.EVENT_VALID, function () {
self._checkWaterMark();
self._setErrorVisible(false);
self.fireEvent(BI.Editor.EVENT_VALID, arguments);
});
this.editor.on(BI.Input.EVENT_ERROR, function () {
self._checkWaterMark();
self.fireEvent(BI.Editor.EVENT_ERROR, arguments);
self._setErrorVisible(self.isEditing());
});
this.editor.on(BI.Input.EVENT_RESTRICT, function () {
self._checkWaterMark();
var tip = self._setErrorVisible(true);
tip && tip.element.fadeOut(100, function () {
tip.element.fadeIn(100);
});
self.fireEvent(BI.Editor.EVENT_RESTRICT, arguments);
});
this.editor.on(BI.Input.EVENT_EMPTY, function () {
self._checkWaterMark();
self.fireEvent(BI.Editor.EVENT_EMPTY, arguments);
});
this.editor.on(BI.Input.EVENT_ENTER, function () {
self.fireEvent(BI.Editor.EVENT_ENTER, arguments);
});
this.editor.on(BI.Input.EVENT_SPACE, function () {
self.fireEvent(BI.Editor.EVENT_SPACE, arguments);
});
this.editor.on(BI.Input.EVENT_BACKSPACE, function () {
self.fireEvent(BI.Editor.EVENT_BACKSPACE, arguments);
});
this.editor.on(BI.Input.EVENT_REMOVE, function () {
self.fireEvent(BI.Editor.EVENT_REMOVE, arguments);
});
this.editor.on(BI.Input.EVENT_START, function () {
self.fireEvent(BI.Editor.EVENT_START, arguments);
});
this.editor.on(BI.Input.EVENT_PAUSE, function () {
self.fireEvent(BI.Editor.EVENT_PAUSE, arguments);
});
this.editor.on(BI.Input.EVENT_STOP, function () {
self.fireEvent(BI.Editor.EVENT_STOP, arguments);
});
this.editor.on(BI.Input.EVENT_CONFIRM, function () {
self.fireEvent(BI.Editor.EVENT_CONFIRM, arguments);
});
this.element.click(function (e) {
e.stopPropagation();
return false;
});
if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
this._checkError();
this._checkWaterMark();
} else {
this._checkWaterMark();
}
},
_checkToolTip: function () {
var o = this.options;
var errorText = o.errorText;
if (BI.isFunction(errorText)) {
errorText = errorText(this.editor.getValue());
}
if (BI.isKey(errorText)) {
if (!this.isEnabled() || this.isValid() || (BI.Bubbles.has(this.getName()) && BI.Bubbles.get(this.getName()).isVisible())) {
this.setTitle("");
} else {
this.setTitle(errorText);
}
}
},
_checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.isValid());
this._checkToolTip();
},
_checkWaterMark: function () {
var o = this.options;
if (!this.disabledWaterMark && this.editor.getValue() === "" && BI.isKey(o.watermark)) {
this.watermark && this.watermark.visible();
} else {
this.watermark && this.watermark.invisible();
}
},
setErrorText: function (text) {
this.options.errorText = text;
},
getErrorText: function () {
return this.options.errorText;
},
_setErrorVisible: function (b) {
var o = this.options;
var errorText = o.errorText;
if (BI.isFunction(errorText)) {
errorText = errorText(this.editor.getValue());
}
if (!this.disabledError && BI.isKey(errorText)) {
BI.Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {
adjustYOffset: 2
});
this._checkToolTip();
return BI.Bubbles.get(this.getName());
}
},
disableError: function () {
this.disabledError = true;
this._checkError();
},
enableError: function () {
this.disabledError = false;
this._checkError();
},
disableWaterMark: function () {
this.disabledWaterMark = true;
this._checkWaterMark();
},
enableWaterMark: function () {
this.disabledWaterMark = false;
this._checkWaterMark();
},
focus: function () {
this.element.addClass("text-editor-focus");
this.editor.focus();
},
blur: function () {
this.element.removeClass("text-editor-focus");
this.editor.blur();
},
selectAll: function () {
this.editor.selectAll();
},
onKeyDown: function (k) {
this.editor.onKeyDown(k);
},
setValue: function (v) {
BI.Editor.superclass.setValue.apply(this, arguments);
this.editor.setValue(v);
this._checkError();
this._checkWaterMark();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
resetLastValidValue: function () {
this.editor.resetLastValidValue();
},
getValue: function () {
if (!this.isValid()) {
return BI.trim(this.editor.getLastValidValue());
}
return BI.trim(this.editor.getValue());
},
isEditing: function () {
return this.editor.isEditing();
},
isValid: function () {
return this.editor.isValid();
},
destroyed: function () {
BI.Bubbles.remove(this.getName());
}
});
BI.Editor.EVENT_CHANGE = "EVENT_CHANGE";
BI.Editor.EVENT_FOCUS = "EVENT_FOCUS";
BI.Editor.EVENT_BLUR = "EVENT_BLUR";
BI.Editor.EVENT_CLICK = "EVENT_CLICK";
BI.Editor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
BI.Editor.EVENT_SPACE = "EVENT_SPACE";
BI.Editor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
BI.Editor.EVENT_START = "EVENT_START";
BI.Editor.EVENT_PAUSE = "EVENT_PAUSE";
BI.Editor.EVENT_STOP = "EVENT_STOP";
BI.Editor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.Editor.EVENT_VALID = "EVENT_VALID";
BI.Editor.EVENT_ERROR = "EVENT_ERROR";
BI.Editor.EVENT_ENTER = "EVENT_ENTER";
BI.Editor.EVENT_RESTRICT = "EVENT_RESTRICT";
BI.Editor.EVENT_REMOVE = "EVENT_REMOVE";
BI.Editor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.editor", BI.Editor);/**
* 多文件
*
* Created by GUY on 2016/4/13.
* @class BI.MultifileEditor
* @extends BI.Single
* @abstract
*/
BI.MultifileEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.MultifileEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-multifile-editor",
multiple: false,
maxSize: -1, // 1024 * 1024
accept: "",
url: ""
});
},
_init: function () {
var self = this, o = this.options;
BI.MultifileEditor.superclass._init.apply(this, arguments);
this.file = BI.createWidget({
type: "bi.file",
cls: "multifile-editor",
width: "100%",
height: "100%",
name: o.name,
url: o.url,
multiple: o.multiple,
accept: o.accept,
maxSize: o.maxSize,
title: o.title
});
this.file.on(BI.File.EVENT_CHANGE, function () {
self.fireEvent(BI.MultifileEditor.EVENT_CHANGE, arguments);
});
this.file.on(BI.File.EVENT_UPLOADSTART, function () {
self.fireEvent(BI.MultifileEditor.EVENT_UPLOADSTART, arguments);
});
this.file.on(BI.File.EVENT_ERROR, function () {
self.fireEvent(BI.MultifileEditor.EVENT_ERROR, arguments);
});
this.file.on(BI.File.EVENT_PROGRESS, function () {
self.fireEvent(BI.MultifileEditor.EVENT_PROGRESS, arguments);
});
this.file.on(BI.File.EVENT_UPLOADED, function () {
self.fireEvent(BI.MultifileEditor.EVENT_UPLOADED, arguments);
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.adaptive",
scrollable: false,
items: [this.file]
},
top: 0,
right: 0,
left: 0,
bottom: 0
}]
});
},
select: function () {
this.file.select();
},
getValue: function () {
return this.file.getValue();
},
upload: function () {
this.file.upload();
},
reset: function () {
this.file.reset();
}
});
BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE";
BI.MultifileEditor.EVENT_UPLOADSTART = "MultifileEditor.EVENT_UPLOADSTART";
BI.MultifileEditor.EVENT_ERROR = "MultifileEditor.EVENT_ERROR";
BI.MultifileEditor.EVENT_PROGRESS = "MultifileEditor.EVENT_PROGRESS";
BI.MultifileEditor.EVENT_UPLOADED = "MultifileEditor.EVENT_UPLOADED";
BI.shortcut("bi.multifile_editor", BI.MultifileEditor);/**
*
* Created by GUY on 2016/1/18.
* @class BI.TextAreaEditor
* @extends BI.Single
*/
BI.TextAreaEditor = BI.inherit(BI.Single, {
_defaultConfig: function () {
return $.extend(BI.TextAreaEditor.superclass._defaultConfig.apply(), {
baseCls: "bi-textarea-editor",
value: ""
});
},
_init: function () {
BI.TextAreaEditor.superclass._init.apply(this, arguments);
var o = this.options, self = this;
this.content = BI.createWidget({
type: "bi.layout",
tagName: "textarea",
width: "100%",
height: "100%",
cls: "bi-textarea textarea-editor-content display-block"
});
this.content.element.css({resize: "none", whiteSpace: "normal"});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: {
type: "bi.adaptive",
items: [this.content]
},
left: 0,
right: 3,
top: 6,
bottom: 5
}]
});
this.content.element.on("input propertychange", function (e) {
self._checkWaterMark();
self.fireEvent(BI.TextAreaEditor.EVENT_CHANGE);
});
this.content.element.focus(function () {
if (self.isValid()) {
self._focus();
self.fireEvent(BI.TextAreaEditor.EVENT_FOCUS);
}
BI.Widget._renderEngine.createElement(document).bind("mousedown." + self.getName(), function (e) {
if (BI.DOM.isExist(self) && !self.element.__isMouseInBounds__(e)) {
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + self.getName());
self.content.element.blur();
}
});
});
this.content.element.blur(function () {
if (self.isValid()) {
self._blur();
self.fireEvent(BI.TextAreaEditor.EVENT_BLUR);
}
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + self.getName());
});
if (BI.isKey(o.value)) {
self.setValue(o.value);
}
if (BI.isNotNull(o.style)) {
self.setStyle(o.style);
}
this._checkWaterMark();
},
_checkWaterMark: function () {
var self = this, o = this.options;
var val = this.getValue();
if (BI.isNotEmptyString(val)) {
this.watermark && this.watermark.destroy();
this.watermark = null;
} else {
if (BI.isNotEmptyString(o.watermark)) {
if (!this.watermark) {
this.watermark = BI.createWidget({
type: "bi.text_button",
cls: "bi-water-mark",
textAlign: "left",
height: 30,
text: o.watermark,
invalid: o.invalid,
disabled: o.disabled
});
this.watermark.on(BI.TextButton.EVENT_CHANGE, function () {
self.focus();
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.watermark,
left: 0,
top: 0,
right: 0
}]
});
} else {
this.watermark.setText(o.watermark);
this.watermark.setValid(!o.invalid);
this.watermark.setEnable(!o.disabled);
}
}
}
},
_focus: function () {
this.content.element.addClass("textarea-editor-focus");
this._checkWaterMark();
},
_blur: function () {
this.content.element.removeClass("textarea-editor-focus");
this._checkWaterMark();
},
focus: function () {
this._focus();
this.content.element.focus();
},
blur: function () {
this._blur();
this.content.element.blur();
},
getValue: function () {
return this.content.element.val();
},
setValue: function (value) {
this.content.element.val(value);
this._checkWaterMark();
},
setStyle: function (style) {
this.style = style;
this.element.css(style);
this.content.element.css(BI.extend({}, style, {
color: style.color || BI.DOM.getContrastColor(BI.DOM.isRGBColor(style.backgroundColor) ? BI.DOM.rgb2hex(style.backgroundColor) : style.backgroundColor)
}));
},
getStyle: function () {
return this.style;
},
_setValid: function (b) {
BI.TextAreaEditor.superclass._setValid.apply(this, arguments);
// this.content.setValid(b);
// this.watermark && this.watermark.setValid(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.TextAreaEditor.EVENT_BLUR = "EVENT_BLUR";
BI.TextAreaEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.shortcut("bi.textarea_editor", BI.TextAreaEditor);/**
* guy 图标
* @class BI.Icon
* @extends BI.Single
*/
BI.Icon = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Icon.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
tagName: "i",
baseCls: (conf.baseCls || "") + " x-icon b-font horizon-center display-block"
});
},
_init: function () {
BI.Icon.superclass._init.apply(this, arguments);
if (BI.isIE9Below && BI.isIE9Below()) {
this.element.addClass("hack");
}
}
});
BI.shortcut("bi.icon", BI.Icon);/**
* @class BI.Iframe
* @extends BI.Single
* @abstract
* Created by GameJian on 2016/3/2.
*/
BI.Iframe = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Iframe.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-iframe",
src: "",
width: "100%",
height: "100%"
});
},
_init: function () {
var o = this.options;
this.options.element = BI.Widget._renderEngine.createElement("