").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-card",
+ items: {
+ north: {
+ el: {
+ type: "bi.border",
+ cls: "bi-message-title bi-background",
+ items: {
+ center: {
+ el: {
+ type: "bi.label",
+ cls: "bi-font-bold",
+ text: title || BI.i18nText("BI-Basic_Prompt"),
+ textAlign: "left",
+ hgap: 20,
+ height: 40
+ }
+ },
+ 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: 40
+ },
+ center: {
+ el: {
+ type: "bi.label",
+ vgap: 10,
+ hgap: 20,
+ whiteSpace: "normal",
+ text: message
+ }
+ },
+ south: {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.right_vertical_adapt",
+ lgap: 10,
+ items: controlItems
+ },
+ top: 0,
+ left: 20,
+ right: 20,
+ bottom: 0
+ }]
+
+ },
+ height: 44
+ }
+ },
+ width: 450,
+ height: 200
+ }
+ ]
+ };
+
+ 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();
+ }
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
+ this.element.scrollTop(o.scrollTop);
+ this.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
+ logic: {
+ dynamic: false
+ },
+ header: null,
+ body: null,
+ footer: null,
+ closable: true // BI-40839 是否显示右上角的关闭按钮
+ });
+ },
+ 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 - self.element.width()) + "px",
+ top: BI.clamp(self.startY, 0, H - self.element.height()) + "px"
+ });
+ // BI-12134 没有什么特别好的方法
+ BI.Resizers._resize();
+ }, function () {
+ self.tracker.releaseMouseMoves();
+ }, _global);
+ var items = [{
+ 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: o.closable ? {
+ type: "bi.icon_button",
+ cls: "bi-message-close close-font",
+ height: this._constant.HEADER_HEIGHT,
+ handler: function () {
+ self.close();
+ }
+ } : {
+ type: "bi.layout"
+ },
+ width: 56
+ }],
+ height: this._constant.HEADER_HEIGHT
+ },
+ height: this._constant.HEADER_HEIGHT
+ }, {
+ el: o.logic.dynamic ? {
+ type: "bi.vertical",
+ scrolly: false,
+ cls: "popover-body",
+ ref: function () {
+ self.body = this;
+ },
+ hgap: 20,
+ tgap: 10,
+ items: [{
+ el: BI.createWidget(o.body)
+ }]
+ } : {
+ type: "bi.absolute",
+ items: [{
+ el: BI.createWidget(o.body),
+ left: 20,
+ top: 10,
+ right: 20,
+ bottom: 0
+ }]
+ }
+ }];
+ if (o.footer) {
+ items.push({
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: BI.createWidget(o.footer),
+ left: 20,
+ top: 0,
+ right: 20,
+ bottom: 0
+ }],
+ height: 44
+ },
+ height: 44
+ });
+ }
+
+ var size = this._calculateSize();
+
+ return BI.extend({
+ type: o.logic.dynamic ? "bi.vertical" : "bi.vtape",
+ items: items,
+ width: size.width
+ }, o.logic.dynamic ? {
+ type: "bi.vertical",
+ scrolly: false
+ } : {
+ type: "bi.vtape",
+ height: size.height
+ });
+ },
+
+ mounted: function () {
+ var self = this, o = this.options;
+ this.dragger.element.mousedown(function (e) {
+ var pos = self.element.offset();
+ self.startX = pos.left;
+ self.startY = pos.top;
+ self.tracker.captureMouseMoves(e);
+ });
+ if (o.logic.dynamic) {
+ var size = this._calculateSize();
+ var height = this.element.height();
+ var compareHeight = BI.clamp(height, size.height, 600) - (o.footer ? 84 : 44);
+ this.body.element.height(compareHeight);
+ }
+ },
+
+ _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 = 200;
+ 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.view.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.view;
+ },
+
+ populate: function (items) {
+ this.view.populate.apply(this.view, 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.view.setValue(selectedValues);
+ },
+
+ getValue: function () {
+ return this.view.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" + ((BI.isIE() && BI.isIE9Below()) ? " hack" : ""),
+ 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();
+ });
+ }
+
+ var _items = [];
+ if (this.watermark) {
+ _items.push({
+ el: this.watermark,
+ left: 3,
+ right: 3,
+ top: 0,
+ bottom: 0
+ });
+ }
+ _items.push({
+ el: this.editor,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ });
+
+ var items = [{
+ el: {
+ type: "bi.absolute",
+ items: _items
+ },
+ 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 (e) {
+ // tab键就不要隐藏了
+ if (e.keyCode !== BI.KeyCode.TAB && 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();
+ },
+
+ 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 BI.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: 10,
+ right: 10,
+ top: 8,
+ bottom: 8
+ }]
+ });
+
+ 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: 6,
+ 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 表示一行数据,通过position来定位位置的数据
+ * @class BI.Html
+ * @extends BI.Single
+ */
+BI.Html = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Html.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text",
+ textAlign: "left",
+ whiteSpace: "normal",
+ lineHeight: null,
+ handler: null, // 如果传入handler,表示处理文字的点击事件,不是区域的
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ text: ""
+ });
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ if (o.hgap + o.lgap > 0) {
+ this.element.css({
+ "padding-left": o.hgap + o.lgap + "px"
+ });
+ }
+ if (o.hgap + o.rgap > 0) {
+ this.element.css({
+ "padding-right": o.hgap + o.rgap + "px"
+ });
+ }
+ if (o.vgap + o.tgap > 0) {
+ this.element.css({
+ "padding-top": o.vgap + o.tgap + "px"
+ });
+ }
+ if (o.vgap + o.bgap > 0) {
+ this.element.css({
+ "padding-bottom": o.vgap + o.bgap + "px"
+ });
+ }
+ if (BI.isNumber(o.height)) {
+ this.element.css({lineHeight: o.height + "px"});
+ }
+ if (BI.isNumber(o.lineHeight)) {
+ this.element.css({lineHeight: o.lineHeight + "px"});
+ }
+ this.element.css({
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace
+ });
+ if (o.handler) {
+ this.text = BI.createWidget({
+ type: "bi.layout",
+ tagName: "span"
+ });
+ this.text.element.click(function () {
+ o.handler(self.getValue());
+ });
+ BI.createWidget({
+ type: "bi.default",
+ element: this,
+ items: [this.text]
+ });
+ } else {
+ this.text = this;
+ }
+ },
+
+ mounted: function () {
+ var o = this.options;
+
+ if (BI.isKey(o.text)) {
+ this.setText(o.text);
+ } else if (BI.isKey(o.value)) {
+ this.setText(o.value);
+ }
+ },
+
+ doHighLight: function () {
+ this.text.element.addClass("bi-high-light");
+ },
+
+ unHighLight: function () {
+ this.text.element.removeClass("bi-high-light");
+ },
+
+ setValue: function (text) {
+ BI.Html.superclass.setValue.apply(this, arguments);
+ if (!this.isReadOnly()) {
+ this.setText(text);
+ }
+ },
+
+ setStyle: function (css) {
+ this.text.element.css(css);
+ },
+
+ setText: function (text) {
+ BI.Html.superclass.setText.apply(this, arguments);
+ this.options.text = text;
+ this.text.element.html(text);
+ }
+});
+
+BI.shortcut("bi.html", BI.Html);/**
+ * 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, {
+ tagName: "iframe",
+ baseCls: (conf.baseCls || "") + " bi-iframe",
+ src: "",
+ attributes: {},
+ width: "100%",
+ height: "100%"
+ });
+ },
+
+ _init: function () {
+ var o = this.options;
+ o.attributes.frameborder = "0";
+ o.attributes.src = o.src;
+ BI.Iframe.superclass._init.apply(this, arguments);
+ },
+
+ setSrc: function (src) {
+ this.options.src = src;
+ this.element.attr("src", src);
+ },
+
+ getSrc: function () {
+ return this.options.src;
+ },
+
+ setName: function (name) {
+ this.options.name = name;
+ this.element.attr("name", name);
+ },
+
+ getName: function () {
+ return this.options.name;
+ },
+
+ getWidth: function () {
+ return this.options.width;
+ },
+
+ getHeight: function () {
+ return this.options.height;
+ }
+});
+
+BI.shortcut("bi.iframe", BI.Iframe);/**
+ * ͼƬ
+ *
+ * Created by GUY on 2016/1/26.
+ * @class BI.Img
+ * @extends BI.Single
+ * @abstract
+ */
+BI.Img = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Img.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ tagName: "img",
+ baseCls: (conf.baseCls || "") + " bi-img display-block",
+ src: "",
+ attributes: {},
+ width: "100%",
+ height: "100%"
+ });
+ },
+
+ _init: function () {
+ var o = this.options;
+ o.attributes.src = o.src;
+ BI.Img.superclass._init.apply(this, arguments);
+ },
+
+ setSrc: function (src) {
+ this.options.src = src;
+ this.element.attr("src", src);
+ },
+
+ getSrc: function () {
+ return this.options.src;
+ }
+});
+
+BI.shortcut("bi.img", BI.Img);
+/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.ImageCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ var conf = BI.ImageCheckbox.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-image-checkbox check-box-icon",
+ selected: false,
+ handler: BI.emptyFn,
+ width: 16,
+ height: 16,
+ iconWidth: 16,
+ iconHeight: 16
+ });
+ },
+
+ _init: function () {
+ BI.ImageCheckbox.superclass._init.apply(this, arguments);
+ },
+
+ doClick: function () {
+ BI.ImageCheckbox.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.Checkbox.EVENT_CHANGE);
+ }
+ }
+});
+BI.ImageCheckbox.EVENT_CHANGE = "Checkbox.EVENT_CHANGE";
+
+BI.shortcut("bi.image_checkbox", BI.ImageCheckbox);/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.Checkbox = BI.inherit(BI.BasicButton, {
+
+ props: {
+ baseCls: "bi-checkbox",
+ selected: false,
+ handler: BI.emptyFn,
+ width: 16,
+ height: 16,
+ iconWidth: 14,
+ iconHeight: 14
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.center_adapt",
+ items: [{
+ type: "bi.default",
+ ref: function (_ref) {
+ self.checkbox = _ref;
+ },
+ cls: "checkbox-context bi-border",
+ width: o.iconWidth,
+ height: o.iconHeight
+ }]
+ };
+ },
+
+ _setEnable: function (enable) {
+ BI.Checkbox.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.checkbox.element.removeClass("base-disabled disabled");
+ } else {
+ this.checkbox.element.addClass("base-disabled disabled");
+ }
+ },
+
+ doClick: function () {
+ BI.Checkbox.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.Checkbox.EVENT_CHANGE);
+ }
+ },
+
+ setSelected: function (b) {
+ BI.Checkbox.superclass.setSelected.apply(this, arguments);
+ if (b) {
+ this.checkbox.element.removeClass("bi-border").addClass("bi-high-light-background bi-high-light-border");
+ } else {
+ this.checkbox.element.removeClass("bi-high-light-background bi-high-light-border").addClass("bi-border");
+ }
+ }
+});
+BI.Checkbox.EVENT_CHANGE = "Checkbox.EVENT_CHANGE";
+
+BI.shortcut("bi.checkbox", BI.Checkbox);/**
+ * 文件
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.File
+ * @extends BI.Single
+ * @abstract
+ */
+(function (document) {
+
+ /**
+ * @description normalize input.files. create if not present, add item method if not present
+ * @param Object generated wrap object
+ * @return Object the wrap object itself
+ */
+ var F = (function (item) {
+ return function (input) {
+ var files = input.files || [input];
+ if (!files.item) {
+ files.item = item;
+ }
+ return files;
+ };
+ })(function (i) {
+ return this[i];
+ });
+
+ var event = {
+
+ /**
+ * @description add an event via addEventListener or attachEvent
+ * @param DOMElement the element to add event
+ * @param String event name without "on" (e.g. "mouseover")
+ * @param Function the callback to associate as event
+ * @return Object noswfupload.event
+ */
+ add: document.addEventListener ?
+ function (node, name, callback) {
+ node.addEventListener(name, callback, false);
+ return this;
+ } :
+ function (node, name, callback) {
+ node.attachEvent("on" + name, callback);
+ return this;
+ },
+
+ /**
+ * @description remove an event via removeEventListener or detachEvent
+ * @param DOMElement the element to remove event
+ * @param String event name without "on" (e.g. "mouseover")
+ * @param Function the callback associated as event
+ * @return Object noswfupload.event
+ */
+ del: document.removeEventListener ?
+ function (node, name, callback) {
+ node.removeEventListener(name, callback, false);
+ return this;
+ } :
+ function (node, name, callback) {
+ node.detachEvent("on" + name, callback);
+ return this;
+ },
+
+ /**
+ * @description to block event propagation and prevent event default
+ * @param void generated event or undefined
+ * @return Boolean false
+ */
+ stop: function (e) {
+ if (!e) {
+ if (self.event) {
+ event.returnValue = !(event.cancelBubble = true);
+ }
+ } else {
+ e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
+ e.preventDefault ? e.preventDefault() : e.returnValue = false;
+ }
+
+ return false;
+ }
+ };
+
+ var sendFile = (function (toString) {
+ var multipart = function (boundary, name, file) {
+ return "--".concat(
+ boundary, CRLF,
+ "Content-Disposition: form-data; name=\"", name, "\"; filename=\"", BI.cjkEncode(file.fileName), "\"", CRLF,
+ "Content-Type: application/octet-stream", CRLF,
+ CRLF,
+ file.getAsBinary(), CRLF,
+ "--", boundary, "--", CRLF
+ );
+ },
+ isFunction = function (Function) {
+ return toString.call(Function) === "[object Function]";
+ },
+ split = "onabort.onerror.onloadstart.onprogress".split("."),
+ length = split.length,
+ CRLF = "\r\n",
+ xhr = this.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"),
+ sendFile;
+
+ // FireFox 3+, Safari 4 beta (Chrome 2 beta file is buggy and will not work)
+ if (xhr.upload || xhr.sendAsBinary) {
+ sendFile = function (handler, maxSize, width, height) {
+ if (-1 < maxSize && maxSize < handler.file.fileSize) {
+ if (isFunction(handler.onerror)) {
+ handler.onerror();
+ }
+ return;
+ }
+ for (var
+ xhr = new XMLHttpRequest,
+ upload = xhr.upload || {
+ addEventListener: function (event, callback) {
+ this["on" + event] = callback;
+ }
+ },
+ i = 0;
+ i < length;
+ i++
+ ) {
+ upload.addEventListener(
+ split[i].substring(2),
+ (function (event) {
+ return function (rpe) {
+ if (isFunction(handler[event])) {
+ handler[event](rpe, xhr);
+ }
+ };
+ })(split[i]),
+ false
+ );
+ }
+ upload.addEventListener(
+ "load",
+ function (rpe) {
+ if (handler.onreadystatechange === false) {
+ if (isFunction(handler.onload)) {
+ handler.onload(rpe, xhr);
+ }
+ } else {
+ setTimeout(function () {
+ if (xhr.readyState === 4) {
+ if (isFunction(handler.onload)) {
+ handler.onload(rpe, xhr);
+ }
+ } else {
+ setTimeout(arguments.callee, 15);
+ }
+ }, 15);
+ }
+ },
+ false
+ );
+ xhr.open("post", handler.url + "&filename=" + _global.encodeURIComponent(handler.file.fileName), true);
+ if (!xhr.upload) {
+ var rpe = {loaded: 0, total: handler.file.fileSize || handler.file.size, simulation: true};
+ rpe.interval = setInterval(function () {
+ rpe.loaded += 1024 / 4;
+ if (rpe.total <= rpe.loaded) {
+ rpe.loaded = rpe.total;
+ }
+ upload.onprogress(rpe);
+ }, 100);
+ xhr.onabort = function () {
+ upload.onabort({});
+ };
+ xhr.onerror = function () {
+ upload.onerror({});
+ };
+ xhr.onreadystatechange = function () {
+ switch (xhr.readyState) {
+ case 2:
+ case 3:
+ if (rpe.total <= rpe.loaded) {rpe.loaded = rpe.total;}
+ upload.onprogress(rpe);
+ break;
+ case 4:
+ clearInterval(rpe.interval);
+ rpe.interval = 0;
+ rpe.loaded = rpe.total;
+ upload.onprogress(rpe);
+ if (199 < xhr.status && xhr.status < 400) {
+ upload["onload"]({});
+ var attachO = BI.jsonDecode(xhr.responseText);
+ attachO.filename = handler.file.fileName;
+ if (handler.file.type.indexOf("image") != -1) {
+ attachO.attach_type = "image";
+ }
+ handler.attach_array.push(attachO);
+ } else {
+ upload["onerror"]({});
+ }
+ break;
+ }
+ };
+ upload.onloadstart(rpe);
+ } else {
+ xhr.onreadystatechange = function () {
+ switch (xhr.readyState) {
+ case 4:
+ var attachO = BI.jsonDecode(xhr.responseText);
+ if (handler.file.type.indexOf("image") != -1) {
+ attachO.attach_type = "image";
+ }
+ attachO.filename = handler.file.fileName;
+ if (handler.maxlength == 1) {
+ handler.attach_array[0] = attachO;
+ // handler.attach_array.push(attachO);
+ } else {
+ handler.attach_array.push(attachO);
+ }
+ break;
+ }
+ };
+ if (isFunction(upload.onloadstart)) {
+ upload.onloadstart();
+ }
+ }
+ var boundary = "AjaxUploadBoundary" + (new Date).getTime();
+ xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
+ if (handler.file.getAsBinary) {
+ xhr[xhr.sendAsBinary ? "sendAsBinary" : "send"](multipart(boundary, handler.name, handler.file));
+ } else {
+ xhr.setRequestHeader("Content-Type", "multipart/form-data");
+ // xhr.setRequestHeader("X-Name", handler.name);
+ // xhr.setRequestHeader("X-File-Name", handler.file.fileName);
+ var form = new FormData();
+ form.append("FileData", handler.file);
+ xhr.send(form);
+ }
+ return handler;
+ };
+ }
+ // Internet Explorer, Opera, others
+ else {
+ sendFile = function (handler, maxSize, width, height) {
+ var url = handler.url.concat(-1 === handler.url.indexOf("?") ? "?" : "&", "AjaxUploadFrame=true"),
+ rpe = {
+ loaded: 1, total: 100, simulation: true, interval: setInterval(function () {
+ if (rpe.loaded < rpe.total) {++rpe.loaded;}
+ if (isFunction(handler.onprogress)) {handler.onprogress(rpe, {});}
+ }, 100)
+ },
+ onload = function () {
+ iframe.onreadystatechange = iframe.onload = iframe.onerror = null;
+ form.parentNode.removeChild(form);
+ form = null;
+ clearInterval(rpe.interval);
+ // rpe.loaded = rpe.total;
+ try {
+ var responseText = (iframe.contentWindow.document || iframe.contentWindow.contentDocument).body.innerHTML;
+ var attachO = BI.jsonDecode(responseText);
+ if (handler.file.type.indexOf("image") != -1) {
+ attachO.attach_type = "image";
+ }
+
+ // attachO.fileSize = responseText.length;
+ attachO.filename = BI.cjkDecode(handler.file.fileName);
+ if (handler.maxlength == 1) {
+ handler.attach_array[0] = attachO;
+ } else {
+ handler.attach_array.push(attachO);
+ }
+ } catch (e) {
+ if (isFunction(handler.onerror)) {handler.onerror(rpe, event || _global.event);}
+ }
+ if (isFunction(handler.onload)) {handler.onload(rpe, {responseText: responseText});}
+ },
+ target = ["AjaxUpload", (new Date).getTime(), String(Math.random()).substring(2)].join("_");
+ try { // IE < 8 does not accept enctype attribute ...
+ var form = document.createElement("
"),
+ iframe = handler.iframe || (handler.iframe = document.createElement("
"));
+ } catch (e) {
+ var form = document.createElement("form"),
+ iframe = handler.iframe || (handler.iframe = document.createElement("iframe"));
+ form.setAttribute("enctype", "multipart/form-data");
+ iframe.setAttribute("name", iframe.id = target);
+ iframe.setAttribute("src", url);
+ }
+ iframe.style.position = "absolute";
+ iframe.style.left = iframe.style.top = "-10000px";
+ iframe.onload = onload;
+ iframe.onerror = function (event) {
+ if (isFunction(handler.onerror)) {
+ handler.onerror(rpe, event || _global.event);
+ }
+ };
+ iframe.onreadystatechange = function () {
+ if (/loaded|complete/i.test(iframe.readyState)) {
+ onload();
+
+ // wei : todo,将附件信息放到handler.attach
+ } else if (isFunction(handler.onloadprogress)) {
+ if (rpe.loaded < rpe.total) {
+ ++rpe.loaded;
+ }
+ handler.onloadprogress(rpe, {
+ readyState: {
+ loading: 2,
+ interactive: 3,
+ loaded: 4,
+ complete: 4
+ }[iframe.readyState] || 1
+ });
+ }
+ };
+ form.setAttribute("action", handler.url + "&filename=" + _global.encodeURIComponent(handler.file.fileName));
+ form.setAttribute("target", iframe.id);
+ form.setAttribute("method", "post");
+ form.appendChild(handler.file);
+ form.style.display = "none";
+ if (isFunction(handler.onloadstart)) {
+ handler.onloadstart(rpe, {});
+ }
+ with (document.body || document.documentElement) {
+ appendChild(iframe);
+ appendChild(form);
+ form.submit();
+ }
+
+ return handler;
+ };
+ }
+ xhr = null;
+ return sendFile;
+ })(Object.prototype.toString);
+
+ var sendFiles = function (handler, maxSize, width, height) {
+
+ var length = handler.files.length,
+ i = 0,
+ onload = handler.onload,
+ onloadstart = handler.onloadstart;
+ handler.current = 0;
+ handler.total = 0;
+ handler.sent = 0;
+ while (handler.current < length) {
+ handler.total += (handler.files[handler.current].fileSize || handler.files[handler.current].size);
+ handler.current++;
+ }
+ handler.current = 0;
+ if (length && handler.files[0].fileSize !== -1) {
+ handler.file = handler.files[handler.current];
+
+ sendFile(handler, maxSize, width, height).onload = function (rpe, xhr) {
+ handler.onloadstart = null;
+ handler.sent += (handler.files[handler.current].fileSize || handler.files[handler.current].size);
+ if (++handler.current < length) {
+ handler.file = handler.files[handler.current];
+ sendFile(handler, maxSize, width, height).onload = arguments.callee;
+ } else if (onload) {
+ handler.onloadstart = onloadstart;
+ handler.onload = onload;
+ handler.onload(rpe, xhr);
+ }
+ };
+ } else if (length) {
+ handler.total = length * 100;
+ handler.file = handler.files[handler.current];
+ sendFile(handler, maxSize, width, height).onload = function (rpe, xhr) {
+ var callee = arguments.callee;
+ handler.onloadstart = null;
+ handler.sent += 100;
+ if (++handler.current < length) {
+ if (/\b(chrome|safari)\b/i.test(navigator.userAgent)) {
+ handler.iframe.parentNode.removeChild(handler.iframe);
+ handler.iframe = null;
+ }
+ setTimeout(function () {
+ handler.file = handler.files[handler.current];
+ sendFile(handler, maxSize, width, height).onload = callee;
+ }, 15);
+ } else if (onload) {
+ setTimeout(function () {
+ handler.iframe.parentNode.removeChild(handler.iframe);
+ handler.iframe = null;
+ handler.onloadstart = onloadstart;
+ handler.onload = onload;
+ handler.onload(rpe, xhr);
+ }, 15);
+ }
+ };
+ }
+ return handler;
+ };
+
+ BI.File = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.File.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-file display-block",
+ tagName: "input",
+ attributes: {
+ type: "file"
+ },
+ name: "",
+ url: "",
+ multiple: true,
+ accept: "", /** '*.jpg; *.zip'**/
+ maxSize: -1 // 1024 * 1024
+ });
+ },
+
+ _init: function () {
+ var self = this, o = this.options;
+ BI.File.superclass._init.apply(this, arguments);
+ if (o.multiple === true) {
+ this.element.attr("multiple", "multiple");
+ }
+ this.element.attr("name", o.name || this.getName());
+ this.element.attr("title", o.title || "");
+ },
+
+ created: function () {
+ var self = this, o = this.options;
+ // create the noswfupload.wrap Object
+ // wrap.maxSize 文件大小限制
+ // wrap.maxlength 文件个数限制
+ var _wrap = this.wrap = this._wrap(this.element[0], o.maxSize);
+ // fileType could contain whatever text but filter checks *.{extension}
+ // if present
+
+ // handlers
+
+ _wrap.onloadstart = function (rpe, xhr) {
+ // BI.Msg.toast("loadstart");
+ self.fireEvent(BI.File.EVENT_UPLOADSTART, arguments);
+ };
+
+ _wrap.onprogress = function (rpe, xhr) {
+ // BI.Msg.toast("onprogress");
+ // percent for each bar
+
+ // fileSize is -1 only if browser does not support file info access
+ // this if splits recent browsers from others
+ if (this.file.fileSize !== -1) {
+ // simulation property indicates when the progress event is fake
+ if (rpe.simulation) {
+
+ } else {
+
+ }
+ } else {
+ // if fileSIze is -1 browser is using an iframe because it does
+ // not support
+ // files sent via Ajax (XMLHttpRequest)
+ // We can still show some information
+ }
+ self.fireEvent(BI.File.EVENT_PROGRESS, {
+ file: this.file,
+ total: rpe.total,
+ loaded: rpe.loaded,
+ simulation: rpe.simulation
+ });
+ };
+
+ // generated if there is something wrong during upload
+ _wrap.onerror = function () {
+ // just inform the user something was wrong
+ self.fireEvent(BI.File.EVENT_ERROR);
+ };
+
+ // generated when every file has been sent (one or more, it does not
+ // matter)
+ _wrap.onload = function (rpe, xhr) {
+ var self_ = this;
+ // just show everything is fine ...
+ // ... and after a second reset the component
+ setTimeout(function () {
+ self_.clean(); // remove files from list
+ self_.hide(); // hide progress bars and enable input file
+
+ // BI.Msg.toast("onload");
+ self.fireEvent(BI.File.EVENT_UPLOADED);
+ // enable again the submit button/element
+ }, 1000);
+ };
+ _wrap.url = o.url;
+ _wrap.fileType = o.accept; // 文件类型限制
+ _wrap.attach_array = [];
+ _wrap.attach_names = [];
+ _wrap.attachNum = 0;
+ },
+
+ _events: function (wrap) {
+ var self = this;
+ event.add(wrap.dom.input, "change", function () {
+ event.del(wrap.dom.input, "change", arguments.callee);
+ for (var input = wrap.dom.input.cloneNode(true), i = 0, files = F(wrap.dom.input); i < files.length; i++) {
+ var item = files.item(i);
+ var tempFile = item.value || item.name;
+ var value = item.fileName || (item.fileName = tempFile.split("\\").pop()),
+ ext = -1 !== value.indexOf(".") ? value.split(".").pop().toLowerCase() : "unknown",
+ size = item.fileSize || item.size;
+ if (wrap.fileType && -1 === wrap.fileType.indexOf("*." + ext)) {
+ // 文件类型不支持
+ BI.Msg.toast(BI.i18nText("BI-Upload_File_Type_Error"), {level: "error"});
+ self.fireEvent(BI.File.EVENT_ERROR, {
+ errorType: 0,
+ file: item
+ });
+ } else if (wrap.maxSize !== -1 && size && wrap.maxSize < size) {
+ // 文件大小不支持
+ BI.Msg.toast(BI.i18nText("BI-Upload_File_Size_Error"), {level: "error"});
+ self.fireEvent(BI.File.EVENT_ERROR, {
+ errorType: 1,
+ file: item
+ });
+ } else {
+ wrap.files.unshift(item);
+ // BI.Msg.toast(value);
+ }
+ }
+ wrap.files.length > 0 && self.fireEvent(BI.File.EVENT_CHANGE, {
+ files: wrap.files
+ });
+ input.value = "";
+ wrap.dom.input.parentNode.replaceChild(input, wrap.dom.input);
+ wrap.dom.input = input;
+ event.add(wrap.dom.input, "change", arguments.callee);
+ });
+ return wrap;
+ },
+
+ _wrap: function () {
+ var self = this, o = this.options;
+ // be sure input accept multiple files
+ var input = this.element[0];
+ if (o.multiple === true) {
+ this.element.attr("multiple", "multiple");
+ }
+ input.value = "";
+
+ // wrap Object
+ return this._events({
+
+ // DOM namespace
+ dom: {
+ input: input, // input file
+ disabled: false // internal use, checks input file state
+ },
+ name: input.name, // name to send for each file ($_FILES[{name}] in the server)
+ // maxSize is the maximum amount of bytes for each file
+ maxSize: o.maxSize ? o.maxSize >> 0 : -1,
+ files: [], // file list
+
+ // remove every file from the noswfupload component
+ clean: function () {
+ this.files = [];
+ },
+
+ // upload one file a time (which make progress possible rather than all files in one shot)
+ // the handler is an object injected into the wrap one, could be the wrap itself or
+ // something like {onload:function(){alert("OK")},onerror:function(){alert("Error")}, etc ...}
+ upload: function (handler) {
+ if (handler) {
+ for (var key in handler) {
+ this[key] = handler[key];
+ }
+ }
+ sendFiles(this, this.maxSize);
+ return this;
+ },
+
+ // hide progress bar (total + current) and enable files selection
+ hide: function () {
+ if (this.dom.disabled) {
+ this.dom.disabled = false;
+ this.dom.input.removeAttribute("disabled");
+ }
+ },
+
+ // show progress bar and disable file selection (used during upload)
+ // total and current are pixels used to style bars
+ // totalProp and currentProp are properties to change, "height" by default
+ show: function (total, current, totalProp, currentProp) {
+ if (!this.dom.disabled) {
+ this.dom.disabled = true;
+ this.dom.input.setAttribute("disabled", "disabled");
+ }
+ }
+ });
+ },
+
+ select: function () {
+ this.wrap && BI.Widget._renderEngine.createElement(this.wrap.dom.input).click();
+ },
+
+ upload: function (handler) {
+ this.wrap && this.wrap.upload(handler);
+ },
+
+ getValue: function () {
+ return this.wrap ? this.wrap.attach_array : [];
+ },
+
+ reset: function () {
+ if (this.wrap) {
+ this.wrap.attach_array = [];
+ this.wrap.attach_names = [];
+ this.wrap.attachNum = 0;
+ }
+ },
+
+ _setEnable: function (enable) {
+ BI.File.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.element.attr("disabled", "disabled");
+ } else {
+ this.element.removeAttr("disabled");
+ }
+ }
+ });
+ BI.File.EVENT_CHANGE = "BI.File.EVENT_CHANGE";
+ BI.File.EVENT_UPLOADSTART = "EVENT_UPLOADSTART";
+ BI.File.EVENT_ERROR = "EVENT_ERROR";
+ BI.File.EVENT_PROGRESS = "EVENT_PROGRESS";
+ BI.File.EVENT_UPLOADED = "EVENT_UPLOADED";
+ BI.shortcut("bi.file", BI.File);
+})(_global.document || {});/**
+ * guy
+ * @class BI.Input 一个button和一行数 组成的一行listitem
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.Input = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Input.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-input display-block overflow-dot",
+ tagName: "input",
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn, // 按确定键能否退出编辑
+ allowBlank: false
+ });
+ },
+
+ _init: function () {
+ BI.Input.superclass._init.apply(this, arguments);
+ var self = this;
+ var ctrlKey = false;
+ var keyCode = null;
+ var inputEventValid = false;
+ var _keydown = BI.debounce(function (keyCode) {
+ self.onKeyDown(keyCode, ctrlKey);
+ self._keydown_ = false;
+ }, 300);
+ var _clk = BI.debounce(BI.bind(this._click, this), BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ this.element
+ .keydown(function (e) {
+ inputEventValid = false;
+ ctrlKey = e.ctrlKey;
+ keyCode = e.keyCode;
+ self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments);
+ })
+ .keyup(function (e) {
+ keyCode = null;
+ if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) {
+ self._keydown_ = true;
+ _keydown(e.keyCode);
+ }
+ })
+ .on("input propertychange", function (e) {
+ // 输入内容全选并直接删光,如果按键没放开就失去焦点不会触发keyup,被focusout覆盖了
+ // 这个事件在input的属性发生改变的时候就会触发(class的变化也算)
+ if (BI.isNotNull(keyCode)) {
+ keyCode = null;
+ inputEventValid = true;
+ self._keydown_ = true;
+ _keydown(keyCode);
+ }
+ })
+ .click(function (e) {
+ e.stopPropagation();
+ _clk();
+ })
+ .mousedown(function (e) {
+ self.element.val(self.element.val());
+ })
+ .focus(function (e) { // 可以不用冒泡
+ self._focusDebounce();
+ })
+ .focusout(function (e) {
+ self._blurDebounce();
+ });
+ if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) {
+ this.setValue(this.options.value);
+ }
+ },
+
+ _focus: function () {
+ this.element.addClass("bi-input-focus");
+ this._checkValidationOnValueChange();
+ this._isEditing = true;
+ if (this.getValue() == "") {
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_EMPTY);
+ }
+ this.fireEvent(BI.Input.EVENT_FOCUS);
+ },
+
+ _blur: function () {
+ var self = this;
+ if (self._keydown_ === true) {
+ BI.delay(blur, 300);
+ } else {
+ blur();
+ }
+
+ function blur () {
+ if (!self.isValid() && self.options.quitChecker.apply(self, [BI.trim(self.getValue())]) !== false) {
+ self.element.val(self._lastValidValue ? self._lastValidValue : "");
+ self._checkValidationOnValueChange();
+ self._defaultState();
+ }
+ self.element.removeClass("bi-input-focus");
+ self._isEditing = false;
+ self._start = false;
+ if (self.isValid()) {
+ self._lastValidValue = self.getValue();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CONFIRM, self.getValue(), self);
+ self.fireEvent(BI.Input.EVENT_CONFIRM);
+ }
+ self.fireEvent(BI.Input.EVENT_BLUR);
+ }
+ },
+
+ _click: function () {
+ if (this._isEditing !== true) {
+ this.selectAll();
+ this.fireEvent(BI.Input.EVENT_CLICK);
+ }
+ },
+
+ onClick: function () {
+ this._click();
+ },
+
+ onKeyDown: function (keyCode, ctrlKey) {
+ if (!this.isValid() || BI.trim(this._lastChangedValue) !== BI.trim(this.getValue())) {
+ this._checkValidationOnValueChange();
+ }
+ if (this.isValid() && BI.trim(this.getValue()) !== "") {
+ if (BI.trim(this.getValue()) !== this._lastValue && (!this._start || this._lastValue == null || this._lastValue === "")
+ || (this._pause === true && !/(\s|\u00A0)$/.test(this.getValue()))) {
+ this._start = true;
+ this._pause = false;
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STARTEDIT, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_START);
+ }
+ }
+ if (ctrlKey === true && keyCode === 86) {// ctrlKey+V
+ this._valueChange();
+ } else {
+ if (keyCode == BI.KeyCode.ENTER) {
+ if (this.isValid() || this.options.quitChecker.apply(this, [BI.trim(this.getValue())]) !== false) {
+ this.blur();
+ this.fireEvent(BI.Input.EVENT_ENTER);
+ } else {
+ this.fireEvent(BI.Input.EVENT_RESTRICT);
+ }
+ }
+ if (keyCode == BI.KeyCode.SPACE) {
+ this.fireEvent(BI.Input.EVENT_SPACE);
+ }
+ if (keyCode == BI.KeyCode.BACKSPACE && this._lastValue == "") {
+ this.fireEvent(BI.Input.EVENT_REMOVE);
+ }
+ if (keyCode == BI.KeyCode.BACKSPACE || keyCode == BI.KeyCode.DELETE) {
+ this.fireEvent(BI.Input.EVENT_BACKSPACE);
+ }
+ }
+ this.fireEvent(BI.Input.EVENT_KEY_DOWN);
+
+ if (BI.isEndWithBlank(this.getValue())) {
+ this._pause = true;
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.PAUSE, "", this);
+ this.fireEvent(BI.Input.EVENT_PAUSE);
+ this._defaultState();
+ } else if ((keyCode === BI.KeyCode.BACKSPACE || keyCode === BI.KeyCode.DELETE) &&
+ BI.trim(this.getValue()) === "" && (this._lastValue !== null && BI.trim(this._lastValue) !== "")) {
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_STOP);
+ this._valueChange();
+ } else {
+ this._valueChange();
+ }
+ },
+
+ // 初始状态
+ _defaultState: function () {
+ if (this.getValue() == "") {
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_EMPTY);
+ }
+ this._lastValue = this.getValue();
+ this._lastSubmitValue = null;
+ },
+
+ _valueChange: function () {
+ if (this.isValid() && BI.trim(this.getValue()) !== this._lastSubmitValue) {
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_CHANGE);
+ this._lastSubmitValue = BI.trim(this.getValue());
+ }
+ if (this.getValue() == "") {
+ this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
+ this.fireEvent(BI.Input.EVENT_EMPTY);
+ }
+ this._lastValue = this.getValue();
+ },
+
+ _checkValidationOnValueChange: function () {
+ var o = this.options;
+ var v = this.getValue();
+ this.setValid(
+ (o.allowBlank === true && BI.trim(v) == "") ||
+ (BI.isNotEmptyString(BI.trim(v))
+ && (v === this._lastChangedValue ||
+ o.validationChecker.apply(this, [BI.trim(v)]) !== false))
+ );
+ },
+
+ focus: function () {
+ if (!this.element.is(":visible")) {
+ throw new Error("input输入框在不可见下不能focus");
+ }
+ if (!this._isEditing === true) {
+ this.element.focus();
+ this.selectAll();
+ }
+ },
+
+ blur: function () {
+ if (!this.element.is(":visible")) {
+ throw new Error("input输入框在不可见下不能blur");
+ }
+ if (this._isEditing === true) {
+ this.element.blur();
+ this._blurDebounce();
+ }
+ },
+
+ selectAll: function () {
+ if (!this.element.is(":visible")) {
+ throw new Error("input输入框在不可见下不能select");
+ }
+ this.element.select();
+ this._isEditing = true;
+ },
+
+ setValue: function (textValue) {
+ this.element.val(textValue);
+ BI.nextTick(BI.bind(function () {
+ this._checkValidationOnValueChange();
+ this._defaultState();
+ if (this.isValid()) {
+ this._lastValidValue = this._lastSubmitValue = this.getValue();
+ }
+ }, this));
+ },
+
+ getValue: function () {
+ return this.element.val() || "";
+ },
+
+ isEditing: function () {
+ return this._isEditing;
+ },
+
+ getLastValidValue: function () {
+ return this._lastChangedValue;
+ },
+
+ _setValid: function () {
+ BI.Input.superclass._setValid.apply(this, arguments);
+ if (this.isValid()) {
+ this._lastChangedValue = this.getValue();
+ this.element.removeClass("bi-input-error");
+ this.fireEvent(BI.Input.EVENT_VALID, BI.trim(this.getValue()), this);
+ } else {
+ if (this._lastChangedValue === this.getValue()) {
+ this._lastChangedValue = null;
+ }
+ this.element.addClass("bi-input-error");
+ this.fireEvent(BI.Input.EVENT_ERROR, BI.trim(this.getValue()), this);
+ }
+ },
+
+ _setEnable: function (b) {
+ BI.Input.superclass._setEnable.apply(this, [b]);
+ this.element[0].disabled = !b;
+ }
+});
+BI.Input.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.Input.EVENT_FOCUS = "EVENT_FOCUS";
+BI.Input.EVENT_CLICK = "EVENT_CLICK";
+BI.Input.EVENT_BLUR = "EVENT_BLUR";
+BI.Input.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.Input.EVENT_QUICK_DOWN = "EVENT_QUICK_DOWN";
+BI.Input.EVENT_SPACE = "EVENT_SPACE";
+BI.Input.EVENT_BACKSPACE = "EVENT_BACKSPACE";
+
+BI.Input.EVENT_START = "EVENT_START";
+BI.Input.EVENT_PAUSE = "EVENT_PAUSE";
+BI.Input.EVENT_STOP = "EVENT_STOP";
+BI.Input.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.Input.EVENT_REMOVE = "EVENT_REMOVE";
+BI.Input.EVENT_EMPTY = "EVENT_EMPTY";
+BI.Input.EVENT_VALID = "EVENT_VALID";
+BI.Input.EVENT_ERROR = "EVENT_ERROR";
+BI.Input.EVENT_ENTER = "EVENT_ENTER";
+BI.Input.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.shortcut("bi.input", BI.Input);
+/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.ImageRadio = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ var conf = BI.ImageRadio.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-radio radio-icon",
+ selected: false,
+ handler: BI.emptyFn,
+ width: 16,
+ height: 16,
+ iconWidth: 16,
+ iconHeight: 16
+ });
+ },
+
+ _init: function () {
+ BI.ImageRadio.superclass._init.apply(this, arguments);
+ },
+
+ doClick: function () {
+ BI.ImageRadio.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.ImageRadio.EVENT_CHANGE);
+ }
+ }
+});
+BI.ImageRadio.EVENT_CHANGE = "Radio.EVENT_CHANGE";
+
+BI.shortcut("bi.image_radio", BI.ImageRadio);/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.Radio = BI.inherit(BI.BasicButton, {
+
+ props: {
+ baseCls: "bi-radio",
+ selected: false,
+ handler: BI.emptyFn,
+ width: 16,
+ height: 16,
+ iconWidth: 14,
+ iconHeight: 14
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.center_adapt",
+ element: this.element,
+ items: [{
+ type: "bi.layout",
+ cls: "radio-content bi-border",
+ ref: function (_ref) {
+ self.radio = _ref;
+ },
+ width: o.iconWidth,
+ height: o.iconHeight
+ }]
+ };
+ },
+
+ _setEnable: function (enable) {
+ BI.Radio.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.radio.element.removeClass("base-disabled disabled");
+ } else {
+ this.radio.element.addClass("base-disabled disabled");
+ }
+ },
+
+ doClick: function () {
+ BI.Radio.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.Radio.EVENT_CHANGE);
+ }
+ },
+
+ setSelected: function (b) {
+ BI.Radio.superclass.setSelected.apply(this, arguments);
+ if (b) {
+ this.radio.element.removeClass("bi-border").addClass("bi-high-light-background bi-high-light-border");
+ } else {
+ this.radio.element.removeClass("bi-high-light-background bi-high-light-border").addClass("bi-border");
+ }
+ }
+});
+BI.Radio.EVENT_CHANGE = "Radio.EVENT_CHANGE";
+
+BI.shortcut("bi.radio", BI.Radio);/**
+ * Created by GUY on 2015/6/26.
+ */
+
+BI.HtmlLabel = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.HtmlLabel.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-label",
+ textAlign: "center",
+ whiteSpace: "nowrap", // normal or nowrap
+ forceCenter: false, // 是否无论如何都要居中, 不考虑超出边界的情况, 在未知宽度和高度时有效
+ textWidth: null,
+ textHeight: null,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ text: ""
+ });
+ },
+
+ _createJson: function () {
+ var o = this.options;
+ return {
+ type: "bi.html",
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ lineHeight: o.textHeight,
+ text: o.text,
+ value: o.value
+ };
+ },
+
+ _init: function () {
+ BI.HtmlLabel.superclass._init.apply(this, arguments);
+
+ if (this.options.textAlign === "center") {
+ this._createCenterEl();
+ } else {
+ this._createNotCenterEl();
+ }
+ },
+
+ _createCenterEl: function () {
+ var o = this.options;
+ var json = this._createJson();
+ if (BI.isNumber(o.width) && o.width > 0) {
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ if (BI.isNumber(o.height) && o.height > 0) {
+ var gap = (o.width - o.textWidth) / 2;
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json)),
+ left: gap + o.hgap + o.lgap,
+ right: gap + o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }
+ ]
+ });
+ this.element.css({"line-height": o.height + "px"});
+ return;
+ }
+ json.width = o.textWidth;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ json.width = o.width - 2 * o.hgap;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json))
+ }]
+ });
+ return;
+ }
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ if (BI.isNumber(o.textHeight) && o.textHeight > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ if (o.forceCenter) {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ },
+
+ _createNotCenterEl: function () {
+ var o = this.options;
+ var json = this._createJson();
+ if (BI.isNumber(o.width) && o.width > 0) {
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ if (BI.isNumber(o.height) && o.height > 0) {
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }
+ ]
+ });
+ this.element.css({"line-height": o.height + "px"});
+ return;
+ }
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [this.text]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ json.width = o.width - 2 * o.hgap - o.lgap - o.rgap;
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json))
+ }]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [this.text]
+ });
+ // 父亲有line-height,而当前label是inline-block,那么他的行高一定是父亲的lineHeight,就算text上设置了line-height
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ if (BI.isNumber(o.textHeight) && o.textHeight > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ if (o.forceCenter) {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: [this.text]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ },
+
+ _setEnable: function (enable) {
+ BI.HtmlLabel.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (enable === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ setText: function (v) {
+ this.options.text = v;
+ this.text.setText(v);
+ },
+
+ getText: function () {
+ return this.options.text;
+ },
+
+ setStyle: function (css) {
+ this.text.setStyle(css);
+ },
+
+ setValue: function (v) {
+ BI.HtmlLabel.superclass.setValue.apply(this, arguments);
+ if (!this.isReadOnly()) {
+ this.text.setValue(v);
+ }
+ },
+
+ populate: function () {
+ BI.HtmlLabel.superclass.populate.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.html_label", BI.HtmlLabel);/**
+ * @class BI.IconButton
+ * @extends BI.BasicButton
+ * 图标标签
+ */
+BI.IconLabel = BI.inherit(BI.Single, {
+
+ props: {
+ baseCls: "bi-icon-label horizon-center",
+ iconWidth: null,
+ iconHeight: null
+ },
+
+ _init: function () {
+ BI.IconLabel.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]
+ });
+ }
+ }
+});
+BI.shortcut("bi.icon_label", BI.IconLabel);/**
+ * Created by GUY on 2015/6/26.
+ */
+
+BI.Label = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Label.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-label",
+ textAlign: "center",
+ whiteSpace: "nowrap", // normal or nowrap
+ forceCenter: false, // 是否无论如何都要居中, 不考虑超出边界的情况, 在未知宽度和高度时有效
+ textWidth: null,
+ textHeight: null,
+ hgap: 0,
+ vgap: 0,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ text: "",
+ py: "",
+ keyword: "",
+ highLight: false
+ });
+ },
+
+ _createJson: function () {
+ var o = this.options;
+ return {
+ type: "bi.text",
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ lineHeight: o.textHeight,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword,
+ highLight: o.highLight
+ };
+ },
+
+ _init: function () {
+ BI.Label.superclass._init.apply(this, arguments);
+
+ if (this.options.textAlign === "center") {
+ this._createCenterEl();
+ } else {
+ this._createNotCenterEl();
+ }
+ },
+
+ _createCenterEl: function () {
+ var o = this.options;
+ var json = this._createJson();
+ json.textAlign = "left";
+ if (BI.isNumber(o.width) && o.width > 0) {
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ if (BI.isNumber(o.height) && o.height > 0) {
+ var gap = (o.width - o.textWidth) / 2;
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json)),
+ left: gap + o.hgap + o.lgap,
+ right: gap + o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }
+ ]
+ });
+ this.element.css({"line-height": o.height + "px"});
+ return;
+ }
+ json.width = o.textWidth;
+ json.textAlign = o.textAlign;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ json.textAlign = o.textAlign;
+ BI.createWidget({
+ type: "bi.absolute",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ json.width = o.width - 2 * o.hgap;
+ json.textAlign = o.textAlign;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json))
+ }]
+ });
+ return;
+ }
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ if (BI.isNumber(o.textHeight) && o.textHeight > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ json.textAlign = o.textAlign;
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ // 能走到这边,说明这个text不需要换行,并且不会做任何布局包装,那么这时候就该是什么align是什么align
+ json.textAlign = o.textAlign;
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ if (o.forceCenter) {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [this.text]
+ });
+ return;
+ }
+ // 能走到这边,说明这个text不需要换行,并且不会做任何布局包装,那么这时候就该是什么align是什么align
+ json.textAlign = o.textAlign;
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ },
+
+ _createNotCenterEl: function () {
+ var o = this.options;
+ var json = this._createJson();
+ if (BI.isNumber(o.width) && o.width > 0) {
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ if (BI.isNumber(o.height) && o.height > 0) {
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }
+ ]
+ });
+ this.element.css({"line-height": o.height + "px"});
+ return;
+ }
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [this.text]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ json.width = o.width - 2 * o.hgap - o.lgap - o.rgap;
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json))
+ }]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.textWidth) && o.textWidth > 0) {
+ json.width = o.textWidth;
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [
+ {
+ el: (this.text = BI.createWidget(json))
+ }
+ ]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (o.whiteSpace == "normal") {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ scrollable: o.whiteSpace === "normal",
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ element: this,
+ items: [this.text]
+ });
+ // 父亲有line-height,而当前label是inline-block,那么他的行高一定是父亲的lineHeight,就算text上设置了line-height
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ if (BI.isNumber(o.height) && o.height > 0) {
+ if (BI.isNumber(o.textHeight) && o.textHeight > 0) {
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ BI.createWidget({
+ type: "bi.adaptive",
+ height: o.height,
+ scrollable: o.whiteSpace === "normal",
+ element: this,
+ items: [{
+ el: (this.text = BI.createWidget(json)),
+ left: o.hgap + o.lgap,
+ right: o.hgap + o.rgap,
+ top: o.vgap + o.tgap,
+ bottom: o.vgap + o.bgap
+ }]
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ this.element.css({
+ "line-height": o.height + "px"
+ });
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ return;
+ }
+ BI.extend(json, {
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap
+ });
+ if (o.forceCenter) {
+ this.text = BI.createWidget(json);
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: [this.text]
+ });
+ o.textHeight && this.element.css({"line-height": o.textHeight + "px"});
+ return;
+ }
+ this.text = BI.createWidget(BI.extend(json, {
+ element: this
+ }));
+ BI.createWidget({
+ type: "bi.layout",
+ element: this.text,
+ scrollable: o.whiteSpace === "normal"
+ });
+ },
+
+ _setEnable: function (enable) {
+ BI.Label.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (enable === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ },
+
+ 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 (v) {
+ this.options.text = v;
+ this.text.setText(v);
+ },
+
+ getText: function () {
+ return this.options.text;
+ },
+
+ setStyle: function (css) {
+ this.text.setStyle(css);
+ },
+
+ setValue: function (v) {
+ BI.Label.superclass.setValue.apply(this, arguments);
+ if (!this.isReadOnly()) {
+ this.text.setValue(v);
+ }
+ },
+
+ populate: function () {
+ BI.Label.superclass.populate.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.label", BI.Label);/**
+ * guy a元素
+ * @class BI.Link
+ * @extends BI.Text
+ */
+BI.Link = BI.inherit(BI.Label, {
+ _defaultConfig: function () {
+ var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-link display-block",
+ tagName: "a",
+ href: "",
+ target: "_blank"
+ });
+ },
+
+ _createJson: function () {
+ var o = this.options;
+ return {
+ type: "bi.a",
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ lineHeight: o.textHeight,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py,
+ href: o.href,
+ target: o.target
+ };
+ },
+
+ _init: function () {
+ BI.Link.superclass._init.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.link", BI.Link);/**
+ * guy
+ * 气泡提示
+ * @class BI.Bubble
+ * @extends BI.Tip
+ * @type {*|void|Object}
+ */
+BI.Bubble = BI.inherit(BI.Tip, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Bubble.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-bubble",
+ direction: "top",
+ text: "",
+ level: "error",
+ height: 18
+ });
+ },
+ _init: function () {
+ BI.Bubble.superclass._init.apply(this, arguments);
+ var fn = function (e) {
+ e.stopPropagation();
+ e.stopEvent();
+ return false;
+ };
+ this.element.bind({click: fn, mousedown: fn, mouseup: fn, mouseover: fn, mouseenter: fn, mouseleave: fn, mousemove: fn});
+ BI.createWidget({
+ type: "bi.left",
+ element: this,
+ items: [this["_" + this.options.direction]()]
+ });
+ },
+
+ _createBubbleText: function () {
+ var o = this.options;
+ return (this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "bubble-text" + (" bubble-" + o.level),
+ text: o.text,
+ hgap: 5,
+ height: 18
+ }));
+ },
+
+ _top: function () {
+ return BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: this._createBubbleText(),
+ height: 18
+ }, {
+ el: {
+ type: "bi.layout"
+ },
+ height: 3
+ }]
+ });
+ },
+
+ _bottom: function () {
+ return BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.layout"
+ },
+ height: 3
+ }, {
+ el: this._createBubbleText(),
+ height: 18
+ }]
+ });
+ },
+
+ _left: function () {
+ return BI.createWidget({
+ type: "bi.right",
+ items: [{
+ el: {
+ type: "bi.layout",
+ width: 3,
+ height: 18
+ }
+ }, {
+ el: this._createBubbleText()
+ }]
+ });
+ },
+
+ _right: function () {
+ return BI.createWidget({
+ type: "bi.left",
+ items: [{
+ el: {
+ type: "bi.layout",
+ width: 3,
+ height: 18
+ }
+ }, {
+ el: this._createBubbleText()
+ }]
+ });
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ }
+});
+
+BI.shortcut("bi.bubble", BI.Bubble);/**
+ * toast提示
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.Toast
+ * @extends BI.Tip
+ */
+BI.Toast = BI.inherit(BI.Tip, {
+ _const: {
+ minWidth: 200,
+ hgap: 10
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.Toast.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-toast",
+ text: "",
+ level: "success" // success或warning
+ });
+ },
+ _init: function () {
+ BI.Toast.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.element.css({
+ minWidth: this._const.minWidth + "px"
+ });
+ this.element.addClass("toast-" + o.level);
+ var fn = function (e) {
+ e.stopPropagation();
+ e.stopEvent();
+ return false;
+ };
+ this.element.bind({click: fn, mousedown: fn, mouseup: fn, mouseover: fn, mouseenter: fn, mouseleave: fn, mousemove: fn});
+ var cls = "close-font";
+ switch(o.level) {
+ case "success":
+ cls = "toast-success-font";
+ break;
+ case "error":
+ cls = "toast-error-font";
+ break;
+ case "warning":
+ cls = "toast-warning-font";
+ break;
+ case "normal":
+ default:
+ cls = "toast-message-font";
+ break;
+ }
+
+ var items = [{
+ type: "bi.icon_label",
+ cls: cls + " toast-icon",
+ width: 36
+ }, {
+ el: {
+ type: "bi.label",
+ whiteSpace: "normal",
+ text: o.text,
+ textHeight: 16,
+ textAlign: "left"
+ },
+ rgap: o.autoClose ? this._const.hgap : 0
+ }];
+
+ var columnSize = [36, ""];
+
+ if(o.autoClose === false) {
+ items.push({
+ type: "bi.icon_button",
+ cls: "close-font toast-icon",
+ handler: function () {
+ self.destroy();
+ },
+ width: 36
+ });
+ columnSize.push(36);
+ }
+
+ this.text = BI.createWidget({
+ type: "bi.horizontal_adapt",
+ element: this,
+ items: items,
+ vgap: 7,
+ columnSize: columnSize
+ });
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ },
+
+ beforeDestroy: function () {
+ this.fireEvent(BI.Toast.EVENT_DESTORY);
+ }
+});
+BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
+BI.shortcut("bi.toast", BI.Toast);/**
+ * toast提示
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.Tooltip
+ * @extends BI.Tip
+ */
+BI.Tooltip = BI.inherit(BI.Tip, {
+ _const: {
+ hgap: 5,
+ vgap: 3
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.Tooltip.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-tooltip",
+ text: "",
+ level: "success", // success或warning
+ stopEvent: false,
+ stopPropagation: false,
+ height: 20
+ });
+ },
+ _init: function () {
+ BI.Tooltip.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.element.addClass("tooltip-" + o.level);
+ var fn = function (e) {
+ o.stopPropagation && e.stopPropagation();
+ o.stopEvent && e.stopEvent();
+ };
+ this.element.bind({
+ click: fn,
+ mousedown: fn,
+ mouseup: fn,
+ mouseover: fn,
+ mouseenter: fn,
+ mouseleave: fn,
+ mousemove: fn
+ });
+
+ var texts = (o.text + "").split("\n");
+ if (texts.length > 1) {
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ hgap: this._const.hgap,
+ items: BI.map(texts, function (i, text) {
+ return {
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "normal",
+ text: text,
+ textHeight: 16
+ };
+ })
+ });
+ } else {
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: "left",
+ whiteSpace: "normal",
+ text: o.text,
+ textHeight: 16,
+ hgap: this._const.hgap,
+ vgap: this._const.vgap
+ });
+ }
+ },
+
+ setWidth: function (width) {
+ this.element.width(width - 2 * this._const.hgap);
+ },
+
+ setText: function (text) {
+ this.text && this.text.setText(text);
+ },
+
+ setLevel: function (level) {
+ this.element.removeClass("tooltip-success").removeClass("tooltip-warning");
+ this.element.addClass("tooltip-" + level);
+ }
+});
+
+BI.shortcut("bi.tooltip", BI.Tooltip);/**
+ * 下拉
+ * @class BI.Trigger
+ * @extends BI.Single
+ * @abstract
+ */
+BI.Trigger = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ _baseCls: (conf._baseCls || "") + " bi-trigger cursor-pointer",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.Trigger.superclass._init.apply(this, arguments);
+ },
+
+ setKey: function () {
+
+ },
+
+ getKey: function () {
+
+ }
+});/**
+ *
+ * 自定义树
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.CustomTree
+ * @extends BI.Single
+ */
+BI.CustomTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.CustomTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-custom-tree",
+ expander: {
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: [],
+ itemsCreator: BI.emptyFn,
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ },
+
+ _init: function () {
+ BI.CustomTree.superclass._init.apply(this, arguments);
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes) {
+ var self = this, o = this.options;
+ nodes = BI.Tree.transformToTreeFormat(nodes);
+
+ var items = [];
+ BI.each(nodes, function (i, node) {
+ if (BI.isNotEmptyArray(node.children) || node.isParent === true) {
+ var item = BI.extend({
+ type: "bi.expander",
+ el: {
+ value: node.value
+ },
+ popup: {type: "bi.custom_tree"}
+ }, BI.deepClone(o.expander), {
+ id: node.id,
+ pId: node.pId
+ });
+ var el = BI.stripEL(node);
+ if (!BI.isWidget(el)) {
+ el = BI.clone(el);
+ delete el.children;
+ BI.extend(item.el, el);
+ } else {
+ item.el = el;
+ }
+ item.popup.expander = BI.deepClone(o.expander);
+ item.items = item.popup.items = node.children;
+ item.itemsCreator = item.popup.itemsCreator = function (op) {
+ if (BI.isNotNull(op.node)) {// 从子节点传过来的itemsCreator直接向上传递
+ return o.itemsCreator.apply(self, arguments);
+ }
+ var args = Array.prototype.slice.call(arguments, 0);
+ args[0].node = node;
+ return o.itemsCreator.apply(self, args);
+ };
+ BI.isNull(item.popup.el) && (item.popup.el = BI.deepClone(o.el));
+ items.push(item);
+ } else {
+ items.push(node);
+ }
+ });
+ return items;
+ },
+
+ // 构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.tree = BI.createWidget(o.el, {
+ element: this,
+ items: this._formatItems(nodes),
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(this, [op, function (items) {
+ var args = Array.prototype.slice.call(arguments, 0);
+ args[0] = self._formatItems(items);
+ callback.apply(null, args);
+ }]);
+ },
+ value: o.value
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.CustomTree.EVENT_CHANGE, val, obj);
+ }
+ });
+ },
+
+ // 生成树方法
+ stroke: function (nodes) {
+ this.populate.apply(this, arguments);
+ },
+
+ populate: function (nodes) {
+ var args = Array.prototype.slice.call(arguments, 0);
+ if (arguments.length > 0) {
+ args[0] = this._formatItems(nodes);
+ }
+ this.tree.populate.apply(this.tree, args);
+ },
+
+ setValue: function (v) {
+ this.tree && this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree ? this.tree.getValue() : [];
+ },
+
+ getAllButtons: function () {
+ return this.tree ? this.tree.getAllButtons() : [];
+ },
+
+ getAllLeaves: function () {
+ return this.tree ? this.tree.getAllLeaves() : [];
+ },
+
+ getNodeById: function (id) {
+ return this.tree && this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree && this.tree.getNodeByValue(id);
+ },
+
+ empty: function () {
+ this.tree.empty();
+ }
+});
+BI.CustomTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.custom_tree", BI.CustomTree);/*
+ * JQuery zTree core v3.5.18
+ * http://zTree.me/
+ *
+ * Copyright (c) 2010 Hunter.z
+ *
+ * Licensed same as jquery - MIT License
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * email: hunter.z@263.net
+ * Date: 2015-06-18
+ */
+(function($){
+ var settings = {}, roots = {}, caches = {},
+ //default consts of core
+ _consts = {
+ className: {
+ BUTTON: "button",
+ LEVEL: "level",
+ ICO_LOADING: "ico_loading",
+ SWITCH: "switch"
+ },
+ event: {
+ NODECREATED: "ztree_nodeCreated",
+ CLICK: "ztree_click",
+ EXPAND: "ztree_expand",
+ COLLAPSE: "ztree_collapse",
+ ASYNC_SUCCESS: "ztree_async_success",
+ ASYNC_ERROR: "ztree_async_error",
+ REMOVE: "ztree_remove",
+ SELECTED: "ztree_selected",
+ UNSELECTED: "ztree_unselected"
+ },
+ id: {
+ A: "_a",
+ ICON: "_ico",
+ SPAN: "_span",
+ SWITCH: "_switch",
+ UL: "_ul"
+ },
+ line: {
+ ROOT: "root",
+ ROOTS: "roots",
+ CENTER: "center",
+ BOTTOM: "bottom",
+ NOLINE: "noline",
+ LINE: "line"
+ },
+ folder: {
+ OPEN: "open",
+ CLOSE: "close",
+ DOCU: "docu"
+ },
+ node: {
+ CURSELECTED: "curSelectedNode"
+ }
+ },
+ //default setting of core
+ _setting = {
+ treeId: "",
+ treeObj: null,
+ view: {
+ addDiyDom: null,
+ autoCancelSelected: true,
+ dblClickExpand: true,
+ expandSpeed: "fast",
+ fontCss: {},
+ nameIsHTML: false,
+ selectedMulti: true,
+ showIcon: true,
+ showLine: true,
+ showTitle: true,
+ txtSelectedEnable: false
+ },
+ data: {
+ key: {
+ children: "children",
+ name: "name",
+ title: "",
+ url: "url"
+ },
+ simpleData: {
+ enable: false,
+ idKey: "id",
+ pIdKey: "pId",
+ rootPId: null
+ },
+ keep: {
+ parent: false,
+ leaf: false
+ }
+ },
+ async: {
+ enable: false,
+ contentType: "application/x-www-form-urlencoded",
+ type: "post",
+ dataType: "text",
+ url: "",
+ autoParam: [],
+ otherParam: [],
+ dataFilter: null
+ },
+ callback: {
+ beforeAsync:null,
+ beforeClick:null,
+ beforeDblClick:null,
+ beforeRightClick:null,
+ beforeMouseDown:null,
+ beforeMouseUp:null,
+ beforeExpand:null,
+ beforeCollapse:null,
+ beforeRemove:null,
+
+ onAsyncError:null,
+ onAsyncSuccess:null,
+ onNodeCreated:null,
+ onClick:null,
+ onDblClick:null,
+ onRightClick:null,
+ onMouseDown:null,
+ onMouseUp:null,
+ onExpand:null,
+ onCollapse:null,
+ onRemove:null
+ }
+ },
+ //default root of core
+ //zTree use root to save full data
+ _initRoot = function (setting) {
+ var r = data.getRoot(setting);
+ if (!r) {
+ r = {};
+ data.setRoot(setting, r);
+ }
+ r[setting.data.key.children] = [];
+ r.expandTriggerFlag = false;
+ r.curSelectedList = [];
+ r.noSelection = true;
+ r.createdNodes = [];
+ r.zId = 0;
+ r._ver = (new Date()).getTime();
+ },
+ //default cache of core
+ _initCache = function(setting) {
+ var c = data.getCache(setting);
+ if (!c) {
+ c = {};
+ data.setCache(setting, c);
+ }
+ c.nodes = [];
+ c.doms = [];
+ },
+ //default bindEvent of core
+ _bindEvent = function(setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.bind(c.NODECREATED, function (event, treeId, node) {
+ tools.apply(setting.callback.onNodeCreated, [event, treeId, node]);
+ });
+
+ o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) {
+ tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]);
+ });
+
+ o.bind(c.EXPAND, function (event, treeId, node) {
+ tools.apply(setting.callback.onExpand, [event, treeId, node]);
+ });
+
+ o.bind(c.COLLAPSE, function (event, treeId, node) {
+ tools.apply(setting.callback.onCollapse, [event, treeId, node]);
+ });
+
+ o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) {
+ tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]);
+ });
+
+ o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) {
+ tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]);
+ });
+
+ o.bind(c.REMOVE, function (event, treeId, treeNode) {
+ tools.apply(setting.callback.onRemove, [event, treeId, treeNode]);
+ });
+
+ o.bind(c.SELECTED, function (event, srcEvent, treeId, node) {
+ tools.apply(setting.callback.onSelected, [srcEvent, treeId, node]);
+ });
+ o.bind(c.UNSELECTED, function (event, srcEvent, treeId, node) {
+ tools.apply(setting.callback.onUnSelected, [srcEvent, treeId, node]);
+ });
+ },
+ _unbindEvent = function(setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.unbind(c.NODECREATED)
+ .unbind(c.CLICK)
+ .unbind(c.EXPAND)
+ .unbind(c.COLLAPSE)
+ .unbind(c.ASYNC_SUCCESS)
+ .unbind(c.ASYNC_ERROR)
+ .unbind(c.REMOVE)
+ .unbind(c.SELECTED)
+ .unbind(c.UNSELECTED);
+ },
+ //default event proxy of core
+ _eventProxy = function(event) {
+ var target = event.target,
+ setting = data.getSetting(event.data.treeId),
+ tId = "", node = null,
+ nodeEventType = "", treeEventType = "",
+ nodeEventCallback = null, treeEventCallback = null,
+ tmp = null;
+
+ if (tools.eqs(event.type, "mousedown")) {
+ treeEventType = "mousedown";
+ } else if (tools.eqs(event.type, "mouseup")) {
+ treeEventType = "mouseup";
+ } else if (tools.eqs(event.type, "contextmenu")) {
+ treeEventType = "contextmenu";
+ } else if (tools.eqs(event.type, "click")) {
+ if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "switchNode";
+ } else {
+ tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+ if (tmp) {
+ tId = tools.getNodeMainDom(tmp).id;
+ nodeEventType = "clickNode";
+ }
+ }
+ } else if (tools.eqs(event.type, "dblclick")) {
+ treeEventType = "dblclick";
+ tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+ if (tmp) {
+ tId = tools.getNodeMainDom(tmp).id;
+ nodeEventType = "switchNode";
+ }
+ }
+ if (treeEventType.length > 0 && tId.length == 0) {
+ tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+ if (tmp) {tId = tools.getNodeMainDom(tmp).id;}
+ }
+ // event to node
+ if (tId.length>0) {
+ node = data.getNodeCache(setting, tId);
+ switch (nodeEventType) {
+ case "switchNode" :
+ if (!node.isParent) {
+ nodeEventType = "";
+ } else if (tools.eqs(event.type, "click")
+ || (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) {
+ nodeEventCallback = handler.onSwitchNode;
+ } else {
+ nodeEventType = "";
+ }
+ break;
+ case "clickNode" :
+ nodeEventCallback = handler.onClickNode;
+ break;
+ }
+ }
+ // event to zTree
+ switch (treeEventType) {
+ case "mousedown" :
+ treeEventCallback = handler.onZTreeMousedown;
+ break;
+ case "mouseup" :
+ treeEventCallback = handler.onZTreeMouseup;
+ break;
+ case "dblclick" :
+ treeEventCallback = handler.onZTreeDblclick;
+ break;
+ case "contextmenu" :
+ treeEventCallback = handler.onZTreeContextmenu;
+ break;
+ }
+ var proxyResult = {
+ stop: false,
+ node: node,
+ nodeEventType: nodeEventType,
+ nodeEventCallback: nodeEventCallback,
+ treeEventType: treeEventType,
+ treeEventCallback: treeEventCallback
+ };
+ return proxyResult
+ },
+ //default init node of core
+ _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
+ if (!n) return;
+ var r = data.getRoot(setting),
+ childKey = setting.data.key.children;
+ n.level = level;
+ n.tId = setting.treeId + "_" + (++r.zId);
+ n.parentTId = parentNode ? parentNode.tId : null;
+ n.open = (typeof n.open == "string") ? tools.eqs(n.open, "true") : !!n.open;
+ if (n[childKey] && n[childKey].length > 0) {
+ n.isParent = true;
+ n.zAsync = true;
+ } else {
+ n.isParent = (typeof n.isParent == "string") ? tools.eqs(n.isParent, "true") : !!n.isParent;
+ n.open = (n.isParent && !setting.async.enable) ? n.open : false;
+ n.zAsync = !n.isParent;
+ }
+ n.isFirstNode = isFirstNode;
+ n.isLastNode = isLastNode;
+ n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);};
+ n.getPreNode = function() {return data.getPreNode(setting, n);};
+ n.getNextNode = function() {return data.getNextNode(setting, n);};
+ n.isAjaxing = false;
+ data.fixPIdKeyValue(setting, n);
+ },
+ _init = {
+ bind: [_bindEvent],
+ unbind: [_unbindEvent],
+ caches: [_initCache],
+ nodes: [_initNode],
+ proxys: [_eventProxy],
+ roots: [_initRoot],
+ beforeA: [],
+ afterA: [],
+ innerBeforeA: [],
+ innerAfterA: [],
+ zTreeTools: []
+ },
+ //method of operate data
+ data = {
+ addNodeCache: function(setting, node) {
+ data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node;
+ },
+ getNodeCacheId: function(tId) {
+ return tId.substring(tId.lastIndexOf("_")+1);
+ },
+ addAfterA: function(afterA) {
+ _init.afterA.push(afterA);
+ },
+ addBeforeA: function(beforeA) {
+ _init.beforeA.push(beforeA);
+ },
+ addInnerAfterA: function(innerAfterA) {
+ _init.innerAfterA.push(innerAfterA);
+ },
+ addInnerBeforeA: function(innerBeforeA) {
+ _init.innerBeforeA.push(innerBeforeA);
+ },
+ addInitBind: function(bindEvent) {
+ _init.bind.push(bindEvent);
+ },
+ addInitUnBind: function(unbindEvent) {
+ _init.unbind.push(unbindEvent);
+ },
+ addInitCache: function(initCache) {
+ _init.caches.push(initCache);
+ },
+ addInitNode: function(initNode) {
+ _init.nodes.push(initNode);
+ },
+ addInitProxy: function(initProxy, isFirst) {
+ if (!!isFirst) {
+ _init.proxys.splice(0,0,initProxy);
+ } else {
+ _init.proxys.push(initProxy);
+ }
+ },
+ addInitRoot: function(initRoot) {
+ _init.roots.push(initRoot);
+ },
+ addNodesData: function(setting, parentNode, nodes) {
+ var childKey = setting.data.key.children;
+ if (!parentNode[childKey]) parentNode[childKey] = [];
+ if (parentNode[childKey].length > 0) {
+ parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false;
+ view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]);
+ }
+ parentNode.isParent = true;
+ parentNode[childKey] = parentNode[childKey].concat(nodes);
+ },
+ addSelectedNode: function(setting, node) {
+ var root = data.getRoot(setting);
+ if (!data.isSelectedNode(setting, node)) {
+ root.curSelectedList.push(node);
+ }
+ },
+ addCreatedNode: function(setting, node) {
+ if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
+ var root = data.getRoot(setting);
+ root.createdNodes.push(node);
+ }
+ },
+ addZTreeTools: function(zTreeTools) {
+ _init.zTreeTools.push(zTreeTools);
+ },
+ exSetting: function(s) {
+ $.extend(true, _setting, s);
+ },
+ fixPIdKeyValue: function(setting, node) {
+ if (setting.data.simpleData.enable) {
+ node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId;
+ }
+ },
+ getAfterA: function(setting, node, array) {
+ for (var i=0, j=_init.afterA.length; i
-1) {
+ result.push(nodes[i]);
+ }
+ result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value));
+ }
+ return result;
+ },
+ getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) {
+ if (!nodes) return (isSingle ? null : []);
+ var childKey = setting.data.key.children,
+ result = isSingle ? null : [];
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ if (tools.apply(filter, [nodes[i], invokeParam], false)) {
+ if (isSingle) {return nodes[i];}
+ result.push(nodes[i]);
+ }
+ var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam);
+ if (isSingle && !!tmpResult) {return tmpResult;}
+ result = isSingle ? tmpResult : result.concat(tmpResult);
+ }
+ return result;
+ },
+ getPreNode: function(setting, node) {
+ if (!node) return null;
+ var childKey = setting.data.key.children,
+ p = node.parentTId ? node.getParentNode() : data.getRoot(setting);
+ for (var i=0, l=p[childKey].length; i 0)));
+ },
+ clone: function (obj){
+ if (obj === null) return null;
+ var o = tools.isArray(obj) ? [] : {};
+ for(var i in obj){
+ o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]);
+ }
+ return o;
+ },
+ eqs: function(str1, str2) {
+ return str1.toLowerCase() === str2.toLowerCase();
+ },
+ isArray: function(arr) {
+ return Object.prototype.toString.apply(arr) === "[object Array]";
+ },
+ $: function(node, exp, setting) {
+ if (!!exp && typeof exp != "string") {
+ setting = exp;
+ exp = "";
+ }
+ if (typeof node == "string") {
+ return $(node, setting ? setting.treeObj.get(0).ownerDocument : null);
+ } else {
+ return $("#" + node.tId + exp, setting ? setting.treeObj : null);
+ }
+ },
+ getMDom: function (setting, curDom, targetExpr) {
+ if (!curDom) return null;
+ while (curDom && curDom.id !== setting.treeId) {
+ for (var i=0, l=targetExpr.length; curDom.tagName && i 0 );
+ },
+ uCanDo: function(setting, e) {
+ return true;
+ }
+ },
+ //method of operate ztree dom
+ view = {
+ addNodes: function(setting, parentNode, newNodes, isSilent) {
+ if (setting.data.keep.leaf && parentNode && !parentNode.isParent) {
+ return;
+ }
+ if (!tools.isArray(newNodes)) {
+ newNodes = [newNodes];
+ }
+ if (setting.data.simpleData.enable) {
+ newNodes = data.transformTozTreeFormat(setting, newNodes);
+ }
+ if (parentNode) {
+ var target_switchObj = $$(parentNode, consts.id.SWITCH, setting),
+ target_icoObj = $$(parentNode, consts.id.ICON, setting),
+ target_ulObj = $$(parentNode, consts.id.UL, setting);
+
+ if (!parentNode.open) {
+ view.replaceSwitchClass(parentNode, target_switchObj, consts.folder.CLOSE);
+ view.replaceIcoClass(parentNode, target_icoObj, consts.folder.CLOSE);
+ parentNode.open = false;
+ target_ulObj.css({
+ "display": "none"
+ });
+ }
+
+ data.addNodesData(setting, parentNode, newNodes);
+ view.createNodes(setting, parentNode.level + 1, newNodes, parentNode);
+ if (!isSilent) {
+ view.expandCollapseParentNode(setting, parentNode, true);
+ }
+ } else {
+ data.addNodesData(setting, data.getRoot(setting), newNodes);
+ view.createNodes(setting, 0, newNodes, null);
+ }
+ },
+ appendNodes: function(setting, level, nodes, parentNode, initFlag, openFlag) {
+ if (!nodes) return [];
+ var html = [],
+ childKey = setting.data.key.children;
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ var node = nodes[i];
+ if (initFlag) {
+ var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
+ tmpPChild = tmpPNode[childKey],
+ isFirstNode = ((tmpPChild.length == nodes.length) && (i == 0)),
+ isLastNode = (i == (nodes.length - 1));
+ data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag);
+ data.addNodeCache(setting, node);
+ }
+
+ var childHtml = [];
+ if (node[childKey] && node[childKey].length > 0) {
+ //make child html first, because checkType
+ childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open);
+ }
+ if (openFlag) {
+
+ view.makeDOMNodeMainBefore(html, setting, node);
+ view.makeDOMNodeLine(html, setting, node);
+ data.getBeforeA(setting, node, html);
+ view.makeDOMNodeNameBefore(html, setting, node);
+ data.getInnerBeforeA(setting, node, html);
+ view.makeDOMNodeIcon(html, setting, node);
+ data.getInnerAfterA(setting, node, html);
+ view.makeDOMNodeNameAfter(html, setting, node);
+ data.getAfterA(setting, node, html);
+ if (node.isParent && node.open) {
+ view.makeUlHtml(setting, node, html, childHtml.join(''));
+ }
+ view.makeDOMNodeMainAfter(html, setting, node);
+ data.addCreatedNode(setting, node);
+ }
+ }
+ return html;
+ },
+ appendParentULDom: function(setting, node) {
+ var html = [],
+ nObj = $$(node, setting);
+ if (!nObj.get(0) && !!node.parentTId) {
+ view.appendParentULDom(setting, node.getParentNode());
+ nObj = $$(node, setting);
+ }
+ var ulObj = $$(node, consts.id.UL, setting);
+ if (ulObj.get(0)) {
+ ulObj.remove();
+ }
+ var childKey = setting.data.key.children,
+ childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true);
+ view.makeUlHtml(setting, node, html, childHtml.join(''));
+ nObj.append(html.join(''));
+ },
+ asyncNode: function(setting, node, isSilent, callback) {
+ var i, l;
+ if (node && !node.isParent) {
+ tools.apply(callback);
+ return false;
+ } else if (node && node.isAjaxing) {
+ return false;
+ } else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) {
+ tools.apply(callback);
+ return false;
+ }
+ if (node) {
+ node.isAjaxing = true;
+ var icoObj = $$(node, consts.id.ICON, setting);
+ icoObj.attr({"style":"", "class":consts.className.BUTTON + " " + consts.className.ICO_LOADING});
+ }
+
+ var tmpParam = {};
+ for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) {
+ var pKey = setting.async.autoParam[i].split("="), spKey = pKey;
+ if (pKey.length>1) {
+ spKey = pKey[1];
+ pKey = pKey[0];
+ }
+ tmpParam[spKey] = node[pKey];
+ }
+ if (tools.isArray(setting.async.otherParam)) {
+ for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) {
+ tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1];
+ }
+ } else {
+ for (var p in setting.async.otherParam) {
+ tmpParam[p] = setting.async.otherParam[p];
+ }
+ }
+
+ var _tmpV = data.getRoot(setting)._ver;
+ $.ajax({
+ contentType: setting.async.contentType,
+ cache: false,
+ type: setting.async.type,
+ url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url),
+ data: tmpParam,
+ dataType: setting.async.dataType,
+ success: function(msg) {
+ if (_tmpV != data.getRoot(setting)._ver) {
+ return;
+ }
+ var newNodes = [];
+ try {
+ if (!msg || msg.length == 0) {
+ newNodes = [];
+ } else if (typeof msg == "string") {
+ newNodes = eval("(" + msg + ")");
+ } else {
+ newNodes = msg;
+ }
+ } catch(err) {
+ newNodes = msg;
+ }
+
+ if (node) {
+ node.isAjaxing = null;
+ node.zAsync = true;
+ }
+ view.setNodeLineIcos(setting, node);
+ if (newNodes && newNodes !== "") {
+ newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes);
+ view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
+ } else {
+ view.addNodes(setting, node, [], !!isSilent);
+ }
+ setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]);
+ tools.apply(callback);
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
+ if (_tmpV != data.getRoot(setting)._ver) {
+ return;
+ }
+ if (node) node.isAjaxing = null;
+ view.setNodeLineIcos(setting, node);
+ setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]);
+ }
+ });
+ return true;
+ },
+ cancelPreSelectedNode: function (setting, node, excludeNode) {
+ var list = data.getRoot(setting).curSelectedList,
+ i, n;
+ for (i=list.length-1; i>=0; i--) {
+ n = list[i];
+ if (node === n || (!node && (!excludeNode || excludeNode !== n))) {
+ $$(n, consts.id.A, setting).removeClass(consts.node.CURSELECTED);
+ if (node) {
+ data.removeSelectedNode(setting, node);
+ setting.treeObj.trigger(consts.event.UNSELECTED, [event, setting.treeId, n]);
+ break;
+ } else {
+ list.splice(i, 1);
+ setting.treeObj.trigger(consts.event.UNSELECTED, [event, setting.treeId, n]);
+ }
+ }
+ }
+ },
+ createNodeCallback: function(setting) {
+ if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
+ var root = data.getRoot(setting);
+ while (root.createdNodes.length>0) {
+ var node = root.createdNodes.shift();
+ tools.apply(setting.view.addDiyDom, [setting.treeId, node]);
+ if (!!setting.callback.onNodeCreated) {
+ setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]);
+ }
+ }
+ }
+ },
+ createNodes: function(setting, level, nodes, parentNode) {
+ if (!nodes || nodes.length == 0) return;
+ var root = data.getRoot(setting),
+ childKey = setting.data.key.children,
+ openFlag = !parentNode || parentNode.open || !!$$(parentNode[childKey][0], setting).get(0);
+ root.createdNodes = [];
+ var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag);
+ if (!parentNode) {
+ setting.treeObj.append(zTreeHtml.join(''));
+ } else {
+ var ulObj = $$(parentNode, consts.id.UL, setting);
+ if (ulObj.get(0)) {
+ ulObj.append(zTreeHtml.join(''));
+ }
+ }
+ view.createNodeCallback(setting);
+ },
+ destroy: function(setting) {
+ if (!setting) return;
+ data.initCache(setting);
+ data.initRoot(setting);
+ event.unbindTree(setting);
+ event.unbindEvent(setting);
+ setting.treeObj.empty();
+ delete settings[setting.treeId];
+ },
+ expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) {
+ var root = data.getRoot(setting),
+ childKey = setting.data.key.children;
+ if (!node) {
+ tools.apply(callback, []);
+ return;
+ }
+ if (root.expandTriggerFlag) {
+ var _callback = callback;
+ callback = function(){
+ if (_callback) _callback();
+ if (node.open) {
+ setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]);
+ } else {
+ setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]);
+ }
+ };
+ root.expandTriggerFlag = false;
+ }
+ if (!node.open && node.isParent && ((!$$(node, consts.id.UL, setting).get(0)) || (node[childKey] && node[childKey].length>0 && !$$(node[childKey][0], setting).get(0)))) {
+ view.appendParentULDom(setting, node);
+ view.createNodeCallback(setting);
+ }
+ if (node.open == expandFlag) {
+ tools.apply(callback, []);
+ return;
+ }
+ var ulObj = $$(node, consts.id.UL, setting),
+ switchObj = $$(node, consts.id.SWITCH, setting),
+ icoObj = $$(node, consts.id.ICON, setting);
+
+ if (node.isParent) {
+ node.open = !node.open;
+ if (node.iconOpen && node.iconClose) {
+ icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
+ }
+
+ if (node.open) {
+ view.replaceSwitchClass(node, switchObj, consts.folder.OPEN);
+ view.replaceIcoClass(node, icoObj, consts.folder.OPEN);
+ if (animateFlag == false || setting.view.expandSpeed == "") {
+ ulObj.show();
+ tools.apply(callback, []);
+ } else {
+ if (node[childKey] && node[childKey].length > 0) {
+ ulObj.slideDown(setting.view.expandSpeed, callback);
+ } else {
+ ulObj.show();
+ tools.apply(callback, []);
+ }
+ }
+ } else {
+ view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE);
+ view.replaceIcoClass(node, icoObj, consts.folder.CLOSE);
+ if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) {
+ ulObj.hide();
+ tools.apply(callback, []);
+ } else {
+ ulObj.slideUp(setting.view.expandSpeed, callback);
+ }
+ }
+ } else {
+ tools.apply(callback, []);
+ }
+ },
+ expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) {
+ if (!node) return;
+ if (!node.parentTId) {
+ view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback);
+ return;
+ } else {
+ view.expandCollapseNode(setting, node, expandFlag, animateFlag);
+ }
+ if (node.parentTId) {
+ view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback);
+ }
+ },
+ expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) {
+ var root = data.getRoot(setting),
+ childKey = setting.data.key.children,
+ treeNodes = (node) ? node[childKey]: root[childKey],
+ selfAnimateSign = (node) ? false : animateFlag,
+ expandTriggerFlag = data.getRoot(setting).expandTriggerFlag;
+ data.getRoot(setting).expandTriggerFlag = false;
+ if (treeNodes) {
+ for (var i = 0, l = treeNodes.length; i < l; i++) {
+ if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign);
+ }
+ }
+ data.getRoot(setting).expandTriggerFlag = expandTriggerFlag;
+ view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback );
+ },
+ isSelectedNode: function (setting, node) {
+ if (!node) {
+ return false;
+ }
+ var list = data.getRoot(setting).curSelectedList,
+ i;
+ for (i=list.length-1; i>=0; i--) {
+ if (node === list[i]) {
+ return true;
+ }
+ }
+ return false;
+ },
+ makeDOMNodeIcon: function(html, setting, node) {
+ var nameStr = data.getNodeName(setting, node),
+ name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(//g,'>');
+ html.push("",name," ");
+ },
+ makeDOMNodeLine: function(html, setting, node) {
+ html.push(" ");
+ },
+ makeDOMNodeMainAfter: function(html, setting, node) {
+ html.push("");
+ },
+ makeDOMNodeMainBefore: function(html, setting, node) {
+ html.push("");
+ },
+ makeDOMNodeNameAfter: function(html, setting, node) {
+ html.push("");
+ },
+ makeDOMNodeNameBefore: function(html, setting, node) {
+ var title = data.getNodeTitle(setting, node),
+ url = view.makeNodeUrl(setting, node),
+ fontcss = view.makeNodeFontCss(setting, node),
+ fontStyle = [];
+ for (var f in fontcss) {
+ fontStyle.push(f, ":", fontcss[f], ";");
+ }
+ html.push(" 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''),
+ "'");
+ if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(//g,'>'),"'");}
+ html.push(">");
+ },
+ makeNodeFontCss: function(setting, node) {
+ var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss);
+ return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {};
+ },
+ makeNodeIcoClass: function(setting, node) {
+ var icoCss = ["ico"];
+ if (!node.isAjaxing) {
+ icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0];
+ if (node.isParent) {
+ icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
+ } else {
+ icoCss.push(consts.folder.DOCU);
+ }
+ }
+ return consts.className.BUTTON + " " + icoCss.join('_');
+ },
+ makeNodeIcoStyle: function(setting, node) {
+ var icoStyle = [];
+ if (!node.isAjaxing) {
+ var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon;
+ if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;");
+ if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) {
+ icoStyle.push("width:0px;height:0px;");
+ }
+ }
+ return icoStyle.join('');
+ },
+ makeNodeLineClass: function(setting, node) {
+ var lineClass = [];
+ if (setting.view.showLine) {
+ if (node.level == 0 && node.isFirstNode && node.isLastNode) {
+ lineClass.push(consts.line.ROOT);
+ } else if (node.level == 0 && node.isFirstNode) {
+ lineClass.push(consts.line.ROOTS);
+ } else if (node.isLastNode) {
+ lineClass.push(consts.line.BOTTOM);
+ } else {
+ lineClass.push(consts.line.CENTER);
+ }
+ } else {
+ lineClass.push(consts.line.NOLINE);
+ }
+ if (node.isParent) {
+ lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
+ } else {
+ lineClass.push(consts.folder.DOCU);
+ }
+ return view.makeNodeLineClassEx(node) + lineClass.join('_');
+ },
+ makeNodeLineClassEx: function(node) {
+ return consts.className.BUTTON + " " + consts.className.LEVEL + node.level + " " + consts.className.SWITCH + " ";
+ },
+ makeNodeTarget: function(node) {
+ return (node.target || "_blank");
+ },
+ makeNodeUrl: function(setting, node) {
+ var urlKey = setting.data.key.url;
+ return node[urlKey] ? node[urlKey] : null;
+ },
+ makeUlHtml: function(setting, node, html, content) {
+ html.push("");
+ html.push(content);
+ html.push(" ");
+ },
+ makeUlLineClass: function(setting, node) {
+ return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : "");
+ },
+ removeChildNodes: function(setting, node) {
+ if (!node) return;
+ var childKey = setting.data.key.children,
+ nodes = node[childKey];
+ if (!nodes) return;
+
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ data.removeNodeCache(setting, nodes[i]);
+ }
+ data.removeSelectedNode(setting);
+ delete node[childKey];
+
+ if (!setting.data.keep.parent) {
+ node.isParent = false;
+ node.open = false;
+ var tmp_switchObj = $$(node, consts.id.SWITCH, setting),
+ tmp_icoObj = $$(node, consts.id.ICON, setting);
+ view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU);
+ view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU);
+ $$(node, consts.id.UL, setting).remove();
+ } else {
+ $$(node, consts.id.UL, setting).empty();
+ }
+ },
+ setFirstNode: function(setting, parentNode) {
+ var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
+ if ( childLength > 0) {
+ parentNode[childKey][0].isFirstNode = true;
+ }
+ },
+ setLastNode: function(setting, parentNode) {
+ var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
+ if ( childLength > 0) {
+ parentNode[childKey][childLength - 1].isLastNode = true;
+ }
+ },
+ removeNode: function(setting, node) {
+ var root = data.getRoot(setting),
+ childKey = setting.data.key.children,
+ parentNode = (node.parentTId) ? node.getParentNode() : root;
+
+ node.isFirstNode = false;
+ node.isLastNode = false;
+ node.getPreNode = function() {return null;};
+ node.getNextNode = function() {return null;};
+
+ if (!data.getNodeCache(setting, node.tId)) {
+ return;
+ }
+
+ $$(node, setting).remove();
+ data.removeNodeCache(setting, node);
+ data.removeSelectedNode(setting, node);
+
+ for (var i = 0, l = parentNode[childKey].length; i < l; i++) {
+ if (parentNode[childKey][i].tId == node.tId) {
+ parentNode[childKey].splice(i, 1);
+ break;
+ }
+ }
+ view.setFirstNode(setting, parentNode);
+ view.setLastNode(setting, parentNode);
+
+ var tmp_ulObj,tmp_switchObj,tmp_icoObj,
+ childLength = parentNode[childKey].length;
+
+ //repair nodes old parent
+ if (!setting.data.keep.parent && childLength == 0) {
+ //old parentNode has no child nodes
+ parentNode.isParent = false;
+ parentNode.open = false;
+ tmp_ulObj = $$(parentNode, consts.id.UL, setting);
+ tmp_switchObj = $$(parentNode, consts.id.SWITCH, setting);
+ tmp_icoObj = $$(parentNode, consts.id.ICON, setting);
+ view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU);
+ view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU);
+ tmp_ulObj.css("display", "none");
+
+ } else if (setting.view.showLine && childLength > 0) {
+ //old parentNode has child nodes
+ var newLast = parentNode[childKey][childLength - 1];
+ tmp_ulObj = $$(newLast, consts.id.UL, setting);
+ tmp_switchObj = $$(newLast, consts.id.SWITCH, setting);
+ tmp_icoObj = $$(newLast, consts.id.ICON, setting);
+ if (parentNode == root) {
+ if (parentNode[childKey].length == 1) {
+ //node was root, and ztree has only one root after move node
+ view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT);
+ } else {
+ var tmp_first_switchObj = $$(parentNode[childKey][0], consts.id.SWITCH, setting);
+ view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS);
+ view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
+ }
+ } else {
+ view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
+ }
+ tmp_ulObj.removeClass(consts.line.LINE);
+ }
+ },
+ replaceIcoClass: function(node, obj, newName) {
+ if (!obj || node.isAjaxing) return;
+ var tmpName = obj.attr("class");
+ if (tmpName == undefined) return;
+ var tmpList = tmpName.split("_");
+ switch (newName) {
+ case consts.folder.OPEN:
+ case consts.folder.CLOSE:
+ case consts.folder.DOCU:
+ tmpList[tmpList.length-1] = newName;
+ break;
+ }
+ obj.attr("class", tmpList.join("_"));
+ },
+ replaceSwitchClass: function(node, obj, newName) {
+ if (!obj) return;
+ var tmpName = obj.attr("class");
+ if (tmpName == undefined) return;
+ var tmpList = tmpName.split("_");
+ switch (newName) {
+ case consts.line.ROOT:
+ case consts.line.ROOTS:
+ case consts.line.CENTER:
+ case consts.line.BOTTOM:
+ case consts.line.NOLINE:
+ tmpList[0] = view.makeNodeLineClassEx(node) + newName;
+ break;
+ case consts.folder.OPEN:
+ case consts.folder.CLOSE:
+ case consts.folder.DOCU:
+ tmpList[1] = newName;
+ break;
+ }
+ obj.attr("class", tmpList.join("_"));
+ if (newName !== consts.folder.DOCU) {
+ obj.removeAttr("disabled");
+ } else {
+ obj.attr("disabled", "disabled");
+ }
+ },
+ selectNode: function(setting, node, addFlag) {
+ if (!addFlag) {
+ view.cancelPreSelectedNode(setting, null, node);
+ }
+ $$(node, consts.id.A, setting).addClass(consts.node.CURSELECTED);
+ data.addSelectedNode(setting, node);
+ setting.treeObj.trigger(consts.event.SELECTED, [event, setting.treeId, node]);
+ },
+ setNodeFontCss: function(setting, treeNode) {
+ var aObj = $$(treeNode, consts.id.A, setting),
+ fontCss = view.makeNodeFontCss(setting, treeNode);
+ if (fontCss) {
+ aObj.css(fontCss);
+ }
+ },
+ setNodeLineIcos: function(setting, node) {
+ if (!node) return;
+ var switchObj = $$(node, consts.id.SWITCH, setting),
+ ulObj = $$(node, consts.id.UL, setting),
+ icoObj = $$(node, consts.id.ICON, setting),
+ ulLine = view.makeUlLineClass(setting, node);
+ if (ulLine.length==0) {
+ ulObj.removeClass(consts.line.LINE);
+ } else {
+ ulObj.addClass(ulLine);
+ }
+ switchObj.attr("class", view.makeNodeLineClass(setting, node));
+ if (node.isParent) {
+ switchObj.removeAttr("disabled");
+ } else {
+ switchObj.attr("disabled", "disabled");
+ }
+ icoObj.removeAttr("style");
+ icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
+ icoObj.attr("class", view.makeNodeIcoClass(setting, node));
+ },
+ setNodeName: function(setting, node) {
+ var title = data.getNodeTitle(setting, node),
+ nObj = $$(node, consts.id.SPAN, setting);
+ nObj.empty();
+ if (setting.view.nameIsHTML) {
+ nObj.html(data.getNodeName(setting, node));
+ } else {
+ nObj.text(data.getNodeName(setting, node));
+ }
+ if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) {
+ var aObj = $$(node, consts.id.A, setting);
+ aObj.attr("title", !title ? "" : title);
+ }
+ },
+ setNodeTarget: function(setting, node) {
+ var aObj = $$(node, consts.id.A, setting);
+ aObj.attr("target", view.makeNodeTarget(node));
+ },
+ setNodeUrl: function(setting, node) {
+ var aObj = $$(node, consts.id.A, setting),
+ url = view.makeNodeUrl(setting, node);
+ if (url == null || url.length == 0) {
+ aObj.removeAttr("href");
+ } else {
+ aObj.attr("href", url);
+ }
+ },
+ switchNode: function(setting, node) {
+ if (node.open || !tools.canAsync(setting, node)) {
+ view.expandCollapseNode(setting, node, !node.open);
+ } else if (setting.async.enable) {
+ if (!view.asyncNode(setting, node)) {
+ view.expandCollapseNode(setting, node, !node.open);
+ return;
+ }
+ } else if (node) {
+ view.expandCollapseNode(setting, node, !node.open);
+ }
+ }
+ };
+ // zTree defind
+ $.fn.zTree = {
+ consts : _consts,
+ _z : {
+ tools: tools,
+ view: view,
+ event: event,
+ data: data
+ },
+ getZTreeObj: function(treeId) {
+ var o = data.getZTreeTools(treeId);
+ return o ? o : null;
+ },
+ destroy: function(treeId) {
+ if (!!treeId && treeId.length > 0) {
+ view.destroy(data.getSetting(treeId));
+ } else {
+ for(var s in settings) {
+ view.destroy(settings[s]);
+ }
+ }
+ },
+ init: function(obj, zSetting, zNodes) {
+ var setting = tools.clone(_setting);
+ $.extend(true, setting, zSetting);
+ setting.treeId = obj.attr("id");
+ setting.treeObj = obj;
+ setting.treeObj.empty();
+ settings[setting.treeId] = setting;
+ //For some older browser,(e.g., ie6)
+ if(typeof document.body.style.maxHeight === "undefined") {
+ setting.view.expandSpeed = "";
+ }
+ data.initRoot(setting);
+ var root = data.getRoot(setting),
+ childKey = setting.data.key.children;
+ zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : [];
+ if (setting.data.simpleData.enable) {
+ root[childKey] = data.transformTozTreeFormat(setting, zNodes);
+ } else {
+ root[childKey] = zNodes;
+ }
+
+ data.initCache(setting);
+ event.unbindTree(setting);
+ event.bindTree(setting);
+ event.unbindEvent(setting);
+ event.bindEvent(setting);
+
+ var zTreeTools = {
+ setting : setting,
+ addNodes : function(parentNode, newNodes, isSilent) {
+ if (!newNodes) return null;
+ if (!parentNode) parentNode = null;
+ if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null;
+ var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]);
+ function addCallback() {
+ view.addNodes(setting, parentNode, xNewNodes, (isSilent==true));
+ }
+
+ if (tools.canAsync(setting, parentNode)) {
+ view.asyncNode(setting, parentNode, isSilent, addCallback);
+ } else {
+ addCallback();
+ }
+ return xNewNodes;
+ },
+ cancelSelectedNode : function(node) {
+ view.cancelPreSelectedNode(setting, node);
+ },
+ destroy : function() {
+ view.destroy(setting);
+ },
+ expandAll : function(expandFlag) {
+ expandFlag = !!expandFlag;
+ view.expandCollapseSonNode(setting, null, expandFlag, true);
+ return expandFlag;
+ },
+ expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) {
+ if (!node || !node.isParent) return null;
+ if (expandFlag !== true && expandFlag !== false) {
+ expandFlag = !node.open;
+ }
+ callbackFlag = !!callbackFlag;
+
+ if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) {
+ return null;
+ } else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) {
+ return null;
+ }
+ if (expandFlag && node.parentTId) {
+ view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, false);
+ }
+ if (expandFlag === node.open && !sonSign) {
+ return null;
+ }
+
+ data.getRoot(setting).expandTriggerFlag = callbackFlag;
+ if (!tools.canAsync(setting, node) && sonSign) {
+ view.expandCollapseSonNode(setting, node, expandFlag, true, function() {
+ if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
+ });
+ } else {
+ node.open = !expandFlag;
+ view.switchNode(this.setting, node);
+ if (focus !== false) {try{$$(node, setting).focus().blur();}catch(e){}}
+ }
+ return expandFlag;
+ },
+ getNodes : function() {
+ return data.getNodes(setting);
+ },
+ getNodeByParam : function(key, value, parentNode) {
+ if (!key) return null;
+ return data.getNodeByParam(setting, parentNode?parentNode[setting.data.key.children]:data.getNodes(setting), key, value);
+ },
+ getNodeByTId : function(tId) {
+ return data.getNodeCache(setting, tId);
+ },
+ getNodesByParam : function(key, value, parentNode) {
+ if (!key) return null;
+ return data.getNodesByParam(setting, parentNode?parentNode[setting.data.key.children]:data.getNodes(setting), key, value);
+ },
+ getNodesByParamFuzzy : function(key, value, parentNode) {
+ if (!key) return null;
+ return data.getNodesByParamFuzzy(setting, parentNode?parentNode[setting.data.key.children]:data.getNodes(setting), key, value);
+ },
+ getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) {
+ isSingle = !!isSingle;
+ if (!filter || (typeof filter != "function")) return (isSingle ? null : []);
+ return data.getNodesByFilter(setting, parentNode?parentNode[setting.data.key.children]:data.getNodes(setting), filter, isSingle, invokeParam);
+ },
+ getNodeIndex : function(node) {
+ if (!node) return null;
+ var childKey = setting.data.key.children,
+ parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
+ for (var i=0, l = parentNode[childKey].length; i < l; i++) {
+ if (parentNode[childKey][i] == node) return i;
+ }
+ return -1;
+ },
+ getSelectedNodes : function() {
+ var r = [], list = data.getRoot(setting).curSelectedList;
+ for (var i=0, l=list.length; i 0) {
+ view.createNodes(setting, 0, root[childKey]);
+ } else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
+ view.asyncNode(setting);
+ }
+ return zTreeTools;
+ }
+ };
+
+ var zt = $.fn.zTree,
+ $$ = tools.$,
+ consts = zt.consts;
+})(jQuery);/*
+ * JQuery zTree excheck v3.5.18
+ * http://zTree.me/
+ *
+ * Copyright (c) 2010 Hunter.z
+ *
+ * Licensed same as jquery - MIT License
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * email: hunter.z@263.net
+ * Date: 2015-06-18
+ */
+(function($){
+ //default consts of excheck
+ var _consts = {
+ event: {
+ CHECK: "ztree_check"
+ },
+ id: {
+ CHECK: "_check"
+ },
+ checkbox: {
+ STYLE: "checkbox",
+ DEFAULT: "chk",
+ DISABLED: "disable",
+ FALSE: "false",
+ TRUE: "true",
+ FULL: "full",
+ PART: "part",
+ FOCUS: "focus"
+ },
+ radio: {
+ STYLE: "radio",
+ TYPE_ALL: "all",
+ TYPE_LEVEL: "level"
+ }
+ },
+ //default setting of excheck
+ _setting = {
+ check: {
+ enable: false,
+ autoCheckTrigger: false,
+ chkStyle: _consts.checkbox.STYLE,
+ nocheckInherit: false,
+ chkDisabledInherit: false,
+ radioType: _consts.radio.TYPE_LEVEL,
+ chkboxType: {
+ "Y": "ps",
+ "N": "ps"
+ }
+ },
+ data: {
+ key: {
+ checked: "checked"
+ }
+ },
+ callback: {
+ beforeCheck:null,
+ onCheck:null
+ }
+ },
+ //default root of excheck
+ _initRoot = function (setting) {
+ var r = data.getRoot(setting);
+ r.radioCheckedList = [];
+ },
+ //default cache of excheck
+ _initCache = function(treeId) {},
+ //default bind event of excheck
+ _bindEvent = function(setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
+ event.srcEvent = srcEvent;
+ tools.apply(setting.callback.onCheck, [event, treeId, node]);
+ });
+ },
+ _unbindEvent = function(setting) {
+ var o = setting.treeObj,
+ c = consts.event;
+ o.unbind(c.CHECK);
+ },
+ //default event proxy of excheck
+ _eventProxy = function(e) {
+ var target = e.target,
+ setting = data.getSetting(e.data.treeId),
+ tId = "", node = null,
+ nodeEventType = "", treeEventType = "",
+ nodeEventCallback = null, treeEventCallback = null;
+
+ if (tools.eqs(e.type, "mouseover")) {
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "mouseoverCheck";
+ }
+ } else if (tools.eqs(e.type, "mouseout")) {
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "mouseoutCheck";
+ }
+ } else if (tools.eqs(e.type, "click")) {
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
+ tId = tools.getNodeMainDom(target).id;
+ nodeEventType = "checkNode";
+ }
+ }
+ if (tId.length>0) {
+ node = data.getNodeCache(setting, tId);
+ switch (nodeEventType) {
+ case "checkNode" :
+ nodeEventCallback = _handler.onCheckNode;
+ break;
+ case "mouseoverCheck" :
+ nodeEventCallback = _handler.onMouseoverCheck;
+ break;
+ case "mouseoutCheck" :
+ nodeEventCallback = _handler.onMouseoutCheck;
+ break;
+ }
+ }
+ var proxyResult = {
+ stop: nodeEventType === "checkNode",
+ node: node,
+ nodeEventType: nodeEventType,
+ nodeEventCallback: nodeEventCallback,
+ treeEventType: treeEventType,
+ treeEventCallback: treeEventCallback
+ };
+ return proxyResult
+ },
+ //default init node of excheck
+ _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
+ if (!n) return;
+ var checkedKey = setting.data.key.checked;
+ if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
+ n[checkedKey] = !!n[checkedKey];
+ n.checkedOld = n[checkedKey];
+ if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
+ n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
+ if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
+ n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
+ if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
+ n.halfCheck = !!n.halfCheck;
+ n.check_Child_State = -1;
+ n.check_Focus = false;
+ n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
+
+ if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) {
+ var r = data.getRoot(setting);
+ r.radioCheckedList.push(n);
+ }
+ },
+ //add dom for check
+ _beforeA = function(setting, node, html) {
+ var checkedKey = setting.data.key.checked;
+ if (setting.check.enable) {
+ data.makeChkFlag(setting, node);
+ html.push(" ");
+ }
+ },
+ //update zTreeObj, add method of check
+ _zTreeTools = function(setting, zTreeTools) {
+ zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
+ var checkedKey = this.setting.data.key.checked;
+ if (node.chkDisabled === true) return;
+ if (checked !== true && checked !== false) {
+ checked = !node[checkedKey];
+ }
+ callbackFlag = !!callbackFlag;
+
+ if (node[checkedKey] === checked && !checkTypeFlag) {
+ return;
+ } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
+ return;
+ }
+ if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
+ node[checkedKey] = checked;
+ var checkObj = $$(node, consts.id.CHECK, this.setting);
+ if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
+ view.setChkClass(this.setting, checkObj, node);
+ view.repairParentChkClassWithSelf(this.setting, node);
+ if (callbackFlag) {
+ this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]);
+ }
+ }
+ }
+
+ zTreeTools.checkAllNodes = function(checked) {
+ view.repairAllChk(this.setting, !!checked);
+ }
+
+ zTreeTools.getCheckedNodes = function(checked) {
+ var childKey = this.setting.data.key.children;
+ checked = (checked !== false);
+ return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
+ }
+
+ zTreeTools.getChangeCheckedNodes = function() {
+ var childKey = this.setting.data.key.children;
+ return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
+ }
+
+ zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
+ disabled = !!disabled;
+ inheritParent = !!inheritParent;
+ inheritChildren = !!inheritChildren;
+ view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
+ view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
+ }
+
+ var _updateNode = zTreeTools.updateNode;
+ zTreeTools.updateNode = function(node, checkTypeFlag) {
+ if (_updateNode) _updateNode.apply(zTreeTools, arguments);
+ if (!node || !this.setting.check.enable) return;
+ var nObj = $$(node, this.setting);
+ if (nObj.get(0) && tools.uCanDo(this.setting)) {
+ var checkObj = $$(node, consts.id.CHECK, this.setting);
+ if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
+ view.setChkClass(this.setting, checkObj, node);
+ view.repairParentChkClassWithSelf(this.setting, node);
+ }
+ }
+ },
+ //method of operate data
+ _data = {
+ getRadioCheckedList: function(setting) {
+ var checkedList = data.getRoot(setting).radioCheckedList;
+ for (var i=0, j=checkedList.length; i -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
+ };
+ return r;
+ },
+ getTreeCheckedNodes: function(setting, nodes, checked, results) {
+ if (!nodes) return [];
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
+ results = !results ? [] : results;
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
+ results.push(nodes[i]);
+ if(onlyOne) {
+ break;
+ }
+ }
+ data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
+ if(onlyOne && results.length > 0) {
+ break;
+ }
+ }
+ return results;
+ },
+ getTreeChangeCheckedNodes: function(setting, nodes, results) {
+ if (!nodes) return [];
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked;
+ results = !results ? [] : results;
+ for (var i = 0, l = nodes.length; i < l; i++) {
+ if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
+ results.push(nodes[i]);
+ }
+ data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
+ }
+ return results;
+ },
+ makeChkFlag: function(setting, node) {
+ if (!node) return;
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ chkFlag = -1;
+ if (node[childKey]) {
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
+ var cNode = node[childKey][i];
+ var tmp = -1;
+ if (setting.check.chkStyle == consts.radio.STYLE) {
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
+ tmp = cNode.check_Child_State;
+ } else if (cNode.halfCheck === true) {
+ tmp = 2;
+ } else if (cNode[checkedKey]) {
+ tmp = 2;
+ } else {
+ tmp = cNode.check_Child_State > 0 ? 2:0;
+ }
+ if (tmp == 2) {
+ chkFlag = 2; break;
+ } else if (tmp == 0){
+ chkFlag = 0;
+ }
+ } else if (setting.check.chkStyle == consts.checkbox.STYLE) {
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
+ tmp = cNode.check_Child_State;
+ } else if (cNode.halfCheck === true) {
+ tmp = 1;
+ } else if (cNode[checkedKey] ) {
+ tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
+ } else {
+ tmp = (cNode.check_Child_State > 0) ? 1 : 0;
+ }
+ if (tmp === 1) {
+ chkFlag = 1; break;
+ } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
+ chkFlag = 1; break;
+ } else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
+ chkFlag = 1; break;
+ } else if (tmp > -1) {
+ chkFlag = tmp;
+ }
+ }
+ }
+ }
+ node.check_Child_State = chkFlag;
+ }
+ },
+ //method of event proxy
+ _event = {
+
+ },
+ //method of event handler
+ _handler = {
+ onCheckNode: function (event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkedKey = setting.data.key.checked;
+ if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
+ node[checkedKey] = !node[checkedKey];
+ view.checkNodeRelation(setting, node);
+ var checkObj = $$(node, consts.id.CHECK, setting);
+ view.setChkClass(setting, checkObj, node);
+ view.repairParentChkClassWithSelf(setting, node);
+ setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
+ return true;
+ },
+ onMouseoverCheck: function(event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkObj = $$(node, consts.id.CHECK, setting);
+ node.check_Focus = true;
+ view.setChkClass(setting, checkObj, node);
+ return true;
+ },
+ onMouseoutCheck: function(event, node) {
+ if (node.chkDisabled === true) return false;
+ var setting = data.getSetting(event.data.treeId),
+ checkObj = $$(node, consts.id.CHECK, setting);
+ node.check_Focus = false;
+ view.setChkClass(setting, checkObj, node);
+ return true;
+ }
+ },
+ //method of tools for zTree
+ _tools = {
+
+ },
+ //method of operate ztree dom
+ _view = {
+ checkNodeRelation: function(setting, node) {
+ var pNode, i, l,
+ childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ r = consts.radio;
+ if (setting.check.chkStyle == r.STYLE) {
+ var checkedList = data.getRadioCheckedList(setting);
+ if (node[checkedKey]) {
+ if (setting.check.radioType == r.TYPE_ALL) {
+ for (i = checkedList.length-1; i >= 0; i--) {
+ pNode = checkedList[i];
+ if (pNode[checkedKey] && pNode != node) {
+ pNode[checkedKey] = false;
+ checkedList.splice(i, 1);
+
+ view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
+ if (pNode.parentTId != node.parentTId) {
+ view.repairParentChkClassWithSelf(setting, pNode);
+ }
+ }
+ }
+ checkedList.push(node);
+ } else {
+ var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
+ for (i = 0, l = parentNode[childKey].length; i < l; i++) {
+ pNode = parentNode[childKey][i];
+ if (pNode[checkedKey] && pNode != node) {
+ pNode[checkedKey] = false;
+ view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
+ }
+ }
+ }
+ } else if (setting.check.radioType == r.TYPE_ALL) {
+ for (i = 0, l = checkedList.length; i < l; i++) {
+ if (node == checkedList[i]) {
+ checkedList.splice(i, 1);
+ break;
+ }
+ }
+ }
+
+ } else {
+ if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
+ view.setSonNodeCheckBox(setting, node, true);
+ }
+ if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
+ view.setSonNodeCheckBox(setting, node, false);
+ }
+ if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
+ view.setParentNodeCheckBox(setting, node, true);
+ }
+ if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
+ view.setParentNodeCheckBox(setting, node, false);
+ }
+ }
+ },
+ makeChkClass: function(setting, node) {
+ var checkedKey = setting.data.key.checked,
+ c = consts.checkbox, r = consts.radio,
+ fullStyle = "";
+ if (node.chkDisabled === true) {
+ fullStyle = c.DISABLED;
+ } else if (node.halfCheck) {
+ fullStyle = c.PART;
+ } else if (setting.check.chkStyle == r.STYLE) {
+ fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
+ } else {
+ fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
+ }
+ var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
+ chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
+ return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
+ },
+ repairAllChk: function(setting, checked) {
+ if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
+ var checkedKey = setting.data.key.checked,
+ childKey = setting.data.key.children,
+ root = data.getRoot(setting);
+ for (var i = 0, l = root[childKey].length; i 0) {
+ view.repairParentChkClass(setting, node[childKey][0]);
+ } else {
+ view.repairParentChkClass(setting, node);
+ }
+ },
+ repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
+ if (!node) return;
+ var childKey = setting.data.key.children;
+ if (node.chkDisabled != chkDisabled) {
+ node.chkDisabled = chkDisabled;
+ }
+ view.repairChkClass(setting, node);
+ if (node[childKey] && inherit) {
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
+ var sNode = node[childKey][i];
+ view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
+ }
+ }
+ },
+ repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
+ if (!node) return;
+ if (node.chkDisabled != chkDisabled && inherit) {
+ node.chkDisabled = chkDisabled;
+ }
+ view.repairChkClass(setting, node);
+ view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
+ },
+ setChkClass: function(setting, obj, node) {
+ if (!obj) return;
+ if (node.nocheck === true) {
+ obj.hide();
+ } else {
+ obj.show();
+ }
+ obj.attr('class', view.makeChkClass(setting, node));
+ },
+ setParentNodeCheckBox: function(setting, node, value, srcNode) {
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ checkObj = $$(node, consts.id.CHECK, setting);
+ if (!srcNode) srcNode = node;
+ data.makeChkFlag(setting, node);
+ if (node.nocheck !== true && node.chkDisabled !== true) {
+ node[checkedKey] = value;
+ view.setChkClass(setting, checkObj, node);
+ if (setting.check.autoCheckTrigger && node != srcNode) {
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
+ }
+ }
+ if (node.parentTId) {
+ var pSign = true;
+ if (!value) {
+ var pNodes = node.getParentNode()[childKey];
+ for (var i = 0, l = pNodes.length; i < l; i++) {
+ if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
+ || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
+ pSign = false;
+ break;
+ }
+ }
+ }
+ if (pSign) {
+ view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
+ }
+ }
+ },
+ setSonNodeCheckBox: function(setting, node, value, srcNode) {
+ if (!node) return;
+ var childKey = setting.data.key.children,
+ checkedKey = setting.data.key.checked,
+ checkObj = $$(node, consts.id.CHECK, setting);
+ if (!srcNode) srcNode = node;
+
+ var hasDisable = false;
+ if (node[childKey]) {
+ for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
+ var sNode = node[childKey][i];
+ view.setSonNodeCheckBox(setting, sNode, value, srcNode);
+ if (sNode.chkDisabled === true) hasDisable = true;
+ }
+ }
+
+ if (node != data.getRoot(setting) && node.chkDisabled !== true) {
+ if (hasDisable && node.nocheck !== true) {
+ data.makeChkFlag(setting, node);
+ }
+ if (node.nocheck !== true && node.chkDisabled !== true) {
+ node[checkedKey] = value;
+ if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
+ } else {
+ node.check_Child_State = -1;
+ }
+ view.setChkClass(setting, checkObj, node);
+ if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
+ }
+ }
+
+ }
+ },
+
+ _z = {
+ tools: _tools,
+ view: _view,
+ event: _event,
+ data: _data
+ };
+ $.extend(true, $.fn.zTree.consts, _consts);
+ $.extend(true, $.fn.zTree._z, _z);
+
+ var zt = $.fn.zTree,
+ tools = zt._z.tools,
+ consts = zt.consts,
+ view = zt._z.view,
+ data = zt._z.data,
+ event = zt._z.event,
+ $$ = tools.$;
+
+ data.exSetting(_setting);
+ data.addInitBind(_bindEvent);
+ data.addInitUnBind(_unbindEvent);
+ data.addInitCache(_initCache);
+ data.addInitNode(_initNode);
+ data.addInitProxy(_eventProxy, true);
+ data.addInitRoot(_initRoot);
+ data.addBeforeA(_beforeA);
+ data.addZTreeTools(_zTreeTools);
+
+ var _createNodes = view.createNodes;
+ view.createNodes = function(setting, level, nodes, parentNode) {
+ if (_createNodes) _createNodes.apply(view, arguments);
+ if (!nodes) return;
+ view.repairParentChkClassWithSelf(setting, parentNode);
+ }
+ var _removeNode = view.removeNode;
+ view.removeNode = function(setting, node) {
+ var parentNode = node.getParentNode();
+ if (_removeNode) _removeNode.apply(view, arguments);
+ if (!node || !parentNode) return;
+ view.repairChkClass(setting, parentNode);
+ view.repairParentChkClass(setting, parentNode);
+ }
+
+ var _appendNodes = view.appendNodes;
+ view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
+ var html = "";
+ if (_appendNodes) {
+ html = _appendNodes.apply(view, arguments);
+ }
+ if (parentNode) {
+ data.makeChkFlag(setting, parentNode);
+ }
+ return html;
+ }
+})(jQuery);/**
+ * 可以改变图标的button
+ *
+ * Created by GUY on 2016/2/2.
+ *
+ * @class BI.IconChangeButton
+ * @extends BI.Single
+ */
+BI.IconChangeButton = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.IconChangeButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-icon-change-button",
+ iconCls: "",
+ iconWidth: null,
+ iconHeight: null,
+
+ stopEvent: false,
+ stopPropagation: false,
+ selected: false,
+ once: false, // 点击一次选中有效,再点无效
+ forceSelected: false, // 点击即选中, 选中了就不会被取消
+ forceNotSelected: false, // 无论怎么点击都不会被选中
+ disableSelected: false, // 使能选中
+
+ shadow: false,
+ isShadowShowingOnSelected: false, // 选中状态下是否显示阴影
+ trigger: null,
+ handler: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.IconChangeButton.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.button = BI.createWidget({
+ type: "bi.icon_button",
+ element: this,
+ cls: o.iconCls,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight,
+
+ stopEvent: o.stopEvent,
+ stopPropagation: o.stopPropagation,
+ selected: o.selected,
+ once: o.once,
+ forceSelected: o.forceSelected,
+ forceNotSelected: o.forceNotSelected,
+ disableSelected: o.disableSelected,
+
+ shadow: o.shadow,
+ isShadowShowingOnSelected: o.isShadowShowingOnSelected,
+ trigger: o.trigger,
+ handler: o.handler
+ });
+
+ this.button.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.IconChangeButton.EVENT_CHANGE, arguments);
+ });
+ },
+
+ isSelected: function () {
+ return this.button.isSelected();
+ },
+
+ setSelected: function (b) {
+ this.button.setSelected(b);
+ },
+
+ setIcon: function (cls) {
+ var o = this.options;
+ if (o.iconCls !== cls) {
+ this.element.removeClass(o.iconCls).addClass(cls);
+ o.iconCls = cls;
+ }
+ }
+});
+BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE";
+BI.shortcut("bi.icon_change_button", BI.IconChangeButton);/**
+ * 统一的trigger图标按钮
+ *
+ * Created by GUY on 2015/9/16.
+ * @class BI.TriggerIconButton
+ * @extends BI.IconButton
+ */
+BI.TriggerIconButton = BI.inherit(BI.IconButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.TriggerIconButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-trigger-icon-button",
+ extraCls: "pull-down-font"
+ });
+ },
+
+ _init: function () {
+ BI.TriggerIconButton.superclass._init.apply(this, arguments);
+ },
+
+ doClick: function () {
+ BI.TriggerIconButton.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TriggerIconButton.EVENT_CHANGE, this);
+ }
+ }
+});
+BI.TriggerIconButton.EVENT_CHANGE = "TriggerIconButton.EVENT_CHANGE";
+BI.shortcut("bi.trigger_icon_button", BI.TriggerIconButton);/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.HalfIconButton = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-half-icon-button check-half-select-icon",
+ height: 16,
+ width: 16,
+ iconWidth: 16,
+ iconHeight: 16,
+ selected: false
+ });
+ },
+
+ _init: function () {
+ BI.HalfIconButton.superclass._init.apply(this, arguments);
+ },
+
+ doClick: function () {
+ BI.HalfIconButton.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.HalfIconButton.EVENT_CHANGE);
+ }
+ }
+});
+BI.HalfIconButton.EVENT_CHANGE = "HalfIconButton.EVENT_CHANGE";
+
+BI.shortcut("bi.half_icon_button", BI.HalfIconButton);/**
+ * guy
+ * @extends BI.Single
+ * @type {*|void|Object}
+ */
+BI.HalfButton = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-half-button bi-border bi-high-light-border",
+ height: 14,
+ width: 14,
+ selected: false
+ });
+ },
+
+ _init: function () {
+ BI.HalfButton.superclass._init.apply(this, arguments);
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this.element,
+ items: [{
+ type: "bi.layout",
+ cls: "bi-high-light-background",
+ width: 8,
+ height: 8
+ }]
+ });
+ },
+
+ doClick: function () {
+ BI.HalfButton.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.HalfButton.EVENT_CHANGE);
+ }
+ }
+});
+BI.HalfButton.EVENT_CHANGE = "HalfIconButton.EVENT_CHANGE";
+
+BI.shortcut("bi.half_button", BI.HalfButton);/**
+ * guy
+ * 复选框item
+ * @type {*|void|Object}
+ */
+BI.MultiSelectItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multi-select-item",
+ height: 24,
+ logic: {
+ dynamic: false
+ },
+ iconWrapperWidth: 26
+ });
+ },
+ _init: function () {
+ BI.MultiSelectItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.checkbox"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ rgap: o.rgap,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", {
+ type: "bi.center_adapt",
+ items: [this.checkbox],
+ width: o.iconWrapperWidth
+ }, this.text)
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiSelectItem.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ if (this.isValid()) {
+ this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ setSelected: function (v) {
+ BI.MultiSelectItem.superclass.setSelected.apply(this, arguments);
+ this.checkbox.setSelected(v);
+ }
+});
+BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_select_item", BI.MultiSelectItem);/**
+ * Created by GUY on 2016/2/2.
+ *
+ * @class BI.SingleSelectIconTextItem
+ * @extends BI.BasicButton
+ */
+BI.SingleSelectIconTextItem = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-single-select-icon-text-item bi-list-item-active",
+ iconCls: "",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SingleSelectIconTextItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.icon_text_item",
+ element: this,
+ cls: o.iconCls,
+ once: o.once,
+ iconWrapperWidth: o.iconWrapperWidth,
+ selected: o.selected,
+ height: o.height,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py
+ });
+ this.text.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ isSelected: function () {
+ return this.text.isSelected();
+ },
+
+ setSelected: function (b) {
+ this.text.setSelected(b);
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.SingleSelectIconTextItem.superclass.doClick.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem);/**
+ * guy
+ * 复选框item
+ * @type {*|void|Object}
+ */
+BI.SingleSelectItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-single-select-item bi-list-item-active",
+ hgap: 10,
+ height: 24,
+ textAlign: "left"
+ });
+ },
+ _init: function () {
+ BI.SingleSelectItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: o.textAlign,
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ title: o.title || o.text,
+ warningTitle: o.warningTitle,
+ py: o.py
+ });
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.SingleSelectItem.superclass.doClick.apply(this, arguments);
+ },
+
+ setSelected: function (v) {
+ BI.SingleSelectItem.superclass.setSelected.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.single_select_item", BI.SingleSelectItem);/**
+ * guy
+ * 单选框item
+ * @type {*|void|Object}
+ */
+BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-single-select-radio-item",
+ logic: {
+ dynamic: false
+ },
+ hgap: 10,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SingleSelectRadioItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.radio = BI.createWidget({
+ type: "bi.radio"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", {
+ type: "bi.center_adapt",
+ items: [this.radio],
+ width: 16
+ }, this.text)
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.SingleSelectRadioItem.superclass.doClick.apply(this, arguments);
+ this.radio.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.SingleSelectRadioItem.superclass.setSelected.apply(this, arguments);
+ this.radio.setSelected(v);
+
+ }
+});
+
+BI.shortcut("bi.single_select_radio_item", BI.SingleSelectRadioItem);/**
+ * Created by roy on 15/10/16.
+ */
+BI.ArrowNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.ArrowNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-arrow-group-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ var self = this, o = this.options;
+ BI.ArrowNode.superclass._init.apply(this, arguments);
+ this.checkbox = BI.createWidget({
+ type: "bi.arrow_group_node_checkbox"
+ });
+
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.ArrowNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isOpened());
+ },
+
+ setText: function (text) {
+ BI.ArrowNode.superclass.setText.apply(this, arguments);
+ this.text.setText(text);
+ },
+
+ setOpened: function (v) {
+ BI.ArrowNode.superclass.setOpened.apply(this, arguments);
+ this.checkbox.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.arrow_group_node", BI.ArrowNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.FirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.FirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-first-plus-group-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.FirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.first_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.FirstPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.FirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.first_plus_group_node", BI.FirstPlusGroupNode);/**
+ * Created by User on 2016/3/31.
+ */
+/**
+ * > + icon + 文本
+ * @class BI.IconArrowNode
+ * @extends BI.NodeButton
+ */
+BI.IconArrowNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.IconArrowNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-arrow-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24,
+ iconHeight: 12,
+ iconWidth: 12,
+ iconCls: ""
+ });
+ },
+ _init: function () {
+ BI.IconArrowNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.arrow_group_node_checkbox",
+ width: 24,
+ stopPropagation: true
+ });
+
+ var icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: 24,
+ cls: o.iconCls,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, {
+ width: 24,
+ el: icon
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.IconArrowNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.IconArrowNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.icon_arrow_node", BI.IconArrowNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.LastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.LastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-last-plus-group-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.LastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.last_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if(type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.LastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.LastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.last_plus_group_node", BI.LastPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.MidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-mid-plus-group-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.mid_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.MidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerIconArrowNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-icon-arrow-node bi-list-item",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 24,
+ iconHeight: 16,
+ iconWidth: 16,
+ iconCls: ""
+ });
+ },
+ _init: function () {
+ BI.MultiLayerIconArrowNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.icon_arrow_node",
+ iconCls: o.iconCls,
+ cls: "bi-list-item-none",
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ width: 24,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 24),
+ items: [items]
+ });
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerIconArrowNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerIconArrowNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_icon_arrow_node", BI.MultiLayerIconArrowNode);
+/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.PlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.PlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.PlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-plus-group-node bi-list-item",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.PlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.tree_node_checkbox"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.PlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.PlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (this.checkbox) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.plus_group_node", BI.PlusGroupNode);/**
+ * Created by Windy on 2018/2/1.
+ */
+BI.Switch = BI.inherit(BI.BasicButton, {
+
+ props: {
+ extraCls: "bi-switch",
+ height: 22,
+ width: 44,
+ logic: {
+ dynamic: false
+ }
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.absolute",
+ ref: function () {
+ self.layout = this;
+ },
+ items: [{
+ el: {
+ type: "bi.text_button",
+ cls: "circle-button bi-card"
+ },
+ width: 18,
+ height: 18,
+ top: 2,
+ left: this.options.selected ? 24 : 2
+ }]
+ };
+ },
+
+ setSelected: function (v) {
+ BI.Switch.superclass.setSelected.apply(this, arguments);
+ this.layout.attr("items")[0].left = v ? 24 : 2;
+ this.layout.resize();
+ },
+
+ doClick: function () {
+ BI.Switch.superclass.doClick.apply(this, arguments);
+ this.fireEvent(BI.Switch.EVENT_CHANGE);
+ }
+});
+BI.Switch.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.switch", BI.Switch);/**
+ * guy
+ * 复选框item
+ * @type {*|void|Object}
+ */
+BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.FirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-first-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ layer: 0,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.FirstTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.checkbox"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
+ width: 12,
+ el: {
+ type: "bi.layout",
+ cls: (o.pNode && o.pNode.isLastNode) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ }
+ }), {
+ width: 24,
+ el: {
+ type: "bi.layout",
+ cls: "first-line-conn-background",
+ width: 24,
+ height: o.height
+ }
+ }, {
+ el: this.text
+ });
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ 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);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.FirstTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.FirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.checkbox.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.first_tree_leaf_item", BI.FirstTreeLeafItem);BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-icon-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ height: 24,
+ iconWidth: 16,
+ iconHeight: 16,
+ iconCls: ""
+ });
+ },
+
+ _init: function () {
+ BI.IconTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var icon = BI.createWidget({
+ type: "bi.center_adapt",
+ width: 24,
+ cls: o.iconCls,
+ items: [{
+ type: "bi.icon",
+ width: o.iconWidth,
+ height: o.iconHeight
+ }]
+ });
+
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: icon
+ }, {
+ el: this.text
+ });
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ 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);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.IconTreeLeafItem.superclass.doClick.apply(this, arguments);
+ },
+
+ setSelected: function (v) {
+ BI.IconTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.icon_tree_leaf_item", BI.IconTreeLeafItem);/**
+ * guy
+ * 复选框item
+ * @type {*|void|Object}
+ */
+BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.LastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-last-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ layer: 0,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.LastTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.checkbox"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
+ width: 12,
+ el: {
+ type: "bi.layout",
+ cls: (o.pNode && o.pNode.isLastNode) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ }
+ }), {
+ width: 24,
+ el: {
+ type: "bi.layout",
+ cls: "last-line-conn-background",
+ width: 24,
+ height: o.height
+ }
+ }, {
+ el: this.text
+ });
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ 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);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.LastTreeLeafItem.superclass.doClick.apply(this, arguments);
+ // this.checkbox.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.LastTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ // this.checkbox.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.last_tree_leaf_item", BI.LastTreeLeafItem);/**
+ * guy
+ * 复选框item
+ * @type {*|void|Object}
+ */
+BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-mid-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ layer: 0,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MidTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.checkbox"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.setSelected(self.isSelected());
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : {
+ width: 12,
+ el: {
+ type: "bi.layout",
+ cls: (o.pNode && o.pNode.isLastNode) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ }
+ }), {
+ width: 24,
+ el: {
+ type: "bi.layout",
+ cls: "mid-line-conn-background",
+ width: 24,
+ height: o.height
+ }
+ }, {
+ el: this.text
+ });
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ 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);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MidTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.checkbox.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MidTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.checkbox.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.mid_tree_leaf_item", BI.MidTreeLeafItem);/**
+ * @class BI.MultiLayerIconTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerIconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-icon-tree-leaf-item bi-list-item-active",
+ layer: 0,
+ height: 24,
+ iconCls: "",
+ iconHeight: 16,
+ iconWidth: 16
+ });
+ },
+ _init: function () {
+ BI.MultiLayerIconTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.icon_tree_leaf_item",
+ cls: "bi-list-item-none",
+ iconCls: o.iconCls,
+ id: o.id,
+ pId: o.pId,
+ isFront: true,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var items = [];
+ BI.count(0, o.layer, function () {
+ items.push({
+ type: "bi.layout",
+ width: 24,
+ height: o.height
+ });
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 24),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.item.doRedMark.apply(this.item, arguments);
+ },
+
+ unRedMark: function () {
+ this.item.unRedMark.apply(this.item, arguments);
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerIconTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerIconTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ },
+
+ getValue: function () {
+ return this.options.value;
+ }
+});
+
+BI.shortcut("bi.multilayer_icon_tree_leaf_item", BI.MultiLayerIconTreeLeafItem);
+/**
+ * 树叶子节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.TreeTextLeafItem
+ * @extends BI.BasicButton
+ */
+BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeTextLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-tree-text-leaf-item bi-list-item-active",
+ id: "",
+ pId: "",
+ height: 24,
+ hgap: 0,
+ lgap: 0,
+ rgap: 0
+ });
+ },
+ _init: function () {
+ BI.TreeTextLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ lgap: o.lgap,
+ rgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.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);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ }
+});
+
+BI.shortcut("bi.tree_text_leaf_item", BI.TreeTextLeafItem);/**
+ * 专门为calendar的视觉加的button,作为私有button,不能配置任何属性,也不要用这个玩意
+ */
+BI.CalendarDateItem = BI.inherit(BI.BasicButton, {
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.text_item",
+ cls: "bi-list-item-select",
+ textAlign: "center",
+ whiteSpace: "normal",
+ text: o.text,
+ value: o.value,
+ ref: function () {
+ self.text = this;
+ }
+ },
+ left: o.lgap,
+ right: o.rgap,
+ top: 0,
+ bottom: 0
+ }]
+ };
+ },
+
+ 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);
+ }
+ },
+
+ setSelected: function (b) {
+ BI.CalendarDateItem.superclass.setSelected.apply(this, arguments);
+ this.text.setSelected(b);
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ }
+});
+BI.shortcut("bi.calendar_date_item", BI.CalendarDateItem);/**
+ * Created by GUY on 2015/8/28.
+ * @class BI.Calendar
+ * @extends BI.Widget
+ */
+BI.Calendar = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.Calendar.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-calendar",
+ logic: {
+ dynamic: false
+ },
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ year: 2015,
+ month: 8,
+ day: 25
+ });
+ },
+
+ _dateCreator: function (Y, M, D) {
+ var self = this, o = this.options, log = {}, De = BI.getDate();
+ var mins = o.min.match(/\d+/g);
+ var maxs = o.max.match(/\d+/g);
+ Y < (mins[0] | 0) && (Y = (mins[0] | 0));
+ Y > (maxs[0] | 0) && (Y = (maxs[0] | 0));
+
+ De.setFullYear(Y, M, D);
+ log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()];
+
+ var MD = BI.Date._MD.slice(0);
+ MD[1] = BI.isLeapYear(log.ymd[0]) ? 29 : 28;
+
+ // 日期所在月第一天
+ De.setFullYear(log.ymd[0], log.ymd[1], 1);
+ // 是周几
+ log.FDay = De.getDay();
+
+ // 当前BI.StartOfWeek与周日对齐后的FDay是周几
+ var offSetFDay = (7 - BI.StartOfWeek + log.FDay) % 7;
+
+ // 当前月页第一天是几号
+ log.PDay = MD[M === 0 ? 11 : M - 1] - offSetFDay + 1;
+ log.NDay = 1;
+
+ var items = [];
+ BI.each(BI.range(42), function (i) {
+ var td = {}, YY = log.ymd[0], MM = log.ymd[1] + 1, DD;
+ // 上个月的日期
+ if (i < offSetFDay) {
+ td.lastMonth = true;
+ DD = i + log.PDay;
+ // 上一年
+ MM === 1 && (YY -= 1);
+ MM = MM === 1 ? 12 : MM - 1;
+ } else if (i >= offSetFDay && i < offSetFDay + MD[log.ymd[1]]) {
+ DD = i - offSetFDay + 1;
+ if (i - offSetFDay + 1 === log.ymd[2]) {
+ td.currentDay = true;
+ }
+ } else {
+ td.nextMonth = true;
+ DD = log.NDay++;
+ MM === 12 && (YY += 1);
+ MM = MM === 12 ? 1 : MM + 1;
+ }
+ if (BI.checkDateVoid(YY, MM, DD, mins, maxs)[0]) {
+ td.disabled = true;
+ }
+ td.text = DD;
+ items.push(td);
+ });
+ return items;
+ },
+
+ _init: function () {
+ BI.Calendar.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var items = BI.map(this._getWeekLabel(), function (i, value) {
+ return {
+ type: "bi.label",
+ height: 24,
+ text: value
+ };
+ });
+ var title = BI.createWidget({
+ type: "bi.button_group",
+ height: 44,
+ items: items,
+ layouts: [{
+ type: "bi.center",
+ hgap: 5,
+ vgap: 10
+ }]
+ });
+ var days = this._dateCreator(o.year, o.month - 1, o.day);
+ items = [];
+ items.push(days.slice(0, 7));
+ items.push(days.slice(7, 14));
+ items.push(days.slice(14, 21));
+ items.push(days.slice(21, 28));
+ items.push(days.slice(28, 35));
+ items.push(days.slice(35, 42));
+
+ items = BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ var month = td.lastMonth ? o.month - 1 : (td.nextMonth ? o.month + 1 : o.month);
+ return BI.extend(td, {
+ type: "bi.calendar_date_item",
+ textAlign: "center",
+ whiteSpace: "normal",
+ once: false,
+ forceSelected: true,
+ height: 24,
+ value: o.year + "-" + month + "-" + td.text,
+ disabled: td.lastMonth || td.nextMonth || td.disabled,
+ lgap: 5,
+ rgap: 5
+ // selected: td.currentDay
+ });
+ });
+ });
+
+ this.days = BI.createWidget({
+ type: "bi.button_group",
+ items: BI.createItems(items, {}),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, {
+ columns: 7,
+ rows: 6,
+ columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7],
+ rowSize: 24,
+ vgap: 10
+ }))]
+ });
+ this.days.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ BI.createWidget(BI.extend({
+ element: this
+
+ }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("top", title, this.days)
+ }))));
+ },
+
+ _getWeekLabel: function () {
+ return BI.map(BI.range(0, 7), function (idx, v) {
+ return BI.Date._SDN[(v + BI.StartOfWeek) % 7];
+ });
+ },
+
+ isFrontDate: function () {
+ var o = this.options, c = this._const;
+ var Y = o.year, M = o.month, De = BI.getDate(), day = De.getDay();
+ Y = Y | 0;
+ De.setFullYear(Y, M, 1);
+ var newDate = BI.getOffsetDate(De, -1 * (day + 1));
+ return !!BI.checkDateVoid(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), o.min, o.max)[0];
+ },
+
+ isFinalDate: function () {
+ var o = this.options, c = this._const;
+ var Y = o.year, M = o.month, De = BI.getDate(), day = De.getDay();
+ Y = Y | 0;
+ De.setFullYear(Y, M, 1);
+ var newDate = BI.getOffsetDate(De, 42 - day);
+ return !!BI.checkDateVoid(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), o.min, o.max)[0];
+ },
+
+ setValue: function (ob) {
+ this.days.setValue([ob.year + "-" + ob.month + "-" + ob.day]);
+ },
+
+ getValue: function () {
+ var date = this.days.getValue()[0].match(/\d+/g);
+ return {
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0
+ };
+ }
+});
+
+BI.extend(BI.Calendar, {
+ getPageByDateJSON: function (json) {
+ var year = BI.getDate().getFullYear();
+ var month = BI.getDate().getMonth();
+ var page = (json.year - year) * 12;
+ page += json.month - 1 - month;
+ return page;
+ },
+ getDateJSONByPage: function (v) {
+ var months = BI.getDate().getMonth();
+ var page = v;
+
+ // 对当前page做偏移,使到当前年初
+ page = page + months;
+
+ var year = BI.parseInt(page / 12);
+ if(page < 0 && page % 12 !== 0) {
+ year--;
+ }
+ var month = page >= 0 ? (page % 12) : ((12 + page % 12) % 12);
+ return {
+ year: BI.getDate().getFullYear() + year,
+ month: month + 1
+ };
+ }
+});
+
+BI.shortcut("bi.calendar", BI.Calendar);/**
+ * Created by GUY on 2015/8/28.
+ * @class BI.YearCalendar
+ * @extends BI.Widget
+ */
+BI.YearCalendar = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ var conf = BI.YearCalendar.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-year-calendar",
+ behaviors: {},
+ logic: {
+ dynamic: false
+ },
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ year: null
+ });
+ },
+
+ _yearCreator: function (Y) {
+ var o = this.options;
+ Y = Y | 0;
+ var start = BI.YearCalendar.getStartYear(Y);
+ var items = [];
+ BI.each(BI.range(BI.YearCalendar.INTERVAL), function (i) {
+ var td = {};
+ if (BI.checkDateVoid(start + i, 1, 1, o.min, o.max)[0]) {
+ td.disabled = true;
+ }
+ td.text = start + i;
+ items.push(td);
+ });
+ return items;
+ },
+
+ _init: function () {
+ BI.YearCalendar.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.currentYear = BI.getDate().getFullYear();
+ var years = this._yearCreator(o.year || this.currentYear);
+
+ // 纵向排列年
+ var len = years.length, tyears = BI.makeArray(len, "");
+ var map = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11];
+ BI.each(years, function (i, y) {
+ tyears[i] = years[map[i]];
+ });
+ var items = [];
+ items.push(tyears.slice(0, 2));
+ items.push(tyears.slice(2, 4));
+ items.push(tyears.slice(4, 6));
+ items.push(tyears.slice(6, 8));
+ items.push(tyears.slice(8, 10));
+ items.push(tyears.slice(10, 12));
+
+ items = BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ return BI.extend(td, {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "normal",
+ once: false,
+ forceSelected: true,
+ height: 24,
+ width: 45,
+ value: td.text,
+ disabled: td.disabled
+ });
+ });
+ });
+
+ this.years = BI.createWidget({
+ type: "bi.button_group",
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: 24
+ })), {
+ type: "bi.center_adapt",
+ vgap: 1
+ }]
+ });
+ this.years.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ BI.createWidget(BI.extend({
+ element: this
+
+ }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("top", this.years)
+ }))));
+ },
+
+ isFrontYear: function () {
+ var o = this.options;
+ var Y = o.year;
+ Y = Y | 0;
+ return !!BI.checkDateVoid(BI.YearCalendar.getStartYear(Y) - 1, 1, 1, o.min, o.max)[0];
+ },
+
+ isFinalYear: function () {
+ var o = this.options, c = this._const;
+ var Y = o.year;
+ Y = Y | 0;
+ return !!BI.checkDateVoid(BI.YearCalendar.getEndYear(Y) + 1, 1, 1, o.min, o.max)[0];
+ },
+
+ setValue: function (val) {
+ this.years.setValue([val]);
+ },
+
+ getValue: function () {
+ return this.years.getValue()[0];
+ }
+});
+// 类方法
+BI.extend(BI.YearCalendar, {
+ INTERVAL: 12,
+
+ // 获取显示的第一年
+ getStartYear: function (year) {
+ var cur = BI.getDate().getFullYear();
+ return year - ((year - cur + 3) % BI.YearCalendar.INTERVAL + 12) % BI.YearCalendar.INTERVAL;
+ },
+
+ getEndYear: function (year) {
+ return BI.YearCalendar.getStartYear(year) + BI.YearCalendar.INTERVAL - 1;
+ },
+
+ getPageByYear: function (year) {
+ var cur = BI.getDate().getFullYear();
+ year = BI.YearCalendar.getStartYear(year);
+ return (year - cur + 3) / BI.YearCalendar.INTERVAL;
+ }
+});
+
+BI.shortcut("bi.year_calendar", BI.YearCalendar);/**
+ * Created by roy on 15/10/16.
+ * 右与下箭头切换的树节点
+ */
+BI.ArrowTreeGroupNodeCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ArrowTreeGroupNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-arrow-group-node-checkbox"
+ });
+ },
+ _init: function () {
+ BI.ArrowTreeGroupNodeCheckbox.superclass._init.apply(this, arguments);
+ },
+ setSelected: function (v) {
+ BI.ArrowTreeGroupNodeCheckbox.superclass.setSelected.apply(this, arguments);
+ if(v) {
+ this.element.removeClass("expander-right-font").addClass("expander-down-font");
+ } else {
+ this.element.removeClass("expander-down-font").addClass("expander-right-font");
+ }
+ }
+});
+BI.shortcut("bi.arrow_group_node_checkbox", BI.ArrowTreeGroupNodeCheckbox);/**
+ * 十字型的树节点
+ * @class BI.CheckingMarkNode
+ * @extends BI.IconButton
+ */
+BI.CheckingMarkNode = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend( BI.CheckingMarkNode.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "check-mark-font"
+ });
+ },
+ _init: function () {
+ BI.CheckingMarkNode.superclass._init.apply(this, arguments);
+ this.setSelected(this.options.selected);
+
+ },
+ setSelected: function (v) {
+ BI.CheckingMarkNode.superclass.setSelected.apply(this, arguments);
+ if(v === true) {
+ this.element.addClass("check-mark-font");
+ } else {
+ this.element.removeClass("check-mark-font");
+ }
+ }
+});
+BI.shortcut("bi.checking_mark_node", BI.CheckingMarkNode);/**
+ * 十字型的树节点
+ * @class BI.FirstTreeNodeCheckbox
+ * @extends BI.IconButton
+ */
+BI.FirstTreeNodeCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend( BI.FirstTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "tree-collapse-icon-type2",
+ iconWidth: 24,
+ iconHeight: 24
+ });
+ },
+ _init: function () {
+ BI.FirstTreeNodeCheckbox.superclass._init.apply(this, arguments);
+
+ },
+ setSelected: function (v) {
+ BI.FirstTreeNodeCheckbox.superclass.setSelected.apply(this, arguments);
+ if(v === true) {
+ this.element.addClass("tree-expand-icon-type2");
+ } else {
+ this.element.removeClass("tree-expand-icon-type2");
+ }
+ }
+});
+BI.shortcut("bi.first_tree_node_checkbox", BI.FirstTreeNodeCheckbox);/**
+ * 十字型的树节点
+ * @class BI.LastTreeNodeCheckbox
+ * @extends BI.IconButton
+ */
+BI.LastTreeNodeCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.LastTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "tree-collapse-icon-type4",
+ iconWidth: 24,
+ iconHeight: 24
+ });
+ },
+ _init: function () {
+ BI.LastTreeNodeCheckbox.superclass._init.apply(this, arguments);
+
+ },
+ setSelected: function (v) {
+ BI.LastTreeNodeCheckbox.superclass.setSelected.apply(this, arguments);
+ if (v === true) {
+ this.element.addClass("tree-expand-icon-type4");
+ } else {
+ this.element.removeClass("tree-expand-icon-type4");
+ }
+ }
+});
+BI.shortcut("bi.last_tree_node_checkbox", BI.LastTreeNodeCheckbox);/**
+ * 十字型的树节点
+ * @class BI.MidTreeNodeCheckbox
+ * @extends BI.IconButton
+ */
+BI.MidTreeNodeCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend( BI.MidTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "tree-collapse-icon-type3",
+ iconWidth: 24,
+ iconHeight: 24
+ });
+ },
+ _init: function () {
+ BI.MidTreeNodeCheckbox.superclass._init.apply(this, arguments);
+
+ },
+ setSelected: function (v) {
+ BI.MidTreeNodeCheckbox.superclass.setSelected.apply(this, arguments);
+ if(v === true) {
+ this.element.addClass("tree-expand-icon-type3");
+ } else {
+ this.element.removeClass("tree-expand-icon-type3");
+ }
+ }
+});
+BI.shortcut("bi.mid_tree_node_checkbox", BI.MidTreeNodeCheckbox);/**
+ * 十字型的树节点
+ * @class BI.TreeNodeCheckbox
+ * @extends BI.IconButton
+ */
+BI.TreeNodeCheckbox = BI.inherit(BI.IconButton, {
+ _defaultConfig: function () {
+ return BI.extend( BI.TreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "tree-collapse-icon-type1",
+ iconWidth: 24,
+ iconHeight: 24
+ });
+ },
+ _init: function () {
+ BI.TreeNodeCheckbox.superclass._init.apply(this, arguments);
+
+ },
+ setSelected: function (v) {
+ BI.TreeNodeCheckbox.superclass.setSelected.apply(this, arguments);
+ if(v) {
+ this.element.addClass("tree-expand-icon-type1");
+ } else {
+ this.element.removeClass("tree-expand-icon-type1");
+ }
+ }
+});
+BI.shortcut("bi.tree_node_checkbox", BI.TreeNodeCheckbox);/**
+ * 自定义选色
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.CustomColorChooser
+ * @extends BI.Widget
+ */
+BI.CustomColorChooser = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.CustomColorChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-custom-color-chooser",
+ width: 227,
+ height: 245
+ });
+ },
+
+ _init: function () {
+ BI.CustomColorChooser.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.editor, {
+ type: "bi.simple_color_picker_editor"
+ });
+ this.editor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () {
+ self.setValue(this.getValue());
+ });
+ this.farbtastic = BI.createWidget({
+ type: "bi.farbtastic"
+ });
+ this.farbtastic.on(BI.Farbtastic.EVENT_CHANGE, function () {
+ self.setValue(this.getValue());
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.editor,
+ left: 0,
+ top: 0,
+ right: 0
+ }],
+ height: 30
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.farbtastic,
+ left: 15,
+ right: 15,
+ top: 7
+ }],
+ height: 215
+ }]
+ });
+ },
+
+ setValue: function (color) {
+ this.editor.setValue(color);
+ this.farbtastic.setValue(color);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ }
+});
+BI.CustomColorChooser.EVENT_CHANGE = "CustomColorChooser.EVENT_CHANGE";
+BI.shortcut("bi.custom_color_chooser", BI.CustomColorChooser);/**
+ * 选色控件
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.ColorChooser
+ * @extends BI.Widget
+ */
+BI.ColorChooser = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ColorChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-color-chooser",
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.ColorChooser.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ container: o.container,
+ adjustLength: 1,
+ isNeedAdjustWidth: false,
+ isNeedAdjustHeight: false,
+ el: BI.extend({
+ type: o.width <= 24 ? "bi.color_chooser_trigger" : "bi.long_color_chooser_trigger",
+ ref: function (_ref) {
+ self.trigger = _ref;
+ },
+ width: o.width,
+ height: o.height
+ }, o.el),
+ popup: {
+ el: BI.extend({
+ type: "bi.color_chooser_popup",
+ ref: function (_ref) {
+ self.colorPicker = _ref;
+ },
+ listeners: [{
+ eventName: BI.ColorChooserPopup.EVENT_VALUE_CHANGE,
+ action: function () {
+ fn();
+ if (!self._isRGBColor(self.colorPicker.getValue())) {
+ self.combo.hideView();
+ }
+ }
+ }, {
+ eventName: BI.ColorChooserPopup.EVENT_CHANGE,
+ action: function () {
+ fn();
+ self.combo.hideView();
+ }
+ }]
+ }, o.popup),
+ stopPropagation: true,
+ width: 230
+ },
+ value: o.value
+ });
+
+ var fn = function () {
+ var color = self.colorPicker.getValue();
+ self.trigger.setValue(color);
+ var colors = BI.string2Array(BI.Cache.getItem("colors") || "");
+ var que = new BI.Queue(8);
+ que.fromArray(colors);
+ que.remove(color);
+ que.unshift(color);
+ BI.Cache.setItem("colors", BI.array2String(que.toArray()));
+ };
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.colorPicker.setStoreColors(BI.string2Array(BI.Cache.getItem("colors") || ""));
+ });
+
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ self.fireEvent(BI.ColorChooser.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _isRGBColor: function (color) {
+ return BI.isNotEmptyString(color) && color !== "transparent";
+ },
+
+ isViewVisible: function () {
+ return this.combo.isViewVisible();
+ },
+
+ hideView: function () {
+ this.combo.hideView();
+ },
+
+ showView: function () {
+ this.combo.showView();
+ },
+
+ setValue: function (color) {
+ this.combo.setValue(color);
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ }
+});
+BI.ColorChooser.EVENT_CHANGE = "ColorChooser.EVENT_CHANGE";
+BI.shortcut("bi.color_chooser", BI.ColorChooser);/**
+ * 选色控件
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.ColorChooserPopup
+ * @extends BI.Widget
+ */
+BI.ColorChooserPopup = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-color-chooser-popup",
+ width: 230,
+ height: 145
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ this.colorEditor = BI.createWidget(o.editor, {
+ type: "bi.color_picker_editor",
+ value: o.value,
+ cls: "bi-header-background bi-border-bottom",
+ height: 30
+ });
+
+ this.colorEditor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () {
+ self.setValue(this.getValue());
+ self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments);
+ });
+
+ this.storeColors = BI.createWidget({
+ type: "bi.color_picker",
+ cls: "bi-border-bottom bi-border-right",
+ items: [[{
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }, {
+ value: "",
+ disabled: true
+ }]],
+ width: 210,
+ height: 24,
+ value: o.value
+ });
+ this.storeColors.on(BI.ColorPicker.EVENT_CHANGE, function () {
+ self.setValue(this.getValue()[0]);
+ self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
+ });
+
+ this.colorPicker = BI.createWidget({
+ type: "bi.color_picker",
+ width: 210,
+ height: 50,
+ value: o.value
+ });
+
+ this.colorPicker.on(BI.ColorPicker.EVENT_CHANGE, function () {
+ self.setValue(this.getValue()[0]);
+ self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
+ });
+
+ this.customColorChooser = BI.createWidget({
+ type: "bi.custom_color_chooser",
+ editor: o.editor
+ });
+
+ var panel = BI.createWidget({
+ type: "bi.popup_panel",
+ buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")],
+ title: BI.i18nText("BI-Custom_Color"),
+ el: this.customColorChooser,
+ stopPropagation: false,
+ bgap: -1,
+ rgap: 1,
+ lgap: 1,
+ minWidth: 227
+ });
+
+ this.more = BI.createWidget({
+ type: "bi.combo",
+ cls: "bi-border-top",
+ container: null,
+ direction: "right,top",
+ isNeedAdjustHeight: false,
+ el: {
+ type: "bi.text_item",
+ cls: "color-chooser-popup-more bi-list-item",
+ textAlign: "center",
+ height: 24,
+ textLgap: 10,
+ text: BI.i18nText("BI-Basic_More") + "..."
+ },
+ popup: panel
+ });
+
+ this.more.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
+ self.customColorChooser.setValue(self.getValue());
+ });
+ panel.on(BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.more.hideView();
+ break;
+ case 1:
+ self.setValue(self.customColorChooser.getValue());
+ self.more.hideView();
+ self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments);
+ break;
+ }
+ });
+
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vtape",
+ items: [this.colorEditor, {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: this.storeColors,
+ left: 10,
+ right: 10,
+ top: 5
+ }]
+ },
+ height: 29
+ }, {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: this.colorPicker,
+ left: 10,
+ right: 10,
+ top: 5,
+ bottom: 5
+ }]
+ },
+ height: 60
+ }, {
+ el: this.more,
+ height: 24
+ }]
+ },
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "disable-mask",
+ invisible: !o.disabled,
+ ref: function () {
+ self.mask = this;
+ }
+ },
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ };
+ },
+
+ mounted: function () {
+ var self = this;
+ var o = this.options;
+ if (BI.isNotNull(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ _setEnable: function (enable) {
+ BI.ColorChooserPopup.superclass._setEnable.apply(this, arguments);
+ this.mask.setVisible(!enable);
+ },
+
+ setStoreColors: function (colors) {
+ if (BI.isArray(colors)) {
+ var items = BI.map(colors, function (i, color) {
+ return {
+ value: color
+ };
+ });
+ BI.count(colors.length, 8, function (i) {
+ items.push({
+ value: "",
+ disabled: true
+ });
+ });
+ this.storeColors.populate([items]);
+ }
+ },
+
+ setValue: function (color) {
+ this.colorEditor.setValue(color);
+ this.colorPicker.setValue(color);
+ this.storeColors.setValue(color);
+ },
+
+ getValue: function () {
+ return this.colorEditor.getValue();
+ }
+});
+BI.ColorChooserPopup.EVENT_VALUE_CHANGE = "ColorChooserPopup.EVENT_VALUE_CHANGE";
+BI.ColorChooserPopup.EVENT_CHANGE = "ColorChooserPopup.EVENT_CHANGE";
+BI.shortcut("bi.color_chooser_popup", BI.ColorChooserPopup);/**
+ * 选色控件
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.SimpleColorChooserPopup
+ * @extends BI.Widget
+ */
+BI.SimpleColorChooserPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SimpleColorChooserPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-color-chooser-popup"
+ });
+ },
+
+ _init: function () {
+ BI.SimpleColorChooserPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popup = BI.createWidget({
+ type: "bi.color_chooser_popup",
+ value: o.value,
+ element: this,
+ editor: {
+ type: "bi.simple_color_picker_editor"
+ }
+ });
+ this.popup.on(BI.ColorChooserPopup.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SimpleColorChooserPopup.EVENT_CHANGE, arguments);
+ });
+ this.popup.on(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, function () {
+ self.fireEvent(BI.SimpleColorChooserPopup.EVENT_VALUE_CHANGE, arguments);
+ });
+ },
+
+ setStoreColors: function (colors) {
+ this.popup.setStoreColors(colors);
+ },
+
+ setValue: function (color) {
+ this.popup.setValue(color);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.SimpleColorChooserPopup.EVENT_VALUE_CHANGE = "ColorChooserPopup.EVENT_VALUE_CHANGE";
+BI.SimpleColorChooserPopup.EVENT_CHANGE = "ColorChooserPopup.EVENT_CHANGE";
+BI.shortcut("bi.simple_color_chooser_popup", BI.SimpleColorChooserPopup);/**
+ * 简单选色控件,没有自动和透明
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.SimpleColorChooser
+ * @extends BI.Widget
+ */
+BI.SimpleColorChooser = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SimpleColorChooser.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-simple-color-chooser",
+ value: "#ffffff"
+ });
+ },
+
+ _init: function () {
+ BI.SimpleColorChooser.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.combo = BI.createWidget({
+ type: "bi.color_chooser",
+ element: this,
+ container: o.container,
+ value: o.value,
+ width: o.width,
+ height: o.height,
+ popup: {
+ type: "bi.simple_color_chooser_popup"
+ }
+ });
+ this.combo.on(BI.ColorChooser.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SimpleColorChooser.EVENT_CHANGE, arguments);
+ });
+ },
+
+ isViewVisible: function () {
+ return this.combo.isViewVisible();
+ },
+
+ hideView: function () {
+ this.combo.hideView();
+ },
+
+ showView: function () {
+ this.combo.showView();
+ },
+
+ setValue: function (color) {
+ this.combo.setValue(color);
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ }
+});
+BI.SimpleColorChooser.EVENT_CHANGE = "ColorChooser.EVENT_CHANGE";
+BI.shortcut("bi.simple_color_chooser", BI.SimpleColorChooser);/**
+ * 选色控件
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.ColorChooserTrigger
+ * @extends BI.Trigger
+ */
+BI.ColorChooserTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-border",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.ColorChooserTrigger.superclass._init.apply(this, arguments);
+ this.colorContainer = BI.createWidget({
+ type: "bi.layout",
+ cls: "color-chooser-trigger-content" + (BI.isIE9Below && BI.isIE9Below() ? " hack" : "")
+ });
+
+ var down = BI.createWidget({
+ type: "bi.icon_button",
+ disableSelected: true,
+ cls: "icon-combo-down-icon trigger-triangle-font icon-size-12",
+ width: 12,
+ height: 8
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.colorContainer,
+ left: 3,
+ right: 3,
+ top: 3,
+ bottom: 3
+ }, {
+ el: down,
+ right: -1,
+ bottom: 1
+ }]
+ });
+ if (BI.isNotNull(this.options.value)) {
+ this.setValue(this.options.value);
+ }
+ },
+
+ setValue: function (color) {
+ BI.ColorChooserTrigger.superclass.setValue.apply(this, arguments);
+ if (color === "") {
+ this.colorContainer.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background");
+ } else if (color === "transparent") {
+ this.colorContainer.element.css("background-color", "").removeClass("auto-color-background").addClass("trans-color-background");
+ } else {
+ this.colorContainer.element.css({"background-color": color}).removeClass("auto-color-background").removeClass("trans-color-background");
+ }
+ }
+});
+BI.ColorChooserTrigger.EVENT_CHANGE = "ColorChooserTrigger.EVENT_CHANGE";
+BI.shortcut("bi.color_chooser_trigger", BI.ColorChooserTrigger);/**
+ * 选色控件
+ *
+ * Created by GUY on 2015/11/17.
+ * @class BI.LongColorChooserTrigger
+ * @extends BI.Trigger
+ */
+BI.LongColorChooserTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ var conf = BI.LongColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger bi-border",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.LongColorChooserTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.colorContainer = BI.createWidget({
+ type: "bi.htape",
+ cls: "color-chooser-trigger-content",
+ items: [{
+ type: "bi.icon_change_button",
+ ref: function (_ref) {
+ self.changeIcon = _ref;
+ },
+ iconCls: "auto-color-icon",
+ width: 24,
+ iconWidth: 16,
+ iconHeight: 16
+ }, {
+ el: {
+ type: "bi.label",
+ ref: function (_ref) {
+ self.label = _ref;
+ },
+ textAlign: "left",
+ hgap: 5,
+ height: 18,
+ text: BI.i18nText("BI-Basic_Auto")
+ }
+ }]
+ });
+
+ var down = BI.createWidget({
+ type: "bi.icon_button",
+ disableSelected: true,
+ cls: "icon-combo-down-icon trigger-triangle-font icon-size-12",
+ width: 12,
+ height: 8
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.colorContainer,
+ left: 3,
+ right: 3,
+ top: 3,
+ bottom: 3
+ }, {
+ el: down,
+ right: 3,
+ bottom: 3
+ }]
+ });
+ if (this.options.value) {
+ this.setValue(this.options.value);
+ }
+ },
+
+ setValue: function (color) {
+ BI.LongColorChooserTrigger.superclass.setValue.apply(this, arguments);
+ if (color === "") {
+ this.colorContainer.element.css("background-color", "");
+ this.changeIcon.setVisible(true);
+ this.label.setVisible(true);
+ this.changeIcon.setIcon("auto-color-icon");
+ this.label.setText(BI.i18nText("BI-Basic_Auto"));
+ } else if (color === "transparent") {
+ this.colorContainer.element.css("background-color", "");
+ this.changeIcon.setVisible(true);
+ this.label.setVisible(true);
+ this.changeIcon.setIcon("trans-color-icon");
+ this.label.setText(BI.i18nText("BI-Transparent_Color"));
+ } else {
+ this.colorContainer.element.css({"background-color": color});
+ this.changeIcon.setVisible(false);
+ this.label.setVisible(false);
+ }
+ }
+});
+BI.LongColorChooserTrigger.EVENT_CHANGE = "ColorChooserTrigger.EVENT_CHANGE";
+BI.shortcut("bi.long_color_chooser_trigger", BI.LongColorChooserTrigger);/**
+ * 简单选色控件按钮
+ *
+ * Created by GUY on 2015/11/16.
+ * @class BI.ColorPickerButton
+ * @extends BI.BasicButton
+ */
+BI.ColorPickerButton = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.ColorPickerButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-color-picker-button bi-background bi-border-top bi-border-left"
+ });
+ },
+
+ _init: function () {
+ BI.ColorPickerButton.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (o.value) {
+ this.element.css("background-color", o.value);
+ var name = this.getName();
+ this.element.hover(function () {
+ self._createMask();
+ if (self.isEnabled()) {
+ BI.Maskers.show(name);
+ }
+ }, function () {
+ if (!self.isSelected()) {
+ BI.Maskers.hide(name);
+ }
+ });
+ }
+ },
+
+ _createMask: function () {
+ var o = this.options, name = this.getName();
+ if (this.isEnabled() && !BI.Maskers.has(name)) {
+ var w = BI.Maskers.make(name, this, {
+ offset: {
+ left: -1,
+ top: -1,
+ right: -1,
+ bottom: -1
+ }
+ });
+ w.element.addClass("color-picker-button-mask").css("background-color", o.value);
+ }
+ },
+
+ setSelected: function (b) {
+ BI.ColorPickerButton.superclass.setSelected.apply(this, arguments);
+ if (b) {
+ this._createMask();
+ }
+ BI.Maskers[b ? "show" : "hide"](this.getName());
+ }
+});
+BI.ColorPickerButton.EVENT_CHANGE = "ColorPickerButton.EVENT_CHANGE";
+BI.shortcut("bi.color_picker_button", BI.ColorPickerButton);/**
+ * 简单选色控件
+ *
+ * Created by GUY on 2015/11/16.
+ * @class BI.ColorPicker
+ * @extends BI.Widget
+ */
+BI.ColorPicker = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ColorPicker.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-color-picker",
+ items: null
+ });
+ },
+
+ _items: [
+ [{
+ value: "#ffffff"
+ }, {
+ value: "#f2f2f2"
+ }, {
+ value: "#e5e5e5"
+ }, {
+ value: "#d9d9d9"
+ }, {
+ value: "#cccccc"
+ }, {
+ value: "#bfbfbf"
+ }, {
+ value: "#b2b2b2"
+ }, {
+ value: "#a6a6a6"
+ }, {
+ value: "#999999"
+ }, {
+ value: "#8c8c8c"
+ }, {
+ value: "#808080"
+ }, {
+ value: "#737373"
+ }, {
+ value: "#666666"
+ }, {
+ value: "#4d4d4d"
+ }, {
+ value: "#333333"
+ }, {
+ value: "#000000"
+ }],
+ [{
+ value: "#d8b5a6"
+ }, {
+ value: "#ff9e9a"
+ }, {
+ value: "#ffc17d"
+ }, {
+ value: "#f5e56b"
+ }, {
+ value: "#d8e698"
+ }, {
+ value: "#e0ebaf"
+ }, {
+ value: "#c3d825"
+ }, {
+ value: "#bce2e8"
+ }, {
+ value: "#85d3cd"
+ }, {
+ value: "#bce2e8"
+ }, {
+ value: "#a0d8ef"
+ }, {
+ value: "#89c3eb"
+ }, {
+ value: "#bbc8e6"
+ }, {
+ value: "#bbbcde"
+ }, {
+ value: "#d6b4cc"
+ }, {
+ value: "#fbc0d3"
+ }],
+ [{
+ value: "#bb9581"
+ }, {
+ value: "#f37d79"
+ }, {
+ value: "#fba74f"
+ }, {
+ value: "#ffdb4f"
+ }, {
+ value: "#c7dc68"
+ }, {
+ value: "#b0ca71"
+ }, {
+ value: "#99ab4e"
+ }, {
+ value: "#84b9cb"
+ }, {
+ value: "#00a3af"
+ }, {
+ value: "#2ca9e1"
+ }, {
+ value: "#0095d9"
+ }, {
+ value: "#4c6cb3"
+ }, {
+ value: "#8491c3"
+ }, {
+ value: "#a59aca"
+ }, {
+ value: "#cc7eb1"
+ }, {
+ value: "#e89bb4"
+ }],
+ [{
+ value: "#9d775f"
+ }, {
+ value: "#dd4b4b"
+ }, {
+ value: "#ef8b07"
+ }, {
+ value: "#fcc800"
+ }, {
+ value: "#aacf53"
+ }, {
+ value: "#82ae46"
+ }, {
+ value: "#69821b"
+ }, {
+ value: "#59b9c6"
+ }, {
+ value: "#2a83a2"
+ }, {
+ value: "#007bbb"
+ }, {
+ value: "#19448e"
+ }, {
+ value: "#274a78"
+ }, {
+ value: "#4a488e"
+ }, {
+ value: "#7058a3"
+ }, {
+ value: "#884898"
+ }, {
+ value: "#d47596"
+ }]
+ ],
+
+ _init: function () {
+ BI.ColorPicker.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.colors = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ items: BI.createItems(o.items || this._items, {
+ type: "bi.color_picker_button",
+ once: false
+ }),
+ layouts: [{
+ type: "bi.grid"
+ }],
+ value: o.value
+ });
+ this.colors.on(BI.ButtonGroup.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ColorPicker.EVENT_CHANGE, arguments);
+ });
+ },
+
+ populate: function (items) {
+ var args = [].slice.call(arguments);
+ args[0] = BI.createItems(items, {
+ type: "bi.color_picker_button",
+ once: false
+ });
+ this.colors.populate.apply(this.colors, args);
+ },
+
+ setValue: function (color) {
+ this.colors.setValue(color);
+ },
+
+ getValue: function () {
+ return this.colors.getValue();
+ }
+});
+BI.ColorPicker.EVENT_CHANGE = "ColorPicker.EVENT_CHANGE";
+BI.shortcut("bi.color_picker", BI.ColorPicker);/**
+ * 简单选色控件
+ *
+ * Created by GUY on 2015/11/16.
+ * @class BI.ColorPickerEditor
+ * @extends BI.Widget
+ */
+BI.ColorPickerEditor = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ColorPickerEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-color-picker-editor",
+ // width: 200,
+ height: 30
+ });
+ },
+
+ _init: function () {
+ BI.ColorPickerEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = {};
+ this.colorShow = BI.createWidget({
+ type: "bi.layout",
+ cls: "color-picker-editor-display bi-card bi-border",
+ height: 16,
+ width: 16
+ });
+ var RGB = BI.createWidgets(BI.createItems([{text: "R"}, {text: "G"}, {text: "B"}], {
+ type: "bi.label",
+ cls: "color-picker-editor-label",
+ width: 20,
+ height: 20
+ }));
+
+ var checker = function (v) {
+ return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
+ };
+ var Ws = BI.createWidgets([{}, {}, {}], {
+ type: "bi.small_text_editor",
+ cls: "color-picker-editor-input",
+ validationChecker: checker,
+ errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
+ allowBlank: true,
+ value: 255,
+ width: 30,
+ height: 20
+ });
+ BI.each(Ws, function (i, w) {
+ w.on(BI.TextEditor.EVENT_CHANGE, function () {
+ self._checkEditors();
+ if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) {
+ self.colorShow.element.css("background-color", self.getValue());
+ self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
+ }
+ });
+ });
+ this.R = Ws[0];
+ this.G = Ws[1];
+ this.B = Ws[2];
+
+ this.none = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "auto-color-icon",
+ width: 16,
+ height: 16,
+ iconWidth: 16,
+ iconHeight: 16,
+ title: BI.i18nText("BI-Basic_Auto")
+ });
+ this.none.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (this.isSelected()) {
+ self.lastColor = self.getValue();
+ self.setValue("");
+ } else {
+ self.setValue(self.lastColor || "#ffffff");
+ }
+ if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) || self._isEmptyRGB()) {
+ self.colorShow.element.css("background-color", self.getValue());
+ self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
+ }
+ });
+
+ this.transparent = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "trans-color-icon",
+ width: 16,
+ height: 16,
+ iconWidth: 16,
+ iconHeight: 16,
+ title: BI.i18nText("BI-Transparent_Color")
+ });
+ this.transparent.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (this.isSelected()) {
+ self.lastColor = self.getValue();
+ self.setValue("transparent");
+ } else {
+ if (self.lastColor === "transparent") {
+ self.lastColor = "";
+ }
+ self.setValue(self.lastColor || "#ffffff");
+ }
+ if ((self.R.isValid() && self.G.isValid() && self.B.isValid()) ||
+ self._isEmptyRGB()) {
+ self.colorShow.element.css("background-color", self.getValue());
+ self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical_adapt",
+ items: [{
+ el: this.colorShow,
+ width: 16
+ }, {
+ el: RGB[0],
+ width: 20
+ }, {
+ el: this.R,
+ width: 30
+ }, {
+ el: RGB[1],
+ width: 20
+ }, {
+ el: this.G,
+ width: 30
+ }, {
+ el: RGB[2],
+ width: 20
+ }, {
+ el: this.B,
+ width: 30
+ }, {
+ el: this.transparent,
+ width: 16,
+ lgap: 5
+ }, {
+ el: this.none,
+ width: 16,
+ lgap: 5
+ }]
+ },
+ left: 10,
+ right: 10,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _checkEditors: function () {
+ if(BI.isEmptyString(this.R.getValue())) {
+ this.R.setValue(0);
+ }
+ if(BI.isEmptyString(this.G.getValue())) {
+ this.G.setValue(0);
+ }
+ if(BI.isEmptyString(this.B.getValue())) {
+ this.B.setValue(0);
+ }
+ this.storeValue = {
+ r: this.R.getValue() || 0,
+ g: this.G.getValue() || 0,
+ b: this.B.getValue() || 0
+ };
+ },
+
+ _isEmptyRGB: function () {
+ return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b);
+ },
+
+ _showPreColor: function (color) {
+ if (color === "") {
+ this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-normal-background");
+ } else if (color === "transparent") {
+ this.colorShow.element.css("background-color", "").removeClass("auto-color-normal-background").addClass("trans-color-background");
+ } else {
+ this.colorShow.element.css({"background-color": color}).removeClass("auto-color-normal-background").removeClass("trans-color-background");
+ }
+ },
+
+ _setEnable: function (enable) {
+ BI.ColorPickerEditor.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (enable === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ },
+
+ setValue: function (color) {
+ if (color === "transparent") {
+ this.transparent.setSelected(true);
+ this.none.setSelected(false);
+ this._showPreColor("transparent");
+ this.R.setValue("");
+ this.G.setValue("");
+ this.B.setValue("");
+ this.storeValue = {
+ r: "",
+ g: "",
+ b: ""
+ };
+ return;
+ }
+ if (!color) {
+ color = "";
+ this.none.setSelected(true);
+ } else {
+ this.none.setSelected(false);
+ }
+ this.transparent.setSelected(false);
+ this._showPreColor(color);
+ var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color));
+ this.storeValue = {
+ r: BI.isNull(json.r) ? "" : json.r,
+ g: BI.isNull(json.r) ? "" : json.g,
+ b: BI.isNull(json.r) ? "" : json.b
+ };
+ this.R.setValue(this.storeValue.r);
+ this.G.setValue(this.storeValue.g);
+ this.B.setValue(this.storeValue.b);
+ },
+
+ getValue: function () {
+ if (this._isEmptyRGB() && this.transparent.isSelected()) {
+ return "transparent";
+ }
+ return BI.DOM.rgb2hex(BI.DOM.json2rgb({
+ r: this.storeValue.r,
+ g: this.storeValue.g,
+ b: this.storeValue.b
+ }));
+ }
+});
+BI.ColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
+BI.shortcut("bi.color_picker_editor", BI.ColorPickerEditor);/**
+ * 简单选色控件
+ *
+ * Created by GUY on 2015/11/16.
+ * @class BI.SimpleColorPickerEditor
+ * @extends BI.Widget
+ */
+BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SimpleColorPickerEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-color-picker-editor",
+ // width: 200,
+ height: 30
+ });
+ },
+
+ _init: function () {
+ BI.SimpleColorPickerEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.colorShow = BI.createWidget({
+ type: "bi.layout",
+ cls: "color-picker-editor-display bi-card bi-border",
+ height: 16,
+ width: 16
+ });
+ var RGB = BI.createWidgets(BI.createItems([{text: "R"}, {text: "G"}, {text: "B"}], {
+ type: "bi.label",
+ cls: "color-picker-editor-label",
+ width: 20,
+ height: 20
+ }));
+
+ var checker = function (v) {
+ return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255;
+ };
+ var Ws = BI.createWidgets([{}, {}, {}], {
+ type: "bi.small_text_editor",
+ cls: "color-picker-editor-input",
+ validationChecker: checker,
+ errorText: BI.i18nText("BI-Color_Picker_Error_Text"),
+ allowBlank: true,
+ value: 255,
+ width: 32,
+ height: 20
+ });
+ BI.each(Ws, function (i, w) {
+ w.on(BI.TextEditor.EVENT_CHANGE, function () {
+ if (self.R.isValid() && self.G.isValid() && self.B.isValid()) {
+ self.colorShow.element.css("background-color", self.getValue());
+ self.fireEvent(BI.SimpleColorPickerEditor.EVENT_CHANGE);
+ }
+ });
+ });
+ this.R = Ws[0];
+ this.G = Ws[1];
+ this.B = Ws[2];
+
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: [{
+ el: this.colorShow,
+ width: 16,
+ lgap: 20,
+ rgap: 15
+ }, {
+ el: RGB[0],
+ width: 20
+ }, {
+ el: this.R,
+ width: 30
+ }, {
+ el: RGB[1],
+ width: 20
+ }, {
+ el: this.G,
+ width: 30
+ }, {
+ el: RGB[2],
+ width: 20
+ }, {
+ el: this.B,
+ width: 30
+ }]
+ });
+ },
+
+ setValue: function (color) {
+ this.colorShow.element.css({"background-color": color});
+ var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color));
+ this.R.setValue(BI.isNull(json.r) ? "" : json.r);
+ this.G.setValue(BI.isNull(json.g) ? "" : json.g);
+ this.B.setValue(BI.isNull(json.b) ? "" : json.b);
+ },
+
+ getValue: function () {
+ return BI.DOM.rgb2hex(BI.DOM.json2rgb({
+ r: this.R.getValue(),
+ g: this.G.getValue(),
+ b: this.B.getValue()
+ }));
+ }
+});
+BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
+BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);BI.Farbtastic = BI.inherit(BI.BasicButton, {
+
+ constants: {
+ RADIUS: 84,
+ SQUARE: 100,
+ WIDTH: 194
+ },
+
+ props: {
+ baseCls: "bi-farbtastic",
+ width: 195,
+ height: 195,
+ stopPropagation: true,
+ value: "#000000"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "",
+ ref: function (_ref) {
+ self.colorWrapper = _ref;
+ }
+ },
+ top: 47,
+ left: 47,
+ width: 101,
+ height: 101
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "wheel",
+ ref: function (_ref) {
+ self.wheel = _ref;
+ }
+ },
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "overlay",
+ ref: function (_ref) {
+ self.overlay = _ref;
+ }
+ },
+ top: 47,
+ left: 47,
+ width: 101,
+ height: 101
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "marker",
+ ref: function (_ref) {
+ self.hMarker = _ref;
+ },
+ scrollable: false,
+ width: 17,
+ height: 17
+ }
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "marker",
+ ref: function (_ref) {
+ self.slMarker = _ref;
+ },
+ scrollable: false,
+ width: 17,
+ height: 17
+ }
+ }]
+ };
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (BI.isKey(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ _unpack: function (color) {
+ if (color.length === 7) {
+ return [parseInt("0x" + color.substring(1, 3)) / 255,
+ parseInt("0x" + color.substring(3, 5)) / 255,
+ parseInt("0x" + color.substring(5, 7)) / 255];
+ } else if (color.length === 4) {
+ return [parseInt("0x" + color.substring(1, 2)) / 15,
+ parseInt("0x" + color.substring(2, 3)) / 15,
+ parseInt("0x" + color.substring(3, 4)) / 15];
+ }
+ },
+
+ _pack: function (rgb) {
+ var r = Math.round(rgb[0] * 255);
+ var g = Math.round(rgb[1] * 255);
+ var b = Math.round(rgb[2] * 255);
+ return "#" + (r < 16 ? "0" : "") + r.toString(16) +
+ (g < 16 ? "0" : "") + g.toString(16) +
+ (b < 16 ? "0" : "") + b.toString(16);
+ },
+
+ _setColor: function (color) {
+ var unpack = this._unpack(color);
+ if (this.value !== color && unpack) {
+ this.value = color;
+ this.rgb = unpack;
+ this.hsl = this._RGBToHSL(this.rgb);
+ this._updateDisplay();
+ }
+ },
+
+ _setHSL: function (hsl) {
+ this.hsl = hsl;
+ this.rgb = this._HSLToRGB(hsl);
+ this.value = this._pack(this.rgb);
+ this._updateDisplay();
+ return this;
+ },
+
+ _HSLToRGB: function (hsl) {
+ var m1, m2, r, g, b;
+ var h = hsl[0], s = hsl[1], l = hsl[2];
+ m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
+ m1 = l * 2 - m2;
+ return [this._hueToRGB(m1, m2, h + 0.33333),
+ this._hueToRGB(m1, m2, h),
+ this._hueToRGB(m1, m2, h - 0.33333)];
+ },
+
+ _hueToRGB: function (m1, m2, h) {
+ h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
+ if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
+ if (h * 2 < 1) return m2;
+ if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
+ return m1;
+ },
+
+ _RGBToHSL: function (rgb) {
+ var min, max, delta, h, s, l;
+ var r = rgb[0], g = rgb[1], b = rgb[2];
+ min = Math.min(r, Math.min(g, b));
+ max = Math.max(r, Math.max(g, b));
+ delta = max - min;
+ l = (min + max) / 2;
+ s = 0;
+ if (l > 0 && l < 1) {
+ s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
+ }
+ h = 0;
+ if (delta > 0) {
+ if (max == r && max != g) h += (g - b) / delta;
+ if (max == g && max != b) h += (2 + (b - r) / delta);
+ if (max == b && max != r) h += (4 + (r - g) / delta);
+ h /= 6;
+ }
+ return [h, s, l];
+ },
+
+ _updateDisplay: function () {
+ var angle = this.hsl[0] * 6.28;
+ this.hMarker.element.css({
+ left: Math.round(Math.sin(angle) * this.constants.RADIUS + this.constants.WIDTH / 2) + "px",
+ top: Math.round(-Math.cos(angle) * this.constants.RADIUS + this.constants.WIDTH / 2) + "px"
+ });
+
+ this.slMarker.element.css({
+ left: Math.round(this.constants.SQUARE * (.5 - this.hsl[1]) + this.constants.WIDTH / 2) + "px",
+ top: Math.round(this.constants.SQUARE * (.5 - this.hsl[2]) + this.constants.WIDTH / 2) + "px"
+ });
+
+ // Saturation/Luminance gradient
+ this.colorWrapper.element.css("backgroundColor", this._pack(this._HSLToRGB([this.hsl[0], 1, 0.5])));
+
+ this.fireEvent(BI.Farbtastic.EVENT_CHANGE, this.getValue(), this);
+ },
+
+ _absolutePosition: function (el) {
+ var r = {x: el.offsetLeft, y: el.offsetTop};
+ // Resolve relative to offsetParent
+ if (el.offsetParent) {
+ var tmp = this._absolutePosition(el.offsetParent);
+ r.x += tmp.x;
+ r.y += tmp.y;
+ }
+ return r;
+ },
+
+ _widgetCoords: function (event) {
+ var x, y;
+ var el = event.target || event.srcElement;
+ var reference = this.wheel.element[0];
+
+ if (typeof event.offsetX !== "undefined") {
+ // Use offset coordinates and find common offsetParent
+ var pos = {x: event.offsetX, y: event.offsetY};
+
+ // Send the coordinates upwards through the offsetParent chain.
+ var e = el;
+ while (e) {
+ e.mouseX = pos.x;
+ e.mouseY = pos.y;
+ pos.x += e.offsetLeft;
+ pos.y += e.offsetTop;
+ e = e.offsetParent;
+ }
+
+ // Look for the coordinates starting from the wheel widget.
+ var e = reference;
+ var offset = {x: 0, y: 0};
+ while (e) {
+ if (typeof e.mouseX !== "undefined") {
+ x = e.mouseX - offset.x;
+ y = e.mouseY - offset.y;
+ break;
+ }
+ offset.x += e.offsetLeft;
+ offset.y += e.offsetTop;
+ e = e.offsetParent;
+ }
+
+ // Reset stored coordinates
+ e = el;
+ while (e) {
+ e.mouseX = undefined;
+ e.mouseY = undefined;
+ e = e.offsetParent;
+ }
+ } else {
+ // Use absolute coordinates
+ var pos = this._absolutePosition(reference);
+ x = (event.pageX || 0) - pos.x;
+ y = (event.pageY || 0) - pos.y;
+ }
+ // Subtract distance to middle
+ return {x: x - this.constants.WIDTH / 2, y: y - this.constants.WIDTH / 2};
+ },
+
+ _doMouseMove: function (event) {
+ var pos = this._widgetCoords(event);
+
+ // Set new HSL parameters
+ if (this.circleDrag) {
+ var hue = Math.atan2(pos.x, -pos.y) / 6.28;
+ if (hue < 0) hue += 1;
+ this._setHSL([hue, this.hsl[1], this.hsl[2]]);
+ } else {
+ var sat = Math.max(0, Math.min(1, -(pos.x / this.constants.SQUARE) + .5));
+ var lum = Math.max(0, Math.min(1, -(pos.y / this.constants.SQUARE) + .5));
+ this._setHSL([this.hsl[0], sat, lum]);
+ }
+ },
+
+ doClick: function (event) {
+ var pos = this._widgetCoords(event);
+ this.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > this.constants.SQUARE;
+
+ // Process
+ this._doMouseMove(event);
+ return false;
+ },
+
+ setValue: function (color) {
+ this._setColor(color);
+ },
+
+ getValue: function () {
+ return this.value;
+ }
+});
+BI.Farbtastic.EVENT_CHANGE = "Farbtastic.EVENT_CHANGE";
+BI.shortcut("bi.farbtastic", BI.Farbtastic);/**
+ * Created by GUY on 2017/2/8.
+ *
+ * @class BI.BubbleCombo
+ * @extends BI.Widget
+ */
+BI.BubbleCombo = BI.inherit(BI.Widget, {
+ _const: {
+ TRIANGLE_LENGTH: 6
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-bubble-combo",
+ trigger: "click",
+ toggle: true,
+ direction: "bottom,left", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
+ isDefaultInit: false,
+ destroyWhenHide: false,
+ isNeedAdjustHeight: true, // 是否需要高度调整
+ isNeedAdjustWidth: true,
+ stopPropagation: false,
+ adjustLength: 0, // 调整的距离
+ // adjustXOffset: 0,
+ // adjustYOffset: 10,
+ hideChecker: BI.emptyFn,
+ offsetStyle: "left", // left,right,center
+ el: {},
+ popup: {}
+ });
+ },
+ _init: function () {
+ BI.BubbleCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ trigger: o.trigger,
+ toggle: o.toggle,
+ container: o.container,
+ direction: o.direction,
+ isDefaultInit: o.isDefaultInit,
+ destroyWhenHide: o.destroyWhenHide,
+ isNeedAdjustHeight: o.isNeedAdjustHeight,
+ isNeedAdjustWidth: o.isNeedAdjustWidth,
+ adjustLength: this._getAdjustLength(),
+ stopPropagation: o.stopPropagation,
+ adjustXOffset: 0,
+ adjustYOffset: 0,
+ hideChecker: o.hideChecker,
+ offsetStyle: o.offsetStyle,
+ el: o.el,
+ popup: BI.extend({
+ type: "bi.bubble_popup_view"
+ }, o.popup)
+ });
+ this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_CHANGE, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_EXPAND, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_COLLAPSE, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () {
+ self._showTriangle();
+ self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
+ self._hideTriangle();
+ self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments);
+ });
+ },
+
+ _getAdjustLength: function () {
+ return this._const.TRIANGLE_LENGTH + this.options.adjustLength;
+ },
+
+ _createTriangle: function (direction) {
+ var pos = {}, op = {};
+ var adjustLength = this.options.adjustLength;
+ var offset = this.element.offset();
+ var left = offset.left, right = offset.left + this.element.outerWidth();
+ var top = offset.top, bottom = offset.top + this.element.outerHeight();
+ switch (direction) {
+ case "left":
+ pos = {
+ top: top,
+ height: this.element.outerHeight(),
+ left: left - adjustLength - this._const.TRIANGLE_LENGTH
+ };
+ op = {width: this._const.TRIANGLE_LENGTH};
+ break;
+ case "right":
+ pos = {
+ top: top,
+ height: this.element.outerHeight(),
+ left: right + adjustLength
+ };
+ op = {width: this._const.TRIANGLE_LENGTH};
+ break;
+ case "top":
+ pos = {
+ left: left,
+ width: this.element.outerWidth(),
+ top: top - adjustLength - this._const.TRIANGLE_LENGTH
+ };
+ op = {height: this._const.TRIANGLE_LENGTH};
+ break;
+ case "bottom":
+ pos = {
+ left: left,
+ width: this.element.outerWidth(),
+ top: bottom + adjustLength
+ };
+ op = {height: this._const.TRIANGLE_LENGTH};
+ break;
+ default:
+ break;
+ }
+ this.triangle && this.triangle.destroy();
+ this.triangle = BI.createWidget(op, {
+ type: "bi.center_adapt",
+ cls: "button-combo-triangle-wrapper",
+ items: [{
+ type: "bi.layout",
+ cls: "bubble-combo-triangle-" + direction
+ }]
+ });
+ pos.el = this.triangle;
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [pos]
+ });
+ },
+
+ _createLeftTriangle: function () {
+ this._createTriangle("left");
+ },
+
+ _createRightTriangle: function () {
+ this._createTriangle("right");
+ },
+
+ _createTopTriangle: function () {
+ this._createTriangle("top");
+ },
+
+ _createBottomTriangle: function () {
+ this._createTriangle("bottom");
+ },
+
+ _showTriangle: function () {
+ var pos = this.combo.getPopupPosition();
+ switch (pos.dir) {
+ case "left,top":
+ case "left,bottom":
+ this._createLeftTriangle();
+ break;
+ case "right,top":
+ case "right,bottom":
+ this._createRightTriangle();
+ break;
+ case "top,left":
+ case "top,right":
+ this._createTopTriangle();
+ break;
+ case "bottom,left":
+ case "bottom,right":
+ this._createBottomTriangle();
+ break;
+ }
+ },
+
+ _hideTriangle: function () {
+ this.triangle && this.triangle.destroy();
+ this.triangle = null;
+ },
+
+ hideView: function () {
+ this._hideTriangle();
+ this.combo && this.combo.hideView();
+ },
+
+ showView: function () {
+ this.combo && this.combo.showView();
+ },
+
+ isViewVisible: function () {
+ return this.combo.isViewVisible();
+ }
+});
+
+BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
+BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND";
+BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE";
+BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
+
+
+BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
+BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
+BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
+BI.shortcut("bi.bubble_combo", BI.BubbleCombo);/**
+ * Created by GUY on 2017/2/8.
+ *
+ * @class BI.BubblePopupView
+ * @extends BI.PopupView
+ */
+BI.BubblePopupView = BI.inherit(BI.PopupView, {
+ _defaultConfig: function () {
+ var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(config, {
+ baseCls: config.baseCls + " bi-bubble-popup-view",
+ minWidth: 220,
+ maxWidth: 300,
+ minHeight: 90
+ });
+ },
+ _init: function () {
+ BI.BubblePopupView.superclass._init.apply(this, arguments);
+ }
+});
+
+BI.shortcut("bi.bubble_popup_view", BI.BubblePopupView);
+
+/**
+ * Created by GUY on 2017/2/8.
+ *
+ * @class BI.BubblePopupBarView
+ * @extends BI.BubblePopupView
+ */
+BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, {
+ _defaultConfig: function () {
+ return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-bubble-bar-popup-view",
+ buttons: [{
+ value: BI.i18nText("BI-Basic_Cancel"),
+ ghost: true
+ }, {value: BI.i18nText(BI.i18nText("BI-Basic_Sure"))}]
+ });
+ },
+ _init: function () {
+ BI.BubblePopupBarView.superclass._init.apply(this, arguments);
+ },
+ _createToolBar: function () {
+ var o = this.options, self = this;
+
+ var items = [];
+ BI.each(o.buttons, function (i, buttonOpt) {
+ if (BI.isWidget(buttonOpt)) {
+ items.push(buttonOpt);
+ } else {
+ items.push(BI.extend({
+ type: "bi.button",
+ height: 24,
+ handler: function (v) {
+ self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v);
+ }
+ }, buttonOpt));
+ }
+ });
+ return BI.createWidget({
+ type: "bi.center",
+ height: 44,
+ rgap: 15,
+ items: [{
+ type: "bi.right_vertical_adapt",
+ lgap: 10,
+ items: items
+ }]
+ });
+ },
+
+ _createView: function () {
+ var o = this.options;
+
+ var button = BI.createWidget({
+ type: "bi.button_group",
+ items: [o.el],
+ layouts: [{
+ type: "bi.vertical",
+ cls: "bar-popup-container",
+ hgap: 15,
+ tgap: 10
+ }]
+ });
+
+ button.element.css("min-height", o.minHeight - 44);
+
+ return button;
+ }
+});
+BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
+BI.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView);
+
+/**
+ * Created by Windy on 2018/2/2.
+ *
+ * @class BI.TextBubblePopupBarView
+ * @extends BI.BubblePopupView
+ */
+BI.TextBubblePopupBarView = BI.inherit(BI.Widget, {
+
+ props: function () {
+ return {
+ baseCls: "bi-text-bubble-bar-popup-view",
+ text: "",
+ buttons: [{
+ level: "ignore",
+ value: false,
+ text: BI.i18nText("BI-Basic_Cancel")
+ }, {
+ value: true,
+ text: BI.i18nText("BI-Basic_Sure")
+ }]
+ };
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ var buttons = BI.map(o.buttons, function (index, buttonOpt) {
+ if (BI.isWidget(buttonOpt)) {
+ return buttonOpt;
+ }
+ return BI.extend({
+ type: "bi.button",
+ height: 24,
+ handler: function (v) {
+ self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v);
+ }
+ }, buttonOpt);
+
+ });
+ return {
+ type: "bi.bubble_bar_popup_view",
+ ref: function () {
+ self.popup = this;
+ },
+ el: {
+ type: "bi.label",
+ text: o.text,
+ whiteSpace: "normal",
+ textAlign: "left",
+ ref: function () {
+ self.text = this;
+ }
+ },
+ buttons: buttons
+ };
+ },
+
+ populate: function (v) {
+ this.text.setText(v || this.options.text);
+ }
+});
+BI.TextBubblePopupBarView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_bubble_bar_popup_view", BI.TextBubblePopupBarView);
+/**
+ * Created by Young's on 2016/4/28.
+ */
+BI.EditorIconCheckCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.EditorIconCheckCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseClass: "bi-check-editor-combo",
+ width: 100,
+ height: 24,
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: true,
+ watermark: "",
+ errorText: ""
+ });
+ },
+
+ _init: function () {
+ BI.EditorIconCheckCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.editor_trigger",
+ items: o.items,
+ height: o.height,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText,
+ value: o.value
+ });
+ this.trigger.on(BI.EditorTrigger.EVENT_CHANGE, function () {
+ self.popup.setValue(this.getValue());
+ self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE);
+ });
+ this.popup = BI.createWidget({
+ type: "bi.text_value_check_combo_popup",
+ chooseType: o.chooseType,
+ items: o.items,
+ value: o.value
+ });
+ this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.editorIconCheckCombo.hideView();
+ self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editorIconCheckCombo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 300
+ }
+ });
+ },
+
+ setValue: function (v) {
+ this.editorIconCheckCombo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.trigger.getValue();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.editorIconCheckCombo.populate(items);
+ }
+});
+BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);
+/**
+ * Created by GUY on 2016/2/2.
+ *
+ * @class BI.IconCombo
+ * @extend BI.Widget
+ */
+BI.IconCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-icon-combo",
+ width: 24,
+ height: 24,
+ el: {},
+ popup: {},
+ minWidth: 100,
+ maxWidth: "auto",
+ maxHeight: 300,
+ direction: "bottom",
+ adjustLength: 3, // 调整的距离
+ adjustXOffset: 0,
+ adjustYOffset: 0,
+ offsetStyle: "left",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ });
+ },
+
+ _init: function () {
+ BI.IconCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget(o.el, {
+ type: "bi.icon_combo_trigger",
+ iconCls: o.iconCls,
+ title: o.title,
+ items: o.items,
+ width: o.width,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight,
+ value: o.value
+ });
+ this.popup = BI.createWidget(o.popup, {
+ type: "bi.icon_combo_popup",
+ chooseType: o.chooseType,
+ items: o.items,
+ value: o.value
+ });
+ this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.iconCombo.hideView();
+ self.fireEvent(BI.IconCombo.EVENT_CHANGE);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.iconCombo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ direction: o.direction,
+ trigger: o.trigger,
+ container: o.container,
+ adjustLength: o.adjustLength,
+ adjustXOffset: o.adjustXOffset,
+ adjustYOffset: o.adjustYOffset,
+ offsetStyle: o.offsetStyle,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxWidth: o.maxWidth,
+ maxHeight: o.maxHeight,
+ minWidth: o.minWidth
+ }
+ });
+ },
+
+ showView: function () {
+ this.iconCombo.showView();
+ },
+
+ hideView: function () {
+ this.iconCombo.hideView();
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ var value = this.popup.getValue();
+ return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.iconCombo.populate(items);
+ }
+});
+BI.IconCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_combo", BI.IconCombo);/**
+ * Created by GUY on 2016/2/2.
+ *
+ * @class BI.IconComboPopup
+ * @extend BI.Pane
+ */
+BI.IconComboPopup = BI.inherit(BI.Pane, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconComboPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi.icon-combo-popup",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ });
+ },
+
+ _init: function () {
+ BI.IconComboPopup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ this.popup = BI.createWidget({
+ type: "bi.button_group",
+ items: BI.createItems(o.items, {
+ type: "bi.single_select_icon_text_item",
+ height: 24
+ }),
+ chooseType: o.chooseType,
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+
+ this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.IconComboPopup.EVENT_CHANGE, val, obj);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.popup]
+ });
+ },
+
+ populate: function (items) {
+ BI.IconComboPopup.superclass.populate.apply(this, arguments);
+ items = BI.createItems(items, {
+ type: "bi.single_select_icon_text_item",
+ height: 24
+ });
+ this.popup.populate(items);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ this.popup.setValue(v);
+ }
+
+});
+BI.IconComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_combo_popup", BI.IconComboPopup);/**
+ * Created by GUY on 2016/2/2.
+ *
+ * @class BI.IconComboTrigger
+ * @extend BI.Widget
+ */
+BI.IconComboTrigger = BI.inherit(BI.Trigger, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconComboTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-icon-combo-trigger",
+ el: {},
+ items: [],
+ iconCls: "",
+ width: 24,
+ height: 24,
+ isShowDown: true,
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.IconComboTrigger.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ var iconCls = "";
+ if(BI.isKey(o.value)){
+ iconCls = this._digest(o.value, o.items);
+ }
+ this.button = BI.createWidget(o.el, {
+ type: "bi.icon_change_button",
+ cls: "icon-combo-trigger-icon",
+ iconCls: iconCls,
+ disableSelected: true,
+ width: o.isShowDown ? o.width - 12 : o.width,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight,
+ selected: BI.isNotEmptyString(iconCls)
+ });
+ this.down = BI.createWidget({
+ type: "bi.icon_button",
+ disableSelected: true,
+ cls: "icon-combo-down-icon trigger-triangle-font font-size-12",
+ width: 12,
+ height: 8,
+ selected: BI.isNotEmptyString(iconCls)
+ });
+ this.down.setVisible(o.isShowDown);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.button,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: this.down,
+ right: 3,
+ bottom: 0
+ }]
+ });
+ },
+
+ _digest: function (v, items) {
+ var iconCls = "";
+ v = BI.isArray(v) ? v[0] : v;
+ BI.any(items, function (i, item) {
+ if (v === item.value) {
+ iconCls = item.iconCls;
+ return true;
+ }
+ });
+ return iconCls;
+ },
+
+ populate: function (items) {
+ var o = this.options;
+ this.options.items = items || [];
+ this.button.setIcon(o.iconCls);
+ this.button.setSelected(false);
+ this.down.setSelected(false);
+ },
+
+ setValue: function (v) {
+ BI.IconComboTrigger.superclass.setValue.apply(this, arguments);
+ var o = this.options;
+ var iconCls = this._digest(v, this.options.items);
+ v = BI.isArray(v) ? v[0] : v;
+ if (BI.isNotEmptyString(iconCls)) {
+ this.button.setIcon(iconCls);
+ this.button.setSelected(true);
+ this.down.setSelected(true);
+ } else {
+ this.button.setIcon(o.iconCls);
+ this.button.setSelected(false);
+ this.down.setSelected(false);
+ }
+ }
+});
+BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);/**
+ * Created by Windy on 2017/12/12.
+ * combo : icon + text + icon, popup : icon + text
+ */
+BI.IconTextValueCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-icon-text-value-combo",
+ height: 24,
+ iconHeight: null,
+ iconWidth: null,
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.IconTextValueCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.select_icon_text_trigger",
+ cls: "icon-text-value-trigger",
+ items: o.items,
+ height: o.height,
+ text: o.text,
+ iconCls: o.iconCls,
+ value: o.value,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ iconWrapperWidth: o.iconWrapperWidth,
+ title: o.title,
+ warningTitle: o.warningTitle
+ });
+ this.popup = BI.createWidget({
+ type: "bi.icon_text_value_combo_popup",
+ items: o.items,
+ value: o.value,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ iconWrapperWidth: o.iconWrapperWidth
+ });
+ this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.textIconCombo.hideView();
+ self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.textIconCombo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ container: o.container,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 240
+ }
+ });
+ if (BI.isKey(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ _checkError: function (v) {
+ if(BI.isNotNull(v)) {
+ v = BI.isArray(v) ? v : [v];
+ var result = BI.find(this.options.items, function (idx, item) {
+ return BI.contains(v, item.value);
+ });
+ if (BI.isNull(result)) {
+ this.trigger.options.tipType = "warning";
+ this.element.removeClass("combo-error").addClass("combo-error");
+ } else {
+ this.trigger.options.tipType = "success";
+ this.element.removeClass("combo-error");
+ }
+ }
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ this._checkError(v);
+ },
+
+ getValue: function () {
+ var value = this.popup.getValue();
+ return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.textIconCombo.populate(items);
+ }
+});
+BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);
+/**
+ * Created by Windy on 2017/12/12.
+ */
+BI.IconTextValueComboPopup = BI.inherit(BI.Pane, {
+ _defaultConfig: function () {
+ return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-icon-text-icon-popup"
+ });
+ },
+
+ _init: function () {
+ BI.IconTextValueComboPopup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ this.popup = BI.createWidget({
+ type: "bi.button_group",
+ items: BI.createItems(o.items, {
+ type: "bi.single_select_icon_text_item",
+ height: 24,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ iconWrapperWidth: o.iconWrapperWidth
+ }),
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ value: o.value
+ });
+
+ this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.popup]
+ });
+ },
+
+ populate: function (items, keyword) {
+ BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments);
+ var o = this.options;
+ items = BI.createItems(items, {
+ type: "bi.single_select_icon_text_item",
+ height: 24,
+ iconWrapperWidth: o.iconWrapperWidth,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth
+ });
+ this.popup.populate(items, keyword);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ this.popup.setValue(v);
+ }
+
+});
+BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);
+/**
+ * Created by Windy on 2018/2/2.
+ */
+BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-search-text-value-combo",
+ height: 24,
+ text: "",
+ items: [],
+ tipType: "",
+ warningTitle: "",
+ attributes: {
+ tabIndex: 0
+ }
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.combo",
+ container: o.container,
+ adjustLength: 2,
+ toggle: false,
+ ref: function () {
+ self.combo = this;
+ },
+ el: {
+ type: "bi.search_text_value_trigger",
+ cls: "search-text-value-trigger",
+ ref: function () {
+ self.trigger = this;
+ },
+ items: o.items,
+ height: o.height - 2,
+ text: o.text,
+ value: o.value,
+ tipType: o.tipType,
+ warningTitle: o.warningTitle,
+ title: o.title,
+ listeners: [{
+ eventName: BI.SearchTextValueTrigger.EVENT_CHANGE,
+ action: function () {
+ self.setValue(this.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
+ }
+ }]
+ },
+ popup: {
+ el: {
+ type: "bi.text_value_combo_popup",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ value: o.value,
+ items: o.items,
+ ref: function () {
+ self.popup = this;
+ self.trigger.getSearcher().setAdapter(self.popup);
+ },
+ listeners: [{
+ eventName: BI.TextValueComboPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(this.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
+ }
+ }]
+ },
+ maxHeight: 252
+ },
+ listeners: [{
+ eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
+ action: function () {
+ self.trigger.stopEditing();
+ }
+ }, {
+ eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW);
+ }
+ }],
+ hideChecker: function (e) {
+ return self.triggerBtn.element.find(e.target).length === 0;
+ }
+ },
+ left: 0,
+ right: 0,
+ bottom: 0,
+ top: 0
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ cls: "trigger-icon-button",
+ ref: function () {
+ self.triggerBtn = this;
+ },
+ width: o.height,
+ height: o.height,
+ handler: function () {
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ }
+ },
+ right: 0,
+ bottom: 0,
+ top: 0
+ }]
+ };
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if(BI.isKey(o.value)) {
+ this._checkError(o.value);
+ }
+ },
+
+ _checkError: function (v) {
+ if(BI.isNotNull(v)) {
+ v = BI.isArray(v) ? v : [v];
+ var result = BI.find(this.options.items, function (idx, item) {
+ return BI.contains(v, item.value);
+ });
+ if (BI.isNull(result)) {
+ this.element.removeClass("combo-error").addClass("combo-error");
+ this.trigger.attr("tipType", "warning");
+ } else {
+ this.element.removeClass("combo-error");
+ this.trigger.attr("tipType", "success");
+ }
+ }
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.combo.populate(items);
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ this._checkError(v);
+ },
+
+ getValue: function () {
+ var value = this.popup.getValue();
+ return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
+ }
+});
+BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);
+/**
+ * Created by Windy on 2018/2/5.
+ */
+BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, {
+
+ props: {
+ baseCls: "bi-search-text-value-popup"
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vertical",
+ vgap: 5,
+ items: [{
+ type: "bi.button_group",
+ ref: function () {
+ self.popup = this;
+ },
+ items: BI.createItems(o.items, {
+ type: "bi.single_select_item",
+ textAlign: o.textAlign,
+ height: 24
+ }),
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ value: o.value,
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj);
+ }
+ }
+ }]
+ }]
+ };
+ },
+
+ populate: function (find, match, keyword) {
+ var items = BI.concat(find, match);
+ BI.SearchTextValueComboPopup.superclass.populate.apply(this, items);
+ items = BI.createItems(items, {
+ type: "bi.single_select_item",
+ height: 24
+ });
+ this.popup.populate(items, keyword);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ this.popup.setValue(v);
+ }
+
+});
+BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/**
+ * Created by Windy on 2018/2/2.
+ */
+BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
+
+ props: {
+ extraCls: "bi-search-text-value-trigger bi-border",
+ height: 24
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.htape",
+ items: [
+ {
+ el: {
+ type: "bi.searcher",
+ ref: function () {
+ self.searcher = this;
+ },
+ isAutoSearch: false,
+ el: {
+ type: "bi.state_editor",
+ ref: function () {
+ self.editor = this;
+ },
+ text: this._digest(o.value, o.items),
+ value: o.value,
+ height: o.height,
+ tipText: ""
+ },
+ popup: {
+ type: "bi.search_text_value_combo_popup",
+ cls: "bi-card",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ },
+ onSearch: function (obj, callback) {
+ var keyword = obj.keyword;
+ var finding = BI.Func.getSearchResult(o.items, keyword);
+ var matched = finding.match, find = finding.find;
+ callback(find, matched);
+ },
+ listeners: [{
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE);
+ }
+ }]
+ }
+ }, {
+ el: {
+ type: "bi.layout",
+ width: 24
+ },
+ width: 24
+ }
+ ]
+ };
+ },
+
+ _setState: function (v) {
+ this.editor.setState(v);
+ },
+
+ _digest: function(vals, items){
+ var o = this.options;
+ vals = BI.isArray(vals) ? vals : [vals];
+ var result = [];
+ var formatItems = BI.Tree.transformToArrayFormat(items);
+ BI.each(formatItems, function (i, item) {
+ if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) {
+ result.push(item.text || item.value);
+ }
+ });
+
+ if (result.length > 0) {
+ return result.join(",");
+ } else {
+ return o.text;
+ }
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ },
+
+ setValue: function (vals) {
+ this._setState(this._digest(vals, this.options.items));
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP";
+BI.SearchTextValueTrigger.EVENT_START = "EVENT_START";
+BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/**
+ * @class BI.TextValueCheckCombo
+ * @extend BI.Widget
+ * combo : text + icon, popup : check + text
+ */
+BI.TextValueCheckCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-text-value-check-combo",
+ width: 100,
+ height: 24,
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.TextValueCheckCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ cls: "text-value-trigger",
+ items: o.items,
+ height: o.height,
+ text: o.text,
+ value: o.value
+ });
+ this.popup = BI.createWidget({
+ type: "bi.text_value_check_combo_popup",
+ chooseType: o.chooseType,
+ items: o.items,
+ value: o.value
+ });
+ this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.textIconCheckCombo.hideView();
+ self.fireEvent(BI.TextValueCheckCombo.EVENT_CHANGE);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.textIconCheckCombo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 300
+ }
+ });
+
+ if (BI.isKey(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ setTitle: function (title) {
+ this.trigger.setTitle(title);
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ setWarningTitle: function (title) {
+ this.trigger.setWarningTitle(title);
+ },
+
+ getValue: function () {
+ var value = this.popup.getValue();
+ return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.textIconCheckCombo.populate(items);
+ }
+});
+BI.TextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_value_check_combo", BI.TextValueCheckCombo);/**
+ * @class BI.SmallTextValueCheckCombo
+ * @extend BI.Widget
+ * combo : text + icon, popup : check + text
+ */
+BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SmallTextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), {
+ width: 100,
+ height: 24,
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.SmallTextValueCheckCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.small_select_text_trigger",
+ items: o.items,
+ height: o.height,
+ text: o.text,
+ value: o.value
+ });
+ this.popup = BI.createWidget({
+ type: "bi.text_value_check_combo_popup",
+ chooseType: o.chooseType,
+ items: o.items,
+ value: o.value
+ });
+ this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.SmallTextIconCheckCombo.hideView();
+ self.fireEvent(BI.SmallTextValueCheckCombo.EVENT_CHANGE);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.SmallTextIconCheckCombo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 300
+ }
+ });
+ },
+
+ setValue: function (v) {
+ this.SmallTextIconCheckCombo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.SmallTextIconCheckCombo.populate(items);
+ }
+});
+BI.SmallTextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.small_text_value_check_combo", BI.SmallTextValueCheckCombo);BI.TextValueCheckComboPopup = BI.inherit(BI.Pane, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TextValueCheckComboPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-text-icon-popup",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ });
+ },
+
+ _init: function () {
+ BI.TextValueCheckComboPopup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ this.popup = BI.createWidget({
+ type: "bi.button_group",
+ items: this._formatItems(o.items),
+ chooseType: o.chooseType,
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+
+ this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.TextValueCheckComboPopup.EVENT_CHANGE, val, obj);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.popup]
+ });
+ },
+
+ _formatItems: function (items) {
+ return BI.map(items, function (i, item) {
+ return BI.extend({
+ type: "bi.single_select_item",
+ cls: "bi-list-item",
+ height: 24
+ }, item);
+ });
+ },
+
+ populate: function (items) {
+ BI.TextValueCheckComboPopup.superclass.populate.apply(this, arguments);
+ this.popup.populate(this._formatItems(items));
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ this.popup.setValue(v);
+ }
+
+});
+BI.TextValueCheckComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_value_check_combo_popup", BI.TextValueCheckComboPopup);
+/**
+ * @class BI.TextValueCombo
+ * @extend BI.Widget
+ * combo : text + icon, popup : text
+ * 参见场景dashboard布局方式选择
+ */
+BI.TextValueCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-text-value-combo",
+ height: 24,
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ text: "",
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.TextValueCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ cls: "text-value-trigger",
+ items: o.items,
+ height: o.height,
+ text: o.text,
+ value: o.value,
+ warningTitle: o.warningTitle
+ });
+ this.popup = BI.createWidget({
+ type: "bi.text_value_combo_popup",
+ chooseType: o.chooseType,
+ value: o.value,
+ items: o.items
+ });
+ this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.textIconCombo.hideView();
+ self.fireEvent(BI.TextValueCombo.EVENT_CHANGE, arguments);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.textIconCombo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 240
+ }
+ });
+ if(BI.isKey(o.value)) {
+ this._checkError(o.value);
+ }
+ },
+
+ _checkError: function (v) {
+ if(BI.isNotNull(v)) {
+ v = BI.isArray(v) ? v : [v];
+ var result = BI.find(this.options.items, function (idx, item) {
+ return BI.contains(v, item.value);
+ });
+ if (BI.isNull(result)) {
+ this.trigger.setTipType("warning");
+ this.element.removeClass("combo-error").addClass("combo-error");
+ } else {
+ this.trigger.setTipType("success");
+ this.element.removeClass("combo-error");
+ }
+ }
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ this._checkError(v);
+ },
+
+ getValue: function () {
+ var value = this.popup.getValue();
+ return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.textIconCombo.populate(items);
+ }
+});
+BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_value_combo", BI.TextValueCombo);
+/**
+ * @class BI.SmallTextValueCombo
+ * @extend BI.Widget
+ * combo : text + icon, popup : text
+ * 参见场景dashboard布局方式选择
+ */
+BI.SmallTextValueCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SmallTextValueCombo.superclass._defaultConfig.apply(this, arguments), {
+ width: 100,
+ height: 20,
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ el: {},
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.SmallTextValueCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget(o.el, {
+ type: "bi.small_select_text_trigger",
+ items: o.items,
+ height: o.height,
+ text: o.text
+ });
+ this.popup = BI.createWidget({
+ type: "bi.text_value_combo_popup",
+ chooseType: o.chooseType,
+ items: o.items
+ });
+ this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.SmallTextValueCombo.hideView();
+ self.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE);
+ });
+ this.popup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.SmallTextValueCombo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ container: o.container,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup,
+ maxHeight: 240
+ }
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.SmallTextValueCombo.populate(items);
+ }
+});
+BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueComboPopup = BI.inherit(BI.Pane, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-text-icon-popup",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE
+ });
+ },
+
+ _init: function () {
+ BI.TextValueComboPopup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ this.popup = BI.createWidget({
+ type: "bi.button_group",
+ items: BI.createItems(o.items, {
+ type: "bi.single_select_item",
+ textAlign: o.textAlign,
+ height: 24
+ }),
+ chooseType: o.chooseType,
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+
+ this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj);
+ }
+ });
+ this.check();
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.popup]
+ });
+ },
+
+ populate: function (items) {
+ BI.TextValueComboPopup.superclass.populate.apply(this, arguments);
+ items = BI.createItems(items, {
+ type: "bi.single_select_item",
+ height: 24
+ });
+ this.popup.populate(items);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ this.popup.setValue(v);
+ }
+
+});
+BI.TextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_value_combo_popup", BI.TextValueComboPopup);/**
+ * @class BI.TextValueDownListCombo
+ * @extend BI.Widget
+ */
+BI.TextValueDownListCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.TextValueDownListCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-text-value-down-list-combo",
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.TextValueDownListCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this._createValueMap();
+
+ var value;
+ if(BI.isNotNull(o.value)) {
+ value = this._digest(o.value);
+ }
+ this.trigger = BI.createWidget({
+ type: "bi.down_list_select_text_trigger",
+ cls: "text-value-down-list-trigger",
+ height: o.height,
+ items: o.items,
+ text: o.text,
+ value: value
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.down_list_combo",
+ element: this,
+ chooseType: BI.Selection.Single,
+ adjustLength: 2,
+ height: o.height,
+ el: this.trigger,
+ value: BI.isNull(value) ? [] : [value],
+ items: BI.deepClone(o.items)
+ });
+
+ this.combo.on(BI.DownListCombo.EVENT_CHANGE, function () {
+ var currentVal = self.combo.getValue()[0].value;
+ if (currentVal !== self.value) {
+ self.setValue(currentVal);
+ self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE);
+ }
+ });
+
+ this.combo.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function () {
+ var currentVal = self.combo.getValue()[0].childValue;
+ if (currentVal !== self.value) {
+ self.setValue(currentVal);
+ self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE);
+ }
+ });
+ },
+
+ _createValueMap: function () {
+ var self = this;
+ this.valueMap = {};
+ BI.each(BI.flatten(this.options.items), function (idx, item) {
+ if (BI.has(item, "el")) {
+ BI.each(item.children, function (id, it) {
+ self.valueMap[it.value] = {value: item.el.value, childValue: it.value};
+ });
+ } else {
+ self.valueMap[item.value] = {value: item.value};
+ }
+ });
+ },
+
+ _digest: function (v) {
+ this.value = v;
+ return this.valueMap[v];
+ },
+
+ setValue: function (v) {
+ v = this._digest(v);
+ this.combo.setValue([v]);
+ this.trigger.setValue(v);
+ },
+
+ getValue: function () {
+ var v = this.combo.getValue()[0];
+ return [v.childValue || v.value];
+ },
+
+ populate: function (items) {
+ this.options.items = BI.flatten(items);
+ this.combo.populate(items);
+ this._createValueMap();
+ }
+});
+BI.TextValueDownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_value_down_list_combo", BI.TextValueDownListCombo);/**
+ * 选择字段trigger, downlist专用
+ * 显示形式为 父亲值(儿子值)
+ *
+ * @class BI.DownListSelectTextTrigger
+ * @extends BI.Trigger
+ */
+BI.DownListSelectTextTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-select-text-trigger",
+ height: 24,
+ text: ""
+ });
+ },
+
+ _init: function () {
+ BI.DownListSelectTextTrigger.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ element: this,
+ height: o.height,
+ items: this._formatItemArray(o.items),
+ text: o.text,
+ value: BI.isNull(o.value) ? "" : o.value.childValue || o.value.value
+ });
+ },
+
+ _formatItemArray: function () {
+ var sourceArray = BI.flatten(BI.deepClone(this.options.items));
+ var targetArray = [];
+ BI.each(sourceArray, function (idx, item) {
+ if(BI.has(item, "el")) {
+ BI.each(item.children, function (id, it) {
+ it.text = item.el.text + "(" + it.text + ")";
+ });
+ targetArray = BI.concat(targetArray, item.children);
+ }else{
+ targetArray.push(item);
+ }
+ });
+ return targetArray;
+ },
+
+ setValue: function (vals) {
+ this.trigger.setValue(vals.childValue || vals.value);
+ },
+
+ populate: function (items) {
+ this.trigger.populate(this._formatItemArray(items));
+ }
+});
+BI.shortcut("bi.down_list_select_text_trigger", BI.DownListSelectTextTrigger);/**
+ * 有清楚按钮的文本框
+ * Created by GUY on 2015/9/29.
+ * @class BI.SmallTextEditor
+ * @extends BI.SearchEditor
+ */
+BI.ClearEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.ClearEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-clear-editor",
+ height: 24,
+ errorText: "",
+ watermark: "",
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.ClearEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ watermark: o.watermark,
+ allowBlank: true,
+ errorText: o.errorText,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ value: o.value
+ });
+ this.clear = BI.createWidget({
+ type: "bi.icon_button",
+ stopEvent: true,
+ cls: "search-close-h-font"
+ });
+ this.clear.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.setValue("");
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT);
+ self.fireEvent(BI.ClearEditor.EVENT_CLEAR);
+ });
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.editor
+ },
+ {
+ el: this.clear,
+ width: 24
+ }]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_FOCUS);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_BLUR);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_CLICK);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self._checkClear();
+ self.fireEvent(BI.ClearEditor.EVENT_CHANGE);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.ClearEditor.EVENT_KEY_DOWN, v);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_SPACE);
+ });
+ this.editor.on(BI.Editor.EVENT_BACKSPACE, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_BACKSPACE);
+ });
+
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_VALID);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_ERROR);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_ENTER);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_RESTRICT);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self._checkClear();
+ self.fireEvent(BI.ClearEditor.EVENT_EMPTY);
+ });
+ this.editor.on(BI.Editor.EVENT_REMOVE, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_REMOVE);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_START);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.ClearEditor.EVENT_STOP);
+ });
+
+ if (BI.isKey(o.value)) {
+ this.clear.visible();
+ } else {
+ this.clear.invisible();
+ }
+ },
+
+ _checkClear: function () {
+ if (!this.getValue()) {
+ this.clear.invisible();
+ } else {
+ this.clear.visible();
+ }
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ getValue: function () {
+ if (this.isValid()) {
+ var res = this.editor.getValue().match(/[\S]+/g);
+ return BI.isNull(res) ? "" : res[res.length - 1];
+ }
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ if (BI.isKey(v)) {
+ this.clear.visible();
+ }
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ }
+});
+BI.ClearEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.ClearEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.ClearEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.ClearEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.ClearEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.ClearEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.ClearEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
+BI.ClearEditor.EVENT_CLEAR = "EVENT_CLEAR";
+
+BI.ClearEditor.EVENT_START = "EVENT_START";
+BI.ClearEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.ClearEditor.EVENT_STOP = "EVENT_STOP";
+BI.ClearEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.ClearEditor.EVENT_VALID = "EVENT_VALID";
+BI.ClearEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.ClearEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.ClearEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.ClearEditor.EVENT_REMOVE = "EVENT_REMOVE";
+BI.ClearEditor.EVENT_EMPTY = "EVENT_EMPTY";
+BI.shortcut("bi.clear_editor", BI.ClearEditor);/**
+ * 带标记的文本框
+ * Created by GUY on 2016/1/25.
+ * @class BI.ShelterEditor
+ * @extends BI.Widget
+ */
+BI.ShelterEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.ShelterEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-shelter-editor",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: true,
+ watermark: "",
+ errorText: "",
+ height: 24,
+ textAlign: "left"
+ });
+ },
+
+ _init: function () {
+ BI.ShelterEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText
+ });
+ this.text = BI.createWidget({
+ type: "bi.text_button",
+ cls: "shelter-editor-text",
+ title: o.title,
+ warningTitle: o.warningTitle,
+ tipType: o.tipType,
+ textAlign: o.textAlign,
+ height: o.height,
+ hgap: o.hgap
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.text,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.text.on(BI.Controller.EVENT_CHANGE, function () {
+ arguments[2] = self;
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.text.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_CLICK_LABEL);
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_FOCUS, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_BLUR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_CLICK, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.ShelterEditor.EVENT_KEY_DOWN, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_VALID, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self._showHint();
+ self._checkText();
+ self.fireEvent(BI.ShelterEditor.EVENT_CONFIRM, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_START, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_PAUSE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_STOP, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_SPACE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkText();
+ self.fireEvent(BI.ShelterEditor.EVENT_ERROR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_ENTER, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_RESTRICT, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self.fireEvent(BI.ShelterEditor.EVENT_EMPTY, arguments);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ this._showHint();
+ self._checkText();
+ this.text.doRedMark(o.keyword);
+ },
+
+ _checkText: function () {
+ var o = this.options;
+ if (this.editor.getValue() === "") {
+ this.text.setValue(o.watermark || "");
+ this.text.element.addClass("bi-water-mark");
+ } else {
+ this.text.setValue(this.editor.getValue());
+ this.text.element.removeClass("bi-water-mark");
+ }
+ },
+
+ _showInput: function () {
+ this.editor.visible();
+ this.text.invisible();
+ },
+
+ _showHint: function () {
+ this.editor.invisible();
+ this.text.visible();
+ },
+
+ setTitle: function (title) {
+ this.text.setTitle(title);
+ },
+
+ setWarningTitle: function (title) {
+ this.text.setWarningTitle(title);
+ },
+
+ focus: function () {
+ this._showInput();
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ this._showHint();
+ this._checkText();
+ },
+
+ doRedMark: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setTextStyle: function (style) {
+ this.text.setStyle(style);
+ },
+
+ setValue: function (k) {
+ this.editor.setValue(k);
+ this._checkText();
+ this.text.doRedMark(this.options.keyword);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getState: function () {
+ return this.text.getValue();
+ },
+
+ setState: function (v) {
+ this._showHint();
+ this.text.setValue(v);
+ }
+});
+BI.ShelterEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.ShelterEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.ShelterEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.ShelterEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.ShelterEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.ShelterEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
+
+BI.ShelterEditor.EVENT_START = "EVENT_START";
+BI.ShelterEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.ShelterEditor.EVENT_STOP = "EVENT_STOP";
+BI.ShelterEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.ShelterEditor.EVENT_VALID = "EVENT_VALID";
+BI.ShelterEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.ShelterEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.ShelterEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY";
+
+BI.shortcut("bi.shelter_editor", BI.ShelterEditor);
+/**
+ * 带标记的文本框
+ * Created by GUY on 2015/8/28.
+ * @class BI.SignEditor
+ * @extends BI.Widget
+ */
+BI.SignEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.SignEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-sign-editor",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: true,
+ watermark: "",
+ errorText: "",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.SignEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText
+ });
+ this.text = BI.createWidget({
+ type: "bi.text_button",
+ cls: "sign-editor-text",
+ title: o.title,
+ warningTitle: o.warningTitle,
+ tipType: o.tipType,
+ textAlign: "left",
+ height: o.height,
+ hgap: 4,
+ handler: function () {
+ self._showInput();
+ self.editor.focus();
+ self.editor.selectAll();
+ }
+ });
+ this.text.on(BI.TextButton.EVENT_CHANGE, function () {
+ BI.nextTick(function () {
+ self.fireEvent(BI.SignEditor.EVENT_CLICK_LABEL);
+ });
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.text,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.SignEditor.EVENT_FOCUS, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.SignEditor.EVENT_BLUR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.SignEditor.EVENT_CLICK, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SignEditor.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.SignEditor.EVENT_KEY_DOWN, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.SignEditor.EVENT_VALID, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self._showHint();
+ self._checkText();
+ self.fireEvent(BI.SignEditor.EVENT_CONFIRM, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.SignEditor.EVENT_START, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SignEditor.EVENT_PAUSE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.SignEditor.EVENT_STOP, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.SignEditor.EVENT_SPACE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkText();
+ self.fireEvent(BI.SignEditor.EVENT_ERROR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.SignEditor.EVENT_ENTER, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.SignEditor.EVENT_RESTRICT, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self.fireEvent(BI.SignEditor.EVENT_EMPTY, arguments);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ this._showHint();
+ self._checkText();
+ },
+
+ _checkText: function () {
+ var o = this.options;
+ BI.nextTick(BI.bind(function () {
+ if (this.editor.getValue() === "") {
+ this.text.setValue(o.watermark || "");
+ this.text.element.addClass("bi-water-mark");
+ } else {
+ this.text.setValue(this.editor.getValue());
+ this.text.element.removeClass("bi-water-mark");
+ }
+ }, this));
+ },
+
+ _showInput: function () {
+ this.editor.visible();
+ this.text.invisible();
+ },
+
+ _showHint: function () {
+ this.editor.invisible();
+ this.text.visible();
+ },
+
+ setTitle: function (title) {
+ this.text.setTitle(title);
+ },
+
+ setWarningTitle: function (title) {
+ this.text.setWarningTitle(title);
+ },
+
+ focus: function () {
+ this._showInput();
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ this._showHint();
+ this._checkText();
+ },
+
+ doRedMark: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setValue: function (k) {
+ this.editor.setValue(k);
+ this._checkText();
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getState: function () {
+ return this.text.getValue();
+ },
+
+ setState: function (v) {
+ this._showHint();
+ this.text.setValue(v);
+ }
+});
+BI.SignEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SignEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.SignEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.SignEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.SignEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.SignEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
+
+BI.SignEditor.EVENT_START = "EVENT_START";
+BI.SignEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SignEditor.EVENT_STOP = "EVENT_STOP";
+BI.SignEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.SignEditor.EVENT_VALID = "EVENT_VALID";
+BI.SignEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.SignEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.SignEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.SignEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.SignEditor.EVENT_EMPTY = "EVENT_EMPTY";
+
+BI.shortcut("bi.sign_editor", BI.SignEditor);/**
+ * guy
+ * 记录状态的输入框
+ * @class BI.StateEditor
+ * @extends BI.Single
+ */
+BI.StateEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.StateEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-state-editor",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: true,
+ watermark: "",
+ errorText: "",
+ height: 24,
+ text: BI.i18nText("BI-Basic_Unrestricted")
+ });
+ },
+
+ _init: function () {
+ BI.StateEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText
+ });
+ this.text = BI.createWidget({
+ type: "bi.text_button",
+ cls: "state-editor-infinite-text tip-text-style",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ hgap: 4,
+ handler: function () {
+ self._showInput();
+ self.editor.focus();
+ self.editor.setValue("");
+ },
+ title: BI.isNotNull(o.tipText) ? o.tipText : function () {
+ var title = "";
+ if (BI.isString(self.stateValue)) {
+ title = self.stateValue;
+ }
+ if (BI.isArray(self.stateValue) && self.stateValue.length === 1) {
+ title = self.stateValue[0];
+ }
+ return title;
+ },
+ warningTitle: o.warningTitle,
+ tipType: o.tipType
+ });
+ this.text.on(BI.TextButton.EVENT_CHANGE, function () {
+ BI.nextTick(function () {
+ self.fireEvent(BI.StateEditor.EVENT_CLICK_LABEL);
+ });
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.text,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.StateEditor.EVENT_FOCUS, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.StateEditor.EVENT_BLUR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.StateEditor.EVENT_CLICK, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.StateEditor.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.StateEditor.EVENT_KEY_DOWN, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.StateEditor.EVENT_VALID, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self._showHint();
+ self.fireEvent(BI.StateEditor.EVENT_CONFIRM, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.StateEditor.EVENT_START, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.StateEditor.EVENT_PAUSE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.StateEditor.EVENT_STOP, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.StateEditor.EVENT_SPACE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self.fireEvent(BI.StateEditor.EVENT_ERROR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.StateEditor.EVENT_ENTER, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.StateEditor.EVENT_RESTRICT, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self.fireEvent(BI.StateEditor.EVENT_EMPTY, arguments);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ this._showHint();
+ if(BI.isNotNull(o.text)){
+ this.setState(o.text);
+ }
+ },
+
+ doRedMark: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ focus: function () {
+ if (this.options.disabled === false) {
+ this._showInput();
+ this.editor.focus();
+ }
+ },
+
+ blur: function () {
+ this.editor.blur();
+ this._showHint();
+ },
+
+ _showInput: function () {
+ this.editor.visible();
+ this.text.invisible();
+ },
+
+ _showHint: function () {
+ this.editor.invisible();
+ this.text.visible();
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setValue: function (k) {
+ this.editor.setValue(k);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getState: function () {
+ return this.editor.getValue().match(/[^\s]+/g);
+ },
+
+ setState: function (v) {
+ var o = this.options;
+ BI.StateEditor.superclass.setValue.apply(this, arguments);
+ this.stateValue = v;
+ if (BI.isNumber(v)) {
+ if (v === BI.Selection.All) {
+ this.text.setText(BI.i18nText("BI-Select_All"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else if (v === BI.Selection.Multi) {
+ this.text.setText(BI.i18nText("BI-Select_Part"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else {
+ this.text.setText(o.text);
+ this.text.element.addClass("state-editor-infinite-text");
+ }
+ return;
+ }
+ if (BI.isString(v)) {
+ this.text.setText(v);
+ this.text.element.removeClass("state-editor-infinite-text");
+ return;
+ }
+ if (BI.isArray(v)) {
+ if (BI.isEmpty(v)) {
+ this.text.setText(o.text);
+ this.text.element.addClass("state-editor-infinite-text");
+ } else if (v.length === 1) {
+ this.text.setText(v[0]);
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else {
+ this.text.setText(BI.i18nText("BI-Select_Part"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ }
+ }
+ },
+
+ setTipType: function (v) {
+ this.text.options.tipType = v;
+ }
+});
+BI.StateEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.StateEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.StateEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.StateEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.StateEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.StateEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
+
+BI.StateEditor.EVENT_START = "EVENT_START";
+BI.StateEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.StateEditor.EVENT_STOP = "EVENT_STOP";
+BI.StateEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.StateEditor.EVENT_VALID = "EVENT_VALID";
+BI.StateEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.StateEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.StateEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.StateEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.StateEditor.EVENT_EMPTY = "EVENT_EMPTY";
+
+BI.shortcut("bi.state_editor", BI.StateEditor);
+/**
+ * 无限制-已选择状态输入框
+ * Created by GUY on 2016/5/18.
+ * @class BI.SimpleStateEditor
+ * @extends BI.Single
+ */
+BI.SimpleStateEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.SimpleStateEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-simple-state-editor",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ mouseOut: false,
+ allowBlank: true,
+ watermark: "",
+ errorText: "",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.SimpleStateEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText
+ });
+ this.text = BI.createWidget({
+ type: "bi.text_button",
+ cls: "state-editor-infinite-text",
+ textAlign: "left",
+ height: o.height,
+ text: BI.i18nText("BI-Basic_Unrestricted"),
+ hgap: 4,
+ handler: function () {
+ self._showInput();
+ self.editor.focus();
+ self.editor.setValue("");
+ }
+ });
+ this.text.on(BI.TextButton.EVENT_CHANGE, function () {
+ BI.nextTick(function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_CLICK_LABEL);
+ });
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.text,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_FOCUS, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_BLUR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_CLICK, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_KEY_DOWN, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_VALID, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self._showHint();
+ self.fireEvent(BI.SimpleStateEditor.EVENT_CONFIRM, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_START, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_PAUSE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_STOP, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_SPACE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_ERROR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_ENTER, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_RESTRICT, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self.fireEvent(BI.SimpleStateEditor.EVENT_EMPTY, arguments);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ this._showHint();
+ if(BI.isNotNull(o.text)){
+ this.setState(o.text);
+ }
+ },
+
+ doRedMark: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ focus: function () {
+ this._showInput();
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ this._showHint();
+ },
+
+ _showInput: function () {
+ this.editor.visible();
+ this.text.invisible();
+ },
+
+ _showHint: function () {
+ this.editor.invisible();
+ this.text.visible();
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setValue: function (k) {
+ this.editor.setValue(k);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getState: function () {
+ return this.editor.getValue().match(/[^\s]+/g);
+ },
+
+ setState: function (v) {
+ BI.SimpleStateEditor.superclass.setValue.apply(this, arguments);
+ if (BI.isNumber(v)) {
+ if (v === BI.Selection.All) {
+ this.text.setText(BI.i18nText("BI-Already_Selected"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else if (v === BI.Selection.Multi) {
+ this.text.setText(BI.i18nText("BI-Already_Selected"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else {
+ this.text.setText(BI.i18nText("BI-Basic_Unrestricted"));
+ this.text.element.addClass("state-editor-infinite-text");
+ }
+ return;
+ }
+ if (!BI.isArray(v) || v.length === 1) {
+ this.text.setText(v);
+ this.text.setTitle(v);
+ this.text.element.removeClass("state-editor-infinite-text");
+ } else if (BI.isEmpty(v)) {
+ this.text.setText(BI.i18nText("BI-Basic_Unrestricted"));
+ this.text.element.addClass("state-editor-infinite-text");
+ } else {
+ this.text.setText(BI.i18nText("BI-Already_Selected"));
+ this.text.element.removeClass("state-editor-infinite-text");
+ }
+ }
+});
+BI.SimpleStateEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SimpleStateEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.SimpleStateEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.SimpleStateEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.SimpleStateEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.SimpleStateEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
+
+BI.SimpleStateEditor.EVENT_START = "EVENT_START";
+BI.SimpleStateEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SimpleStateEditor.EVENT_STOP = "EVENT_STOP";
+BI.SimpleStateEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.SimpleStateEditor.EVENT_VALID = "EVENT_VALID";
+BI.SimpleStateEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.SimpleStateEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.SimpleStateEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.SimpleStateEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.SimpleStateEditor.EVENT_EMPTY = "EVENT_EMPTY";
+
+BI.shortcut("bi.simple_state_editor", BI.SimpleStateEditor);/**
+ * 下拉框弹出层的多选版本,toolbar带有若干按钮, zIndex在1000w
+ * @class BI.MultiPopupView
+ * @extends BI.Widget
+ */
+
+BI.MultiPopupView = BI.inherit(BI.PopupView, {
+
+ _defaultConfig: function () {
+ var conf = BI.MultiPopupView.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ _baseCls: (conf._baseCls || "") + " bi-multi-list-view",
+ buttons: [BI.i18nText("BI-Basic_Sure")]
+ });
+ },
+
+ _init: function () {
+ BI.MultiPopupView.superclass._init.apply(this, arguments);
+ },
+
+ _createToolBar: function () {
+ var o = this.options, self = this;
+ if (o.buttons.length === 0) {
+ return;
+ }
+
+ var text = []; // 构造[{text:content},……]
+ BI.each(o.buttons, function (idx, item) {
+ text.push({
+ text: item,
+ value: idx
+ });
+ });
+
+ this.buttongroup = BI.createWidget({
+ type: "bi.button_group",
+ cls: "list-view-toolbar bi-high-light bi-split-top",
+ height: 24,
+ items: BI.createItems(text, {
+ type: "bi.text_button",
+ once: false,
+ shadow: true,
+ isShadowShowingOnSelected: true
+ }),
+ layouts: [{
+ type: "bi.center",
+ hgap: 0,
+ vgap: 0
+ }]
+ });
+
+ this.buttongroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
+ self.fireEvent(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, value, obj);
+ });
+
+ return this.buttongroup;
+ }
+
+});
+
+BI.MultiPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
+
+BI.shortcut("bi.multi_popup_view", BI.MultiPopupView);/**
+ * 可以理解为MultiPopupView和Panel两个面板的结合体
+ * @class BI.PopupPanel
+ * @extends BI.MultiPopupView
+ */
+
+BI.PopupPanel = BI.inherit(BI.MultiPopupView, {
+
+ _defaultConfig: function () {
+ var conf = BI.PopupPanel.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-popup-panel",
+ title: ""
+ });
+ },
+
+ _init: function () {
+ BI.PopupPanel.superclass._init.apply(this, arguments);
+ },
+
+ _createTool: function () {
+ var self = this, o = this.options;
+ var close = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "close-h-font",
+ width: 25,
+ height: 25
+ });
+ close.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.setVisible(false);
+ self.fireEvent(BI.PopupPanel.EVENT_CLOSE);
+ });
+ return BI.createWidget({
+ type: "bi.htape",
+ cls: "popup-panel-title bi-header-background",
+ height: 25,
+ items: [{
+ el: {
+ type: "bi.label",
+ textAlign: "left",
+ text: o.title,
+ height: 25,
+ lgap: 10
+ }
+ }, {
+ el: close,
+ width: 25
+ }]
+ });
+ }
+});
+
+BI.PopupPanel.EVENT_CHANGE = "EVENT_CHANGE";
+BI.PopupPanel.EVENT_CLOSE = "EVENT_CLOSE";
+BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON";
+
+BI.shortcut("bi.popup_panel", BI.PopupPanel);/**
+ * list面板
+ *
+ * Created by GUY on 2015/10/30.
+ * @class BI.ListPane
+ * @extends BI.Pane
+ */
+BI.ListPane = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ var conf = BI.ListPane.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-list-pane",
+ logic: {
+ dynamic: true
+ },
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ vgap: 0,
+ hgap: 0,
+ items: [],
+ itemsCreator: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+ el: {
+ type: "bi.button_group"
+ }
+ });
+ },
+ _init: function () {
+ BI.ListPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.button_group = BI.createWidget(o.el, {
+ type: "bi.button_group",
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ behaviors: {},
+ items: o.items,
+ itemsCreator: function (op, calback) {
+ if (op.times === 1) {
+ self.empty();
+ BI.nextTick(function () {
+ self.loading();
+ });
+ }
+ o.itemsCreator(op, function () {
+ calback.apply(self, arguments);
+ op.times === 1 && BI.nextTick(function () {
+ self.loaded();
+ });
+ });
+ },
+ hasNext: o.hasNext,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.ListPane.EVENT_CHANGE, value, obj);
+ }
+ });
+ this.check();
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({
+ scrolly: true,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ vgap: o.vgap,
+ hgap: o.hgap
+ }, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group)
+ }))));
+ },
+
+ hasPrev: function () {
+ return this.button_group.hasPrev && this.button_group.hasPrev();
+ },
+
+ hasNext: function () {
+ return this.button_group.hasNext && this.button_group.hasNext();
+ },
+
+ prependItems: function (items) {
+ this.options.items = items.concat(this.options.items);
+ this.button_group.prependItems.apply(this.button_group, arguments);
+ this.check();
+ },
+
+ addItems: function (items) {
+ this.options.items = this.options.items.concat(items);
+ this.button_group.addItems.apply(this.button_group, arguments);
+ this.check();
+ },
+
+ removeItemAt: function (indexes) {
+ indexes = indexes || [];
+ BI.removeAt(this.options.items, indexes);
+ this.button_group.removeItemAt.apply(this.button_group, arguments);
+ this.check();
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ if (arguments.length === 0 && (BI.isFunction(this.button_group.attr("itemsCreator")))) {// 接管loader的populate方法
+ this.button_group.attr("itemsCreator").apply(this, [{times: 1}, function () {
+ if (arguments.length === 0) {
+ throw new Error("参数不能为空");
+ }
+ self.populate.apply(self, arguments);
+ }]);
+ return;
+ }
+ BI.ListPane.superclass.populate.apply(this, arguments);
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ setNotSelectedValue: function () {
+ this.button_group.setNotSelectedValue.apply(this.button_group, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.button_group.getNotSelectedValue();
+ },
+
+ setValue: function () {
+ this.button_group.setValue.apply(this.button_group, arguments);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue.apply(this.button_group, arguments);
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.button_group.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.button_group.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.button_group.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.button_group.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.button_group.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.button_group.getNodeByValue(value);
+ }
+});
+BI.ListPane.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.list_pane", BI.ListPane);/**
+ * 带有标题栏的pane
+ * @class BI.Panel
+ * @extends BI.Widget
+ */
+BI.Panel = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Panel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-panel bi-border",
+ title: "",
+ titleButtons: [],
+ el: {},
+ logic: {
+ dynamic: false
+ }
+ });
+ },
+
+ _init: function () {
+ BI.Panel.superclass._init.apply(this, arguments);
+ var o = this.options;
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("top", this._createTitle()
+ , this.options.el)
+ }))));
+ },
+
+ _createTitle: function () {
+ var self = this, o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "panel-title-text",
+ text: o.title,
+ height: 30
+ });
+
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ items: o.titleButtons,
+ layouts: [{
+ type: "bi.center_adapt",
+ lgap: 10
+ }]
+ });
+
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
+ self.fireEvent(BI.Panel.EVENT_CHANGE, value, obj);
+ });
+
+ return {
+ el: {
+ type: "bi.left_right_vertical_adapt",
+ cls: "panel-title bi-header-background bi-border-bottom",
+ height: 29,
+ items: {
+ left: [this.text],
+ right: [this.button_group]
+ },
+ lhgap: 10,
+ rhgap: 10
+ },
+ height: 29
+ };
+ },
+
+ setTitle: function (title) {
+ this.text.setValue(title);
+ }
+});
+BI.Panel.EVENT_CHANGE = "Panel.EVENT_CHANGE";
+
+BI.shortcut("bi.panel", BI.Panel);
+BI.LinearSegmentButton = BI.inherit(BI.BasicButton, {
+
+ props: {
+ extraCls: "bi-line-segment-button bi-list-item-effect",
+ once: true,
+ readonly: true,
+ hgap: 10,
+ height: 25
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+
+ return [{
+ type: "bi.label",
+ text: o.text,
+ height: o.height,
+ value: o.value,
+ hgap: o.hgap,
+ ref: function () {
+ self.text = this;
+ }
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "line-segment-button-line",
+ height: 2,
+ ref: function () {
+ self.line = this;
+ }
+ },
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ }];
+ },
+
+ setSelected: function (v) {
+ BI.LinearSegmentButton.superclass.setSelected.apply(this, arguments);
+ if (v) {
+ this.line.element.addClass("bi-high-light-background");
+ } else {
+ this.line.element.removeClass("bi-high-light-background");
+ }
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ }
+});
+BI.shortcut("bi.linear_segment_button", BI.LinearSegmentButton);BI.LinearSegment = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-linear-segment bi-split-bottom",
+ items: [],
+ height: 29
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.button_group",
+ items: BI.createItems(o.items, {
+ type: "bi.linear_segment_button",
+ height: o.height - 1
+ }),
+ layout: [{
+ type: "bi.center"
+ }],
+ listeners: [{
+ eventName: "__EVENT_CHANGE__",
+ action: function () {
+ self.fireEvent("__EVENT_CHANGE__", arguments);
+ }
+ }, {
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }],
+ ref: function () {
+ self.buttonGroup = this;
+ }
+ };
+ },
+
+ setValue: function (v) {
+ this.buttonGroup.setValue(v);
+ },
+
+ setEnabledValue: function (v) {
+ this.buttonGroup.setEnabledValue(v);
+ },
+
+
+ getValue: function () {
+ return this.buttonGroup.getValue();
+ }
+});
+BI.shortcut("bi.linear_segment", BI.LinearSegment);/**
+ * 选择列表
+ *
+ * Created by GUY on 2015/11/1.
+ * @class BI.SelectList
+ * @extends BI.Widget
+ */
+BI.SelectList = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-list",
+ direction: BI.Direction.Top, // toolbar的位置
+ logic: {
+ dynamic: true
+ },
+ items: [],
+ itemsCreator: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+ toolbar: {
+ type: "bi.multi_select_bar",
+ iconWrapperWidth: 36
+ },
+ el: {
+ type: "bi.list_pane"
+ }
+ });
+ },
+ _init: function () {
+ BI.SelectList.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ // 全选
+ this.toolbar = BI.createWidget(o.toolbar);
+ this.allSelected = false;
+ this.toolbar.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.allSelected = this.isSelected();
+ if (type === BI.Events.CLICK) {
+ self.setAllSelected(self.allSelected);
+ self.fireEvent(BI.SelectList.EVENT_CHANGE, value, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.list = BI.createWidget(o.el, {
+ type: "bi.list_pane",
+ items: o.items,
+ itemsCreator: function (op, callback) {
+ op.times === 1 && self.toolbar.setVisible(false);
+ o.itemsCreator(op, function (items) {
+ callback.apply(self, arguments);
+ if (op.times === 1) {
+ self.toolbar.setVisible(items && items.length > 0);
+ self.toolbar.setEnable(items && items.length > 0);
+ }
+ self._checkAllSelected();
+ });
+ },
+ onLoaded: o.onLoaded,
+ hasNext: o.hasNext
+ });
+
+ this.list.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (type === BI.Events.CLICK) {
+ self._checkAllSelected();
+ self.fireEvent(BI.SelectList.EVENT_CHANGE, value, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
+ scrolly: true
+ }, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.toolbar, this.list)
+ }))));
+
+ if (o.items.length <= 0) {
+ this.toolbar.setVisible(false);
+ this.toolbar.setEnable(false);
+ }
+ if(BI.isNotNull(o.value)){
+ this.setValue(o.value);
+ }
+ },
+
+ _checkAllSelected: function () {
+ var selectLength = this.list.getValue().length;
+ var notSelectLength = this.getAllLeaves().length - selectLength;
+ var hasNext = this.list.hasNext();
+ var isAlreadyAllSelected = this.toolbar.isSelected();
+ var isHalf = selectLength > 0 && (notSelectLength > 0 || (!isAlreadyAllSelected && hasNext));
+ isHalf = isHalf || (notSelectLength > 0 && hasNext && isAlreadyAllSelected);
+ this.toolbar.setHalfSelected(isHalf);
+ !isHalf && this.toolbar.setSelected(selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected));
+ },
+
+ setAllSelected: function (v) {
+ BI.each(this.getAllButtons(), function (i, btn) {
+ (btn.setSelected || btn.setAllSelected).apply(btn, [v]);
+ });
+ this.allSelected = !!v;
+ this.toolbar.setSelected(v);
+ this.toolbar.setHalfSelected(false);
+ },
+
+ setToolBarVisible: function (b) {
+ this.toolbar.setVisible(b);
+ },
+
+ isAllSelected: function () {
+ return this.allSelected;
+ // return this.toolbar.isSelected();
+ },
+
+ hasPrev: function () {
+ return this.list.hasPrev();
+ },
+
+ hasNext: function () {
+ return this.list.hasNext();
+ },
+
+ prependItems: function (items) {
+ this.list.prependItems.apply(this.list, arguments);
+ },
+
+ addItems: function (items) {
+ this.list.addItems.apply(this.list, arguments);
+ },
+
+ setValue: function (data) {
+ var selectAll = data.type === BI.ButtonGroup.CHOOSE_TYPE_ALL;
+ this.setAllSelected(selectAll);
+ this.list[selectAll ? "setNotSelectedValue" : "setValue"](data.value);
+ this._checkAllSelected();
+ },
+
+ getValue: function () {
+ if (this.isAllSelected() === false) {
+ return {
+ type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ value: this.list.getValue(),
+ assist: this.list.getNotSelectedValue()
+ };
+ }
+ return {
+ type: BI.ButtonGroup.CHOOSE_TYPE_ALL,
+ value: this.list.getNotSelectedValue(),
+ assist: this.list.getValue()
+ };
+
+ },
+
+ empty: function () {
+ this.list.empty();
+ },
+
+ populate: function (items) {
+ this.toolbar.setVisible(!BI.isEmptyArray(items));
+ this.toolbar.setEnable(!BI.isEmptyArray(items));
+ this.list.populate.apply(this.list, arguments);
+ this._checkAllSelected();
+ },
+
+ _setEnable: function (enable) {
+ BI.SelectList.superclass._setEnable.apply(this, arguments);
+ this.toolbar.setEnable(enable);
+ },
+
+ resetHeight: function (h) {
+ var toolHeight = ( this.toolbar.element.outerHeight() || 25) * ( this.toolbar.isVisible() ? 1 : 0);
+ this.list.resetHeight ? this.list.resetHeight(h - toolHeight) :
+ this.list.element.css({"max-height": h - toolHeight + "px"});
+ },
+
+ setNotSelectedValue: function () {
+ this.list.setNotSelectedValue.apply(this.list, arguments);
+ this._checkAllSelected();
+ },
+
+ getNotSelectedValue: function () {
+ return this.list.getNotSelectedValue();
+ },
+
+ getAllButtons: function () {
+ return this.list.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.list.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.list.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.list.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.list.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.list.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.list.getNodeByValue(value);
+ }
+});
+BI.SelectList.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.select_list", BI.SelectList);/**
+ * Created by roy on 15/11/6.
+ */
+BI.LazyLoader = BI.inherit(BI.Widget, {
+ _const: {
+ PAGE: 100
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.LazyLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-lazy-loader",
+ el: {}
+ });
+ },
+
+ _init: function () {
+ var self = this, o = this.options;
+ BI.LazyLoader.superclass._init.apply(this, arguments);
+ var all = o.items.length;
+ this.loader = BI.createWidget({
+ type: "bi.loader",
+ element: this,
+ // 下面是button_group的属性
+ el: o.el,
+
+ itemsCreator: function (options, populate) {
+ populate(self._getNextItems(options));
+ },
+ hasNext: function (option) {
+ return option.count < all;
+ }
+ });
+
+ this.loader.on(BI.Loader.EVENT_CHANGE, function (obj) {
+ self.fireEvent(BI.LazyLoader.EVENT_CHANGE, obj);
+ });
+ },
+ _getNextItems: function (options) {
+ var self = this, o = this.options;
+ var lastNum = o.items.length - this._const.PAGE * (options.times - 1);
+ var lastItems = BI.takeRight(o.items, lastNum);
+ var nextItems = BI.take(lastItems, this._const.PAGE);
+ return nextItems;
+ },
+
+ populate: function (items) {
+ this.loader.populate(items);
+ },
+
+ addItems: function (items) {
+ this.loader.addItems(items);
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ setNotSelectedValue: function () {
+ this.loader.setNotSelectedValue.apply(this.loader, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.loader.getNotSelectedValue();
+ },
+
+ setValue: function () {
+ this.loader.setValue.apply(this.loader, arguments);
+ },
+
+ getValue: function () {
+ return this.loader.getValue.apply(this.loader, arguments);
+ },
+
+ getAllButtons: function () {
+ return this.loader.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.loader.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.loader.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.loader.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.loader.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.loader.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.loader.getNodeByValue(value);
+ }
+});
+BI.LazyLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.lazy_loader", BI.LazyLoader);/**
+ * 恶心的加载控件, 为解决排序问题引入的控件
+ *
+ * Created by GUY on 2015/11/12.
+ * @class BI.ListLoader
+ * @extends BI.Widget
+ */
+BI.ListLoader = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ListLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-list-loader",
+
+ isDefaultInit: true, // 是否默认初始化数据
+
+ // 下面是button_group的属性
+ el: {
+ type: "bi.button_group"
+ },
+
+ items: [],
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+
+ // 下面是分页信息
+ count: false,
+ next: {},
+ hasNext: BI.emptyFn
+ });
+ },
+
+ _nextLoad: function () {
+ var self = this, o = this.options;
+ this.next.setLoading();
+ o.itemsCreator.apply(this, [{times: ++this.times}, function () {
+ self.next.setLoaded();
+ self.addItems.apply(self, arguments);
+ }]);
+ },
+
+ _init: function () {
+ BI.ListLoader.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (o.itemsCreator === false) {
+ o.next = false;
+ }
+
+ this.button_group = BI.createWidget(o.el, {
+ type: "bi.button_group",
+ element: this,
+ chooseType: 0,
+ items: o.items,
+ behaviors: {},
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.ListLoader.EVENT_CHANGE, obj);
+ }
+ });
+
+ if (o.next !== false) {
+ this.next = BI.createWidget(BI.extend({
+ type: "bi.loading_bar"
+ }, o.next));
+ this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self._nextLoad();
+ }
+ });
+ }
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.next]
+ });
+
+ o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () {
+ this.populate();
+ }, this));
+ if (BI.isNotEmptyArray(o.items)) {
+ this.populate(o.items);
+ }
+ },
+
+ hasNext: function () {
+ var o = this.options;
+ if (BI.isNumber(o.count)) {
+ return this.count < o.count;
+ }
+ return !!o.hasNext.apply(this, [{
+ times: this.times,
+ count: this.count
+ }]);
+ },
+
+ addItems: function (items) {
+ this.count += items.length;
+ if (BI.isObject(this.next)) {
+ if (this.hasNext()) {
+ this.options.items = this.options.items.concat(items);
+ this.next.setLoaded();
+ } else {
+ this.next.setEnd();
+ }
+ }
+ this.button_group.addItems.apply(this.button_group, arguments);
+ this.next.element.appendTo(this.element);
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
+ o.itemsCreator.apply(this, [{times: 1}, function () {
+ if (arguments.length === 0) {
+ throw new Error("参数不能为空");
+ }
+ self.populate.apply(self, arguments);
+ o.onLoaded();
+ }]);
+ return;
+ }
+ this.options.items = items;
+ this.times = 1;
+ this.count = 0;
+ this.count += items.length;
+ if (BI.isObject(this.next)) {
+ if (this.hasNext()) {
+ this.next.setLoaded();
+ } else {
+ this.next.invisible();
+ }
+ }
+ BI.DOM.hang([this.next]);
+ this.button_group.populate.apply(this.button_group, arguments);
+ this.next.element.appendTo(this.element);
+ },
+
+ empty: function () {
+ BI.DOM.hang([this.next]);
+ this.button_group.empty();
+ this.next.element.appendTo(this.element);
+ BI.each([this.next], function (i, ob) {
+ ob && ob.setVisible(false);
+ });
+ },
+
+ setNotSelectedValue: function () {
+ this.button_group.setNotSelectedValue.apply(this.button_group, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.button_group.getNotSelectedValue();
+ },
+
+ setValue: function () {
+ this.button_group.setValue.apply(this.button_group, arguments);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue.apply(this.button_group, arguments);
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.button_group.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.button_group.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.button_group.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.button_group.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.button_group.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.button_group.getNodeByValue(value);
+ }
+});
+BI.ListLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.list_loader", BI.ListLoader);/**
+ * Created by GUY on 2016/4/29.
+ *
+ * @class BI.SortList
+ * @extends BI.Widget
+ */
+BI.SortList = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SortList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-sort-list",
+
+ isDefaultInit: true, // 是否默认初始化数据
+
+ // 下面是button_group的属性
+ el: {
+ type: "bi.button_group"
+ },
+
+ items: [],
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+
+ // 下面是分页信息
+ count: false,
+ next: {},
+ hasNext: BI.emptyFn
+
+ // containment: this.element,
+ // connectWith: ".bi-sort-list",
+ });
+ },
+
+ _init: function () {
+ BI.SortList.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.loader = BI.createWidget({
+ type: "bi.list_loader",
+ element: this,
+ isDefaultInit: o.isDefaultInit,
+ el: o.el,
+ items: this._formatItems(o.items),
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (items) {
+ callback(self._formatItems(items));
+ });
+ },
+ onLoaded: o.onLoaded,
+ count: o.count,
+ next: o.next,
+ hasNext: o.hasNext
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.SortList.EVENT_CHANGE, value, obj);
+ }
+ });
+
+ this.loader.element.sortable({
+ containment: o.containment || this.element,
+ connectWith: o.connectWith || ".bi-sort-list",
+ items: ".sort-item",
+ cursor: o.cursor || "drag",
+ tolerance: o.tolerance || "intersect",
+ placeholder: {
+ element: function ($currentItem) {
+ var holder = BI.createWidget({
+ type: "bi.layout",
+ cls: "bi-sortable-holder",
+ height: $currentItem.outerHeight()
+ });
+ holder.element.css({
+ "margin-left": $currentItem.css("margin-left"),
+ "margin-right": $currentItem.css("margin-right"),
+ "margin-top": $currentItem.css("margin-top"),
+ "margin-bottom": $currentItem.css("margin-bottom"),
+ margin: $currentItem.css("margin")
+ });
+ return holder.element;
+ },
+ update: function () {
+
+ }
+ },
+ start: function (event, ui) {
+
+ },
+ stop: function (event, ui) {
+ self.fireEvent(BI.SortList.EVENT_CHANGE);
+ },
+ over: function (event, ui) {
+
+ }
+ });
+ },
+
+ _formatItems: function (items) {
+ BI.each(items, function (i, item) {
+ item = BI.stripEL(item);
+ item.cls = item.cls ? item.cls + " sort-item" : "sort-item";
+ item.attributes = {
+ sorted: item.value
+ };
+ });
+ return items;
+ },
+
+ hasNext: function () {
+ return this.loader.hasNext();
+ },
+
+ addItems: function (items) {
+ this.loader.addItems(items);
+ },
+
+ populate: function (items) {
+ if (items) {
+ arguments[0] = this._formatItems(items);
+ }
+ this.loader.populate.apply(this.loader, arguments);
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ setNotSelectedValue: function () {
+ this.loader.setNotSelectedValue.apply(this.loader, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.loader.getNotSelectedValue();
+ },
+
+ setValue: function () {
+ this.loader.setValue.apply(this.loader, arguments);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.loader.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.loader.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.loader.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.loader.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.loader.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.loader.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.loader.getNodeByValue(value);
+ },
+
+ getSortedValues: function () {
+ return this.loader.element.sortable("toArray", {attribute: "sorted"});
+ }
+});
+BI.SortList.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.sort_list", BI.SortList);
+/**
+ * author: young
+ * createdDate: 2018/12/18
+ * description:
+ */
+BI.LoadingPane = BI.inherit(BI.Pane, {
+ _mount: function () {
+ var isMounted = BI.Pane.superclass._mount.apply(this, arguments);
+ if (isMounted) {
+ if (this.beforeInit) {
+ this.__asking = true;
+ this.loading();
+ this.beforeInit(BI.bind(this.__loaded, this));
+ }
+ }
+ },
+
+ _initRender: function () {
+ if (this.beforeInit) {
+ this.__async = true;
+ } else {
+ this._render();
+ }
+ },
+
+ __loaded: function () {
+ this.__asking = false;
+ this.loaded();
+ this._render();
+ }
+});/**
+ * 有总页数和总行数的分页控件
+ * Created by Young's on 2016/10/13.
+ */
+BI.AllCountPager = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-all-count-pager",
+ height: 24,
+ pages: 1, // 必选项
+ curr: 1, // 初始化当前页, pages为数字时可用,
+ count: 1 // 总行数
+ });
+ },
+ _init: function () {
+ BI.AllCountPager.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.small_text_editor",
+ cls: "pager-editor",
+ validationChecker: function (v) {
+ return (self.rowCount.getValue() === 0 && v === "0") || BI.isPositiveInteger(v);
+ },
+ hgap: 4,
+ vgap: 0,
+ value: o.curr,
+ errorText: BI.i18nText("BI-Please_Input_Positive_Integer"),
+ width: 40,
+ height: 24
+ });
+
+ this.pager = BI.createWidget({
+ type: "bi.pager",
+ width: 58,
+ layouts: [{
+ type: "bi.horizontal",
+ lgap: 5
+ }],
+
+ dynamicShow: false,
+ pages: o.pages,
+ curr: o.curr,
+ groups: 0,
+
+ first: false,
+ last: false,
+ prev: {
+ type: "bi.icon_button",
+ value: "prev",
+ title: BI.i18nText("BI-Previous_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
+ height: 22,
+ width: 22,
+ cls: "bi-border all-pager-prev pull-up-font"
+ },
+ next: {
+ type: "bi.icon_button",
+ value: "next",
+ title: BI.i18nText("BI-Next_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
+ height: 22,
+ width: 22,
+ cls: "bi-border all-pager-next pull-down-font"
+ },
+
+ hasPrev: o.hasPrev,
+ hasNext: o.hasNext,
+ firstPage: o.firstPage,
+ lastPage: o.lastPage
+ });
+
+ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
+ self.pager.setValue(BI.parseInt(self.editor.getValue()));
+ self.fireEvent(BI.AllCountPager.EVENT_CHANGE);
+ });
+ this.pager.on(BI.Pager.EVENT_CHANGE, function () {
+ self.fireEvent(BI.AllCountPager.EVENT_CHANGE);
+ });
+ this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () {
+ self.editor.setValue(self.pager.getCurrentPage());
+ });
+
+ this.allPages = BI.createWidget({
+ type: "bi.label",
+ title: o.pages,
+ text: "/" + o.pages,
+ lgap: 5
+ });
+
+ this.rowCount = BI.createWidget({
+ type: "bi.label",
+ cls: "row-count",
+ height: o.height,
+ hgap: 5,
+ text: o.count,
+ title: o.count
+ });
+
+ var count = BI.createWidget({
+ type: "bi.left",
+ height: o.height,
+ scrollable: false,
+ items: [{
+ type: "bi.label",
+ height: o.height,
+ text: BI.i18nText("BI-Basic_Total"),
+ width: 15
+ }, this.rowCount, {
+ type: "bi.label",
+ height: o.height,
+ text: BI.i18nText("BI-Tiao_Data"),
+ width: 50,
+ textAlign: "left"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.left_right_vertical_adapt",
+ element: this,
+ items: {
+ left: [count],
+ right: [this.editor, this.allPages, this.pager]
+ }
+ });
+ },
+
+ alwaysShowPager: true,
+
+ setAllPages: function (v) {
+ this.allPages.setText("/" + v);
+ this.allPages.setTitle(v);
+ this.pager.setAllPages(v);
+ this.editor.setEnable(v >= 1);
+ },
+
+ setValue: function (v) {
+ this.pager.setValue(v);
+ },
+
+ setVPage: function (v) {
+ this.pager.setValue(v);
+ },
+
+ setCount: function (count) {
+ this.rowCount.setText(count);
+ this.rowCount.setTitle(count);
+ },
+
+ getCurrentPage: function () {
+ return this.pager.getCurrentPage();
+ },
+
+ hasPrev: function () {
+ return this.pager.hasPrev();
+ },
+
+ hasNext: function () {
+ return this.pager.hasNext();
+ },
+
+ setPagerVisible: function (b) {
+ this.editor.setVisible(b);
+ this.allPages.setVisible(b);
+ this.pager.setVisible(b);
+ },
+
+ populate: function () {
+ this.pager.populate();
+ }
+});
+BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.all_count_pager", BI.AllCountPager);/**
+ * 显示页码的分页控件
+ *
+ * Created by GUY on 2016/6/30.
+ * @class BI.DirectionPager
+ * @extends BI.Widget
+ */
+BI.DirectionPager = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DirectionPager.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-direction-pager",
+ height: 20,
+ horizontal: {
+ pages: false, // 总页数
+ curr: 1, // 初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ },
+ vertical: {
+ pages: false, // 总页数
+ curr: 1, // 初始化当前页, pages为数字时可用
+
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ firstPage: 1,
+ lastPage: BI.emptyFn
+ }
+ });
+ },
+ _init: function () {
+ BI.DirectionPager.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var v = o.vertical, h = o.horizontal;
+ this._createVPager();
+ this._createHPager();
+ this.layout = BI.createWidget({
+ type: "bi.absolute",
+ scrollable: false,
+ element: this,
+ items: [{
+ el: this.vpager,
+ top: 0,
+ right: 74
+ }, {
+ el: this.vlabel,
+ top: 0,
+ right: 111
+ }, {
+ el: this.hpager,
+ top: 0,
+ right: -9
+ }, {
+ el: this.hlabel,
+ top: 0,
+ right: 28
+ }]
+ });
+ },
+
+ _createVPager: function () {
+ var self = this, o = this.options;
+ var v = o.vertical;
+ this.vlabel = BI.createWidget({
+ type: "bi.label",
+ width: 24,
+ height: 20,
+ value: v.curr,
+ title: v.curr,
+ invisible: true
+ });
+ this.vpager = BI.createWidget({
+ type: "bi.pager",
+ width: 76,
+ layouts: [{
+ type: "bi.horizontal",
+ scrollx: false,
+ rgap: 24,
+ vgap: 1
+ }],
+ invisible: true,
+
+ dynamicShow: false,
+ pages: v.pages,
+ curr: v.curr,
+ groups: 0,
+
+ first: false,
+ last: false,
+ prev: {
+ type: "bi.icon_button",
+ value: "prev",
+ title: BI.i18nText("BI-Up_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
+ height: 20,
+ iconWidth: 16,
+ iconHeight: 16,
+ cls: "direction-pager-prev column-pre-page-h-font"
+ },
+ next: {
+ type: "bi.icon_button",
+ value: "next",
+ title: BI.i18nText("BI-Down_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
+ height: 20,
+ iconWidth: 16,
+ iconHeight: 16,
+ cls: "direction-pager-next column-next-page-h-font"
+ },
+
+ hasPrev: v.hasPrev,
+ hasNext: v.hasNext,
+ firstPage: v.firstPage,
+ lastPage: v.lastPage
+ });
+
+ this.vpager.on(BI.Pager.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DirectionPager.EVENT_CHANGE);
+ });
+ this.vpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () {
+ self.vlabel.setValue(this.getCurrentPage());
+ self.vlabel.setTitle(this.getCurrentPage());
+ });
+ },
+
+ _createHPager: function () {
+ var self = this, o = this.options;
+ var h = o.horizontal;
+ this.hlabel = BI.createWidget({
+ type: "bi.label",
+ width: 24,
+ height: 20,
+ value: h.curr,
+ title: h.curr,
+ invisible: true
+ });
+ this.hpager = BI.createWidget({
+ type: "bi.pager",
+ width: 76,
+ layouts: [{
+ type: "bi.horizontal",
+ scrollx: false,
+ rgap: 24,
+ vgap: 1
+ }],
+ invisible: true,
+
+ dynamicShow: false,
+ pages: h.pages,
+ curr: h.curr,
+ groups: 0,
+
+ first: false,
+ last: false,
+ prev: {
+ type: "bi.icon_button",
+ value: "prev",
+ title: BI.i18nText("BI-Left_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_First_Page"),
+ height: 20,
+ iconWidth: 16,
+ iconHeight: 16,
+ cls: "direction-pager-prev row-pre-page-h-font"
+ },
+ next: {
+ type: "bi.icon_button",
+ value: "next",
+ title: BI.i18nText("BI-Right_Page"),
+ warningTitle: BI.i18nText("BI-Current_Is_Last_Page"),
+ height: 20,
+ iconWidth: 16,
+ iconHeight: 16,
+ cls: "direction-pager-next row-next-page-h-font"
+ },
+
+ hasPrev: h.hasPrev,
+ hasNext: h.hasNext,
+ firstPage: h.firstPage,
+ lastPage: h.lastPage
+ });
+
+ this.hpager.on(BI.Pager.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DirectionPager.EVENT_CHANGE);
+ });
+ this.hpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () {
+ self.hlabel.setValue(this.getCurrentPage());
+ self.hlabel.setTitle(this.getCurrentPage());
+ });
+ },
+
+ getVPage: function () {
+ return this.vpager.getCurrentPage();
+ },
+
+ getHPage: function () {
+ return this.hpager.getCurrentPage();
+ },
+
+ setVPage: function (v) {
+ this.vpager.setValue(v);
+ this.vlabel.setValue(v);
+ this.vlabel.setTitle(v);
+ },
+
+ setHPage: function (v) {
+ this.hpager.setValue(v);
+ this.hlabel.setValue(v);
+ this.hlabel.setTitle(v);
+ },
+
+ hasVNext: function () {
+ return this.vpager.hasNext();
+ },
+
+ hasHNext: function () {
+ return this.hpager.hasNext();
+ },
+
+ hasVPrev: function () {
+ return this.vpager.hasPrev();
+ },
+
+ hasHPrev: function () {
+ return this.hpager.hasPrev();
+ },
+
+ setHPagerVisible: function (b) {
+ this.hpager.setVisible(b);
+ this.hlabel.setVisible(b);
+ },
+
+ setVPagerVisible: function (b) {
+ this.vpager.setVisible(b);
+ this.vlabel.setVisible(b);
+ },
+
+ populate: function () {
+ this.vpager.populate();
+ this.hpager.populate();
+ var vShow = false, hShow = false;
+ if (!this.hasHNext() && !this.hasHPrev()) {
+ this.setHPagerVisible(false);
+ } else {
+ this.setHPagerVisible(true);
+ hShow = true;
+ }
+ if (!this.hasVNext() && !this.hasVPrev()) {
+ this.setVPagerVisible(false);
+ } else {
+ this.setVPagerVisible(true);
+ vShow = true;
+ }
+ this.setVisible(hShow || vShow);
+ var num = [74, 111, -9, 28];
+ var items = this.layout.attr("items");
+
+ if (vShow === true && hShow === true) {
+ items[0].right = num[0];
+ items[1].right = num[1];
+ items[2].right = num[2];
+ items[3].right = num[3];
+ } else if (vShow === true) {
+ items[0].right = num[2];
+ items[1].right = num[3];
+ } else if (hShow === true) {
+ items[2].right = num[2];
+ items[3].right = num[3];
+ }
+ this.layout.attr("items", items);
+ this.layout.resize();
+ },
+
+ clear: function () {
+ this.vpager.attr("curr", 1);
+ this.hpager.attr("curr", 1);
+ }
+});
+BI.DirectionPager.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.direction_pager", BI.DirectionPager);/**
+ * 分页控件
+ *
+ * Created by GUY on 2015/8/31.
+ * @class BI.DetailPager
+ * @extends BI.Widget
+ */
+BI.DetailPager = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DetailPager.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-detail-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.DetailPager.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: "page-item bi-border bi-list-item-active",
+ 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.DetailPager.EVENT_CHANGE, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.fireEvent(BI.DetailPager.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.DetailPager.superclass.attr.apply(this, arguments);
+ if (key === "curr") {
+ this.currPage = BI.result(this.options, "curr");
+ }
+ },
+
+ populate: function () {
+ this._populate();
+ }
+});
+BI.DetailPager.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DetailPager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE";
+BI.shortcut("bi.detail_pager", BI.DetailPager);/**
+ * 分段控件使用的button
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.SegmentButton
+ * @extends BI.BasicButton
+ */
+BI.SegmentButton = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.SegmentButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-segment-button bi-list-item-select",
+ shadow: true,
+ readonly: true,
+ hgap: 5
+ });
+ },
+
+ _init: function () {
+ BI.SegmentButton.superclass._init.apply(this, arguments);
+ var opts = this.options, self = this;
+ // if (BI.isNumber(opts.height) && BI.isNull(opts.lineHeight)) {
+ // this.element.css({lineHeight : (opts.height - 2) + 'px'});
+ // }
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textHeight: opts.height,
+ whiteSpace: opts.whiteSpace,
+ text: opts.text,
+ value: opts.value,
+ hgap: opts.hgap
+ });
+ },
+
+ setSelected: function () {
+ BI.SegmentButton.superclass.setSelected.apply(this, arguments);
+ },
+
+ setText: function (text) {
+ BI.SegmentButton.superclass.setText.apply(this, arguments);
+ this.text.setText(text);
+ },
+
+ destroy: function () {
+ BI.SegmentButton.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut("bi.segment_button", BI.SegmentButton);/**
+ * 单选按钮组
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.Segment
+ * @extends BI.Widget
+ */
+BI.Segment = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Segment.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-segment",
+ items: [],
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.Segment.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.buttonGroup = BI.createWidget({
+ element: this,
+ type: "bi.button_group",
+ value: o.value,
+ items: BI.createItems(o.items, {
+ type: "bi.segment_button",
+ height: o.height - 2,
+ whiteSpace: o.whiteSpace
+ }),
+ layout: [
+ {
+ type: "bi.center"
+ }
+ ]
+ });
+ this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.buttonGroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) {
+ self.fireEvent(BI.Segment.EVENT_CHANGE, value, obj);
+ });
+ },
+
+ _setEnable: function (enable) {
+ BI.Segment.superclass._setEnable.apply(this, arguments);
+ if (enable === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (enable === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ },
+
+ setValue: function (v) {
+ this.buttonGroup.setValue(v);
+ },
+
+ setEnabledValue: function (v) {
+ this.buttonGroup.setEnabledValue(v);
+ },
+
+ getValue: function () {
+ return this.buttonGroup.getValue();
+ }
+});
+BI.Segment.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.segment", BI.Segment);/**
+ * guy
+ * 复选导航条
+ * Created by GUY on 2015/8/25.
+ * @class BI.MultiSelectBar
+ * @extends BI.BasicButton
+ */
+BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectBar.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multi-select-bar",
+ height: 25,
+ text: BI.i18nText("BI-Select_All"),
+ isAllCheckedBySelectedValue: BI.emptyFn,
+ // 手动控制选中
+ disableSelected: true,
+ isHalfCheckedBySelectedValue: function (selectedValues) {
+ return selectedValues.length > 0;
+ },
+ halfSelected: false,
+ iconWrapperWidth: 26
+ });
+ },
+ _init: function () {
+ BI.MultiSelectBar.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var isSelect = o.selected === true;
+ var isHalfSelect = !o.selected && o.halfSelected;
+ this.checkbox = BI.createWidget({
+ type: "bi.checkbox",
+ stopPropagation: true,
+ handler: function () {
+ self.setSelected(self.isSelected());
+ },
+ selected: isSelect,
+ invisible: isHalfSelect
+ });
+ this.half = BI.createWidget({
+ type: "bi.half_icon_button",
+ stopPropagation: true,
+ handler: function () {
+ self.setSelected(true);
+ },
+ invisible: isSelect || !isHalfSelect
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
+ });
+ this.checkbox.on(BI.Checkbox.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, self.isSelected(), self);
+ });
+ this.half.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self);
+ });
+ this.half.on(BI.HalfIconButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, self.isSelected(), self);
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ width: o.iconWrapperWidth,
+ el: {
+ type: "bi.center_adapt",
+ items: [this.checkbox, this.half]
+ }
+ }, {
+ el: this.text
+ }]
+ });
+ },
+
+ _setSelected: function (v) {
+ this.checkbox.setSelected(!!v);
+ },
+
+ // 自己手动控制选中
+ beforeClick: function () {
+ var isHalf = this.isHalfSelected(), isSelected = this.isSelected();
+ if (isHalf === true) {
+ this.setSelected(true);
+ } else {
+ this.setSelected(!isSelected);
+ }
+ },
+
+ setSelected: function (v) {
+ this.checkbox.setSelected(v);
+ this.setHalfSelected(false);
+ },
+
+ setHalfSelected: function (b) {
+ this.halfSelected = !!b;
+ if (b === true) {
+ this.checkbox.setSelected(false);
+ this.half.visible();
+ this.checkbox.invisible();
+ } else {
+ this.half.invisible();
+ this.checkbox.visible();
+ }
+ },
+
+ isHalfSelected: function () {
+ return !this.isSelected() && !!this.halfSelected;
+ },
+
+ isSelected: function () {
+ return this.checkbox.isSelected();
+ },
+
+ setValue: function (selectedValues) {
+ BI.MultiSelectBar.superclass.setValue.apply(this, arguments);
+ var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments);
+ this._setSelected(isAllChecked);
+ !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments));
+ },
+
+ doClick: function () {
+ BI.MultiSelectBar.superclass.doClick.apply(this, arguments);
+ if(this.isValid()) {
+ this.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
+ }
+ }
+});
+BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_bar", BI.MultiSelectBar);
+/**
+ * guy
+ * 二级树
+ * @class BI.LevelTree
+ * @extends BI.Single
+ */
+BI.LevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.LevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-level-tree",
+ el: {
+ chooseType: 0
+ },
+ expander: {},
+ items: [],
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.LevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer, pNode) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {layer: layer};
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ extend.pNode = pNode;
+ if (node.isParent === true || node.parent === true || BI.isNotEmptyArray(node.children)) {
+ extend.type = "bi.mid_plus_group_node";
+ if (i === nodes.length - 1) {
+ extend.type = "bi.last_plus_group_node";
+ extend.isLastNode = true;
+ }
+ if (i === 0 && !pNode) {
+ extend.type = "bi.first_plus_group_node"
+ }
+ if (i === 0 && i === nodes.length - 1) { // 根
+ extend.type = "bi.plus_group_node";
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children, layer + 1, node);
+ } else {
+ extend.type = "bi.mid_tree_leaf_item";
+ if (i === 0 && !pNode) {
+ extend.type = "bi.first_tree_leaf_item"
+ }
+ if (i === nodes.length - 1) {
+ extend.type = "bi.last_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ });
+ },
+
+ // 构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ element: this,
+ expander: BI.extend({
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ }, o.expander),
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ value: o.value,
+
+ el: BI.extend({
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }, o.el)
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type, value, ob) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.LevelTree.EVENT_CHANGE, value, ob);
+ }
+ });
+ },
+
+ // 生成树方法
+ stroke: function (nodes) {
+ this.tree.stroke.apply(this.tree, arguments);
+ },
+
+ populate: function (items, keyword) {
+ items = this._formatItems(BI.Tree.transformToTreeFormat(items), 0);
+ this.tree.populate(items, keyword);
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.LevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.level_tree", BI.LevelTree);/**
+ * guy
+ * 异步树
+ * @class BI.DisplayTree
+ * @extends BI.TreeView
+ */
+BI.DisplayTree = BI.inherit(BI.TreeView, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DisplayTree.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-display-tree"
+ });
+ },
+ _init: function () {
+ BI.DisplayTree.superclass._init.apply(this, arguments);
+ },
+
+ // 配置属性
+ _configSetting: function () {
+ var setting = {
+ view: {
+ selectedMulti: false,
+ dblClickExpand: false,
+ showIcon: false,
+ nameIsHTML: true,
+ showTitle: false
+ },
+ data: {
+ key: {
+ title: "title",
+ name: "text"
+ },
+ simpleData: {
+ enable: true
+ }
+ },
+ callback: {
+ beforeCollapse: beforeCollapse
+ }
+ };
+
+ function beforeCollapse(treeId, treeNode) {
+ return false;
+ }
+
+ return setting;
+ },
+
+ _dealWidthNodes: function (nodes) {
+ nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments);
+ var self = this, o = this.options;
+ BI.each(nodes, function (i, node) {
+ node.isParent = node.isParent || node.parent;
+ if (node.text == null) {
+ if (node.count > 0) {
+ node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")";
+ }
+ }
+ });
+ return nodes;
+ },
+
+ initTree: function (nodes, setting) {
+ var setting = setting || this._configSetting();
+ this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes);
+ },
+
+ destroy: function () {
+ BI.DisplayTree.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.DisplayTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.display_tree", BI.DisplayTree);/**
+ * 简单的多选树
+ *
+ * Created by GUY on 2016/2/16.
+ * @class BI.SimpleTreeView
+ * @extends BI.Widget
+ */
+BI.SimpleTreeView = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SimpleTreeView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-simple-tree",
+ itemsCreator: BI.emptyFn,
+ items: null
+ });
+ },
+ _init: function () {
+ BI.SimpleTreeView.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.structure = new BI.Tree();
+ this.tree = BI.createWidget({
+ type: "bi.tree_view",
+ element: this,
+ itemsCreator: function (op, callback) {
+ var fn = function (items) {
+ callback({
+ items: items
+ });
+ self.structure.initTree(BI.Tree.transformToTreeFormat(items));
+ };
+ if (BI.isNotNull(o.items)) {
+ fn(o.items);
+ } else {
+ o.itemsCreator(op, fn);
+ }
+ }
+ });
+ this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SimpleTreeView.EVENT_CHANGE, arguments);
+ });
+ if (BI.isNotEmptyArray(o.items)) {
+ this.populate();
+ }
+ if (BI.isNotNull(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ populate: function (items, keyword) {
+ if (items) {
+ this.options.items = items;
+ }
+ this.tree.stroke({
+ keyword: keyword
+ });
+ },
+
+ _digest: function (v) {
+ v || (v = []);
+ var self = this, map = {};
+ var selected = [];
+ BI.each(v, function (i, val) {
+ var node = self.structure.search(val, "value");
+ if (node) {
+ var p = node;
+ p = p.getParent();
+ if (p) {
+ if (!map[p.value]) {
+ map[p.value] = 0;
+ }
+ map[p.value]++;
+ }
+
+ while (p && p.getChildrenLength() <= map[p.value]) {
+ selected.push(p.value);
+ p = p.getParent();
+ if (p) {
+ if (!map[p.value]) {
+ map[p.value] = 0;
+ }
+ map[p.value]++;
+ }
+ }
+ }
+ });
+ return BI.makeObject(v.concat(selected));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(this._digest(v));
+ },
+
+ _getValue: function () {
+ var self = this, result = [], val = this.tree.getValue();
+ var track = function (nodes) {
+ BI.each(nodes, function (key, node) {
+ if (BI.isEmpty(node)) {
+ result.push(key);
+ } else {
+ track(node);
+ }
+ });
+ };
+ track(val);
+ return result;
+ },
+
+ empty: function () {
+ this.tree.empty();
+ },
+
+ getValue: function () {
+ var self = this, result = [], val = this._getValue();
+ BI.each(val, function (i, key) {
+ var target = self.structure.search(key, "value");
+ if (target) {
+ self.structure._traverse(target, function (node) {
+ if (node.isLeaf()) {
+ result.push(node.value);
+ }
+ });
+ }
+ });
+ return result;
+ }
+});
+BI.SimpleTreeView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.simple_tree", BI.SimpleTreeView);
+/**
+ * 文本输入框trigger
+ *
+ * Created by GUY on 2015/9/15.
+ * @class BI.EditorTrigger
+ * @extends BI.Trigger
+ */
+BI.EditorTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4
+ },
+
+ _defaultConfig: function () {
+ var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border",
+ height: 24,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: false,
+ watermark: "",
+ errorText: ""
+ });
+ },
+
+ _init: function () {
+ this.options.height -= 2;
+ BI.EditorTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText,
+ title: function () {
+ return self.getValue();
+ }
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.triggerWidth || o.height
+ },
+ width: o.triggerWidth || o.height
+ }
+ ]
+ });
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ setValue: function (value) {
+ this.editor.setValue(value);
+ },
+
+ setText: function (text) {
+ this.editor.setState(text);
+ }
+});
+BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE";
+BI.shortcut("bi.editor_trigger", BI.EditorTrigger);
+/**
+ * 图标按钮trigger
+ *
+ * Created by GUY on 2015/10/8.
+ * @class BI.IconTrigger
+ * @extends BI.Trigger
+ */
+BI.IconTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-icon-trigger",
+ el: {},
+ height: 24
+ });
+ },
+ _init: function () {
+ var o = this.options;
+ BI.IconTrigger.superclass._init.apply(this, arguments);
+ this.iconButton = BI.createWidget(o.el, {
+ type: "bi.trigger_icon_button",
+ element: this,
+ width: o.width,
+ height: o.height
+ });
+ }
+});
+BI.shortcut("bi.icon_trigger", BI.IconTrigger);/**
+ * 文字trigger
+ *
+ * Created by GUY on 2015/9/15.
+ * @class BI.IconTextTrigger
+ * @extends BI.Trigger
+ */
+BI.IconTextTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4
+ },
+
+ _defaultConfig: function () {
+ var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-trigger",
+ height: 24,
+ iconHeight: null,
+ iconWidth: null
+ });
+ },
+
+ _init: function () {
+ BI.IconTextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "select-text-label",
+ textAlign: "left",
+ height: o.height,
+ text: o.text
+ });
+ this.trigerButton = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.triggerWidth || o.height
+ });
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ ref: function (_ref) {
+ self.wrapper = _ref;
+ },
+ items: [{
+ el: {
+ type: "bi.icon_change_button",
+ cls: "icon-combo-trigger-icon",
+ iconCls: o.iconCls,
+ ref: function (_ref) {
+ self.icon = _ref;
+ },
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ disableSelected: true
+ },
+ width: BI.isEmptyString(o.iconCls) ? 0 : (o.iconWrapperWidth || o.height)
+ },
+ {
+ el: this.text,
+ lgap: BI.isEmptyString(o.iconCls) ? 5 : 0
+ }, {
+ el: this.trigerButton,
+ width: o.triggerWidth || o.height
+ }
+ ]
+ });
+ },
+
+ setValue: function (value) {
+ this.text.setValue(value);
+ },
+
+ setIcon: function (iconCls) {
+ var o = this.options;
+ this.icon.setIcon(iconCls);
+ var iconItem = this.wrapper.attr("items")[0];
+ var textItem = this.wrapper.attr("items")[1];
+ if(BI.isNull(iconCls) || BI.isEmptyString(iconCls)) {
+ if(iconItem.width !== 0) {
+ iconItem.width = 0;
+ textItem.lgap = 5;
+ this.wrapper.resize();
+ }
+ }else{
+ if(iconItem.width !== (o.iconWrapperWidth || o.height)) {
+ iconItem.width = (o.iconWrapperWidth || o.height);
+ textItem.lgap = 0;
+ this.wrapper.resize();
+ }
+ }
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ }
+});
+BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
+ * Created by Windy on 2017/12/12.
+ */
+BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-text-trigger bi-border",
+ height: 24,
+ iconHeight: null,
+ iconWidth: null,
+ iconCls: ""
+ });
+ },
+
+ _init: function () {
+ this.options.height -= 2;
+ BI.SelectIconTextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var obj = this._digist(o.value, o.items);
+ this.trigger = BI.createWidget({
+ type: "bi.icon_text_trigger",
+ element: this,
+ text: obj.text,
+ iconCls: obj.iconCls,
+ height: o.height,
+ iconHeight: o.iconHeight,
+ iconWidth: o.iconWidth,
+ iconWrapperWidth: o.iconWrapperWidth
+ });
+ },
+
+ _digist: function (vals, items) {
+ var o = this.options;
+ vals = BI.isArray(vals) ? vals : [vals];
+ var result;
+ var formatItems = BI.Tree.transformToArrayFormat(items);
+ BI.any(formatItems, function (i, item) {
+ if (BI.deepContains(vals, item.value)) {
+ result = {
+ text: item.text || item.value,
+ iconCls: item.iconCls
+ };
+ return true;
+ }
+ });
+
+ if (BI.isNotNull(result)) {
+ return {
+ text: result.text,
+ iconCls: result.iconCls
+ };
+ } else {
+ return {
+ text: o.text,
+ iconCls: o.iconCls
+ };
+ }
+ },
+
+ setValue: function (vals) {
+ var obj = this._digist(vals, this.options.items);
+ this.trigger.setText(obj.text);
+ this.trigger.setIcon(obj.iconCls);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ }
+});
+BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger);/**
+ * 文字trigger
+ *
+ * Created by GUY on 2015/9/15.
+ * @class BI.TextTrigger
+ * @extends BI.Trigger
+ */
+BI.TextTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4
+ },
+
+ _defaultConfig: function () {
+ var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-trigger",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.TextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "select-text-label",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ title: function () {
+ return self.text.getText();
+ },
+ tipType: o.tipType,
+ warningTitle: o.warningTitle,
+ hgap: c.hgap,
+ readonly: o.readonly
+ });
+ this.trigerButton = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.triggerWidth || o.height
+ });
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.text
+ }, {
+ el: this.trigerButton,
+ width: o.triggerWidth || o.height
+ }
+ ]
+ });
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ },
+
+ setTipType: function (v) {
+ this.text.options.tipType = v;
+ }
+});
+BI.shortcut("bi.text_trigger", BI.TextTrigger);
+/**
+ * 选择字段trigger
+ *
+ * Created by GUY on 2015/9/15.
+ * @class BI.SelectTextTrigger
+ * @extends BI.Trigger
+ */
+BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-text-trigger bi-border bi-focus-shadow",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ this.options.height -= 2;
+ BI.SelectTextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.trigger = BI.createWidget({
+ type: "bi.text_trigger",
+ element: this,
+ height: o.height,
+ readonly: o.readonly,
+ text: this._digest(o.value, o.items),
+ tipType: o.tipType,
+ warningTitle: o.warningTitle
+ });
+ },
+
+ _digest: function(vals, items){
+ var o = this.options;
+ vals = BI.isArray(vals) ? vals : [vals];
+ var result = [];
+ var formatItems = BI.Tree.transformToArrayFormat(items);
+ BI.each(formatItems, function (i, item) {
+ if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) {
+ result.push(item.text || item.value);
+ }
+ });
+
+ if (result.length > 0) {
+ return result.join(",");
+ } else {
+ return o.text;
+ }
+ },
+
+ setValue: function (vals) {
+ this.trigger.setText(this._digest(vals, this.options.items));
+ },
+
+ setTipType: function (v) {
+ this.trigger.setTipType(v);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ }
+});
+BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);
+/**
+ * 选择字段trigger小一号的
+ *
+ * @class BI.SmallSelectTextTrigger
+ * @extends BI.Trigger
+ */
+BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SmallSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-small-select-text-trigger bi-border",
+ height: 20
+ });
+ },
+
+ _init: function () {
+ this.options.height -= 2;
+ BI.SmallSelectTextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var obj = this._digest(o.text, o.items);
+ this.trigger = BI.createWidget({
+ type: "bi.small_text_trigger",
+ element: this,
+ height: o.height - 2,
+ text: obj.text,
+ cls: obj.cls
+ });
+ },
+
+ _digest: function(vals, items){
+ var o = this.options;
+ vals = BI.isArray(vals) ? vals : [vals];
+ var result = [];
+ var formatItems = BI.Tree.transformToArrayFormat(items);
+ BI.each(formatItems, function (i, item) {
+ if (BI.deepContains(vals, item.value) && !BI.contains(result, item.text || item.value)) {
+ result.push(item.text || item.value);
+ }
+ });
+
+ if (result.length > 0) {
+ return {
+ cls: "",
+ text: result.join(",")
+ }
+ } else {
+ return {
+ cls: "bi-water-mark",
+ text: o.text
+ }
+ }
+ },
+
+ setValue: function (vals) {
+ var formatValue = this._digest(vals, this.options.items);
+ this.trigger.element.removeClass("bi-water-mark").addClass(formatValue.cls);
+ this.trigger.setText(formatValue.text);
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ }
+});
+BI.shortcut("bi.small_select_text_trigger", BI.SmallSelectTextTrigger);/**
+ * 文字trigger(右边小三角小一号的) ==
+ *
+ * @class BI.SmallTextTrigger
+ * @extends BI.Trigger
+ */
+BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4
+ },
+
+ _defaultConfig: function () {
+ var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-trigger",
+ height: 20
+ });
+ },
+
+ _init: function () {
+ BI.SmallTextTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ height: o.height,
+ text: o.text,
+ hgap: c.hgap
+ });
+ this.trigerButton = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.triggerWidth || o.height
+ });
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.text
+ }, {
+ el: this.trigerButton,
+ width: o.triggerWidth || o.height
+ }
+ ]
+ });
+ },
+
+ setValue: function (value) {
+ this.text.setValue(value);
+ },
+
+ setText: function (text) {
+ this.text.setText(text);
+ }
+});
+BI.shortcut("bi.small_text_trigger", BI.SmallTextTrigger);/**
+ * 日期控件中的月份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.MonthDateCombo
+ * @extends BI.Trigger
+ */
+BI.MonthDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function () {
+ return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ height: 24,
+ container: null
+ });
+ },
+ _init: function () {
+ BI.MonthDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup",
+ behaviors: o.behaviors
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ });
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ container: o.container,
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_CHANGE, function () {
+ self.combo.hideView();
+ self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE);
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.doBehavior();
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_date_combo", BI.MonthDateCombo);/**
+ * 年份下拉框
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.YearDateCombo
+ * @extends BI.Trigger
+ */
+BI.YearDateCombo = BI.inherit(BI.Trigger, {
+ _defaultConfig: function () {
+ return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-combo",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ behaviors: {},
+ height: 24,
+ container: null
+ });
+ },
+ _init: function () {
+ BI.YearDateCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.date_triangle_trigger"
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.year_popup",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ });
+
+ this.popup.on(BI.YearPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ });
+
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ offsetStyle: "center",
+ element: this,
+ container: o.container,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 100,
+ stopPropagation: false,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_CHANGE, function () {
+ self.fireEvent(BI.YearDateCombo.EVENT_CHANGE);
+ });
+ // BI-22551 popup未初始化传入的behavior无效
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.doBehavior();
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.year_date_combo", BI.YearDateCombo);
+/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DatePicker
+ * @extends BI.Widget
+ */
+BI.DatePicker = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-picker",
+ height: 40,
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31" // 最大日期
+ });
+ },
+
+ _init: function () {
+ BI.DatePicker.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._year = BI.getDate().getFullYear();
+ this._month = BI.getDate().getMonth() + 1;
+ this.left = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 24,
+ height: 24
+ });
+ this.left.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 1) {
+ self.setValue({
+ year: self.year.getValue() - 1,
+ month: 12
+ });
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() - 1
+ });
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ self._checkLeftValid();
+ self._checkRightValid();
+ });
+
+ this.right = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 24,
+ height: 24
+ });
+
+ this.right.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self._month === 12) {
+ self.setValue({
+ year: self.year.getValue() + 1,
+ month: 1
+ });
+ } else {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue() + 1
+ });
+ }
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ self._checkLeftValid();
+ self._checkRightValid();
+ });
+
+ this.year = BI.createWidget({
+ type: "bi.year_date_combo",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ });
+ this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+ this.month = BI.createWidget({
+ type: "bi.month_date_combo",
+ behaviors: o.behaviors
+ });
+ this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () {
+ self.setValue({
+ year: self.year.getValue(),
+ month: self.month.getValue()
+ });
+ self.fireEvent(BI.DatePicker.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.center_adapt",
+ items: [this.left]
+ },
+ width: 24
+ }, {
+ type: "bi.center_adapt",
+ items: [{
+ el: {
+ type: "bi.horizontal",
+ width: 120,
+ rgap: 10,
+ items: [{
+ el: this.year,
+ lgap: 10
+ }, this.month]
+ }
+ }]
+ }, {
+ el: {
+ type: "bi.center_adapt",
+ items: [this.right]
+ },
+ width: 24
+ }]
+ });
+ this.setValue({
+ year: this._year,
+ month: this._month
+ });
+ },
+
+ _checkLeftValid: function () {
+ var o = this.options;
+ var valid = !(this._month === 1 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear());
+ this.left.setEnable(valid);
+ return valid;
+ },
+
+ _checkRightValid: function () {
+ var o = this.options;
+ var valid = !(this._month === 12 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear());
+ this.right.setEnable(valid);
+ return valid;
+ },
+
+
+
+ setValue: function (ob) {
+ this._year = BI.parseInt(ob.year);
+ this._month = BI.parseInt(ob.month);
+ this.year.setValue(ob.year);
+ this.month.setValue(ob.month);
+ this._checkLeftValid();
+ this._checkRightValid();
+ },
+
+ getValue: function () {
+ return {
+ year: this.year.getValue(),
+ month: this.month.getValue()
+ };
+ }
+});
+BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.date_picker", BI.DatePicker);/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.YearPicker
+ * @extends BI.Widget
+ */
+BI.YearPicker = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.YearPicker.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-year-picker",
+ behaviors: {},
+ height: 40,
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31" // 最大日期
+ });
+ },
+
+ _init: function () {
+ BI.YearPicker.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._year = BI.getDate().getFullYear();
+ this.left = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25
+ });
+ this.left.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.setValue(self.year.getValue() - 1);
+ self.fireEvent(BI.YearPicker.EVENT_CHANGE);
+ self._checkLeftValid();
+ self._checkRightValid();
+ });
+
+ this.right = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25
+ });
+
+ this.right.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.setValue(self.year.getValue() + 1);
+ self.fireEvent(BI.YearPicker.EVENT_CHANGE);
+ self._checkLeftValid();
+ self._checkRightValid();
+ });
+
+ this.year = BI.createWidget({
+ type: "bi.year_date_combo",
+ min: o.min,
+ behaviors: o.behaviors,
+ max: o.max
+ });
+ this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
+ self.setValue(self.year.getValue());
+ self.fireEvent(BI.YearPicker.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.center_adapt",
+ items: [this.left]
+ },
+ width: 25
+ }, {
+ type: "bi.center_adapt",
+ items: [{
+ el: {
+ type: "bi.horizontal_float",
+ width: 50,
+ items: [{
+ el: this.year
+ }]
+ }
+ }]
+ }, {
+ el: {
+ type: "bi.center_adapt",
+ items: [this.right]
+ },
+ width: 25
+ }]
+ });
+ this.setValue({
+ year: this._year
+ });
+ },
+
+ _checkLeftValid: function () {
+ var o = this.options;
+ var valid = !(this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear());
+ this.left.setEnable(valid);
+ return valid;
+ },
+
+ _checkRightValid: function () {
+ var o = this.options;
+ var valid = !(this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear());
+ this.right.setEnable(valid);
+ return valid;
+ },
+
+
+
+ setValue: function (v) {
+ this._year = v;
+ this.year.setValue(v);
+ this._checkLeftValid();
+ this._checkRightValid();
+ },
+
+ getValue: function () {
+ return this.year.getValue();
+ }
+});
+BI.YearPicker.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.year_picker", BI.YearPicker);
+/**
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateCalendarPopup
+ * @extends BI.Widget
+ */
+BI.DateCalendarPopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-calendar-popup",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ selectedTime: null
+ });
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: true
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _init: function () {
+ BI.DateCalendarPopup.superclass._init.apply(this, arguments);
+ var self = this,
+ o = this.options;
+ this.today = BI.getDate();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth() + 1;
+ this._day = this.today.getDate();
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month,
+ day: this._day
+ };
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "top",
+ logic: {
+ dynamic: true
+ },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this),
+
+ afterCardCreated: function () {
+
+ },
+
+ afterCardShow: function () {
+ this.setValue(self.selectedTime);
+ }
+ });
+
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ self.selectedTime = self.datePicker.getValue();
+ self.selectedTime.day = 1;
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ });
+
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.calendar,
+ left: 5,
+ right: 5
+ }, {
+ el: {
+ type: "bi.layout",
+ cls: "bi-split-top"
+ },
+ height: 1,
+ top: 40,
+ left: 0,
+ right: 0
+ }]
+ });
+ },
+
+ setValue: function (timeOb) {
+ this.datePicker.setValue(timeOb);
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
+ this.calendar.setValue(timeOb);
+ this.selectedTime = timeOb;
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+});
+BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearPopup
+ * @extends BI.Trigger
+ */
+BI.YearPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-popup",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31" // 最大日期
+ });
+ },
+
+ _createYearCalendar: function (v) {
+ var o = this.options, y = this._year;
+
+ var calendar = BI.createWidget({
+ type: "bi.year_calendar",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max,
+ logic: {
+ dynamic: true
+ },
+ year: y + v * 12
+ });
+ calendar.setValue(this._year);
+ return calendar;
+ },
+
+ _init: function () {
+ BI.YearPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.selectedYear = this._year = BI.getDate().getFullYear();
+
+ var backBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 24,
+ height: 24,
+ value: -1
+ });
+
+ var preBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 24,
+ height: 24,
+ value: 1
+ });
+
+ this.navigation = BI.createWidget({
+ type: "bi.navigation",
+ element: this,
+ single: true,
+ logic: {
+ dynamic: true
+ },
+ tab: {
+ cls: "year-popup-navigation bi-high-light bi-split-top",
+ height: 24,
+ items: [backBtn, preBtn]
+ },
+ cardCreator: BI.bind(this._createYearCalendar, this),
+
+ afterCardShow: function () {
+ this.setValue(self.selectedYear);
+ var calendar = this.getSelectedCard();
+ backBtn.setEnable(!calendar.isFrontYear());
+ preBtn.setEnable(!calendar.isFinalYear());
+ }
+ });
+
+ this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedYear = this.getValue();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
+ });
+
+ if(BI.isKey(o.value)){
+ this.setValue(o.value);
+ }
+ },
+
+ getValue: function () {
+ return this.selectedYear;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ v = BI.parseInt(v);
+ if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) {
+ v = BI.getDate().getFullYear();
+ this.selectedYear = "";
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue("");
+ } else {
+ this.selectedYear = v;
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue(v);
+ }
+ }
+});
+BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.year_popup", BI.YearPopup);/**
+ * 日期控件中的年份或月份trigger
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.DateTriangleTrigger
+ * @extends BI.Trigger
+ */
+BI.DateTriangleTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ height: 24,
+ iconWidth: 12,
+ iconHeight: 12
+ },
+
+ _defaultConfig: function () {
+ return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.DateTriangleTrigger.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "right",
+ text: o.text,
+ value: o.value,
+ height: c.height
+ });
+
+ BI.createWidget({
+ type: "bi.vertical_adapt",
+ element: this,
+ items: [{
+ el: this.text,
+ rgap: 5
+ }, {
+ type: "bi.icon_label",
+ width: 16
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this.text.setValue(v);
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function (v) {
+ this.text.setText(v);
+ },
+
+ getText: function () {
+ return this.item.getText();
+ },
+
+ getKey: function () {
+
+ }
+});
+BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/**
+ * Created by zcf on 2017/2/20.
+ */
+BI.StaticDatePaneCard = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.StaticDatePaneCard.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-pane",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ selectedTime: null
+ });
+ },
+ _init: function () {
+ BI.StaticDatePaneCard.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.today = BI.getDate();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth() + 1;
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month
+ };
+
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ });
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ var value = self.datePicker.getValue();
+ var monthDay = BI.getMonthDays(BI.getDate(value.year, value.month - 1, 1));
+ var day = self.selectedTime.day || 0;
+ if (day > monthDay) {
+ day = monthDay;
+ }
+ self.selectedTime = {
+ year: value.year,
+ month: value.month
+ };
+ day !== 0 && (self.selectedTime.day = day);
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ self.calendar.setValue(self.selectedTime);
+ day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "custom",
+ // logic: {
+ // dynamic: false
+ // },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this)
+ });
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = self.calendar.getValue();
+ self.calendar.empty();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+ this.setValue(o.selectedTime);
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.datePicker,
+ height: 40
+ }, this.calendar],
+ hgap: 10
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-split-top"
+ },
+ height: 1,
+ top: 40,
+ left: 0,
+ right: 0
+ }]
+ });
+
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: false
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _getNewCurrentDate: function () {
+ var today = BI.getDate();
+ return {
+ year: today.getFullYear(),
+ month: today.getMonth() + 1
+ };
+ },
+
+ _setCalenderValue: function (date) {
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
+ this.calendar.setValue(date);
+ this.selectedTime = date;
+ },
+
+ _setDatePicker: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
+ this.datePicker.setValue(this._getNewCurrentDate());
+ } else {
+ this.datePicker.setValue(timeOb);
+ }
+ },
+
+ _setCalendar: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
+ this.calendar.empty();
+ this._setCalenderValue(this._getNewCurrentDate());
+ } else {
+ this._setCalenderValue(timeOb);
+ }
+ },
+
+ setValue: function (timeOb) {
+ this._setDatePicker(timeOb);
+ this._setCalendar(timeOb);
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+
+});
+BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePane = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-dynamic-date-pane"
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: 30,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Multi_Date_YMD"),
+ value: BI.DynamicDatePane.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicDatePane.Dynamic
+ }], {
+ textAlign: "center"
+ }),
+ listeners: [{
+ eventName: BI.ButtonGroup.EVENT_CHANGE,
+ action: function () {
+ var value = this.getValue()[0];
+ self.dateTab.setSelect(value);
+ switch (value) {
+ case BI.DynamicDatePane.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ break;
+ case BI.DynamicDatePane.Dynamic:
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ break;
+ default:
+ break;
+ }
+ }
+ }],
+ ref: function () {
+ self.switcher = this;
+ }
+ },
+ height: 30
+ }, {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ showIndex: BI.DynamicDatePane.Static,
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicDatePane.Static:
+ return {
+ type: "bi.static_date_pane_card",
+ behaviors: o.behaviors,
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }],
+ ref: function () {
+ self.ymd = this;
+ }
+ };
+ case BI.DynamicDatePane.Dynamic:
+ default:
+ return {
+ type: "bi.dynamic_date_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ if(self._checkValue(self.getValue())) {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ }
+ }
+ }]
+ };
+ },
+
+ mounted: function () {
+ this.setValue(this.options.value);
+ },
+
+ _checkValueValid: function (value) {
+ return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
+ },
+
+ _checkValue: function (v) {
+ switch (v.type) {
+ case BI.DynamicDateCombo.Dynamic:
+ return BI.isNotEmptyObject(v.value);
+ case BI.DynamicDateCombo.Static:
+ default:
+ return true;
+ }
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ var type = v.type || BI.DynamicDateCombo.Static;
+ var value = v.value || v;
+ this.switcher.setValue(type);
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (this._checkValueValid(value)) {
+ var date = BI.getDate();
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1
+ });
+ } else {
+ this.ymd.setValue(value);
+ }
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+});
+BI.shortcut("bi.dynamic_date_pane", BI.DynamicDatePane);
+
+BI.extend(BI.DynamicDatePane, {
+ Static: 1,
+ Dynamic: 2
+});/**
+ * Created by Urthur on 2017/7/14.
+ */
+BI.DateTimeCombo = BI.inherit(BI.Single, {
+ constants: {
+ popupHeight: 290,
+ popupWidth: 270,
+ comboAdjustHeight: 1,
+ border: 1,
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-time-combo bi-border bi-border-radius",
+ width: 200,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.DateTimeCombo.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+ var date = BI.getDate();
+ this.storeValue = BI.isNotNull(opts.value) ? opts.value : {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds()
+ };
+ this.trigger = BI.createWidget({
+ type: "bi.date_time_trigger",
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ value: opts.value
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.date_time_popup",
+ behaviors: opts.behaviors,
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ value: opts.value
+ });
+ self.setValue(this.storeValue);
+
+ this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
+ self.setValue(self.storeValue);
+ self.hidePopupView();
+ self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL);
+ });
+ this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
+ self.storeValue = self.popup.getValue();
+ self.setValue(self.storeValue);
+ self.hidePopupView();
+ self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM);
+ });
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: opts.container,
+ toggle: false,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: this.popup,
+ width: this.constants.popupWidth,
+ stopPropagation: false
+ },
+ // DEC-4250 和复选下拉一样,点击不收起
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-font",
+ width: 24,
+ height: 24
+ });
+ triggerBtn.on(BI.IconButton.EVENT_CHANGE, function () {
+ if (self.combo.isViewVisible()) {
+ // self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.combo,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ top: 0,
+ right: 0
+ }]
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.popup.setValue(v);
+ this.trigger.setValue(v);
+ },
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ hidePopupView: function () {
+ this.combo.hideView();
+ }
+});
+
+BI.DateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
+BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);
+/**
+ * Created by Urthur on 2017/7/14.
+ */
+BI.DateTimePopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-date-time-popup",
+ width: 268,
+ height: 374
+ });
+ },
+ _init: function () {
+ BI.DateTimePopup.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+ this.cancelButton = BI.createWidget({
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "multidate-popup-button bi-border-top bi-border-right",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Cancel")
+ });
+ this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE);
+ });
+
+ this.okButton = BI.createWidget({
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "multidate-popup-button bi-border-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK")
+ });
+ this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE);
+ });
+
+ this.dateCombo = BI.createWidget({
+ type: "bi.date_calendar_popup",
+ behaviors: opts.behaviors,
+ min: self.options.min,
+ max: self.options.max
+ });
+ self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE);
+ });
+
+ this.dateButton = BI.createWidget({
+ type: "bi.grid",
+ items: [[this.cancelButton, this.okButton]]
+ });
+ BI.createWidget({
+ element: this,
+ type: "bi.vtape",
+ items: [{
+ el: this.dateCombo
+ }, {
+ el: {
+ type: "bi.center_adapt",
+ cls: "bi-split-top",
+ items: [{
+ type: "bi.dynamic_date_time_select",
+ ref: function (_ref) {
+ self.timeSelect = _ref;
+ }
+ }]
+ },
+ height: 50
+ }, {
+ el: this.dateButton,
+ height: 30
+ }]
+ });
+ this.setValue(opts.value);
+ },
+
+ setValue: function (v) {
+ var value = v, date;
+ if (BI.isNull(value)) {
+ date = BI.getDate();
+ this.dateCombo.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ this.timeSelect.setValue({
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds()
+ });
+ } else {
+ this.dateCombo.setValue({
+ year: value.year,
+ month: value.month,
+ day: value.day
+ });
+ this.timeSelect.setValue({
+ hour: value.hour,
+ minute: value.minute,
+ second: value.second
+ });
+ }
+ },
+
+ getValue: function () {
+ return BI.extend({
+ year: this.dateCombo.getValue().year,
+ month: this.dateCombo.getValue().month,
+ day: this.dateCombo.getValue().day
+ }, this.timeSelect.getValue());
+ }
+});
+BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
+BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
+BI.shortcut("bi.date_time_popup", BI.DateTimePopup);
+/**
+ * Created by Urthur on 2017/7/14.
+ */
+BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-date-time-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 24,
+ width: 200
+ });
+ },
+ _init: function () {
+ BI.DateTimeTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ height: o.height,
+ width: o.width,
+ hgap: c.hgap
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.text
+ },{
+ el: BI.createWidget(),
+ width: o.height
+ }]
+ });
+ this.setValue(o.value);
+ },
+
+ _printTime: function (v) {
+ return v < 10 ? "0" + v : v;
+ },
+
+ setValue: function (v) {
+ var self = this;
+ var value = v, dateStr;
+ if(BI.isNull(value)) {
+ value = BI.getDate();
+ dateStr = BI.print(value, "%Y-%X-%d %H:%M:%S");
+ } else {
+ var date = BI.getDate(value.year, value.month - 1, value.day, value.hour, value.minute, value.second);
+ dateStr = BI.print(date, "%Y-%X-%d %H:%M:%S");
+
+ }
+ this.text.setText(dateStr);
+ this.text.setTitle(dateStr);
+ }
+
+});
+BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
+BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.StaticDateTimePaneCard.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-date-time-pane",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ selectedTime: null
+ });
+ },
+ _init: function () {
+ BI.StaticDateTimePaneCard.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.today = BI.getDate();
+ this._year = this.today.getFullYear();
+ this._month = this.today.getMonth() + 1;
+
+ this.selectedTime = o.selectedTime || {
+ year: this._year,
+ month: this._month
+ };
+
+ this.datePicker = BI.createWidget({
+ type: "bi.date_picker",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ });
+ this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
+ var value = self.datePicker.getValue();
+ var monthDay = BI.getMonthDays(BI.getDate(value.year, value.month - 1, 1));
+ var day = self.selectedTime.day || 0;
+ if (day > monthDay) {
+ day = monthDay;
+ }
+ self.selectedTime = BI.extend(self.selectedTime, {
+ year: value.year,
+ month: value.month,
+ day: day
+ });
+ day !== 0 && (self.selectedTime.day = day);
+ self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
+ self.calendar.setValue(self.selectedTime);
+ day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ this.calendar = BI.createWidget({
+ direction: "custom",
+ // logic: {
+ // dynamic: false
+ // },
+ type: "bi.navigation",
+ tab: this.datePicker,
+ cardCreator: BI.bind(this._createNav, this)
+ });
+ this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue());
+ self.calendar.empty();
+ self.setValue(self.selectedTime);
+ self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ hgap: 10,
+ items: [{
+ el: this.datePicker,
+ height: 40
+ }, this.calendar, {
+ el: {
+ type: "bi.dynamic_date_time_select",
+ cls: "bi-split-top",
+ ref: function () {
+ self.timeSelect = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM,
+ action: function () {
+ self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue());
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ },
+ height: 40
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-split-top"
+ },
+ height: 1,
+ top: 40,
+ left: 0,
+ right: 0
+ }]
+ });
+ this.setValue(o.selectedTime);
+
+ },
+
+ _createNav: function (v) {
+ var date = BI.Calendar.getDateJSONByPage(v);
+ var calendar = BI.createWidget({
+ type: "bi.calendar",
+ logic: {
+ dynamic: false
+ },
+ min: this.options.min,
+ max: this.options.max,
+ year: date.year,
+ month: date.month,
+ day: this.selectedTime.day
+ });
+ return calendar;
+ },
+
+ _getNewCurrentDate: function () {
+ var today = BI.getDate();
+ return {
+ year: today.getFullYear(),
+ month: today.getMonth() + 1
+ };
+ },
+
+ _setCalenderValue: function (date) {
+ this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date));
+ this.calendar.setValue(date);
+ this.selectedTime = BI.extend({}, this.timeSelect.getValue(), date);
+ },
+
+ _setDatePicker: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) {
+ this.datePicker.setValue(this._getNewCurrentDate());
+ } else {
+ this.datePicker.setValue(timeOb);
+ }
+ },
+
+ _setCalendar: function (timeOb) {
+ if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) {
+ this.calendar.empty();
+ this._setCalenderValue(this._getNewCurrentDate());
+ } else {
+ this._setCalenderValue(timeOb);
+ }
+ },
+
+ setValue: function (timeOb) {
+ timeOb = timeOb || {};
+ this._setDatePicker(timeOb);
+ this._setCalendar(timeOb);
+ this.timeSelect.setValue({
+ hour: timeOb.hour,
+ minute: timeOb.minute,
+ second: timeOb.second
+ });
+ },
+
+ getValue: function () {
+ return this.selectedTime;
+ }
+
+});
+BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.DynamicDateTimePane = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-dynamic-date-pane"
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: 30,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Multi_Date_YMD"),
+ value: BI.DynamicDateTimePane.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicDateTimePane.Dynamic
+ }], {
+ textAlign: "center"
+ }),
+ listeners: [{
+ eventName: BI.ButtonGroup.EVENT_CHANGE,
+ action: function () {
+ var value = this.getValue()[0];
+ self.dateTab.setSelect(value);
+ switch (value) {
+ case BI.DynamicDateTimePane.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ break;
+ case BI.DynamicDateTimePane.Dynamic:
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ break;
+ default:
+ break;
+ }
+ }
+ }],
+ ref: function () {
+ self.switcher = this;
+ }
+ },
+ height: 30
+ }, {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ showIndex: BI.DynamicDateTimePane.Static,
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicDateTimePane.Static:
+ return {
+ type: "bi.static_date_time_pane_card",
+ behaviors: o.behaviors,
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }],
+ ref: function () {
+ self.ymd = this;
+ }
+ };
+ case BI.DynamicDateTimePane.Dynamic:
+ default:
+ return {
+ type: "bi.dynamic_date_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ if(self._checkValue(self.getValue())) {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ }
+ }
+ }]
+ };
+ },
+
+ mounted: function () {
+ this.setValue(this.options.value);
+ },
+
+ _checkValueValid: function (value) {
+ return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
+ },
+
+ _checkValue: function (v) {
+ switch (v.type) {
+ case BI.DynamicDateCombo.Dynamic:
+ return BI.isNotEmptyObject(v.value);
+ case BI.DynamicDateCombo.Static:
+ default:
+ return true;
+ }
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ var type = v.type || BI.DynamicDateTimePane.Static;
+ var value = v.value || v;
+ this.switcher.setValue(type);
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateTimePane.Dynamic:
+ this.dynamicPane.setValue(value);
+ break;
+ case BI.DynamicDateTimePane.Static:
+ default:
+ if (this._checkValueValid(value)) {
+ var date = BI.getDate();
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1
+ });
+ } else {
+ this.ymd.setValue(value);
+ }
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+});
+BI.shortcut("bi.dynamic_date_time_pane", BI.DynamicDateTimePane);
+
+BI.extend(BI.DynamicDateTimePane, {
+ Static: 1,
+ Dynamic: 2
+});/**
+ * Created by roy on 15/8/14.
+ */
+BI.DownListCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-combo",
+ height: 24,
+ items: [],
+ adjustLength: 0,
+ direction: "bottom",
+ trigger: "click",
+ container: null,
+ stopPropagation: false,
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.DownListCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popupview = BI.createWidget({
+ type: "bi.down_list_popup",
+ items: o.items,
+ chooseType: o.chooseType,
+ value: o.value
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
+ self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
+ self.downlistcombo.hideView();
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
+ self.downlistcombo.hideView();
+ });
+
+
+ this.downlistcombo = BI.createWidget({
+ element: this,
+ type: "bi.combo",
+ trigger: o.trigger,
+ isNeedAdjustWidth: false,
+ container: o.container,
+ adjustLength: o.adjustLength,
+ direction: o.direction,
+ stopPropagation: o.stopPropagation,
+ el: BI.createWidget(o.el, {
+ type: "bi.icon_trigger",
+ extraCls: o.iconCls ? o.iconCls : "",
+ width: o.width,
+ height: o.height
+ }),
+ popup: {
+ el: this.popupview,
+ stopPropagation: true,
+ maxHeight: 1000,
+ minWidth: 140
+ }
+ });
+
+ this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ hideView: function () {
+ this.downlistcombo.hideView();
+ },
+
+ showView: function (e) {
+ this.downlistcombo.showView(e);
+ },
+
+ populate: function (items) {
+ this.popupview.populate(items);
+ },
+
+ setValue: function (v) {
+ this.popupview.setValue(v);
+ },
+ getValue: function () {
+ return this.popupview.getValue();
+ }
+});
+BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.down_list_combo", BI.DownListCombo);/**
+ * Created by roy on 15/9/6.
+ */
+BI.DownListGroup = BI.inherit(BI.Widget, {
+ constants: {
+ iconCls: "check-mark-ha-font"
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-down-list-group",
+ items: [
+ {
+ el: {}
+ }
+ ]
+ });
+ },
+ _init: function () {
+ BI.DownListGroup.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+
+ this.downlistgroup = BI.createWidget({
+ element: this,
+ type: "bi.button_tree",
+ items: o.items,
+ chooseType: 0, // 0单选,1多选
+ layouts: [{
+ type: "bi.vertical",
+ hgap: 0,
+ vgap: 0
+ }],
+ value: o.value
+ });
+ this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if(type === BI.Events.CLICK) {
+ self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments);
+ }
+ });
+ },
+ getValue: function () {
+ return this.downlistgroup.getValue();
+ },
+ setValue: function (v) {
+ this.downlistgroup.setValue(v);
+ }
+
+
+});
+BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-item bi-list-item-active",
+ cls: "",
+ height: 24,
+ logic: {
+ dynamic: true
+ },
+ selected: false,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.DownListItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ 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.center_adapt",
+ width: 36,
+ height: o.height,
+ items: [{
+ el: {
+ type: "bi.icon",
+ width: o.iconWidth,
+ height: o.iconHeight
+ }
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left), BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.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.DownListItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.DownListItem.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.DownListItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-down-list-group-item",
+ logic: {
+ dynamic: false
+ },
+ // invalid: true,
+ iconCls1: "dot-e-font",
+ iconCls2: "pull-right-e-font"
+ });
+ },
+ _init: function () {
+ BI.DownListGroupItem.superclass._init.apply(this, arguments);
+ var o = this.options;
+ var self = this;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-group-item-text",
+ textAlign: "left",
+ text: o.text,
+ value: o.value,
+ height: o.height
+ });
+
+ this.icon1 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls1,
+ width: 36,
+ forceNotSelected: true,
+ selected: this._digest(o.value)
+ });
+
+ this.icon2 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls2,
+ width: 24,
+ forceNotSelected: true
+ });
+
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: 24
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.icon2,
+ 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", this.icon1, this.text, blank)
+ }))));
+
+ this.element.hover(function () {
+ if (self.isEnabled()) {
+ self.hover();
+ }
+ }, function () {
+ if (self.isEnabled()) {
+ self.dishover();
+ }
+ });
+ },
+
+ _digest: function (v) {
+ var self = this, o = this.options;
+ v = BI.isArray(v) ? v : [v];
+ return BI.any(v, function (idx, value) {
+ return BI.contains(o.childValues, value);
+ });
+ },
+
+ hover: function () {
+ BI.DownListGroupItem.superclass.hover.apply(this, arguments);
+ this.icon1.element.addClass("hover");
+ this.icon2.element.addClass("hover");
+
+ },
+
+ dishover: function () {
+ BI.DownListGroupItem.superclass.dishover.apply(this, arguments);
+ this.icon1.element.removeClass("hover");
+ this.icon2.element.removeClass("hover");
+ },
+
+ doClick: function () {
+ BI.DownListGroupItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue());
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ setValue: function (v) {
+ this.icon1.setSelected(this._digest(v));
+ }
+});
+BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/**
+ * Created by roy on 15/9/8.
+ * 处理popup中的item分组样式
+ * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
+ */
+BI.DownListPopup = BI.inherit(BI.Pane, {
+ constants: {
+ nextIcon: "pull-right-e-font",
+ height: 24,
+ iconHeight: 12,
+ iconWidth: 12,
+ hgap: 0,
+ vgap: 0,
+ border: 1
+ },
+ _defaultConfig: function () {
+ var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-popup",
+ items: [],
+ chooseType: BI.Selection.Multi
+ });
+ },
+ _init: function () {
+ BI.DownListPopup.superclass._init.apply(this, arguments);
+ this.singleValues = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ this.items = BI.deepClone(this.options.items);
+ var self = this, o = this.options, children = this._createChildren(this.items);
+ this.popup = BI.createWidget({
+ type: "bi.button_tree",
+ items: BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ ),
+ layouts: [{
+ type: "bi.vertical",
+ hgap: this.constants.hgap,
+ vgap: this.constants.vgap
+ }],
+ value: this._digest(o.value),
+ chooseType: o.chooseType
+ });
+
+ this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
+ var changedValue = value;
+ if (BI.isNotNull(self.childValueMap[value])) {
+ changedValue = self.childValueMap[value];
+ self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]);
+ } else {
+ self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object);
+ }
+
+
+ if (!BI.contains(self.singleValues, changedValue)) {
+ var item = self.getValue();
+ var result = [];
+ BI.each(item, function (i, valueObject) {
+ if (valueObject.value != changedValue) {
+ result.push(valueObject);
+ }
+ });
+ self.setValue(result);
+ }
+
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.popup],
+ vgap: 5
+ });
+
+ },
+ _createChildren: function (items) {
+ var self = this, result = [];
+ // 不能修改populate进来的item的引用
+ BI.each(items, function (i, it) {
+ var item_done = {
+ type: "bi.down_list_group",
+ items: []
+ };
+
+ BI.each(it, function (i, item) {
+ if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
+ item.type = "bi.combo_group";
+ item.cls = "down-list-group";
+ item.trigger = "hover";
+ item.isNeedAdjustWidth = false;
+ item.el.title = item.el.title || item.el.text;
+ item.el.type = "bi.down_list_group_item";
+ item.el.logic = {
+ dynamic: true
+ };
+ item.el.height = self.constants.height;
+ item.el.iconCls2 = self.constants.nextIcon;
+ item.popup = {
+ lgap: 1,
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+
+ },
+ innerVGap: 5,
+ maxHeight: 378
+ };
+ item.el.childValues = [];
+ BI.each(item.children, function (i, child) {
+ var fatherValue = BI.deepClone(item.el.value);
+ var childValue = BI.deepClone(child.value);
+ self.singleValues.push(child.value);
+ child.type = "bi.down_list_item";
+ child.extraCls = " child-down-list-item";
+ child.title = child.title || child.text;
+ child.textRgap = 10;
+ child.isNeedAdjustWidth = false;
+ child.logic = {
+ dynamic: true
+ };
+ child.father = fatherValue;
+ self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
+ self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
+ child.value = self._createChildValue(fatherValue, childValue);
+ item.el.childValues.push(child.value);
+ });
+ } else {
+ item.type = "bi.down_list_item";
+ item.title = item.title || item.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true
+ };
+ }
+ var el_done = {};
+ el_done.el = item;
+ item_done.items.push(el_done);
+ });
+ if (self._isGroup(item_done.items)) {
+ BI.each(item_done.items, function (i, item) {
+ self.singleValues.push(item.el.value);
+ });
+ }
+
+ result.push(item_done);
+ if (self._needSpliter(i, items.length)) {
+ var spliter_container = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-down-list-spliter bi-split-top cursor-pointer",
+ height: 0
+ }
+
+ }],
+ cls: "bi-down-list-spliter-container cursor-pointer",
+ vgap: 5,
+ lgap: 10,
+ rgap: 0
+ });
+ result.push(spliter_container);
+ }
+ });
+ return result;
+ },
+
+ _isGroup: function (i) {
+ return i.length > 1;
+ },
+
+ _needSpliter: function (i, itemLength) {
+ return i < itemLength - 1;
+ },
+
+ _createChildValue: function (fatherValue, childValue) {
+ return fatherValue + "_" + childValue;
+ },
+
+ _digest: function (valueItem) {
+ var self = this;
+ var valueArray = [];
+ BI.each(valueItem, function (i, item) {
+ var value;
+ if (BI.isNotNull(item.childValue)) {
+ value = self._createChildValue(item.value, item.childValue);
+ } else {
+ value = item.value;
+ }
+ valueArray.push(value);
+ }
+ );
+ return valueArray;
+ },
+
+ _checkValues: function (values) {
+ var value = [];
+ BI.each(this.items, function (idx, itemGroup) {
+ BI.each(itemGroup, function (id, item) {
+ if(BI.isNotNull(item.children)) {
+ var childValues = BI.map(item.children, "value");
+ var v = joinValue(childValues, values[idx]);
+ if(BI.isNotEmptyString(v)) {
+ value.push(v);
+ }
+ }else{
+ if(item.value === values[idx][0]) {
+ value.push(values[idx][0]);
+ }
+ }
+ });
+ });
+ return value;
+
+ function joinValue (sources, targets) {
+ var value = "";
+ BI.some(sources, function (idx, s) {
+ return BI.some(targets, function (id, t) {
+ if(s === t) {
+ value = s;
+ return true;
+ }
+ });
+ });
+ return value;
+ }
+ },
+
+ populate: function (items) {
+ BI.DownListPopup.superclass.populate.apply(this, arguments);
+ this.items = BI.deepClone(items);
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ this.singleValues = [];
+ var children = this._createChildren(this.items);
+ var popupItem = BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ );
+ this.popup.populate(popupItem);
+ },
+
+ setValue: function (valueItem) {
+ this.popup.setValue(this._digest(valueItem));
+ },
+
+ _getValue: function () {
+ var v = [];
+ BI.each(this.popup.getAllButtons(), function (i, item) {
+ i % 2 === 0 && v.push(item.getValue());
+ });
+ return v;
+ },
+
+ getValue: function () {
+ var self = this, result = [];
+ var values = this._checkValues(this._getValue());
+ BI.each(values, function (i, value) {
+ var valueItem = {};
+ if (BI.isNotNull(self.childValueMap[value])) {
+ var fartherValue = self.fatherValueMap[value];
+ valueItem.childValue = self.childValueMap[value];
+ valueItem.value = fartherValue;
+ } else {
+ valueItem.value = value;
+ }
+ result.push(valueItem);
+ });
+ return result;
+ }
+
+
+});
+
+BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.shortcut("bi.down_list_popup", BI.DownListPopup);/**
+ * 汇总表格帮助类
+ * Created by Young's on 2017/1/19.
+ */
+!(function () {
+ BI.DynamicDateHelper = {};
+ BI.extend(BI.DynamicDateHelper, {
+ getCalculation: function (obj) {
+ var date = BI.getDate();
+
+ return this.getCalculationByDate(date, obj);
+ },
+
+ getCalculationByDate: function (date, obj) {
+ if (BI.isNotNull(obj.year)) {
+ date = BI.getDate((date.getFullYear() + BI.parseInt(obj.year)), date.getMonth(), date.getDate());
+ }
+ if (BI.isNotNull(obj.quarter)) {
+ date = BI.getOffsetQuarter(date, BI.parseInt(obj.quarter));
+ }
+ if (BI.isNotNull(obj.month)) {
+ date = BI.getOffsetMonth(date, BI.parseInt(obj.month));
+ }
+ if (BI.isNotNull(obj.week)) {
+ date = BI.getOffsetDate(date, BI.parseInt(obj.week) * 7);
+ }
+ if (BI.isNotNull(obj.day)) {
+ date = BI.getOffsetDate(date, BI.parseInt(obj.day));
+ }
+ if (BI.isNotNull(obj.workDay)) {
+ // 配置了节假日就按照节假日计算工作日偏移,否则按正常的天去算
+ if(BI.isNotNull(BI.holidays)) {
+ var count = Math.abs(obj.workDay);
+ for (var i = 0; i < count; i++) {
+ date = BI.getOffsetDate(date, obj.workDay < 0 ? -1 : 1);
+ if(BI.isNotNull(BI.holidays[BI.print(date, "%Y-%X-%d")])) {
+ i--;
+ }
+ }
+ } else {
+ date = BI.getOffsetDate(date, BI.parseInt(obj.workDay));
+ }
+ }
+ if (BI.isNotNull(obj.position) && obj.position !== BI.DynamicDateCard.OFFSET.CURRENT) {
+ date = this.getBeginDate(date, obj);
+ }
+
+ return BI.getDate(date.getFullYear(), date.getMonth(), date.getDate());
+ },
+
+ getBeginDate: function (date, obj) {
+ if (BI.isNotNull(obj.day)) {
+ return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (BI.getLastDateOfMonth(date)).getDate());
+ }
+ if (BI.isNotNull(obj.week)) {
+ return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getWeekStartDate(date) : BI.getWeekEndDate(date);
+ }
+ if (BI.isNotNull(obj.month)) {
+ return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (BI.getLastDateOfMonth(date)).getDate());
+ }
+ if (BI.isNotNull(obj.quarter)) {
+ return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getQuarterStartDate(date) : BI.getQuarterEndDate(date);
+ }
+ if (BI.isNotNull(obj.year)) {
+ return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), 0, 1) : BI.getDate(date.getFullYear(), 11, 31);
+ }
+ return date;
+ }
+ });
+})();
+BI.DynamicDateCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-dynamic-date-card"
+ },
+
+ render: function () {
+ var self = this;
+ this.position = BI.DynamicDateCard.OFFSET.CURRENT;
+ return {
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.label",
+ text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: 12,
+ lgap: 10
+ },
+ tgap: 10,
+ bgap: 5
+ }, {
+ type: "bi.button_group",
+ ref: function () {
+ self.checkgroup = this;
+ },
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ lgap: 4,
+ value: [BI.DynamicDateCard.TYPE.YEAR],
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Basic_Year"),
+ value: BI.DynamicDateCard.TYPE.YEAR
+ }, {
+ text: BI.i18nText("BI-Basic_Single_Quarter"),
+ value: BI.DynamicDateCard.TYPE.QUARTER
+ }, {
+ text: BI.i18nText("BI-Basic_Month"),
+ value: BI.DynamicDateCard.TYPE.MONTH
+ }, {
+ text: BI.i18nText("BI-Basic_Week"),
+ value: BI.DynamicDateCard.TYPE.WEEK
+ }, {
+ text: BI.i18nText("BI-Basic_Day"),
+ value: BI.DynamicDateCard.TYPE.DAY
+ }], {
+ type: "bi.multi_select_item",
+ logic: {
+ dynamic: true
+ }
+ }),
+ layouts: [{
+ type: "bi.left",
+ rgap: 4
+ }],
+ listeners: [{
+ eventName: BI.ButtonGroup.EVENT_CHANGE,
+ action: function () {
+ var value = self.checkgroup.getValue();
+ if(value.length !== 0) {
+ self.workDayBox.setSelected(false);
+ }
+
+ var plainValue = {};
+ BI.each(self.resultPane.getAllButtons(), function (idx, button) {
+ var value = button.getValue();
+ if(BI.isNotNull(value.dateType)) {
+ plainValue[value.dateType] = {
+ value: value.value,
+ offset: value.offset
+ };
+ }
+ });
+ self.resultPane.populate(self._getParamJson(BI.map(self.checkgroup.getValue(), function (idx, v) {
+ var obj = {
+ dateType: v
+ };
+ if(BI.has(plainValue, v)) {
+ obj.value = plainValue[v].value;
+ obj.offset = plainValue[v].offset;
+ }
+ return obj;
+ })));
+ self.position = BI.DynamicDateCard.OFFSET.CURRENT;
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }, {
+ type: "bi.vertical_adapt",
+ lgap: 2,
+ items: [{
+ el: {
+ type: "bi.multi_select_item",
+ ref: function () {
+ self.workDayBox = this;
+ },
+ logic: {
+ dynamic: true
+ },
+ text: BI.i18nText("BI-Basic_Work_Day"),
+ value: BI.DynamicDateCard.TYPE.WORK_DAY,
+ listeners: [{
+ eventName: BI.MultiSelectItem.EVENT_CHANGE,
+ action: function () {
+ if(this.isSelected()) {
+ self.checkgroup.setValue();
+ }
+ self.resultPane.populate(this.isSelected() ? self._getParamJson([{
+ dateType: BI.DynamicDateCard.TYPE.WORK_DAY
+ }]) : []);
+ self.position = BI.DynamicDateCard.OFFSET.CURRENT;
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }
+ }],
+ ref: function () {
+ self.workDay = this;
+ }
+ }, {
+ type: "bi.button_group",
+ items: this._getParamJson([{
+ dateType: BI.DynamicDateCard.TYPE.YEAR
+ }]),
+ ref: function () {
+ self.resultPane = this;
+ },
+ layouts: [{
+ type: "bi.vertical",
+ bgap: 10,
+ hgap: 10
+ }]
+ }]
+ };
+ },
+
+ _getParamJson: function (values, positionValue) {
+ var self = this;
+ var items = BI.map(values, function (idx, value) {
+ return {
+ el: {
+ type: "bi.dynamic_date_param_item",
+ dateType: value.dateType,
+ value: value.value,
+ offset: value.offset,
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ },
+ tgap: idx === 0 ? 5 : 0
+ };
+ });
+
+ if(values.length === 1 && values[0].dateType === BI.DynamicDateCard.TYPE.DAY) {
+ var comboItems = this._getText(BI.DynamicDateCard.TYPE.MONTH);
+ comboItems[0].text = BI.i18nText("BI-Basic_Empty");
+ items.push({
+ type: "bi.text_value_combo",
+ height: 24,
+ items: comboItems,
+ container: null,
+ value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT,
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.position = this.getValue()[0];
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ });
+ }else{
+ if(values.length !== 0 && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.DAY && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.WORK_DAY) {
+ items.push({
+ type: "bi.text_value_combo",
+ height: 24,
+ container: null,
+ items: this._getText(BI.last(values).dateType),
+ value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT,
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.position = this.getValue()[0];
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ });
+
+ }
+ }
+
+ return items;
+ },
+
+ _getText: function (lastValue) {
+ switch (lastValue) {
+ case BI.DynamicDateCard.TYPE.YEAR:
+ return [{
+ text: BI.i18nText("BI-Basic_Current_Day"),
+ value: BI.DynamicDateCard.OFFSET.CURRENT
+ }, {
+ text: BI.i18nText("BI-Basic_Year_Begin"),
+ value: BI.DynamicDateCard.OFFSET.BEGIN
+ }, {
+ text: BI.i18nText("BI-Basic_Year_End"),
+ value: BI.DynamicDateCard.OFFSET.END
+ }];
+ case BI.DynamicDateCard.TYPE.QUARTER:
+ return [{
+ text: BI.i18nText("BI-Basic_Current_Day"),
+ value: BI.DynamicDateCard.OFFSET.CURRENT
+ }, {
+ text: BI.i18nText("BI-Basic_Quarter_Begin"),
+ value: BI.DynamicDateCard.OFFSET.BEGIN
+ }, {
+ text: BI.i18nText("BI-Basic_Quarter_End"),
+ value: BI.DynamicDateCard.OFFSET.END
+ }];
+ case BI.DynamicDateCard.TYPE.MONTH:
+ return [{
+ text: BI.i18nText("BI-Basic_Current_Day"),
+ value: BI.DynamicDateCard.OFFSET.CURRENT
+ }, {
+ text: BI.i18nText("BI-Basic_Month_Begin"),
+ value: BI.DynamicDateCard.OFFSET.BEGIN
+ }, {
+ text: BI.i18nText("BI-Basic_Month_End"),
+ value: BI.DynamicDateCard.OFFSET.END
+ }];
+ case BI.DynamicDateCard.TYPE.WEEK:
+ default:
+ return [{
+ text: BI.i18nText("BI-Basic_Current_Day"),
+ value: BI.DynamicDateCard.OFFSET.CURRENT
+ }, {
+ text: BI.i18nText("BI-Basic_Week_Begin"),
+ value: BI.DynamicDateCard.OFFSET.BEGIN
+ }, {
+ text: BI.i18nText("BI-Basic_Week_End"),
+ value: BI.DynamicDateCard.OFFSET.END
+ }];
+ }
+ },
+
+ _createValue: function (type, v) {
+ return {
+ dateType: type,
+ value: Math.abs(v),
+ offset: v > 0 ? 1 : 0
+ };
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ this.position = v.position || BI.DynamicDateCard.OFFSET.CURRENT;
+ var values = [];
+ var valuesItems = [];
+ if(BI.isNotNull(v.year)) {
+ values.push(BI.DynamicDateCard.TYPE.YEAR);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
+ }
+ if(BI.isNotNull(v.quarter)) {
+ values.push(BI.DynamicDateCard.TYPE.QUARTER);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter));
+ }
+ if(BI.isNotNull(v.month)) {
+ values.push(BI.DynamicDateCard.TYPE.MONTH);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month));
+ }
+ if(BI.isNotNull(v.week)) {
+ values.push(BI.DynamicDateCard.TYPE.WEEK);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WEEK, v.week));
+ }
+ if(BI.isNotNull(v.day)) {
+ values.push(BI.DynamicDateCard.TYPE.DAY);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.DAY, v.day));
+ }
+ if(BI.isNotNull(v.workDay)) {
+ values.push(BI.DynamicDateCard.TYPE.WORK_DAY);
+ valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WORK_DAY, v.workDay));
+ }
+ this.checkgroup.setValue(values);
+ this.workDayBox.setSelected(BI.isNotNull(v.workDay));
+ this.resultPane.populate(this._getParamJson(valuesItems, v.position));
+ },
+
+ getValue: function () {
+ var self = this;
+ var valueMap = {};
+ var selectValues = this.checkgroup.getValue();
+ var buttons = this.resultPane.getAllButtons();
+ if(selectValues.length !== 0) {
+ BI.each(buttons, function (idx, button) {
+ var value = button.getValue();
+ switch (value.dateType) {
+ case BI.DynamicDateCard.TYPE.YEAR:
+ valueMap.year = (value.offset === 0 ? -value.value : value.value);
+ break;
+ case BI.DynamicDateCard.TYPE.QUARTER:
+ valueMap.quarter = (value.offset === 0 ? -value.value : value.value);
+ break;
+ case BI.DynamicDateCard.TYPE.MONTH:
+ valueMap.month = (value.offset === 0 ? -value.value : value.value);
+ break;
+ case BI.DynamicDateCard.TYPE.WEEK:
+ valueMap.week = (value.offset === 0 ? -value.value : value.value);
+ break;
+ case BI.DynamicDateCard.TYPE.DAY:
+ valueMap.day = (value.offset === 0 ? -value.value : value.value);
+ break;
+ default:
+ break;
+ }
+ if(BI.isNull(value.dateType)) {
+ valueMap.position = self.position || BI.DynamicDateCard.OFFSET.CURRENT;
+ }
+ });
+ }
+ if(this.workDayBox.isSelected()) {
+ var value = buttons[0].getValue();
+ valueMap.workDay = (value.offset === 0 ? -value.value : value.value);
+ }
+ return valueMap;
+ }
+
+});
+BI.shortcut("bi.dynamic_date_card", BI.DynamicDateCard);
+
+BI.extend(BI.DynamicDateCard, {
+ TYPE: {
+ YEAR: 1,
+ QUARTER: 2,
+ MONTH: 3,
+ WEEK: 4,
+ DAY: 5,
+ WORK_DAY: 6
+ },
+ OFFSET: {
+ CURRENT: 1,
+ BEGIN: 2,
+ END: 3
+ }
+
+});BI.DynamicDateCombo = BI.inherit(BI.Single, {
+ constants: {
+ popupHeight: 259,
+ popupWidth: 270,
+ comboAdjustHeight: 1,
+ border: 1,
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+
+ props: {
+ baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow bi-border-radius",
+ height: 22
+ },
+
+
+ render: function () {
+ var self = this, opts = this.options;
+ this.storeTriggerValue = "";
+ var date = BI.getDate();
+ this.storeValue = opts.value;
+ return {
+ type: "bi.htape",
+ items: [{
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: opts.height,
+ height: opts.height,
+ ref: function () {
+ self.changeIcon = this;
+ }
+ },
+ width: opts.height
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.combo",
+ container: opts.container,
+ ref: function () {
+ self.combo = this;
+ },
+ toggle: false,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: {
+ type: "bi.dynamic_date_trigger",
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ height: opts.height,
+ value: opts.value,
+ ref: function () {
+ self.trigger = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ }
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_STOP,
+ action: function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK,
+ action: function () {
+ self.combo.toggle();
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_FOCUS,
+ action: function () {
+ self.storeTriggerValue = self.trigger.getKey();
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS);
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_ERROR,
+ action: function () {
+ self.storeValue = {
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1
+ }
+ };
+ self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR);
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_VALID,
+ action: function () {
+ self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.DynamicDateTrigger.EVENT_CONFIRM,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ var dateStore = self.storeTriggerValue;
+ var dateObj = self.trigger.getKey();
+ if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
+ self.storeValue = self.trigger.getValue();
+ self.setValue(self.trigger.getValue());
+ } else if (BI.isEmptyString(dateObj)) {
+ self.storeValue = null;
+ self.trigger.setValue();
+ }
+ self._checkDynamicValue(self.storeValue);
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }]
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: {
+ type: "bi.dynamic_date_popup",
+ behaviors: opts.behaviors,
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ value: opts.value,
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: function () {
+ var date = BI.getDate();
+ self.setValue({
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ }
+ });
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ var value = self.popup.getValue();
+ if(self._checkValue(value)) {
+ self.setValue(value);
+ }
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDatePopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }]
+ },
+ stopPropagation: false
+ },
+ // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
+ hideChecker: function (e) {
+ return self.triggerBtn.element.find(e.target).length === 0;
+ },
+ listeners: [{
+ eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
+ }
+ }]
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-font",
+ width: opts.height,
+ height: opts.height,
+ listeners: [{
+ eventName: BI.IconButton.EVENT_CHANGE,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ // self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ }
+ }],
+ ref: function () {
+ self.triggerBtn = this;
+ }
+ },
+ top: 0,
+ right: 0
+ }]
+ }],
+ ref: function (_ref) {
+ self.comboWrapper = _ref;
+ }
+ };
+ },
+
+ mounted: function () {
+ this._checkDynamicValue(this.storeValue);
+ },
+
+ _checkDynamicValue: function (v) {
+ var o = this.options;
+ var type = null;
+ if (BI.isNotNull(v)) {
+ type = v.type;
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ this.comboWrapper.attr("items")[0].width = o.height;
+ this.comboWrapper.resize();
+ break;
+ default:
+ this.comboWrapper.attr("items")[0].width = 0;
+ this.comboWrapper.resize();
+ this.changeIcon.setVisible(false);
+ break;
+ }
+ },
+
+ _checkValue: function (v) {
+ switch (v.type) {
+ case BI.DynamicDateCombo.Dynamic:
+ return BI.isNotEmptyObject(v.value);
+ case BI.DynamicDateCombo.Static:
+ default:
+ return true;
+ }
+ },
+
+ _defaultState: function () {
+
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ this._checkDynamicValue(v);
+ },
+ getValue: function () {
+ return this.storeValue;
+ },
+ getKey: function () {
+ return this.trigger.getKey();
+ },
+ hidePopupView: function () {
+ this.combo.hideView();
+ }
+});
+
+BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID";
+BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.dynamic_date_combo", BI.DynamicDateCombo);
+
+BI.extend(BI.DynamicDateCombo, {
+ Static: 1,
+ Dynamic: 2
+});BI.DynamicDateParamItem = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-dynamic-date-param-item",
+ dateType: BI.DynamicDateCard.TYPE.YEAR,
+ value: 0,
+ offset: 0,
+ height: 24
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.htape",
+ items: [{
+ el: {
+ type: "bi.sign_editor",
+ cls: "bi-border",
+ height: 22,
+ validationChecker: function (v) {
+ return BI.isNaturalNumber(v);
+ },
+ value: o.value,
+ ref: function () {
+ self.editor = this;
+ },
+ errorText: function (v) {
+ if(BI.isEmptyString(v)) {
+ return BI.i18nText("BI-Basic_Please_Input_Content");
+ }
+ return BI.i18nText("BI-Please_Input_Natural_Number");
+ },
+ allowBlank: false,
+ listeners: [{
+ eventName: BI.SignEditor.EVENT_CONFIRM,
+ action: function () {
+ self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE);
+ }
+ }]
+ },
+ width: 60
+ }, {
+ el: {
+ type: "bi.label",
+ height: 24,
+ text: this._getText()
+ },
+ width: o.dateType === BI.DynamicDateCard.TYPE.WORK_DAY ? 60 : 20
+ }, {
+ type: "bi.text_value_combo",
+ height: 24,
+ items: [{
+ text: BI.i18nText("BI-Basic_Front"),
+ value: 0
+ }, {
+ text: BI.i18nText("BI-Basic_Behind"),
+ value: 1
+ }],
+ ref: function () {
+ self.offsetCombo = this;
+ },
+ container: null,
+ value: o.offset,
+ listeners: [{
+ eventName: BI.TextValueCombo.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE);
+ }
+ }]
+ }]
+ };
+ },
+
+ _getText: function () {
+ var text = "";
+ switch (this.options.dateType) {
+ case BI.DynamicDateCard.TYPE.YEAR:
+ text = BI.i18nText("BI-Basic_Year");
+ break;
+ case BI.DynamicDateCard.TYPE.QUARTER:
+ text = BI.i18nText("BI-Basic_Single_Quarter");
+ break;
+ case BI.DynamicDateCard.TYPE.MONTH:
+ text = BI.i18nText("BI-Basic_Month");
+ break;
+ case BI.DynamicDateCard.TYPE.WEEK:
+ text = BI.i18nText("BI-Basic_Week");
+ break;
+ case BI.DynamicDateCard.TYPE.DAY:
+ text = BI.i18nText("BI-Basic_Day");
+ break;
+ case BI.DynamicDateCard.TYPE.WORK_DAY:
+ default:
+ text = BI.i18nText("BI-Basic_Work_Day");
+ break;
+ }
+ return text;
+ },
+
+ setValue: function (v) {
+ v = v || {};
+ v.value = v.value || 0;
+ v.offset = v.offset || 0;
+ this.editor.setValue(v.value);
+ this.offsetCombo.setValue(v.offset);
+ },
+
+ getValue: function () {
+ return {
+ dateType: this.options.dateType,
+ value: this.editor.getValue(),
+ offset: this.offsetCombo.getValue()[0]
+ };
+ }
+
+});
+BI.DynamicDateParamItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_date_param_item", BI.DynamicDateParamItem);
+BI.DynamicDatePopup = BI.inherit(BI.Widget, {
+ constants: {
+ tabHeight: 30,
+ buttonHeight: 24
+ },
+
+ props: {
+ baseCls: "bi-dynamic-date-popup",
+ width: 248,
+ height: 344
+ },
+
+ _init: function () {
+ BI.DynamicDatePopup.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options, c = this.constants;
+ this.storeValue = {type: BI.DynamicDateCombo.Static};
+ BI.createWidget({
+ element: this,
+ type: "bi.vtape",
+ items: [{
+ el: this._getTabJson()
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Clear"),
+ textHeight: c.buttonHeight - 1,
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ shadow: true,
+ textHeight: c.buttonHeight - 1,
+ text: BI.i18nText("BI-Multi_Date_Today"),
+ ref: function () {
+ self.textButton = this;
+ },
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ });
+ this.setValue(opts.value);
+ },
+
+ _getTabJson: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ tab: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: this.constants.tabHeight,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Multi_Date_YMD"),
+ value: BI.DynamicDateCombo.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicDateCombo.Dynamic
+ }], {
+ textAlign: "center"
+ })
+ },
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicDateCombo.Dynamic:
+ return {
+ type: "bi.dynamic_date_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self._setInnerValue(self.year, v);
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ case BI.DynamicDateCombo.Static:
+ default:
+ return {
+ type: "bi.date_calendar_popup",
+ behaviors: o.behaviors,
+ min: self.options.min,
+ max: self.options.max,
+ listeners: [{
+ eventName: BI.DateCalendarPopup.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDatePopup.EVENT_CHANGE);
+ }
+ }],
+ ref: function () {
+ self.ymd = this;
+ }
+ };
+ }
+ },
+ listeners: [{
+ eventName: BI.Tab.EVENT_CHANGE,
+ action: function () {
+ var v = self.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicDateCombo.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Dynamic:
+ default:
+ if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) {
+ self.dynamicPane.setValue(self.storeValue.value);
+ }else{
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ }
+ self._setInnerValue();
+ break;
+ }
+ }
+ }]
+ };
+ },
+
+ _setInnerValue: function () {
+ if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ this.textButton.setEnable(true);
+ } else {
+ var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ date = BI.print(date, "%Y-%X-%d");
+ this.textButton.setValue(date);
+ this.textButton.setEnable(false);
+ }
+ },
+
+ _checkValueValid: function (value) {
+ return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ var self = this;
+ var type, value;
+ v = v || {};
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (this._checkValueValid(value)) {
+ var date = BI.getDate();
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ } else {
+ this.ymd.setValue(value);
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ }
+ this.textButton.setEnable(true);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+});
+BI.DynamicDatePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ yearLength: 4,
+ yearMonthLength: 6,
+ yearFullMonthLength: 7
+ },
+
+ props: {
+ extraCls: "bi-date-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 24
+ },
+
+ _init: function () {
+ BI.DynamicDateTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.storeTriggerValue = "";
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ var date = v.match(/\d+/g);
+ self._autoAppend(v, date);
+ return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0
+ });
+ },
+ quitChecker: function () {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ errorText: function () {
+ if (self.editor.isEditing()) {
+ return BI.i18nText("BI-Date_Trigger_Error_Text");
+ }
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ },
+ title: function () {
+ var storeValue = self.storeValue || {};
+ var type = storeValue.type || BI.DynamicDateCombo.Static;
+ var value = storeValue.value;
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = self._getText(value);
+ var date = BI.getDate();
+ date = BI.DynamicDateHelper.getCalculation(value);
+ var dateStr = BI.print(date, "%Y-%X-%d");
+ return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ return "";
+ }
+ return BI.print(BI.getDate(value.year, (value.month - 1), value.day), "%Y-%X-%d");
+ }
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_KEY_DOWN);
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.storeTriggerValue = self.getKey();
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_VALID, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_VALID);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_ERROR);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setState(value);
+ }
+
+ if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) {
+ var date = value.split("-");
+ self.storeValue = {
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0
+ }
+ };
+ }
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DynamicDateTrigger.EVENT_CHANGE);
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.editor
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+ this.setValue(o.value);
+ },
+ _dateCheck: function (date) {
+ return BI.print(BI.parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ },
+ _checkVoid: function (obj) {
+ return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
+ },
+ _autoAppend: function (v, dateObj) {
+ if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) {
+ switch (v.length) {
+ case this._const.yearLength:
+ if (this._yearCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ case this._const.yearMonthLength:
+ case this._const.yearFullMonthLength:
+ var splitMonth = v.split("-")[1];
+ if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ }
+ }
+ },
+
+ _yearCheck: function (v) {
+ var date = BI.print(BI.parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+ return BI.print(BI.parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
+ },
+
+ _monthCheck: function (v) {
+ var date = BI.parseDateTime(v, "%Y-%X-%d");
+ var dateStr = BI.print(date, "%Y-%X-%d");
+ return (date.getMonth() >= 0 && (BI.print(BI.parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
+ BI.print(BI.parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
+ },
+
+ _setInnerValue: function (date) {
+ var dateStr = BI.print(date, "%Y-%X-%d");
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ },
+
+ _getText: function (obj) {
+ var value = "";
+ var endText = "";
+ if(BI.isNotNull(obj.year)) {
+ if(BI.parseInt(obj.year) !== 0) {
+ value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position);
+ }
+ if(BI.isNotNull(obj.quarter)) {
+ if(BI.parseInt(obj.quarter) !== 0) {
+ value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position);
+ }
+ if(BI.isNotNull(obj.month)) {
+ if(BI.parseInt(obj.month) !== 0) {
+ value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position);
+ }
+ if(BI.isNotNull(obj.week)) {
+ if(BI.parseInt(obj.week) !== 0) {
+ value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position);
+ }
+ if(BI.isNotNull(obj.day)) {
+ if(BI.parseInt(obj.day) !== 0) {
+ value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : "";
+ }
+ if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) {
+ value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ return value + endText;
+
+ function getPositionText (baseText, position) {
+ switch (position) {
+ case BI.DynamicDateCard.OFFSET.BEGIN:
+ return baseText + BI.i18nText("BI-Basic_Begin_Start");
+ case BI.DynamicDateCard.OFFSET.END:
+ return baseText + BI.i18nText("BI-Basic_End_Stop");
+ case BI.DynamicDateCard.OFFSET.CURRENT:
+ default:
+ return BI.i18nText("BI-Basic_Current_Day");
+ }
+ }
+ },
+
+ setValue: function (v) {
+ var type, value, self = this;
+ var date = BI.getDate();
+ this.storeValue = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ date = BI.DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ this.editor.setState("");
+ this.editor.setValue("");
+ } else {
+ var dateStr = BI.print(BI.getDate(value.year, (value.month - 1), value.day), "%Y-%X-%d");
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ }
+ break;
+ }
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+ getValue: function () {
+ return this.storeValue;
+ }
+
+});
+
+BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicDateTrigger.EVENT_START = "EVENT_START";
+BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DynamicDateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicDateTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDateTrigger.EVENT_VALID = "EVENT_VALID";
+BI.DynamicDateTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.DynamicDateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.dynamic_date_trigger", BI.DynamicDateTrigger);
+BI.DynamicDateTimeCombo = BI.inherit(BI.Single, {
+ constants: {
+ popupHeight: 259,
+ popupWidth: 270,
+ comboAdjustHeight: 1,
+ border: 1,
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+
+ props: {
+ baseCls: "bi-dynamic-date-combo bi-border bi-focus-shadow",
+ height: 22
+ },
+
+
+ render: function () {
+ var self = this, opts = this.options;
+ this.storeTriggerValue = "";
+ var date = BI.getDate();
+ this.storeValue = opts.value;
+ return {
+ type: "bi.htape",
+ items: [{
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: opts.height,
+ height: opts.height,
+ ref: function () {
+ self.changeIcon = this;
+ }
+ },
+ width: opts.height
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.combo",
+ container: opts.container,
+ ref: function () {
+ self.combo = this;
+ },
+ toggle: false,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: {
+ type: "bi.dynamic_date_time_trigger",
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ height: opts.height,
+ value: opts.value,
+ ref: function () {
+ self.trigger = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ }
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_STOP,
+ action: function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK,
+ action: function () {
+ self.combo.toggle();
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS,
+ action: function () {
+ self.storeTriggerValue = self.trigger.getKey();
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS);
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR,
+ action: function () {
+ self.storeValue = {
+ type: BI.DynamicDateTimeCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1
+ }
+ };
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR);
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_VALID,
+ action: function () {
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID);
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ var dateStore = self.storeTriggerValue;
+ var dateObj = self.trigger.getKey();
+ if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
+ self.storeValue = self.trigger.getValue();
+ self.setValue(self.trigger.getValue());
+ } else if (BI.isEmptyString(dateObj)) {
+ self.storeValue = null;
+ self.trigger.setValue();
+ }
+ self._checkDynamicValue(self.storeValue);
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
+ }
+ }]
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: {
+ type: "bi.dynamic_date_time_popup",
+ behaviors: opts.behaviors,
+ min: this.constants.DATE_MIN_VALUE,
+ max: this.constants.DATE_MAX_VALUE,
+ value: opts.value,
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: function () {
+ var date = BI.getDate();
+ self.setValue({
+ type: BI.DynamicDateTimeCombo.Static,
+ value: {
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ hour: 0,
+ minute: 0,
+ second: 0
+ }
+ });
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ var value = self.popup.getValue();
+ if(self._checkValue(value)) {
+ self.setValue(value);
+ }
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicDateTimePopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM);
+ }
+ }]
+ },
+ stopPropagation: false
+ },
+ listeners: [{
+ eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
+ }
+ }],
+ // DEC-4250 和复选下拉一样,点击不收起
+ hideChecker: function (e) {
+ return self.triggerBtn.element.find(e.target).length === 0;
+ }
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-font",
+ width: opts.height,
+ height: opts.height,
+ listeners: [{
+ eventName: BI.IconButton.EVENT_CHANGE,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ // self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ }
+ }],
+ ref: function () {
+ self.triggerBtn = this;
+ }
+ },
+ top: 0,
+ right: 0
+ }]
+ }],
+ ref: function (_ref) {
+ self.comboWrapper = _ref;
+ }
+ };
+ },
+
+ mounted: function () {
+ this._checkDynamicValue(this.storeValue);
+ },
+
+ _checkDynamicValue: function (v) {
+ var o = this.options;
+ var type = null;
+ if (BI.isNotNull(v)) {
+ type = v.type;
+ }
+ switch (type) {
+ case BI.DynamicDateTimeCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ this.comboWrapper.attr("items")[0].width = o.height;
+ this.comboWrapper.resize();
+ break;
+ default:
+ this.comboWrapper.attr("items")[0].width = 0;
+ this.comboWrapper.resize();
+ this.changeIcon.setVisible(false);
+ break;
+ }
+ },
+
+ _checkValue: function (v) {
+ switch (v.type) {
+ case BI.DynamicDateCombo.Dynamic:
+ return BI.isNotEmptyObject(v.value);
+ case BI.DynamicDateCombo.Static:
+ default:
+ return true;
+ }
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ this._checkDynamicValue(v);
+ },
+ getValue: function () {
+ return this.storeValue;
+ },
+ getKey: function () {
+ return this.trigger.getKey();
+ },
+ hidePopupView: function () {
+ this.combo.hideView();
+ },
+
+ isValid: function () {
+ return this.trigger.isValid();
+ }
+});
+
+BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID";
+BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.dynamic_date_time_combo", BI.DynamicDateTimeCombo);
+
+BI.extend(BI.DynamicDateTimeCombo, {
+ Static: 1,
+ Dynamic: 2
+});BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
+ constants: {
+ tabHeight: 30,
+ buttonHeight: 24
+ },
+
+ props: {
+ baseCls: "bi-dynamic-date-time-popup",
+ width: 248,
+ height: 385
+ },
+
+ _init: function () {
+ BI.DynamicDateTimePopup.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options, c = this.constants;
+ this.storeValue = {type: BI.DynamicDateCombo.Static};
+ BI.createWidget({
+ element: this,
+ type: "bi.vtape",
+ items: [{
+ el: this._getTabJson()
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Clear"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Multi_Date_Today"),
+ ref: function () {
+ self.textButton = this;
+ },
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ });
+ this.setValue(opts.value);
+ },
+
+ _getTabJson: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ tab: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: this.constants.tabHeight,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Multi_Date_YMD"),
+ value: BI.DynamicDateCombo.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicDateCombo.Dynamic
+ }], {
+ textAlign: "center"
+ })
+ },
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicDateCombo.Dynamic:
+ return {
+ type: "bi.dynamic_date_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self._setInnerValue(self.year, v);
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ case BI.DynamicDateCombo.Static:
+ default:
+ return {
+ type: "bi.vtape",
+ items: [{
+ type: "bi.date_calendar_popup",
+ behaviors: o.behaviors,
+ min: self.options.min,
+ max: self.options.max,
+ ref: function () {
+ self.ymd = this;
+ }
+ }, {
+ el: {
+ type: "bi.dynamic_date_time_select",
+ cls: "bi-split-top",
+ ref: function () {
+ self.timeSelect = this;
+ }
+ },
+ height: 40
+ }]
+ };
+ }
+ },
+ listeners: [{
+ eventName: BI.Tab.EVENT_CHANGE,
+ action: function () {
+ var v = self.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicDateCombo.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ self.timeSelect.setValue();
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Dynamic:
+ default:
+ if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) {
+ self.dynamicPane.setValue(self.storeValue.value);
+ }else{
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ }
+ self._setInnerValue();
+ break;
+ }
+ }
+ }]
+ };
+ },
+
+ _setInnerValue: function () {
+ if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ this.textButton.setEnable(true);
+ } else {
+ var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ date = BI.print(date, "%Y-%X-%d");
+ this.textButton.setValue(date);
+ this.textButton.setEnable(false);
+ }
+ },
+
+ _checkValueValid: function (value) {
+ return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ var self = this;
+ var type, value;
+ v = v || {};
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (this._checkValueValid(value)) {
+ var date = BI.getDate();
+ this.ymd.setValue({
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate()
+ });
+ this.timeSelect.setValue();
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ } else {
+ this.ymd.setValue(value);
+ this.timeSelect.setValue({
+ hour: value.hour,
+ minute: value.minute,
+ second: value.second
+ });
+ this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
+ }
+ this.textButton.setEnable(true);
+ break;
+ }
+ },
+
+ getValue: function () {
+ var type = this.dateTab.getSelect();
+ return {
+ type: type,
+ value: type === BI.DynamicDateTimeCombo.Static ? BI.extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue()
+ };
+ }
+});
+BI.DynamicDateTimePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-date-time-select"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.center_adapt",
+ items: [{
+ type: "bi.vertical_adapt",
+ items: [{
+ el: {
+ type: "bi.number_editor",
+ ref: function () {
+ self.hour = this;
+ },
+ validationChecker: function (v) {
+ return BI.isNaturalNumber(v) && BI.parseInt(v) < 24;
+ },
+ errorText: function (v) {
+ if(BI.isNumeric(v)) {
+ return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-23\"");
+ }
+ return BI.i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [{
+ eventName: BI.SignEditor.EVENT_CONFIRM,
+ action: function () {
+ var value = this.getValue();
+ self._checkHour(value);
+ this.setValue(self._formatValueToDoubleDigit(value));
+ self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.SignEditor.EVENT_CHANGE,
+ action: function () {
+ var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.HOUR);
+ this.setValue(value);
+ }
+ }],
+ width: 60,
+ height: 24
+ }
+ }, {
+ type: "bi.label",
+ text: ":",
+ width: 20
+ }, {
+ type: "bi.number_editor",
+ ref: function () {
+ self.minute = this;
+ },
+ validationChecker: function (v) {
+ return BI.isNaturalNumber(v) && BI.parseInt(v) < 60;
+ },
+ errorText: function (v) {
+ if(BI.isNumeric(v)) {
+ return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
+ }
+ return BI.i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [{
+ eventName: BI.SignEditor.EVENT_CONFIRM,
+ action: function () {
+ var value = this.getValue();
+ self._checkMinute(value);
+ this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE);
+ self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.SignEditor.EVENT_CHANGE,
+ action: function () {
+ var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.MINUTE);
+ this.setValue(value);
+ }
+ }],
+ width: 60,
+ height: 24
+ }, {
+ type: "bi.label",
+ text: ":",
+ width: 20
+ }, {
+ type: "bi.number_editor",
+ ref: function () {
+ self.second = this;
+ },
+ validationChecker: function (v) {
+ return BI.isNaturalNumber(v) && BI.parseInt(v) < 60;
+ },
+ errorText: function (v) {
+ if(BI.isNumeric(v)) {
+ return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\"");
+ }
+ return BI.i18nText("BI-Numerical_Interval_Input_Data");
+ },
+ listeners: [{
+ eventName: BI.SignEditor.EVENT_CONFIRM,
+ action: function () {
+ var value = this.getValue();
+ self._checkSecond(value);
+ this.setValue(self._formatValueToDoubleDigit(value));
+ self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM);
+ }
+ }],
+ width: 60,
+ height: 24
+ }]
+ }]
+ };
+ },
+
+ _checkBorder: function (v) {
+ v = v || {};
+ this._checkHour(v.hour);
+ this._checkMinute(v.minute);
+ this._checkSecond(v.second);
+ },
+
+ _checkHour: function (value) {
+ this.hour.setDownEnable(BI.parseInt(value) > 0);
+ this.hour.setUpEnable(BI.parseInt(value) < 23);
+ },
+
+ _checkMinute: function (value) {
+ this.minute.setDownEnable(BI.parseInt(value) > 0);
+ this.minute.setUpEnable(BI.parseInt(value) < 59);
+ },
+
+ _checkSecond: function (value) {
+ this.second.setDownEnable(BI.parseInt(value) > 0);
+ this.second.setUpEnable(BI.parseInt(value) < 59);
+ },
+
+ _autoSwitch: function (v, type) {
+ var limit = 0;
+ var value = v + "";
+ switch (type) {
+ case BI.DynamicDateTimeSelect.HOUR:
+ limit = 2;
+ break;
+ case BI.DynamicDateTimeSelect.MINUTE:
+ limit = 5;
+ break;
+ default:
+ break;
+ }
+ if(value.length === 1 && BI.parseInt(value) > limit) {
+ value = "0" + value;
+ }
+ if (value.length === 2) {
+ switch (type) {
+ case BI.DynamicDateTimeSelect.HOUR:
+ this.hour.isEditing() && this.minute.focus();
+ break;
+ case BI.DynamicDateTimeSelect.MINUTE:
+ this.minute.isEditing() && this.second.focus();
+ break;
+ case BI.DynamicDateTimeSelect.SECOND:
+ default:
+ break;
+ }
+ }
+ return value;
+ },
+
+ _formatValueToDoubleDigit: function (v) {
+ if(BI.isNull(v) || BI.isEmptyString(v)) {
+ v = 0;
+ }
+ var value = BI.parseInt(v);
+ if(value < 10) {
+ value = "0" + value;
+ }
+ return value;
+ },
+
+ _assertValue: function (v) {
+ v = v || {};
+ v.hour = this._formatValueToDoubleDigit(v.hour) || "00";
+ v.minute = this._formatValueToDoubleDigit(v.minute) || "00";
+ v.second = this._formatValueToDoubleDigit(v.second) || "00";
+ return v;
+ },
+
+ getValue: function () {
+ return {
+ hour: BI.parseInt(this.hour.getValue()),
+ minute: BI.parseInt(this.minute.getValue()),
+ second: BI.parseInt(this.second.getValue())
+ };
+ },
+
+ setValue: function (v) {
+ v = this._assertValue(v);
+ this.hour.setValue(v.hour);
+ this.minute.setValue(v.minute);
+ this.second.setValue(v.second);
+ this._checkBorder(v);
+ }
+
+});
+BI.DynamicDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.dynamic_date_time_select", BI.DynamicDateTimeSelect);
+
+BI.extend(BI.DynamicDateTimeSelect, {
+ HOUR: 1,
+ MINUTE: 2,
+ SECOND: 3
+});BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ yearLength: 4,
+ yearMonthLength: 6,
+ yearFullMonthLength: 7
+ },
+
+ props: {
+ extraCls: "bi-date-time-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 24
+ },
+
+ _init: function () {
+ BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.storeTriggerValue = "";
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ var date = v.match(/\d+/g);
+ self._autoAppend(v, date);
+ return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0
+ });
+ },
+ quitChecker: function () {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ errorText: function () {
+ if (self.editor.isEditing()) {
+ return BI.i18nText("BI-Basic_Date_Time_Error_Text");
+ }
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ },
+ title: function () {
+ var storeValue = self.storeValue || {};
+ var type = storeValue.type || BI.DynamicDateCombo.Static;
+ var value = storeValue.value;
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = self._getText(value);
+ var date = BI.DynamicDateHelper.getCalculation(value);
+ var dateStr = BI.print(date, "%Y-%x-%e %H:%M:%S");
+ return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ return "";
+ }
+ return BI.print(BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
+ value.second || 0), "%Y-%X-%d %H:%M:%S");
+ }
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN);
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.storeTriggerValue = self.getKey();
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_VALID, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_VALID);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_ERROR);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setState(value);
+ }
+
+ if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) {
+ var date = value.split(/-|\s|:/);
+ self.storeValue = {
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: date[0] | 0,
+ month: date[1] | 0,
+ day: date[2] | 0,
+ hour: date[3] | 0,
+ minute: date[4] | 0,
+ second: date[5] | 0
+ }
+ };
+ }
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CHANGE);
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [{
+ el: this.editor
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+ this.setValue(o.value);
+ },
+ _dateCheck: function (date) {
+ return BI.print(BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date ||
+
+ BI.print(BI.parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ },
+ _checkVoid: function (obj) {
+ return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0];
+ },
+ _autoAppend: function (v, dateObj) {
+ if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) {
+ switch (v.length) {
+ case this._const.yearLength:
+ if (this._yearCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ case this._const.yearMonthLength:
+ case this._const.yearFullMonthLength:
+ var splitMonth = v.split("-")[1];
+ if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) {
+ this.editor.setValue(v + "-");
+ }
+ break;
+ }
+ }
+ },
+
+ _yearCheck: function (v) {
+ var date = BI.print(BI.parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+ return BI.print(BI.parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
+ },
+
+ _monthCheck: function (v) {
+ var date = BI.parseDateTime(v, "%Y-%X-%d");
+ var dateStr = BI.print(date, "%Y-%X-%d");
+ return (date.getMonth() > 0 && (BI.print(BI.parseDateTime(v, "%Y-%X"), "%Y-%X") === v ||
+ BI.print(BI.parseDateTime(v, "%Y-%x"), "%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max;
+ },
+
+ _setInnerValue: function (date) {
+ var dateStr = BI.print(date, "%Y-%X-%e %H:%M:%S");
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ },
+
+ _getText: function (obj) {
+ var value = "";
+ var endText = "";
+ if(BI.isNotNull(obj.year)) {
+ if(BI.parseInt(obj.year) !== 0) {
+ value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position);
+ }
+ if(BI.isNotNull(obj.quarter)) {
+ if(BI.parseInt(obj.quarter) !== 0) {
+ value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position);
+ }
+ if(BI.isNotNull(obj.month)) {
+ if(BI.parseInt(obj.month) !== 0) {
+ value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position);
+ }
+ if(BI.isNotNull(obj.week)) {
+ if(BI.parseInt(obj.week) !== 0) {
+ value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position);
+ }
+ if(BI.isNotNull(obj.day)) {
+ if(BI.parseInt(obj.day) !== 0) {
+ value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : "";
+ }
+ if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) {
+ value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ return value + endText;
+
+ function getPositionText (baseText, position) {
+ switch (position) {
+ case BI.DynamicDateCard.OFFSET.BEGIN:
+ return baseText + BI.i18nText("BI-Basic_Begin_Start");
+ case BI.DynamicDateCard.OFFSET.END:
+ return baseText + BI.i18nText("BI-Basic_End_Stop");
+ case BI.DynamicDateCard.OFFSET.CURRENT:
+ default:
+ return BI.i18nText("BI-Basic_Current_Day");
+ }
+ }
+ },
+
+ setValue: function (v) {
+ var type, value, self = this;
+ var date = BI.getDate();
+ this.storeValue = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ date = BI.DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ if (BI.isNull(value) || BI.isNull(value.day)) {
+ this.editor.setState("");
+ this.editor.setValue("");
+ } else {
+ var dateStr = BI.print(BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0,
+ value.second || 0), "%Y-%X-%d %H:%M:%S");
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ }
+ break;
+ }
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ }
+
+});
+
+BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START";
+BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DynamicDateTimeTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicDateTimeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DynamicDateTimeTrigger.EVENT_VALID = "EVENT_VALID";
+BI.DynamicDateTimeTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.dynamic_date_time_trigger", BI.DynamicDateTimeTrigger);/**
+ * Created by roy on 15/9/14.
+ */
+BI.SearchEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.SearchEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-search-editor bi-border bi-focus-shadow",
+ height: 24,
+ errorText: "",
+ watermark: BI.i18nText("BI-Basic_Search"),
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn
+ });
+ },
+ _init: function () {
+ this.options.height -= 2;
+ BI.SearchEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ watermark: o.watermark,
+ allowBlank: true,
+ hgap: 1,
+ errorText: o.errorText,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker
+ });
+ this.clear = BI.createWidget({
+ type: "bi.icon_button",
+ stopEvent: true,
+ cls: "close-font"
+ });
+ this.clear.on(BI.IconButton.EVENT_CHANGE, function () {
+ self.setValue("");
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT);
+ // 从有内容到无内容的清空也是一次change
+ self.fireEvent(BI.SearchEditor.EVENT_CHANGE);
+ self.fireEvent(BI.SearchEditor.EVENT_CLEAR);
+ });
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: {
+ type: "bi.icon_label",
+ cls: "search-font"
+ },
+ width: 24
+ },
+ {
+ el: self.editor
+ },
+ {
+ el: this.clear,
+ width: 24
+ }
+ ]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_FOCUS);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_BLUR);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_CLICK);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self._checkClear();
+ self.fireEvent(BI.SearchEditor.EVENT_CHANGE);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.SearchEditor.EVENT_KEY_DOWN, v);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_SPACE);
+ });
+ this.editor.on(BI.Editor.EVENT_BACKSPACE, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_BACKSPACE);
+ });
+
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_VALID);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_ERROR);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_ENTER);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_RESTRICT);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self._checkClear();
+ self.fireEvent(BI.SearchEditor.EVENT_EMPTY);
+ });
+ this.editor.on(BI.Editor.EVENT_REMOVE, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_REMOVE);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_START);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.SearchEditor.EVENT_STOP);
+ });
+
+ this.clear.invisible();
+ },
+
+ _checkClear: function () {
+ if (!this.getValue()) {
+ this.clear.invisible();
+ } else {
+ this.clear.visible();
+ }
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ getValue: function () {
+ if (this.isValid()) {
+ var res = this.editor.getValue().match(/[\S]+/g);
+ return BI.isNull(res) ? "" : res[res.length - 1];
+ }
+ },
+
+ getKeywords: function () {
+ var val = this.editor.getLastValidValue();
+ var keywords = val.match(/[\S]+/g);
+ if (BI.isEndWithBlank(val)) {
+ return keywords.concat([" "]);
+ }
+ return keywords;
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ if (BI.isKey(v)) {
+ this.clear.visible();
+ }
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ }
+});
+BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SearchEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.SearchEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.SearchEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.SearchEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.SearchEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.SearchEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
+BI.SearchEditor.EVENT_CLEAR = "EVENT_CLEAR";
+
+BI.SearchEditor.EVENT_START = "EVENT_START";
+BI.SearchEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SearchEditor.EVENT_STOP = "EVENT_STOP";
+BI.SearchEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.SearchEditor.EVENT_VALID = "EVENT_VALID";
+BI.SearchEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.SearchEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.SearchEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.SearchEditor.EVENT_REMOVE = "EVENT_REMOVE";
+BI.SearchEditor.EVENT_EMPTY = "EVENT_EMPTY";
+BI.shortcut("bi.search_editor", BI.SearchEditor);/**
+ * 小号搜索框
+ * Created by GUY on 2015/9/29.
+ * @class BI.SmallSearchEditor
+ * @extends BI.SearchEditor
+ */
+BI.SmallSearchEditor = BI.inherit(BI.SearchEditor, {
+ _defaultConfig: function () {
+ var conf = BI.SmallSearchEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-small-search-editor",
+ height: 20
+ });
+ },
+
+ _init: function () {
+ BI.SmallSearchEditor.superclass._init.apply(this, arguments);
+ }
+});
+BI.shortcut("bi.small_search_editor", BI.SmallSearchEditor);/**
+ * guy
+ * @class BI.TextEditor
+ * @extends BI.Single
+ */
+BI.TextEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.TextEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-text-editor bi-border bi-focus-shadow",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: false,
+ watermark: "",
+ errorText: "",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.TextEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNumber(o.height)) {
+ this.element.css({height: o.height - 2});
+ }
+ if (BI.isNumber(o.width)) {
+ this.element.css({width: o.width - 2});
+ }
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height - 2,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ value: o.value,
+ title: o.title,
+ tipType: o.tipType,
+ validationChecker: o.validationChecker,
+ quitChecker: o.quitChecker,
+ allowBlank: o.allowBlank,
+ watermark: o.watermark,
+ errorText: o.errorText
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.Editor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.TextEditor.EVENT_FOCUS);
+ });
+ this.editor.on(BI.Editor.EVENT_BLUR, function () {
+ self.fireEvent(BI.TextEditor.EVENT_BLUR);
+ });
+ this.editor.on(BI.Editor.EVENT_CLICK, function () {
+ self.fireEvent(BI.TextEditor.EVENT_CLICK);
+ });
+ this.editor.on(BI.Editor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.TextEditor.EVENT_CHANGE);
+ });
+ this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
+ self.fireEvent(BI.TextEditor.EVENT_KEY_DOWN);
+ });
+ this.editor.on(BI.Editor.EVENT_SPACE, function (v) {
+ self.fireEvent(BI.TextEditor.EVENT_SPACE);
+ });
+ this.editor.on(BI.Editor.EVENT_BACKSPACE, function (v) {
+ self.fireEvent(BI.TextEditor.EVENT_BACKSPACE);
+ });
+
+
+ this.editor.on(BI.Editor.EVENT_VALID, function () {
+ self.fireEvent(BI.TextEditor.EVENT_VALID);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.TextEditor.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.Editor.EVENT_REMOVE, function (v) {
+ self.fireEvent(BI.TextEditor.EVENT_REMOVE);
+ });
+ this.editor.on(BI.Editor.EVENT_START, function () {
+ self.fireEvent(BI.TextEditor.EVENT_START);
+ });
+ this.editor.on(BI.Editor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.TextEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.Editor.EVENT_STOP, function () {
+ self.fireEvent(BI.TextEditor.EVENT_STOP);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self.fireEvent(BI.TextEditor.EVENT_ERROR, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ENTER, function () {
+ self.fireEvent(BI.TextEditor.EVENT_ENTER);
+ });
+ this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
+ self.fireEvent(BI.TextEditor.EVENT_RESTRICT);
+ });
+ this.editor.on(BI.Editor.EVENT_EMPTY, function () {
+ self.fireEvent(BI.TextEditor.EVENT_EMPTY);
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ }
+});
+BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.TextEditor.EVENT_FOCUS = "EVENT_FOCUS";
+BI.TextEditor.EVENT_BLUR = "EVENT_BLUR";
+BI.TextEditor.EVENT_CLICK = "EVENT_CLICK";
+BI.TextEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.TextEditor.EVENT_SPACE = "EVENT_SPACE";
+BI.TextEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE";
+
+BI.TextEditor.EVENT_START = "EVENT_START";
+BI.TextEditor.EVENT_PAUSE = "EVENT_PAUSE";
+BI.TextEditor.EVENT_STOP = "EVENT_STOP";
+BI.TextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.TextEditor.EVENT_VALID = "EVENT_VALID";
+BI.TextEditor.EVENT_ERROR = "EVENT_ERROR";
+BI.TextEditor.EVENT_ENTER = "EVENT_ENTER";
+BI.TextEditor.EVENT_RESTRICT = "EVENT_RESTRICT";
+BI.TextEditor.EVENT_REMOVE = "EVENT_REMOVE";
+BI.TextEditor.EVENT_EMPTY = "EVENT_EMPTY";
+
+BI.shortcut("bi.text_editor", BI.TextEditor);/**
+ * 小号搜索框
+ * Created by GUY on 2015/9/29.
+ * @class BI.SmallTextEditor
+ * @extends BI.SearchEditor
+ */
+BI.SmallTextEditor = BI.inherit(BI.TextEditor, {
+ _defaultConfig: function () {
+ var conf = BI.SmallTextEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-small-text-editor",
+ height: 20
+ });
+ },
+
+ _init: function () {
+ BI.SmallTextEditor.superclass._init.apply(this, arguments);
+ }
+});
+BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/**
+ * Created by zcf on 2016/9/26.
+ */
+BI.IntervalSlider = BI.inherit(BI.Single, {
+ _constant: {
+ EDITOR_WIDTH: 58,
+ EDITOR_R_GAP: 60,
+ EDITOR_HEIGHT: 30,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ props: {
+ baseCls: "bi-interval-slider bi-slider-track",
+ digit: false,
+ unit: ""
+ },
+
+ render: function () {
+
+ var self = this;
+ var c = this._constant;
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.calculation = new BI.AccurateCalculationModel();
+
+ // this.backgroundTrack = BI.createWidget({
+ // type: "bi.layout",
+ // cls: "background-track",
+ // height: c.TRACK_HEIGHT
+ // });
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 6
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 6
+ });
+ this.track = this._createTrackWrapper();
+
+ this.labelOne = BI.createWidget({
+ type: "bi.sign_text_editor",
+ cls: "slider-editor-button",
+ text: this.options.unit,
+ allowBlank: false,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelOne.element.hover(function () {
+ self.labelOne.element.removeClass("bi-border").addClass("bi-border");
+ }, function () {
+ self.labelOne.element.removeClass("bi-border");
+ });
+ this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () {
+ var oldValueOne = self.valueOne;
+ var v = BI.parseFloat(this.getValue());
+ self.valueOne = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份
+ self._setSliderOnePosition(significantPercent);
+ self._setBlueTrack();
+ self._checkLabelPosition(oldValueOne, self.valueTwo, self.valueOne, self.valueTwo);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+
+ this.labelTwo = BI.createWidget({
+ type: "bi.sign_text_editor",
+ cls: "slider-editor-button",
+ text: this.options.unit,
+ allowBlank: false,
+ width: c.EDITOR_WIDTH,
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.labelTwo.element.hover(function () {
+ self.labelTwo.element.removeClass("bi-border").addClass("bi-border");
+ }, function () {
+ self.labelTwo.element.removeClass("bi-border");
+ });
+ this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () {
+ var oldValueTwo = self.valueTwo;
+ var v = BI.parseFloat(this.getValue());
+ self.valueTwo = v;
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderTwoPosition(significantPercent);
+ self._setBlueTrack();
+ self._checkLabelPosition(self.valueOne, oldValueTwo, self.valueOne, self.valueTwo);
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ });
+
+ this.sliderOne = BI.createWidget({
+ type: "bi.single_slider_button"
+ });
+ this.sliderTwo = BI.createWidget({
+ type: "bi.single_slider_button"
+ });
+ this._draggable(this.sliderOne, true);
+ this._draggable(this.sliderTwo, false);
+ this._setVisible(false);
+
+ return {
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 23,
+ left: 0,
+ width: "100%"
+ },
+ this._createLabelWrapper(),
+ this._createSliderWrapper()
+ ]
+ };
+ },
+
+ _rePosBySizeAfterMove: function (size, isLeft) {
+ var o = this.options;
+ var percent = size * 100 / (this._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ var v = this._getValueByPercent(significantPercent);
+ v = this._assertValue(v);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ var oldValueOne = this.valueOne, oldValueTwo = this.valueTwo;
+ if(isLeft) {
+ this._setSliderOnePosition(significantPercent);
+ this.labelOne.setValue(v);
+ this.valueOne = v;
+ this._checkLabelPosition(oldValueOne, oldValueTwo, v, this.valueTwo);
+ }else{
+ this._setSliderTwoPosition(significantPercent);
+ this.labelTwo.setValue(v);
+ this.valueTwo = v;
+ this._checkLabelPosition(oldValueOne, oldValueTwo, this.valueOne, v);
+ }
+ this._setBlueTrack();
+ },
+
+ _rePosBySizeAfterStop: function (size, isLeft) {
+ var percent = size * 100 / (this._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent);
+ },
+
+ _draggable: function (widget, isLeft) {
+ var self = this, o = this.options;
+ var startDrag = false;
+ var size = 0, offset = 0, defaultSize = 0;
+ var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
+ if (mouseMoveTracker.isDragging()) {
+ startDrag = true;
+ offset += deltaX;
+ size = optimizeSize(defaultSize + offset);
+ widget.element.addClass("dragging");
+ self._rePosBySizeAfterMove(size, isLeft);
+ }
+ }, function () {
+ if (startDrag === true) {
+ size = optimizeSize(size);
+ self._rePosBySizeAfterStop(size, isLeft);
+ size = 0;
+ offset = 0;
+ defaultSize = size;
+ startDrag = false;
+ }
+ widget.element.removeClass("dragging");
+ mouseMoveTracker.releaseMouseMoves();
+ self.fireEvent(BI.IntervalSlider.EVENT_CHANGE);
+ }, window);
+ widget.element.on("mousedown", function (event) {
+ if(!widget.isEnabled()) {
+ return;
+ }
+ defaultSize = this.offsetLeft;
+ optimizeSize(defaultSize);
+ mouseMoveTracker.captureMouseMoves(event);
+ });
+
+ function optimizeSize (s) {
+ return BI.clamp(s, 0, self._getGrayTrackLength());
+ }
+ },
+
+ _createLabelWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.labelOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.labelTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ rgap: c.EDITOR_R_GAP,
+ height: c.SLIDER_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ };
+ },
+
+ _createSliderWrapper: function () {
+ var c = this._constant;
+ return {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderOne,
+ top: 0,
+ left: "0%"
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: this.sliderTwo,
+ top: 0,
+ left: "100%"
+ }]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ },
+ top: 20,
+ left: 0,
+ width: "100%"
+ };
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ });
+ },
+
+ _checkValidation: function (v) {
+ var o = this.options;
+ var valid = false;
+ // 像90.这样的既不属于整数又不属于小数,是不合法的值
+ var dotText = (v + "").split(".")[1];
+ if (BI.isEmptyString(dotText)) {
+ }else{
+ if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) {
+ if(o.digit === false) {
+ valid = true;
+ }else{
+ dotText = dotText || "";
+ valid = (dotText.length === o.digit);
+ }
+ }
+ }
+ return valid;
+ },
+
+ _checkOverlap: function () {
+ var labelOneLeft = this.labelOne.element[0].offsetLeft;
+ var labelTwoLeft = this.labelTwo.element[0].offsetLeft;
+ if (labelOneLeft <= labelTwoLeft) {
+ if ((labelTwoLeft - labelOneLeft) < 90) {
+ this.labelTwo.element.css({top: 40});
+ } else {
+ this.labelTwo.element.css({top: 0});
+ }
+ } else {
+ if ((labelOneLeft - labelTwoLeft) < 90) {
+ this.labelTwo.element.css({top: 40});
+ } else {
+ this.labelTwo.element.css({top: 0});
+ }
+ }
+ },
+
+ _checkLabelPosition: function (oldValueOne, oldValueTwo, valueOne, valueTwo, isLeft) {
+ oldValueOne = BI.parseFloat(oldValueOne);
+ oldValueTwo = BI.parseFloat(oldValueTwo);
+ valueOne = BI.parseFloat(valueOne);
+ valueTwo = BI.parseFloat(valueTwo);
+ if((oldValueOne <= oldValueTwo && valueOne > valueTwo) || (oldValueOne >= oldValueTwo && valueOne < valueTwo)) {
+ var isSliderOneLeft = BI.parseFloat(this.sliderOne.element[0].style.left) < BI.parseFloat(this.sliderTwo.element[0].style.left);
+ this.labelOne.element.css({left: isSliderOneLeft ? "0%" : "100%"});
+ this.labelTwo.element.css({left: isSliderOneLeft ? "100%" : "0%"});
+ }
+ },
+
+ _setSliderOnePosition: function (percent) {
+ this.sliderOne.element.css({left: percent + "%"});
+ },
+
+ _setSliderTwoPosition: function (percent) {
+ this.sliderTwo.element.css({left: percent + "%"});
+ },
+
+ _setBlueTrackLeft: function (percent) {
+ this.blueTrack.element.css({left: percent + "%"});
+ },
+
+ _setBlueTrackWidth: function (percent) {
+ this.blueTrack.element.css({width: percent + "%"});
+ },
+
+ _setBlueTrack: function () {
+ var percentOne = this._getPercentByValue(this.labelOne.getValue());
+ var percentTwo = this._getPercentByValue(this.labelTwo.getValue());
+ if (percentOne <= percentTwo) {
+ this._setBlueTrackLeft(percentOne);
+ this._setBlueTrackWidth(percentTwo - percentOne);
+ } else {
+ this._setBlueTrackLeft(percentTwo);
+ this._setBlueTrackWidth(percentOne - percentTwo);
+ }
+ },
+
+ _setAllPosition: function (one, two) {
+ this._setSliderOnePosition(one);
+ this._setSliderTwoPosition(two);
+ this._setBlueTrack();
+ },
+
+ _setVisible: function (visible) {
+ this.sliderOne.setVisible(visible);
+ this.sliderTwo.setVisible(visible);
+ this.labelOne.setVisible(visible);
+ this.labelTwo.setVisible(visible);
+ },
+
+ _setErrorText: function () {
+ var errorText = BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max);
+ this.labelOne.setErrorText(errorText);
+ this.labelTwo.setErrorText(errorText);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth;
+ },
+
+ // 其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度
+ _getValueByPercent: function (percent) {// return (((max-min)*percent)/100+min)
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var mul = this.calculation.accurateMultiplication(sub, percent);
+ var div = this.calculation.accurateDivisionTenExponent(mul, 2);
+ if(this.precision < 0) {
+ var value = BI.parseFloat(this.calculation.accurateAddition(div, this.min));
+ var reduceValue = Math.round(this.calculation.accurateDivisionTenExponent(value, -this.precision));
+ return this.calculation.accurateMultiplication(reduceValue, Math.pow(10, -this.precision));
+ }
+ return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision));
+
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setDraggableEnable: function (enable) {
+ this.sliderOne.setEnable(enable);
+ this.sliderTwo.setEnable(enable);
+ },
+
+ _getPrecision: function () {
+ // 计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度)
+ // 如果差值的整数位数大于4,toPrecision(4)得到的是科学计数法123456 => 1.235e+5
+ // 返回非负值: 保留的小数位数
+ // 返回负值: 保留的10^n精度中的n
+ var sub = this.calculation.accurateSubtraction(this.max, this.min);
+ var pre = sub.toPrecision(4);
+ // 科学计数法
+ var eIndex = pre.indexOf("e");
+ var arr = [];
+ if(eIndex > -1) {
+ arr = pre.split("e");
+ var decimalPartLength = BI.size(arr[0].split(".")[1]);
+ var sciencePartLength = BI.parseInt(arr[1].substring(1));
+ return decimalPartLength - sciencePartLength;
+ }
+ arr = pre.split(".");
+ return arr.length > 1 ? arr[1].length : 0;
+
+ },
+
+ _assertValue: function (value) {
+ if(value <= this.min) {
+ return this.min;
+ }
+ if(value >= this.max) {
+ return this.max;
+ }
+ return value;
+ },
+
+ _setEnable: function (b) {
+ BI.IntervalSlider.superclass._setEnable.apply(this, [b]);
+ if(b) {
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
+ } else {
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
+ }
+ },
+
+ getValue: function () {
+ if (this.valueOne <= this.valueTwo) {
+ return {min: this.valueOne, max: this.valueTwo};
+ }
+ return {min: this.valueTwo, max: this.valueOne};
+
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber )) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ this.valueOne = minNumber;
+ this.valueTwo = maxNumber;
+ this.precision = this._getPrecision();
+ this._setDraggableEnable(true);
+ }
+ if (maxNumber === minNumber) {
+ this._setDraggableEnable(false);
+ }
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ var valueOne = BI.parseFloat(v.min);
+ var valueTwo = BI.parseFloat(v.max);
+ valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit);
+ valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit);
+ if (!isNaN(valueOne) && !isNaN(valueTwo)) {
+ if (this._checkValidation(valueOne)) {
+ this.valueOne = (this.valueOne <= this.valueTwo ? valueOne : valueTwo);
+ }
+ if (this._checkValidation(valueTwo)) {
+ this.valueTwo = (this.valueOne <= this.valueTwo ? valueTwo : valueOne);
+ }
+ if (valueOne < this.min) {
+ this.valueOne = this.min;
+ }
+ if (valueTwo > this.max) {
+ this.valueTwo = this.max;
+ }
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.valueOne = "";
+ this.valueTwo = "";
+ this.min = NaN;
+ this.max = NaN;
+ this._setBlueTrackWidth(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this.enable = true;
+ this._setVisible(true);
+ this._setErrorText();
+ if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) {
+ this.labelOne.setValue(this.valueOne);
+ this.labelTwo.setValue(this.valueTwo);
+ this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo));
+ } else {
+ this.labelOne.setValue(this.min);
+ this.labelTwo.setValue(this.max);
+ this._setAllPosition(0, 100);
+ }
+ }
+ }
+});
+BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.interval_slider", BI.IntervalSlider);/**
+ * Created by zcf on 2017/3/1.
+ * 万恶的IEEE-754
+ * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数
+ */
+BI.AccurateCalculationModel = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: ""
+ });
+ },
+
+ _init: function () {
+ BI.AccurateCalculationModel.superclass._init.apply(this, arguments);
+ },
+
+ _getMagnitude: function (n) {
+ var magnitude = "1";
+ for (var i = 0; i < n; i++) {
+ magnitude += "0";
+ }
+ return BI.parseInt(magnitude);
+ },
+
+ _formatDecimal: function (stringNumber1, stringNumber2) {
+ if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) {
+ return;
+ }
+ var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength;
+ if (magnitudeDiff > 0) {
+ var needAddZero = stringNumber2;
+ } else {
+ var needAddZero = stringNumber1;
+ magnitudeDiff = (0 - magnitudeDiff);
+ }
+ for (var i = 0; i < magnitudeDiff; i++) {
+ if (needAddZero.numDecimal === "0" && i === 0) {
+ continue;
+ }
+ needAddZero.numDecimal += "0";
+ }
+ },
+
+ _stringNumberFactory: function (num) {
+ var strNum = num.toString();
+ var numStrArray = strNum.split(".");
+ var numInteger = numStrArray[0];
+ if (numStrArray.length === 1) {
+ var numDecimal = "0";
+ var numDecimalLength = 0;
+ } else {
+ var numDecimal = numStrArray[1];
+ var numDecimalLength = numStrArray[1].length;
+ }
+ return {
+ numInteger: numInteger,
+ numDecimal: numDecimal,
+ numDecimalLength: numDecimalLength
+ };
+ },
+
+ _accurateSubtraction: function (num1, num2) {// num1-num2 && num1>num2
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ // 整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger);
+ // 小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+ var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2);
+
+ if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) {
+ var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ } else {// 否则借位
+ integerResult--;
+ var borrow = this._getMagnitude(decimalMaxLength);
+ var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString();
+ var decimalResult = addZero(decimalResultTemp, decimalMaxLength);
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function getDecimalMaxLength (num1, num2) {
+ if (num1.numDecimal.length >= num2.numDecimal.length) {
+ return num1.numDecimal.length;
+ }
+ return num2.numDecimal.length;
+ }
+
+ function addZero (resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp;
+ }
+ },
+
+ _accurateAddition: function (num1, num2) {// 加法结合律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ // 整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger);
+ // 小数部分
+ this._formatDecimal(stringNumber1, stringNumber2);
+
+ var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString();
+
+ if (decimalResult !== "0") {
+ if (decimalResult.length <= stringNumber1.numDecimal.length) {
+ decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length);
+ } else {
+ integerResult++;// 进一
+ decimalResult = decimalResult.slice(1);
+ }
+ }
+ var result = integerResult + "." + decimalResult;
+ return BI.parseFloat(result);
+
+ function addZero (resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp;
+ }
+ },
+
+ _accurateMultiplication: function (num1, num2) {// 乘法分配律
+ var stringNumber1 = this._stringNumberFactory(num1);
+ var stringNumber2 = this._stringNumberFactory(num2);
+ // 整数部分计算
+ var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger);
+ // num1的小数和num2的整数
+ var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength);
+ // num1的整数和num2的小数
+ var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength);
+ // 小数*小数
+ var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength));
+
+ return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2);
+ },
+
+ _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0
+ var stringNumber = this._stringNumberFactory(num);
+ if (stringNumber.numInteger.length > n) {
+ var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n));
+ var partDecimalResult = stringNumber.numInteger.slice(-n);
+ } else {
+ var integerResult = "0";
+ var partDecimalResult = addZero(stringNumber.numInteger, n);
+ }
+ var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal;
+ return BI.parseFloat(result);
+
+ function addZero (resultTemp, length) {
+ var diff = length - resultTemp.length;
+ for (var i = 0; i < diff; i++) {
+ resultTemp = "0" + resultTemp;
+ }
+ return resultTemp;
+ }
+ },
+
+ accurateSubtraction: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(num1, num2);
+ }
+ return -this._accurateSubtraction(num2, num1);
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this._accurateAddition(num1, -num2);
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateAddition(-num1, num2);
+ }
+ if (num1 < 0 && num2 < 0) {
+ if (num1 >= num2) {
+ return this._accurateSubtraction(-num2, -num1);
+ }
+ return this._accurateSubtraction(-num1, -num2);
+ }
+ },
+
+ accurateAddition: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateAddition(num1, num2);
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return this.accurateSubtraction(num1, -num2);
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return this.accurateSubtraction(num2, -num1);
+ }
+ if (num1 < 0 && num2 < 0) {
+ return -this._accurateAddition(-num1, -num2);
+ }
+ },
+
+ accurateMultiplication: function (num1, num2) {
+ if (num1 >= 0 && num2 >= 0) {
+ return this._accurateMultiplication(num1, num2);
+ }
+ if (num1 >= 0 && num2 < 0) {
+ return -this._accurateMultiplication(num1, -num2);
+ }
+ if (num1 < 0 && num2 >= 0) {
+ return -this._accurateMultiplication(-num1, num2);
+ }
+ if (num1 < 0 && num2 < 0) {
+ return this._accurateMultiplication(-num1, -num2);
+ }
+ },
+
+ accurateDivisionTenExponent: function (num1, n) {
+ if (num1 >= 0) {
+ return this._accurateDivisionTenExponent(num1, n);
+ }
+ return -this._accurateDivisionTenExponent(-num1, n);
+ }
+});/**
+ * 月份下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.MonthCombo
+ * @extends BI.Trigger
+ */
+BI.MonthCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-combo",
+ behaviors: {},
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.month_trigger",
+ value: o.value
+ });
+
+ this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getValue());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_START, function () {
+ self.combo.hideView();
+ });
+ this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.month_popup",
+ behaviors: o.behaviors,
+ value: o.value
+ });
+ this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MonthCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ if (BI.isNull(this.popup)) {
+ return this.options.value || "";
+ } else {
+ return this.popup.getValue() || "";
+ }
+ }
+});
+
+BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.month_combo", BI.MonthCombo);/**
+ * 月份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.MonthPopup
+ * @extends BI.Trigger
+ */
+BI.MonthPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-month-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.MonthPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ // 纵向排列月
+ var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
+ var items = [];
+ items.push(month.slice(0, 2));
+ items.push(month.slice(2, 4));
+ items.push(month.slice(4, 6));
+ items.push(month.slice(6, 8));
+ items.push(month.slice(8, 10));
+ items.push(month.slice(10, 12));
+ items = BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ return {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 23,
+ width: 38,
+ value: td,
+ text: td
+ };
+ });
+ });
+
+ this.month = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({
+ dynamic: true
+ }, {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: 25
+ })), {
+ type: "bi.center_adapt",
+ vgap: 1,
+ hgap: 2
+ }],
+ value: o.value
+ });
+
+ this.month.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ });
+ },
+
+ getValue: function () {
+ return this.month.getValue()[0];
+ },
+
+ setValue: function (v) {
+ v = BI.parseInt(v);
+ this.month.setValue([v]);
+ }
+});
+BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_popup", BI.MonthPopup);/**
+ * 月份trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.MonthTrigger
+ * @extends BI.Trigger
+ */
+BI.MonthTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-month-trigger bi-border",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MonthTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: BI.i18nText("BI-Month_Trigger_Error_Text")
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.MonthTrigger.EVENT_STOP);
+ });
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Month"),
+ baseCls: "bi-trigger-month-text",
+ width: o.height
+ },
+ width: o.height
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.height
+ },
+ width: o.height
+ }
+ ]
+ });
+ this.setValue(o.value);
+ },
+ setValue: function (v) {
+ if(BI.isNotNull(v)) {
+ this.editor.setState(v + 1);
+ this.editor.setValue(v + 1);
+ this.editor.setTitle(v + 1);
+ return;
+ }
+ this.editor.setState("");
+ this.editor.setValue("");
+ this.editor.setTitle("");
+ },
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ },
+ getValue: function () {
+ return this.editor.getValue() - 1;
+ }
+});
+BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.MonthTrigger.EVENT_START = "EVENT_START";
+BI.MonthTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.month_trigger", BI.MonthTrigger);/**
+ * Created by roy on 15/8/14.
+ */
+BI.DownListCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-down-list-combo",
+ height: 24,
+ items: [],
+ adjustLength: 0,
+ direction: "bottom",
+ trigger: "click",
+ container: null,
+ stopPropagation: false,
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.DownListCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popupview = BI.createWidget({
+ type: "bi.multi_layer_down_list_popup",
+ items: o.items,
+ chooseType: o.chooseType,
+ value: o.value
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) {
+ self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value);
+ self.downlistcombo.hideView();
+ });
+
+ this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) {
+ self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue);
+ self.downlistcombo.hideView();
+ });
+
+
+ this.downlistcombo = BI.createWidget({
+ element: this,
+ type: "bi.combo",
+ trigger: o.trigger,
+ isNeedAdjustWidth: false,
+ container: o.container,
+ adjustLength: o.adjustLength,
+ direction: o.direction,
+ stopPropagation: o.stopPropagation,
+ el: BI.createWidget(o.el, {
+ type: "bi.icon_trigger",
+ extraCls: o.iconCls ? o.iconCls : "pull-down-font",
+ width: o.width,
+ height: o.height
+ }),
+ popup: {
+ el: this.popupview,
+ stopPropagation: true,
+ maxHeight: 1000
+ }
+ });
+
+ this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ hideView: function () {
+ this.downlistcombo.hideView();
+ },
+
+ showView: function (e) {
+ this.downlistcombo.showView(e);
+ },
+
+ populate: function (items) {
+ this.popupview.populate(items);
+ },
+
+ setValue: function (v) {
+ this.popupview.setValue(v);
+ },
+ getValue: function () {
+ return this.popupview.getValue();
+ }
+});
+BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+
+BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/**
+ * Created by roy on 15/9/8.
+ * 处理popup中的item分组样式
+ * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项
+ */
+BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, {
+ constants: {
+ nextIcon: "pull-right-e-font",
+ height: 25,
+ iconHeight: 12,
+ iconWidth: 12,
+ hgap: 0,
+ vgap: 0,
+ border: 1
+ },
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-down-list-popup",
+ items: [],
+ chooseType: BI.Selection.Multi
+ });
+ },
+ _init: function () {
+ BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments);
+ this.singleValues = [];
+ this.childValueMap = {};
+ this.fatherValueMap = {};
+ var self = this, o = this.options, children = this._createPopupItems(o.items);
+ this.popup = BI.createWidget({
+ type: "bi.button_tree",
+ items: BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ ),
+ layouts: [{
+ type: "bi.vertical",
+ hgap: this.constants.hgap,
+ vgap: this.constants.vgap
+ }],
+ value: this._digest(o.value),
+ chooseType: o.chooseType
+ });
+
+ this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) {
+ var changedValue = value;
+ if (BI.isNotNull(self.childValueMap[value])) {
+ changedValue = self.childValueMap[value];
+ var fatherValue = self.fatherValueMap[value];
+ var fatherArrayValue = (fatherValue + "").split("_");
+ self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue);
+ } else {
+ self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object);
+ }
+
+
+ if (!BI.contains(self.singleValues, changedValue)) {
+ var item = self.getValue();
+ var result = [];
+ BI.each(item, function (i, valueObject) {
+ if (valueObject.value != changedValue) {
+ result.push(valueObject);
+ }
+ });
+ self.setValue(result);
+ }
+
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.popup],
+ vgap: 5
+ });
+
+ },
+ _createPopupItems: function (items) {
+ var self = this, result = [];
+ BI.each(items, function (i, it) {
+ var item_done = {
+ type: "bi.down_list_group",
+ items: []
+ };
+
+ BI.each(it, function (i, item) {
+ if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) {
+ item.type = "bi.combo_group";
+ item.cls = "down-list-group";
+ item.trigger = "hover";
+ item.isNeedAdjustWidth = false;
+ item.el.title = item.el.title || item.el.text;
+ item.el.type = "bi.down_list_group_item";
+ item.el.logic = {
+ dynamic: true
+ };
+ item.el.height = self.constants.height;
+ item.el.iconCls2 = self.constants.nextIcon;
+ item.popup = {
+ lgap: 1,
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+
+ },
+ innerVGap: 5
+ };
+ item.el.childValues = [];
+ BI.each(item.children, function (i, child) {
+ child = child.el ? BI.extend(child.el, {children: child.children}) : child;
+ var fatherValue = BI.deepClone(item.el.value);
+ var childValue = BI.deepClone(child.value);
+ self.singleValues.push(child.value);
+ child.type = "bi.down_list_item";
+ child.extraCls = " child-down-list-item";
+ child.title = child.title || child.text;
+ child.textRgap = 10;
+ child.isNeedAdjustWidth = false;
+ child.logic = {
+ dynamic: true
+ };
+ child.father = fatherValue;
+ self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
+ self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
+ child.value = self._createChildValue(fatherValue, childValue);
+ item.el.childValues.push(child.value);
+ if (BI.isNotEmptyArray(child.children)) {
+ child.type = "bi.down_list_group_item";
+ self._createChildren(child);
+ child.height = self.constants.height;
+ child.iconCls2 = self.constants.nextIcon;
+ item.el.childValues = BI.concat(item.el.childValues, child.childValues);
+ }
+ });
+ } else {
+ item.type = "bi.down_list_item";
+ item.title = item.title || item.text;
+ item.textRgap = 10;
+ item.isNeedAdjustWidth = false;
+ item.logic = {
+ dynamic: true
+ };
+ }
+ var el_done = {};
+ el_done.el = item;
+ item_done.items.push(el_done);
+ });
+ if (self._isGroup(item_done.items)) {
+ BI.each(item_done.items, function (i, item) {
+ self.singleValues.push(item.el.value);
+ });
+ }
+
+ result.push(item_done);
+ if (self._needSpliter(i, items.length)) {
+ var spliter_container = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ el: {
+ type: "bi.layout",
+ cls: "bi-down-list-spliter bi-border-top cursor-pointer",
+ height: 0
+ }
+
+ }],
+ cls: "bi-down-list-spliter-container cursor-pointer",
+ lgap: 10,
+ rgap: 0
+ });
+ result.push(spliter_container);
+ }
+ });
+ return result;
+ },
+
+ _createChildren: function (child) {
+ var self = this;
+ child.childValues = [];
+ BI.each(child.children, function (i, c) {
+ var fatherValue = BI.deepClone(child.value);
+ var childValue = BI.deepClone(c.value);
+ c.type = "bi.down_list_item";
+ c.title = c.title || c.text;
+ c.textRgap = 10;
+ c.isNeedAdjustWidth = false;
+ c.logic = {
+ dynamic: true
+ };
+ c.father = fatherValue;
+ self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue;
+ self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue;
+ c.value = self._createChildValue(fatherValue, childValue);
+ child.childValues.push(c.value);
+ });
+ },
+
+ _isGroup: function (i) {
+ return i.length > 1;
+ },
+
+ _needSpliter: function (i, itemLength) {
+ return i < itemLength - 1;
+ },
+
+ _createChildValue: function (fatherValue, childValue) {
+ var fValue = fatherValue;
+ if(BI.isArray(fatherValue)) {
+ fValue = fatherValue.join("_");
+ }
+ return fValue + "_" + childValue;
+ },
+
+ _digest: function (valueItem) {
+ var self = this;
+ var valueArray = [];
+ BI.each(valueItem, function (i, item) {
+ var value;
+ if (BI.isNotNull(item.childValue)) {
+ value = self._createChildValue(item.value, item.childValue);
+ } else {
+ value = item.value;
+ }
+ valueArray.push(value);
+ }
+ );
+ return valueArray;
+ },
+
+ _checkValues: function (values) {
+ var self = this, o = this.options;
+ var value = [];
+ BI.each(o.items, function (idx, itemGroup) {
+ BI.each(itemGroup, function (id, item) {
+ if(BI.isNotNull(item.children)) {
+ var childValues = getChildrenValue(item);
+ var v = joinValue(childValues, values[idx]);
+ if(BI.isNotEmptyString(v)) {
+ value.push(v);
+ }
+ }else{
+ if(item.value === values[idx][0]) {
+ value.push(values[idx][0]);
+ }
+ }
+ });
+ });
+ return value;
+
+ function joinValue (sources, targets) {
+ var value = "";
+ BI.some(sources, function (idx, s) {
+ return BI.some(targets, function (id, t) {
+ if(s === t) {
+ value = s;
+ return true;
+ }
+ });
+ });
+ return value;
+ }
+
+ function getChildrenValue (item) {
+ var children = [];
+ if(BI.isNotNull(item.children)) {
+ BI.each(item.children, function (idx, child) {
+ children = BI.concat(children, getChildrenValue(child));
+ });
+ } else {
+ children.push(item.value);
+ }
+ return children;
+ }
+ },
+
+ populate: function (items) {
+ BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments);
+ var self = this;
+ self.childValueMap = {};
+ self.fatherValueMap = {};
+ self.singleValues = [];
+ var children = self._createPopupItems(items);
+ var popupItem = BI.createItems(children,
+ {}, {
+ adjustLength: -2
+ }
+ );
+ self.popup.populate(popupItem);
+ },
+
+ setValue: function (valueItem) {
+ this.popup.setValue(this._digest(valueItem));
+ },
+
+ _getValue: function () {
+ var v = [];
+ BI.each(this.popup.getAllButtons(), function (i, item) {
+ i % 2 === 0 && v.push(item.getValue());
+ });
+ return v;
+ },
+
+ getValue: function () {
+ var self = this, result = [];
+ var values = this._checkValues(this._getValue());
+ BI.each(values, function (i, value) {
+ var valueItem = {};
+ if (BI.isNotNull(self.childValueMap[value])) {
+ var fartherValue = self.fatherValueMap[value];
+ valueItem.childValue = self.childValueMap[value];
+ var fatherArrayValue = (fartherValue + "").split("_");
+ valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue;
+ } else {
+ valueItem.value = value;
+ }
+ result.push(valueItem);
+ });
+ return result;
+ }
+
+
+});
+
+BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
+BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/**
+ * @class BI.MultiLayerSelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer_select_tree-combo",
+ isDefaultInit: false,
+ height: 24,
+ text: "",
+ items: [],
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items,
+ value: o.value
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_select_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ value: o.value
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSelectLevelTree
+ * @extends BI.Select
+ */
+BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn,
+ value: "",
+ scrollable: true
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer, pNode) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ extend.pNode = pNode;
+ if (node.isParent === true || node.parent === true || BI.isNotEmptyArray(node.children)) {
+ extend.type = "bi.multilayer_select_tree_mid_plus_group_node";
+ if (i === nodes.length - 1) {
+ extend.type = "bi.multilayer_select_tree_last_plus_group_node";
+ extend.isLastNode = true;
+ }
+ if (i === 0 && !pNode) {
+ extend.type = "bi.multilayer_select_tree_first_plus_group_node";
+ }
+ if (i === 0 && i === nodes.length - 1 && !pNode) { // 根
+ extend.type = "bi.multilayer_select_tree_plus_group_node";
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children, layer + 1, node);
+ } else {
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ if (i === 0 && !pNode) {
+ extend.type = "bi.multilayer_single_tree_first_tree_leaf_item";
+ }
+ if (i === nodes.length - 1) {
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ // 构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ cls: "tree-view display-table",
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ itemsCreator: o.itemsCreator,
+ value: o.value,
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: BI.Selection.Single,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: this,
+ scrollable: o.scrollable,
+ items: [this.tree]
+ });
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return BI.uniq(this.tree.getValue());
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-select-tree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: [],
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: "bi.multilayer_select_level_tree",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ value: o.value,
+ itemsCreator: o.itemsCreator,
+ scrollable: null
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ vgap: 5,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_first_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_last_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_mid_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSelectTreePlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSelectTreePlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSelectTreePlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSelectTreePlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = BI.createWidget({
+ type: "bi.select_tree_plus_group_node",
+ cls: "bi-list-item-none",
+ stopPropagation: true,
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py
+ });
+ this.node.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.setSelected(self.isSelected());
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ isSelected: function () {
+ return this.node.isSelected();
+ },
+
+ setSelected: function (b) {
+ BI.MultiLayerSelectTreePlusGroupNode.superclass.setSelected.apply(this, arguments);
+ this.node.setSelected(b);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSelectTreePlusGroupNode.superclass.setOpened.apply(this, arguments);
+ this.node.setOpened(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_select_tree_plus_group_node", BI.MultiLayerSelectTreePlusGroupNode);/**
+ * 多层级下拉单选树
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-combo",
+ isDefaultInit: false,
+ height: 24,
+ text: "",
+ itemsCreator: BI.emptyFn,
+ items: [],
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items,
+ value: o.value
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.multilayer_single_tree_popup",
+ isDefaultInit: o.isDefaultInit,
+ itemsCreator: o.itemsCreator,
+ items: o.items,
+ value: o.value
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
+ * guy
+ * 二级树
+ * @class BI.MultiLayerSingleLevelTree
+ * @extends BI.Single
+ */
+BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-single-level-tree",
+ isDefaultInit: false,
+ items: [],
+ itemsCreator: BI.emptyFn,
+ chooseType: BI.Selection.Single,
+ scrollable: true
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments);
+
+ this.initTree(this.options.items);
+ },
+
+ _formatItems: function (nodes, layer, pNode) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {};
+ node.layer = layer;
+ if (!BI.isKey(node.id)) {
+ node.id = BI.UUID();
+ }
+ extend.pNode = pNode;
+ if (node.isParent === true || node.parent === true || BI.isNotEmptyArray(node.children)) {
+ extend.type = "bi.multilayer_single_tree_mid_plus_group_node";
+ if (i === nodes.length - 1) {
+ extend.type = "bi.multilayer_single_tree_last_plus_group_node";
+ extend.isLastNode = true;
+ }
+ if (i === 0 && !pNode) {
+ extend.type = "bi.multilayer_single_tree_first_plus_group_node";
+ }
+ if (i === 0 && i === nodes.length - 1 && !pNode) { // 根
+ extend.type = "bi.multilayer_single_tree_plus_group_node";
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children, layer + 1, node);
+ } else {
+ extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item";
+ if (i === 0 && !pNode) {
+ extend.type = "bi.multilayer_single_tree_first_tree_leaf_item"
+ }
+ if (i === nodes.length - 1) {
+ extend.type = "bi.multilayer_single_tree_last_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _assertId: function (sNodes) {
+ BI.each(sNodes, function (i, node) {
+ node.id = node.id || BI.UUID();
+ });
+ },
+
+ // 构造树结构,
+ initTree: function (nodes) {
+ var self = this, o = this.options;
+ this.empty();
+ this._assertId(nodes);
+ this.tree = BI.createWidget({
+ type: "bi.custom_tree",
+ cls: "tree-view display-table",
+ expander: {
+ isDefaultInit: o.isDefaultInit,
+ el: {},
+ popup: {
+ type: "bi.custom_tree"
+ }
+ },
+
+ items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0),
+ value: o.value,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (items) {
+ callback(BI.Tree.transformToTreeFormat(items), 0);
+ });
+ },
+
+ el: {
+ type: "bi.button_tree",
+ chooseType: o.chooseType,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: this,
+ scrollable: o.scrollable,
+ items: [this.tree]
+ });
+ },
+
+ populate: function (nodes) {
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0));
+ },
+
+ setValue: function (v) {
+ this.tree.setValue(v);
+ },
+
+ getValue: function () {
+ return BI.filter(BI.uniq(this.tree.getValue()), function (idx, value) {
+ return BI.isNotNull(value);
+ });
+
+ },
+
+ getAllLeaves: function () {
+ return this.tree.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ return this.tree.getNodeById(id);
+ },
+
+ getNodeByValue: function (id) {
+ return this.tree.getNodeByValue(id);
+ }
+});
+BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree);
+/**
+ * Created by GUY on 2016/1/26.
+ *
+ * @class BI.MultiLayerSingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multilayer-singletree-popup",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ isDefaultInit: false,
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: "bi.multilayer_single_level_tree",
+ isDefaultInit: o.isDefaultInit,
+ items: o.items,
+ itemsCreator: o.itemsCreator,
+ value: o.value,
+ scrollable: null
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ scrollable: true,
+ element: this,
+ vgap: 5,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = this._createNode();
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ },
+
+ _createNode: function () {
+ var self = this, o = this.options;
+
+ return BI.createWidget({
+ type: "bi.first_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ isLastNode: o.isLastNode,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword,
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ }
+ }]
+ });
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = this._createNode();
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ },
+
+ _createNode: function () {
+ var self = this, o = this.options;
+
+ return BI.createWidget({
+ type: "bi.last_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword,
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ }
+ }]
+ });
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = this._createNode();
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ },
+
+ _createNode: function () {
+ var self = this, o = this.options;
+
+ return BI.createWidget({
+ type: "bi.mid_plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword,
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ }
+ }]
+ });
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/**
+ *@desc 根节点,既是第一个又是最后一个
+ *@author dailer
+ *@date 2018/09/16
+ */
+BI.MultiLayerSingleTreePlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.MultiLayerSingleTreePlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-multilayer-single-tree-plus-group-node bi-list-item",
+ layer: 0, // 第几层级
+ id: "",
+ pId: "",
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreePlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.node = this._createNode();
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.node);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doRedMark: function () {
+ this.node.doRedMark.apply(this.node, arguments);
+ },
+
+ unRedMark: function () {
+ this.node.unRedMark.apply(this.node, arguments);
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreePlusGroupNode.superclass.doClick.apply(this, arguments);
+ this.node.setSelected(this.isSelected());
+ },
+
+ setOpened: function (v) {
+ BI.MultiLayerSingleTreePlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.node)) {
+ this.node.setOpened(v);
+ }
+ },
+
+ _createNode: function () {
+ var self = this, o = this.options;
+
+ return BI.createWidget({
+ type: "bi.plus_group_node",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ open: o.open,
+ isLastNode: o.isLastNode,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword,
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ }
+ }]
+ });
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_plus_group_node", BI.MultiLayerSingleTreePlusGroupNode);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeFirstTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.first_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeLastTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.last_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/**
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.MultiLayerSingleTreeMidTreeLeafItem
+ * @extends BI.BasicButton
+ */
+BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ layer: 0,
+ id: "",
+ pId: "",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.item = BI.createWidget({
+ type: "bi.mid_tree_leaf_item",
+ cls: "bi-list-item-none",
+ logic: {
+ dynamic: true
+ },
+ id: o.id,
+ pId: o.pId,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ this.item.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {// 本身实现click功能
+ return;
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ var needBlankLayers = [];
+ var pNode = o.pNode;
+ while (pNode) {
+ if (pNode.isLastNode) {
+ needBlankLayers.push(pNode.layer)
+ }
+ pNode = pNode.pNode;
+ }
+
+ var items = [];
+ BI.count(0, o.layer, function (index) {
+ items.push({
+ type: "bi.layout",
+ cls: BI.contains(needBlankLayers, index) ? "" : "base-line-conn-background",
+ width: 12,
+ height: o.height
+ });
+ });
+ items.push(this.item);
+ BI.createWidget({
+ type: "bi.td",
+ element: this,
+ columnSize: BI.makeArray(o.layer, 12),
+ items: [items]
+ });
+ },
+
+ doHighLight: function () {
+ this.item.doHighLight.apply(this.item, arguments);
+ },
+
+ unHighLight: function () {
+ this.item.unHighLight.apply(this.item, arguments);
+ },
+
+ getId: function () {
+ return this.options.id;
+ },
+
+ getPId: function () {
+ return this.options.pId;
+ },
+
+ doClick: function () {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments);
+ this.item.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments);
+ this.item.setSelected(v);
+ }
+});
+
+BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/**
+ *
+ * @class BI.MultiSelectCheckPane
+ * @extends BI.Widget
+ */
+BI.MultiSelectCheckPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 12,
+ lgap: 10,
+ tgap: 10,
+ bgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-check-pane bi-background",
+ items: [],
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.storeValue = opts.value || {};
+ this.display = BI.createWidget({
+ type: "bi.display_selected_list",
+ items: opts.items,
+ itemsCreator: function (op, callback) {
+ op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ });
+ if (self.storeValue.type === BI.Selection.Multi) {
+ callback({
+ items: BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt
+ };
+ })
+ });
+ return;
+ }
+ opts.itemsCreator(op, callback);
+ }
+ });
+
+ this.continueSelect = BI.createWidget({
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Continue_Select"),
+ cls: "multi-select-check-selected bi-high-light"
+ });
+
+ this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: {
+ type: "bi.vertical_adapt",
+ cls: "multi-select-continue-select",
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText("BI-Selected_Data")
+ },
+ lgap: this.constants.lgap
+ },
+ {
+ el: this.continueSelect,
+ lgap: this.constants.lgap
+ }]
+ },
+ tgap: this.constants.tgap
+ }, {
+ height: "fill",
+ el: this.display,
+ tgap: this.constants.bgap
+ }]
+ });
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function () {
+ this.display.populate.apply(this.display, arguments);
+ }
+});
+
+BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/**
+ *
+ *
+ * 查看已选弹出层的展示面板
+ * @class BI.DisplaySelectedList
+ * @extends BI.Widget
+ */
+BI.DisplaySelectedList = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 24,
+ lgap: 10
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-display-list",
+ itemsCreator: BI.emptyFn,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.DisplaySelectedList.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.list_pane",
+ element: this,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ items: this._createItems(opts.items),
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ layouts: [{
+ type: "bi.vertical",
+ lgap: 10
+ }]
+ },
+ itemsCreator: function (options, callback) {
+
+ opts.itemsCreator(options, function (ob) {
+ self.hasNext = !!ob.hasNext;
+ callback(self._createItems(ob.items));
+ });
+ },
+ hasNext: function () {
+ return self.hasNext;
+ }
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.icon_text_item",
+ cls: "cursor-default check-font icon-size-12 display-list-item bi-tips",
+ once: true,
+ invalid: true,
+ selected: true,
+ height: this.constants.height,
+ logic: {
+ dynamic: true
+ }
+ });
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ if (arguments.length === 0) {
+ this.button_group.populate();
+ } else {
+ this.button_group.populate(this._createItems(items));
+ }
+ }
+});
+
+BI.shortcut("bi.display_selected_list", BI.DisplaySelectedList);/**
+ *
+ * @class BI.MultiSelectCombo
+ * @extends BI.Single
+ */
+BI.MultiSelectCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-combo",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = o.value || {};
+
+ this._assertValue(this.storeValue);
+
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ text: o.text,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 25
+ }
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(BI.deepClone(self.getValue()));
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ value: this.storeValue
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ var keyword = this.getSearcher().getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue("");
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ container: o.container,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.multi_select_popup_view",
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ value: o.value,
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ BI.remove(self.storeValue.assist, item);
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ });
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+
+ }
+
+ function adjust () {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ };
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ };
+ }
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ BI.remove(self.storeValue.assist, v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ populate: function () {
+ this._count = null;
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectCombo, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.multi_select_combo", BI.MultiSelectCombo);/**
+ *
+ * @class BI.MultiSelectInsertCombo
+ * @extends BI.Single
+ */
+BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-insert-combo",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectInsertCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = o.value || {};
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_insert_trigger",
+ height: o.height,
+ text: o.text,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 25
+ }
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(BI.deepClone(self.getValue()));
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ value: o.value
+ });
+
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ self._addItem(assertShowValue);
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
+ if (!this.getSearcher().hasMatched()) {
+ self._addItem(assertShowValue);
+ self.trigger.stopEditing();
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ container: o.container,
+ popup: {
+ type: "bi.multi_select_popup_view",
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ value: o.value,
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _addItem: function (assertShowValue) {
+ var self = this;
+ var keyword = this.trigger.getSearcher().getKeyword();
+ this._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ // 如果在不选的状态下直接把该值添加进来
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue("");
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ BI.remove(self.storeValue.assist, item);
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ });
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ adjust();
+ callback();
+ function adjust () {
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ // value更新的时候assist也需要更新
+ BI.remove(self.storeValue.assist, v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectInsertCombo, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.multi_select_insert_combo", BI.MultiSelectInsertCombo);/**
+ *
+ * @class BI.MultiSelectInsertCombo
+ * @extends BI.Single
+ */
+BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertNoBarCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-insert-combo",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectInsertNoBarCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = {
+ type: BI.Selection.Multi,
+ value: o.value || []
+ };
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_insert_trigger",
+ height: o.height,
+ text: o.text,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 25
+ }
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue({
+ type: BI.Selection.Multi,
+ value: self.getValue()
+ });
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ value: {
+ type: BI.Selection.Multi,
+ value: o.value
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ self._addItem(assertShowValue);
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
+ if (!this.getSearcher().hasMatched()) {
+ self._addItem(assertShowValue);
+ self.trigger.stopEditing();
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ container: o.container,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.multi_select_no_bar_popup_view",
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ value: {
+ type: BI.Selection.Multi,
+ value: o.value
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _addItem: function (assertShowValue) {
+ var self = this;
+ var keyword = this.trigger.getSearcher().getKeyword();
+ this._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ // 如果在不选的状态下直接把该值添加进来
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue("");
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ BI.remove(self.storeValue.assist, item);
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ });
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ adjust();
+ callback();
+ function adjust () {
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ BI.remove(self.storeValue.assist, v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = {
+ type: BI.Selection.Multi,
+ value: v || []
+ };
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue.value);
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectInsertNoBarCombo, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.multi_select_insert_no_bar_combo", BI.MultiSelectInsertNoBarCombo);/**
+ *
+ * 复选下拉框
+ * @class BI.MultiSelectInsertTrigger
+ * @extends BI.Trigger
+ */
+
+BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-trigger bi-border",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectInsertTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.multi_select_insert_searcher",
+ height: o.height,
+ text: o.text,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM);
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_CHANGE, arguments);
+ });
+ this.numberCounter = BI.createWidget(o.switcher, {
+ type: "bi.multi_select_check_selected_switcher",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK);
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ });
+
+ var wrapNumberCounter = BI.createWidget({
+ type: "bi.right_vertical_adapt",
+ hgap: 4,
+ items: [{
+ el: this.numberCounter
+ }]
+ });
+
+ var wrapper = BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: "fill"
+ }, {
+ el: wrapNumberCounter,
+ width: 0
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+
+ this.numberCounter.on(BI.Events.VIEW, function (b) {
+ BI.nextTick(function () {// 自动调整宽度
+ wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ wrapper.resize();
+ });
+ });
+
+ this.element.click(function (e) {
+ if (self.element.find(e.target).length > 0) {
+ self.numberCounter.hideView();
+ }
+ });
+ },
+
+ getCounter: function () {
+ return this.numberCounter;
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ this.numberCounter.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ this.numberCounter.setAdapter(adapter);
+ },
+
+ setValue: function (ob) {
+ this.searcher.setValue(ob);
+ this.numberCounter.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.MultiSelectInsertTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.MultiSelectInsertTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectInsertTrigger.EVENT_START = "EVENT_START";
+BI.MultiSelectInsertTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectInsertTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectInsertTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
+
+BI.shortcut("bi.multi_select_insert_trigger", BI.MultiSelectInsertTrigger);/**
+ * 多选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.MultiSelectLoader
+ * @extends Widget
+ */
+BI.MultiSelectLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-loader",
+ logic: {
+ dynamic: true
+ },
+ el: {
+ height: 400
+ },
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.storeValue = opts.value || {};
+ this._assertValue(this.storeValue);
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ logic: opts.logic,
+ toolbar: {
+ type: "bi.multi_select_bar",
+ cls: "bi-list-item-active",
+ iconWrapperWidth: 36
+ },
+ el: BI.extend({
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ }, opts.el),
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
+ ? self.storeValue.value.concat(startValue) : self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === BI.Selection.Multi
+ };
+ });
+ if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
+ var txt = opts.valueFormatter(startValue) || startValue;
+ json.unshift({
+ text: txt,
+ value: startValue,
+ title: txt,
+ selected: true
+ });
+ }
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue));
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ },
+ value: this.storeValue
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({
+ scrolly: true,
+ vgap: 5
+ }, opts.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group)
+ }))));
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: this.options.logic,
+ cls: "bi-list-item-active",
+ height: 24,
+ selected: this.isAllSelected(),
+ iconWrapperWidth: 36
+ });
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ arguments[0] = this._createItems(items);
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h - 10);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader);/**
+ * 多选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.MultiSelectNoBarLoader
+ * @extends Widget
+ */
+BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectNoBarLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-loader",
+ logic: {
+ dynamic: true
+ },
+ el: {
+ height: 400
+ },
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectNoBarLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.storeValue = opts.value || {};
+ this._assertValue(this.storeValue);
+
+ this.button_group = BI.createWidget(BI.extend({
+ type: "bi.list_pane",
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ },
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
+ ? self.storeValue.value.concat(startValue) : self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === BI.Selection.Multi
+ };
+ });
+ if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
+ var txt = opts.valueFormatter(startValue) || startValue;
+ json.unshift({
+ text: txt,
+ value: startValue,
+ title: txt,
+ selected: true
+ });
+ }
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue));
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ },
+ value: this.storeValue
+ }, opts.el));
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.button_group],
+ vgap: 5
+ });
+
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectNoBarLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ cls: "bi-list-item-active",
+ logic: this.options.logic,
+ height: 24,
+ iconWrapperWidth: 36
+ });
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue.value);
+ },
+
+ getValue: function () {
+ return {
+ type: BI.Selection.Multi,
+ value: this.button_group.getValue()
+ };
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ arguments[0] = this._createItems(items);
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.element.css({"max-height": h + "px"});
+ },
+
+ resetWidth: function () {
+
+ }
+});
+
+BI.MultiSelectNoBarLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_select_no_bar_loader", BI.MultiSelectNoBarLoader);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiSelectPopupView
+ * @extends Widget
+ */
+BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-popup-view",
+ maxWidth: "auto",
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_loader",
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded,
+ value: opts.value
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")],
+ el: this.loader,
+ value: opts.value
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE);
+ });
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+
+BI.shortcut("bi.multi_select_popup_view", BI.MultiSelectPopupView);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiSelectPopupView
+ * @extends Widget
+ */
+BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectNoBarPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-popup-view",
+ maxWidth: "auto",
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectNoBarPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_no_bar_loader",
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded,
+ value: opts.value
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")],
+ el: this.loader,
+ value: opts.value
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CHANGE);
+ });
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiSelectNoBarPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+
+BI.shortcut("bi.multi_select_no_bar_popup_view", BI.MultiSelectNoBarPopupView);/**
+ *
+ * 复选下拉框
+ * @class BI.MultiSelectTrigger
+ * @extends BI.Trigger
+ */
+
+BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-trigger bi-border",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.multi_select_searcher",
+ height: o.height,
+ text: o.text,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments);
+ });
+ this.numberCounter = BI.createWidget(o.switcher, {
+ type: "bi.multi_select_check_selected_switcher",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ });
+
+ var wrapNumberCounter = BI.createWidget({
+ type: "bi.right_vertical_adapt",
+ hgap: 4,
+ items: [{
+ el: this.numberCounter
+ }]
+ });
+
+ var wrapper = BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: "fill"
+ }, {
+ el: wrapNumberCounter,
+ width: 0
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+
+ this.numberCounter.on(BI.Events.VIEW, function (b) {
+ BI.nextTick(function () {// 自动调整宽度
+ wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ wrapper.resize();
+ });
+ });
+
+ this.element.click(function (e) {
+ if (self.element.find(e.target).length > 0) {
+ self.numberCounter.hideView();
+ }
+ });
+ },
+
+ getCounter: function () {
+ return this.numberCounter;
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ this.numberCounter.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ this.numberCounter.setAdapter(adapter);
+ },
+
+ setValue: function (ob) {
+ this.searcher.setValue(ob);
+ this.numberCounter.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectTrigger.EVENT_START = "EVENT_START";
+BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+BI.shortcut("bi.multi_select_trigger", BI.MultiSelectTrigger);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiSelectSearchInsertPane
+ * @extends Widget
+ */
+
+BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 24,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchInsertPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchInsertPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.tooltipClick = BI.createWidget({
+ type: "bi.label",
+ invisible: true,
+ text: BI.i18nText("BI-Click_Blank_To_Select"),
+ cls: "multi-select-toolbar",
+ height: this.constants.height
+ });
+
+ this.addNotMatchTip = BI.createWidget({
+ type: "bi.text_button",
+ invisible: true,
+ text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
+ height: this.constants.height,
+ cls: "bi-high-light",
+ hgap: 5,
+ handler: function () {
+ self.fireEvent(BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, o.keywordGetter());
+ }
+ });
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_search_loader",
+ keywordGetter: o.keywordGetter,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(self, [op, function (res) {
+ callback(res);
+ self.setKeyword(o.keywordGetter());
+ }]);
+ },
+ value: o.value
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.resizer = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ type: "bi.vertical",
+ items: [this.tooltipClick, this.addNotMatchTip],
+ height: this.constants.height
+ }, {
+ el: this.loader
+ }]
+ });
+ },
+
+ setKeyword: function (keyword) {
+ var btn;
+ var isMatchTipVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
+ this.tooltipClick.setVisible(isMatchTipVisible);
+ this.addNotMatchTip.setVisible(!isMatchTipVisible);
+ !isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ hasMatched: function () {
+ return this.tooltipClick.isVisible();
+ },
+
+ setValue: function (v) {
+ this.loader.setValue(v);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ populate: function (items) {
+ this.loader.populate.apply(this.loader, arguments);
+ }
+});
+
+BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
+
+BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);/**
+ * 多选加载数据搜索loader面板
+ * Created by guy on 15/11/4.
+ * @class BI.MultiSelectSearchLoader
+ * @extends Widget
+ */
+BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-search-loader",
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+ this.storeValue = BI.deepClone(opts.value);
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ toolbar: {
+ type: "bi.multi_select_bar",
+ cls: "bi-list-item-active",
+ iconWrapperWidth: 36
+ },
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ value: opts.value,
+ el: {
+ tipText: BI.i18nText("BI-No_Select"),
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ },
+ itemsCreator: function (op, callback) {
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ var keyword = ob.keyword = opts.keywordGetter();
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = self._filterValues(self.storeValue);
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), keyword);
+ if (op.times === 1 && self.storeValue) {
+ self.setValue(self.storeValue);
+ }
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: {
+ dynamic: false
+ },
+ height: 24,
+ selected: this.isAllSelected(),
+ cls: "bi-list-item-active",
+ iconWrapperWidth: 36
+ });
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _filterValues: function (src) {
+ var o = this.options;
+ var keyword = o.keywordGetter();
+ var values = BI.deepClone(src.value) || [];
+ var newValues = BI.map(values, function (i, v) {
+ return {
+ text: o.valueFormatter(v) || v,
+ value: v
+ };
+ });
+ if (BI.isKey(keyword)) {
+ var search = BI.Func.getSearchResult(newValues, keyword);
+ values = search.match.concat(search.find);
+ }
+ return BI.map(values, function (i, v) {
+ return {
+ text: v.text,
+ title: v.text,
+ value: v.value,
+ selected: src.type === BI.Selection.All
+ };
+ });
+ },
+
+ setValue: function (v) {
+ // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
+ this.storeValue = BI.deepClone(v);
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiSelectSearchPane
+ * @extends Widget
+ */
+
+BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 24,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.tooltipClick = BI.createWidget({
+ type: "bi.label",
+ invisible: true,
+ text: BI.i18nText("BI-Click_Blank_To_Select"),
+ cls: "multi-select-toolbar",
+ height: this.constants.height
+ });
+
+ this.loader = BI.createWidget({
+ type: "bi.multi_select_search_loader",
+ keywordGetter: o.keywordGetter,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(self, [op, function (res) {
+ callback(res);
+ self.setKeyword(o.keywordGetter());
+ }]);
+ },
+ value: o.value
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.resizer = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.tooltipClick,
+ height: 0
+ }, {
+ el: this.loader
+ }]
+ });
+ this.tooltipClick.setVisible(false);
+ },
+
+ setKeyword: function (keyword) {
+ var btn;
+ var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
+ if (isVisible !== this.tooltipClick.isVisible()) {
+ this.tooltipClick.setVisible(isVisible);
+ this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
+ this.resizer.resize();
+ }
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ hasMatched: function () {
+ return this.tooltipClick.isVisible();
+ },
+
+ setValue: function (v) {
+ this.loader.setValue(v);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ populate: function (items) {
+ this.loader.populate.apply(this.loader, arguments);
+ }
+});
+
+BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-check-selected-button",
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.numberCounter = BI.createWidget({
+ type: "bi.text_button",
+ element: this,
+ hgap: 4,
+ text: "0",
+ textAlign: "center",
+ textHeight: 16,
+ cls: "bi-high-light-background count-tip"
+ });
+ this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ this.numberCounter.element.hover(function () {
+ self.numberCounter.setTag(self.numberCounter.getText());
+ self.numberCounter.setText(BI.i18nText("BI-Check_Selected"));
+ }, function () {
+ self.numberCounter.setText(self.numberCounter.getTag());
+ });
+ this.setVisible(false);
+ if(BI.isNotNull(o.value)){
+ this.setValue(o.value);
+ }
+ },
+
+ setValue: function (ob) {
+ var self = this, o = this.options;
+ ob || (ob = {});
+ ob.type || (ob.type = BI.Selection.Multi);
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ o.itemsCreator({
+ type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ var length = res.count - ob.value.length;
+ BI.nextTick(function () {
+ self.numberCounter.setText(length);
+ self.setVisible(length > 0);
+ });
+ });
+ return;
+ }
+ BI.nextTick(function () {
+ self.numberCounter.setText(ob.value.length);
+ self.setVisible(ob.value.length > 0);
+ });
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_select_check_selected_button", BI.MultiSelectCheckSelectedButton);/**
+ * 多选输入框
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectEditor
+ * @extends Widget
+ */
+BI.MultiSelectEditor = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-editor",
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.state_editor",
+ element: this,
+ height: o.height,
+ watermark: BI.i18nText("BI-Basic_Search"),
+ allowBlank: true,
+ value: o.value,
+ text: o.text,
+ tipType: o.tipType,
+ warningTitle: o.warningTitle,
+ });
+
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
+
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ setState: function (state) {
+ this.editor.setState(state);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ },
+
+ setTipType: function (v) {
+ this.editor.setTipType(v);
+ },
+
+ getValue: function () {
+ var v = this.editor.getState();
+ if (BI.isArray(v) && v.length > 0) {
+ return v[v.length - 1];
+ }
+ return "";
+
+ },
+
+ getKeywords: function () {
+ var val = this.editor.getLastValidValue();
+ var keywords = val.match(/[\S]+/g);
+ if (BI.isEndWithBlank(val)) {
+ return keywords.concat([" "]);
+ }
+ return keywords;
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE";
+BI.shortcut("bi.multi_select_editor", BI.MultiSelectEditor);
+/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectInsertSearcher
+ * @extends Widget
+ */
+BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-searcher",
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {},
+ text: BI.i18nText("BI-Basic_Please_Select")
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectInsertSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.multi_select_editor",
+ height: o.height,
+ text: o.text
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_select_search_insert_pane",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ var keyword = self.editor.getValue();
+ op.keywords = [keyword];
+ this.setKeyword(keyword);
+ o.itemsCreator(op, callback);
+ },
+ value: o.value,
+ listeners: [{
+ eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
+ action: function () {
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM);
+ }
+ }]
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, keywords);
+ });
+ if (BI.isNotNull(o.value)) {
+ this.setState(o.value);
+ }
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (ob) {
+ var o = this.options;
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.All);
+ } else if (BI.size(ob.assist) <= 20) {
+ var state = "";
+ BI.each(ob.assist, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ } else {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.None);
+ } else if (BI.size(ob.value) <= 20) {
+ var state = "";
+ BI.each(ob.value, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiSelectInsertSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiSelectInsertSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectInsertSearcher.EVENT_START = "EVENT_START";
+BI.MultiSelectInsertSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectInsertSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectInsertSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
+BI.shortcut("bi.multi_select_insert_searcher", BI.MultiSelectInsertSearcher);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectSearcher
+ * @extends Widget
+ */
+BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-searcher",
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {},
+ text: BI.i18nText("BI-Basic_Please_Select")
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.multi_select_editor",
+ height: o.height,
+ text: o.text
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_select_search_pane",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ var keyword = self.editor.getValue();
+ op.keywords = [keyword];
+ this.setKeyword(keyword);
+ o.itemsCreator(op, callback);
+ },
+ value: o.value
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords);
+ });
+ if (BI.isNotNull(o.value)) {
+ this.setState(o.value);
+ }
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (ob) {
+ var o = this.options;
+ ob || (ob = {});
+ ob.value || (ob.value = []);
+ if (ob.type === BI.Selection.All) {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.All);
+ } else if (BI.size(ob.assist) <= 20) {
+ var state = "";
+ BI.each(ob.assist, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ } else {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.None);
+ } else if (BI.size(ob.value) <= 20) {
+ var state = "";
+ BI.each(ob.value, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiSelectSearcher.EVENT_START = "EVENT_START";
+BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
+BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.shortcut("bi.multi_select_searcher", BI.MultiSelectSearcher);/**
+ * 查看已选switcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiSelectCheckSelectedSwitcher
+ * @extends Widget
+ */
+BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-check-selected-switcher",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ el: {},
+ popup: {},
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.button = BI.createWidget(o.el, {
+ type: "bi.multi_select_check_selected_button",
+ itemsCreator: o.itemsCreator,
+ value: o.value
+ });
+ this.button.on(BI.Events.VIEW, function () {
+ self.fireEvent(BI.Events.VIEW, arguments);
+ });
+ this.switcher = BI.createWidget({
+ type: "bi.switcher",
+ toggle: false,
+ element: this,
+ el: this.button,
+ popup: BI.extend({
+ type: "bi.multi_select_check_pane",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ onClickContinueSelect: function () {
+ self.switcher.hideView();
+ },
+ value: o.value
+ }, o.popup),
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE);
+ });
+ this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW);
+ });
+ this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () {
+ var me = this;
+ BI.nextTick(function () {
+ me.populate();
+ });
+ });
+
+ this.switcher.element.click(function (e) {
+ e.stopPropagation();
+ });
+ },
+
+ adjustView: function () {
+ this.switcher.adjustView();
+ },
+
+ hideView: function () {
+ this.switcher.empty();
+ this.switcher.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.switcher.setAdapter(adapter);
+ },
+
+ setValue: function (v) {
+ this.switcher.setValue(v);
+ },
+
+ setButtonChecked: function (v) {
+ this.button.setValue(v);
+ },
+
+ getValue: function () {
+
+ },
+
+ populate: function (items) {
+ this.switcher.populate.apply(this.switcher, arguments);
+ }
+});
+
+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_1 on 2017/5/2.
+ */
+BI.MultiSelectInsertList = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-insert-list",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectInsertList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = o.value || {};
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_loader",
+ cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ logic: {
+ dynamic: true
+ },
+ // onLoaded: o.onLoaded,
+ el: {},
+ value: o.value
+ });
+ this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
+ });
+
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_select_search_insert_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.trigger.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keywords = [self.trigger.getKeyword()];
+ this.setKeyword(op.keywords[0]);
+ o.itemsCreator(op, callback);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
+ action: function () {
+ var keyword = self.trigger.getKeyword();
+ if (!self.trigger.hasMatched()) {
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self.adapter.populate();
+ if (self.storeValue.type === BI.Selection.Multi) {
+ self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
+ }
+ }
+ }
+ }]
+ });
+ this.searcherPane.setVisible(false);
+
+ 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.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue("");
+ self.adapter.setValue(self.storeValue);
+ // 需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ var keyword = this.getKeyword();
+ if (this.hasMatched()) {
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
+ });
+ }
+ self._showAdapter();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_SEARCHING,
+ action: function () {
+ var keywords = this.getKeywords();
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
+ });
+ }
+ }
+ }],
+ value: o.value
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: 24
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ 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();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.map(ob.items, "value");
+ digest(self._allData);
+ });
+ } else {
+ digest(this._allData);
+ }
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ callback();
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA,
+ keywords: [self.trigger.getKeyword()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ callback();
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ callback();
+ });
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ callback();
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectInsertList, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectInsertList.EVENT_CHANGE = "BI.MultiSelectInsertList.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_insert_list", BI.MultiSelectInsertList);/**
+ * Created by zcf_1 on 2017/5/2.
+ */
+BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectInsertNoBarList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-insert-list",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectInsertNoBarList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = {
+ type: BI.Selection.Multi,
+ value: o.value || []
+ };
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_no_bar_loader",
+ cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ logic: {
+ dynamic: false
+ },
+ // onLoaded: o.onLoaded,
+ el: {},
+ value: {
+ type: BI.Selection.Multi,
+ value: o.value || []
+ }
+ });
+ this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
+ });
+
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_select_search_insert_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.trigger.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keywords = [self.trigger.getKeyword()];
+ this.setKeyword(op.keywords[0]);
+ o.itemsCreator(op, callback);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
+ action: function () {
+ var keyword = self.trigger.getKeyword();
+ if (!self.trigger.hasMatched()) {
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self.adapter.populate();
+ if (self.storeValue.type === BI.Selection.Multi) {
+ self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
+ }
+ }
+ }
+ }]
+ });
+ this.searcherPane.setVisible(false);
+
+ 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.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue("");
+ self.adapter.setValue(self.storeValue);
+ // 需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ var keyword = this.getKeyword();
+ if (this.hasMatched()) {
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ if (self.storeValue.type === BI.Selection.Multi) {
+ BI.pushDistinct(self.storeValue.value, keyword);
+ }
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_SEARCHING,
+ action: function () {
+ var keywords = this.getKeywords();
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
+ });
+ }
+ }
+ }],
+ value: {
+ type: BI.Selection.Multi,
+ value: o.value || []
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: 24
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ 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();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.map(ob.items, "value");
+ digest(self._allData);
+ });
+ } else {
+ digest(this._allData);
+ }
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ callback();
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA,
+ keywords: [self.trigger.getKeyword()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ callback();
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ callback();
+ });
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ callback();
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = {
+ type: BI.Selection.Multi,
+ value: v || []
+ };
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue.value);
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectInsertNoBarList, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectInsertNoBarList.EVENT_CHANGE = "BI.MultiSelectInsertNoBarList.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_insert_no_bar_list", BI.MultiSelectInsertNoBarList);/**
+ * Created by zcf_1 on 2017/5/2.
+ */
+BI.MultiSelectList = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_HEIGHT: 24
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-list",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = {};
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_loader",
+ cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ logic: {
+ dynamic: false
+ },
+ // onLoaded: o.onLoaded,
+ el: {}
+ });
+ this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ });
+
+ 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) {
+ op.keywords = [self.trigger.getKeyword()];
+ this.setKeyword(op.keywords[0]);
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ 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.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue("");
+ self.adapter.setValue(self.storeValue);
+ // 需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ var keyword = this.getKeyword();
+ if (this.hasMatched()) {
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ }
+ }
+ }, {
+ 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.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue("");
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
+ });
+ }
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: this._constant.EDITOR_HEIGHT
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: this._constant.EDITOR_HEIGHT,
+ 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();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.map(ob.items, "value");
+ digest(self._allData);
+ });
+ } else {
+ digest(this._allData);
+ }
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ });
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.MultiSelectList.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+ }
+
+ function adjust () {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ };
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ };
+ }
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.MultiSelectList, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/**
+ * Created by zcf_1 on 2017/5/11.
+ */
+BI.MultiSelectTree = BI.inherit(BI.Single, {
+ _constant: {
+ EDITOR_HEIGHT: 24
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-tree",
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiSelectTree.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = {value: {}};
+
+ this.adapter = BI.createWidget({
+ type: "bi.multi_select_tree_popup",
+ itemsCreator: o.itemsCreator
+ });
+ this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ });
+
+ // 搜索中的时候用的是parttree,同adapter中的synctree不一样
+ this.searcherPane = BI.createWidget({
+ type: "bi.multi_tree_search_pane",
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ keywordGetter: function () {
+ return self.searcher.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.searcher.getKeyword();
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.searcher.getKeyword()
+ });
+ },
+ adapter: this.adapter,
+ popup: this.searcherPane,
+ masker: false,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ // self.storeValue = {value: self.adapter.getValue()};
+ // self.searcherPane.setSelectedValue(self.storeValue.value);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ // self.storeValue = {value: self.searcherPane.getValue()};
+ // self.adapter.setSelectedValue(self.storeValue.value);
+ BI.nextTick(function () {
+ self.adapter.populate();
+ });
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function () {
+ if (self.searcher.isSearching()) {
+ self.storeValue = {value: self.searcherPane.getValue()};
+ } else {
+ self.storeValue = {value: self.adapter.getValue()};
+ }
+ self.setSelectedValue(self.storeValue.value);
+ self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ self._showAdapter();
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.searcher,
+ height: this._constant.EDITOR_HEIGHT
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: this._constant.EDITOR_HEIGHT,
+ 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);
+ },
+
+ resize: function () {
+
+ },
+
+ setSelectedValue: function (v) {
+ this.storeValue.value = v || {};
+ this.adapter.setSelectedValue(v);
+ this.searcherPane.setSelectedValue(v);
+ this.searcher.setValue({
+ value: v || {}
+ });
+ },
+
+ setValue: function (v) {
+ this.adapter.setValue(v);
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ updateValue: function (v) {
+ this.adapter.updateValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.searcher.populate.apply(this.searcher, arguments);
+ this.adapter.populate.apply(this.adapter, arguments);
+ }
+});
+BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
+BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
+ * Created by zcf on 2016/12/21.
+ */
+BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.popup = BI.createWidget({
+ type: "bi.async_tree",
+ element: this,
+ itemsCreator: o.itemsCreator
+ });
+ this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT);
+ });
+ this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE);
+ });
+ },
+
+ hasChecked: function () {
+ return this.popup.hasChecked();
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.popup.setValue(v);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.popup.setSelectedValue(v);
+ },
+
+ updateValue: function (v) {
+ this.popup.updateValue(v);
+ this.popup.refresh();
+ },
+
+ populate: function (config) {
+ this.popup.stroke(config);
+ }
+
+});
+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);/**
+ *
+ * @class BI.MultiTreeCheckPane
+ * @extends BI.Pane
+ */
+BI.MultiTreeCheckPane = BI.inherit(BI.Pane, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-check-pane bi-background",
+ onClickContinueSelect: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ var continueSelect = BI.createWidget({
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Continue_Select"),
+ cls: "multi-tree-check-selected"
+ });
+ continueSelect.on(BI.TextButton.EVENT_CHANGE, function () {
+ opts.onClickContinueSelect();
+ BI.nextTick(function () {
+ self.empty();
+ });
+ });
+
+ var backToPopup = BI.createWidget({
+ type: "bi.left",
+ cls: "multi-tree-continue-select",
+ items: [
+ {
+ el: {
+ type: "bi.label",
+ text: BI.i18nText("BI-Selected_Data")
+ },
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ },
+ {
+ el: continueSelect,
+ lgap: this.constants.lgap,
+ tgap: this.constants.tgap
+ }]
+ });
+
+ this.display = BI.createWidget({
+ type: "bi.display_tree",
+ cls: "bi-multi-tree-display",
+ itemsCreator: function (op, callback) {
+ op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA;
+ opts.itemsCreator(op, callback);
+ },
+ value: (opts.value || {}).value
+ });
+
+ this.display.on(BI.Events.AFTERINIT, function () {
+ self.fireEvent(BI.Events.AFTERINIT);
+ });
+
+ this.display.on(BI.TreeView.EVENT_INIT, function () {
+ backToPopup.setVisible(false);
+ });
+
+ this.display.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ backToPopup.setVisible(true);
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ height: this.constants.height,
+ el: backToPopup
+ }, {
+ height: "fill",
+ el: this.display
+ }]
+ });
+
+ },
+
+ empty: function () {
+ this.display.empty();
+ },
+
+ populate: function (configs) {
+ this.display.stroke(configs);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.display.setSelectedValue(v.value);
+ },
+
+ getValue: function () {
+
+ }
+});
+
+BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK";
+
+
+BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/**
+ *
+ * @class BI.MultiTreeCombo
+ * @extends BI.Single
+ */
+
+BI.MultiTreeCombo = BI.inherit(BI.Single, {
+
+ constants: {
+ offset: {
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 25
+ }
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-combo",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCombo.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ var isInit = false;
+ var want2showCounter = false;
+
+ this.storeValue = {value: o.value || {}};
+
+ this.trigger = BI.createWidget({
+ type: "bi.multi_select_trigger",
+ height: o.height,
+ valueFormatter: o.valueFormatter,
+ // 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"
+ },
+ popup: {
+ type: "bi.multi_tree_check_pane",
+ itemsCreator: o.itemsCreator
+ }
+ },
+ value: {value: o.value || {}}
+
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ container: o.container,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.multi_tree_popup_view",
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
+ action: function () {
+ self.trigger.getCounter().adjustView();
+ isInit = true;
+ if (want2showCounter === true) {
+ showCounter();
+ }
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CHANGE,
+ action: function () {
+ change = true;
+ var val = {
+ type: BI.Selection.Multi,
+ value: this.hasChecked() ? this.getValue() : {}
+ };
+ self.trigger.getSearcher().setState(val);
+ self.trigger.getCounter().setButtonChecked(val);
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self.combo.hideView();
+ }
+ }, {
+ eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR,
+ action: function () {
+ clear = true;
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ value: {value: o.value || {}},
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ var change = false;
+ var clear = false; // 标识当前是否点击了清空
+
+ var isSearching = function () {
+ return self.trigger.getSearcher().isSearching();
+ };
+
+ var isPopupView = function () {
+ return self.combo.isViewVisible();
+ };
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self.storeValue = {value: self.combo.getValue()};
+ this.setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self.storeValue = {value: this.getValue()};
+ self.combo.setValue(self.storeValue);
+ BI.nextTick(function () {
+ if (isPopupView()) {
+ self.combo.populate();
+ }
+ });
+ });
+
+ function showCounter () {
+ if (isSearching()) {
+ self.storeValue = {value: self.trigger.getValue()};
+ } else if (isPopupView()) {
+ self.storeValue = {value: self.combo.getValue()};
+ }
+ self.trigger.setValue(self.storeValue);
+ }
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ if (want2showCounter === false) {
+ want2showCounter = true;
+ }
+ if (isInit === true) {
+ want2showCounter = null;
+ showCounter();
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
+ self.combo.toggle();
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
+ var checked = this.getSearcher().hasChecked();
+ var val = {
+ type: BI.Selection.Multi,
+ value: checked ? {1: 1} : {}
+ };
+ this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
+ this.getCounter().setButtonChecked(val);
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ if (isSearching()) {
+ return;
+ }
+ if (change === true) {
+ self.storeValue = {value: self.combo.getValue()};
+ change = false;
+ }
+ self.combo.setValue(self.storeValue);
+ self.populate();
+
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
+ if (isSearching()) {
+ self.trigger.stopEditing();
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ } else {
+ if (isPopupView()) {
+ self.trigger.stopEditing();
+ self.storeValue = {value: self.combo.getValue()};
+ if (clear === true) {
+ self.storeValue = {value: {}};
+ }
+ self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
+ }
+ }
+ clear = false;
+ change = false;
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ setValue: function (v) {
+ this.storeValue.value = v || {};
+ this.combo.setValue({
+ value: v || {}
+ });
+ },
+
+ getValue: function () {
+ return this.storeValue.value;
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM";
+
+BI.shortcut("bi.multi_tree_combo", BI.MultiTreeCombo);/**
+ * 带加载的多选下拉面板
+ * @class BI.MultiTreePopup
+ * @extends BI.Pane
+ */
+BI.MultiTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-popup",
+ maxWidth: "auto",
+ minWidth: 100,
+ maxHeight: 400,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.selectedValues = {};
+
+ this.tree = BI.createWidget({
+ type: "bi.async_tree",
+ height: 400,
+ cls: "popup-view-tree",
+ itemsCreator: opts.itemsCreator,
+ onLoaded: opts.onLoaded,
+ value: opts.value || {}
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ element: this,
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")],
+ el: this.tree
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+
+ this.tree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE);
+ });
+
+ this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () {
+ self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT);
+ });
+
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.tree.setSelectedValue(v.value);
+ },
+
+ populate: function (config) {
+ this.tree.stroke(config);
+ },
+
+ hasChecked: function () {
+ return this.tree.hasChecked();
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT";
+
+
+BI.shortcut("bi.multi_tree_popup_view", BI.MultiTreePopup);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.MultiTreeSearchPane
+ * @extends BI.Pane
+ */
+
+BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-search-pane bi-card",
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+
+ this.partTree = BI.createWidget({
+ type: "bi.part_tree",
+ element: this,
+ tipText: BI.i18nText("BI-No_Select"),
+ itemsCreator: function (op, callback) {
+ op.keyword = opts.keywordGetter();
+ opts.itemsCreator(op, callback);
+ },
+ value: opts.value
+ });
+
+ this.partTree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.partTree.on(BI.TreeView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
+ });
+ },
+
+ hasChecked: function () {
+ return this.partTree.hasChecked();
+ },
+
+ setValue: function (v) {
+ this.setSelectedValue(v.value);
+ },
+
+ setSelectedValue: function (v) {
+ v || (v = {});
+ this.partTree.setSelectedValue(v);
+ },
+
+ getValue: function () {
+ return this.partTree.getValue();
+ },
+
+ empty: function () {
+ this.partTree.empty();
+ },
+
+ populate: function (op) {
+ this.partTree.stroke.apply(this.partTree, arguments);
+ }
+});
+
+BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/**
+ * 查看已选按钮
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeCheckSelectedButton
+ * @extends BI.Single
+ */
+BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-check-selected-button",
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments);
+ var self = this;
+ this.indicator = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "check-font trigger-check-selected icon-size-12",
+ width: 15,
+ height: 15,
+ stopPropagation: true
+ });
+
+ this.checkSelected = BI.createWidget({
+ type: "bi.text_button",
+ cls: "trigger-check-selected",
+ invisible: true,
+ hgap: 4,
+ text: BI.i18nText("BI-Check_Selected"),
+ textAlign: "center",
+ textHeight: 15
+ });
+ this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget({
+ type: "bi.horizontal",
+ element: this,
+ items: [this.indicator, this.checkSelected]
+ });
+
+ this.element.hover(function () {
+ self.indicator.setVisible(false);
+ self.checkSelected.setVisible(true);
+ }, function () {
+ self.indicator.setVisible(true);
+ self.checkSelected.setVisible(false);
+ });
+ this.setVisible(false);
+ },
+
+ setValue: function (v) {
+ v || (v = {});
+ this.setVisible(BI.size(v.value) > 0);
+ }
+});
+
+BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.multi_tree_check_selected_button", BI.MultiTreeCheckSelectedButton);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.MultiTreeSearcher
+ * @extends Widget
+ */
+BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-tree-searcher",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: function (v) {
+ return v;
+ },
+ popup: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.MultiTreeSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.multi_select_editor",
+ height: o.height,
+ el: {
+ type: "bi.simple_state_editor",
+ height: o.height
+ }
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback({
+ keyword: self.editor.getValue()
+ });
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_tree_search_pane",
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ op.keyword = self.editor.getValue();
+ o.itemsCreator(op, callback);
+ },
+ value: o.value
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments);
+ });
+ if (BI.isNotNull(o.value)) {
+ this.setState(o.value);
+ }
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setState: function (ob) {
+ var o = this.options;
+ ob || (ob = {});
+ ob.value || (ob.value = {});
+ var count = 0;
+ if (BI.isNumber(ob)) {
+ this.editor.setState(ob);
+ } else if (BI.size(ob.value) === 0) {
+ this.editor.setState(BI.Selection.None);
+ } else {
+ var text = "";
+ BI.each(ob.value, function (name, children) {
+ var childNodes = getChildrenNode(children);
+ text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; ";
+ if (childNodes === "") {
+ count++;
+ }
+ });
+
+ if (count > 20) {
+ this.editor.setState(BI.Selection.Multi);
+ } else {
+ this.editor.setState(text);
+ }
+ }
+
+ function getChildrenNode (ob) {
+ var text = "";
+ var index = 0, size = BI.size(ob);
+ BI.each(ob, function (name, children) {
+ index++;
+ var childNodes = getChildrenNode(children);
+ text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ",");
+ if (childNodes === "") {
+ count++;
+ }
+ });
+ return text;
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+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 windy on 2017/3/13.
+ * 数值微调器
+ */
+BI.NumberEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-number-editor bi-border bi-focus-shadow",
+ validationChecker: function () {
+ return true;
+ },
+ valueFormatter: function (v) {
+ return v;
+ },
+ value: 0,
+ allowBlank: false,
+ errorText: "",
+ step: 1
+ });
+ },
+
+ _init: function () {
+ BI.NumberEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height - 2,
+ allowBlank: o.allowBlank,
+ value: o.valueFormatter(o.value),
+ validationChecker: o.validationChecker,
+ errorText: o.errorText
+ });
+ this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
+ o.value = BI.parseFloat(this.getValue());
+ self.fireEvent(BI.NumberEditor.EVENT_CHANGE);
+ });
+ this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
+ this.setValue(BI.parseFloat(this.getValue()));
+ self.fireEvent(BI.NumberEditor.EVENT_CONFIRM);
+ });
+ this.topBtn = BI.createWidget({
+ type: "bi.icon_button",
+ forceNotSelected: true,
+ trigger: "lclick,",
+ cls: "add-up-font top-button bi-border-left bi-list-item-active2 icon-size-12"
+ });
+ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () {
+ self._finetuning(o.step);
+ self.fireEvent(BI.NumberEditor.EVENT_CHANGE);
+ self.fireEvent(BI.NumberEditor.EVENT_CONFIRM);
+ });
+ this.bottomBtn = BI.createWidget({
+ type: "bi.icon_button",
+ trigger: "lclick,",
+ forceNotSelected: true,
+ cls: "minus-down-font bottom-button bi-border-left bi-list-item-active2 icon-size-12"
+ });
+ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () {
+ self._finetuning(-o.step);
+ self.fireEvent(BI.NumberEditor.EVENT_CHANGE);
+ self.fireEvent(BI.NumberEditor.EVENT_CONFIRM);
+ });
+ BI.createWidget({
+ type: "bi.htape",
+ height: o.height - 2,
+ element: this,
+ items: [this.editor, {
+ el: {
+ type: "bi.grid",
+ columns: 1,
+ rows: 2,
+ items: [{
+ column: 0,
+ row: 0,
+ el: this.topBtn
+ }, {
+ column: 0,
+ row: 1,
+ el: this.bottomBtn
+ }]
+ },
+ width: 23
+ }]
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ // 微调
+ _finetuning: function (add) {
+ var v = BI.parseFloat(this.getValue());
+ this.setValue(BI.add(v, add));
+ },
+
+ setUpEnable: function (v) {
+ this.topBtn.setEnable(!!v);
+ },
+
+ setDownEnable: function (v) {
+ this.bottomBtn.setEnable(!!v);
+ },
+
+ getValue: function () {
+ return this.options.value;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ o.value = v;
+ this.editor.setValue(o.valueFormatter(v));
+ }
+
+});
+BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.NumberEditor.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.number_editor", BI.NumberEditor);// 小于号的值为:0,小于等于号的值为:1
+// closeMIn:最小值的符号,closeMax:最大值的符号
+/**
+ * Created by roy on 15/9/17.
+ *
+ */
+BI.NumberInterval = BI.inherit(BI.Single, {
+ constants: {
+ typeError: "typeBubble",
+ numberError: "numberBubble",
+ signalError: "signalBubble",
+ editorWidth: 114,
+ columns: 5,
+ width: 24,
+ rows: 1,
+ numberErrorCls: "number-error",
+ border: 1,
+ less: 0,
+ less_equal: 1,
+ numTip: "",
+ adjustYOffset: 2
+ },
+ _defaultConfig: function () {
+ var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-number-interval",
+ height: 24,
+ validation: "valid",
+ closeMin: true
+ });
+ },
+ _init: function () {
+ var self = this, c = this.constants, o = this.options;
+ BI.NumberInterval.superclass._init.apply(this, arguments);
+ this.smallEditor = BI.createWidget({
+ type: "bi.number_interval_single_editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.min,
+ level: "warning",
+ tipType: "success",
+ title: function () {
+ return self.smallEditor && self.smallEditor.getValue();
+ },
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.smallEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "number-interval-small-editor bi-border"
+ });
+
+ this.smallTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.smallEditor.element,
+ items: [{
+ el: this.smallTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ this.bigEditor = BI.createWidget({
+ type: "bi.number_interval_single_editor",
+ height: o.height - 2,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ value: o.max,
+ level: "warning",
+ tipType: "success",
+ title: function () {
+ return self.bigEditor && self.bigEditor.getValue();
+ },
+ quitChecker: function () {
+ return false;
+ },
+ validationChecker: function (v) {
+ if (!BI.isNumeric(v)) {
+ self.bigEditorBubbleType = c.typeError;
+ return false;
+ }
+ return true;
+ },
+ cls: "number-interval-big-editor bi-border"
+ });
+
+ this.bigTip = BI.createWidget({
+ type: "bi.label",
+ text: o.numTip,
+ height: o.height - 2,
+ invisible: true
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this.bigEditor.element,
+ items: [{
+ el: this.bigTip,
+ top: 0,
+ right: 5
+ }]
+ });
+
+ // this.smallCombo = BI.createWidget({
+ // type: "bi.number_interval_combo",
+ // cls: "number-interval-small-combo",
+ // height: o.height,
+ // value: o.closemin ? 1 : 0,
+ // offsetStyle: "left"
+ // });
+ //
+ // this.bigCombo = BI.createWidget({
+ // type: "bi.number_interval_combo",
+ // cls: "number-interval-big-combo",
+ // height: o.height,
+ // value: o.closemax ? 1 : 0,
+ // offsetStyle: "left"
+ // });
+ this.smallCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "number-interval-small-combo bi-border-top bi-border-bottom bi-border-right",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconCls: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconCls: "less-equal-font"
+ }]
+ });
+ if (o.closeMin === true) {
+ this.smallCombo.setValue(1);
+ } else {
+ this.smallCombo.setValue(0);
+ }
+ this.bigCombo = BI.createWidget({
+ type: "bi.icon_combo",
+ cls: "number-interval-big-combo bi-border-top bi-border-bottom bi-border-left",
+ height: o.height - 2,
+ items: [{
+ text: "(" + BI.i18nText("BI-Less_Than") + ")",
+ iconCls: "less-font",
+ value: 0
+ }, {
+ text: "(" + BI.i18nText("BI-Less_And_Equal") + ")",
+ value: 1,
+ iconCls: "less-equal-font"
+ }]
+ });
+ if (o.closeMax === true) {
+ this.bigCombo.setValue(1);
+ } else {
+ this.bigCombo.setValue(0);
+ }
+ this.label = BI.createWidget({
+ type: "bi.label",
+ text: BI.i18nText("BI-Basic_Value"),
+ textHeight: o.height - c.border * 2,
+ width: c.width - c.border * 2,
+ height: o.height - c.border * 2,
+ level: "warning",
+ tipType: "warning"
+ });
+ this.left = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.smallEditor
+ }, {
+ el: self.smallCombo,
+ width: c.width - c.border
+ }]
+
+ });
+ this.right = BI.createWidget({
+ type: "bi.htape",
+ items: [{
+ el: self.bigCombo,
+ width: c.width - c.border
+ }, {
+ el: self.bigEditor,
+ // BI-23883 间距考虑边框
+ lgap: 1
+ }]
+ });
+
+
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ hgap: 15,
+ height: o.height,
+ items: [
+ {
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: -15,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: 0,
+ right: -15,
+ top: 0,
+ bottom: 0
+ }]
+ }
+ ]
+ });
+
+ BI.createWidget({
+ element: self,
+ type: "bi.horizontal_auto",
+ items: [
+ self.label
+ ]
+ });
+
+
+ self._setValidEvent(self.bigEditor, c.bigEditor);
+ self._setValidEvent(self.smallEditor, c.smallEditor);
+ self._setErrorEvent(self.bigEditor, c.bigEditor);
+ self._setErrorEvent(self.smallEditor, c.smallEditor);
+ self._setBlurEvent(self.bigEditor);
+ self._setBlurEvent(self.smallEditor);
+ self._setFocusEvent(self.bigEditor);
+ self._setFocusEvent(self.smallEditor);
+ self._setComboValueChangedEvent(self.bigCombo);
+ self._setComboValueChangedEvent(self.smallCombo);
+ self._setEditorValueChangedEvent(self.bigEditor);
+ self._setEditorValueChangedEvent(self.smallEditor);
+
+ self._checkValidation();
+ },
+
+ _checkValidation: function () {
+ var self = this, c = this.constants, o = this.options;
+ self._setTitle("");
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) {
+ self.element.removeClass("number-error");
+ o.validation = "invalid";
+ return c.typeError;
+ }
+ if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) {
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+ }
+ var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()),
+ bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue();
+ if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) {
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ }
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+
+ }
+ if (smallValue > bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.numberError;
+ } else if (smallValue === bigValue) {
+ self.element.addClass("number-error");
+ o.validation = "invalid";
+ return c.signalError;
+ }
+ self.element.removeClass("number-error");
+ o.validation = "valid";
+ return "";
+
+
+
+
+
+ },
+
+ _setTitle: function (v) {
+ var self = this;
+ self.bigEditor.setTitle(v);
+ self.smallEditor.setTitle(v);
+ self.label.setTitle(v);
+ },
+
+ _setFocusEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_FOCUS, function () {
+ self._setTitle("");
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ default :
+ return;
+ }
+
+ });
+ },
+ _setBlurEvent: function (w) {
+ var c = this.constants, self = this;
+ w.on(BI.Editor.EVENT_BLUR, function () {
+ BI.Bubbles.hide(c.typeError);
+ BI.Bubbles.hide(c.numberError);
+ BI.Bubbles.hide(c.signalError);
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ break;
+ default:
+ self._setTitle("");
+ }
+ });
+ },
+
+ _setErrorEvent: function (w) {
+ var c = this.constants, self = this;
+ w.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkValidation();
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ });
+ },
+
+
+ _setValidEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_VALID, function () {
+ switch (self._checkValidation()) {
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ break;
+ default:
+ self.fireEvent(BI.NumberInterval.EVENT_VALID);
+ }
+ });
+ },
+
+
+ _setEditorValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.Editor.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ case c.numberError:
+ BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ case c.signalError:
+ BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, {
+ offsetStyle: "left",
+ adjustYOffset: c.adjustYOffset
+ });
+ break;
+ default :
+ break;
+ }
+ self.fireEvent(BI.NumberInterval.EVENT_CHANGE);
+ });
+ w.on(BI.Editor.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.NumberInterval.EVENT_CONFIRM);
+ });
+ },
+
+ _setComboValueChangedEvent: function (w) {
+ var self = this, c = this.constants;
+ w.on(BI.IconCombo.EVENT_CHANGE, function () {
+ switch (self._checkValidation()) {
+ case c.typeError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ break;
+ case c.numberError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ break;
+ case c.signalError:
+ self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));
+ self.fireEvent(BI.NumberInterval.EVENT_ERROR);
+ break;
+ default :
+ self.fireEvent(BI.NumberInterval.EVENT_CHANGE);
+ self.fireEvent(BI.NumberInterval.EVENT_CONFIRM);
+ self.fireEvent(BI.NumberInterval.EVENT_VALID);
+ }
+ });
+ },
+
+ isStateValid: function () {
+ return this.options.validation === "valid";
+ },
+
+ setMinEnable: function (b) {
+ this.smallEditor.setEnable(b);
+ },
+
+ setCloseMinEnable: function (b) {
+ this.smallCombo.setEnable(b);
+ },
+
+ setMaxEnable: function (b) {
+ this.bigEditor.setEnable(b);
+ },
+
+ setCloseMaxEnable: function (b) {
+ this.bigCombo.setEnable(b);
+ },
+
+ showNumTip: function () {
+ this.smallTip.setVisible(true);
+ this.bigTip.setVisible(true);
+ },
+
+ hideNumTip: function () {
+ this.smallTip.setVisible(false);
+ this.bigTip.setVisible(false);
+ },
+
+ setNumTip: function (numTip) {
+ this.smallTip.setText(numTip);
+ this.bigTip.setText(numTip);
+ },
+
+ getNumTip: function () {
+ return this.smallTip.getText();
+ },
+
+ setValue: function (data) {
+ data = data || {};
+ var self = this, combo_value;
+ if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) {
+ self.smallEditor.setValue(data.min);
+ }
+
+ if (!BI.isNotNull(data.min)) {
+ self.smallEditor.setValue("");
+ }
+
+ if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) {
+ self.bigEditor.setValue(data.max);
+ }
+
+ if (!BI.isNotNull(data.max)) {
+ self.bigEditor.setValue("");
+ }
+
+ if (!BI.isNull(data.closeMin)) {
+ if (data.closeMin === true) {
+ combo_value = 1;
+ } else {
+ combo_value = 0;
+ }
+ self.smallCombo.setValue(combo_value);
+ }
+
+ if (!BI.isNull(data.closeMax)) {
+ if (data.closeMax === true) {
+ combo_value = 1;
+ } else {
+ combo_value = 0;
+ }
+ self.bigCombo.setValue(combo_value);
+ }
+
+ this._checkValidation();
+ },
+
+
+ getValue: function () {
+ var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue();
+ value.min = self.smallEditor.getValue();
+ value.max = self.bigEditor.getValue();
+ if (minComboValue[0] === 0) {
+ value.closeMin = false;
+ } else {
+ value.closeMin = true;
+ }
+
+ if (maxComboValue[0] === 0) {
+ value.closeMax = false;
+ } else {
+ value.closeMax = true;
+ }
+ return value;
+ },
+
+ destroyed: function () {
+ var c = this.constants;
+ BI.Bubbles.remove(c.typeError);
+ BI.Bubbles.remove(c.numberError);
+ BI.Bubbles.remove(c.signalError);
+ }
+});
+BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.NumberInterval.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.NumberInterval.EVENT_VALID = "EVENT_VALID";
+BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.shortcut("bi.number_interval", BI.NumberInterval);BI.NumberIntervalSingleEidtor = BI.inherit(BI.Single, {
+ props: {
+ baseCls: "bi-number-interval-single-editor",
+ tipType: "success",
+ title: ""
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.editor",
+ ref: function (_ref) {
+ self.editor = _ref;
+ },
+ height: o.height - 2,
+ watermark: o.watermark,
+ allowBlank: o.allowBlank,
+ value: o.value,
+ level: o.level,
+ quitChecker: o.quitChecker,
+ validationChecker: o.validationChecker,
+ listeners: [{
+ eventName: BI.Editor.EVENT_ERROR,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_ERROR, arguments);
+ }
+ }, {
+ eventName: BI.Editor.EVENT_FOCUS,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_FOCUS, arguments);
+ }
+ }, {
+ eventName: BI.Editor.EVENT_BLUR,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_BLUR, arguments);
+ }
+ }, {
+ eventName: BI.Editor.EVENT_VALID,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_VALID, arguments);
+ }
+ }, {
+ eventName: BI.Editor.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_CHANGE, arguments);
+ }
+ }, {
+ eventName: BI.Editor.EVENT_CONFIRM,
+ action: function () {
+ self.fireEvent(BI.Editor.EVENT_CONFIRM, arguments);
+ }
+ }]
+ }]
+ };
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ setTitle: function (v) {
+ return this.editor.setTitle(v);
+ },
+
+ setValue: function (v) {
+ return this.editor.setValue(v);
+ }
+});
+
+BI.shortcut("bi.number_interval_single_editor", BI.NumberIntervalSingleEidtor);/**
+ * 季度下拉框
+ *
+ * Created by GUY on 2015/8/28.
+ * @class BI.QuarterCombo
+ * @extends BI.Widget
+ */
+BI.QuarterCombo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-combo",
+ behaviors: {},
+ height: 25
+ });
+ },
+ _init: function () {
+ BI.QuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.quarter_trigger",
+ value: o.value
+ });
+
+ this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () {
+ self.storeValue = this.getKey();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+ this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeValue) {
+ self.setValue(this.getKey());
+ } else if (!this.getKey()) {
+ self.setValue();
+ }
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+ this.popup = BI.createWidget({
+ type: "bi.quarter_popup",
+ behaviors: o.behaviors,
+ value: o.value
+ });
+
+ this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ el: this.popup
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+ },
+
+ setValue: function (v) {
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ if (BI.isNull(this.popup)) {
+ return this.options.value || "";
+ } else {
+ return this.popup.getValue() || "";
+ }
+ }
+});
+
+BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.quarter_combo", BI.QuarterCombo);/**
+ * 季度展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.QuarterPopup
+ * @extends BI.Trigger
+ */
+BI.QuarterPopup = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-quarter-popup",
+ behaviors: {}
+ });
+ },
+
+ _init: function () {
+ BI.QuarterPopup.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var items = [{
+ text: BI.Date._QN[1],
+ value: 1
+ }, {
+ text: BI.Date._QN[2],
+ value: 2
+ }, {
+ text: BI.Date._QN[3],
+ value: 3
+ }, {
+ text: BI.Date._QN[4],
+ value: 4
+ }];
+ items = BI.map(items, function (j, item) {
+ return BI.extend(item, {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 25
+ });
+ });
+
+ this.quarter = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ behaviors: o.behaviors,
+ items: BI.createItems(items, {}),
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+
+ this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.MonthPopup.EVENT_CHANGE);
+ }
+ });
+ },
+
+ getValue: function () {
+ return this.quarter.getValue()[0];
+ },
+
+ setValue: function (v) {
+ this.quarter.setValue([v]);
+ }
+});
+BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/**
+ * 季度trigger
+ *
+ * Created by GUY on 2015/8/21.
+ * @class BI.QuarterTrigger
+ * @extends BI.Trigger
+ */
+BI.QuarterTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2,
+ textWidth: 40
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-quarter-trigger bi-border",
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.QuarterTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true,
+ errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text")
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ self.editor.setTitle(value);
+ }
+ self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.QuarterTrigger.EVENT_STOP);
+ });
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [
+ {
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-quarter-text",
+ text: BI.i18nText("BI-Multi_Date_Quarter"),
+ width: c.textWidth
+ },
+ width: c.textWidth
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.height
+ },
+ width: o.height
+ }
+ ]
+ });
+ this.setValue(o.value);
+ },
+
+ setValue: function (v) {
+ v = v || "";
+ this.editor.setState(v);
+ this.editor.setValue(v);
+ this.editor.setTitle(v);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ }
+});
+BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.QuarterTrigger.EVENT_START = "EVENT_START";
+BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP";
+BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/**
+ *
+ * @class BI.SearchMultiTextValueCombo
+ * @extends BI.Single
+ */
+BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SearchMultiTextValueCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-combo bi-search-multi-text-value-combo",
+ height: 24,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.SearchMultiTextValueCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
+ self._updateAllValue();
+ self._checkError();
+ self.trigger.getSearcher().setState(self.storeValue);
+ self.trigger.getCounter().setButtonChecked(self.storeValue);
+ };
+ this.storeValue = BI.deepClone(o.value || {});
+ this._updateAllValue();
+
+ this._assertValue(this.storeValue);
+ this._checkError();
+
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.search_multi_select_trigger",
+ text: o.text,
+ height: o.height,
+ // adapter: this.popup,
+ masker: {
+ offset: {
+ left: 0,
+ top: 0,
+ right: 0,
+ bottom: 25
+ }
+ },
+ allValueGetter: function () {
+ return self.allValue;
+ },
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ self._itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(BI.deepClone(self.getValue()));
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ value: this.storeValue,
+ warningTitle: o.warningTitle
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
+ self._setStartValue("");
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue("");
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ var keyword = this.getSearcher().getKeyword();
+ self._join({
+ type: BI.Selection.Multi,
+ value: [keyword]
+ }, function () {
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self._populate();
+ self._setStartValue("");
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue("");
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ if (obj instanceof BI.MultiSelectBar) {
+ self._joinAll(this.getValue(), function () {
+ assertShowValue();
+ });
+ } else {
+ self._join(this.getValue(), function () {
+ assertShowValue();
+ });
+ }
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
+ this.getCounter().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ toggle: false,
+ container: o.container,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.search_multi_select_popup_view",
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ });
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,
+ action: function () {
+ self._defaultState();
+ }
+ }, {
+ eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,
+ action: function () {
+ self.setValue();
+ self._defaultState();
+ }
+ }],
+ itemsCreator: BI.bind(self._itemsCreator, this),
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getCounter().adjustView();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ value: o.value,
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ }
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self._populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ /**
+ * 在存在标红的情况,如果popover没有发生改变就确认需要同步trigger的值,否则对外value值和trigger样式不统一
+ */
+ assertShowValue();
+ self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "multi-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ self.trigger.getCounter().hideView();
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this._checkError();
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ var o = this.options;
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ BI.remove(val.value, function (idx, value) {
+ return !BI.contains(BI.map(o.items, "value"), value);
+ });
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ this._itemsCreator({
+ type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _joinAll: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this.requesting = true;
+ this._itemsCreator({
+ type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA,
+ keywords: [this.trigger.getKey()]
+ }, function (ob) {
+ var items = BI.map(ob.items, "value");
+ if (self.storeValue.type === res.type) {
+ var change = false;
+ var map = self._makeMap(self.storeValue.value);
+ BI.each(items, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (self.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ var selectedMap = self._makeMap(self.storeValue.value);
+ var notSelectedMap = self._makeMap(res.value);
+ var newItems = [];
+ BI.each(items, function (i, item) {
+ if (BI.isNotNull(selectedMap[items[i]])) {
+ self.storeValue.assist && self.storeValue.assist.push(selectedMap[items[i]]);
+ delete selectedMap[items[i]];
+ }
+ if (BI.isNull(notSelectedMap[items[i]])) {
+ BI.remove(self.storeValue.assist, item);
+ newItems.push(item);
+ }
+ });
+ self.storeValue.value = newItems.concat(BI.values(selectedMap));
+ self._adjust(callback);
+ });
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ this._itemsCreator({
+ type: BI.SearchMultiTextValueCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+
+ }
+
+ function adjust () {
+ if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.Multi,
+ value: []
+ };
+ } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) {
+ self.storeValue = {
+ type: BI.Selection.All,
+ value: []
+ };
+ }
+ self._updateAllValue();
+ self._checkError();
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _join: function (res, callback) {
+ var self = this, o = this.options;
+ this._assertValue(res);
+ this._assertValue(this.storeValue);
+ if (this.storeValue.type === res.type) {
+ var map = this._makeMap(this.storeValue.value);
+ BI.each(res.value, function (i, v) {
+ if (!map[v]) {
+ self.storeValue.value.push(v);
+ BI.remove(self.storeValue.assist, v);
+ map[v] = v;
+ }
+ });
+ var change = false;
+ BI.each(res.assist, function (i, v) {
+ if (BI.isNotNull(map[v])) {
+ change = true;
+ self.storeValue.assist && self.storeValue.assist.push(map[v]);
+ delete map[v];
+ }
+ });
+ change && (this.storeValue.value = BI.values(map));
+ self._adjust(callback);
+ return;
+ }
+ this._joinAll(res, callback);
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ _getItemsByTimes: function (items, times) {
+ var res = [];
+ for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
+ res.push(items[i]);
+ }
+ return res;
+ },
+
+ _hasNextByTimes: function (items, times) {
+ return times * 100 < items.length;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ var items = o.items;
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.match.concat(search.find);
+ });
+ if (options.selectedValues) {// 过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: self._getItemsByTimes(items, options.times),
+ hasNext: self._hasNextByTimes(items, options.times)
+ });
+ },
+
+ _checkError: function () {
+ var v = this.storeValue.value || [];
+ if(BI.isNotEmptyArray(v)) {
+ v = BI.isArray(v) ? v : [v];
+ var result = BI.find(this.allValue, function (idx, value) {
+ return !BI.contains(v, value);
+ });
+ if (BI.isNull(result)) {
+ BI.isNotNull(this.trigger) && (this.trigger.setTipType("success"));
+ this.element.removeClass("combo-error");
+ } else {
+ BI.isNotNull(this.trigger) && (this.trigger.setTipType("warning"));
+ this.element.addClass("combo-error");
+ }
+ } else {
+ if(v.length === this.allValue.length){
+ BI.isNotNull(this.trigger) && (this.trigger.setTipType("success"));
+ this.element.removeClass("combo-error");
+ }else {
+ BI.isNotNull(this.trigger) && (this.trigger.setTipType("warning"));
+ this.element.addClass("combo-error");
+ }
+ }
+ },
+
+ _updateAllValue: function () {
+ this.storeValue = this.storeValue || {};
+ this.allValue = BI.deepClone(this.storeValue.value || []);
+ },
+
+ setValue: function (v) {
+ this.storeValue = BI.deepClone(v || {});
+ this._updateAllValue();
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ this._checkError();
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ _populate: function () {
+ this._count = null;
+ this.combo.populate();
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this._populate();
+ }
+});
+
+BI.extend(BI.SearchMultiTextValueCombo, {
+ REQ_GET_DATA_LENGTH: 1,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.SearchMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.search_multi_text_value_combo", BI.SearchMultiTextValueCombo);
+BI.SearchMultiSelectTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SearchMultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-trigger bi-border",
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.SearchMultiSelectTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.search_multi_select_searcher",
+ height: o.height,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ allValueGetter: o.allValueGetter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value,
+ text: o.text,
+ tipType: o.tipType,
+ warningTitle: o.warningTitle
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_CHANGE, arguments);
+ });
+ this.numberCounter = BI.createWidget(o.switcher, {
+ type: "bi.multi_select_check_selected_switcher",
+ valueFormatter: o.valueFormatter,
+ itemsCreator: o.itemsCreator,
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK);
+ });
+ this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
+ });
+
+ var wrapNumberCounter = BI.createWidget({
+ type: "bi.right_vertical_adapt",
+ hgap: 4,
+ items: [{
+ el: this.numberCounter
+ }]
+ });
+
+ var wrapper = BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: "fill"
+ }, {
+ el: wrapNumberCounter,
+ width: 0
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+
+ this.numberCounter.on(BI.Events.VIEW, function (b) {
+ BI.nextTick(function () {// 自动调整宽度
+ wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
+ wrapper.resize();
+ });
+ });
+
+ this.element.click(function (e) {
+ if (self.element.find(e.target).length > 0) {
+ self.numberCounter.hideView();
+ }
+ });
+ },
+
+ getCounter: function () {
+ return this.numberCounter;
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ this.numberCounter.hideView();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ this.numberCounter.setAdapter(adapter);
+ },
+
+ setValue: function (ob) {
+ this.searcher.setValue(ob);
+ this.numberCounter.setValue(ob);
+ },
+
+ setTipType: function (v) {
+ this.searcher.setTipType(v);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.SearchMultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.SearchMultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SearchMultiSelectTrigger.EVENT_START = "EVENT_START";
+BI.SearchMultiSelectTrigger.EVENT_STOP = "EVENT_STOP";
+BI.SearchMultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SearchMultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+BI.shortcut("bi.search_multi_select_trigger", BI.SearchMultiSelectTrigger);
+/**
+ * 多选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.SearchMultiSelectLoader
+ * @extends Widget
+ */
+BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-loader",
+ logic: {
+ dynamic: true
+ },
+ el: {
+ height: 400
+ },
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.storeValue = opts.value || {};
+ this._assertValue(this.storeValue);
+
+ this.button_group = BI.createWidget({
+ type: "bi.select_list",
+ element: this,
+ logic: opts.logic,
+ el: BI.extend({
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ }, opts.el),
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
+ ? self.storeValue.value.concat(startValue) : self.storeValue.value
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && self.storeValue) {
+ var json = BI.map(self.storeValue.value, function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: self.storeValue.type === BI.Selection.Multi
+ };
+ });
+ if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
+ var txt = opts.valueFormatter(startValue) || startValue;
+ json.unshift({
+ text: txt,
+ value: startValue,
+ title: txt,
+ selected: true
+ });
+ }
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue));
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ },
+ value: this.storeValue
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: "bi.multi_select_item",
+ logic: this.options.logic,
+ cls: "bi-list-item-active",
+ height: 24,
+ selected: this.isAllSelected(),
+ iconWrapperWidth: 36
+ });
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ isAllSelected: function () {
+ return this.button_group.isAllSelected();
+ },
+
+ _assertValue: function (val) {
+ val || (val = {});
+ val.type || (val.type = BI.Selection.Multi);
+ val.value || (val.value = []);
+ },
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v || {};
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ arguments[0] = this._createItems(items);
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader);BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-popup-view",
+ maxWidth: "auto",
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.search_multi_select_loader",
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded,
+ value: opts.value
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.multi_popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")],
+ el: this.loader,
+ value: opts.value
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE);
+ });
+ this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) {
+ switch (index) {
+ case 0:
+ self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR);
+ break;
+ case 1:
+ self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM);
+ break;
+ }
+ });
+ },
+
+ isAllSelected: function () {
+ return this.loader.isAllSelected();
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.SearchMultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM";
+BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR";
+
+
+BI.shortcut("bi.search_multi_select_popup_view", BI.SearchMultiSelectPopupView);BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-searcher",
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.multi_select_editor",
+ height: o.height,
+ text: o.text,
+ tipType: o.tipType,
+ warningTitle: o.warningTitle
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.multi_select_search_pane",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ var keyword = self.editor.getValue();
+ op.keywords = [keyword];
+ this.setKeyword(keyword);
+ o.itemsCreator(op, callback);
+ },
+ value: o.value
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords);
+ });
+ if(BI.isNotNull(o.value)) {
+ this.setState(o.value);
+ }
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (obj) {
+ var o = this.options;
+ var ob = {};
+ ob.type = obj.type;
+ ob.value = o.allValueGetter() || [];
+ ob.assist = obj.assist;
+ if (ob.type === BI.Selection.All) {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.All);
+ } else if (BI.size(ob.assist) <= 20) {
+ var state = "";
+ BI.each(ob.assist, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ } else {
+ if (ob.value.length === 0) {
+ this.editor.setState(BI.Selection.None);
+ } else if (BI.size(ob.value) <= 20) {
+ var state = "";
+ BI.each(ob.value, function (i, v) {
+ if (i === 0) {
+ state += "" + (o.valueFormatter(v + "") || v);
+ } else {
+ state += "," + (o.valueFormatter(v + "") || v);
+ }
+ });
+ this.editor.setState(state);
+ } else {
+ this.editor.setState(BI.Selection.Multi);
+ }
+ }
+ },
+
+ setTipType: function (v) {
+ this.editor.setTipType(v);
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.SearchMultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.SearchMultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SearchMultiSelectSearcher.EVENT_START = "EVENT_START";
+BI.SearchMultiSelectSearcher.EVENT_STOP = "EVENT_STOP";
+BI.SearchMultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SearchMultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.shortcut("bi.search_multi_select_searcher", BI.SearchMultiSelectSearcher);
+/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeFirstPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.first_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeLastPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.last_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreeMidPlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.mid_tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/**
+ * 加号表示的组节点
+ * Created by GUY on 2015/9/6.
+ * @class BI.SelectTreePlusGroupNode
+ * @extends BI.NodeButton
+ */
+BI.SelectTreePlusGroupNode = BI.inherit(BI.NodeButton, {
+ _defaultConfig: function () {
+ var conf = BI.SelectTreePlusGroupNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-select-tree-plus-group-node bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ id: "",
+ pId: "",
+ readonly: true,
+ open: false,
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SelectTreePlusGroupNode.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.checkbox = BI.createWidget({
+ type: "bi.tree_node_checkbox",
+ stopPropagation: true
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.triggerExpand();
+ } else {
+ self.triggerCollapse();
+ }
+ }
+ });
+ var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
+ var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
+ width: 24,
+ el: this.checkbox
+ }, this.text);
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
+ items: items
+ }))));
+ },
+
+ isOnce: function () {
+ return true;
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.NodeButton.superclass.doClick.apply(this, arguments);
+ },
+
+ setOpened: function (v) {
+ BI.SelectTreePlusGroupNode.superclass.setOpened.apply(this, arguments);
+ if (BI.isNotNull(this.checkbox)) {
+ this.checkbox.setSelected(v);
+ }
+ }
+});
+
+BI.shortcut("bi.select_tree_plus_group_node", BI.SelectTreePlusGroupNode);/**
+ * @class BI.SelectTreeCombo
+ * @extends BI.Widget
+ */
+BI.SelectTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-combo",
+ height: 30,
+ text: "",
+ items: [],
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items,
+ value: o.value
+ });
+
+ this.popup = BI.createWidget({
+ type: "bi.select_level_tree",
+ items: o.items,
+ value: o.value
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ }
+});
+
+
+BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/**
+ * @class BI.SelectTreeExpander
+ * @extends BI.Widget
+ */
+BI.SelectTreeExpander = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-tree-expander",
+ trigger: "",
+ toggle: true,
+ direction: "bottom",
+ isDefaultInit: true,
+ el: {},
+ popup: {}
+ });
+ },
+
+ _init: function () {
+ BI.SelectTreeExpander.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(o.el);
+ this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ if (this.isSelected()) {
+ self.expander.setValue([]);
+ }
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.expander = BI.createWidget({
+ type: "bi.expander",
+ element: this,
+ trigger: o.trigger,
+ toggle: o.toggle,
+ direction: o.direction,
+ isDefaultInit: o.isDefaultInit,
+ el: this.trigger,
+ popup: o.popup
+ });
+ this.expander.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self.trigger.setSelected(false);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ if (BI.contains(v, this.trigger.getValue())) {
+ this.trigger.setSelected(true);
+ this.expander.setValue([]);
+ } else {
+ this.trigger.setSelected(false);
+ this.expander.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (this.trigger.isSelected()) {
+ return [this.trigger.getValue()];
+ }
+ return this.expander.getValue();
+ },
+
+ populate: function (items) {
+ this.expander.populate(items);
+ }
+});
+
+BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/**
+ * @class BI.SelectTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SelectTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-level-tree",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: [],
+ value: ""
+ });
+ },
+
+ _formatItems: function (nodes, layer, pNode) {
+ var self = this;
+ BI.each(nodes, function (i, node) {
+ var extend = {layer: layer};
+ node.id = node.id || BI.UUID();
+ extend.pNode = pNode;
+ if (node.isParent === true || node.parent === true || BI.isNotEmptyArray(node.children)) {
+ extend.type = "bi.select_tree_mid_plus_group_node";
+ if (i === nodes.length - 1) {
+ extend.type = "bi.select_tree_last_plus_group_node";
+ extend.isLastNode = true;
+ }
+ if (i === 0 && !pNode) {
+ extend.type = "bi.select_tree_first_plus_group_node"
+ }
+ if (i === 0 && i === nodes.length - 1) { // 根
+ extend.type = "bi.select_tree_plus_group_node";
+ }
+ BI.defaults(node, extend);
+ self._formatItems(node.children, layer + 1, node);
+ } else {
+ extend.type = "bi.mid_tree_leaf_item";
+ if (i === 0 && !pNode) {
+ extend.type = "bi.first_tree_leaf_item"
+ }
+ if (i === nodes.length - 1) {
+ extend.type = "bi.last_tree_leaf_item";
+ }
+ BI.defaults(node, extend);
+ }
+ });
+ return nodes;
+ },
+
+ _init: function () {
+ BI.SelectTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: "bi.level_tree",
+ expander: {
+ type: "bi.select_tree_expander",
+ isDefaultInit: true
+ },
+ items: this._formatItems(BI.Tree.transformToTreeFormat(o.items), 0),
+ value: o.value,
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SelectTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(items)));
+ }
+});
+
+BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/**
+ * 单选加载数据搜索loader面板
+ * Created by guy on 15/11/4.
+ * @class BI.SingleSelectSearchLoader
+ * @extends Widget
+ */
+BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-search-loader",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ keywordGetter: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectSearchLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+
+ this.button_group = BI.createWidget({
+ type: "bi.single_select_list",
+ allowNoSelect: opts.allowNoSelect,
+ element: this,
+ logic: {
+ dynamic: false
+ },
+ value: opts.value,
+ el: {
+ tipText: BI.i18nText("BI-No_Select"),
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ },
+ itemsCreator: function (op, callback) {
+ self.storeValue && (op = BI.extend(op || {}, {
+ selectedValues: [self.storeValue]
+ }));
+ opts.itemsCreator(op, function (ob) {
+ var keyword = ob.keyword = opts.keywordGetter();
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && BI.isNotNull(self.storeValue)) {
+ var json = self._filterValues(self.storeValue);
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ self.setValue(self.storeValue);
+ }
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ }
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleSelectSearchLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: this.options.allowNoSelect ? "bi.single_select_item" : "bi.single_select_combo_item",
+ cls: "bi-list-item-active",
+ logic: {
+ dynamic: false
+ },
+ height: 25,
+ selected: false
+ });
+ },
+
+ _filterValues: function (src) {
+ var o = this.options;
+ var keyword = o.keywordGetter();
+ var values = src || [];
+ var newValues = BI.map(BI.isArray(values) ? values : [values], function (i, v) {
+ return {
+ text: o.valueFormatter(v) || v,
+ value: v
+ };
+ });
+ if (BI.isKey(keyword)) {
+ var search = BI.Func.getSearchResult(newValues, keyword);
+ values = search.match.concat(search.find);
+ }
+ return BI.map(values, function (i, v) {
+ return {
+ text: v.text,
+ title: v.text,
+ value: v.value,
+ selected: false
+ };
+ });
+ },
+
+ setValue: function (v) {
+ // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了
+ this.storeValue = v;
+ this.button_group.setValue(v);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.SingleSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_select_search_loader", BI.SingleSelectSearchLoader);/**
+ *
+ * 在搜索框中输入文本弹出的面板
+ * @class BI.SingleSelectSearchPane
+ * @extends Widget
+ */
+
+BI.SingleSelectSearchPane = BI.inherit(BI.Widget, {
+
+ constants: {
+ height: 25,
+ lgap: 10,
+ tgap: 5
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-search-pane bi-card",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ keywordGetter: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectSearchPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.tooltipClick = BI.createWidget({
+ type: "bi.label",
+ invisible: true,
+ text: BI.i18nText("BI-Click_Blank_To_Select"),
+ cls: "multi-select-toolbar",
+ height: this.constants.height
+ });
+
+ this.loader = BI.createWidget({
+ type: "bi.single_select_search_loader",
+ allowNoSelect: o.allowNoSelect,
+ keywordGetter: o.keywordGetter,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator.apply(self, [op, function (res) {
+ callback(res);
+ self.setKeyword(o.keywordGetter());
+ }]);
+ },
+ value: o.value
+ });
+ this.loader.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.resizer = BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.tooltipClick,
+ height: 0
+ }, {
+ el: this.loader
+ }]
+ });
+ this.tooltipClick.setVisible(false);
+ },
+
+ setKeyword: function (keyword) {
+ var btn;
+ var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue());
+ if (isVisible !== this.tooltipClick.isVisible()) {
+ this.tooltipClick.setVisible(isVisible);
+ this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
+ this.resizer.resize();
+ }
+ },
+
+ hasMatched: function () {
+ return this.tooltipClick.isVisible();
+ },
+
+ setValue: function (v) {
+ this.loader.setValue(v);
+ },
+
+ getValue: function () {
+ return this.loader.getValue();
+ },
+
+ empty: function () {
+ this.loader.empty();
+ },
+
+ populate: function (items) {
+ this.loader.populate.apply(this.loader, arguments);
+ }
+});
+
+BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.single_select_search_pane", BI.SingleSelectSearchPane);/**
+ *
+ * @class BI.SingleSelectCombo
+ * @extends BI.Single
+ */
+BI.SingleSelectCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-combo",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue = self._startValue);
+ self.trigger.getSearcher().setState(self.storeValue);
+ };
+ this.storeValue = o.value;
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_select_trigger",
+ height: o.height,
+ // adapter: this.popup,
+ allowNoSelect: o.allowNoSelect,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(self.getValue());
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ text: o.text,
+ value: this.storeValue
+ });
+
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () {
+ self._setStartValue();
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue();
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
+ if (this.getSearcher().hasMatched()) {
+ var keyword = this.getSearcher().getKeyword();
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue();
+ }
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue();
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self._defaultState();
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.single_select_popup_view",
+ allowNoSelect: o.allowNoSelect,
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ self._defaultState();
+ });
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ },
+ value: o.value
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "single-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {},
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.SingleSelectCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ if (!this._count) {
+ o.itemsCreator({
+ type: BI.SingleSelectCombo.REQ_GET_DATA_LENGTH
+ }, function (res) {
+ self._count = res.count;
+ adjust();
+ callback();
+ });
+ } else {
+ adjust();
+ callback();
+
+ }
+
+ function adjust () {
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this._count = null;
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.SingleSelectCombo, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.SingleSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.single_select_combo", BI.SingleSelectCombo);
+/**
+ *
+ * @class BI.SingleSelectInsertCombo
+ * @extends BI.Single
+ */
+BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-combo",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ height: 24,
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectInsertCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue = self._startValue);
+ self.trigger.getSearcher().setState(self.storeValue);
+ };
+ this.storeValue = o.value;
+ // 标记正在请求数据
+ this.requesting = false;
+
+ this.trigger = BI.createWidget({
+ type: "bi.single_select_trigger",
+ height: o.height,
+ allowNoSelect: o.allowNoSelect,
+ // adapter: this.popup,
+ valueFormatter: o.valueFormatter,
+ itemsCreator: function (op, callback) {
+ o.itemsCreator(op, function (res) {
+ if (op.times === 1 && BI.isNotNull(op.keywords)) {
+ // 预防trigger内部把当前的storeValue改掉
+ self.trigger.setValue(self.getValue());
+ }
+ callback.apply(self, arguments);
+ });
+ },
+ text: o.text,
+ value: this.storeValue
+ });
+
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () {
+ self._setStartValue();
+ this.getSearcher().setValue(self.storeValue);
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () {
+ self._setStartValue();
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
+ var keyword = this.getSearcher().getKeyword();
+ self.storeValue = keyword;
+ self.combo.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.populate();
+ self._setStartValue();
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
+ var last = BI.last(keywords);
+ keywords = BI.initial(keywords || []);
+ if (keywords.length > 0) {
+ self._joinKeywords(keywords, function () {
+ if (BI.isEndWithBlank(last)) {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ self.combo.populate();
+ self._setStartValue();
+ } else {
+ self.combo.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ });
+
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self._defaultState();
+ });
+ this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () {
+ if (!self.combo.isViewVisible()) {
+ self.combo.showView();
+ }
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ toggle: false,
+ el: this.trigger,
+ adjustLength: 1,
+ popup: {
+ type: "bi.single_select_popup_view",
+ allowNoSelect: o.allowNoSelect,
+ ref: function () {
+ self.popup = this;
+ self.trigger.setAdapter(this);
+ },
+ listeners: [{
+ eventName: BI.SingleSelectPopupView.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self._adjust(function () {
+ assertShowValue();
+ self._defaultState();
+ });
+ }
+ }],
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ onLoaded: function () {
+ BI.nextTick(function () {
+ self.combo.adjustWidth();
+ self.combo.adjustHeight();
+ self.trigger.getSearcher().adjustView();
+ });
+ }
+ },
+ hideChecker: function (e) {
+ return triggerBtn.element.find(e.target).length === 0;
+ },
+ value: o.value
+ });
+
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ this.setValue(self.storeValue);
+ BI.nextTick(function () {
+ self.populate();
+ });
+ });
+ // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
+ this.wants2Quit = false;
+ this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
+ // important:关闭弹出时又可能没有退出编辑状态
+ self.trigger.stopEditing();
+ if (self.requesting === true) {
+ self.wants2Quit = true;
+ } else {
+ self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM);
+ }
+ });
+
+ var triggerBtn = BI.createWidget({
+ type: "bi.trigger_icon_button",
+ width: o.height,
+ height: o.height,
+ cls: "single-select-trigger-icon-button"
+ });
+ triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
+ if (self.combo.isViewVisible()) {
+ self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.combo,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }, {
+ el: triggerBtn,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ },
+
+ _defaultState: function () {
+ this.trigger.stopEditing();
+ this.combo.hideView();
+ },
+
+ _assertValue: function (val) {
+ },
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ this.requesting = true;
+ o.itemsCreator({
+ type: BI.SingleSelectInsertCombo.REQ_GET_ALL_DATA,
+ keywords: keywords
+ }, function (ob) {
+ var values = BI.map(ob.items, "value");
+ digest(values);
+ });
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ BI.remove(self.storeValue.value, val);
+ }
+ });
+ self._adjust(callback);
+ }
+ },
+
+ _adjust: function (callback) {
+ var self = this, o = this.options;
+ adjust();
+ callback();
+
+ function adjust () {
+ if (self.wants2Quit === true) {
+ self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM);
+ self.wants2Quit = false;
+ }
+ self.requesting = false;
+ }
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.popup.setStartValue(value);
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this._assertValue(this.storeValue);
+ this.combo.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ populate: function () {
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+
+BI.extend(BI.SingleSelectInsertCombo, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+
+BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo);/**
+ * guy
+ * 单选框item
+ * @type {*|void|Object}
+ */
+BI.SingleSelectComboItem = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectComboItem.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-single-select-radio-item",
+ logic: {
+ dynamic: false
+ },
+ height: 24
+ });
+ },
+ _init: function () {
+ BI.SingleSelectComboItem.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.radio = BI.createWidget({
+ type: "bi.radio"
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHeight: o.height,
+ height: o.height,
+ hgap: o.hgap,
+ text: o.text,
+ keyword: o.keyword,
+ value: o.value,
+ py: o.py
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", {
+ type: "bi.center_adapt",
+ items: [this.radio],
+ width: 26
+ }, this.text)
+ }))));
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doClick: function () {
+ BI.SingleSelectComboItem.superclass.doClick.apply(this, arguments);
+ this.radio.setSelected(this.isSelected());
+ },
+
+ setSelected: function (v) {
+ BI.SingleSelectComboItem.superclass.setSelected.apply(this, arguments);
+ this.radio.setSelected(v);
+
+ }
+});
+
+BI.shortcut("bi.single_select_combo_item", BI.SingleSelectComboItem);/**
+ * 选择列表
+ *
+ * Created by GUY on 2015/11/1.
+ * @class BI.SingleSelectList
+ * @extends BI.Widget
+ */
+BI.SingleSelectList = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-select-list",
+ direction: BI.Direction.Top, // toolbar的位置
+ logic: {
+ dynamic: true
+ },
+ items: [],
+ itemsCreator: BI.emptyFn,
+ hasNext: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+ el: {
+ type: "bi.list_pane"
+ },
+ allowNoSelect: false
+ });
+ },
+ _init: function () {
+ BI.SingleSelectList.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.list = BI.createWidget(o.el, {
+ type: "bi.list_pane",
+ items: o.items,
+ itemsCreator: function (op, callback) {
+ op.times === 1 && self.toolbar && self.toolbar.setVisible(false);
+ o.itemsCreator(op, function (items) {
+ callback.apply(self, arguments);
+ if (op.times === 1) {
+ self.toolbar && self.toolbar.setVisible(items && items.length > 0);
+ self.toolbar && self.toolbar.setEnable(items && items.length > 0);
+ }
+ });
+ },
+ onLoaded: o.onLoaded,
+ hasNext: o.hasNext,
+ value: o.value
+ });
+
+ this.list.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.SingleSelectList.EVENT_CHANGE, value, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
+ scrolly: true
+ }, o.logic, {
+ items: o.allowNoSelect ? BI.LogicFactory.createLogicItemsByDirection(o.direction, {
+ type: "bi.single_select_item",
+ height: 24,
+ forceNotSelected: true,
+ text: BI.i18nText("BI-Basic_No_Select"),
+ ref: function (_ref) {
+ self.toolbar = _ref;
+ },
+ listeners: [{
+ eventName: BI.Controller.EVENT_CHANGE,
+ action: function (type) {
+ if (type === BI.Events.CLICK) {
+ self.list.setValue();
+ self.fireEvent(BI.SingleSelectList.EVENT_CHANGE);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ }
+ }]
+ }, this.list) : BI.LogicFactory.createLogicItemsByDirection(o.direction, this.list)
+ }))));
+
+ },
+
+ hasPrev: function () {
+ return this.list.hasPrev();
+ },
+
+ hasNext: function () {
+ return this.list.hasNext();
+ },
+
+ prependItems: function (items) {
+ this.list.prependItems.apply(this.list, arguments);
+ },
+
+ addItems: function (items) {
+ this.list.addItems.apply(this.list, arguments);
+ },
+
+ setValue: function (v) {
+ this.list.setValue([v]);
+ },
+
+ getValue: function () {
+ return this.list.getValue()[0];
+ },
+
+ empty: function () {
+ this.list.empty();
+ },
+
+ populate: function (items) {
+ this.list.populate.apply(this.list, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.list.resetHeight ? this.list.resetHeight(h) :
+ this.list.element.css({"max-height": h + "px"});
+ },
+
+ setNotSelectedValue: function () {
+ this.list.setNotSelectedValue.apply(this.list, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.list.getNotSelectedValue();
+ },
+
+ getAllButtons: function () {
+ return this.list.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.list.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.list.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.list.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.list.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.list.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.list.getNodeByValue(value);
+ }
+});
+BI.SingleSelectList.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_select_list", BI.SingleSelectList);/**
+ * 单选加载数据面板
+ * Created by guy on 15/11/2.
+ * @class BI.SingleSelectLoader
+ * @extends Widget
+ */
+BI.SingleSelectLoader = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectLoader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-loader",
+ logic: {
+ dynamic: true
+ },
+ allowNoSelect: false,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectLoader.superclass._init.apply(this, arguments);
+
+ var self = this, opts = this.options;
+ var hasNext = false;
+ this.storeValue = opts.value;
+ this.button_group = BI.createWidget({
+ type: "bi.single_select_list",
+ allowNoSelect: opts.allowNoSelect,
+ logic: opts.logic,
+ el: BI.extend({
+ onLoaded: opts.onLoaded,
+ el: {
+ type: "bi.loader",
+ isDefaultInit: false,
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+ el: {
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ }, opts.el),
+ itemsCreator: function (op, callback) {
+ var startValue = self._startValue;
+ BI.isNotNull(self.storeValue) && (op = BI.extend(op || {}, {
+ selectedValues: [self.storeValue]
+ }));
+ opts.itemsCreator(op, function (ob) {
+ hasNext = ob.hasNext;
+ var firstItems = [];
+ if (op.times === 1 && BI.isNotNull(self.storeValue)) {
+ var json = BI.map([self.storeValue], function (i, v) {
+ var txt = opts.valueFormatter(v) || v;
+ return {
+ text: txt,
+ value: v,
+ title: txt,
+ selected: true
+ };
+ });
+ firstItems = self._createItems(json);
+ }
+ callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
+ if (op.times === 1 && self.storeValue) {
+ BI.isKey(startValue) && (self.storeValue = startValue);
+ self.setValue(self.storeValue);
+ }
+ (op.times === 1) && self._scrollToTop();
+ });
+ },
+ hasNext: function () {
+ return hasNext;
+ },
+ value: this.storeValue
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.button_group],
+ vgap: 5
+ });
+
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleSelectLoader.EVENT_CHANGE, arguments);
+ });
+ },
+
+ _createItems: function (items) {
+ return BI.createItems(items, {
+ type: this.options.allowNoSelect ? "bi.single_select_item" : "bi.single_select_combo_item",
+ logic: this.options.logic,
+ cls: "bi-list-item-active",
+ height: 24,
+ selected: false
+ });
+ },
+
+ _scrollToTop: function () {
+ var self = this;
+ BI.delay(function () {
+ self.button_group.element.scrollTop(0);
+ }, 30);
+ },
+
+ _assertValue: function (val) {},
+
+ setStartValue: function (v) {
+ this._startValue = v;
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this._assertValue(this.storeValue);
+ this.button_group.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.button_group.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.button_group.resetWidth(w);
+ }
+});
+
+BI.SingleSelectLoader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_select_loader", BI.SingleSelectLoader);
+/**
+ * 带加载的单选下拉面板
+ * @class BI.SingleSelectPopupView
+ * @extends Widget
+ */
+BI.SingleSelectPopupView = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectPopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-popup-view",
+ allowNoSelect: false,
+ maxWidth: "auto",
+ minWidth: 135,
+ maxHeight: 400,
+ valueFormatter: BI.emptyFn,
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectPopupView.superclass._init.apply(this, arguments);
+ var self = this, opts = this.options;
+
+ this.loader = BI.createWidget({
+ type: "bi.single_select_loader",
+ allowNoSelect: opts.allowNoSelect,
+ itemsCreator: opts.itemsCreator,
+ valueFormatter: opts.valueFormatter,
+ onLoaded: opts.onLoaded,
+ value: opts.value
+ });
+
+ this.popupView = BI.createWidget({
+ type: "bi.popup_view",
+ stopPropagation: false,
+ maxWidth: opts.maxWidth,
+ minWidth: opts.minWidth,
+ maxHeight: opts.maxHeight,
+ element: this,
+ el: this.loader,
+ value: opts.value
+ });
+
+ this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleSelectPopupView.EVENT_CHANGE);
+ });
+ },
+
+ setStartValue: function (v) {
+ this.loader.setStartValue(v);
+ },
+
+ setValue: function (v) {
+ this.popupView.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popupView.getValue();
+ },
+
+ populate: function (items) {
+ this.popupView.populate.apply(this.popupView, arguments);
+ },
+
+ resetHeight: function (h) {
+ this.popupView.resetHeight(h);
+ },
+
+ resetWidth: function (w) {
+ this.popupView.resetWidth(w);
+ }
+});
+
+BI.SingleSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE";
+
+
+BI.shortcut("bi.single_select_popup_view", BI.SingleSelectPopupView);/**
+ *
+ * 单选下拉框
+ * @class BI.SingleSelectTrigger
+ * @extends BI.Trigger
+ */
+
+BI.SingleSelectTrigger = BI.inherit(BI.Trigger, {
+
+ constants: {
+ height: 14,
+ rgap: 4,
+ lgap: 4
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-trigger bi-border",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn,
+ searcher: {},
+ switcher: {},
+
+ adapter: null,
+ masker: {}
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ if (o.height) {
+ this.setHeight(o.height - 2);
+ }
+
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.single_select_searcher",
+ allowNoSelect: o.allowNoSelect,
+ text: o.text,
+ height: o.height,
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ popup: {},
+ adapter: o.adapter,
+ masker: o.masker,
+ value: o.value
+ });
+ this.searcher.on(BI.SingleSelectSearcher.EVENT_START, function () {
+ self.fireEvent(BI.SingleSelectTrigger.EVENT_START);
+ });
+ this.searcher.on(BI.SingleSelectSearcher.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SingleSelectTrigger.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.SingleSelectSearcher.EVENT_SEARCHING, function () {
+ self.fireEvent(BI.SingleSelectTrigger.EVENT_SEARCHING, arguments);
+ });
+ this.searcher.on(BI.SingleSelectSearcher.EVENT_STOP, function () {
+ self.fireEvent(BI.SingleSelectTrigger.EVENT_STOP);
+ });
+ this.searcher.on(BI.SingleSelectSearcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleSelectTrigger.EVENT_CHANGE, arguments);
+ });
+
+ var wrapper = BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ items: [
+ {
+ el: this.searcher,
+ width: "fill"
+ }, {
+ el: BI.createWidget(),
+ width: 24
+ }]
+ });
+ },
+
+ getSearcher: function () {
+ return this.searcher;
+ },
+
+ stopEditing: function () {
+ this.searcher.stopSearch();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setValue: function (v) {
+ this.searcher.setValue(v);
+ },
+
+ getKey: function () {
+ return this.searcher.getKey();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ }
+});
+
+BI.SingleSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK";
+BI.SingleSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK";
+BI.SingleSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SingleSelectTrigger.EVENT_START = "EVENT_START";
+BI.SingleSelectTrigger.EVENT_STOP = "EVENT_STOP";
+BI.SingleSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SingleSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.SingleSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
+
+BI.shortcut("bi.single_select_trigger", BI.SingleSelectTrigger);/**
+ * @author: Teller
+ * @createdAt: 2018/3/28
+ * @Description
+*/
+BI.SingleSelectInsertList = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectInsertList.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-multi-select-insert-list",
+ allowNoSelect: false,
+ itemsCreator: BI.emptyFn,
+ valueFormatter: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.SingleSelectInsertList.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ this.storeValue = o.value;
+
+ var assertShowValue = function () {
+ BI.isKey(self._startValue) && (self.storeValue = self._startValue);
+ // self.trigger.setValue(self.storeValue);
+ };
+
+ this.adapter = BI.createWidget({
+ type: "bi.single_select_loader",
+ allowNoSelect: o.allowNoSelect,
+ cls: "popup-single-select-list bi-border-left bi-border-right bi-border-bottom",
+ itemsCreator: o.itemsCreator,
+ valueFormatter: o.valueFormatter,
+ logic: {
+ dynamic: true
+ },
+ // onLoaded: o.onLoaded,
+ el: {},
+ value: o.value
+ });
+ this.adapter.on(BI.SingleSelectLoader.EVENT_CHANGE, function () {
+ self.storeValue = this.getValue();
+ assertShowValue();
+ self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
+ });
+
+ this.searcherPane = BI.createWidget({
+ type: "bi.single_select_search_pane",
+ allowNoSelect: o.allowNoSelect,
+ cls: "bi-border-left bi-border-right bi-border-bottom",
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.trigger.getKeyword();
+ },
+ itemsCreator: function (op, callback) {
+ op.keywords = [self.trigger.getKeyword()];
+ this.setKeyword(op.keywords[0]);
+ o.itemsCreator(op, callback);
+ }
+ });
+ this.searcherPane.setVisible(false);
+
+ 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,
+ value: o.value,
+ listeners: [{
+ eventName: BI.Searcher.EVENT_START,
+ action: function () {
+ self._showSearcherPane();
+ self._setStartValue();
+ this.setValue(BI.deepClone(self.storeValue));
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_STOP,
+ action: function () {
+ self._showAdapter();
+ self._setStartValue();
+ self.adapter.setValue(self.storeValue);
+ // 需要刷新回到初始界面,否则搜索的结果不能放在最前面
+ self.adapter.populate();
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_PAUSE,
+ action: function () {
+ var keyword = this.getKeyword();
+ self.storeValue = keyword;
+ self._showAdapter();
+ self.adapter.setValue(self.storeValue);
+ self._setStartValue(keyword);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue();
+ self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
+ }
+ }, {
+ 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.adapter.setValue(self.storeValue);
+ assertShowValue();
+ self.adapter.populate();
+ self._setStartValue();
+ } else {
+ self.adapter.setValue(self.storeValue);
+ assertShowValue();
+ }
+ });
+ }
+ }
+ }, {
+ eventName: BI.Searcher.EVENT_CHANGE,
+ action: function () {
+ self.storeValue = this.getValue();
+ self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
+ }
+ }]
+ });
+
+ BI.createWidget({
+ type: "bi.vtape",
+ element: this,
+ items: [{
+ el: this.trigger,
+ height: 24
+ }, {
+ el: this.adapter,
+ height: "fill"
+ }]
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.searcherPane,
+ top: 24,
+ 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();
+ },
+
+ _assertValue: function () {},
+
+ _makeMap: function (values) {
+ return BI.makeObject(values || []);
+ },
+
+ _joinKeywords: function (keywords, callback) {
+ var self = this, o = this.options;
+ this._assertValue(this.storeValue);
+ if (!this._allData) {
+ o.itemsCreator({
+ type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA
+ }, function (ob) {
+ self._allData = BI.map(ob.items, "value");
+ digest(self._allData);
+ });
+ } else {
+ digest(this._allData);
+ }
+
+ function digest (items) {
+ var selectedMap = self._makeMap(items);
+ BI.each(keywords, function (i, val) {
+ if (BI.isNotNull(selectedMap[val])) {
+ self.storeValue.type === BI.Selection.Single ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
+ }
+ });
+ callback();
+ }
+ },
+
+ _setStartValue: function (value) {
+ this._startValue = value;
+ this.adapter.setStartValue(value);
+ },
+
+ isAllSelected: function () {
+ return this.adapter.isAllSelected();
+ },
+
+ resize: function () {
+ // this.trigger.getCounter().adjustView();
+ // this.trigger.adjustView();
+ },
+ setValue: function (v) {
+ this.storeValue = v;
+ this.adapter.setValue(this.storeValue);
+ this.trigger.setValue(this.storeValue);
+ },
+
+ getValue: function () {
+ return BI.deepClone(this.storeValue);
+ },
+
+ populate: function () {
+ this._count = null;
+ this._allData = null;
+ this.adapter.populate.apply(this.adapter, arguments);
+ this.trigger.populate.apply(this.trigger, arguments);
+ }
+});
+
+BI.extend(BI.SingleSelectInsertList, {
+ REQ_GET_DATA_LENGTH: 0,
+ REQ_GET_ALL_DATA: -1
+});
+
+BI.SingleSelectInsertList.EVENT_CHANGE = "BI.SingleSelectInsertList.EVENT_CHANGE";
+BI.shortcut("bi.single_select_insert_list", BI.SingleSelectInsertList);
+/**
+ * 单选输入框
+ * Created by guy on 15/11/3.
+ * @class BI.SingleSelectEditor
+ * @extends Widget
+ */
+BI.SingleSelectEditor = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectEditor.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-editor",
+ el: {}
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.state_editor",
+ element: this,
+ height: o.height,
+ watermark: BI.i18nText("BI-Basic_Search"),
+ allowBlank: true,
+ value: o.value,
+ text: o.text
+ });
+
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
+ self.fireEvent(BI.SingleSelectEditor.EVENT_PAUSE);
+ });
+ this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () {
+
+ });
+ },
+
+ focus: function () {
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ },
+
+ setState: function (state) {
+ this.editor.setState(state);
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ },
+
+ getValue: function () {
+ var v = this.editor.getState();
+ if (BI.isArray(v) && v.length > 0) {
+ return v[v.length - 1];
+ }
+ return "";
+
+ },
+
+ getKeywords: function () {
+ var val = this.editor.getLastValidValue();
+ var keywords = val.match(/[\S]+/g);
+ if (BI.isEndWithBlank(val)) {
+ return keywords.concat([" "]);
+ }
+ return keywords;
+ },
+
+ populate: function (items) {
+
+ }
+});
+BI.SingleSelectEditor.EVENT_PAUSE = "SingleSelectEditor.EVENT_PAUSE";
+BI.shortcut("bi.single_select_editor", BI.SingleSelectEditor);/**
+ * searcher
+ * Created by guy on 15/11/3.
+ * @class BI.SingleSelectSearcher
+ * @extends Widget
+ */
+BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-select-searcher",
+ itemsCreator: BI.emptyFn,
+ el: {},
+ popup: {},
+ valueFormatter: BI.emptyFn,
+ adapter: null,
+ masker: {},
+ allowNoSelect: false
+ });
+ },
+
+ _init: function () {
+ BI.SingleSelectSearcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.single_select_editor",
+ height: o.height,
+ text: o.text
+ });
+
+ this.searcher = BI.createWidget({
+ type: "bi.searcher",
+ element: this,
+ height: o.height,
+ isAutoSearch: false,
+ isAutoSync: false,
+ onSearch: function (op, callback) {
+ callback();
+ },
+ el: this.editor,
+
+ popup: BI.extend({
+ type: "bi.single_select_search_pane",
+ allowNoSelect: o.allowNoSelect,
+ valueFormatter: o.valueFormatter,
+ keywordGetter: function () {
+ return self.editor.getValue();
+ },
+ itemsCreator: function (op, callback) {
+ var keyword = self.editor.getValue();
+ op.keywords = [keyword];
+ this.setKeyword(keyword);
+ o.itemsCreator(op, callback);
+ },
+ value: o.value
+ }, o.popup),
+
+ adapter: o.adapter,
+ masker: o.masker
+ });
+ this.searcher.on(BI.Searcher.EVENT_START, function () {
+ self.fireEvent(BI.SingleSelectSearcher.EVENT_START);
+ });
+ this.searcher.on(BI.Searcher.EVENT_PAUSE, function () {
+ if (this.hasMatched()) {
+
+ }
+ self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE);
+ });
+ this.searcher.on(BI.Searcher.EVENT_STOP, function () {
+ self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP);
+ });
+ this.searcher.on(BI.Searcher.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments);
+ });
+ this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () {
+ var keywords = this.getKeywords();
+ self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords);
+ });
+
+ if(BI.isNotNull(o.value)){
+ this.setState(o.value);
+ }
+ },
+
+ adjustView: function () {
+ this.searcher.adjustView();
+ },
+
+ isSearching: function () {
+ return this.searcher.isSearching();
+ },
+
+ stopSearch: function () {
+ this.searcher.stopSearch();
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ hasMatched: function () {
+ return this.searcher.hasMatched();
+ },
+
+ hasChecked: function () {
+ return this.searcher.getView() && this.searcher.getView().hasChecked();
+ },
+
+ setAdapter: function (adapter) {
+ this.searcher.setAdapter(adapter);
+ },
+
+ setState: function (v) {
+ var o = this.options;
+ if (BI.isNull(v)) {
+ this.editor.setState(BI.Selection.None);
+ } else {
+ this.editor.setState(o.valueFormatter(v + "") || (v + ""));
+ }
+ },
+
+ setValue: function (ob) {
+ this.setState(ob);
+ this.searcher.setValue(ob);
+ },
+
+ getKey: function () {
+ return this.editor.getValue();
+ },
+
+ getValue: function () {
+ return this.searcher.getValue();
+ },
+
+ populate: function (items) {
+ this.searcher.populate.apply(this.searcher, arguments);
+ }
+});
+
+BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.SingleSelectSearcher.EVENT_START = "EVENT_START";
+BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP";
+BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.shortcut("bi.single_select_searcher", BI.SingleSelectSearcher);
+/**
+ * Created by User on 2017/11/16.
+ */
+BI.SignTextEditor = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
+ validationChecker: BI.emptyFn,
+ text: "",
+ height: 24
+ });
+ },
+
+ _init: function () {
+ BI.SignTextEditor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = BI.createWidget({
+ type: "bi.editor",
+ height: o.height,
+ hgap: 4,
+ vgap: 2,
+ value: o.value,
+ validationChecker: o.validationChecker,
+ allowBlank: false
+ });
+ this.text = BI.createWidget({
+ type: "bi.text_button",
+ cls: "sign-editor-text",
+ title: function () {
+ return self.getValue();
+ },
+ textAlign: o.textAlign,
+ height: o.height,
+ hgap: 4,
+ handler: function () {
+ self._showInput();
+ self.editor.focus();
+ self.editor.selectAll();
+ }
+ });
+ this.text.on(BI.TextButton.EVENT_CHANGE, function () {
+ BI.nextTick(function () {
+ self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL);
+ });
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: this.text,
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
+ self._showHint();
+ self._checkText();
+ self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments);
+ });
+ this.editor.on(BI.Editor.EVENT_ERROR, function () {
+ self._checkText();
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [this.editor]
+ });
+ this._showHint();
+ self._checkText();
+ },
+
+ _checkText: function () {
+ var o = this.options;
+ BI.nextTick(BI.bind(function () {
+ if (this.editor.getValue() === "") {
+ this.text.setValue(o.watermark || "");
+ this.text.element.addClass("bi-water-mark");
+ } else {
+ var v = this.editor.getValue();
+ v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
+ this.text.setValue(v);
+ this.text.element.removeClass("bi-water-mark");
+ }
+ }, this));
+ },
+
+ _showInput: function () {
+ this.editor.visible();
+ this.text.invisible();
+ },
+
+ _showHint: function () {
+ this.editor.invisible();
+ this.text.visible();
+ },
+
+ setTitle: function (title) {
+ this.text.setTitle(title);
+ },
+
+ setWarningTitle: function (title) {
+ this.text.setWarningTitle(title);
+ },
+
+ focus: function () {
+ this._showInput();
+ this.editor.focus();
+ },
+
+ blur: function () {
+ this.editor.blur();
+ this._showHint();
+ this._checkText();
+ },
+
+ doRedMark: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
+ return;
+ }
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ isValid: function () {
+ return this.editor.isValid();
+ },
+
+ setErrorText: function (text) {
+ this.editor.setErrorText(text);
+ },
+
+ getErrorText: function () {
+ return this.editor.getErrorText();
+ },
+
+ isEditing: function () {
+ return this.editor.isEditing();
+ },
+
+ getLastValidValue: function () {
+ return this.editor.getLastValidValue();
+ },
+
+ setValue: function (v) {
+ this.editor.setValue(v);
+ this._checkText();
+ },
+
+ getValue: function () {
+ return this.editor.getValue();
+ },
+
+ getState: function () {
+ return this.text.getValue();
+ },
+
+ setState: function (v) {
+ var o = this.options;
+ this._showHint();
+ v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text;
+ this.text.setValue(v);
+ }
+});
+BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.SignTextEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL";
+
+BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.SliderIconButton = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-single-slider-button"
+ },
+
+ constants: {
+ LARGE_SIZE: 16,
+ NORMAL_SIZE: 12,
+ LARGE_OFFSET: 4,
+ NORMAL_OFFSET: 6
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.absolute",
+ ref: function () {
+ self.wrapper = this;
+ },
+ items: [{
+ el: {
+ type: "bi.text_button",
+ forceNotSelected: true,
+ cls: "slider-button bi-list-item-select3 bi-high-light-border",
+ ref: function () {
+ self.slider = this;
+ }
+ }
+ }]
+ };
+ }
+});
+BI.shortcut("bi.single_slider_button", BI.SliderIconButton);/**
+ * Created by zcf on 2016/9/22.
+ */
+BI.SingleSlider = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 90,
+ EDITOR_HEIGHT: 30,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ props: {
+ baseCls: "bi-single-slider bi-slider-track",
+ digit: false,
+ unit: ""
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ var c = this._constant;
+ this.enable = false;
+ this.value = "";
+
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 6
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 6
+ });
+ this.track = this._createTrackWrapper();
+
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_button"
+ });
+ this._draggable(this.slider);
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ // 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点
+ sliderVertical.element.click(function (e) {
+ if (self.enable && self.isEnabled()) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0;
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100;
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ self.label.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+ this.label = BI.createWidget({
+ type: "bi.sign_text_editor",
+ cls: "slider-editor-button",
+ text: o.unit,
+ width: c.EDITOR_WIDTH - 2,
+ allowBlank: false,
+ textAlign: "center",
+ validationChecker: function (v) {
+ return self._checkValidation(v);
+ }
+ });
+ this.label.element.hover(function () {
+ self.label.element.removeClass("bi-border").addClass("bi-border");
+ }, function () {
+ self.label.element.removeClass("bi-border");
+ });
+ this.label.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var v = BI.parseFloat(this.getValue());
+ var percent = self._getPercentByValue(v);
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ this.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ });
+ this._setVisible(false);
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 23,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 20,
+ left: 0,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.horizontal_auto",
+ items: [this.label]
+ }],
+ height: c.EDITOR_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ };
+ },
+
+ _draggable: function (widget) {
+ var self = this, o = this.options;
+ var startDrag = false;
+ var size = 0, offset = 0, defaultSize = 0;
+ var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
+ if (mouseMoveTracker.isDragging()) {
+ startDrag = true;
+ offset += deltaX;
+ size = optimizeSize(defaultSize + offset);
+ widget.element.addClass("dragging");
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setLabelPosition(significantPercent);
+ self._setSliderPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ self.label.setValue(v);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ }, function () {
+ if (startDrag === true) {
+ size = optimizeSize(size);
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ size = 0;
+ offset = 0;
+ defaultSize = size;
+ startDrag = false;
+ }
+ widget.element.removeClass("dragging");
+ mouseMoveTracker.releaseMouseMoves();
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }, window);
+ widget.element.on("mousedown", function (event) {
+ if(!widget.isEnabled()) {
+ return;
+ }
+ defaultSize = this.offsetLeft;
+ optimizeSize(defaultSize);
+ mouseMoveTracker.captureMouseMoves(event);
+ });
+
+ function optimizeSize (s) {
+ return BI.clamp(s, 0, self._getGrayTrackLength());
+ }
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ });
+ },
+
+ _checkValidation: function (v) {
+ var o = this.options;
+ var valid = false;
+ if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) {
+ if(o.digit === false) {
+ valid = true;
+ }else{
+ var dotText = (v + "").split(".")[1] || "";
+ valid = (dotText.length === o.digit);
+ }
+ }
+ return valid;
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({width: percent + "%"});
+ },
+
+ _setLabelPosition: function (percent) {
+ // this.label.element.css({left: percent + "%"});
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({left: percent + "%"});
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setLabelPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ this.label.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth;
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ v = BI.parseFloat(v);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ if ((!isNaN(v))) {
+ if (this._checkValidation(v)) {
+ this.value = v;
+ }
+ if (v > this.max) {
+ this.value = this.max;
+ }
+ if (v < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ _setEnable: function (b) {
+ BI.SingleSlider.superclass._setEnable.apply(this, [b]);
+ if(b) {
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
+ } else {
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ this.label.setErrorText(BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max));
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this.label.setValue(this.value);
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this.label.setValue(this.max);
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_slider", BI.SingleSlider);/**
+ * Created by Urthur on 2017/9/12.
+ */
+BI.SingleSliderLabel = BI.inherit(BI.Widget, {
+ _constant: {
+ EDITOR_WIDTH: 90,
+ EDITOR_HEIGHT: 20,
+ HEIGHT: 20,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-slider-label bi-slider-track",
+ digit: false,
+ unit: ""
+ });
+ },
+ _init: function () {
+ BI.SingleSliderLabel.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+ var c = this._constant;
+ this.enable = false;
+ this.value = "";
+
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 6
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 6
+ });
+ this.track = this._createTrackWrapper();
+
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_button"
+ });
+ this._draggable(this.slider);
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ sliderVertical.element.click(function (e) {
+ if (self.enable && self.isEnabled()) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0;
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100;
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ self.label.setText(v + o.unit);
+ self.value = v;
+ self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
+ }
+ });
+ this.label = BI.createWidget({
+ type: "bi.label",
+ height: c.HEIGHT,
+ width: c.EDITOR_WIDTH - 2
+ });
+
+ this._setVisible(false);
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 13,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 10,
+ left: 0,
+ width: "100%"
+ }, {
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.horizontal_auto",
+ items: [this.label]
+ }],
+ height: c.EDITOR_HEIGHT
+ },
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ });
+ },
+
+ _draggable: function (widget) {
+ var self = this, o = this.options;
+ var startDrag = false;
+ var size = 0, offset = 0, defaultSize = 0;
+ var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
+ if (mouseMoveTracker.isDragging()) {
+ startDrag = true;
+ offset += deltaX;
+ size = optimizeSize(defaultSize + offset);
+ widget.element.addClass("dragging");
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setLabelPosition(significantPercent);
+ self._setSliderPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ self.label.setValue(v + o.unit);
+ self.value = v;
+ self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
+ }
+ }, function () {
+ if (startDrag === true) {
+ size = optimizeSize(size);
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ size = 0;
+ offset = 0;
+ defaultSize = size;
+ startDrag = false;
+ }
+ widget.element.removeClass("dragging");
+ mouseMoveTracker.releaseMouseMoves();
+ self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE);
+ }, window);
+ widget.element.on("mousedown", function (event) {
+ if(!widget.isEnabled()) {
+ return;
+ }
+ defaultSize = this.offsetLeft;
+ optimizeSize(defaultSize);
+ mouseMoveTracker.captureMouseMoves(event);
+ });
+
+ function optimizeSize (s) {
+ return BI.clamp(s, 0, self._getGrayTrackLength());
+ }
+ },
+
+ _createTrackWrapper: function () {
+ return BI.createWidget({
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }]
+ });
+ },
+
+ _checkValidation: function (v) {
+ return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max);
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({width: percent + "%"});
+ },
+
+ _setLabelPosition: function (percent) {
+ // this.label.element.css({left: percent + "%"});
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({left: percent + "%"});
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setLabelPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ this.label.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth;
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setEnable: function (b) {
+ BI.SingleSliderLabel.superclass._setEnable.apply(this, [b]);
+ if(b) {
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
+ } else {
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
+ }
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ v = BI.parseFloat(v);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ if ((!isNaN(v))) {
+ if (this._checkValidation(v)) {
+ this.value = v;
+ }
+ if (v > this.max) {
+ this.value = this.max;
+ }
+ if (v < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+ },
+
+ populate: function () {
+ var o = this.options;
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this.label.setValue(this.value + o.unit);
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this.label.setValue(this.max + o.unit);
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSliderLabel.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_slider_label", BI.SingleSliderLabel);/**
+ * normal single slider
+ * Created by Young on 2017/6/21.
+ */
+BI.SingleSliderNormal = BI.inherit(BI.Widget, {
+
+ _constant: {
+ HEIGHT: 28,
+ SLIDER_WIDTH_HALF: 15,
+ SLIDER_WIDTH: 30,
+ SLIDER_HEIGHT: 30,
+ TRACK_HEIGHT: 24
+ },
+
+ props: {
+ baseCls: "bi-single-slider-normal bi-slider-track",
+ minMax: {
+ min: 0,
+ max: 100
+ }
+ // color: "#3f8ce8"
+ },
+
+ render: function () {
+ var self = this;
+ var c = this._constant;
+ var track = this._createTrack();
+ this.slider = BI.createWidget({
+ type: "bi.single_slider_button"
+ });
+ this._draggable(this.slider);
+
+ var sliderVertical = BI.createWidget({
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [this.slider]
+ }],
+ hgap: c.SLIDER_WIDTH_HALF,
+ height: c.SLIDER_HEIGHT
+ });
+ sliderVertical.element.click(function (e) {
+ if (self.enable && self.isEnabled()) {
+ var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF;
+ var trackLength = self.track.element[0].scrollWidth;
+ var percent = 0;
+ if (offset < 0) {
+ percent = 0;
+ }
+ if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) {
+ percent = offset * 100 / self._getGrayTrackLength();
+ }
+ if (offset > (trackLength - c.SLIDER_WIDTH)) {
+ percent = 100;
+ }
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setAllPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ self.value = v;
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }
+ });
+
+ return {
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: track,
+ width: "100%",
+ height: c.TRACK_HEIGHT
+ }]
+ }],
+ hgap: 7,
+ height: c.TRACK_HEIGHT
+ },
+ top: 3,
+ left: 0,
+ width: "100%"
+ }, {
+ el: sliderVertical,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }]
+ };
+ },
+
+ _draggable: function (widget) {
+ var self = this, o = this.options;
+ var startDrag = false;
+ var size = 0, offset = 0, defaultSize = 0;
+ var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) {
+ if (mouseMoveTracker.isDragging()) {
+ startDrag = true;
+ offset += deltaX;
+ size = optimizeSize(defaultSize + offset);
+ widget.element.addClass("dragging");
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。
+ self._setBlueTrack(significantPercent);
+ self._setSliderPosition(significantPercent);
+ var v = self._getValueByPercent(significantPercent);
+ v = o.digit === false ? v : v.toFixed(o.digit);
+ self.value = v;
+ self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v);
+ }
+ }, function () {
+ if (startDrag === true) {
+ size = optimizeSize(size);
+ var percent = size * 100 / (self._getGrayTrackLength());
+ var significantPercent = BI.parseFloat(percent.toFixed(1));
+ self._setSliderPosition(significantPercent);
+ size = 0;
+ offset = 0;
+ defaultSize = size;
+ startDrag = false;
+ }
+ widget.element.removeClass("dragging");
+ mouseMoveTracker.releaseMouseMoves();
+ self.fireEvent(BI.SingleSlider.EVENT_CHANGE);
+ }, window);
+ widget.element.on("mousedown", function (event) {
+ if(!widget.isEnabled()) {
+ return;
+ }
+ defaultSize = this.offsetLeft;
+ optimizeSize(defaultSize);
+ mouseMoveTracker.captureMouseMoves(event);
+ });
+
+ function optimizeSize (s) {
+ return BI.clamp(s, 0, self._getGrayTrackLength());
+ }
+ },
+
+ _createTrack: function () {
+ var self = this;
+ var c = this._constant;
+ this.grayTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "gray-track",
+ height: 6
+ });
+ this.blueTrack = BI.createWidget({
+ type: "bi.layout",
+ cls: "blue-track bi-high-light-background",
+ height: 6
+ });
+ if (this.options.color) {
+ this.blueTrack.element.css({"background-color": this.options.color});
+ }
+
+ return {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: this.grayTrack,
+ top: 0,
+ left: 0,
+ width: "100%"
+ }, {
+ el: this.blueTrack,
+ top: 0,
+ left: 0,
+ width: "0%"
+ }]
+ }],
+ hgap: 8,
+ height: 8
+ },
+ top: 8,
+ left: 0,
+ width: "100%"
+ }],
+ ref: function (ref) {
+ self.track = ref;
+ }
+ };
+ },
+
+ _checkValidation: function (v) {
+ return !(BI.isNull(v) || v < this.min || v > this.max);
+ },
+
+ _setBlueTrack: function (percent) {
+ this.blueTrack.element.css({width: percent + "%"});
+ },
+
+ _setSliderPosition: function (percent) {
+ this.slider.element.css({left: percent + "%"});
+ },
+
+ _setAllPosition: function (percent) {
+ this._setSliderPosition(percent);
+ this._setBlueTrack(percent);
+ },
+
+ _setVisible: function (visible) {
+ this.slider.setVisible(visible);
+ },
+
+ _getGrayTrackLength: function () {
+ return this.grayTrack.element[0].scrollWidth;
+ },
+
+ _getValueByPercent: function (percent) {
+ var thousandth = BI.parseInt(percent * 10);
+ return (((this.max - this.min) * thousandth) / 1000 + this.min);
+ },
+
+ _getPercentByValue: function (v) {
+ return (v - this.min) * 100 / (this.max - this.min);
+ },
+
+ _setEnable: function (b) {
+ BI.SingleSliderNormal.superclass._setEnable.apply(this, [b]);
+ if(b) {
+ this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track");
+ } else {
+ this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track");
+ }
+ },
+
+ getValue: function () {
+ return this.value;
+ },
+
+ setValue: function (v) {
+ var value = BI.parseFloat(v);
+ if ((!isNaN(value))) {
+ if (this._checkValidation(value)) {
+ this.value = value;
+ }
+ if (value > this.max) {
+ this.value = this.max;
+ }
+ if (value < this.min) {
+ this.value = this.min;
+ }
+ }
+ },
+
+ setMinAndMax: function (v) {
+ var minNumber = BI.parseFloat(v.min);
+ var maxNumber = BI.parseFloat(v.max);
+ if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) {
+ this.min = minNumber;
+ this.max = maxNumber;
+ }
+ },
+
+ reset: function () {
+ this._setVisible(false);
+ this.enable = false;
+ this.value = "";
+ this.min = 0;
+ this.max = 0;
+ this._setBlueTrack(0);
+ },
+
+ populate: function () {
+ if (!isNaN(this.min) && !isNaN(this.max)) {
+ this._setVisible(true);
+ this.enable = true;
+ if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) {
+ this._setAllPosition(this._getPercentByValue(this.value));
+ } else {
+ this._setAllPosition(100);
+ }
+ }
+ }
+});
+BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG";
+BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);/**
+ * @class BI.SingleTreeCombo
+ * @extends BI.Widget
+ */
+BI.SingleTreeCombo = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-combo",
+ trigger: {},
+ height: 24,
+ text: "",
+ items: [],
+ value: "",
+ attributes: {
+ tabIndex: 0
+ }
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget(BI.extend({
+ type: "bi.single_tree_trigger",
+ text: o.text,
+ height: o.height,
+ items: o.items,
+ value: o.value
+ }, o.trigger));
+
+ this.popup = BI.createWidget({
+ type: "bi.single_level_tree",
+ items: o.items,
+ value: o.value
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ element: this,
+ adjustLength: 2,
+ el: this.trigger,
+ popup: {
+ el: this.popup
+ }
+ });
+
+ this.combo.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments);
+ });
+
+ this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE);
+ });
+ },
+
+ populate: function (items) {
+ this.combo.populate(items);
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.trigger.setValue(v);
+ this.popup.setValue(v);
+ },
+
+ getValue: function () {
+ return this.popup.getValue();
+ }
+});
+
+BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE";
+BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/**
+ * @class BI.SingleTreePopup
+ * @extends BI.Pane
+ */
+
+BI.SingleTreePopup = BI.inherit(BI.Pane, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-level-tree",
+ tipText: BI.i18nText("BI-No_Selected_Item"),
+ items: [],
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreePopup.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.tree = BI.createWidget({
+ type: "bi.level_tree",
+ expander: {
+ isDefaultInit: true
+ },
+ items: o.items,
+ value: o.value,
+ chooseType: BI.Selection.Single
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ vgap: 5,
+ items: [this.tree]
+ });
+
+ this.tree.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.tree.on(BI.LevelTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE);
+ });
+
+ this.check();
+ },
+
+ getValue: function () {
+ return this.tree.getValue();
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.tree.setValue(v);
+ },
+
+ populate: function (items) {
+ BI.SingleTreePopup.superclass.populate.apply(this, arguments);
+ this.tree.populate(items);
+ }
+});
+
+BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.single_level_tree", BI.SingleTreePopup);/**
+ * @class BI.SingleTreeTrigger
+ * @extends BI.Trigger
+ */
+
+BI.SingleTreeTrigger = BI.inherit(BI.Trigger, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-single-tree-trigger",
+ height: 24,
+ text: "",
+ items: [],
+ value: ""
+ });
+ },
+
+ _init: function () {
+ BI.SingleTreeTrigger.superclass._init.apply(this, arguments);
+
+ var self = this, o = this.options;
+
+ this.trigger = BI.createWidget({
+ type: "bi.select_text_trigger",
+ element: this,
+ text: o.text,
+ items: o.items,
+ height: o.height,
+ value: o.value
+ });
+ },
+
+ _checkTitle: function () {
+ var self = this, val = this.getValue();
+ BI.any(this.options.items, function (i, item) {
+ if (BI.contains(val, item.value)) {
+ self.trigger.setTitle(item.text || item.value);
+ return true;
+ }
+ });
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ this.options.value = v;
+ this.trigger.setValue(v);
+ this._checkTitle();
+ },
+
+ getValue: function () {
+ return this.options.value || [];
+ },
+
+ populate: function (items) {
+ BI.SingleTreeTrigger.superclass.populate.apply(this, arguments);
+ this.trigger.populate(items);
+ }
+
+});
+
+BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);!(function () {
+ BI.TimePopup = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "bi-date-time-popup",
+ height: 68
+ },
+ render: function () {
+ var self = this, o = this.options;
+
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: {
+ type: "bi.center_adapt",
+ cls: "bi-split-top",
+ items: [{
+ type: "bi.dynamic_date_time_select",
+ value: o.value,
+ ref: function (_ref) {
+ self.timeSelect = _ref;
+ }
+ }]
+ },
+ hgap: 10,
+ height: 44
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Clears"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.TimePopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Now"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.TimePopup.BUTTON_NOW_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-high-light bi-split-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.TimePopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ var value = v;
+ if (BI.isNull(value)) {
+ var date = BI.getDate();
+ this.timeSelect.setValue({
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds()
+ });
+ } else {
+ this.timeSelect.setValue({
+ hour: value.hour,
+ minute: value.minute,
+ second: value.second
+ });
+ }
+ },
+
+ getValue: function () {
+ return this.timeSelect.getValue();
+ }
+ });
+ BI.TimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+ BI.TimePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+ BI.TimePopup.BUTTON_NOW_EVENT_CHANGE = "BUTTON_NOW_EVENT_CHANGE";
+ BI.TimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
+ BI.shortcut("bi.time_popup", BI.TimePopup);
+})();/**
+ * 时间选择
+ * qcc
+ * 2019/2/28
+ */
+
+!(function () {
+ BI.TimeCombo = BI.inherit(BI.Single, {
+ constants: {
+ popupHeight: 80,
+ popupWidth: 240,
+ comboAdjustHeight: 1,
+ border: 1
+ },
+ props: {
+ baseCls: "bi-time-combo bi-border bi-border-radius",
+ width: 78,
+ height: 22
+ },
+
+ render: function () {
+ var self = this, opts = this.options;
+
+ this.storeValue = opts.value;
+
+ var popup = {
+ type: "bi.time_popup",
+ value: opts.value,
+ listeners: [{
+ eventName: BI.TimePopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.hidePopupView();
+ self.fireEvent(BI.TimeCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.TimePopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.hidePopupView();
+ self.fireEvent(BI.TimeCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.TimePopup.BUTTON_NOW_EVENT_CHANGE,
+ action: function () {
+ self._setNowTime();
+ }
+ }],
+ ref: function (_ref) {
+ self.popup = _ref;
+ }
+ };
+ return {
+ type: "bi.htape",
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.combo",
+ container: opts.container,
+ toggle: false,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: {
+ type: "bi.time_trigger",
+ value: opts.value,
+ ref: function (_ref) {
+ self.trigger = _ref;
+ }
+ },
+ adjustLength: this.constants.comboAdjustHeight,
+ popup: {
+ el: popup,
+ width: this.constants.popupWidth,
+ stopPropagation: false
+ },
+ hideChecker: function (e) {
+ return self.triggerBtn.element.find(e.target).length === 0;
+ },
+ listeners: [{
+ eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.TimeCombo.EVENT_BEFORE_POPUPVIEW);
+ }
+ }],
+ ref: function (_ref) {
+ self.combo = _ref;
+ }
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button time-font icon-size-16",
+ width: 22,
+ height: 22,
+ listeners: [{
+ eventName: BI.IconButton.EVENT_CHANGE,
+ action: function () {
+ if (self.combo.isViewVisible()) {
+ // self.combo.hideView();
+ } else {
+ self.combo.showView();
+ }
+ }
+ }],
+ ref: function (_ref) {
+ self.triggerBtn = _ref;
+ }
+ },
+ top: 0,
+ right: 0
+ }]
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ },
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ hidePopupView: function () {
+ this.combo.hideView();
+ },
+
+ _setNowTime: function () {
+ var date = BI.getDate();
+ var nowTome = {
+ hour: date.getHours(),
+ minute: date.getMinutes(),
+ second: date.getSeconds()
+ };
+ this.setValue(nowTome);
+ this.hidePopupView();
+ this.fireEvent(BI.TimeCombo.EVENT_CONFIRM);
+ }
+ });
+
+ BI.TimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+ BI.TimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
+ BI.TimeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+ BI.shortcut("bi.time_combo", BI.TimeCombo);
+})();!(function () {
+ BI.TimeTrigger = BI.inherit(BI.Trigger, {
+ props: {
+ extraCls: "bi-time-trigger",
+ height: 22,
+ width: 80,
+ value: {}
+ },
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.htape",
+ items: [{
+ el: {
+ type: "bi.label",
+ textAlign: "left",
+ height: o.height,
+ width: o.width,
+ text: this._formatValue(o.value),
+ ref: function (_ref) {
+ self.text = _ref;
+ }
+ },
+ hgap: 4
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ this.text.setText(this._formatValue(v));
+ },
+
+ _formatValue: function (v) {
+ var now = BI.getDate();
+ return BI.isNotEmptyObject(v) ? BI.print(BI.getDate(now.getFullYear(), now.getMonth(), now.getDay(), v.hour, v.minute, v.second), "%H:%M:%S") : BI.i18nText("BI-Basic_Unrestricted");
+ }
+
+ });
+ BI.shortcut("bi.time_trigger", BI.TimeTrigger);
+})();/**
+ * Created by Baron on 2015/10/19.
+ */
+BI.DateInterval = BI.inherit(BI.Single, {
+ constants: {
+ height: 24,
+ width: 24,
+ lgap: 15,
+ offset: 0,
+ timeErrorCls: "time-error",
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+ _defaultConfig: function () {
+ var conf = BI.DateInterval.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-date-interval"
+ });
+ },
+ _init: function () {
+ var self = this, o = this.options;
+ BI.DateInterval.superclass._init.apply(this, arguments);
+
+ o.value = o.value || {};
+ this.left = this._createCombo(o.value.start);
+ this.right = this._createCombo(o.value.end);
+ this.label = BI.createWidget({
+ type: "bi.label",
+ height: this.constants.height,
+ width: this.constants.width,
+ text: "-"
+ });
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ height: this.constants.height,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: this.constants.offset,
+ right: this.constants.width / 2,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: this.constants.width / 2,
+ right: this.constants.offset,
+ top: 0,
+ bottom: 0
+ }]
+ }]
+ });
+ BI.createWidget({
+ type: "bi.horizontal_auto",
+ element: this,
+ items: [
+ self.label
+ ]
+ });
+ },
+
+ _createCombo: function (v) {
+ var self = this, o = this.options;
+ var combo = BI.createWidget({
+ type: "bi.dynamic_date_combo",
+ behaviors: o.behaviors,
+ value: v
+ });
+ combo.on(BI.DynamicDateCombo.EVENT_ERROR, function () {
+ self._clearTitle();
+ BI.Bubbles.hide("error");
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.DateInterval.EVENT_ERROR);
+ });
+
+ combo.on(BI.DynamicDateCombo.EVENT_VALID, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.DateInterval.EVENT_ERROR);
+ } else {
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ }
+ });
+
+ combo.on(BI.DynamicDateCombo.EVENT_FOCUS, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.DateInterval.EVENT_ERROR);
+ } else {
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ }
+ });
+
+ combo.on(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.left.hidePopupView();
+ self.right.hidePopupView();
+ });
+
+ combo.on(BI.DynamicDateCombo.EVENT_CONFIRM, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.DateInterval.EVENT_ERROR);
+ }else{
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.DateInterval.EVENT_CHANGE);
+ }
+ });
+ return combo;
+ },
+ _dateCheck: function (date) {
+ return BI.print(BI.parseDateTime(date, "%Y-%x-%d"), "%Y-%x-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%d"), "%Y-%X-%d") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%x-%e"), "%Y-%x-%e") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%e"), "%Y-%X-%e") === date;
+ },
+ _checkVoid: function (obj) {
+ return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0];
+ },
+ _check: function (smallDate, bigDate) {
+ var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
+ return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1],
+ day: smallObj[2]
+ }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1],
+ day: bigObj[2]
+ });
+ },
+ _compare: function (smallDate, bigDate) {
+ smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%X-%d"), "%Y-%X-%d");
+ bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%X-%d"), "%Y-%X-%d");
+ return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
+ },
+ _setTitle: function (v) {
+ this.left.setTitle(v);
+ this.right.setTitle(v);
+ this.label.setTitle(v);
+ },
+ _clearTitle: function () {
+ this.left.setTitle("");
+ this.right.setTitle("");
+ this.label.setTitle("");
+ },
+ setValue: function (date) {
+ date = date || {};
+ this.left.setValue(date.start);
+ this.right.setValue(date.end);
+ },
+ getValue: function () {
+ return {start: this.left.getValue(), end: this.right.getValue()};
+ }
+});
+BI.DateInterval.EVENT_VALID = "EVENT_VALID";
+BI.DateInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.DateInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.date_interval", BI.DateInterval);/**
+ * Created by Baron on 2015/10/19.
+ */
+BI.TimeInterval = BI.inherit(BI.Single, {
+ constants: {
+ height: 24,
+ width: 24,
+ lgap: 15,
+ offset: 0,
+ timeErrorCls: "time-error",
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+ _defaultConfig: function () {
+ var conf = BI.TimeInterval.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ extraCls: "bi-time-interval"
+ });
+ },
+ _init: function () {
+ var self = this, o = this.options;
+ BI.TimeInterval.superclass._init.apply(this, arguments);
+
+ o.value = o.value || {};
+ this.left = this._createCombo(o.value.start);
+ this.right = this._createCombo(o.value.end);
+ this.label = BI.createWidget({
+ type: "bi.label",
+ height: this.constants.height,
+ width: this.constants.width,
+ text: "-"
+ });
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ height: this.constants.height,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: this.constants.offset,
+ right: this.constants.width / 2,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: this.constants.width / 2,
+ right: this.constants.offset,
+ top: 0,
+ bottom: 0
+ }]
+ }]
+ });
+ BI.createWidget({
+ type: "bi.horizontal_auto",
+ element: this,
+ items: [
+ self.label
+ ]
+ });
+ },
+
+ _createCombo: function (v) {
+ var self = this, o = this.options;
+ var combo = BI.createWidget({
+ type: "bi.dynamic_date_time_combo",
+ behaviors: o.behaviors,
+ value: v
+ });
+ combo.on(BI.DynamicDateTimeCombo.EVENT_ERROR, function () {
+ self._clearTitle();
+ BI.Bubbles.hide("error");
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.TimeInterval.EVENT_ERROR);
+ });
+
+ combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.TimeInterval.EVENT_ERROR);
+ } else {
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ }
+ });
+
+ combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.TimeInterval.EVENT_ERROR);
+ } else {
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ }
+ });
+
+ combo.on(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.left.hidePopupView();
+ self.right.hidePopupView();
+ });
+
+ combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.TimeInterval.EVENT_ERROR);
+ }else{
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.TimeInterval.EVENT_CHANGE);
+ }
+ });
+ return combo;
+ },
+ _dateCheck: function (date) {
+ return BI.print(BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S"), "%Y-%x-%d %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S"), "%Y-%x-%e %H:%M:%S") === date ||
+ BI.print(BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S"), "%Y-%X-%e %H:%M:%S") === date;
+ },
+ _checkVoid: function (obj) {
+ return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0];
+ },
+ _check: function (smallDate, bigDate) {
+ var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
+ return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1],
+ day: smallObj[2]
+ }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1],
+ day: bigObj[2]
+ });
+ },
+ _compare: function (smallDate, bigDate) {
+ smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
+ bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S"), "%Y-%X-%d %H:%M:%S");
+ return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
+ },
+ _setTitle: function (v) {
+ this.left.setTitle(v);
+ this.right.setTitle(v);
+ this.label.setTitle(v);
+ },
+ _clearTitle: function () {
+ this.left.setTitle("");
+ this.right.setTitle("");
+ this.label.setTitle("");
+ },
+ setValue: function (date) {
+ date = date || {};
+ this.left.setValue(date.start);
+ this.right.setValue(date.end);
+ },
+ getValue: function () {
+ return {start: this.left.getValue(), end: this.right.getValue()};
+ }
+});
+BI.TimeInterval.EVENT_VALID = "EVENT_VALID";
+BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.time_interval", BI.TimeInterval);/**
+ * 时间区间
+ * qcc
+ * 2019/2/28
+ */
+
+!(function () {
+ BI.TimePeriods = BI.inherit(BI.Single, {
+ constants: {
+ height: 24,
+ width: 24,
+ lgap: 15,
+ offset: 0
+ },
+ props: {
+ extraCls: "bi-time-interval",
+ value: {}
+ },
+ render: function () {
+ var self = this, o = this.options;
+
+ return {
+ type: "bi.absolute",
+ height: this.constants.height,
+ items: [{
+ el: {
+ type: "bi.horizontal_auto",
+ items: [{
+ type: "bi.label",
+ height: this.constants.height,
+ width: this.constants.width,
+ text: "-",
+ ref: function (_ref) {
+ self.label = _ref;
+ }
+ }]
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }, {
+ el: {
+ type: "bi.center",
+ height: this.constants.height,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: BI.extend({
+ ref: function (_ref) {
+ self.left = _ref;
+ }
+ }, this._createCombo(o.value.start)),
+ left: this.constants.offset,
+ right: this.constants.width / 2,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: BI.extend({
+ ref: function (_ref) {
+ self.right = _ref;
+ }
+ }, this._createCombo(o.value.end)),
+ left: this.constants.width / 2,
+ right: this.constants.offset,
+ top: 0,
+ bottom: 0
+ }]
+ }]
+ },
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }]
+ };
+ },
+
+ _createCombo: function (v) {
+ var self = this;
+ return {
+ type: "bi.time_combo",
+ value: v,
+ listeners: [{
+ eventName: BI.TimeCombo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.left.hidePopupView();
+ self.right.hidePopupView();
+ }
+ }, {
+ eventName: BI.TimeCombo.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.TimePeriods.EVENT_CHANGE);
+ }
+ }, {
+ eventName: BI.TimeCombo.EVENT_CONFIRM,
+ action: function () {
+ self.fireEvent(BI.TimePeriods.EVENT_CONFIRM);
+ }
+ }]
+ };
+ },
+
+ setValue: function (date) {
+ date = date || {};
+ this.left.setValue(date.start);
+ this.right.setValue(date.end);
+ },
+ getValue: function () {
+ return {start: this.left.getValue(), end: this.right.getValue()};
+ }
+ });
+ BI.TimePeriods.EVENT_CONFIRM = "EVENT_CONFIRM";
+ BI.TimePeriods.EVENT_CHANGE = "EVENT_CHANGE";
+ BI.shortcut("bi.time_periods", BI.TimePeriods);
+})();/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearCard
+ * @extends BI.Trigger
+ */
+BI.DynamicYearCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-year-card"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.label",
+ text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: 24
+ }, {
+ type: "bi.dynamic_date_param_item",
+ ref: function () {
+ self.item = this;
+ },
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }],
+ vgap: 10,
+ hgap: 10
+ };
+ },
+
+ _createValue: function (type, v) {
+ return {
+ dateType: type,
+ value: Math.abs(v),
+ offset: v > 0 ? 1 : 0
+ };
+ },
+
+ setValue: function (v) {
+ v = v || {year: 0};
+ this.item.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
+ },
+
+ getValue: function () {
+ var value = this.item.getValue();
+ return {
+ year: (value.offset === 0 ? -value.value : value.value)
+ };
+ }
+});
+BI.DynamicYearCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_card", BI.DynamicYearCard);/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.StaticYearCard
+ * @extends BI.Trigger
+ */
+BI.StaticYearCard = BI.inherit(BI.Widget, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.StaticYearCard.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-year-card",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31" // 最大日期
+ });
+ },
+
+ _createYearCalendar: function (v) {
+ var o = this.options, y = this._year;
+
+ var calendar = BI.createWidget({
+ type: "bi.year_calendar",
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max,
+ logic: {
+ dynamic: true
+ },
+ year: y + v * 12
+ });
+ calendar.setValue(this._year);
+ return calendar;
+ },
+
+ _init: function () {
+ BI.StaticYearCard.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.selectedYear = this._year = BI.getDate().getFullYear();
+
+ this.backBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "pre-page-h-font",
+ width: 25,
+ height: 25,
+ value: -1,
+ listeners: [{
+ eventName: BI.IconButton.EVENT_CHANGE,
+ action: function () {
+ self.navigation.setSelect(self.navigation.getSelect() - 1);
+ self._checkLeftValid();
+ self._checkRightValid();
+ }
+ }]
+ });
+
+ this.preBtn = BI.createWidget({
+ type: "bi.icon_button",
+ cls: "next-page-h-font",
+ width: 25,
+ height: 25,
+ value: 1,
+ listeners: [{
+ eventName: BI.IconButton.EVENT_CHANGE,
+ action: function () {
+ self.navigation.setSelect(self.navigation.getSelect() + 1);
+ self._checkLeftValid();
+ self._checkRightValid();
+ }
+ }]
+ });
+
+ this.navigation = BI.createWidget({
+ type: "bi.navigation",
+ direction: "top",
+ element: this,
+ single: true,
+ logic: {
+ dynamic: true
+ },
+ tab: {
+ type: "bi.htape",
+ cls: "bi-split-top bi-split-bottom",
+ height: 30,
+ items: [{
+ el: {
+ type: "bi.center_adapt",
+ items: [self.backBtn]
+ },
+ width: 25
+ }, {
+ type: "bi.layout"
+ }, {
+ el: {
+ type: "bi.center_adapt",
+ items: [self.preBtn]
+ },
+ width: 25
+ }]
+ },
+ cardCreator: BI.bind(this._createYearCalendar, this),
+
+ afterCardShow: function () {
+ this.setValue(self.selectedYear);
+ var calendar = this.getSelectedCard();
+ self.backBtn.setEnable(!calendar.isFrontYear());
+ self.preBtn.setEnable(!calendar.isFinalYear());
+ }
+ });
+
+ this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
+ self.selectedYear = this.getValue();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.StaticYearCard.EVENT_CHANGE, self.selectedYear);
+ });
+
+ if(BI.isKey(o.value)){
+ this.setValue(o.value);
+ }
+ },
+
+ _checkLeftValid: function () {
+ var o = this.options;
+ var valid = true;
+ this.backBtn.setEnable(valid);
+ return valid;
+ },
+
+ _checkRightValid: function () {
+ var o = this.options;
+ var valid = true;
+ this.preBtn.setEnable(valid);
+ return valid;
+ },
+
+ getValue: function () {
+ return {
+ year: this.selectedYear
+ };
+ },
+
+ setValue: function (obj) {
+ var o = this.options;
+ obj = obj || {};
+ var v = obj.year;
+ if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) {
+ v = BI.getDate().getFullYear();
+ this.selectedYear = "";
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue("");
+ } else {
+ this.selectedYear = BI.parseInt(v);
+ this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
+ this.navigation.setValue(this.selectedYear);
+ }
+ this._checkLeftValid();
+ this._checkRightValid();
+ }
+});
+BI.StaticYearCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.static_year_card", BI.StaticYearCard);BI.DynamicYearCombo = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-year-combo bi-border bi-focus-shadow",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 22
+ },
+
+ _init: function () {
+ BI.DynamicYearCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = o.value;
+ this.trigger = BI.createWidget({
+ type: "bi.dynamic_year_trigger",
+ min: o.min,
+ max: o.max,
+ height: o.height,
+ value: o.value || ""
+ });
+ this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () {
+ self.storeTriggerValue = this.getKey();
+ });
+ this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearTrigger.EVENT_STOP, function () {
+ self.combo.showView();
+ });
+ this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () {
+ if (self.combo.isViewVisible()) {
+ return;
+ }
+ if (this.getKey() && this.getKey() !== self.storeTriggerValue) {
+ self.storeValue = self.trigger.getValue();
+ self.setValue(self.storeValue);
+ } else if (!this.getKey()) {
+ self.storeValue = null;
+ self.setValue();
+ }
+ self._checkDynamicValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: {
+ type: "bi.dynamic_year_popup",
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicYearPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: function () {
+ var date = BI.getDate();
+ self.setValue({type: BI.DynamicYearCombo.Static, value: {year: date.getFullYear()}});
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }],
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ },
+ value: o.value || ""
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ ref: function () {
+ self.comboWrapper = this;
+ },
+ items: [{
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: 24,
+ height: 24,
+ ref: function () {
+ self.changeIcon = this;
+ }
+ },
+ width: 24
+ }, this.combo]
+ });
+ this._checkDynamicValue(o.value);
+ },
+
+ _checkDynamicValue: function (v) {
+ var type = null;
+ if (BI.isNotNull(v)) {
+ type = v.type;
+ }
+ switch (type) {
+ case BI.DynamicYearCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ this.comboWrapper.attr("items")[0].width = 24;
+ this.comboWrapper.resize();
+ break;
+ default:
+ this.comboWrapper.attr("items")[0].width = 0;
+ this.comboWrapper.resize();
+ this.changeIcon.setVisible(false);
+ break;
+ }
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ this._checkDynamicValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ }
+
+});
+BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo);
+
+BI.extend(BI.DynamicYearCombo, {
+ Static: 1,
+ Dynamic: 2
+});/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.DynamicYearPopup
+ * @extends BI.Trigger
+ */
+BI.DynamicYearPopup = BI.inherit(BI.Widget, {
+ constants: {
+ tabHeight: 30,
+ buttonHeight: 24
+ },
+
+ props: {
+ baseCls: "bi-year-popup",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期,
+ width: 180,
+ height: 240
+ },
+
+ render: function () {
+ var self = this, opts = this.options, c = this.constants;
+ this.storeValue = {type: BI.DynamicYearCombo.Static};
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: this._getTabJson()
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Clear"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ textHeight: c.buttonHeight - 1,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Current_Year"),
+ ref: function () {
+ self.textButton = this;
+ },
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ };
+ },
+
+ _setInnerValue: function () {
+ if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
+ this.textButton.setEnable(true);
+ } else {
+ var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ date = BI.print(date, "%Y");
+ this.textButton.setValue(date);
+ this.textButton.setEnable(false);
+ }
+ },
+
+ _getTabJson: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ tab: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: this.constants.tabHeight,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Basic_Year_Fen"),
+ value: BI.DynamicYearCombo.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicYearCombo.Dynamic
+ }], {
+ textAlign: "center"
+ })
+ },
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicYearCombo.Dynamic:
+ return {
+ type: "bi.dynamic_year_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self._setInnerValue(self.year, v);
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ case BI.DynamicYearCombo.Static:
+ default:
+ return {
+ type: "bi.static_year_card",
+ behaviors: o.behaviors,
+ min: self.options.min,
+ max: self.options.max,
+ listeners: [{
+ eventName: BI.StaticYearCard.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearPopup.EVENT_CHANGE);
+ }
+ }],
+ ref: function () {
+ self.year = this;
+ }
+ };
+ }
+ },
+ listeners: [{
+ eventName: BI.Tab.EVENT_CHANGE,
+ action: function () {
+ var v = self.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicYearCombo.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.year.setValue({year: date.getFullYear()});
+ self._setInnerValue();
+ break;
+ case BI.DynamicYearCombo.Dynamic:
+ default:
+ if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) {
+ self.dynamicPane.setValue(self.storeValue.value);
+ }else{
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ }
+ self._setInnerValue();
+ break;
+ }
+ }
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ var self = this;
+ var type, value;
+ v = v || {};
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ this.year.setValue(value);
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
+ this.textButton.setEnable(true);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+
+});
+BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DynamicYearPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.DynamicYearTrigger.superclass._defaultConfig.apply(this, arguments), {
+ extraCls: "bi-year-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 24
+ });
+ },
+
+ beforeInit: function (callback) {
+ var o = this.options;
+ o.title = BI.bind(this._titleCreator, this);
+ callback();
+ },
+
+ _init: function () {
+ BI.DynamicYearTrigger.superclass._init.apply(this, arguments);
+ var self = this, o = this.options, c = this._const;
+ this.editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
+ },
+ quitChecker: function (v) {
+ return false;
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ allowBlank: true,
+ errorText: function () {
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS);
+ });
+ this.editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DynamicYearTrigger.EVENT_STOP);
+ });
+ this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ var value = self.editor.getValue();
+ if (BI.isNotNull(value)) {
+ self.editor.setValue(value);
+ }
+ if (BI.isNotEmptyString(value)) {
+ self.storeValue = {
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: value
+ }
+ };
+ }
+
+ self.fireEvent(BI.DynamicYearTrigger.EVENT_CONFIRM);
+ });
+ this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (self.editor.isValid()) {
+ self.editor.blur();
+ }
+ });
+ this.editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DynamicYearTrigger.EVENT_START);
+ });
+ this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR);
+ });
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [{
+ el: this.editor
+ }, {
+ el: {
+ type: "bi.text_button",
+ baseCls: "bi-trigger-year-text",
+ text: BI.i18nText("BI-Multi_Date_Year"),
+ width: o.height
+ },
+ width: o.height
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.height
+ },
+ width: o.height
+ }]
+ });
+ this.setValue(o.value);
+ },
+
+ _getText: function (obj) {
+ var value = "";
+ if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) {
+ value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ return value;
+ },
+
+ _setInnerValue: function (date, text) {
+ var dateStr = BI.print(date, "%Y");
+ this.editor.setState(dateStr);
+ this.editor.setValue(dateStr);
+ },
+
+ _titleCreator: function () {
+ var storeValue = this.storeValue || {};
+ var type = storeValue.type || BI.DynamicDateCombo.Static;
+ var value = storeValue.value;
+ if(!this.editor.isValid()) {
+ return "";
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ var date = BI.getDate();
+ date = BI.DynamicDateHelper.getCalculation(value);
+ var dateStr = BI.print(date, "%Y");
+ return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
+ case BI.DynamicDateCombo.Static:
+ default:
+ value = value || {};
+ return value.year;
+ }
+ },
+
+ setValue: function (v) {
+ var type, value;
+ var date = BI.getDate();
+ this.storeValue = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ date = BI.DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ value = value || {};
+ this.editor.setState(value.year);
+ this.editor.setValue(value.year);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ getKey: function () {
+ return this.editor.getValue() | 0;
+ }
+});
+BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicYearTrigger.EVENT_START = "EVENT_START";
+BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP";
+BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearCard
+ * @extends BI.Trigger
+ */
+BI.DynamicYearMonthCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-year-month-card"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.label",
+ text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: 24
+ }, {
+ type: "bi.dynamic_date_param_item",
+ ref: function () {
+ self.year = this;
+ },
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }, {
+ type: "bi.dynamic_date_param_item",
+ dateType: BI.DynamicDateCard.TYPE.MONTH,
+ ref: function () {
+ self.month = this;
+ },
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }],
+ vgap: 10,
+ hgap: 10
+ };
+ },
+
+ _createValue: function (type, v) {
+ return {
+ dateType: type,
+ value: Math.abs(v),
+ offset: v > 0 ? 1 : 0
+ };
+ },
+
+ setValue: function (v) {
+ v = v || {year: 0, month: 0};
+ this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
+ this.month.setValue(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month));
+ },
+
+ getValue: function () {
+ var year = this.year.getValue();
+ var month = this.month.getValue();
+ return {
+ year: (year.offset === 0 ? -year.value : year.value),
+ month: (month.offset === 0 ? -month.value : month.value)
+ };
+ }
+});
+BI.DynamicYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_month_card", BI.DynamicYearMonthCard);BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-static-year-month-card",
+ behaviors: {}
+ },
+
+ _createMonths: function () {
+ // 纵向排列月
+ var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
+ var items = [];
+ items.push(month.slice(0, 2));
+ items.push(month.slice(2, 4));
+ items.push(month.slice(4, 6));
+ items.push(month.slice(6, 8));
+ items.push(month.slice(8, 10));
+ items.push(month.slice(10, 12));
+ return BI.map(items, function (i, item) {
+ return BI.map(item, function (j, td) {
+ return {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 23,
+ width: 38,
+ value: td,
+ text: td
+ };
+ });
+ });
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.year_picker",
+ ref: function () {
+ self.yearPicker = this;
+ },
+ behaviors: o.behaviors,
+ height: 30,
+ listeners: [{
+ eventName: BI.YearPicker.EVENT_CHANGE,
+ action: function () {
+ var value = this.getValue();
+ self.setValue({
+ year: value,
+ month: self.selectedMonth
+ });
+ }
+ }]
+ }, {
+ type: "bi.button_group",
+ cls: "bi-split-top",
+ behaviors: o.behaviors,
+ ref: function () {
+ self.month = this;
+ },
+ items: this._createMonths(),
+ layouts: [BI.LogicFactory.createLogic("table", BI.extend({
+ dynamic: true
+ }, {
+ columns: 2,
+ rows: 6,
+ columnSize: [1 / 2, 1 / 2],
+ rowSize: 25
+ })), {
+ type: "bi.center_adapt",
+ vgap: 1,
+ hgap: 2
+ }],
+ value: o.value,
+ listeners: [{
+ eventName: BI.ButtonGroup.EVENT_CHANGE,
+ action: function () {
+ self.selectedYear = self.yearPicker.getValue();
+ self.selectedMonth = this.getValue()[0];
+ self.fireEvent(BI.StaticYearMonthCard.EVENT_CHANGE);
+ }
+ }]
+ }]
+ };
+ },
+
+
+ getValue: function () {
+ return {
+ year: this.selectedYear,
+ month: this.selectedMonth
+ };
+ },
+
+ setValue: function (obj) {
+ var o = this.options;
+ var newObj = {};
+ newObj.year = obj.year || 0;
+ newObj.month = obj.month || 0;
+ if (newObj.year === 0 || newObj.month === 0 || BI.checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) {
+ var year = newObj.year || BI.getDate().getFullYear();
+ this.selectedYear = year;
+ this.selectedMonth = "";
+ this.yearPicker.setValue(year);
+ this.month.setValue();
+ } else {
+ this.selectedYear = BI.parseInt(newObj.year);
+ this.selectedMonth = BI.parseInt(newObj.month);
+ this.yearPicker.setValue(this.selectedYear);
+ this.month.setValue(this.selectedMonth);
+ }
+ }
+});
+BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard);
+BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
+
+ props: {
+ baseCls: "bi-year-month-combo bi-border bi-focus-shadow",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 22
+ },
+
+ _init: function () {
+ BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = o.value;
+ this.storeTriggerValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.dynamic_year_month_trigger",
+ min: o.min,
+ max: o.max,
+ height: o.height,
+ value: o.value || ""
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () {
+ self.combo.showView();
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR);
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () {
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID);
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () {
+ // 没看出来干啥的,先去掉
+ // if (self.combo.isViewVisible()) {
+ // return;
+ // }
+ var dateStore = self.storeTriggerValue;
+ var dateObj = self.trigger.getKey();
+ if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
+ self.storeValue = self.trigger.getValue();
+ self.setValue(self.trigger.getValue());
+ }
+ self._checkDynamicValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
+ });
+ this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_FOCUS, function () {
+ self.storeTriggerValue = self.trigger.getKey();
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS);
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 100,
+ stopPropagation: false,
+ el: {
+ type: "bi.dynamic_year_month_popup",
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: function () {
+ var date = BI.getDate();
+ self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), month: date.getMonth() + 1}});
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }],
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ },
+ value: o.value || ""
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ ref: function () {
+ self.comboWrapper = this;
+ },
+ items: [{
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: 24,
+ height: 24,
+ ref: function () {
+ self.changeIcon = this;
+ }
+ },
+ width: 24
+ }, this.combo]
+ });
+ this._checkDynamicValue(o.value);
+ },
+
+ _checkDynamicValue: function (v) {
+ var type = null;
+ if (BI.isNotNull(v)) {
+ type = v.type;
+ }
+ switch (type) {
+ case BI.DynamicYearMonthCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ this.comboWrapper.attr("items")[0].width = 24;
+ this.comboWrapper.resize();
+ break;
+ default:
+ this.comboWrapper.attr("items")[0].width = 0;
+ this.comboWrapper.resize();
+ this.changeIcon.setVisible(false);
+ break;
+ }
+ },
+
+ hideView: function () {
+ this.combo.hideView();
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ this._checkDynamicValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ getKey: function () {
+ return this.trigger.getKey();
+ },
+
+ isValid: function () {
+ return this.trigger.isValid();
+ }
+
+});
+BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID";
+BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo);
+
+BI.extend(BI.DynamicYearMonthCombo, {
+ Static: 1,
+ Dynamic: 2
+});/**
+ * 年月
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.DynamicYearMonthPopup
+ * @extends BI.Trigger
+ */
+BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
+ constants: {
+ tabHeight: 30,
+ buttonHeight: 24
+ },
+
+ props: {
+ baseCls: "bi-year-month-popup",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期,
+ width: 180,
+ height: 240
+ },
+
+ render: function () {
+ var self = this, opts = this.options, c = this.constants;
+ this.storeValue = {type: BI.DynamicYearMonthCombo.Static};
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: this._getTabJson()
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Clear"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Current_Month"),
+ ref: function () {
+ self.textButton = this;
+ },
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ };
+ },
+
+ _setInnerValue: function () {
+ if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
+ this.textButton.setEnable(true);
+ } else {
+ var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ date = BI.print(date, "%Y-%x");
+ this.textButton.setValue(date);
+ this.textButton.setEnable(false);
+ }
+ },
+
+ _getTabJson: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ tab: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: this.constants.tabHeight,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Basic_Year_Month"),
+ value: BI.DynamicYearCombo.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicYearCombo.Dynamic
+ }], {
+ textAlign: "center"
+ })
+ },
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicYearCombo.Dynamic:
+ return {
+ type: "bi.dynamic_year_month_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self._setInnerValue(self.year, v);
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ case BI.DynamicYearCombo.Static:
+ default:
+ return {
+ type: "bi.static_year_month_card",
+ behaviors: o.behaviors,
+ min: self.options.min,
+ max: self.options.max,
+ listeners: [{
+ eventName: BI.StaticYearMonthCard.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearMonthPopup.EVENT_CHANGE);
+ }
+ }],
+ ref: function () {
+ self.year = this;
+ }
+ };
+ }
+ },
+ listeners: [{
+ eventName: BI.Tab.EVENT_CHANGE,
+ action: function () {
+ var v = self.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicYearCombo.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.year.setValue({year: date.getFullYear(), month: date.getMonth() + 1});
+ self._setInnerValue();
+ break;
+ case BI.DynamicYearCombo.Dynamic:
+ default:
+ if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) {
+ self.dynamicPane.setValue(self.storeValue.value);
+ }else{
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ }
+ self._setInnerValue();
+ break;
+ }
+ }
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ var self = this;
+ var type, value;
+ v = v || {};
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ this.year.setValue(value);
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
+ this.textButton.setEnable(true);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+
+});
+BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DynamicYearMonthPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2
+ },
+
+ props: {
+ extraCls: "bi-year-month-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 22
+ },
+
+ beforeInit: function (callback) {
+ var o = this.options;
+ o.title = BI.bind(this._titleCreator, this);
+ callback();
+ },
+
+ _init: function () {
+ BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments);
+ var o = this.options;
+
+ this.yearEditor = this._createEditor(true);
+ this.monthEditor = this._createEditor(false);
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [{
+ type: "bi.center",
+ items: [{
+ type: "bi.htape",
+ items: [this.yearEditor, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Year"),
+ width: o.height
+ },
+ width: o.height
+ }]
+ }, {
+ type: "bi.htape",
+ items: [this.monthEditor, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Month"),
+ width: o.height
+ },
+ width: o.height}]
+ }]
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.height
+ },
+ width: o.height
+ }]
+ });
+ this.setValue(o.value);
+ },
+
+ _createEditor: function (isYear) {
+ var self = this, o = this.options, c = this._const;
+ var editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ if(isYear) {
+ return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
+ }
+ return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 12) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]);
+ },
+ quitChecker: function () {
+ return false;
+ },
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ errorText: function (v) {
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ },
+ hgap: c.hgap,
+ vgap: c.vgap,
+ allowBlank: true
+ });
+ editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN);
+ });
+ editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_FOCUS);
+ });
+ editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_STOP);
+ });
+ editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ self._doEditorConfirm(editor);
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
+ });
+ editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (editor.isValid()) {
+ editor.blur();
+ }
+ });
+ editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_START);
+ });
+ editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_ERROR);
+ });
+ editor.on(BI.SignEditor.EVENT_VALID, function () {
+ var year = self.yearEditor.getValue();
+ var month = self.monthEditor.getValue();
+ if(BI.isNotEmptyString(year) && BI.isNotEmptyString(month)) {
+ if(BI.isPositiveInteger(year) && month >= 1 && month <= 12 && !BI.checkDateVoid(year, month, 1, o.min, o.max)[0]) {
+ self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID);
+ }
+ }
+ });
+ editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ if(isYear) {
+ self._autoSwitch(editor);
+ }
+ });
+
+ return editor;
+ },
+
+ _titleCreator: function () {
+ var storeValue = this.storeValue || {};
+ var type = storeValue.type || BI.DynamicDateCombo.Static;
+ var value = storeValue.value;
+ if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) {
+ return "";
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ var date = BI.getDate();
+ date = BI.DynamicDateHelper.getCalculation(value);
+ var dateStr = BI.print(date, "%Y-%x");
+ return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr);
+ case BI.DynamicDateCombo.Static:
+ default:
+ value = value || {};
+ return this._getStaticTitle(value);
+ }
+ },
+
+ _doEditorConfirm: function (editor) {
+ var value = editor.getValue();
+ if (BI.isNotNull(value)) {
+ editor.setValue(value);
+ }
+ var monthValue = this.monthEditor.getValue();
+ this.storeValue = {
+ type: BI.DynamicDateCombo.Static,
+ value: {
+ year: this.yearEditor.getValue(),
+ month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue
+ }
+ };
+ },
+
+ _yearCheck: function (v) {
+ var date = BI.print(BI.parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+ return BI.print(BI.parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
+ },
+
+ _autoSwitch: function (editor) {
+ var v = editor.getValue();
+ if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) {
+ if (v.length === 4 && this._yearCheck(v)) {
+ this._doEditorConfirm(editor);
+ this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
+ this.monthEditor.focus();
+ }
+ }
+ },
+
+ _getText: function (obj) {
+ var value = "";
+ if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) {
+ value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ if(BI.isNotNull(obj.month) && BI.parseInt(obj.month) !== 0) {
+ value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ return value;
+ },
+
+ _setInnerValue: function (date, text) {
+ this.yearEditor.setValue(date.getFullYear());
+ this.monthEditor.setValue(date.getMonth() + 1);
+ },
+
+ _getStaticTitle: function (value) {
+ value = value || {};
+ var hasYear = !(BI.isNull(value.year) || BI.isEmptyString(value.year));
+ var hasMonth = !(BI.isNull(value.month) || BI.isEmptyString(value.month));
+ switch ((hasYear << 1) | hasMonth) {
+ // !hasYear && !hasMonth
+ case 0:
+ return "";
+ // !hasYear && hasMonth
+ case 1:
+ return value.month;
+ // hasYear && !hasMonth
+ case 2:
+ return value.year;
+ // hasYear && hasMonth
+ case 3:
+ default:
+ return value.year + "-" + value.month;
+ }
+ },
+
+ setValue: function (v) {
+ var type, value;
+ var date = BI.getDate();
+ this.storeValue = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ }
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ var text = this._getText(value);
+ date = BI.DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ value = value || {};
+ var month = BI.isNull(value.month) ? null : value.month;
+ this.yearEditor.setValue(value.year);
+ this.monthEditor.setValue(month);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ getKey: function () {
+ return this.yearEditor.getValue() + "-" + this.monthEditor.getValue();
+ },
+
+ isValid: function () {
+ return this.yearEditor.isValid() && this.monthEditor.isValid();
+ }
+});
+BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_VALID";
+BI.DynamicYearMonthTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicYearMonthTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START";
+BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.YearMonthInterval = BI.inherit(BI.Single, {
+ constants: {
+ height: 24,
+ width: 25,
+ lgap: 15,
+ offset: -15,
+ timeErrorCls: "time-error",
+ DATE_MIN_VALUE: "1900-01-01",
+ DATE_MAX_VALUE: "2099-12-31"
+ },
+
+ props: {
+ extraCls: "bi-year-month-interval"
+ },
+
+ _init: function () {
+ var self = this, o = this.options;
+ BI.YearMonthInterval.superclass._init.apply(this, arguments);
+
+ o.value = o.value || {};
+ this.left = this._createCombo(o.value.start);
+ this.right = this._createCombo(o.value.end);
+ this.label = BI.createWidget({
+ type: "bi.label",
+ height: this.constants.height,
+ width: this.constants.width,
+ text: "-"
+ });
+ BI.createWidget({
+ element: self,
+ type: "bi.center",
+ hgap: 15,
+ height: this.constants.height,
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: self.left,
+ left: this.constants.offset,
+ right: 0,
+ top: 0,
+ bottom: 0
+ }]
+ }, {
+ type: "bi.absolute",
+ items: [{
+ el: self.right,
+ left: 0,
+ right: this.constants.offset,
+ top: 0,
+ bottom: 0
+ }]
+ }]
+ });
+ BI.createWidget({
+ type: "bi.horizontal_auto",
+ element: this,
+ items: [
+ self.label
+ ]
+ });
+ },
+
+ _createCombo: function (v) {
+ var self = this, o = this.options;
+ var combo = BI.createWidget({
+ type: "bi.dynamic_year_month_combo",
+ behaviors: o.behaviors,
+ value: v,
+ listeners: [{
+ eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW,
+ action: function () {
+ self.fireEvent(BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW);
+ }
+ }]
+ });
+ combo.on(BI.DynamicYearMonthCombo.EVENT_ERROR, function () {
+ self._clearTitle();
+ BI.Bubbles.hide("error");
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
+ });
+
+ combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () {
+ self._checkValid();
+ });
+
+ combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () {
+ self._checkValid();
+ });
+
+ combo.on(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.left.hideView();
+ self.right.hideView();
+ });
+
+ combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () {
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
+ }else{
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ self.fireEvent(BI.YearMonthInterval.EVENT_CHANGE);
+ }
+ });
+ return combo;
+ },
+
+
+ _dateCheck: function (date) {
+ return BI.print(BI.parseDateTime(date, "%Y-%x"), "%Y-%x") === date || BI.print(BI.parseDateTime(date, "%Y-%X"), "%Y-%X") === date;
+ },
+
+
+ // 判是否在最大最小之间
+ _checkVoid: function (obj) {
+ return !BI.checkDateVoid(obj.year, obj.month, 1, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0];
+ },
+
+ // 判格式合法
+ _check: function (smallDate, bigDate) {
+ var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g);
+
+ var smallDate4Check = "";
+ if (BI.isNotNull(smallObj)) {
+ smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1);
+ }
+
+ var bigDate4Check = "";
+ if (BI.isNotNull(bigObj)) {
+ bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1);
+ }
+
+ return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate) && this._checkVoid({
+ year: smallObj[0],
+ month: smallObj[1],
+ day: 1
+ }) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate) && this._checkVoid({
+ year: bigObj[0],
+ month: bigObj[1],
+ day: 1
+ });
+ },
+
+ _compare: function (smallDate, bigDate) {
+ smallDate = BI.print(BI.parseDateTime(smallDate, "%Y-%X"), "%Y-%X");
+ bigDate = BI.print(BI.parseDateTime(bigDate, "%Y-%X"), "%Y-%X");
+ return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate;
+ },
+ _setTitle: function (v) {
+ this.setTitle(v);
+ },
+ _clearTitle: function () {
+ this.setTitle("");
+ },
+ _checkValid: function () {
+ var self = this;
+
+ BI.Bubbles.hide("error");
+ var smallDate = self.left.getKey(), bigDate = self.right.getKey();
+ if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) {
+ self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text"));
+ self.element.addClass(self.constants.timeErrorCls);
+ BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, {
+ offsetStyle: "center"
+ });
+ self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);
+ } else {
+ self._clearTitle();
+ self.element.removeClass(self.constants.timeErrorCls);
+ }
+ },
+ setValue: function (date) {
+ date = date || {};
+ this.left.setValue(date.start);
+ this.right.setValue(date.end);
+
+ this._checkValid();
+ },
+ getValue: function () {
+ return {start: this.left.getValue(), end: this.right.getValue()};
+ }
+});
+BI.YearMonthInterval.EVENT_VALID = "EVENT_VALID";
+BI.YearMonthInterval.EVENT_ERROR = "EVENT_ERROR";
+BI.YearMonthInterval.EVENT_CHANGE = "EVENT_CHANGE";
+BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.year_month_interval", BI.YearMonthInterval);
+/**
+ * 年份展示面板
+ *
+ * Created by GUY on 2015/9/2.
+ * @class BI.YearCard
+ * @extends BI.Trigger
+ */
+BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-year-month-card"
+ },
+
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.label",
+ text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"),
+ textAlign: "left",
+ height: 24
+ }, {
+ type: "bi.dynamic_date_param_item",
+ ref: function () {
+ self.year = this;
+ },
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }, {
+ type: "bi.dynamic_date_param_item",
+ dateType: BI.DynamicDateCard.TYPE.QUARTER,
+ ref: function () {
+ self.quarter = this;
+ },
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.fireEvent("EVENT_CHANGE");
+ }
+ }]
+ }],
+ vgap: 10,
+ hgap: 10
+ };
+ },
+
+ _createValue: function (type, v) {
+ return {
+ dateType: type,
+ value: Math.abs(v),
+ offset: v > 0 ? 1 : 0
+ };
+ },
+
+ setValue: function (v) {
+ v = v || {year: 0, month: 0};
+ this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year));
+ this.quarter.setValue(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter));
+ },
+
+ getValue: function () {
+ var year = this.year.getValue();
+ var quarter = this.quarter.getValue();
+ return {
+ year: (year.offset === 0 ? -year.value : year.value),
+ quarter: (quarter.offset === 0 ? -quarter.value : quarter.value)
+ };
+ }
+});
+BI.DynamicYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_quarter_card", BI.DynamicYearQuarterCard);BI.StaticYearQuarterCard = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-static-year-quarter-card",
+ behaviors: {}
+ },
+
+ _createQuarter: function () {
+
+ var items = [{
+ text: BI.Date._QN[1],
+ value: 1
+ }, {
+ text: BI.Date._QN[2],
+ value: 2
+ }, {
+ text: BI.Date._QN[3],
+ value: 3
+ }, {
+ text: BI.Date._QN[4],
+ value: 4
+ }];
+ return BI.map(items, function (j, item) {
+ return BI.extend(item, {
+ type: "bi.text_item",
+ cls: "bi-list-item-active",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ once: false,
+ forceSelected: true,
+ height: 24
+ });
+ });
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.year_picker",
+ ref: function () {
+ self.yearPicker = this;
+ },
+ behaviors: o.behaviors,
+ height: 30,
+ listeners: [{
+ eventName: BI.YearPicker.EVENT_CHANGE,
+ action: function () {
+ var value = this.getValue();
+ self.setValue({
+ year: value,
+ quarter: self.selectedQuarter
+ });
+ }
+ }]
+ }, {
+ type: "bi.button_group",
+ behaviors: o.behaviors,
+ ref: function () {
+ self.quarter = this;
+ },
+ items: this._createQuarter(),
+ layouts: [{
+ type: "bi.vertical",
+ vgap: 10
+ }],
+ value: o.value,
+ listeners: [{
+ eventName: BI.ButtonGroup.EVENT_CHANGE,
+ action: function () {
+ self.selectedYear = self.yearPicker.getValue();
+ self.selectedQuarter = this.getValue()[0];
+ self.fireEvent(BI.StaticYearQuarterCard.EVENT_CHANGE);
+ }
+ }]
+ }]
+ };
+ },
+
+
+ getValue: function () {
+ return {
+ year: this.selectedYear,
+ quarter: this.selectedQuarter
+ };
+ },
+
+ setValue: function (obj) {
+ var o = this.options;
+ var newObj = {};
+ newObj.year = obj.year || 0;
+ newObj.quarter = obj.quarter || 0;
+ if (newObj.quarter === 0 || newObj.year === 0 || BI.checkDateVoid(newObj.year, newObj.quarter, 1, o.min, o.max)[0]) {
+ var year = newObj.year || BI.getDate().getFullYear();
+ this.selectedYear = year;
+ this.selectedQuarter = "";
+ this.yearPicker.setValue(year);
+ this.quarter.setValue();
+ } else {
+ this.selectedYear = BI.parseInt(newObj.year);
+ this.selectedQuarter = BI.parseInt(newObj.quarter);
+ this.yearPicker.setValue(this.selectedYear);
+ this.quarter.setValue(this.selectedQuarter);
+ }
+ }
+});
+BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.static_year_quarter_card", BI.StaticYearQuarterCard);
+BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-year-quarter-combo bi-border bi-focus-shadow",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 22
+ },
+
+ _init: function () {
+ BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.storeValue = o.value;
+ self.storeTriggerValue = "";
+ this.trigger = BI.createWidget({
+ type: "bi.dynamic_year_quarter_trigger",
+ min: o.min,
+ max: o.max,
+ height: o.height,
+ value: o.value || ""
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () {
+ self.combo.showView();
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () {
+ self.combo.isViewVisible() && self.combo.hideView();
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () {
+ // 没看出来干啥的,先去掉
+ // if (self.combo.isViewVisible()) {
+ // return;
+ // }
+ var dateStore = self.storeTriggerValue;
+ var dateObj = self.trigger.getKey();
+ if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) {
+ self.storeValue = self.trigger.getValue();
+ self.setValue(self.trigger.getValue());
+ }
+ self._checkDynamicValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
+ });
+ this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_FOCUS, function () {
+ self.storeTriggerValue = self.trigger.getKey();
+ });
+
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ container: o.container,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+ el: this.trigger,
+ popup: {
+ minWidth: 85,
+ stopPropagation: false,
+ el: {
+ type: "bi.dynamic_year_quarter_popup",
+ ref: function () {
+ self.popup = this;
+ },
+ listeners: [{
+ eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE,
+ action: function () {
+ self.setValue();
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE,
+ action: function () {
+ var date = BI.getDate();
+ self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), quarter: BI.getQuarter(date)}});
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }, {
+ eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE,
+ action: function () {
+ self.setValue(self.popup.getValue());
+ self.combo.hideView();
+ self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM);
+ }
+ }],
+ behaviors: o.behaviors,
+ min: o.min,
+ max: o.max
+ },
+ value: o.value || ""
+ }
+ });
+ this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
+ self.popup.setValue(self.storeValue);
+ self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW);
+ });
+
+ BI.createWidget({
+ type: "bi.htape",
+ element: this,
+ ref: function () {
+ self.comboWrapper = this;
+ },
+ items: [{
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-trigger-icon-button date-change-h-font",
+ width: 24,
+ height: 24,
+ ref: function () {
+ self.changeIcon = this;
+ }
+ },
+ width: 24
+ }, this.combo]
+ });
+ this._checkDynamicValue(o.value);
+ },
+
+ _checkDynamicValue: function (v) {
+ var type = null;
+ if (BI.isNotNull(v)) {
+ type = v.type;
+ }
+ switch (type) {
+ case BI.DynamicYearQuarterCombo.Dynamic:
+ this.changeIcon.setVisible(true);
+ this.comboWrapper.attr("items")[0].width = 24;
+ this.comboWrapper.resize();
+ break;
+ default:
+ this.comboWrapper.attr("items")[0].width = 0;
+ this.comboWrapper.resize();
+ this.changeIcon.setVisible(false);
+ break;
+ }
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ this.trigger.setValue(v);
+ this._checkDynamicValue(v);
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ }
+
+});
+BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo);
+
+BI.extend(BI.DynamicYearQuarterCombo, {
+ Static: 1,
+ Dynamic: 2
+});BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
+ constants: {
+ tabHeight: 30,
+ buttonHeight: 24
+ },
+
+ props: {
+ baseCls: "bi-year-quarter-popup",
+ behaviors: {},
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期,
+ width: 180,
+ height: 240
+ },
+
+ render: function () {
+ var self = this, opts = this.options, c = this.constants;
+ this.storeValue = {type: BI.DynamicYearQuarterCombo.Static};
+ return {
+ type: "bi.vtape",
+ items: [{
+ el: this._getTabJson()
+ }, {
+ el: {
+ type: "bi.grid",
+ items: [[{
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ shadow: true,
+ textHeight: c.buttonHeight - 1,
+ text: BI.i18nText("BI-Basic_Clear"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
+ textHeight: c.buttonHeight - 1,
+ shadow: true,
+ text: BI.i18nText("BI-Basic_Current_Quarter"),
+ ref: function () {
+ self.textButton = this;
+ },
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE);
+ }
+ }]
+ }, {
+ type: "bi.text_button",
+ forceCenter: true,
+ cls: "bi-split-top bi-high-light",
+ shadow: true,
+ textHeight: c.buttonHeight - 1,
+ text: BI.i18nText("BI-Basic_OK"),
+ listeners: [{
+ eventName: BI.TextButton.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE);
+ }
+ }]
+ }]]
+ },
+ height: 24
+ }]
+ };
+ },
+
+ _setInnerValue: function () {
+ if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) {
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
+ this.textButton.setEnable(true);
+ } else {
+ var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
+ date = BI.print(date, "%Y-%Q");
+ this.textButton.setValue(date);
+ this.textButton.setEnable(false);
+ }
+ },
+
+ _getTabJson: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.tab",
+ ref: function () {
+ self.dateTab = this;
+ },
+ tab: {
+ type: "bi.linear_segment",
+ cls: "bi-split-bottom",
+ height: this.constants.tabHeight,
+ items: BI.createItems([{
+ text: BI.i18nText("BI-Basic_Year_Quarter"),
+ value: BI.DynamicYearQuarterCombo.Static
+ }, {
+ text: BI.i18nText("BI-Basic_Dynamic_Title"),
+ value: BI.DynamicYearQuarterCombo.Dynamic
+ }], {
+ textAlign: "center"
+ })
+ },
+ cardCreator: function (v) {
+ switch (v) {
+ case BI.DynamicYearQuarterCombo.Dynamic:
+ return {
+ type: "bi.dynamic_year_quarter_card",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self._setInnerValue(self.year, v);
+ }
+ }],
+ ref: function () {
+ self.dynamicPane = this;
+ }
+ };
+ case BI.DynamicYearQuarterCombo.Static:
+ default:
+ return {
+ type: "bi.static_year_quarter_card",
+ behaviors: o.behaviors,
+ min: self.options.min,
+ max: self.options.max,
+ listeners: [{
+ eventName: BI.DynamicYearCard.EVENT_CHANGE,
+ action: function () {
+ self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE);
+ }
+ }],
+ ref: function () {
+ self.year = this;
+ }
+ };
+ }
+ },
+ listeners: [{
+ eventName: BI.Tab.EVENT_CHANGE,
+ action: function () {
+ var v = self.dateTab.getSelect();
+ switch (v) {
+ case BI.DynamicYearQuarterCombo.Static:
+ var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue());
+ self.year.setValue({year: date.getFullYear(), quarter: BI.getQuarter(date)});
+ self._setInnerValue();
+ break;
+ case BI.DynamicYearQuarterCombo.Dynamic:
+ default:
+ if(self.storeValue && self.storeValue.type === BI.DynamicYearQuarterCombo.Dynamic) {
+ self.dynamicPane.setValue(self.storeValue.value);
+ }else{
+ self.dynamicPane.setValue({
+ year: 0
+ });
+ }
+ self._setInnerValue();
+ break;
+ }
+ }
+ }]
+ };
+ },
+
+ setValue: function (v) {
+ this.storeValue = v;
+ var self = this;
+ var type, value;
+ v = v || {};
+ type = v.type || BI.DynamicDateCombo.Static;
+ value = v.value || v;
+ this.dateTab.setSelect(type);
+ switch (type) {
+ case BI.DynamicDateCombo.Dynamic:
+ this.dynamicPane.setValue(value);
+ self._setInnerValue();
+ break;
+ case BI.DynamicDateCombo.Static:
+ default:
+ this.year.setValue(value);
+ this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
+ this.textButton.setEnable(true);
+ break;
+ }
+ },
+
+ getValue: function () {
+ return {
+ type: this.dateTab.getSelect(),
+ value: this.dateTab.getValue()
+ };
+ }
+
+});
+BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE";
+BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE";
+BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
+BI.DynamicYearQuarterPopup.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.dynamic_year_quarter_popup", BI.DynamicYearQuarterPopup);BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
+ _const: {
+ hgap: 4,
+ vgap: 2
+ },
+
+ props: {
+ extraCls: "bi-year-quarter-trigger",
+ min: "1900-01-01", // 最小日期
+ max: "2099-12-31", // 最大日期
+ height: 22
+ },
+
+ _init: function () {
+ BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments);
+ var o = this.options;
+
+ this.yearEditor = this._createEditor(true);
+ this.quarterEditor = this._createEditor(false);
+
+ BI.createWidget({
+ element: this,
+ type: "bi.htape",
+ items: [{
+ type: "bi.center",
+ items: [{
+ type: "bi.htape",
+ items: [this.yearEditor, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Year"),
+ width: o.height
+ },
+ width: o.height
+ }]
+ }, {
+ type: "bi.htape",
+ items: [this.quarterEditor, {
+ el: {
+ type: "bi.text_button",
+ text: BI.i18nText("BI-Multi_Date_Quarter"),
+ width: 24
+ },
+ width: 24}]
+ }]
+ }, {
+ el: {
+ type: "bi.trigger_icon_button",
+ width: o.height
+ },
+ width: o.height
+ }]
+ });
+ this.setValue(o.value);
+ },
+
+ _createEditor: function (isYear) {
+ var self = this, o = this.options, c = this._const;
+ var editor = BI.createWidget({
+ type: "bi.sign_editor",
+ height: o.height,
+ validationChecker: function (v) {
+ if(isYear) {
+ return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]);
+ }
+ return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]);
+ },
+ quitChecker: function () {
+ return false;
+ },
+ errorText: function (v) {
+ return BI.i18nText("BI-Year_Trigger_Invalid_Text");
+ },
+ watermark: BI.i18nText("BI-Basic_Unrestricted"),
+ hgap: c.hgap,
+ vgap: c.vgap,
+ title: "",
+ allowBlank: true
+ });
+ editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN);
+ });
+ editor.on(BI.SignEditor.EVENT_FOCUS, function () {
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_FOCUS);
+ });
+ editor.on(BI.SignEditor.EVENT_STOP, function () {
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP);
+ });
+ editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
+ self._doEditorConfirm(editor);
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM);
+ });
+ editor.on(BI.SignEditor.EVENT_SPACE, function () {
+ if (editor.isValid()) {
+ editor.blur();
+ }
+ });
+ editor.on(BI.SignEditor.EVENT_START, function () {
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_START);
+ });
+ editor.on(BI.SignEditor.EVENT_ERROR, function () {
+ self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR);
+ });
+ editor.on(BI.SignEditor.EVENT_CHANGE, function () {
+ if(isYear) {
+ self._autoSwitch(editor);
+ }
+ });
+
+ return editor;
+ },
+
+ _doEditorConfirm: function (editor) {
+ var value = editor.getValue();
+ if (BI.isNotNull(value)) {
+ editor.setValue(value);
+ }
+ var quarterValue = this.quarterEditor.getValue();
+ this.storeValue = {
+ type: BI.DynamicYearQuarterCombo.Static,
+ value: {
+ year: this.yearEditor.getValue(),
+ quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue
+ }
+ };
+ this.setTitle(this._getStaticTitle(this.storeValue.value));
+ },
+
+ _yearCheck: function (v) {
+ var date = BI.print(BI.parseDateTime(v, "%Y-%X-%d"), "%Y-%X-%d");
+ return BI.print(BI.parseDateTime(v, "%Y"), "%Y") === v && date >= this.options.min && date <= this.options.max;
+ },
+
+ _autoSwitch: function (editor) {
+ var v = editor.getValue();
+ if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) {
+ if (v.length === 4 && this._yearCheck(v)) {
+ this._doEditorConfirm(editor);
+ this.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM);
+ this.quarterEditor.focus();
+ }
+ }
+ },
+
+ _getStaticTitle: function (value) {
+ value = value || {};
+ var hasYear = !(BI.isNull(value.year) || BI.isEmptyString(value.year));
+ var hasMonth = !(BI.isNull(value.quarter) || BI.isEmptyString(value.quarter));
+ switch ((hasYear << 1) | hasMonth) {
+ // !hasYear && !hasMonth
+ case 0:
+ return "";
+ // !hasYear && hasMonth
+ case 1:
+ return value.quarter;
+ // hasYear && !hasMonth
+ case 2:
+ return value.year;
+ // hasYear && hasMonth
+ case 3:
+ default:
+ return value.year + "-" + value.quarter;
+ }
+ },
+
+ _getText: function (obj) {
+ var value = "";
+ if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) {
+ value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ if(BI.isNotNull(obj.quarter) && BI.parseInt(obj.quarter) !== 0) {
+ value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind"));
+ }
+ return value;
+ },
+
+ _setInnerValue: function (date, text) {
+ var dateStr = BI.print(date, "%Y-%Q");
+ this.yearEditor.setValue(date.getFullYear());
+ this.quarterEditor.setValue(BI.getQuarter(date));
+ this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr));
+ },
+
+ setValue: function (v) {
+ var type, value;
+ var date = BI.getDate();
+ this.storeValue = v;
+ if (BI.isNotNull(v)) {
+ type = v.type || BI.DynamicYearQuarterCombo.Static;
+ value = v.value || v;
+ }
+ switch (type) {
+ case BI.DynamicYearQuarterCombo.Dynamic:
+ var text = this._getText(value);
+ date = BI.DynamicDateHelper.getCalculation(value);
+ this._setInnerValue(date, text);
+ break;
+ case BI.DynamicYearQuarterCombo.Static:
+ default:
+ value = value || {};
+ var quarter = BI.isNull(value.quarter) ? null : value.quarter;
+ this.yearEditor.setValue(value.year);
+ this.yearEditor.setTitle(value.year);
+ this.quarterEditor.setValue(quarter);
+ this.quarterEditor.setTitle(quarter);
+ this.setTitle(this._getStaticTitle(value));
+ break;
+ }
+ },
+
+ getValue: function () {
+ return this.storeValue;
+ },
+
+ getKey: function () {
+ return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue();
+ }
+});
+BI.DynamicYearQuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS";
+BI.DynamicYearQuarterTrigger.EVENT_ERROR = "EVENT_ERROR";
+BI.DynamicYearQuarterTrigger.EVENT_START = "EVENT_START";
+BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM";
+BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP";
+BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN";
+BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractAllValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ // 把value都换成字符串
+ // 需要考虑到value也可能是数字
+ if (item.value === v || item.value + "" === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call (items) {
+ var keywords = (options.keywords || []).slice();
+ if (options.keyword) {
+ keywords.push(options.keyword);
+ }
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.match.concat(search.find);
+ });
+ if (options.selectedValues) {// 过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: items,
+ hasNext: false
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserCombo
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: "bi.multi_select_combo",
+ text: o.text,
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height,
+ value: {
+ type: BI.Selection.Multi,
+ value: o.value || []
+ }
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function (items) {
+ // 直接用combo的populate不会作用到AbstractValueChooser上
+ this.items = items;
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut("bi.all_value_chooser_combo", BI.AllValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AllValueChooserPane
+ * @extends BI.AbstractAllValueChooser
+ */
+BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-all-value-chooser-pane",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.AllValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.list = BI.createWidget({
+ type: "bi.multi_select_list",
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
+ });
+ },
+
+ setValue: function (v) {
+ this.list.setValue({
+ type: BI.Selection.Multi,
+ value: v || []
+ });
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ if (val.type === BI.Selection.All) {
+ return val.assist;
+ }
+ return val.value || [];
+ },
+
+ populate: function (items) {
+ // 直接用combo的populate不会作用到AbstractValueChooser上
+ this.items = items;
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
+BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);BI.AllValueMultiTextValueCombo = BI.inherit(BI.Widget, {
+
+ props: {
+ baseCls: "bi-all-value-multi-text-value-combo",
+ width: 200,
+ height: 30,
+ items: []
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ var value = this._digestValue(o.value);
+ return {
+ type: "bi.search_multi_text_value_combo",
+ text: o.text,
+ height: o.height,
+ items: o.items,
+ value: value,
+ numOfPage: 100,
+ valueFormatter: o.valueFormatter,
+ warningTitle: o.warningTitle,
+ listeners: [{
+ eventName: BI.SearchMultiTextValueCombo.EVENT_CONFIRM,
+ action: function () {
+ self.fireEvent(BI.AllValueMultiTextValueCombo.EVENT_CONFIRM);
+ }
+ }],
+ ref: function () {
+ self.combo = this;
+ }
+ };
+ },
+
+ setValue: function (v) {
+ var value = this._digestValue(v);
+ this.combo.setValue(value);
+ },
+
+ getValue: function () {
+ var obj = this.combo.getValue() || {};
+ obj.value = obj.value || [];
+ if(obj.type === BI.Selection.All) {
+ var values = [];
+ BI.each(this.options.items, function (idx, item) {
+ !BI.contains(obj.value, item.value) && values.push(item.value);
+ });
+ return values;
+ }
+ return obj.value || [];
+ },
+
+ populate: function (items) {
+ this.options.items = items;
+ this.combo.populate.apply(this, arguments);
+ },
+
+ _digestValue: function (v) {
+ return {
+ type: BI.Selection.Multi,
+ value: v || []
+ };
+ }
+});
+BI.AllValueMultiTextValueCombo.EVENT_CONFIRM = "AllValueMultiTextValueCombo.EVENT_CONFIRM";
+BI.shortcut("bi.all_value_multi_text_value_combo", BI.AllValueMultiTextValueCombo);
+BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ if (item.value + "" === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _initData: function (items) {
+ this.items = items;
+ var nodes = BI.Tree.treeFormat(items);
+ this.tree = new BI.Tree();
+ this.tree.initTree(nodes);
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!this.items) {
+ o.itemsCreator({}, function (items) {
+ self._initData(items);
+ call();
+ });
+ } else {
+ call();
+ }
+
+ function call() {
+ switch (options.type) {
+ case BI.TreeView.REQ_TYPE_INIT_DATA:
+ self._reqInitTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_ADJUST_DATA:
+ self._reqAdjustTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_SELECT_DATA:
+ self._reqSelectedTreeNode(options, callback);
+ break;
+ case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
+ self._reqDisplayTreeNode(options, callback);
+ break;
+ default :
+ self._reqTreeNode(options, callback);
+ break;
+ }
+ }
+ },
+
+ _reqDisplayTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ doCheck([], this.tree.getRoot(), selectedValues);
+
+ callback({
+ items: result
+ });
+
+ function doCheck(parentValues, node, selected) {
+ if (selected == null || BI.isEmpty(selected)) {
+ BI.each(node.getChildren(), function (i, child) {
+ var newParents = BI.clone(parentValues);
+ newParents.push(child.value);
+ var llen = self._getChildCount(newParents);
+ createOneJson(child, node.id, llen);
+ doCheck(newParents, child, {});
+ });
+ return;
+ }
+ BI.each(selected, function (k) {
+ var node = self._getTreeNode(parentValues, k);
+ var newParents = BI.clone(parentValues);
+ newParents.push(node.value);
+ createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents));
+ doCheck(newParents, node, selected[k]);
+ });
+ }
+
+ function getCount(jo, parentValues) {
+ if (jo == null) {
+ return 0;
+ }
+ if (BI.isEmpty(jo)) {
+ return self._getChildCount(parentValues);
+ }
+
+ return BI.size(jo);
+ }
+
+ function createOneJson(node, pId, llen) {
+ result.push({
+ id: node.id,
+ pId: pId,
+ text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
+ value: node.value,
+ open: true
+ });
+ }
+ },
+
+ _reqSelectedTreeNode: function (op, callback) {
+ var self = this;
+ var selectedValues = BI.deepClone(op.selectedValues);
+ var notSelectedValue = op.notSelectedValue || {};
+ var keyword = op.keyword || "";
+ var parentValues = op.parentValues || [];
+
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+
+ dealWithSelectedValues(selectedValues);
+ callback(selectedValues);
+
+
+ function dealWithSelectedValues(selectedValues) {
+ var p = parentValues.concat(notSelectedValue);
+ // 存储的值中存在这个值就把它删掉
+ // 例如选中了中国-江苏-南京, 取消中国或江苏或南京
+ if (canFindKey(selectedValues, p)) {
+ // 如果搜索的值在父亲链中
+ if (isSearchValueInParent(p)) {
+ // 例如选中了 中国-江苏, 搜索江苏, 取消江苏
+ // 例如选中了 中国-江苏, 搜索江苏, 取消中国
+ self._deleteNode(selectedValues, p);
+ } else {
+ var searched = [];
+ var find = search(parentValues, notSelectedValue, [], searched);
+ if (find && BI.isNotEmptyArray(searched)) {
+ BI.each(searched, function (i, arr) {
+ var node = self._getNode(selectedValues, arr);
+ if (node) {
+ // 例如选中了 中国-江苏-南京,搜索南京,取消中国
+ self._deleteNode(selectedValues, arr);
+ } else {
+ // 例如选中了 中国-江苏,搜索南京,取消中国
+ expandSelectedValue(selectedValues, arr, BI.last(arr));
+ }
+ });
+ }
+ }
+ }
+
+ // 存储的值中不存在这个值,但父亲节点是全选的情况
+ // 例如选中了中国-江苏,取消南京
+ // important 选中了中国-江苏,取消了江苏,但是搜索的是南京
+ if (isChild(selectedValues, p)) {
+ var result = [], find = false;
+ // 如果parentValues中有匹配的值,说明搜索结果不在当前值下
+ if (isSearchValueInParent(p)) {
+ find = true;
+ } else {
+ // 从当前值开始搜
+ find = search(parentValues, notSelectedValue, result);
+ p = parentValues;
+ }
+
+ if (find === true) {
+ // 去掉点击的节点之后的结果集
+ expandSelectedValue(selectedValues, p, notSelectedValue);
+ // 添加去掉搜索的结果集
+ if (result.length > 0) {
+ BI.each(result, function (i, strs) {
+ self._buildTree(selectedValues, strs);
+ });
+ }
+ }
+ }
+
+ }
+
+ function expandSelectedValue(selectedValues, parents, notSelectedValue) {
+ var next = selectedValues;
+ var childrenCount = [];
+ var path = [];
+ // 去掉点击的节点之后的结果集
+ BI.some(parents, function (i, v) {
+ var t = next[v];
+ if (t == null) {
+ if (i === 0) {
+ return true;
+ }
+ if (BI.isEmpty(next)) {
+ var split = parents.slice(0, i);
+ var expanded = self._getChildren(split);
+ path.push(split);
+ childrenCount.push(expanded.length);
+ // 如果只有一个值且取消的就是这个值
+ if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) {
+ for (var j = childrenCount.length - 1; j >= 0; j--) {
+ if (childrenCount[j] === 1) {
+ self._deleteNode(selectedValues, path[j]);
+ } else {
+ break;
+ }
+ }
+ } else {
+ BI.each(expanded, function (m, child) {
+ if (i === parents.length - 1 && child.value === notSelectedValue) {
+ return true;
+ }
+ next[child.value] = {};
+ });
+ }
+ next = next[v];
+ } else {
+ return true;
+ // next = {};
+ // next[v] = {};
+ }
+ } else {
+ next = t;
+ }
+ });
+ }
+
+ function search(parents, current, result, searched) {
+ var newParents = BI.clone(parents);
+ newParents.push(current);
+ if (self._isMatch(parents, current, keyword)) {
+ searched && searched.push(newParents);
+ return true;
+ }
+
+ var children = self._getChildren(newParents);
+
+ var notSearch = [];
+ var can = false;
+
+ BI.each(children, function (i, child) {
+ if (search(newParents, child.value, result, searched)) {
+ can = true;
+ } else {
+ notSearch.push(child.value);
+ }
+ });
+ if (can === true) {
+ BI.each(notSearch, function (i, v) {
+ var next = BI.clone(newParents);
+ next.push(v);
+ result.push(next);
+ });
+ }
+ return can;
+ }
+
+ function isSearchValueInParent(parentValues) {
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (self._isMatch(parentValues.slice(0, i), parentValues[i], keyword)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function canFindKey(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ t = t[v];
+ if (t == null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function isChild(selectedValues, parents) {
+ var t = selectedValues;
+ for (var i = 0; i < parents.length; i++) {
+ var v = parents[i];
+ if (!BI.has(t, v)) {
+ return false;
+ }
+ t = t[v];
+ if (BI.isEmpty(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ },
+
+ _reqAdjustTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var selectedValues = op.selectedValues;
+ if (selectedValues == null || BI.isEmpty(selectedValues)) {
+ callback({});
+ return;
+ }
+ BI.each(selectedValues, function (k, v) {
+ result.push([k]);
+ });
+
+ dealWithSelectedValues(selectedValues, []);
+
+ var jo = {};
+ BI.each(result, function (i, strs) {
+ self._buildTree(jo, strs);
+ });
+ callback(jo);
+
+ function dealWithSelectedValues(selected, parents) {
+ if (selected == null || BI.isEmpty(selected)) {
+ return true;
+ }
+ var can = true;
+ BI.each(selected, function (k, v) {
+ var p = BI.clone(parents);
+ p.push(k);
+ if (!dealWithSelectedValues(selected[k], p)) {
+ BI.each(selected[k], function (nk, nv) {
+ var t = BI.clone(p);
+ t.push(nk);
+ result.push(t);
+ });
+ can = false;
+ }
+ });
+ return can && isAllSelected(selected, parents);
+ }
+
+ function isAllSelected(selected, parents) {
+ return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
+ }
+ },
+
+ _reqInitTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var keyword = op.keyword || "";
+ var selectedValues = op.selectedValues;
+ var lastSearchValue = op.lastSearchValue || "";
+ var output = search();
+ BI.nextTick(function () {
+ callback({
+ hasNext: output.length > self._const.perPage,
+ items: result,
+ lastSearchValue: BI.last(output)
+ });
+ });
+
+ function search() {
+ var children = self._getChildren([]);
+ var start = children.length;
+ if (lastSearchValue !== "") {
+ for (var j = 0, len = start; j < len; j++) {
+ if (children[j].value === lastSearchValue) {
+ start = j + 1;
+ break;
+ }
+ }
+ } else {
+ start = 0;
+ }
+ var output = [];
+ for (var i = start, len = children.length; i < len; i++) {
+ if (output.length < self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, result);
+ } else if (output.length === self._const.perPage) {
+ var find = nodeSearch(1, [], children[i].value, false, []);
+ }
+ if (find[0] === true) {
+ output.push(children[i].value);
+ }
+ if (output.length > self._const.perPage) {
+ break;
+ }
+ }
+ return output;
+ }
+
+ function nodeSearch(deep, parentValues, current, isAllSelect, result) {
+ if (self._isMatch(parentValues, current, keyword)) {
+ var checked = isAllSelect || isSelected(parentValues, current);
+ createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
+ return [true, checked];
+ }
+ var newParents = BI.clone(parentValues);
+ newParents.push(current);
+ var children = self._getChildren(newParents);
+
+ var can = false, checked = false;
+
+ var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
+ BI.each(children, function (i, child) {
+ var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
+ if (state[1] === true) {
+ checked = true;
+ }
+ if (state[0] === true) {
+ can = true;
+ }
+ });
+ if (can === true) {
+ checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
+ createOneJson(parentValues, current, true, checked, false, false, result);
+ }
+ return [can, checked];
+ }
+
+ function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
+ var node = self._getTreeNode(parentValues, value);
+ result.push({
+ id: node.id,
+ pId: node.pId,
+ text: node.text,
+ value: node.value,
+ title: node.title,
+ isParent: node.getChildrenLength() > 0,
+ open: isOpen,
+ checked: checked,
+ halfCheck: half,
+ flag: flag
+ });
+ }
+
+ function isHalf(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && !BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isAllSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return null;
+ }
+ return BI.any(find, function (v, ob) {
+ if (v === value) {
+ if (ob != null && BI.isEmpty(ob)) {
+ return true;
+ }
+ }
+ });
+ }
+
+ function isSelected(parentValues, value) {
+ var find = findSelectedObj(parentValues);
+ if (find == null) {
+ return false;
+ }
+ return BI.any(find, function (v) {
+ if (v === value) {
+ return true;
+ }
+ });
+ }
+
+ function findSelectedObj(parentValues) {
+ var find = selectedValues;
+ if (find == null) {
+ return null;
+ }
+ BI.every(parentValues, function (i, v) {
+ find = find[v];
+ if (find == null) {
+ return false;
+ }
+ return true;
+ });
+ return find;
+ }
+ },
+
+ _reqTreeNode: function (op, callback) {
+ var self = this;
+ var result = [];
+ var times = op.times;
+ var checkState = op.checkState || {};
+ var parentValues = op.parentValues || [];
+ var selectedValues = op.selectedValues || {};
+ var valueMap = {};
+ // if (judgeState(parentValues, selectedValues, checkState)) {
+ valueMap = dealWidthSelectedValue(parentValues, selectedValues);
+ // }
+ var nodes = this._getChildren(parentValues);
+ for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
+ var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState);
+ result.push({
+ id: nodes[i].id,
+ pId: nodes[i].pId,
+ value: nodes[i].value,
+ text: nodes[i].text,
+ times: 1,
+ isParent: nodes[i].getChildrenLength() > 0,
+ checked: state[0],
+ halfCheck: state[1]
+ });
+ }
+ BI.nextTick(function () {
+ callback({
+ items: result,
+ hasNext: nodes.length > times * self._const.perPage
+ });
+ });
+
+ function judgeState(parentValues, selected_value, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ if (parentValues.length > 0 && !checked) {
+ return false;
+ }
+ return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
+ }
+
+ function dealWidthSelectedValue(parentValues, selectedValues) {
+ var valueMap = {};
+ BI.each(parentValues, function (i, v) {
+ selectedValues = selectedValues[v] || {};
+ });
+ BI.each(selectedValues, function (value, obj) {
+ if (BI.isNull(obj)) {
+ valueMap[value] = [0, 0];
+ return;
+ }
+ if (BI.isEmpty(obj)) {
+ valueMap[value] = [2, 0];
+ return;
+ }
+ var nextNames = {};
+ BI.each(obj, function (t, o) {
+ if (BI.isNull(o) || BI.isEmpty(o)) {
+ nextNames[t] = true;
+ }
+ });
+ valueMap[value] = [1, BI.size(nextNames)];
+ });
+ return valueMap;
+ }
+
+ function getCheckState(current, parentValues, valueMap, checkState) {
+ var checked = checkState.checked, half = checkState.half;
+ var tempCheck = false, halfCheck = false;
+ if (BI.has(valueMap, current)) {
+ // 可能是半选
+ if (valueMap[current][0] === 1) {
+ var values = BI.clone(parentValues);
+ values.push(current);
+ var childCount = self._getChildCount(values);
+ if (childCount > 0 && childCount !== valueMap[current][1]) {
+ halfCheck = true;
+ }
+ } else if (valueMap[current][0] === 2) {
+ tempCheck = true;
+ }
+ }
+ var check;
+ if (!checked && !halfCheck && !tempCheck) {
+ check = BI.has(valueMap, current);
+ } else {
+ check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
+ }
+ return [check, halfCheck];
+ }
+ },
+
+ _getNode: function (selectedValues, parentValues) {
+ var pNode = selectedValues;
+ for (var i = 0, len = parentValues.length; i < len; i++) {
+ if (pNode == null) {
+ return null;
+ }
+ pNode = pNode[parentValues[i]];
+ }
+ return pNode;
+ },
+
+ _deleteNode: function (selectedValues, values) {
+ var name = values[values.length - 1];
+ var p = values.slice(0, values.length - 1);
+ var pNode = this._getNode(selectedValues, p);
+ if (pNode != null && pNode[name]) {
+ delete pNode[name];
+ // 递归删掉空父节点
+ while (p.length > 0 && BI.isEmpty(pNode)) {
+ name = p[p.length - 1];
+ p = p.slice(0, p.length - 1);
+ pNode = this._getNode(selectedValues, p);
+ if (pNode != null) {
+ delete pNode[name];
+ }
+ }
+ }
+ },
+
+ _buildTree: function (jo, values) {
+ var t = jo;
+ BI.each(values, function (i, v) {
+ if (!BI.has(t, v)) {
+ t[v] = {};
+ }
+ t = t[v];
+ });
+ },
+
+ _isMatch: function (parentValues, value, keyword) {
+ var node = this._getTreeNode(parentValues, value);
+ if (!node) {
+ return false;
+ }
+ var find = BI.Func.getSearchResult([node.text || node.value], keyword);
+ return find.find.length > 0 || find.match.length > 0;
+ },
+
+ _getTreeNode: function (parentValues, v) {
+ var self = this;
+ var findParentNode;
+ var index = 0;
+ this.tree.traverse(function (node) {
+ if (self.tree.isRoot(node)) {
+ return;
+ }
+ if (index > parentValues.length) {
+ return false;
+ }
+ if (index === parentValues.length && node.value === v) {
+ findParentNode = node;
+ return false;
+ }
+ if (node.value === parentValues[index]) {
+ index++;
+ return;
+ }
+ return true;
+ });
+ return findParentNode;
+ },
+
+ _getChildren: function (parentValues) {
+ if (parentValues.length > 0) {
+ var value = BI.last(parentValues);
+ var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value);
+ } else {
+ var parent = this.tree.getRoot();
+ }
+ return parent.getChildren();
+ },
+
+ _getChildCount: function (parentValues) {
+ return this._getChildren(parentValues).length;
+ }
+});/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ }
+ this.combo = BI.createWidget({
+ type: "bi.multi_tree_combo",
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ },
+
+ populate: function (items) {
+ this._initData(items);
+ this.combo.populate.apply(this.combo, arguments);
+ }
+});
+BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo);/**
+ * 简单的复选下拉树控件, 适用于数据量少的情况
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.TreeValueChooserPane
+ * @extends BI.AbstractTreeValueChooser
+ */
+BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tree-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn
+ });
+ },
+
+ _init: function () {
+ BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.pane = BI.createWidget({
+ type: "bi.multi_select_tree",
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this)
+ });
+
+ this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
+ self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this._initData(o.items);
+ this.populate();
+ }
+ },
+
+ setSelectedValue: function (v) {
+ this.pane.setSelectedValue(v);
+ },
+
+ setValue: function (v) {
+ this.pane.setValue(v);
+ },
+
+ getValue: function () {
+ return this.pane.getValue();
+ },
+
+ populate: function () {
+ this.pane.populate.apply(this.pane, arguments);
+ }
+});
+BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
+BI.shortcut("bi.tree_value_chooser_pane", BI.TreeValueChooserPane);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.AbstractValueChooser
+ * @extends BI.Widget
+ */
+BI.AbstractValueChooser = BI.inherit(BI.Widget, {
+
+ _const: {
+ perPage: 100
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _valueFormatter: function (v) {
+ var text = v;
+ if (BI.isNotNull(this.items)) {
+ BI.some(this.items, function (i, item) {
+ // 把value都换成字符串
+ if (item.value + "" === v) {
+ text = item.text;
+ return true;
+ }
+ });
+ }
+ return text;
+ },
+
+ _getItemsByTimes: function (items, times) {
+ var res = [];
+ for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
+ res.push(items[i]);
+ }
+ return res;
+ },
+
+ _hasNextByTimes: function (items, times) {
+ return times * this._const.perPage < items.length;
+ },
+
+ _itemsCreator: function (options, callback) {
+ var self = this, o = this.options;
+ if (!o.cache || !this.items) {
+ o.itemsCreator({}, function (items) {
+ self.items = items;
+ call(items);
+ });
+ } else {
+ call(this.items);
+ }
+ function call (items) {
+ var keywords = (options.keywords || []).slice();
+ BI.each(keywords, function (i, kw) {
+ var search = BI.Func.getSearchResult(items, kw);
+ items = search.match.concat(search.find);
+ });
+ if (options.selectedValues) {// 过滤
+ var filter = BI.makeObject(options.selectedValues, true);
+ items = BI.filter(items, function (i, ob) {
+ return !filter[ob.value];
+ });
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
+ callback({
+ items: items
+ });
+ return;
+ }
+ if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
+ callback({count: items.length});
+ return;
+ }
+ callback({
+ items: self._getItemsByTimes(items, options.times),
+ hasNext: self._hasNextByTimes(items, options.times)
+ });
+ }
+ }
+});/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserCombo
+ * @extends BI.Widget
+ */
+BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-combo",
+ width: 200,
+ height: 30,
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserCombo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ }
+ this.combo = BI.createWidget({
+ type: "bi.multi_select_combo",
+ element: this,
+ text: o.text,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this),
+ width: o.width,
+ height: o.height
+ });
+
+ this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
+ self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
+ });
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.combo.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ };
+ },
+
+ populate: function (items) {
+ // 直接用combo的populate不会作用到AbstractValueChooser上
+ this.items = items;
+ this.combo.populate.apply(this, arguments);
+ }
+});
+BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
+BI.shortcut("bi.value_chooser_combo", BI.ValueChooserCombo);/**
+ * 简单的复选下拉框控件, 适用于数据量少的情况
+ * 封装了字段处理逻辑
+ *
+ * Created by GUY on 2015/10/29.
+ * @class BI.ValueChooserPane
+ * @extends BI.Widget
+ */
+BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
+
+ _defaultConfig: function () {
+ return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-value-chooser-pane",
+ items: null,
+ itemsCreator: BI.emptyFn,
+ cache: true
+ });
+ },
+
+ _init: function () {
+ BI.ValueChooserPane.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.list = BI.createWidget({
+ type: "bi.multi_select_list",
+ element: this,
+ itemsCreator: BI.bind(this._itemsCreator, this),
+ valueFormatter: BI.bind(this._valueFormatter, this)
+ });
+
+ this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
+ self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
+ });
+ if (BI.isNotNull(o.items)) {
+ this.items = o.items;
+ this.list.populate();
+ }
+ },
+
+ setValue: function (v) {
+ this.list.setValue(v);
+ },
+
+ getValue: function () {
+ var val = this.list.getValue() || {};
+ return {
+ type: val.type,
+ value: val.value
+ };
+ },
+
+ populate: function (items) {
+ // 直接用combo的populate不会作用到AbstractValueChooser上
+ items && (this.items = items);
+ this.list.populate.apply(this.list, arguments);
+ }
+});
+BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
+BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
+ function initWatch(vm, watch) {
+ vm._watchers || (vm._watchers = []);
+ for (var key in watch) {
+ var handler = watch[key];
+ if (BI.isArray(handler)) {
+ for (var i = 0; i < handler.length; i++) {
+ vm._watchers.push(createWatcher(vm, key, handler[i]));
+ }
+ } else {
+ vm._watchers.push(createWatcher(vm, key, handler));
+ }
+ }
+ }
+
+ function createWatcher(vm, keyOrFn, handler) {
+ return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
+ store: vm.store
+ });
+ }
+
+ var target = null;
+ var targetStack = [];
+
+ function pushTarget(_target) {
+ if (target) targetStack.push(target);
+ Fix.Model.target = target = _target;
+ }
+
+ function popTarget() {
+ Fix.Model.target = target = targetStack.pop();
+ }
+
+ var context = null;
+ var contextStack = [];
+
+ function pushContext(_context) {
+ if (context) contextStack.push(context);
+ Fix.Model.context = context = _context;
+ }
+
+ function popContext() {
+ Fix.Model.context = context = contextStack.pop();
+ }
+
+ var oldWatch = Fix.watch;
+ Fix.watch = function (model, expOrFn, cb, options) {
+ if (BI.isPlainObject(cb)) {
+ options = cb;
+ cb = cb.handler;
+ }
+ if (typeof cb === "string") {
+ cb = model[cb];
+ }
+ return oldWatch.call(this, model, expOrFn, function () {
+ options && options.store && pushTarget(options.store);
+ var res = cb.apply(this, arguments);
+ options && options.store && popTarget();
+ return res;
+ }, options);
+ };
+
+ function findStore(widget) {
+ if (target != null) {
+ return target;
+ }
+ widget = widget || context;
+ var p = widget;
+ while (p) {
+ if (p instanceof Fix.Model || p.store || p.__cacheStore) {
+ break;
+ }
+ p = p._parent || (p.options && p.options.element);
+ }
+ if (p) {
+ if (p instanceof Fix.Model) {
+ return widget.__cacheStore = p;
+ }
+ widget.__cacheStore = p.store || p.__cacheStore;
+ return p.__cacheStore || p.store;
+ }
+ }
+
+ var _create = BI.createWidget;
+ BI.createWidget = function (item, options, context) {
+ var pushed = false;
+ if (BI.isWidget(options)) {
+ pushContext(options);
+ pushed = true;
+ } else if (context != null) {
+ pushContext(context);
+ pushed = true;
+ }
+ var result = _create.apply(this, arguments);
+ pushed && popContext();
+ return result;
+ };
+
+ _.each(["populate", "addItems", "prependItems"], function (name) {
+ var old = BI.Loader.prototype[name];
+ BI.Loader.prototype[name] = function () {
+ pushContext(this);
+ var result = old.apply(this, arguments);
+ popContext();
+ return result;
+ };
+ });
+
+ function createStore() {
+ var needPop = false;
+ if (_global.Fix && this._store) {
+ var store = findStore(this.options.context || this.options.element);
+ if (store) {
+ pushTarget(store);
+ needPop = true;
+ }
+ this.store = this._store();
+ this.store && (this.store._widget = this);
+ needPop && popTarget();
+ needPop = false;
+ pushTarget(this.store);
+ if (this.store instanceof Fix.Model) {
+ this.model = this.store.model;
+ } else {
+ this.model = this.store;
+ }
+ needPop = true;
+ }
+ return needPop;
+ }
+
+ var _init = BI.Widget.prototype._init;
+ BI.Widget.prototype._init = function () {
+ var self = this;
+ var needPop = createStore.call(this);
+ _init.apply(this, arguments);
+ needPop && popTarget();
+ };
+
+ var _render = BI.Widget.prototype._render;
+ BI.Widget.prototype._render = function () {
+ var needPop = false;
+ if (_global.Fix && this._store) {
+ needPop = true;
+ pushTarget(this.store);
+ initWatch(this, this.watch);
+ }
+ _render.apply(this, arguments);
+ needPop && popTarget();
+ };
+
+ var unMount = BI.Widget.prototype.__d;
+ BI.Widget.prototype.__d = function () {
+ unMount.apply(this, arguments);
+ this.store && BI.isFunction(this.store.destroy) && this.store.destroy();
+ BI.each(this._watchers, function (i, unwatches) {
+ unwatches = BI.isArray(unwatches) ? unwatches : [unwatches];
+ BI.each(unwatches, function (j, unwatch) {
+ unwatch();
+ });
+ });
+ this._watchers && (this._watchers = []);
+ if (this.store) {
+ this.store._parent && (this.store._parent = null);
+ this.store._widget && (this.store._widget = null);
+ this.store = null;
+ }
+ delete this.__cacheStore;
+ };
+
+ _.each(["_mount"], function (name) {
+ var old = BI.Widget.prototype[name];
+ old && (BI.Widget.prototype[name] = function () {
+ this.store && pushTarget(this.store);
+ var res = old.apply(this, arguments);
+ this.store && popTarget();
+ return res;
+ });
+ });
+
+ if (BI.isIE9Below && BI.isIE9Below()) {
+ _.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
+ "sortBy", "groupBy", "indexBy", "countBy", "partition",
+ "keys", "allKeys", "values", "pairs", "invert",
+ "mapObject", "findKey", "pick", "omit", "tap"], function (name) {
+ var old = BI[name];
+ BI[name] = function (obj, fn, context) {
+ return typeof fn === "function" ? old(obj, function (key, value) {
+ if (!(key in Fix.$$skipArray)) {
+ return fn.apply(this, arguments);
+ }
+ }, context) : old.apply(this, arguments);
+ };
+ });
+ BI.isEmpty = function (ob) {
+ if (BI.isPlainObject(ob) && ob.__ob__) {
+ return BI.keys(ob).length === 0;
+ }
+ return _.isEmpty(ob);
+ };
+ BI.keys = function (ob) {
+ var keys = _.keys(ob);
+ var nKeys = [];
+ for (var i = 0; i < keys.length; i++) {
+ if (!(keys[i] in Fix.$$skipArray)) {
+ nKeys.push(keys[i]);
+ }
+ }
+ return nKeys;
+ };
+ BI.values = function (ob) {
+ var keys = BI.keys(obj);
+ var length = keys.length;
+ var values = [];
+ for (var i = 0; i < length; i++) {
+ values[i] = obj[keys[i]];
+ }
+ return values;
+ };
+ BI.extend = function () {
+ var args = Array.prototype.slice.call(arguments);
+ if (args.length < 1) {
+ return {};
+ }
+ var object = args[0];
+ var i = 1;
+ while (i < args.length) {
+ BI.each(args[i], function (key, v) {
+ object[key] = v;
+ });
+ i++;
+ }
+ return object;
+ };
+ BI.size = function (ob) {
+ if (BI.isPlainObject(ob) && ob.__ob__) {
+ return BI.keys(ob).length;
+ }
+ return _.size(ob);
+ };
+ BI.isEmptyObject = function (ob) {
+ return BI.size(ob) === 0;
+ };
+ BI.deepClone = function (ob) {
+ return Fix.toJSON(ob);
+ };
+ }
+ BI.watch = Fix.watch;
+}());(function () {
+ var Events = {
+
+ // Bind an event to a `callback` function. Passing `"all"` will bind
+ // the callback to all events fired.
+ on: function (name, callback, context) {
+ if (!eventsApi(this, "on", name, [callback, context]) || !callback) return this;
+ this._events || (this._events = {});
+ var events = this._events[name] || (this._events[name] = []);
+ events.push({callback: callback, context: context, ctx: context || this});
+ return this;
+ },
+
+ // Bind an event to only be triggered a single time. After the first time
+ // the callback is invoked, it will be removed.
+ once: function (name, callback, context) {
+ if (!eventsApi(this, "once", name, [callback, context]) || !callback) return this;
+ var self = this;
+ var once = _.once(function () {
+ self.off(name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ return this.on(name, once, context);
+ },
+
+ // Remove one or many callbacks. If `context` is null, removes all
+ // callbacks with that function. If `callback` is null, removes all
+ // callbacks for the event. If `name` is null, removes all bound
+ // callbacks for all events.
+ off: function (name, callback, context) {
+ if (!this._events || !eventsApi(this, "off", name, [callback, context])) return this;
+
+ // Remove all callbacks for all events.
+ if (!name && !callback && !context) {
+ this._events = void 0;
+ return this;
+ }
+
+ var names = name ? [name] : _.keys(this._events);
+ for (var i = 0, length = names.length; i < length; i++) {
+ name = names[i];
+
+ // Bail out if there are no events stored.
+ var events = this._events[name];
+ if (!events) continue;
+
+ // Remove all callbacks for this event.
+ if (!callback && !context) {
+ delete this._events[name];
+ continue;
+ }
+
+ // Find any remaining events.
+ var remaining = [];
+ for (var j = 0, k = events.length; j < k; j++) {
+ var event = events[j];
+ if (
+ callback && callback !== event.callback &&
+ callback !== event.callback._callback ||
+ context && context !== event.context
+ ) {
+ remaining.push(event);
+ }
+ }
+
+ // Replace events if there are any remaining. Otherwise, clean up.
+ if (remaining.length) {
+ this._events[name] = remaining;
+ } else {
+ delete this._events[name];
+ }
+ }
+
+ return this;
+ },
+
+ un: function () {
+ this.off.apply(this, arguments);
+ },
+
+ // Trigger one or many events, firing all bound callbacks. Callbacks are
+ // passed the same arguments as `trigger` is, apart from the event name
+ // (unless you're listening on `"all"`, which will cause your callback to
+ // receive the true name of the event as the first argument).
+ trigger: function (name) {
+ if (!this._events) return this;
+ var args = slice.call(arguments, 1);
+ if (!eventsApi(this, "trigger", name, args)) return this;
+ var events = this._events[name];
+ var allEvents = this._events.all;
+ if (events) triggerEvents(events, args);
+ if (allEvents) triggerEvents(allEvents, arguments);
+ return this;
+ },
+
+ fireEvent: function () {
+ this.trigger.apply(this, arguments);
+ },
+
+ // Inversion-of-control versions of `on` and `once`. Tell *this* object to
+ // listen to an event in another object ... keeping track of what it's
+ // listening to.
+ listenTo: function (obj, name, callback) {
+ var listeningTo = this._listeningTo || (this._listeningTo = {});
+ var id = obj._listenId || (obj._listenId = _.uniqueId("l"));
+ listeningTo[id] = obj;
+ if (!callback && typeof name === "object") callback = this;
+ obj.on(name, callback, this);
+ return this;
+ },
+
+ listenToOnce: function (obj, name, callback) {
+ if (typeof name === "object") {
+ for (var event in name) this.listenToOnce(obj, event, name[event]);
+ return this;
+ }
+ if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, length = names.length; i < length; i++) {
+ this.listenToOnce(obj, names[i], callback);
+ }
+ return this;
+ }
+ if (!callback) return this;
+ var once = _.once(function () {
+ this.stopListening(obj, name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ return this.listenTo(obj, name, once);
+ },
+
+ // Tell this object to stop listening to either specific events ... or
+ // to every object it's currently listening to.
+ stopListening: function (obj, name, callback) {
+ var listeningTo = this._listeningTo;
+ if (!listeningTo) return this;
+ var remove = !name && !callback;
+ if (!callback && typeof name === "object") callback = this;
+ if (obj) (listeningTo = {})[obj._listenId] = obj;
+ for (var id in listeningTo) {
+ obj = listeningTo[id];
+ obj.off(name, callback, this);
+ if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id];
+ }
+ return this;
+ }
+
+ };
+
+ // Regular expression used to split event strings.
+ var eventSplitter = /\s+/;
+
+ // Implement fancy features of the Events API such as multiple event
+ // names `"change blur"` and jQuery-style event maps `{change: action}`
+ // in terms of the existing API.
+ var eventsApi = function (obj, action, name, rest) {
+ if (!name) return true;
+
+ // Handle event maps.
+ if (typeof name === "object") {
+ for (var key in name) {
+ obj[action].apply(obj, [key, name[key]].concat(rest));
+ }
+ return false;
+ }
+
+ // Handle space separated event names.
+ if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, length = names.length; i < length; i++) {
+ obj[action].apply(obj, [names[i]].concat(rest));
+ }
+ return false;
+ }
+
+ return true;
+ };
+
+ // A difficult-to-believe, but optimized internal dispatch function for
+ // triggering events. Tries to keep the usual cases speedy (most internal
+ // BI events have 3 arguments).
+ var triggerEvents = function (events, args) {
+ var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
+ switch (args.length) {
+ case 0:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx);
+ return;
+ case 1:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1);
+ return;
+ case 2:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2);
+ return;
+ case 3:
+ while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3);
+ return;
+ default:
+ while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
+ return;
+ }
+ };
+
+ // BI.Router
+ // ---------------
+
+ // Routers map faux-URLs to actions, and fire events when routes are
+ // matched. Creating a new one sets its `routes` hash, if not set statically.
+ var Router = BI.Router = function (options) {
+ options || (options = {});
+ if (options.routes) this.routes = options.routes;
+ this._bindRoutes();
+ this._init.apply(this, arguments);
+ };
+
+ // Cached regular expressions for matching named param parts and splatted
+ // parts of route strings.
+ var optionalParam = /\((.*?)\)/g;
+ var namedParam = /(\(\?)?:\w+/g;
+ var splatParam = /\*\w+/g;
+ var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
+
+ // Set up all inheritable **BI.Router** properties and methods.
+ _.extend(Router.prototype, Events, {
+
+ // _init is an empty function by default. Override it with your own
+ // initialization logic.
+ _init: function () {
+ },
+
+ // Manually bind a single named route to a callback. For example:
+ //
+ // this.route('search/:query/p:num', 'search', function(query, num) {
+ // ...
+ // });
+ //
+ route: function (route, name, callback) {
+ if (!_.isRegExp(route)) route = this._routeToRegExp(route);
+ if (_.isFunction(name)) {
+ callback = name;
+ name = "";
+ }
+ if (!callback) callback = this[name];
+ var router = this;
+ BI.history.route(route, function (fragment) {
+ var args = router._extractParameters(route, fragment);
+ if (router.execute(callback, args, name) !== false) {
+ router.trigger.apply(router, ["route:" + name].concat(args));
+ router.trigger("route", name, args);
+ BI.history.trigger("route", router, name, args);
+ }
+ });
+ return this;
+ },
+
+ // Execute a route handler with the provided parameters. This is an
+ // excellent place to do pre-route setup or post-route cleanup.
+ execute: function (callback, args, name) {
+ if (callback) callback.apply(this, args);
+ },
+
+ // Simple proxy to `BI.history` to save a fragment into the history.
+ navigate: function (fragment, options) {
+ BI.history.navigate(fragment, options);
+ return this;
+ },
+
+ // Bind all defined routes to `BI.history`. We have to reverse the
+ // order of the routes here to support behavior where the most general
+ // routes can be defined at the bottom of the route map.
+ _bindRoutes: function () {
+ if (!this.routes) return;
+ this.routes = _.result(this, "routes");
+ var route, routes = _.keys(this.routes);
+ while ((route = routes.pop()) != null) {
+ this.route(route, this.routes[route]);
+ }
+ },
+
+ // Convert a route string into a regular expression, suitable for matching
+ // against the current location hash.
+ _routeToRegExp: function (route) {
+ route = route.replace(escapeRegExp, "\\$&")
+ .replace(optionalParam, "(?:$1)?")
+ .replace(namedParam, function (match, optional) {
+ return optional ? match : "([^/?]+)";
+ })
+ .replace(splatParam, "([^?]*?)");
+ return new RegExp("^" + route + "(?:\\?([\\s\\S]*))?$");
+ },
+
+ // Given a route, and a URL fragment that it matches, return the array of
+ // extracted decoded parameters. Empty or unmatched parameters will be
+ // treated as `null` to normalize cross-browser behavior.
+ _extractParameters: function (route, fragment) {
+ var params = route.exec(fragment).slice(1);
+ return _.map(params, function (param, i) {
+ // Don't decode the search params.
+ if (i === params.length - 1) return param || null;
+ return param ? decodeURIComponent(param) : null;
+ });
+ }
+
+ });
+
+ // History
+ // ----------------
+
+ // Handles cross-browser history management, based on either
+ // [pushState](http://diveintohtml5.info/history.html) and real URLs, or
+ // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
+ // and URL fragments. If the browser supports neither (old IE, natch),
+ // falls back to polling.
+ var History = function () {
+ this.handlers = [];
+ this.checkUrl = _.bind(this.checkUrl, this);
+
+ // Ensure that `History` can be used outside of the browser.
+ if (typeof window !== "undefined") {
+ this.location = _global.location;
+ this.history = _global.history;
+ }
+ };
+
+ // Cached regex for stripping a leading hash/slash and trailing space.
+ var routeStripper = /^[#\/]|\s+$/g;
+
+ // Cached regex for stripping leading and trailing slashes.
+ var rootStripper = /^\/+|\/+$/g;
+
+ // Cached regex for stripping urls of hash.
+ var pathStripper = /#.*$/;
+
+ // Has the history handling already been started?
+ History.started = false;
+
+ // Set up all inheritable **BI.History** properties and methods.
+ _.extend(History.prototype, Events, {
+
+ // The default interval to poll for hash changes, if necessary, is
+ // twenty times a second.
+ interval: 50,
+
+ // Are we at the app root?
+ atRoot: function () {
+ var path = this.location.pathname.replace(/[^\/]$/, "$&/");
+ return path === this.root && !this.getSearch();
+ },
+
+ // In IE6, the hash fragment and search params are incorrect if the
+ // fragment contains `?`.
+ getSearch: function () {
+ var match = this.location.href.replace(/#.*/, "").match(/\?.+/);
+ return match ? match[0] : "";
+ },
+
+ // Gets the true hash value. Cannot use location.hash directly due to bug
+ // in Firefox where location.hash will always be decoded.
+ getHash: function (window) {
+ var match = (window || this).location.href.match(/#(.*)$/);
+ return match ? match[1] : "";
+ },
+
+ // Get the pathname and search params, without the root.
+ getPath: function () {
+ var path = decodeURI(this.location.pathname + this.getSearch());
+ var root = this.root.slice(0, -1);
+ if (!path.indexOf(root)) path = path.slice(root.length);
+ return path.charAt(0) === "/" ? path.slice(1) : path;
+ },
+
+ // Get the cross-browser normalized URL fragment from the path or hash.
+ getFragment: function (fragment) {
+ if (fragment == null) {
+ if (this._hasPushState || !this._wantsHashChange) {
+ fragment = this.getPath();
+ } else {
+ fragment = this.getHash();
+ }
+ }
+ return fragment.replace(routeStripper, "");
+ },
+
+ // Start the hash change handling, returning `true` if the current URL matches
+ // an existing route, and `false` otherwise.
+ start: function (options) {
+ if (History.started) throw new Error("BI.history has already been started");
+ History.started = true;
+
+ // Figure out the initial configuration. Do we need an iframe?
+ // Is pushState desired ... is it available?
+ this.options = _.extend({root: "/"}, this.options, options);
+ this.root = this.options.root;
+ this._wantsHashChange = this.options.hashChange !== false;
+ this._hasHashChange = "onhashchange" in window;
+ this._wantsPushState = !!this.options.pushState;
+ this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
+ this.fragment = this.getFragment();
+
+ // Normalize root to always include a leading and trailing slash.
+ this.root = ("/" + this.root + "/").replace(rootStripper, "/");
+
+ // Transition from hashChange to pushState or vice versa if both are
+ // requested.
+ if (this._wantsHashChange && this._wantsPushState) {
+
+ // If we've started off with a route from a `pushState`-enabled
+ // browser, but we're currently in a browser that doesn't support it...
+ if (!this._hasPushState && !this.atRoot()) {
+ var root = this.root.slice(0, -1) || "/";
+ this.location.replace(root + "#" + this.getPath());
+ // Return immediately as browser will do redirect to new url
+ return true;
+
+ // Or if we've started out with a hash-based route, but we're currently
+ // in a browser where it could be `pushState`-based instead...
+ } else if (this._hasPushState && this.atRoot()) {
+ this.navigate(this.getHash(), {replace: true});
+ }
+
+ }
+
+ // Proxy an iframe to handle location events if the browser doesn't
+ // support the `hashchange` event, HTML5 history, or the user wants
+ // `hashChange` but not `pushState`.
+ if (!this._hasHashChange && this._wantsHashChange && (!this._wantsPushState || !this._hasPushState)) {
+ var iframe = document.createElement("iframe");
+ iframe.src = "javascript:0";
+ iframe.style.display = "none";
+ iframe.tabIndex = -1;
+ var body = document.body;
+ // Using `appendChild` will throw on IE < 9 if the document is not ready.
+ this.iframe = body.insertBefore(iframe, body.firstChild).contentWindow;
+ this.iframe.document.open().close();
+ this.iframe.location.hash = "#" + this.fragment;
+ }
+
+ // Add a cross-platform `addEventListener` shim for older browsers.
+ var addEventListener = _global.addEventListener || function (eventName, listener) {
+ return attachEvent("on" + eventName, listener);
+ };
+
+ // Depending on whether we're using pushState or hashes, and whether
+ // 'onhashchange' is supported, determine how we check the URL state.
+ if (this._hasPushState) {
+ addEventListener("popstate", this.checkUrl, false);
+ } else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
+ addEventListener("hashchange", this.checkUrl, false);
+ } else if (this._wantsHashChange) {
+ this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
+ }
+
+ if (!this.options.silent) return this.loadUrl();
+ },
+
+ // Disable BI.history, perhaps temporarily. Not useful in a real app,
+ // but possibly useful for unit testing Routers.
+ stop: function () {
+ // Add a cross-platform `removeEventListener` shim for older browsers.
+ var removeEventListener = _global.removeEventListener || function (eventName, listener) {
+ return detachEvent("on" + eventName, listener);
+ };
+
+ // Remove window listeners.
+ if (this._hasPushState) {
+ removeEventListener("popstate", this.checkUrl, false);
+ } else if (this._wantsHashChange && this._hasHashChange && !this.iframe) {
+ removeEventListener("hashchange", this.checkUrl, false);
+ }
+
+ // Clean up the iframe if necessary.
+ if (this.iframe) {
+ document.body.removeChild(this.iframe.frameElement);
+ this.iframe = null;
+ }
+
+ // Some environments will throw when clearing an undefined interval.
+ if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
+ History.started = false;
+ },
+
+ // Add a route to be tested when the fragment changes. Routes added later
+ // may override previous routes.
+ route: function (route, callback) {
+ this.handlers.unshift({route: route, callback: callback});
+ },
+
+ // Checks the current URL to see if it has changed, and if it has,
+ // calls `loadUrl`, normalizing across the hidden iframe.
+ checkUrl: function (e) {
+ var current = this.getFragment();
+
+ // If the user pressed the back button, the iframe's hash will have
+ // changed and we should use that for comparison.
+ if (current === this.fragment && this.iframe) {
+ current = this.getHash(this.iframe);
+ }
+
+ if (current === this.fragment) return false;
+ if (this.iframe) this.navigate(current);
+ this.loadUrl();
+ },
+
+ // Attempt to load the current URL fragment. If a route succeeds with a
+ // match, returns `true`. If no defined routes matches the fragment,
+ // returns `false`.
+ loadUrl: function (fragment) {
+ fragment = this.fragment = this.getFragment(fragment);
+ return _.some(this.handlers, function (handler) {
+ if (handler.route.test(fragment)) {
+ handler.callback(fragment);
+ return true;
+ }
+ });
+ },
+
+ // Save a fragment into the hash history, or replace the URL state if the
+ // 'replace' option is passed. You are responsible for properly URL-encoding
+ // the fragment in advance.
+ //
+ // The options object can contain `trigger: true` if you wish to have the
+ // route callback be fired (not usually desirable), or `replace: true`, if
+ // you wish to modify the current URL without adding an entry to the history.
+ navigate: function (fragment, options) {
+ if (!History.started) return false;
+ if (!options || options === true) options = {trigger: !!options};
+
+ // Normalize the fragment.
+ fragment = this.getFragment(fragment || "");
+
+ // Don't include a trailing slash on the root.
+ var root = this.root;
+ if (fragment === "" || fragment.charAt(0) === "?") {
+ root = root.slice(0, -1) || "/";
+ }
+ var url = root + fragment;
+
+ // Strip the hash and decode for matching.
+ fragment = decodeURI(fragment.replace(pathStripper, ""));
+
+ if (this.fragment === fragment) return;
+ this.fragment = fragment;
+
+ // If pushState is available, we use it to set the fragment as a real URL.
+ if (this._hasPushState) {
+ this.history[options.replace ? "replaceState" : "pushState"]({}, document.title, url);
+
+ // If hash changes haven't been explicitly disabled, update the hash
+ // fragment to store history.
+ } else if (this._wantsHashChange) {
+ this._updateHash(this.location, fragment, options.replace);
+ if (this.iframe && (fragment !== this.getHash(this.iframe))) {
+ // Opening and closing the iframe tricks IE7 and earlier to push a
+ // history entry on hash-tag change. When replace is true, we don't
+ // want this.
+ if (!options.replace) this.iframe.document.open().close();
+ this._updateHash(this.iframe.location, fragment, options.replace);
+ }
+
+ // If you've told us that you explicitly don't want fallback hashchange-
+ // based history, then `navigate` becomes a page refresh.
+ } else {
+ return this.location.assign(url);
+ }
+ if (options.trigger) return this.loadUrl(fragment);
+ },
+
+ // Update the hash location, either replacing the current entry, or adding
+ // a new one to the browser history.
+ _updateHash: function (location, fragment, replace) {
+ if (replace) {
+ var href = location.href.replace(/(javascript:|#).*$/, "");
+ location.replace(href + "#" + fragment);
+ } else {
+ // Some browsers require that `hash` contains a leading #.
+ location.hash = "#" + fragment;
+ }
+ }
+
+ });
+
+ // Create the default BI.history.
+ BI.history = new History;
+}());BI.resourceURL = "http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/resource/";BI.i18n = {
+ "BI-Multi_Date_Quarter_End": "季度末",
+ "BI-Multi_Date_Month_Begin": "月初",
+ "BI-Multi_Date_YMD": "年/月/日",
+ "BI-Custom_Color": "自定义颜色",
+ "BI-Numerical_Interval_Input_Data": "请输入数值",
+ "BI-Please_Input_Natural_Number": "请输入非负整数",
+ "BI-No_More_Data": "无更多数据",
+ "BI-Basic_Altogether": "共",
+ "BI-Basic_Sunday": "星期日",
+ "BI-Widget_Background_Colour": "组件背景",
+ "BI-Color_Picker_Error_Text": "请输入0~255的正整数",
+ "BI-Multi_Date_Month": "月",
+ "BI-No_Selected_Item": "没有可选项",
+ "BI-Multi_Date_Year_Begin": "年初",
+ "BI-Quarter_1": "第1季度",
+ "BI-Quarter_2": "第2季度",
+ "BI-Quarter_3": "第3季度",
+ "BI-Quarter_4": "第4季度",
+ "BI-Multi_Date_Year_Next": "年后",
+ "BI-Multi_Date_Month_Prev": "个月前",
+ "BI-Month_Trigger_Error_Text": "请输入1~12的正整数",
+ "BI-Less_And_Equal": "小于等于",
+ "BI-Year_Trigger_Invalid_Text": "请输入有效时间",
+ "BI-Multi_Date_Week_Next": "周后",
+ "BI-Font_Size": "字号",
+ "BI-Basic_Total": "共",
+ "BI-Already_Selected": "已选择",
+ "BI-Formula_Insert": "插入",
+ "BI-Select_All": "全选",
+ "BI-Basic_Tuesday": "星期二",
+ "BI-Multi_Date_Month_End": "月末",
+ "BI-Load_More": "点击加载更多数据",
+ "BI-Basic_September": "九月",
+ "BI-Current_Is_Last_Page": "当前已是最后一页",
+ "BI-Basic_Auto": "自动",
+ "BI-Basic_Count": "个",
+ "BI-Basic_Value": "值",
+ "BI-Basic_Unrestricted": "无限制",
+ "BI-Quarter_Trigger_Error_Text": "请输入1~4的正整数",
+ "BI-Basic_More": "更多",
+ "BI-Basic_Wednesday": "星期三",
+ "BI-Basic_Bold": "加粗",
+ "BI-Basic_Simple_Saturday": "六",
+ "BI-Multi_Date_Month_Next": "个月后",
+ "BI-Basic_March": "三月",
+ "BI-Current_Is_First_Page": "当前已是第一页",
+ "BI-Basic_Thursday": "星期四",
+ "BI-Basic_Prompt": "提示",
+ "BI-Multi_Date_Today": "今天",
+ "BI-Multi_Date_Quarter_Prev": "个季度前",
+ "BI-Row_Header": "行表头",
+ "BI-Date_Trigger_Error_Text": "日期格式示例:2015-3-11",
+ "BI-Basic_Cancel": "取消",
+ "BI-Basic_January": "一月",
+ "BI-Basic_June": "六月",
+ "BI-Basic_July": "七月",
+ "BI-Basic_April": "四月",
+ "BI-Multi_Date_Quarter_Begin": "季度初",
+ "BI-Multi_Date_Week": "周",
+ "BI-Click_Blank_To_Select": "点击\"空格键\"选中完全匹配项",
+ "BI-Basic_August": "八月",
+ "BI-Word_Align_Left": "文字居左",
+ "BI-Basic_November": "十一月",
+ "BI-Font_Colour": "字体颜色",
+ "BI-Multi_Date_Day_Prev": "天前",
+ "BI-Select_Part": "部分选择",
+ "BI-Multi_Date_Day_Next": "天后",
+ "BI-Less_Than": "小于",
+ "BI-Basic_February": "二月",
+ "BI-Multi_Date_Year": "年",
+ "BI-Number_Index": "序号",
+ "BI-Multi_Date_Week_Prev": "周前",
+ "BI-Next_Page": "下一页",
+ "BI-Right_Page": "向右翻页",
+ "BI-Numerical_Interval_Signal_Value": "前后值相等,请将操作符改为“≤”",
+ "BI-Basic_December": "十二月",
+ "BI-Basic_Saturday": "星期六",
+ "BI-Basic_Simple_Wednesday": "三",
+ "BI-Multi_Date_Quarter_Next": "个季度后",
+ "BI-Basic_October": "十月",
+ "BI-Basic_Simple_Friday": "五",
+ "BI-Basic_Save": "保存",
+ "BI-Numerical_Interval_Number_Value": "请保证前面的数值小于/等于后面的数值",
+ "BI-Previous_Page": "上一页",
+ "BI-No_Select": "搜索结果为空",
+ "BI-Basic_Clears": "清空",
+ "BI-Created_By_Me": "我创建的",
+ "BI-Basic_Simple_Tuesday": "二",
+ "BI-Word_Align_Right": "文字居右",
+ "BI-Summary_Values": "汇总",
+ "BI-Basic_Clear": "清除",
+ "BI-Upload_File_Size_Error": "文件大小不支",
+ "BI-Up_Page": "向上翻页",
+ "BI-Basic_Simple_Sunday": "日",
+ "BI-Multi_Date_Relative_Current_Time": "相对当前时间",
+ "BI-Selected_Data": "已选数据:",
+ "BI-Multi_Date_Quarter": "季度",
+ "BI-Check_Selected": "查看已选",
+ "BI-Basic_Search": "搜索",
+ "BI-Basic_May": "五月",
+ "BI-Continue_Select": "继续选择",
+ "BI-Please_Input_Positive_Integer": "请输入正整数",
+ "BI-Upload_File_Type_Error": "文件类型不支持",
+ "BI-Basic_Friday": "星期五",
+ "BI-Down_Page": "向下翻页",
+ "BI-Basic_Monday": "星期一",
+ "BI-Left_Page": "向左翻页",
+ "BI-Transparent_Color": "透明",
+ "BI-Basic_Simple_Monday": "一",
+ "BI-Multi_Date_Year_End": "年末",
+ "BI-Time_Interval_Error_Text": "请保证开始时间早于/等于结束时间",
+ "BI-Basic_Time": "时间",
+ "BI-Basic_OK": "确定",
+ "BI-Basic_Sure": "确定",
+ "BI-Basic_Simple_Thursday": "四",
+ "BI-Multi_Date_Year_Prev": "年前",
+ "BI-Tiao_Data": "条数据",
+ "BI-Basic_Italic": "斜体",
+ "BI-Basic_Dynamic_Title": "动态时间",
+ "BI-Basic_Year": "年",
+ "BI-Basic_Single_Quarter": "季",
+ "BI-Basic_Month": "月",
+ "BI-Basic_Week": "周",
+ "BI-Basic_Day": "天",
+ "BI-Basic_Work_Day": "工作日",
+ "BI-Basic_Front": "前",
+ "BI-Basic_Behind": "后",
+ "BI-Basic_Empty": "空",
+ "BI-Basic_Month_End": "月末",
+ "BI-Basic_Month_Begin": "月初",
+ "BI-Basic_Year_End": "年末",
+ "BI-Basic_Year_Begin": "年初",
+ "BI-Basic_Quarter_End": "季末",
+ "BI-Basic_Quarter_Begin": "季初",
+ "BI-Basic_Week_End": "周末",
+ "BI-Basic_Week_Begin": "周初",
+ "BI-Basic_Current_Day": "当天",
+ "BI-Basic_Begin_Start": "初",
+ "BI-Basic_End_Stop": "末",
+ "BI-Basic_Current_Year": "今年",
+ "BI-Basic_Year_Fen": "年份",
+ "BI-Basic_Current_Month": "本月",
+ "BI-Basic_Current_Quarter": "本季度",
+ "BI-Basic_Year_Month": "年月",
+ "BI-Basic_Year_Quarter": "年季度",
+ "BI-Basic_Input_Can_Not_Null": "输入框不能为空",
+ "BI-Basic_Date_Time_Error_Text": "日期格式示例:2015-3-11 00:00:00",
+ "BI-Basic_Input_From_To_Number": "请输入{R1}的数值",
+ "BI-Basic_Or": "或",
+ "BI-Basic_And": "且",
+ "BI-Conf_Add_Formula": "添加公式",
+ "BI-Conf_Add_Condition": "添加条件",
+ "BI-Conf_Formula_And": "且公式条件",
+ "BI-Conf_Formula_Or": "或公式条件",
+ "BI-Conf_Condition_And": "且条件",
+ "BI-Conf_Condition_Or": "或条件",
+ "BI-Microsoft_YaHei": "微软雅黑",
+ "BI-Apple_Light": "苹方-light",
+ "BI-Font_Family": "字体",
+ "BI-Basic_Please_Input_Content": "请输入内容",
+ "BI-Word_Align_Center": "文字居中",
+ "BI-Basic_Please_Enter_Number_Between": "请输入{R1}-{R2}的值",
+ "BI-More_Than": "大于",
+ "BI-More_And_Equal": "大于等于",
+ "BI-Please_Enter_SQL": "请输入SQL",
+ "BI-Basic_Click_To_Add_Text": "+点击新增\"{R1}\"",
+ "BI-Basic_Please_Select": "请选择",
+ "BI-Basic_Font_Color": "文字颜色",
+ "BI-Basic_Background_Color": "背景色",
+ "BI-Basic_Underline": "下划线",
+ "BI-Basic_Param_Month": "{R1}月",
+ "BI-Basic_Param_Day": "{R1}日",
+ "BI-Basic_Param_Quarter": "{R1}季度",
+ "BI-Basic_Param_Week_Count": "第{R1}周",
+ "BI-Basic_Param_Hour": "{R1}时",
+ "BI-Basic_Param_Minute": "{R1}分",
+ "BI-Basic_Param_Second": "{R1}秒",
+ "BI-Basic_Param_Year": "{R1}年",
+ "BI-Basic_Date_Day": "日",
+ "BI-Basic_Hour_Sin": "时",
+ "BI-Basic_Seconds": "秒",
+ "BI-Basic_Minute": "分",
+ "BI-Basic_Wan": "万",
+ "BI-Basic_Million": "百万",
+ "BI-Basic_Billion": "亿",
+ "BI-Basic_Quarter": "季度",
+ "BI-Basic_No_Select": "不选",
+ "BI-Basic_Now": "此刻"
+};
\ No newline at end of file
diff --git a/dist/2.0/fineui.min.css b/dist/2.0/fineui.min.css
new file mode 100644
index 0000000000..50dedf1772
--- /dev/null
+++ b/dist/2.0/fineui.min.css
@@ -0,0 +1 @@
+/*! normalize.css v1.0.0 | MIT License | git.io/normalize */dl,h3,menu,ol,p,pre,ul{margin:1em 0}.bi-font-bold,b,strong{font-weight:700}.bi-label,.td-overflow{word-break:break-all}.bi-label,.bi-text,.overflow-dot{text-overflow:ellipsis}.bi-display-tree .ztree li a:hover,.ztree li a,a{text-decoration:none}.ztree li,.ztree li span.button,a,a:active,a:focus,a:hover,div:focus,input,textarea{outline:0}.b-font,i{-webkit-text-stroke-width:.2px;-moz-osx-font-smoothing:grayscale}.b-font,body,i{-moz-osx-font-smoothing:grayscale}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}button,html,input,select,textarea{font-family:sans-serif}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.75em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}.base-disabled,.base-disabled .bi-input,.base-disabled .bi-textarea{color:#9ea6b2!important}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}small,sub,sup{font-size:75%}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:after,q:before{content:'';content:none}sub,sup{line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dd{margin:0 0 0 40px}menu,ol,ul{padding:0 0 0 40px}nav ol,nav ul{list-style:none}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure,form{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0;white-space:normal}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline}button,input{line-height:normal}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#body .bi-button,.border-sizing,body .bi-button{-webkit-box-sizing:border-box;-ms-box-sizing:border-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}*,a,body,div,html,img,li,ol,p,span,ul{margin:0;padding:0}input::-webkit-contacts-auto-fill-button{visibility:hidden;display:none!important;pointer-events:none;position:absolute;right:0}input::-ms-clear{display:none}input,textarea{margin:0;padding:0;border:1px solid #e8eaed}ul{list-style:disc}li{list-style-type:none}i{-webkit-font-smoothing:antialiased}.bi-theme-dark input,.bi-theme-dark textarea{border:1px solid #3a3c53}.base-disabled{cursor:not-allowed!important}.base-disabled .b-font:before{color:#d0d4da!important}.bi-theme-dark .base-disabled,.bi-theme-dark .base-disabled .bi-input,.bi-theme-dark .base-disabled .bi-textarea{color:#878d9f!important}.bi-theme-dark .base-disabled .b-font:before{color:#606479!important}.bi-focus-shadow:focus,.bi-focus-shadow:focus-within,.bi-focus-shadow:hover{border-color:#3685f2}.bi-focus-shadow.disabled:hover{border-color:#e8eaed}.bi-theme-dark .bi-focus-shadow.disabled:hover{border-color:#3a3c53}.base-invalid{cursor:default!important}.clearfix:after,.clearfix:before{content:" ";display:table;line-height:0}.clearfix:after{clear:both}.bi-background{background-color:#f7f8fa;color:#3d4d66}.bi-background .bi-input,.bi-background .bi-textarea{color:#3d4d66}.bi-theme-dark .bi-background{background-color:#191B2B;color:#d6e0dc}.bi-theme-dark .bi-background .bi-input,.bi-theme-dark .bi-background .bi-textarea{color:#d6e0dc}.bi-header-background{background-color:#F2F4F7;color:#647185}.bi-header-background .bi-input,.bi-header-background .bi-textarea{color:#647185}.bi-theme-dark .bi-header-background{background-color:#2F3149;color:#afb7c6}.bi-theme-dark .bi-header-background .bi-input,.bi-theme-dark .bi-header-background .bi-textarea{color:#afb7c6}.bi-card,.bi-card .bi-input,.bi-card .bi-textarea{color:#3d4d66}.bi-card{background-color:#fff}.bi-theme-dark .bi-card{background-color:#242640;color:#d6e0dc}.bi-theme-dark .bi-card .bi-input,.bi-theme-dark .bi-card .bi-textarea{color:#d6e0dc}.bi-disabled,.bi-disabled .bi-input,.bi-disabled .bi-textarea{color:#9ea6b2}.bi-theme-dark .bi-disabled,.bi-theme-dark .bi-disabled .bi-input,.bi-theme-dark .bi-disabled .bi-textarea{color:#878d9f}.bi-tips,.bi-tips .bi-input,.bi-tips .bi-textarea{color:#9ea6b2}.bi-border{border:1px solid #e8eaed}.bi-border.disabled{border-color:#d0d4da!important}.bi-border-top{border-top:1px solid #e8eaed}.bi-border-top.disabled{border-color:#d0d4da!important}.bi-border-right{border-right:1px solid #e8eaed}.bi-border-right.disabled{border-color:#d0d4da!important}.bi-border-bottom{border-bottom:1px solid #e8eaed}.bi-border-bottom.disabled{border-color:#d0d4da!important}.bi-border-left{border-left:1px solid #e8eaed}.bi-border-left.disabled{border-color:#d0d4da!important}.bi-theme-dark .bi-border{border:1px solid #3a3c53}.bi-theme-dark .bi-border-top{border-top:1px solid #3a3c53}.bi-theme-dark .bi-border-right{border-right:1px solid #3a3c53}.bi-theme-dark .bi-border-bottom{border-bottom:1px solid #3a3c53}.bi-theme-dark .bi-border-left{border-left:1px solid #3a3c53}.bi-split{border:1px solid #f2f4f7}.bi-split-top{border-top:1px solid #f2f4f7}.bi-split-right{border-right:1px solid #f2f4f7}.bi-split-bottom{border-bottom:1px solid #f2f4f7}.bi-split-left{border-left:1px solid #f2f4f7}.bi-theme-dark .bi-split{border:1px solid #2F3149}.bi-theme-dark .bi-split-top{border-top:1px solid #2F3149}.bi-theme-dark .bi-split-right{border-right:1px solid #2F3149}.bi-theme-dark .bi-split-bottom{border-bottom:1px solid #2F3149}.bi-theme-dark .bi-split-left{border-left:1px solid #2F3149}.bi-font-helvetica-neue{font-family:"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",Heiti,serif}.bi-font-arial{font-family:Arial,"Helvetica Neue","PingFang SC","Hiragino Sans GB","Microsoft YaHei",Heiti,serif}.bi-font-PingFang{font-family:"PingFang SC","Helvetica Neue",Arial,"Hiragino Sans GB","Microsoft YaHei",Heiti,serif}.bi-font-hiragino-sans{font-family:"Hiragino Sans GB","Helvetica Neue",Arial,"PingFang SC","Microsoft YaHei",Heiti,serif}.bi-font-microsoft-yaHei{font-family:"Microsoft YaHei","Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB",Heiti,serif}.bi-font-heiti{font-family:Heiti,"Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",serif}.bi-border-radius{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-keyword-red-mark,.bi-keyword-red-mark .bi-input,.bi-keyword-red-mark .bi-textarea{color:#faaa39}.bi-high-light,.bi-high-light .bi-input,.bi-high-light .bi-textarea{color:#3685f2}.bi-error,.bi-error .bi-input,.bi-error .bi-textarea{color:#ff4949}.bi-high-light-background{background-color:#3685f2;color:#fff}.bi-high-light-background .bi-input,.bi-high-light-background .bi-textarea{color:#fff}.bi-high-light-background.disabled{background-color:transparent!important;color:#9ea6b2!important}.bi-high-light-background.disabled .bi-input,.bi-high-light-background.disabled .bi-textarea{color:#9ea6b2!important}.bi-error-background{background-color:#ff4949;color:#fff}.bi-error-background .bi-input,.bi-error-background .bi-textarea{color:#fff}.bi-high-light-border{border:1px solid #3685f2}.bi-high-light-border.disabled{border-color:#d0d4da!important}.bi-water-mark{color:#9ea6b2;cursor:text}.bi-water-mark .bi-input,.bi-water-mark .bi-textarea{color:#9ea6b2}.bi-theme-dark .bi-water-mark,.bi-theme-dark .bi-water-mark .bi-input,.bi-theme-dark .bi-water-mark .bi-textarea{color:#6b7084}.bi-mask,.bi-mask .bi-input,.bi-mask .bi-textarea{color:#fff}.bi-resizer{background:#232E40;opacity:.2;filter:alpha(opacity=20);z-index:1000000000!important}.bi-theme-dark .bi-resizer{background:#fff}.bi-mask{background-color:rgba(35,46,64,.2);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#33232e40, endColorstr=#33232e40)}.bi-theme-dark .bi-mask{color:#242640;background-color:rgba(255,255,255,.2);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#33ffffff, endColorstr=#33ffffff)}.bi-theme-dark .bi-mask .bi-input,.bi-theme-dark .bi-mask .bi-textarea{color:#242640}.bi-z-index-mask{background-color:rgba(35,46,64,.5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#80232e40, endColorstr=#80232e40)}.bi-theme-dark .bi-z-index-mask{background-color:rgba(25,27,43,.8);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#cc191b2b, endColorstr=#cc191b2b)}.bi-list-item.hover,.bi-list-item:hover{color:#232e40;background-color:rgba(54,133,242,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0d3685f2, endColorstr=#0d3685f2)}.bi-list-item.hover .bi-input,.bi-list-item.hover .bi-textarea,.bi-list-item:hover .bi-input,.bi-list-item:hover .bi-textarea{color:#232e40}.bi-list-item.disabled,.bi-list-item.disabled:active,.bi-list-item.disabled:hover{background-color:transparent!important;color:#9ea6b2!important}.bi-list-item.disabled .bi-high-light,.bi-list-item.disabled .bi-input,.bi-list-item.disabled .bi-textarea,.bi-list-item.disabled:active .bi-high-light,.bi-list-item.disabled:active .bi-input,.bi-list-item.disabled:active .bi-textarea,.bi-list-item.disabled:hover .bi-high-light,.bi-list-item.disabled:hover .bi-input,.bi-list-item.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item.hover,.bi-theme-dark .bi-list-item:hover{color:#fff;background-color:rgba(54,133,242,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0d3685f2, endColorstr=#0d3685f2)}.bi-theme-dark .bi-list-item.hover .bi-input,.bi-theme-dark .bi-list-item.hover .bi-textarea,.bi-theme-dark .bi-list-item:hover .bi-input,.bi-theme-dark .bi-list-item:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item.disabled,.bi-theme-dark .bi-list-item.disabled:active,.bi-theme-dark .bi-list-item.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-theme-dark .bi-list-item.disabled .bi-high-light,.bi-theme-dark .bi-list-item.disabled .bi-input,.bi-theme-dark .bi-list-item.disabled .bi-textarea,.bi-theme-dark .bi-list-item.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item.disabled:active .bi-input,.bi-theme-dark .bi-list-item.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item.disabled:hover .bi-input,.bi-theme-dark .bi-list-item.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-border.active,.bi-list-item-border:active{border:1px solid #3685f2}.bi-list-item-simple.hover,.bi-list-item-simple.hover .bi-input,.bi-list-item-simple.hover .bi-textarea,.bi-list-item-simple:hover,.bi-list-item-simple:hover .bi-input,.bi-list-item-simple:hover .bi-textarea{color:#3685f2}.bi-list-item-simple.disabled,.bi-list-item-simple.disabled .bi-high-light,.bi-list-item-simple.disabled .bi-input,.bi-list-item-simple.disabled .bi-textarea,.bi-list-item-simple.disabled:active,.bi-list-item-simple.disabled:active .bi-high-light,.bi-list-item-simple.disabled:active .bi-input,.bi-list-item-simple.disabled:active .bi-textarea,.bi-list-item-simple.disabled:hover,.bi-list-item-simple.disabled:hover .bi-high-light,.bi-list-item-simple.disabled:hover .bi-input,.bi-list-item-simple.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-list-item-effect:hover,.bi-list-item-effect:hover .bi-input,.bi-list-item-effect:hover .bi-textarea{color:#232e40}.bi-list-item-effect.active,.bi-list-item-effect.active .bi-input,.bi-list-item-effect.active .bi-textarea,.bi-list-item-effect:active,.bi-list-item-effect:active .bi-input,.bi-list-item-effect:active .bi-textarea{color:#3685f2}.bi-list-item-effect.disabled,.bi-list-item-effect.disabled .bi-high-light,.bi-list-item-effect.disabled .bi-input,.bi-list-item-effect.disabled .bi-textarea,.bi-list-item-effect.disabled:active,.bi-list-item-effect.disabled:active .bi-high-light,.bi-list-item-effect.disabled:active .bi-input,.bi-list-item-effect.disabled:active .bi-textarea,.bi-list-item-effect.disabled:hover,.bi-list-item-effect.disabled:hover .bi-high-light,.bi-list-item-effect.disabled:hover .bi-input,.bi-list-item-effect.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item-effect:hover,.bi-theme-dark .bi-list-item-effect:hover .bi-input,.bi-theme-dark .bi-list-item-effect:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-effect.active,.bi-theme-dark .bi-list-item-effect.active .bi-input,.bi-theme-dark .bi-list-item-effect.active .bi-textarea,.bi-theme-dark .bi-list-item-effect:active,.bi-theme-dark .bi-list-item-effect:active .bi-input,.bi-theme-dark .bi-list-item-effect:active .bi-textarea{color:#3685f2}.bi-theme-dark .bi-list-item-effect.disabled,.bi-theme-dark .bi-list-item-effect.disabled:active,.bi-theme-dark .bi-list-item-effect.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-list-item-active.hover,.bi-list-item-active:active,.bi-list-item-active:hover{background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.bi-theme-dark .bi-list-item-effect.disabled .bi-high-light,.bi-theme-dark .bi-list-item-effect.disabled .bi-input,.bi-theme-dark .bi-list-item-effect.disabled .bi-textarea,.bi-theme-dark .bi-list-item-effect.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-effect.disabled:active .bi-input,.bi-theme-dark .bi-list-item-effect.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-effect.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-effect.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-effect.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-active.hover,.bi-list-item-active.hover .bi-input,.bi-list-item-active.hover .bi-textarea,.bi-list-item-active:hover,.bi-list-item-active:hover .bi-input,.bi-list-item-active:hover .bi-textarea{color:#232e40}.bi-list-item-active.active,.bi-list-item-active.active .bi-input,.bi-list-item-active.active .bi-textarea,.bi-list-item-active:active,.bi-list-item-active:active .bi-input,.bi-list-item-active:active .bi-textarea{color:#3685f2}.bi-list-item-active.disabled,.bi-list-item-active.disabled:active,.bi-list-item-active.disabled:hover{background-color:transparent!important;color:#9ea6b2!important}.bi-list-item-active.disabled .bi-high-light,.bi-list-item-active.disabled .bi-input,.bi-list-item-active.disabled .bi-textarea,.bi-list-item-active.disabled:active .bi-high-light,.bi-list-item-active.disabled:active .bi-input,.bi-list-item-active.disabled:active .bi-textarea,.bi-list-item-active.disabled:hover .bi-high-light,.bi-list-item-active.disabled:hover .bi-input,.bi-list-item-active.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item-active.hover,.bi-theme-dark .bi-list-item-active:hover{color:#fff;background-color:rgba(255,255,255,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0dffffff, endColorstr=#0dffffff)}.bi-theme-dark .bi-list-item-active.hover .bi-input,.bi-theme-dark .bi-list-item-active.hover .bi-textarea,.bi-theme-dark .bi-list-item-active:hover .bi-input,.bi-theme-dark .bi-list-item-active:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-active.active,.bi-theme-dark .bi-list-item-active:active{color:#3685f2;background-color:rgba(255,255,255,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0dffffff, endColorstr=#0dffffff)}.bi-theme-dark .bi-list-item-active.active .bi-input,.bi-theme-dark .bi-list-item-active.active .bi-textarea,.bi-theme-dark .bi-list-item-active:active .bi-input,.bi-theme-dark .bi-list-item-active:active .bi-textarea{color:#3685f2}.bi-theme-dark .bi-list-item-active.disabled,.bi-theme-dark .bi-list-item-active.disabled:active,.bi-theme-dark .bi-list-item-active.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-list-item-active2.active,.bi-list-item-active2.hover,.bi-list-item-active2:active,.bi-list-item-active2:hover{background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.bi-theme-dark .bi-list-item-active.disabled .bi-high-light,.bi-theme-dark .bi-list-item-active.disabled .bi-input,.bi-theme-dark .bi-list-item-active.disabled .bi-textarea,.bi-theme-dark .bi-list-item-active.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-active.disabled:active .bi-input,.bi-theme-dark .bi-list-item-active.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-active.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-active.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-active.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-active2.hover,.bi-list-item-active2.hover .bi-input,.bi-list-item-active2.hover .bi-textarea,.bi-list-item-active2:hover,.bi-list-item-active2:hover .bi-input,.bi-list-item-active2:hover .bi-textarea{color:#232e40}.bi-list-item-active2.active,.bi-list-item-active2.active .bi-input,.bi-list-item-active2.active .bi-textarea,.bi-list-item-active2:active,.bi-list-item-active2:active .bi-input,.bi-list-item-active2:active .bi-textarea{color:#3685f2}.bi-list-item-active2.disabled,.bi-list-item-active2.disabled:active,.bi-list-item-active2.disabled:hover{background-color:transparent!important;color:#9ea6b2!important}.bi-list-item-active2.disabled .bi-high-light,.bi-list-item-active2.disabled .bi-input,.bi-list-item-active2.disabled .bi-textarea,.bi-list-item-active2.disabled:active .bi-high-light,.bi-list-item-active2.disabled:active .bi-input,.bi-list-item-active2.disabled:active .bi-textarea,.bi-list-item-active2.disabled:hover .bi-high-light,.bi-list-item-active2.disabled:hover .bi-input,.bi-list-item-active2.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item-active2.hover,.bi-theme-dark .bi-list-item-active2:hover{color:#fff;background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.bi-theme-dark .bi-list-item-active2.hover .bi-input,.bi-theme-dark .bi-list-item-active2.hover .bi-textarea,.bi-theme-dark .bi-list-item-active2:hover .bi-input,.bi-theme-dark .bi-list-item-active2:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-active2.active,.bi-theme-dark .bi-list-item-active2:active{color:#3685f2;background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.bi-theme-dark .bi-list-item-active2.active .bi-input,.bi-theme-dark .bi-list-item-active2.active .bi-textarea,.bi-theme-dark .bi-list-item-active2:active .bi-input,.bi-theme-dark .bi-list-item-active2:active .bi-textarea{color:#3685f2}.bi-theme-dark .bi-list-item-active2.disabled,.bi-theme-dark .bi-list-item-active2.disabled:active,.bi-theme-dark .bi-list-item-active2.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-theme-dark .bi-list-item-active2.disabled .bi-high-light,.bi-theme-dark .bi-list-item-active2.disabled .bi-input,.bi-theme-dark .bi-list-item-active2.disabled .bi-textarea,.bi-theme-dark .bi-list-item-active2.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-active2.disabled:active .bi-input,.bi-theme-dark .bi-list-item-active2.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-active2.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-active2.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-active2.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-select.hover,.bi-list-item-select:hover{background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.bi-list-item-select.active,.bi-list-item-select:active{color:#fff;background-color:#3685f2}.bi-list-item-select.active .bi-high-light,.bi-list-item-select.active .bi-input,.bi-list-item-select.active .bi-textarea,.bi-list-item-select:active .bi-high-light,.bi-list-item-select:active .bi-input,.bi-list-item-select:active .bi-textarea{color:#fff}.bi-list-item-select.button-success.active,.bi-list-item-select.button-success:active{color:#fff;background-color:#13cd66}.bi-list-item-select.button-success.active .bi-high-light,.bi-list-item-select.button-success.active .bi-input,.bi-list-item-select.button-success.active .bi-textarea,.bi-list-item-select.button-success:active .bi-high-light,.bi-list-item-select.button-success:active .bi-input,.bi-list-item-select.button-success:active .bi-textarea{color:#fff}.bi-list-item-select.button-warning,.bi-list-item-select.button-warning .bi-high-light,.bi-list-item-select.button-warning .bi-input,.bi-list-item-select.button-warning .bi-textarea,.bi-list-item-select.button-warning.hover .bi-high-light,.bi-list-item-select.button-warning.hover .bi-input,.bi-list-item-select.button-warning.hover .bi-textarea,.bi-list-item-select.button-warning:hover .bi-high-light,.bi-list-item-select.button-warning:hover .bi-input,.bi-list-item-select.button-warning:hover .bi-textarea{color:#ff4949}.bi-list-item-select.button-success.active.bi-high-light-border,.bi-list-item-select.button-success:active.bi-high-light-border{border-color:#13cd66}.bi-list-item-select.button-warning.active.bi-high-light-border,.bi-list-item-select.button-warning.bi-high-light-border,.bi-list-item-select.button-warning.hover.bi-high-light-border,.bi-list-item-select.button-warning:active.bi-high-light-border,.bi-list-item-select.button-warning:hover.bi-high-light-border{border-color:#FF4949}.bi-list-item-select.button-warning.hover,.bi-list-item-select.button-warning:hover{color:#ff4949;background-color:#ffecec}.bi-list-item-select.button-warning.active,.bi-list-item-select.button-warning:active{color:#fff;background-color:#ff4949}.bi-list-item-select.button-warning.active .bi-high-light,.bi-list-item-select.button-warning.active .bi-input,.bi-list-item-select.button-warning.active .bi-textarea,.bi-list-item-select.button-warning:active .bi-high-light,.bi-list-item-select.button-warning:active .bi-input,.bi-list-item-select.button-warning:active .bi-textarea{color:#fff}.bi-list-item-select.disabled.active.bi-high-light-border,.bi-list-item-select.disabled.bi-high-light-border,.bi-list-item-select.disabled.hover.bi-high-light-border{border-color:#d0d4da}.bi-list-item-select.disabled{color:#9ea6b2!important;background-color:transparent!important}.bi-list-item-select.disabled .bi-high-light,.bi-list-item-select.disabled .bi-input,.bi-list-item-select.disabled .bi-textarea{color:#9ea6b2!important}.bi-list-item-select.disabled.active,.bi-list-item-select.disabled.hover{color:#fff!important;background-color:#d0d4da!important}.bi-list-item-select.disabled.active .bi-input,.bi-list-item-select.disabled.active .bi-textarea,.bi-list-item-select.disabled.hover .bi-input,.bi-list-item-select.disabled.hover .bi-textarea{color:#fff!important}.bi-list-item-select.disabled.active .bi-high-light,.bi-list-item-select.disabled.hover .bi-high-light{color:#9ea6b2!important}.bi-list-item-select2.active.bi-border,.bi-list-item-select2.hover.bi-border,.bi-list-item-select2:active.bi-border,.bi-list-item-select2:hover.bi-border{border-color:#3685f2}.bi-list-item-select2.hover,.bi-list-item-select2.hover .bi-input,.bi-list-item-select2.hover .bi-textarea,.bi-list-item-select2:hover,.bi-list-item-select2:hover .bi-input,.bi-list-item-select2:hover .bi-textarea{color:#232e40}.bi-list-item-select2:active,.bi-list-item-select2:active .bi-input,.bi-list-item-select2:active .bi-textarea{color:#3685f2}.bi-list-item-select2.active{color:#fff;background-color:#3685f2}.bi-list-item-select2.active .bi-input,.bi-list-item-select2.active .bi-textarea{color:#fff}.bi-list-item-select2.disabled,.bi-list-item-select2.disabled:active,.bi-list-item-select2.disabled:hover{background-color:transparent!important;color:#9ea6b2!important}.bi-list-item-select2.disabled .bi-high-light,.bi-list-item-select2.disabled .bi-input,.bi-list-item-select2.disabled .bi-textarea,.bi-list-item-select2.disabled:active .bi-high-light,.bi-list-item-select2.disabled:active .bi-input,.bi-list-item-select2.disabled:active .bi-textarea,.bi-list-item-select2.disabled:hover .bi-high-light,.bi-list-item-select2.disabled:hover .bi-input,.bi-list-item-select2.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item-select2.hover,.bi-theme-dark .bi-list-item-select2:hover{color:#fff;background-color:#242640}.bi-theme-dark .bi-list-item-select2.hover .bi-input,.bi-theme-dark .bi-list-item-select2.hover .bi-textarea,.bi-theme-dark .bi-list-item-select2:hover .bi-input,.bi-theme-dark .bi-list-item-select2:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-select2.active,.bi-theme-dark .bi-list-item-select2:active{color:#3685f2;background-color:#242640}.bi-theme-dark .bi-list-item-select2.active .bi-input,.bi-theme-dark .bi-list-item-select2.active .bi-textarea,.bi-theme-dark .bi-list-item-select2:active .bi-input,.bi-theme-dark .bi-list-item-select2:active .bi-textarea{color:#3685f2}.bi-theme-dark .bi-list-item-select2.disabled,.bi-theme-dark .bi-list-item-select2.disabled:active,.bi-theme-dark .bi-list-item-select2.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-theme-dark .bi-list-item-select2.disabled .bi-high-light,.bi-theme-dark .bi-list-item-select2.disabled .bi-input,.bi-theme-dark .bi-list-item-select2.disabled .bi-textarea,.bi-theme-dark .bi-list-item-select2.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-select2.disabled:active .bi-input,.bi-theme-dark .bi-list-item-select2.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-select2.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-select2.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-select2.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-select3.hover,.bi-list-item-select3:hover{background-color:#f7f8fa}.bi-list-item-select3.active,.bi-list-item-select3:active{color:#3685f2;background-color:#f7f8fa}.bi-list-item-select3.active .bi-input,.bi-list-item-select3.active .bi-textarea,.bi-list-item-select3:active .bi-input,.bi-list-item-select3:active .bi-textarea{color:#3685f2}.bi-list-item-select3.disabled.active,.bi-list-item-select3.disabled.hover,.bi-list-item-select3.disabled:active,.bi-list-item-select3.disabled:hover{background-color:#fff!important}.bi-theme-dark .bi-list-item-select3.hover,.bi-theme-dark .bi-list-item-select3:hover{background-color:#191B2B}.bi-theme-dark .bi-list-item-select3.active,.bi-theme-dark .bi-list-item-select3:active{color:#3685f2;background-color:#191B2B}.bi-theme-dark .bi-list-item-select3.active .bi-input,.bi-theme-dark .bi-list-item-select3.active .bi-textarea,.bi-theme-dark .bi-list-item-select3:active .bi-input,.bi-theme-dark .bi-list-item-select3:active .bi-textarea{color:#3685f2}.bi-theme-dark .bi-list-item-select3.disabled.active,.bi-theme-dark .bi-list-item-select3.disabled.hover,.bi-theme-dark .bi-list-item-select3.disabled:active,.bi-theme-dark .bi-list-item-select3.disabled:hover{background-color:#242640!important}.bi-theme-dark .bi-list-item-select.hover,.bi-theme-dark .bi-list-item-select:hover{color:#fff;background-color:rgba(255,255,255,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0dffffff, endColorstr=#0dffffff)}.bi-theme-dark .bi-list-item-select.hover .bi-input,.bi-theme-dark .bi-list-item-select.hover .bi-textarea,.bi-theme-dark .bi-list-item-select:hover .bi-input,.bi-theme-dark .bi-list-item-select:hover .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-select.active,.bi-theme-dark .bi-list-item-select:active{color:#fff;background-color:#3685f2}.bi-theme-dark .bi-list-item-select.active .bi-high-light,.bi-theme-dark .bi-list-item-select.active .bi-input,.bi-theme-dark .bi-list-item-select.active .bi-textarea,.bi-theme-dark .bi-list-item-select:active .bi-high-light,.bi-theme-dark .bi-list-item-select:active .bi-input,.bi-theme-dark .bi-list-item-select:active .bi-textarea{color:#fff}.bi-theme-dark .bi-list-item-select.disabled,.bi-theme-dark .bi-list-item-select.disabled:active,.bi-theme-dark .bi-list-item-select.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-theme-dark .bi-list-item-select.disabled .bi-high-light,.bi-theme-dark .bi-list-item-select.disabled .bi-input,.bi-theme-dark .bi-list-item-select.disabled .bi-textarea,.bi-theme-dark .bi-list-item-select.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-select.disabled:active .bi-input,.bi-theme-dark .bi-list-item-select.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-select.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-select.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-select.disabled:hover .bi-textarea{color:#878d9f!important}.bi-list-item-none.hover,.bi-list-item-none:hover{color:inherit;background-color:transparent}.bi-list-item-none.hover .bi-input,.bi-list-item-none.hover .bi-textarea,.bi-list-item-none:hover .bi-input,.bi-list-item-none:hover .bi-textarea{color:inherit}.bi-list-item-none.active,.bi-list-item-none:active{color:inherit;background-color:transparent}.bi-list-item-none.active .bi-high-light,.bi-list-item-none.active .bi-input,.bi-list-item-none.active .bi-textarea,.bi-list-item-none:active .bi-high-light,.bi-list-item-none:active .bi-input,.bi-list-item-none:active .bi-textarea{color:inherit}.bi-list-item-none.disabled,.bi-list-item-none.disabled:active,.bi-list-item-none.disabled:hover{color:#9ea6b2!important;background-color:transparent!important}.bi-list-item-none.disabled .bi-high-light,.bi-list-item-none.disabled .bi-input,.bi-list-item-none.disabled .bi-textarea,.bi-list-item-none.disabled:active .bi-high-light,.bi-list-item-none.disabled:active .bi-input,.bi-list-item-none.disabled:active .bi-textarea,.bi-list-item-none.disabled:hover .bi-high-light,.bi-list-item-none.disabled:hover .bi-input,.bi-list-item-none.disabled:hover .bi-textarea{color:#9ea6b2!important}.bi-theme-dark .bi-list-item-none.hover,.bi-theme-dark .bi-list-item-none:hover{color:inherit;background-color:transparent}.bi-theme-dark .bi-list-item-none.hover .bi-input,.bi-theme-dark .bi-list-item-none.hover .bi-textarea,.bi-theme-dark .bi-list-item-none:hover .bi-input,.bi-theme-dark .bi-list-item-none:hover .bi-textarea{color:inherit}.bi-theme-dark .bi-list-item-none.active,.bi-theme-dark .bi-list-item-none:active{color:inherit;background-color:transparent}.bi-theme-dark .bi-list-item-none.active .bi-high-light,.bi-theme-dark .bi-list-item-none.active .bi-input,.bi-theme-dark .bi-list-item-none.active .bi-textarea,.bi-theme-dark .bi-list-item-none:active .bi-high-light,.bi-theme-dark .bi-list-item-none:active .bi-input,.bi-theme-dark .bi-list-item-none:active .bi-textarea{color:inherit}.bi-theme-dark .bi-list-item-none.disabled,.bi-theme-dark .bi-list-item-none.disabled:active,.bi-theme-dark .bi-list-item-none.disabled:hover{background-color:transparent!important;color:#878d9f!important}.bi-theme-dark .bi-list-item-none.disabled .bi-high-light,.bi-theme-dark .bi-list-item-none.disabled .bi-input,.bi-theme-dark .bi-list-item-none.disabled .bi-textarea,.bi-theme-dark .bi-list-item-none.disabled:active .bi-high-light,.bi-theme-dark .bi-list-item-none.disabled:active .bi-input,.bi-theme-dark .bi-list-item-none.disabled:active .bi-textarea,.bi-theme-dark .bi-list-item-none.disabled:hover .bi-high-light,.bi-theme-dark .bi-list-item-none.disabled:hover .bi-input,.bi-theme-dark .bi-list-item-none.disabled:hover .bi-textarea{color:#878d9f!important}.cursor-pointer{cursor:pointer}.bi-popup-view,.cursor-default{cursor:default}.cursor-move{cursor:move}.y-overflow-auto{overflow-y:auto;overflow-x:hidden}.x-overflow-auto{overflow-y:hidden;overflow-x:auto}.y-overflow-scroll{overflow-y:scroll;overflow-x:hidden}.x-overflow-scroll{overflow-y:hidden;overflow-x:scroll}.overflow-auto{overflow-x:auto;overflow-y:auto}.overflow-scroll{overflow-x:scroll;overflow-y:scroll}.bi-label,.bi-segment>.center-element,.bi-text,.bi-textarea-editor,.overflow-dot,.overflow-hidden{overflow-x:hidden;overflow-y:hidden}.td-overflow{white-space:normal}.bi-label,.bi-text,.overflow-dot,.ztree li{white-space:nowrap}.display-block{display:block}.display-inline{display:inline-block}.display-table{display:table}.vertical-super{vertical-align:super}.vertical-top{vertical-align:top}.horizon-center{text-align:center}.horizon-left{text-align:left}.border-sizing{-moz-box-sizing:border-box;box-sizing:border-box}.content-sizing{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;-ms-box-sizing:content-box;box-sizing:content-box}.bi-flex-center-layout{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:center;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;-o-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-flex-align:center;-ms-align-items:center;-o-align-items:center;align-items:center}.bi-flex-horizontal-layout{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-moz-justify-content:flex-start;-ms-justify-content:flex-start;-o-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:start;-webkit-align-items:flex-start;-moz-align-items:flex-start;-ms-align-items:flex-start;-ms-flex-align:start;-o-align-items:flex-start;align-items:flex-start;-webkit-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-ms-flex-wrap:nowrap;-o-flex-wrap:nowrap;flex-wrap:nowrap}.bi-flex-horizontal-layout.middle{-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-ms-flex-align:center;-o-align-items:center;align-items:center}.bi-flex-horizontal-layout.bottom{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-moz-align-items:flex-end;-ms-align-items:flex-end;-ms-flex-align:end;-o-align-items:flex-end;align-items:flex-end}.bi-flex-vertical-center{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-moz-justify-content:flex-start;-ms-justify-content:flex-start;-o-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-ms-flex-align:center;-o-align-items:center;align-items:center;-webkit-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-ms-flex-wrap:nowrap;-o-flex-wrap:nowrap;flex-wrap:nowrap}.bi-flex-vertical-center.stretch{-webkit-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;-o-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;-ms-flex-pack:center;-o-justify-content:center;justify-content:center;-webkit-box-align:stretch;-webkit-align-items:stretch;-moz-align-items:stretch;-ms-align-items:stretch;-ms-flex-align:stretch;-o-align-items:stretch;align-items:stretch}.bi-flex-wrapper-center-layout .flex-wrapper-center-layout-wrapper{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:center;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;-ms-flex-pack:center;-o-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-ms-flex-align:center;-o-align-items:center;align-items:center;min-width:100%;min-height:100%;float:left}.bi-flex-wrapper-horizontal-layout .flex-wrapper-horizontal-layout-wrapper{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-moz-justify-content:flex-start;-ms-justify-content:flex-start;-ms-flex-pack:start;-o-justify-content:flex-start;justify-content:flex-start;-webkit-box-align:flex-start;-webkit-align-items:flex-start;-moz-align-items:flex-start;-ms-align-items:flex-start;-ms-flex-align:start;-o-align-items:flex-start;align-items:flex-start;-webkit-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-ms-flex-wrap:nowrap;-o-flex-wrap:nowrap;flex-wrap:nowrap;min-height:100%}.bi-flex-wrapper-horizontal-layout .flex-wrapper-horizontal-layout-wrapper.middle{-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-o-align-items:center;align-items:center}.bi-flex-wrapper-horizontal-layout .flex-wrapper-horizontal-layout-wrapper.bottom{-webkit-box-align:flex-end;-webkit-align-items:flex-end;-moz-align-items:flex-end;-ms-align-items:flex-end;-o-align-items:flex-end;align-items:flex-end}.bi-flex-wrapper-vertical-center .flex-wrapper-vertical-center-wrapper{display:box;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:horizontal;-webkit-flex-direction:row;-moz-flex-direction:row;-ms-flex-direction:row;-o-flex-direction:row;flex-direction:row;-webkit-box-pack:flex-start;-webkit-justify-content:flex-start;-moz-justify-content:flex-start;-ms-justify-content:flex-start;-ms-flex-pack:start;-o-justify-content:flex-start;justify-content:flex-start;-webkit-box-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-ms-flex-align:center;-o-align-items:center;align-items:center;-webkit-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-ms-flex-wrap:nowrap;-o-flex-wrap:nowrap;flex-wrap:nowrap;min-height:100%;float:left}.bi-inline-center-adapt-layout:after,.bi-inline-center-adapt-layout>.inline-center-adapt-item{display:inline-block}.bi-flex-wrapper-vertical-center .flex-wrapper-vertical-center-wrapper.stretch{width:100%;-webkit-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;-o-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-moz-justify-content:center;-ms-justify-content:center;-o-justify-content:center;justify-content:center;-webkit-box-align:stretch;-webkit-align-items:stretch;-moz-align-items:stretch;-ms-align-items:stretch;-o-align-items:stretch;align-items:stretch}.bi-inline-center-adapt-layout:after,.bi-inline-vertical-adapt-layout:after{width:0;min-height:100%;content:' ';vertical-align:middle}.bi-inline-center-adapt-layout>.bi-combo.bi-combo-popup,.bi-inline-center-adapt-layout>.inline-center-adapt-item.x-icon{display:inline-block!important}.bi-inline-vertical-adapt-layout:after,.bi-inline-vertical-adapt-layout>.inline-vertical-adapt-item{display:inline-block}.bi-inline-vertical-adapt-layout>.bi-combo.bi-combo-popup,.bi-inline-vertical-adapt-layout>.inline-vertical-adapt-item.x-icon{display:inline-block!important}.bi-theme-dark{color:#d6e0dc}.bi-theme-dark .bi-input{color:#fff}.bi-icon-text-value-combo.combo-error .bi-text-trigger .select-text-label,.bi-search-text-value-combo.combo-error .bi-search-text-value-trigger .bi-text-button,.bi-text-value-combo.combo-error .bi-select-text-trigger .select-text-label{color:#ff4949}.bi-year-calendar{padding-top:5px;padding-bottom:5px}.bi-color-chooser-popup .disable-mask{opacity:.5;filter:alpha(opacity=50);background-color:#fff}.bi-color-chooser-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-color-picker-button .color-picker-button-mask{border:1px solid #232e40}.bi-theme-dark .bi-color-picker-button .color-picker-button-mask{border:1px solid #fff}.bi-color-picker-editor .color-picker-editor-display{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-color-picker-editor.disabled .auto-color-normal-background{background:url(images/2x/background/auto_color_normal_disable.png) center center no-repeat;background-size:contain}.bi-color-picker-editor.disabled .auto-color-normal-background.hack{background:url(images/1x/background/auto_color_normal_disable.png) center center no-repeat}.bi-color-picker-editor.disabled .trans-color-background{background:url(images/2x/background/trans_disable.png) center center no-repeat;background-size:contain}.bi-color-picker-editor.disabled .trans-color-background.hack{background:url(images/1x/background/trans_disable.png) center center no-repeat}.bi-farbtastic *{cursor:crosshair}.bi-farbtastic .marker{margin:-8px 0 0 -8px}.bi-bubble-combo .button-combo-triangle-wrapper{position:fixed!important;line-height:0;z-index:10000000}.bi-bubble-combo .bubble-combo-triangle-left{z-index:1;position:absolute;width:6px;height:16px;text-align:left}.bi-bubble-combo .bubble-combo-triangle-left:before{position:absolute;width:6px;height:6px;margin-left:-3px;margin-top:4px;content:"";transform:rotate(-45deg)}.bi-bubble-combo .bubble-combo-triangle-right{z-index:1;position:absolute;width:6px;height:16px;text-align:left}.bi-bubble-combo .bubble-combo-triangle-right:before{position:absolute;width:6px;height:6px;margin-left:2px;margin-top:3px;content:"";transform:rotate(135deg)}.bi-bubble-combo .bubble-combo-triangle-top{z-index:1;position:absolute;width:16px;height:6px;text-align:left}.bi-bubble-combo .bubble-combo-triangle-top:before{position:absolute;width:6px;height:6px;margin-left:4px;margin-top:-3px;content:"";transform:rotate(45deg)}.bi-bubble-combo .bubble-combo-triangle-bottom{z-index:1;position:absolute;width:16px;height:6px;text-align:left}.bi-bubble-combo .bubble-combo-triangle-bottom:before{position:absolute;width:6px;height:6px;margin-left:4px;margin-top:2px;content:"";transform:rotate(-135deg)}.bi-bubble-combo .bubble-combo-triangle-bottom:before,.bi-bubble-combo .bubble-combo-triangle-left:before,.bi-bubble-combo .bubble-combo-triangle-right:before,.bi-bubble-combo .bubble-combo-triangle-top:before{background-color:#fff;border-bottom:1px solid #f2f4f7;border-right:1px solid #f2f4f7}.bi-theme-dark .bi-bubble-combo .bubble-combo-triangle-bottom:before,.bi-theme-dark .bi-bubble-combo .bubble-combo-triangle-left:before,.bi-theme-dark .bi-bubble-combo .bubble-combo-triangle-right:before,.bi-theme-dark .bi-bubble-combo .bubble-combo-triangle-top:before{background-color:#242640;border-bottom:1px solid #2F3149;border-right:1px solid #2F3149}.bi-combo>.bi-trigger .bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-combo.bi-combo-popup{display:block!important;visibility:visible!important}#body .bi-button.button-common.disabled:after,#body .bi-button.button-error.disabled:after,#body .bi-button.button-ignore.disabled:after,#body .bi-button.button-success.disabled:after,#body .bi-button.button-warning.disabled:after,body .bi-button.button-common.disabled:after,body .bi-button.button-error.disabled:after,body .bi-button.button-ignore.disabled:after,body .bi-button.button-success.disabled:after,body .bi-button.button-warning.disabled:after{display:none}.bi-combo.bi-combo-popup>.bi-trigger .bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-combo.bi-combo-hover>.bi-border,.bi-combo.bi-combo-popup>.bi-border,.bi-combo:hover>.bi-border{border-color:#3685f2}.bi-combo.disabled.bi-combo-hover>.bi-border,.bi-combo.disabled:hover>.bi-border{border-color:#e8eaed}.bi-theme-dark .bi-combo.disabled.bi-combo-hover>.bi-border,.bi-theme-dark .bi-combo.disabled:hover>.bi-border{border-color:#3a3c53}.bi-search-text-value-combo .trigger-icon-button{font-size:16px}.bi-search-text-value-combo .search-text-value-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-search-text-value-combo .bi-combo.bi-combo-popup+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-search-text-value-combo .bi-combo+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-all-count-pager .row-count,.bi-segment-button{color:#3685f2}.bi-text-value-check-combo.bi-combo-popup>.bi-border,.bi-text-value-check-combo:hover>.bi-border,.bi-text-value-down-list-combo.bi-combo-popup>.bi-border,.bi-text-value-down-list-combo:hover>.bi-border{border-color:#3685f2}.bi-bubble-bar-popup-view .bar-popup-container{max-height:456px}.bi-search-editor{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-search-editor .circle-close-font,.bi-search-editor .search-font{font-size:18px}.bi-small-search-editor .bi-editor,.bi-small-search-editor .bi-editor .bi-input,.bi-small-search-editor .bi-editor .bi-label{font-size:12px}.bi-small-search-editor .close-font,.bi-small-search-editor .search-font{font-size:16px}.bi-message-title{font-size:14px;cursor:pointer}.bi-message-text{font-size:16px;-webkit-user-select:text;-khtml-user-select:text;-moz-user-select:text;-ms-user-select:text;-o-user-select:text;user-select:text}.bi-message-close,.bi-message-content{font-size:16px}.bi-message-animate{-webkit-transition:opacity .3s,transform .3s,left .3s,right .3s,top .4s,bottom .3s;-moz-transition:opacity .3s,transform .3s,left .3s,right .3s,top .4s,bottom .3s;-o-transition:opacity .3s,transform .3s,left .3s,right .3s,top .4s,bottom .3s;transition:opacity .3s,transform .3s,left .3s,right .3s,top .4s,bottom .3s}.bi-message-enter{opacity:1}.bi-message-leave{opacity:0;transform:translateY(-100%)}.bi-multi-list-view .bi-button-mask{opacity:.1;filter:alpha(opacity=10)}.bi-panel{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-panel .panel-title .panel-title-text{cursor:text;font-size:14px}.bi-all-count-pager .all-pager-next,.bi-all-count-pager .all-pager-prev,.bi-direction-pager .direction-pager-next,.bi-direction-pager .direction-pager-prev{font-size:16px}.bi-sortable-holder{border:1px dashed #e8eaed}.bi-half-button,.bi-pager .page-item{-webkit-border-radius:2px;-moz-border-radius:2px}.bi-pager .page-item{border-radius:2px}.bi-pane{min-height:25px}.bi-pane.loading-status{min-height:55px}.bi-pane .loading-container{background-color:rgba(247,248,250,0);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#00f7f8fa, endColorstr=#00f7f8fa)}.bi-loading-widget{font-size:0}.bi-loading-widget .animate-rect{background-color:rgba(54,133,242,.9);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#e63685f2, endColorstr=#e63685f2);-webkit-border-radius:1.5px;-moz-border-radius:1.5px;border-radius:1.5px;-webkit-animation:loading-widget .8s infinite linear;-moz-animation:loading-widget .8s infinite linear;-ms-animation:loading-widget .8s infinite linear;-o-animation:loading-widget .8s infinite linear;animation:loading-widget .8s infinite linear}.bi-loading-widget .rect2{-webkit-animation-delay:-.2s;-moz-animation-delay:-.2s;-ms-animation-delay:-.2s;-o-animation-delay:-.2s;animation-delay:-.2s}.bi-loading-widget .rect3{-webkit-animation-delay:-.4s;-moz-animation-delay:-.4s;-ms-animation-delay:-.4s;-o-animation-delay:-.4s;animation-delay:-.4s}@-webkit-keyframes loading-widget{0%,100%{-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);-ms-transform:scaleY(.3);transform:scaleY(.3)}50%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);-ms-transform:scaleY(1);transform:scaleY(1)}}@-moz-keyframes loading-widget{0%,100%{-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);-ms-transform:scaleY(.3);transform:scaleY(.3)}50%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);-ms-transform:scaleY(1);transform:scaleY(1)}}@-ms-keyframes loading-widget{0%,100%{-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);-ms-transform:scaleY(.3);transform:scaleY(.3)}50%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);-ms-transform:scaleY(1);transform:scaleY(1)}}@-o-keyframes loading-widget{0%,100%{-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);-ms-transform:scaleY(.3);transform:scaleY(.3)}50%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);-ms-transform:scaleY(1);transform:scaleY(1)}}@keyframes loading-widget{0%,100%{-webkit-transform:scaleY(.3);-moz-transform:scaleY(.3);-o-transform:scaleY(.3);-ms-transform:scaleY(.3);transform:scaleY(.3)}50%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);-ms-transform:scaleY(1);transform:scaleY(1)}}.bi-loading-widget.hack{background:url(images/1x/icon/wave_loading.gif) center center no-repeat}.bi-loading-widget.hack .animate-rect{background-color:rgba(54,133,242,0);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#003685f2, endColorstr=#003685f2)}.bi-segment>.center-element{overflow:hidden;background:#fff;border-right:1px solid #3685f2;border-top:1px solid #3685f2;border-bottom:1px solid #3685f2}.bi-segment>.first-element{border-left:1px solid #3685f2;-webkit-border-radius:2px 0 0 2px;-moz-border-radius:2px 0 0 2px;border-radius:2px 0 0 2px}.bi-segment>.last-element{-webkit-border-radius:0 2px 2px 0;-moz-border-radius:0 2px 2px 0;border-radius:0 2px 2px 0}.bi-segment.disabled>.center-element,.bi-segment.disabled>.first-element{border-color:#d0d4da}.bi-theme-dark .bi-segment>.center-element{overflow:hidden;overflow-x:hidden;overflow-y:hidden;background:#242640;border-right:1px solid #3a3c53;border-top:1px solid #3a3c53;border-bottom:1px solid #3a3c53}.bi-theme-dark .bi-segment>.first-element{border-left:1px solid #242640}.bi-half-button{border-radius:2px}#body .bi-button,body .bi-button{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;border:1px solid #3685f2;background-color:#3685f2;-moz-box-sizing:border-box;box-sizing:border-box;text-align:center;vertical-align:middle;cursor:pointer}#body .bi-button.clear,#body .bi-button.ghost,body .bi-button.clear,body .bi-button.ghost{font-size:inherit;background-color:transparent}#body .bi-button.block,body .bi-button.block{font-size:inherit;border-width:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}#body .bi-button.clear,body .bi-button.clear{border-width:0}#body .bi-button.clear:hover,body .bi-button.clear:hover{opacity:.9;filter:alpha(opacity=90)}#body .bi-button.clear:active,body .bi-button.clear:active{opacity:.8;filter:alpha(opacity=80)}#body .bi-button.button-common,#body .bi-button.button-common .b-font:before,body .bi-button.button-common,body .bi-button.button-common .b-font:before{color:#fff}#body .bi-button.button-common.clear,#body .bi-button.button-common.clear .b-font:before,#body .bi-button.button-common.ghost,#body .bi-button.button-common.ghost .b-font:before,body .bi-button.button-common.clear,body .bi-button.button-common.clear .b-font:before,body .bi-button.button-common.ghost,body .bi-button.button-common.ghost .b-font:before{color:#3685f2}#body .bi-button.button-common.ghost:hover,body .bi-button.button-common.ghost:hover{color:#fff;background-color:#3685f2}#body .bi-button.button-common.ghost:active,body .bi-button.button-common.ghost:active{background-color:#3685f2}#body .bi-button.button-ignore,body .bi-button.button-ignore{background-color:transparent;border-color:#3685f2}#body .bi-button.button-ignore,#body .bi-button.button-ignore .b-font:before,body .bi-button.button-ignore,body .bi-button.button-ignore .b-font:before{color:#3685f2}#body .bi-button.button-ignore.clear,body .bi-button.button-ignore.clear{background-color:transparent;border-width:0}#body .bi-button.button-success,body .bi-button.button-success{background-color:#13cd66;border-color:#13cd66}#body .bi-button.button-success,#body .bi-button.button-success .b-font:before,body .bi-button.button-success,body .bi-button.button-success .b-font:before{color:#fff}#body .bi-button.button-success.clear,body .bi-button.button-success.clear{background-color:transparent;border-width:0}#body .bi-button.button-success.clear,#body .bi-button.button-success.clear .b-font:before,body .bi-button.button-success.clear,body .bi-button.button-success.clear .b-font:before{color:#13cd66}#body .bi-button.button-warning,body .bi-button.button-warning{background-color:#faaa39;border-color:#fbb03b}#body .bi-button.button-warning,#body .bi-button.button-warning .b-font:before,body .bi-button.button-warning,body .bi-button.button-warning .b-font:before{color:#fff}#body .bi-button.button-warning.clear,body .bi-button.button-warning.clear{background-color:transparent;border-width:0}#body .bi-button.button-warning.clear,#body .bi-button.button-warning.clear .b-font:before,body .bi-button.button-warning.clear,body .bi-button.button-warning.clear .b-font:before{color:#faaa39}#body .bi-button.button-error,body .bi-button.button-error{background-color:#ff4949;border-color:#FF4949}#body .bi-button.button-error,#body .bi-button.button-error .b-font:before,body .bi-button.button-error,body .bi-button.button-error .b-font:before{color:#fff}#body .bi-button.button-error.clear,body .bi-button.button-error.clear{background-color:transparent;border-width:0}#body .bi-button.button-error.clear,#body .bi-button.button-error.clear .b-font:before,body .bi-button.button-error.clear,body .bi-button.button-error.clear .b-font:before{color:#ff4949}#body .bi-button.button-common.disabled,#body .bi-button.button-common.disabled .b-font:before,#body .bi-button.button-common.disabled.base-disabled,#body .bi-button.button-common.disabled.base-disabled .b-font:before,#body .bi-button.button-common.disabled.clear,#body .bi-button.button-common.disabled.clear .b-font:before,#body .bi-button.button-error.disabled,#body .bi-button.button-error.disabled .b-font:before,#body .bi-button.button-error.disabled.base-disabled,#body .bi-button.button-error.disabled.base-disabled .b-font:before,#body .bi-button.button-error.disabled.clear,#body .bi-button.button-error.disabled.clear .b-font:before,#body .bi-button.button-ignore.disabled,#body .bi-button.button-ignore.disabled .b-font:before,#body .bi-button.button-ignore.disabled.clear,#body .bi-button.button-ignore.disabled.clear .b-font:before,#body .bi-button.button-success.disabled,#body .bi-button.button-success.disabled .b-font:before,#body .bi-button.button-success.disabled.base-disabled,#body .bi-button.button-success.disabled.base-disabled .b-font:before,#body .bi-button.button-success.disabled.clear,#body .bi-button.button-success.disabled.clear .b-font:before,#body .bi-button.button-warning.disabled,#body .bi-button.button-warning.disabled .b-font:before,#body .bi-button.button-warning.disabled.base-disabled,#body .bi-button.button-warning.disabled.base-disabled .b-font:before,#body .bi-button.button-warning.disabled.clear,#body .bi-button.button-warning.disabled.clear .b-font:before,body .bi-button.button-common.disabled,body .bi-button.button-common.disabled .b-font:before,body .bi-button.button-common.disabled.base-disabled,body .bi-button.button-common.disabled.base-disabled .b-font:before,body .bi-button.button-common.disabled.clear,body .bi-button.button-common.disabled.clear .b-font:before,body .bi-button.button-error.disabled,body .bi-button.button-error.disabled .b-font:before,body .bi-button.button-error.disabled.base-disabled,body .bi-button.button-error.disabled.base-disabled .b-font:before,body .bi-button.button-error.disabled.clear,body .bi-button.button-error.disabled.clear .b-font:before,body .bi-button.button-ignore.disabled,body .bi-button.button-ignore.disabled .b-font:before,body .bi-button.button-ignore.disabled.clear,body .bi-button.button-ignore.disabled.clear .b-font:before,body .bi-button.button-success.disabled,body .bi-button.button-success.disabled .b-font:before,body .bi-button.button-success.disabled.base-disabled,body .bi-button.button-success.disabled.base-disabled .b-font:before,body .bi-button.button-success.disabled.clear,body .bi-button.button-success.disabled.clear .b-font:before,body .bi-button.button-warning.disabled,body .bi-button.button-warning.disabled .b-font:before,body .bi-button.button-warning.disabled.base-disabled,body .bi-button.button-warning.disabled.base-disabled .b-font:before,body .bi-button.button-warning.disabled.clear,body .bi-button.button-warning.disabled.clear .b-font:before{color:#9ea6b2!important}#body .bi-button.button-common.disabled,#body .bi-button.button-common.disabled.base-disabled,#body .bi-button.button-error.disabled,#body .bi-button.button-error.disabled.base-disabled,#body .bi-button.button-success.disabled,#body .bi-button.button-success.disabled.base-disabled,#body .bi-button.button-warning.disabled,#body .bi-button.button-warning.disabled.base-disabled,body .bi-button.button-common.disabled,body .bi-button.button-common.disabled.base-disabled,body .bi-button.button-error.disabled,body .bi-button.button-error.disabled.base-disabled,body .bi-button.button-success.disabled,body .bi-button.button-success.disabled.base-disabled,body .bi-button.button-warning.disabled,body .bi-button.button-warning.disabled.base-disabled{background:#F2F4F7!important;border-color:#d0d4da!important}#body .bi-button.button-ignore.disabled,body .bi-button.button-ignore.disabled{background:#fff!important;border-color:#e8eaed!important}#body .bi-button.button-common.disabled.clear,#body .bi-button.button-error.disabled.clear,#body .bi-button.button-ignore.disabled.clear,#body .bi-button.button-success.disabled.clear,#body .bi-button.button-warning.disabled.clear,body .bi-button.button-common.disabled.clear,body .bi-button.button-error.disabled.clear,body .bi-button.button-ignore.disabled.clear,body .bi-button.button-success.disabled.clear,body .bi-button.button-warning.disabled.clear{background:0 0!important;border-width:0!important}#body .bi-button.button-common.disabled.clear:active,#body .bi-button.button-common.disabled.clear:hover,#body .bi-button.button-error.disabled.clear:active,#body .bi-button.button-error.disabled.clear:hover,#body .bi-button.button-ignore.disabled.clear:active,#body .bi-button.button-ignore.disabled.clear:hover,#body .bi-button.button-success.disabled.clear:active,#body .bi-button.button-success.disabled.clear:hover,#body .bi-button.button-warning.disabled.clear:active,#body .bi-button.button-warning.disabled.clear:hover,body .bi-button.button-common.disabled.clear:active,body .bi-button.button-common.disabled.clear:hover,body .bi-button.button-error.disabled.clear:active,body .bi-button.button-error.disabled.clear:hover,body .bi-button.button-ignore.disabled.clear:active,body .bi-button.button-ignore.disabled.clear:hover,body .bi-button.button-success.disabled.clear:active,body .bi-button.button-success.disabled.clear:hover,body .bi-button.button-warning.disabled.clear:active,body .bi-button.button-warning.disabled.clear:hover{opacity:1;filter:alpha(opacity=100)}#body .bi-button.button-common.disabled.ghost,#body .bi-button.button-error.disabled.ghost,#body .bi-button.button-ignore.disabled.ghost,#body .bi-button.button-success.disabled.ghost,#body .bi-button.button-warning.disabled.ghost,body .bi-button.button-common.disabled.ghost,body .bi-button.button-error.disabled.ghost,body .bi-button.button-ignore.disabled.ghost,body .bi-button.button-success.disabled.ghost,body .bi-button.button-warning.disabled.ghost{background:0 0!important;border-color:#3685f2!important;opacity:.5;filter:alpha(opacity=50)}#body .bi-button.button-common.disabled.ghost,#body .bi-button.button-common.disabled.ghost .b-font:before,#body .bi-button.button-error.disabled.ghost,#body .bi-button.button-error.disabled.ghost .b-font:before,#body .bi-button.button-ignore.disabled.ghost,#body .bi-button.button-ignore.disabled.ghost .b-font:before,#body .bi-button.button-success.disabled.ghost,#body .bi-button.button-success.disabled.ghost .b-font:before,#body .bi-button.button-warning.disabled.ghost,#body .bi-button.button-warning.disabled.ghost .b-font:before,body .bi-button.button-common.disabled.ghost,body .bi-button.button-common.disabled.ghost .b-font:before,body .bi-button.button-error.disabled.ghost,body .bi-button.button-error.disabled.ghost .b-font:before,body .bi-button.button-ignore.disabled.ghost,body .bi-button.button-ignore.disabled.ghost .b-font:before,body .bi-button.button-success.disabled.ghost,body .bi-button.button-success.disabled.ghost .b-font:before,body .bi-button.button-warning.disabled.ghost,body .bi-button.button-warning.disabled.ghost .b-font:before{color:#3685f2!important}.bi-basic-button.button-common:after,.bi-basic-button.button-error:after,.bi-basic-button.button-success:after,.bi-basic-button.button-warning:after{content:"";background-color:#232E40;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;display:block;width:100%;height:100%;position:absolute;transform:scale(1,1);opacity:0;filter:alpha(opacity=0);-webkit-transition:transform .5s ease,opacity 1s ease;-moz-transition:transform .5s ease,opacity 1s ease;-o-transition:transform .5s ease,opacity 1s ease;transition:transform .5s ease,opacity 1s ease;left:0;top:0;pointer-events:none}.bi-basic-button.button-common.hack:after,.bi-basic-button.button-error.hack:after,.bi-basic-button.button-success.hack:after,.bi-basic-button.button-warning.hack:after{content:none}.bi-basic-button.button-common:active:after,.bi-basic-button.button-error:active:after,.bi-basic-button.button-success:active:after,.bi-basic-button.button-warning:active:after{transform:scale(0,1);opacity:.1;filter:alpha(opacity=10);-webkit-transition:transform 0s;-moz-transition:transform 0s;-o-transition:transform 0s;transition:transform 0s}.bi-basic-button.button-common:hover .bi-button-mask,.bi-basic-button.button-error:hover .bi-button-mask,.bi-basic-button.button-success:hover .bi-button-mask,.bi-basic-button.button-warning:hover .bi-button-mask{opacity:.1;filter:alpha(opacity=10);background-color:#fff;-webkit-transition:opacity .3s ease;-moz-transition:opacity .3s ease;-o-transition:opacity .3s ease;transition:opacity .3s ease}.bi-basic-button.button-ignore:after{content:"";background-color:#3685f2;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;display:block;width:100%;height:100%;position:absolute;transform:scale(1,1);opacity:0;filter:alpha(opacity=0);-webkit-transition:transform .5s ease,opacity 1s ease;-moz-transition:transform .5s ease,opacity 1s ease;-o-transition:transform .5s ease,opacity 1s ease;transition:transform .5s ease,opacity 1s ease;left:0;top:0;pointer-events:none}.bi-basic-button.button-ignore.hack:after{content:none}.bi-basic-button.button-ignore:active:after{transform:scale(0,1);opacity:.1;filter:alpha(opacity=10);-webkit-transition:transform 0s;-moz-transition:transform 0s;-o-transition:transform 0s;transition:transform 0s}.bi-basic-button.button-ignore:hover{background-color:rgba(54,133,242,.05);-webkit-transition:opacity .3s ease;-moz-transition:opacity .3s ease;-o-transition:opacity .3s ease;transition:opacity .3s ease}.bi-basic-button .popup-content{font-size:14px}.bi-theme-dark #body .bi-button.button-common.ghost,.bi-theme-dark #body .bi-button.button-common.ghost .b-font:before,.bi-theme-dark body .bi-button.button-common.ghost,.bi-theme-dark body .bi-button.button-common.ghost .b-font:before{color:#fff;border-color:#fff}.bi-theme-dark #body .bi-button.button-common.ghost:hover,.bi-theme-dark body .bi-button.button-common.ghost:hover{color:#3d4d66;background-color:#fff}.bi-theme-dark #body .bi-button.button-common.ghost:active,.bi-theme-dark body .bi-button.button-common.ghost:active{background-color:rgba(255,255,255,.9);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#e6ffffff, endColorstr=#e6ffffff)}.bi-theme-dark #body .bi-button.button-ignore:hover,.bi-theme-dark body .bi-button.button-ignore:hover{background-color:rgba(54,133,242,.05)}.bi-theme-dark #body .bi-button.button-ignore:active,.bi-theme-dark body .bi-button.button-ignore:active{background-color:rgba(54,133,242,.1)}.bi-theme-dark #body .bi-button.button-common.disabled.ghost,.bi-theme-dark body .bi-button.button-common.disabled.ghost{background:0 0!important;border-color:#fff!important;opacity:.5;filter:alpha(opacity=50)}.bi-theme-dark #body .bi-button.button-common.disabled.ghost,.bi-theme-dark #body .bi-button.button-common.disabled.ghost .b-font:before,.bi-theme-dark body .bi-button.button-common.disabled.ghost,.bi-theme-dark body .bi-button.button-common.disabled.ghost .b-font:before{color:#fff!important}.bi-single-select-icon-text-item.active .b-font:before,.bi-single-select-icon-text-item:active .b-font:before{color:#3685f2}.bi-switch{-webkit-border-radius:40px 40px 40px 40px;-moz-border-radius:40px;border-radius:40px;background-color:#d0d4da}.bi-switch.active,.bi-switch:active{background-color:#3685f2}.bi-switch .circle-button{-webkit-border-radius:9px 9px 9px 9px;-moz-border-radius:9px;border-radius:9px}.bi-switch.disabled,.bi-switch.disabled:active{background-color:#F2F4F7}.bi-theme-dark .bi-switch{background-color:#606479}.bi-theme-dark .bi-switch.active,.bi-theme-dark .bi-switch:active{background-color:#3685f2}.bi-theme-dark .bi-switch.disabled,.bi-theme-dark .bi-switch.disabled:active{background-color:#2F3149}.bi-multifile-editor .multifile-editor{text-align:right;cursor:pointer;font-size:100px;z-index:2}.bi-textarea-editor{overflow:hidden}.bi-textarea-editor .textarea-editor-content{font-size:12px;line-height:21px;border:none}.x-icon.b-font{margin:auto;width:100%}.bi-checkbox .checkbox-context{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-checkbox .checkbox-context:after{position:absolute;display:table;top:50%;left:22%;border:2px solid transparent;border-top:0;border-left:0;width:4px;height:8px;-webkit-transform:rotate(45deg) scale(1) translate(-50%,-50%);-moz-transform:rotate(45deg) scale(1) translate(-50%,-50%);-o-transform:rotate(45deg) scale(1) translate(-50%,-50%);-ms-transform:rotate(45deg) scale(1) translate(-50%,-50%);transform:rotate(45deg) scale(1) translate(-50%,-50%);content:''}.bi-checkbox.active .checkbox-context:after,.bi-checkbox:active .checkbox-context:after{border-color:#fff;opacity:1}.bi-checkbox.disabled .checkbox-context:after,.bi-file{opacity:0}.bi-file{filter:alpha(opacity=0);z-index:2}.bi-input,.bi-textarea{border:none;outline:0;background-color:transparent;padding:0;margin:0;width:100%;height:100%}.bi-input.bi-input-focus,.bi-textarea.bi-input-focus{border:none}.bi-input.bi-input-error,.bi-textarea.bi-input-error{border:none;color:#ff4949!important}.bi-radio .radio-content{-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px}.bi-radio .radio-content:after{content:""}.bi-radio.active .radio-content:after,.bi-radio:active .radio-content:after{width:6px;height:6px;display:table;position:absolute;top:50%;left:50%;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;background-color:#fff;-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.bi-bubble .bubble-text,.bi-toast{-webkit-border-radius:2px;-moz-border-radius:2px}.bi-radio.disabled.active .radio-content:after,.bi-radio.disabled:active .radio-content:after{background-color:transparent}.bi-text{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;word-break:break-word}.bi-bubble .bubble-text{border-radius:2px}.bi-bubble .bubble-error{background:#ffecec;color:#ff4949}.bi-theme-dark .bi-bubble .bubble-error{background:#3A2940}.bi-bubble .bubble-common{background:#eaf2fd;color:#3685f2}.bi-bubble .bubble-success{background:#e1f4e7;color:#13cd66}.bi-bubble .bubble-warning{background:#feeed7;color:#faaa39}.bi-tip{position:fixed!important}.bi-toast{color:#fff;max-width:400px;min-width:150px;border-radius:2px}.bi-toast.toast-success{background:#13cd66}.bi-toast.toast-warning{background:#faaa39}.bi-toast.toast-error{background:#ff4949}.bi-toast.toast-normal{background:#3685f2}.bi-toast .toast-icon{font-size:16px}.bi-tooltip{max-width:250px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;font-size:12px;color:#fff}.bi-tooltip.tooltip-success{background:#647185;border:1px solid #647185}.bi-tooltip.tooltip-warning{background:#ff4949;border:1px solid #FF4949}.bi-branch-tree .bi-branch-tree-view{min-width:300px}.bi-display-tree .ztree *{color:#999}.bi-display-tree .ztree li a,.bi-display-tree .ztree li span{cursor:default!important}.ztree li a,.ztree li span.button{cursor:pointer;display:inline-block}.bi-display-tree .ztree li a.curSelectedNode{padding-top:1px;border:none;background-color:inherit;opacity:1;filter:alpha(opacity=100)}.ztree *{padding:0;margin:0}.ztree{margin:0;padding:5px}.ztree li{padding:0;margin:0;list-style:none;line-height:14px;text-align:left}.ztree li ul{margin:0;padding:0 0 0 18px}.ztree li a{padding:1px 3px 0 0;margin:0;height:24px;background-color:transparent;vertical-align:top}.ztree li a:active,.ztree li a:hover{background-color:rgba(54,133,242,.06);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0f3685f2, endColorstr=#0f3685f2)}.ztree li a:active{color:#3685f2}.ztree li a.tmpTargetNode_inner,ul.tmpTargetzTree,ul.ztree.zTreeDragUL{opacity:.8;filter:alpha(opacity=80)}.ztree li a.curSelectedNode_Edit{padding-top:0;background-color:#FFE6B0;color:#000;height:16px;border:1px solid #FFB951;opacity:.8}.ztree li a.tmpTargetNode_inner{padding-top:0;background-color:#316AC5;color:#fff;height:16px;border:1px solid #316AC5}.ztree li a input.rename{height:14px;width:80px;padding:0;margin:0;font-size:12px;border:1px solid #7EC4CC}.bi-dynamic-date-combo .date-font,.bi-multi-select-combo .multi-select-trigger-icon-button,.bi-multi-select-insert-combo .multi-select-trigger-icon-button,.bi-multi-tree-combo .multi-select-trigger-icon-button,.bi-trigger .bi-trigger-icon-button{font-size:16px}.ztree li span{line-height:24px;margin-right:2px}.ztree li span.button{line-height:0;margin:0;width:16px;height:16px;vertical-align:middle;border:0;background-color:transparent;background-repeat:no-repeat;background-attachment:scroll}.ztree li span.button.chk{width:16px;height:16px;margin:0 3px 0 0;cursor:auto}.ztree li span.button.chk.checkbox_false_disable{background-position:0 -56px}.ztree li span.button.chk.checkbox_true_disable{background-position:-14px -56px}.ztree li span.button.chk.radio_false_full{background-position:-28px 0}.ztree li span.button.chk.radio_false_full_focus{background-position:-28px -14px}.ztree li span.button.chk.radio_false_part{background-position:-28px -28px}.ztree li span.button.chk.radio_false_part_focus{background-position:-28px -42px}.ztree li span.button.chk.radio_false_disable{background-position:-28px -56px}.ztree li span.button.chk.radio_true_full{background-position:-42px 0}.ztree li span.button.chk.radio_true_full_focus{background-position:-42px -14px}.ztree li span.button.chk.radio_true_part{background-position:-42px -28px}.ztree li span.button.chk.radio_true_part_focus{background-position:-42px -42px}.ztree li span.button.chk.checkbox_true_full+a,.ztree li span.button.chk.checkbox_true_full_focus+a,.ztree li span.button.chk.checkbox_true_part+a,.ztree li span.button.chk.checkbox_true_part_focus+a{color:#3685f2}.ztree li span.button.chk.radio_true_disable{background-position:-42px -56px}.ztree li span.button.switch{width:25px;height:25px}.ztree li span.button.noline_open{background-position:-92px -72px}.ztree li span.button.noline_close{background-position:-74px -72px}.ztree li span.button.noline_docu,.ztree li span.button.root_docu{background:0 0}.ztree li span.button.ico_open{margin-right:2px;background-position:-110px -16px;vertical-align:top}.ztree li span.button.ico_close{margin-right:2px;background-position:-110px 0;vertical-align:top}.ztree li span.button.ico_docu{margin-right:2px;background-position:-110px -32px;vertical-align:top}.ztree li span.button.edit{margin-right:2px;background-position:-110px -48px;vertical-align:top}.ztree li span.button.remove{margin-right:2px;background-position:-110px -64px;vertical-align:top}.ztree li span.button.ico_loading{width:0;margin-right:2px;vertical-align:top}ul.tmpTargetzTree{background-color:#FFE6B0}span.tmpzTreeMove_arrow{width:16px;height:16px;display:inline-block;padding:0;margin:2px 0 0 1px;border:0;position:absolute;background-color:transparent;background-repeat:no-repeat;background-attachment:scroll;background-position:-110px -80px}.zTreeMask,ul.ztree.zTreeDragUL{background-color:#cfcfcf;position:absolute}ul.ztree.zTreeDragUL{margin:0;padding:0;width:auto;height:auto;overflow:hidden;border:1px dotted #00B83F}.zTreeMask{z-index:10000;opacity:0;filter:alpha(opacity=0)}.bi-select-text-trigger,.bi-small-select-text-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-popup-view{position:fixed!important;overflow-y:visible!important;overflow-x:visible!important;overflow:visible!important}.bi-popup-view .list-view-outer{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-popup-view .padding-outer{padding-top:5px;padding-bottom:5px}.bi-popup-view .list-view-shadow{-webkit-box-shadow:0 1px 5px 0 rgba(35,46,64,.2);-moz-box-shadow:0 1px 5px 0 rgba(35,46,64,.2);box-shadow:0 1px 5px 0 rgba(35,46,64,.2)}.bi-popup-view .list-view-toolbar{line-height:24px}.bi-popup-view .list-view-toolbar>.center-element{border-left:1px solid #e8eaed}.bi-popup-view .list-view-toolbar>.first-element{border-left:none}.bi-theme-dark .bi-popup-view .list-view-toolbar>.center-element{border-left:1px solid #3a3c53}.bi-theme-dark .bi-popup-view .list-view-toolbar>.first-element{border-left:none}.bi-theme-dark .list-view-shadow{-webkit-box-shadow:0 1px 5px 0 rgba(25,27,43,.8);-moz-box-shadow:0 1px 5px 0 rgba(25,27,43,.8);box-shadow:0 1px 5px 0 rgba(25,27,43,.8)}.bi-date-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-down-list-popup .bi-down-list-item .list-item-text,.bi-down-list-popup .list-group-item-text{max-width:203px}.bi-interactive-arrangement .interactive-arrangement-dragtag-line{z-index:1000000000;background-color:#faaa39}.bi-interactive-arrangement .interactive-arrangement-dragtag-icon{z-index:1000000000}.bi-interval-slider,.bi-interval-slider-label{min-height:50px}.bi-month-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-multilayer-select-level-tree .tree-view,.bi-multilayer-single-level-tree .tree-view{min-width:100%}.bi-multi-select-check-pane .multi-select-check-selected{text-decoration:underline}.bi-multi-select-combo .bi-combo.bi-combo-popup+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-select-combo .bi-combo+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-select-insert-combo .bi-combo.bi-combo-popup+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-select-insert-combo .bi-combo+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-select-trigger{-webkit-border-radius:2px 2px 2px 2px;-moz-border-radius:2px;border-radius:2px}.bi-multi-select-search-pane .multi-select-toolbar{color:#faaa39}.bi-multi-select-check-selected-button{z-index:1;min-width:16px;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px}.bi-multi-select-insert-list .bi-search-editor,.bi-multi-select-list .bi-search-editor{-moz-border-radius-bottomleft:0;-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.bi-multi-tree-check-pane .multi-tree-check-selected{color:#3685f2}.bi-multi-tree-combo .bi-combo.bi-combo-popup+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-tree-combo .bi-combo+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-multi-tree-popup .popup-view-tree{min-height:170px}.bi-multi-tree-check-selected-button .trigger-check-selected{color:#3685f2;z-index:1}.bi-number-editor{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-number-editor .pull-down-font,.bi-number-editor .pull-up-font{font-size:12px}.bi-number-interval .number-interval-big-combo .bi-icon-combo-trigger .icon-combo-trigger-icon,.bi-number-interval .number-interval-small-combo .bi-icon-combo-trigger .icon-combo-trigger-icon{font-size:14px}.bi-number-interval .number-interval-small-editor{-moz-border-radius-topleft:2px;-webkit-border-top-left-radius:2px;-moz-border-radius-bottomleft:2px;-webkit-border-bottom-left-radius:2px;border-top-left-radius:2px;border-bottom-left-radius:2px}.bi-number-interval .number-interval-big-editor{-moz-border-radius-topright:2px;-webkit-border-top-right-radius:2px;-moz-border-radius-bottomright:2px;-webkit-border-bottom-right-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px}.bi-number-interval .number-interval-big-combo{-moz-border-radius-topleft:2px;-webkit-border-top-left-radius:2px;-moz-border-radius-bottomleft:2px;-webkit-border-bottom-left-radius:2px;border-top-left-radius:2px;border-bottom-left-radius:2px}.bi-number-interval .number-interval-small-combo{-moz-border-radius-topright:2px;-webkit-border-top-right-radius:2px;-moz-border-radius-bottomright:2px;-webkit-border-bottom-right-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px}.bi-search-multi-text-value-combo .multi-select-trigger-icon-button,.bi-single-select-combo .single-select-trigger-icon-button{font-size:16px}.bi-number-interval.number-error .bi-input{color:#ff4949!important}.bi-date-interval.time-error .bi-input,.bi-date-interval.time-error .sign-editor-text,.bi-search-multi-text-value-combo.combo-error .bi-multi-select-searcher .tip-text-style,.bi-time-interval.time-error .bi-date-time-trigger .bi-input,.bi-time-interval.time-error .bi-date-time-trigger .sign-editor-text,.bi-year-month-interval.time-error .bi-input,.bi-year-month-interval.time-error .sign-editor-text{color:#ff4949}.bi-quarter-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-single-select-combo .bi-combo.bi-combo-popup+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);transform:rotate(180deg);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-single-select-combo .bi-combo+.bi-trigger-icon-button .x-icon{-webkit-transform:rotate(0);-moz-transform:rotate(0);transform:rotate(0);-webkit-transition:transform .3s ease;-moz-transition:transform .3s ease;-o-transition:transform .3s ease;transition:transform .3s ease}.bi-single-slider-label{min-height:50px}.bi-single-slider-normal{min-height:30px}.bi-single-slider{min-height:50px}.bi-single-slider-button .slider-button{cursor:ew-resize;border-width:2px;border-style:solid;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;background-color:#fff;height:16px;width:16px;top:6px;left:-8px}.bi-single-slider-button .slider-button.hover,.bi-single-slider-button .slider-button:hover{-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background-color:#f7f8fa;width:20px;height:20px;top:4px;left:-10px}.bi-single-slider-button .slider-button.disabled{border-color:#d0d4da}.bi-single-slider-button .slider-button.disabled.hover,.bi-single-slider-button .slider-button.disabled:hover{background-color:#f7f8fa;width:16px;height:16px;top:6px;left:-8px}body,html{height:100%}.bi-theme-dark .bi-single-slider-button .slider-button{background-color:#242640}.bi-theme-dark .bi-single-slider-button .slider-button.disabled.hover,.bi-theme-dark .bi-single-slider-button .slider-button.disabled:hover,.bi-theme-dark .bi-single-slider-button .slider-button.hover,.bi-theme-dark .bi-single-slider-button .slider-button:hover{background-color:#191B2B}.bi-slider-track .gray-track{background-color:rgba(61,77,102,.1);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#1a3d4d66, endColorstr=#1a3d4d66);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.bi-slider-track .blue-track{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.bi-slider-track .disabled-blue-track{background-color:#d0d4da;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.bi-theme-dark .bi-slider-track .gray-track{background-color:rgba(214,224,220,.1);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#1ad6e0dc, endColorstr=#1ad6e0dc);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.bi-theme-dark .bi-slider-track .disabled-blue-track{background-color:#606479;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.bi-time-interval .bi-date-time-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.bi-year-popup .year-popup-navigation{line-height:30px}.bi-year-popup .year-popup-navigation>.center-element{border-left:1px solid #e8eaed}.bi-year-popup .year-popup-navigation>.first-element{border-left:none}.bi-theme-dark .bi-year-popup .year-popup-navigation>.center-element{border-left:1px solid #3a3c53}.bi-theme-dark .bi-year-popup .year-popup-navigation>.first-element{border-left:none}.bi-year-trigger{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}html{overflow:hidden}body{position:absolute;width:100%;margin:0;padding:0;top:0;left:0;background-repeat:repeat;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;color:#3d4d66;font:400 12px "Helvetica Neue",Arial,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Heiti,"黑体",sans-serif;-webkit-font-smoothing:antialiased;text-decoration:none;-kthml-user-focus:normal;-moz-user-focus:normal;-moz-outline:0 none;outline:0}div::-webkit-scrollbar,textarea::-webkit-scrollbar{-webkit-appearance:none;background-color:rgba(135,141,159,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0d878d9f, endColorstr=#0d878d9f);width:6px;height:6px}div::-webkit-scrollbar-thumb,textarea::-webkit-scrollbar-thumb{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;background-color:rgba(135,141,159,.3);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d878d9f, endColorstr=#4d878d9f)}div::-webkit-scrollbar-thumb:hover,textarea::-webkit-scrollbar-thumb:hover{background-color:rgba(135,141,159,.7);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#b3878d9f, endColorstr=#b3878d9f)}.bi-theme-dark div::-webkit-scrollbar,.bi-theme-dark textarea::-webkit-scrollbar{-webkit-appearance:none;background-color:rgba(208,212,218,.05);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#0dd0d4da, endColorstr=#0dd0d4da);width:6px;height:6px}.bi-theme-dark div::-webkit-scrollbar-thumb,.bi-theme-dark textarea::-webkit-scrollbar-thumb{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;background-color:rgba(208,212,218,.3);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4dd0d4da, endColorstr=#4dd0d4da)}.bi-theme-dark div::-webkit-scrollbar-thumb:hover,.bi-theme-dark textarea::-webkit-scrollbar-thumb:hover{background-color:rgba(208,212,218,.7);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#b3d0d4da, endColorstr=#b3d0d4da)}.bi-farbtastic .wheel{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/wheel.png) center center no-repeat}.bi-farbtastic .overlay{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/mask.png) center center no-repeat}.bi-farbtastic .marker{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/marker.png) center center no-repeat}.bi-display-tree .ztree li span.button.switch.center_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_3.png) center center no-repeat}.bi-display-tree .ztree li span.button.switch.roots_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_2.png) center center no-repeat}.bi-display-tree .ztree li span.button.switch.bottom_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_4.png) center center no-repeat}.ztree li ul.line{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_1.png) 1px 0 repeat-y}.bi-theme-dark .ztree li ul.line{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_1.png) 1px 0 repeat-y}.ztree li span.button.chk.checkbox_false_full,.ztree li span.button.chk.checkbox_false_full_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_normal.png) center center no-repeat;background-size:contain}.ztree li span.button.chk.checkbox_false_part,.ztree li span.button.chk.checkbox_false_part_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/half_selected.png) center center no-repeat;background-size:contain}.ztree li span.button.chk.checkbox_true_full,.ztree li span.button.chk.checkbox_true_full_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_active.png) center center no-repeat;background-size:contain}.ztree li span.button.chk.checkbox_true_part,.ztree li span.button.chk.checkbox_true_part_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/half_selected.png) center center no-repeat;background-size:contain}.ztree.hack li span.button.chk.checkbox_false_full,.ztree.hack li span.button.chk.checkbox_false_full_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_normal.png) center center no-repeat}.ztree.hack li span.button.chk.checkbox_false_part,.ztree.hack li span.button.chk.checkbox_false_part_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/half_selected.png) center center no-repeat}.ztree.hack li span.button.chk.checkbox_true_full,.ztree.hack li span.button.chk.checkbox_true_full_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_active.png) center center no-repeat}.ztree.hack li span.button.chk.checkbox_true_part,.ztree.hack li span.button.chk.checkbox_true_part_focus{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/half_selected.png) center center no-repeat}.ztree li span.button.root_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_1.png) center center no-repeat}.bi-theme-dark .ztree li span.button.root_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_1.png) center center no-repeat}.ztree li span.button.root_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_1.png) center center no-repeat}.bi-theme-dark .ztree li span.button.root_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_1.png) center center no-repeat}.ztree li span.button.roots_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_2.png) center center no-repeat}.bi-theme-dark .ztree li span.button.roots_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_2.png) center center no-repeat}.ztree li span.button.roots_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_2.png) center center no-repeat}.bi-theme-dark .ztree li span.button.roots_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_2.png) center center no-repeat}.ztree li span.button.center_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_3.png) center center no-repeat}.bi-theme-dark .ztree li span.button.center_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_3.png) center center no-repeat}.ztree li span.button.center_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_3.png) center center no-repeat}.bi-theme-dark .ztree li span.button.center_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_3.png) center center no-repeat}.ztree li span.button.bottom_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_4.png) center center no-repeat}.bi-theme-dark .ztree li span.button.bottom_open{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_4.png) center center no-repeat}.ztree li span.button.bottom_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_4.png) center center no-repeat}.bi-theme-dark .ztree li span.button.bottom_close{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_4.png) center center no-repeat}.ztree li span.button.roots_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_2.png) center center no-repeat}.bi-theme-dark .ztree li span.button.roots_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_2.png) center center no-repeat}.ztree li span.button.center_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_3.png) center center no-repeat}.bi-theme-dark .ztree li span.button.center_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_3.png) center center no-repeat}.ztree li span.button.bottom_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_4.png) center center no-repeat}.bi-theme-dark .ztree li span.button.bottom_docu{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_4.png) center center no-repeat}.ztree li span.button.ico_loading{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/loading.gif) center center no-repeat}.base-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_1.png) repeat-y}.bi-theme-dark .base-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_1.png) repeat-y}.first-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_2.png) center center no-repeat}.bi-theme-dark .first-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_2.png) center center no-repeat}.mid-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_3.png) center center no-repeat}.bi-theme-dark .mid-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_3.png) center center no-repeat}.last-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_4.png) center center no-repeat}.bi-theme-dark .last-line-conn-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_4.png) center center no-repeat}.loading-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/loading.gif) center center no-repeat;background-size:contain}.auto-color-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/background/auto_color.png) center center no-repeat;background-size:contain}.auto-color-normal-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/background/auto_color_normal.png) center center no-repeat;background-size:contain}.auto-color-normal-disabled-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/background/auto_color_normal_disable.png) center center no-repeat;background-size:contain}.trans-color-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/background/trans_normal.png) center center no-repeat;background-size:contain}.trans-color-disabled-background{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/background/trans_disable.png) center center no-repeat;background-size:contain}.auto-color-background.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/auto_color.png) center center no-repeat}.auto-color-normal-background.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/auto_color_normal.png) center center no-repeat}.auto-color-normal-disabled-background.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/auto_color_normal_disable.png) center center no-repeat}.trans-color-background.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/trans_normal.png) center center no-repeat}.trans-color-disabled-background.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/background/trans_disable.png) center center no-repeat}@font-face{font-family:bi;src:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/font/iconfont.eot);src:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/font/iconfont.eot?#iefix) format('embedded-opentype'),url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/font/iconfont.woff) format('woff'),url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/font/iconfont.ttf) format('truetype'),url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/font/iconfont.svg#svgFontName) format('svg')}.b-font{font-family:bi;font-style:normal;-webkit-font-smoothing:antialiased}.close-font .b-font:before,.close-font.disabled .b-font:before,.close-h-font .b-font:before,.close-h-font.disabled .b-font:before,.close-h-font.hover .b-font:before,.close-h-font:hover .b-font:before,.close-ha-font .b-font:before,.close-ha-font.hover .b-font:before,.close-ha-font:hover .b-font:before{content:"\e6d0";color:inherit}.close-ha-font.active .b-font:before,.close-ha-font:active .b-font:before{content:"\e6d0";color:#3f8ce8}.close-ha-font.disabled .b-font:before{content:"\e6d0";color:inherit}.circle-close-font .b-font:before,.circle-close-font.disabled .b-font:before{content:"\e6d5";color:inherit}.search-close-h-font .b-font:before{content:"\e6d0";color:inherit}.search-close-h-font.hover .b-font:before,.search-close-h-font:hover .b-font:before{content:"\e6d0";color:#ff4949}.search-close-h-font.disabled .b-font:before{content:"\e6d0";color:inherit}.pre-page-h-font .b-font:before,.pre-page-h-font.disabled .b-font:before,.pre-page-h-font.hover .b-font:before,.pre-page-h-font:hover .b-font:before{content:"\e70d";color:inherit}.next-page-h-font .b-font:before,.next-page-h-font.disabled .b-font:before,.next-page-h-font.hover .b-font:before,.next-page-h-font:hover .b-font:before{content:"\e70c";color:inherit}.search-font .b-font:before,.search-font.disabled .b-font:before{content:"\e6dc";color:inherit}.date-font .b-font:before,.date-font.disabled .b-font:before{content:"\e733";color:inherit}.time-font .b-font:before,.time-font.disabled .b-font:before{content:"\e6b1";color:inherit}.date-change-h-font .b-font:before,.date-change-h-font.disabled .b-font:before,.date-change-h-font.hover .b-font:before,.date-change-h-font:hover .b-font:before{content:"\e72f";color:inherit}.dot-font .b-font:before,.dot-font.disabled .b-font:before,.dot-h-font .b-font:before{content:"\e762";color:#232e40}.dot-h-font.hover .b-font:before,.dot-h-font:hover .b-font:before{content:"\e762";color:inherit}.dot-h-font.disabled .b-font:before{content:"\e762";color:#232e40}.dot-ha-font .b-font:before{content:"\e762";color:#fff}.dot-ha-font.hover .b-font:before,.dot-ha-font:hover .b-font:before{content:"\e762";color:#999}.dot-ha-font.active .b-font:before,.dot-ha-font:active .b-font:before{content:"\e762";color:#232e40}.dot-ha-font.disabled .b-font:before{content:"\e762";color:#fff}.dot-e-font .b-font:before{content:"\e762";color:transparent}.dot-e-font.hover .b-font:before,.dot-e-font:hover .b-font:before{content:"\e762";color:rgba(54,133,242,.06)}.dot-e-font.active .b-font:before,.dot-e-font:active .b-font:before{content:"\e762";color:#3685f2}.dot-e-font.disabled .b-font:before{content:"\e762";color:transparent}.pull-right-font .b-font:before,.pull-right-font.disabled .b-font:before,.pull-right-h-font .b-font:before,.pull-right-h-font.disabled .b-font:before,.pull-right-h-font.hover .b-font:before,.pull-right-h-font:hover .b-font:before,.pull-right-ha-font .b-font:before,.pull-right-ha-font.hover .b-font:before,.pull-right-ha-font:hover .b-font:before{content:"\e70c";color:inherit}.pull-right-ha-font.active .b-font:before,.pull-right-ha-font:active .b-font:before{content:"\e70c";color:#3f8ce8}.pull-right-e-font .b-font:before,.pull-right-e-font.hover .b-font:before,.pull-right-e-font:hover .b-font:before,.pull-right-ha-font.disabled .b-font:before{content:"\e70c";color:inherit}.pull-right-e-font.active .b-font:before,.pull-right-e-font:active .b-font:before{content:"\e70c";color:#3f8ce8}.pull-right-e-font.disabled .b-font:before{content:"\e70c";color:inherit}.copy-font .b-font:before,.copy-font.disabled .b-font:before{content:"\e6bd";color:inherit}.copy-h-font .b-font:before{content:"\e6bd";color:#232e40}.copy-h-font.hover .b-font:before,.copy-h-font:hover .b-font:before{content:"\e6bd";color:inherit}.copy-h-font.disabled .b-font:before{content:"\e6bd";color:#232e40}.copy-ha-font .b-font:before,.copy-ha-font.hover .b-font:before,.copy-ha-font:hover .b-font:before{content:"\e6bd";color:inherit}.copy-ha-font.active .b-font:before,.copy-ha-font:active .b-font:before{content:"\e6bd";color:#3f8ce8}.copy-e-font .b-font:before,.copy-e-font.hover .b-font:before,.copy-e-font:hover .b-font:before,.copy-ha-font.disabled .b-font:before{content:"\e6bd";color:inherit}.copy-e-font.active .b-font:before,.copy-e-font:active .b-font:before{content:"\e6bd";color:#3f8ce8}.copy-e-font.disabled .b-font:before{content:"\e6bd";color:inherit}.check-mark-font .b-font:before,.check-mark-font.disabled .b-font:before,.check-mark-h-font .b-font:before,.check-mark-h-font.disabled .b-font:before,.check-mark-h-font.hover .b-font:before,.check-mark-h-font:hover .b-font:before,.check-mark-ha-font .b-font:before,.check-mark-ha-font.hover .b-font:before,.check-mark-ha-font:hover .b-font:before{content:"\e6cf";color:inherit}.check-mark-ha-font.active .b-font:before,.check-mark-ha-font:active .b-font:before{content:"\e6cf";color:#3f8ce8}.check-mark-e-font .b-font:before,.check-mark-e-font.hover .b-font:before,.check-mark-e-font:hover .b-font:before,.check-mark-ha-font.disabled .b-font:before{content:"\e6cf";color:inherit}.check-mark-e-font.active .b-font:before,.check-mark-e-font:active .b-font:before{content:"\e6cf";color:#3f8ce8}.check-mark-e-font.disabled .b-font:before{content:"\e6cf";color:inherit}.row-pre-page-h-font .b-font:before,.row-pre-page-h-font.disabled .b-font:before,.row-pre-page-h-font.hover .b-font:before,.row-pre-page-h-font:hover .b-font:before{content:"\e6d9";color:inherit}.row-next-page-h-font .b-font:before,.row-next-page-h-font.disabled .b-font:before,.row-next-page-h-font.hover .b-font:before,.row-next-page-h-font:hover .b-font:before{content:"\e6d8";color:inherit}.column-pre-page-h-font .b-font:before,.column-pre-page-h-font.disabled .b-font:before,.column-pre-page-h-font.hover .b-font:before,.column-pre-page-h-font:hover .b-font:before{content:"\e6d6";color:inherit}.column-next-page-h-font .b-font:before,.column-next-page-h-font.disabled .b-font:before,.column-next-page-h-font.hover .b-font:before,.column-next-page-h-font:hover .b-font:before{content:"\e6d7";color:inherit}.expander-right-font .b-font:before,.expander-right-font.disabled .b-font:before{content:"\e6d8";color:inherit}.expander-down-font .b-font:before,.expander-down-font.disabled .b-font:before{content:"\e6d7";color:inherit}.solid-triangle-top-font .b-font:before,.solid-triangle-top-font.disabled .b-font:before,.solid-triangle-top-font.hover .b-font:before,.solid-triangle-top-font:hover .b-font:before{content:"\e6d6";color:inherit}.solid-triangle-bottom-font .b-font:before,.solid-triangle-bottom-font.disabled .b-font:before,.solid-triangle-bottom-font.hover .b-font:before,.solid-triangle-bottom-font:hover .b-font:before{content:"\e6d7";color:inherit}.trigger-triangle-font .b-font:before,.trigger-triangle-font.disabled .b-font:before{content:"\e64e";color:inherit}.pull-up-font .b-font:before,.pull-up-font.disabled .b-font:before{content:"\e70a";color:inherit}.pull-down-font .b-font:before,.pull-down-font.disabled .b-font:before{content:"\e70b";color:inherit}.pull-down-h-font .b-font:before{content:"\e70b";color:#647185}.pull-down-h-font.hover .b-font:before,.pull-down-h-font:hover .b-font:before{content:"\e70b";color:inherit}.pull-down-h-font.disabled .b-font:before,.pull-down-ha-font .b-font:before{content:"\e70b";color:#647185}.pull-down-ha-font.hover .b-font:before,.pull-down-ha-font:hover .b-font:before{content:"\e70b";color:inherit}.pull-down-ha-font.active .b-font:before,.pull-down-ha-font:active .b-font:before{content:"\e70b";color:#3f8ce8}.pull-down-ha-font.disabled .b-font:before{content:"\e70b";color:#647185}.check-font .b-font:before,.check-font.disabled .b-font:before{content:"\e6cf";color:#3685f2}.item-check-font .b-font:before{content:"\e6cf";color:#fff}.item-check-font.hover .b-font:before,.item-check-font:hover .b-font:before{content:"\e6cf";color:#999}.item-check-font.active .b-font:before,.item-check-font:active .b-font:before{content:"\e6cf";color:#3f8ce8}.item-check-font.disabled .b-font:before{content:"\e6cf";color:#fff}.primary-key-font .b-font:before,.primary-key-font.disabled .b-font:before,.primary-key-font.hover .b-font:before,.primary-key-font:hover .b-font:before{content:"\e740";color:inherit}.drag-tag-font .b-font:before,.drag-tag-font.disabled .b-font:before{content:"\e6d0";color:#faaa39}.less-font .b-font:before,.less-font.disabled .b-font:before{content:"\e75e";color:inherit}.less-equal-font .b-font:before,.less-equal-font.disabled .b-font:before{content:"\e761";color:inherit}.text-bold-font .b-font:before,.text-bold-font.disabled .b-font:before{content:"\e697";color:inherit}.text-italic-font .b-font:before,.text-italic-font.disabled .b-font:before{content:"\e69d";color:inherit}.text-underline-font .b-font:before,.text-underline-font.disabled .b-font:before{content:"\e69c";color:inherit}.text-color-font .b-font:before,.text-color-font.disabled .b-font:before{content:"\e698";color:inherit}.text-background-font .b-font:before,.text-background-font.disabled .b-font:before{content:"\e699";color:inherit}.text-color-underline-font .b-font:before,.text-color-underline-font.disabled .b-font:before{content:"\e69a";color:inherit}.text-align-left-font .b-font:before,.text-align-left-font.disabled .b-font:before{content:"\e6ca";color:inherit}.text-align-center-font .b-font:before,.text-align-center-font.disabled .b-font:before{content:"\e6bf";color:inherit}.text-align-right-font .b-font:before,.text-align-right-font.disabled .b-font:before{content:"\e6c8";color:inherit}.toast-error-font .b-font:before,.toast-error-font.disabled .b-font:before{content:"\e757";color:inherit}.toast-success-font .b-font:before,.toast-success-font.disabled .b-font:before{content:"\e756";color:inherit}.toast-warning-font .b-font:before,.toast-warning-font.disabled .b-font:before{content:"\e755";color:inherit}.toast-message-font .b-font:before,.toast-message-font.disabled .b-font:before{content:"\e74b";color:inherit}.text-add-tip-font .b-font:before,.text-add-tip-font.disabled .b-font:before{content:"\e6dd";color:#13cd66}.add-up-font .b-font:before,.add-up-font.disabled .b-font:before{content:"\e70a";color:inherit}.minus-down-font .b-font:before,.minus-down-font.disabled .b-font:before{content:"\e70b";color:inherit}.tree-collapse-icon-type1 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_collapse_1.png) center center no-repeat;background-size:contain}.tree-collapse-icon-type1 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_1.png) center center no-repeat}.tree-collapse-icon-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_collapse_2.png) center center no-repeat;background-size:contain}.tree-collapse-icon-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_2.png) center center no-repeat}.tree-collapse-icon-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_collapse_3.png) center center no-repeat;background-size:contain}.tree-collapse-icon-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_3.png) center center no-repeat}.tree-collapse-icon-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_collapse_4.png) center center no-repeat;background-size:contain}.tree-collapse-icon-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_collapse_4.png) center center no-repeat}.tree-expand-icon-type1 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_expand_1.png) center center no-repeat;background-size:contain}.tree-expand-icon-type1 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_1.png) center center no-repeat}.tree-expand-icon-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_expand_2.png) center center no-repeat;background-size:contain}.tree-expand-icon-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_2.png) center center no-repeat}.tree-expand-icon-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_expand_3.png) center center no-repeat;background-size:contain}.tree-expand-icon-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_3.png) center center no-repeat}.tree-expand-icon-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_expand_4.png) center center no-repeat;background-size:contain}.tree-expand-icon-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_expand_4.png) center center no-repeat}.tree-vertical-line-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_vertical_line_2.png) center center no-repeat;background-size:contain}.tree-vertical-line-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_2.png) center center no-repeat}.tree-vertical-line-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_vertical_line_3.png) center center no-repeat;background-size:contain}.tree-vertical-line-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_3.png) center center no-repeat}.tree-vertical-line-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/tree_vertical_line_4.png) center center no-repeat;background-size:contain}.tree-vertical-line-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/tree_vertical_line_4.png) center center no-repeat}.bi-theme-dark .tree-collapse-icon-type1 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_collapse_1.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-collapse-icon-type1 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_1.png) center center no-repeat}.bi-theme-dark .tree-collapse-icon-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_collapse_2.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-collapse-icon-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_2.png) center center no-repeat}.bi-theme-dark .tree-collapse-icon-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_collapse_3.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-collapse-icon-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_3.png) center center no-repeat}.bi-theme-dark .tree-collapse-icon-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_collapse_4.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-collapse-icon-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_collapse_4.png) center center no-repeat}.bi-theme-dark .tree-expand-icon-type1 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_expand_1.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-expand-icon-type1 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_1.png) center center no-repeat}.bi-theme-dark .tree-expand-icon-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_expand_2.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-expand-icon-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_2.png) center center no-repeat}.bi-theme-dark .tree-expand-icon-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_expand_3.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-expand-icon-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_3.png) center center no-repeat}.bi-theme-dark .tree-expand-icon-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_expand_4.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-expand-icon-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_expand_4.png) center center no-repeat}.bi-theme-dark .tree-vertical-line-type2 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_vertical_line_2.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-vertical-line-type2 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_2.png) center center no-repeat}.bi-theme-dark .tree-vertical-line-type3 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_vertical_line_3.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-vertical-line-type3 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_3.png) center center no-repeat}.bi-theme-dark .tree-vertical-line-type4 .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/dark/tree_vertical_line_4.png) center center no-repeat;background-size:contain}.bi-theme-dark .tree-vertical-line-type4 .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/dark/tree_vertical_line_4.png) center center no-repeat}.check-box-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_normal.png) center center no-repeat;background-size:contain}.check-box-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_normal.png) center center no-repeat}.check-box-icon.hover .x-icon,.check-box-icon:hover .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_normal.png) center center no-repeat;background-size:contain}.check-box-icon.hover .x-icon.hack,.check-box-icon:hover .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_normal.png) center center no-repeat}.check-box-icon:active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_normal.png) center center no-repeat;background-size:contain}.check-box-icon:active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_normal.png) center center no-repeat}.check-box-icon.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_active.png) center center no-repeat;background-size:contain}.check-box-icon.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_active.png) center center no-repeat}.check-box-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_disable.png) center center no-repeat;background-size:contain}.check-box-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_disable.png) center center no-repeat}.check-box-icon.disabled.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/check_box_disable2.png) center center no-repeat;background-size:contain}.check-box-icon.disabled.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/check_box_disable2.png) center center no-repeat}.radio-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_normal.png) center center no-repeat;background-size:contain}.radio-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_normal.png) center center no-repeat}.radio-icon.hover .x-icon,.radio-icon:hover .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_normal.png) center center no-repeat;background-size:contain}.radio-icon.hover .x-icon.hack,.radio-icon:hover .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_normal.png) center center no-repeat}.radio-icon:active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_normal.png) center center no-repeat;background-size:contain}.radio-icon:active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_normal.png) center center no-repeat}.radio-icon.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_active.png) center center no-repeat;background-size:contain}.radio-icon.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_active.png) center center no-repeat}.radio-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_disable.png) center center no-repeat;background-size:contain}.radio-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_disable.png) center center no-repeat}.radio-icon.disabled.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/radio_disable2.png) center center no-repeat;background-size:contain}.radio-icon.disabled.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/radio_disable2.png) center center no-repeat}.check-half-select-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/half_selected.png) center center no-repeat;background-size:contain}.check-half-select-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/half_selected.png) center center no-repeat}.check-half-select-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/half_selected_disable.png) center center no-repeat;background-size:contain}.check-half-select-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/half_selected_disable.png) center center no-repeat}.slider-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/slider_normal_small.png) center center no-repeat;background-size:contain}.slider-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/slider_normal_small.png) center center no-repeat}.slider-icon.hover .x-icon,.slider-icon:hover .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/slider_active_small.png) center center no-repeat;background-size:contain}.slider-icon.hover .x-icon.hack,.slider-icon:hover .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/slider_active_small.png) center center no-repeat}.slider-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/slider_normal_small.png) center center no-repeat;background-size:contain}.slider-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/slider_normal_small.png) center center no-repeat}.auto-color-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/auto_normal.png) center center no-repeat;background-size:contain}.auto-color-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/auto_normal.png) center center no-repeat}.auto-color-icon.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/auto_select.png) center center no-repeat;background-size:contain}.auto-color-icon.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/auto_select.png) center center no-repeat}.auto-color-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/auto_disable.png) center center no-repeat;background-size:contain}.auto-color-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/auto_disable.png) center center no-repeat}.trans-color-icon .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/trans_normal.png) center center no-repeat;background-size:contain}.trans-color-icon .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/trans_normal.png) center center no-repeat}.trans-color-icon.active .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/trans_select.png) center center no-repeat;background-size:contain}.trans-color-icon.active .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/trans_select.png) center center no-repeat}.trans-color-icon.disabled .x-icon{display:block;background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/2x/icon/trans_disable.png) center center no-repeat;background-size:contain}.trans-color-icon.disabled .x-icon.hack{background:url(http://fine-design-storage.oss-cn-shanghai.aliyuncs.com/fineui/2.0/images/1x/icon/trans_disable.png) center center no-repeat}.icon-size-12 .b-font{font-size:12px}.icon-size-16 .b-font{font-size:16px}.icon-size-24 .b-font{font-size:24px}.icon-size-40 .b-font{font-size:40px}.icon-size-50 .b-font{font-size:50px}.icon-size-70 .b-font{font-size:70px}
\ No newline at end of file
diff --git a/dist/2.0/fineui.min.js b/dist/2.0/fineui.min.js
new file mode 100644
index 0000000000..5cf0146f36
--- /dev/null
+++ b/dist/2.0/fineui.min.js
@@ -0,0 +1,40 @@
+/*! fineui 2019-03-08 15:48:53 */
+function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _global;_global="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,null==_global.BI&&(_global.BI={prepares:[]}),null==_global.BI.prepares&&(_global.BI.prepares=[]),function(){function a(a,b,c){switch(c.length){case 0:return a.call(b);case 1:return a.call(b,c[0]);case 2:return a.call(b,c[0],c[1]);case 3:return a.call(b,c[0],c[1],c[2])}return a.apply(b,c)}function b(a,b,c,d){for(var e=-1,f=null==a?0:a.length;++e-1}function g(a,b,c){for(var d=-1,e=null==a?0:a.length;++d-1;);return c}function z(a,b){for(var c=a.length;c--&&o(b,a[c],0)>-1;);return c}function A(a,b){for(var c=a.length,d=0;c--;)a[c]===b&&++d;return d}function B(a,b){return null==a?Ie:a[b]}function C(a){return Cg.test(a)}function D(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c}function E(a){var b=-1,c=Array(a.size);return a.forEach(function(a,d){c[++b]=[d,a]}),c}function F(a,b){return function(c){return a(b(c))}}function G(a,b){for(var c=-1,d=a.length,e=0,f=[];++c-1}function ea(a,b){var c=this.__data__,d=xa(c,a);return d<0?(++this.size,c.push([a,b])):c[d][1]=b,this}function fa(a){var b=-1,c=null==a?0:a.length;for(this.clear();++b=b?a:b)),a}function Ea(a,b,d,e,f,g){var h,i=b&Pe,j=b&Qe,k=bℜif(d&&(h=f?d(a,e,f,g):d(a)),h!==Ie)return h;if(!Sd(a))return a;var l=si(a);if(l){if(h=xc(a),!i)return Qb(a,h)}else{var m=bi(a),n=m==uf||m==vf;if(ti(a))return Gb(a,i);if(m==zf||m==of||n&&!f){if(h=j||n?{}:yc(a),!i)return j?Tb(a,Aa(h,a)):Sb(a,za(h,a))}else{if(!Eg[m])return f?a:{};h=zc(a,m,i)}}g||(g=new oa);var o=g.get(a);if(o)return o;if(g.set(a,h),xi(a))return a.forEach(function(c){h.add(Ea(c,b,d,c,a,g))}),h;if(vi(a))return a.forEach(function(c,e){h.set(e,Ea(c,b,d,e,a,g))}),h;var p=k?j?nc:mc:j?me:le,q=l?Ie:p(a);return c(q||a,function(c,e){q&&(e=c,c=a[e]),wa(h,e,Ea(c,b,d,e,a,g))}),h}function Fa(a,b,c){if("function"!=typeof a)throw new TypeError(Le);return setTimeout(function(){a.apply(Ie,c)},b)}function Ga(a,b,c,d){var e=-1,i=f,j=!0,k=a.length,l=[],m=b.length;if(!k)return l;c&&(b=h(b,v(c))),d?(i=g,j=!1):b.length>=Ke&&(i=x,j=!1,b=new la(b));a:for(;++e0&&c(h)?b>1?Ka(h,b-1,c,d,e):i(e,h):d||(e[e.length]=h)}return e}function La(a,b){return a&&Vh(a,b,le)}function Ma(a,b){return a&&Wh(a,b,le)}function Na(a,b){return e(b,function(b){return Qd(a[b])})}function Oa(a,b){b=Eb(b,a);for(var c=0,d=b.length;null!=a&&c