diff --git a/bi/core.js b/bi/core.js index 42c6dfde5..903f7363b 100644 --- a/bi/core.js +++ b/bi/core.js @@ -17056,7 +17056,7 @@ BI.View.registerVMRouter = function (viewRouter, modelRouter) { }; BI.createWidget = function (item, options) { - var el; + var el, w; options || (options = {}); if (BI.isEmpty(item) && BI.isEmpty(options)) { return BI.createWidget({ @@ -17068,11 +17068,13 @@ BI.View.registerVMRouter = function (viewRouter, modelRouter) { } if (item && (item.type || options.type)) { el = BI.extend({}, options, item); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && BI.isWidget(item.el)) { return item.el; diff --git a/bi/sliders.css b/bi/sliders.css index 03f096baf..a8d9688bb 100644 --- a/bi/sliders.css +++ b/bi/sliders.css @@ -1,14 +1,14 @@ .bi-interval-slider-label { min-height: 50px; } - + .bi-interval-slider { min-height: 70px; } .bi-single-slider-label { min-height: 50px; } - + .bi-single-slider-normal { min-height: 30px; } diff --git a/bi/widget.js b/bi/widget.js index a69151301..fb16a787d 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -1,17550 +1,18438 @@ -/** - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTableTreeNumber - * @extends BI.Widget - */ -BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table-tree-number", - isNeedFreeze: false, - startSequence: 1,//开始的序号 - scrollTop: 0, - headerRowSize: 25, - rowSize: 25, - - sequenceHeaderCreator: null, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.vCurr = 1; - this.hCurr = 1; - this.tasks = []; - this.renderedCells = []; - this.renderedKeys = []; - - this.container = BI.createWidget({ - type: "bi.absolute", - width: 60, - scrollable: false - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.vertical", - scrollable: false, - scrolly: false, - items: [this.container] - }); - - this.headerContainer = BI.createWidget({ - type: "bi.absolute", - cls: "bi-border", - width: 58, - scrollable: false - }); - - this.layout = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.headerContainer, - height: this._getHeaderHeight() - 2 - }, {el: {type: "bi.layout"}, height: 2}, { - el: this.scrollContainer - }] - }); - //缓存第一行对应的序号 - this.start = this.options.startSequence; - this.cache = {}; - this._nextState(); - - this._populate(); - }, - - _getNextSequence: function (nodes) { - var self = this; - var start = this.start; - var cnt = this.start; - - function track(node) { - //如果已经有缓存了就不改计数了,复杂表会出现这种情况 - self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); - cnt++; - } - - BI.each(nodes, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - if (index === 0) { - if (self.cache[child.text || child.value]) { - start = cnt = self.cache[child.text || child.value]; - } - } - track(child) - }); - } - }); - this.start = cnt; - return start; - }, - - _getStart: function (nodes) { - var self = this; - var start = this.start; - BI.some(nodes, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - return BI.some(node.children, function (index, child) { - if (index === 0) { - if (self.cache[child.text || child.value]) { - start = self.cache[child.text || child.value]; - return true; - } - } - }); - } - }); - return start; - }, - - _formatNumber: function (nodes) { - var self = this, o = this.options; - var result = []; - var count = this._getStart(nodes); - - function getLeafCount(node) { - var cnt = 0; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - cnt += getLeafCount(child); - }); - if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = this._getHeaderHeight() - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _getHeaderHeight: function () { - var o = this.options; - return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); - }, - - _nextState: function () { - var o = this.options; - this._getNextSequence(o.items); - }, - - _prevState: function () { - var self = this, o = this.options; - var firstChild; - BI.some(o.items, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - return BI.some(node.children, function (j, child) { - firstChild = child; - return true; - }); - } - }); - if (firstChild && BI.isNotEmptyObject(this.cache)) { - this.start = this.cache[firstChild.text || firstChild.value]; - } else { - this.start = 1; - } - this._nextState(); - }, - - _getMaxScrollTop: function (numbers) { - var cnt = 0; - BI.each(numbers, function (i, number) { - cnt += number.cnt; - }); - return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - - var renderedCells = [], renderedKeys = []; - var numbers = this._formatNumber(o.items); - var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); - BI.each(numbers, function (i, number) { - intervalTree.set(i, number.height); - }); - var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); - var index = intervalTree.greatestLowerBound(scrollTop); - var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); - var height = offsetTop; - var bodyHeight = o.height - this._getHeaderHeight(); - while (height < bodyHeight && index < numbers.length) { - renderedKeys.push(index); - offsetTop += numbers[index].height; - height += numbers[index].height; - index++; - } - - BI.each(renderedKeys, function (i, key) { - var index = BI.deepIndexOf(self.renderedKeys, key); - if (index > -1) { - if (numbers[key].height !== self.renderedCells[index]._height) { - self.renderedCells[index]._height = numbers[key].height; - self.renderedCells[index].el.setHeight(numbers[key].height); - } - if (numbers[key].top !== self.renderedCells[index].top) { - self.renderedCells[index].top = numbers[key].top; - self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); - } - renderedCells.push(self.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - styleGetter: numbers[key].isSummary === true ? function () { - return o.summaryCellStyleGetter(true); - } : function (key) { - return function () { - return o.sequenceCellStyleGetter(key); - } - }(numbers[key].index) - }, numbers[key])); - renderedCells.push({ - el: child, - left: 0, - top: numbers[key].top, - _height: numbers[key].height - }); - } - }); - - //已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]) - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - - this.container.setHeight(intervalTree.sumUntil(numbers.length)); - }, - - _restore: function () { - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - _populate: function () { - var self = this; - BI.each(this.tasks, function (i, task) { - task.apply(self); - }); - this.tasks = []; - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - if (v <= 1) { - this.cache = {}; - this.start = this.options.startSequence; - this._restore(); - this.tasks.push(this._nextState); - } else if (v === this.vCurr + 1) { - this.tasks.push(this._nextState); - } else if (v === this.vCurr - 1) { - this.tasks.push(this._prevState); - } - this.vCurr = v; - }, - - setHPage: function (v) { - if (v !== this.hCurr) { - this.tasks.push(this._prevState); - } - this.hCurr = v; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - this.tasks.push(this._prevState); - } - if (header && header !== this.options.header) { - o.header = header; - } - if (crossItems && crossItems !== this.options.crossItems) { - o.crossItems = crossItems; - } - if (crossHeader && crossHeader !== this.options.crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - } -}); -BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** - * 自适应布局 - * - * 1、resize - * 2、吸附 - * 3、当前组件在最上方 - * 4、可以撤销 - * 5、上下之间插入组件 - * - * Created by GUY on 2016/2/23. - * @class BI.AdaptiveArrangement - * @extends BI.Widget - */ -BI.AdaptiveArrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-adaptive-arrangement", - resizable: true, - layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, - items: [] - }); - }, - - _init: function () { - BI.AdaptiveArrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.arrangement", - element: this, - layoutType: o.layoutType, - items: o.items - }); - this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { - self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); - }); - this.zIndex = 0; - BI.each(o.items, function (i, item) { - self._initResizable(item.el); - }); - - $(document).mousedown(function (e) { - BI.each(self.getAllRegions(), function (i, region) { - if (region.el.element.find(e.target).length === 0) { - region.el.element.removeClass("selected"); - } - }); - }); - BI.ResizeDetector.addResizeListener(this, function () { - self.arrangement.resize(); - self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); - }); - }, - - _isEqual: function () { - return this.arrangement._isEqual.apply(this.arrangement, arguments); - }, - - _setSelect: function (item) { - if (!item.element.hasClass("selected")) { - item.element.css("zIndex", ++this.zIndex); - BI.each(this.getAllRegions(), function (i, region) { - region.el.element.removeClass("selected"); - }); - item.element.addClass("selected"); - } - }, - - _initResizable: function (item) { - var self = this, o = this.options; - item.element.css("zIndex", ++this.zIndex); - item.element.mousedown(function () { - self._setSelect(item) - }); - // o.resizable && item.element.resizable({ - // handles: "e, s, se", - // minWidth: 20, - // minHeight: 20, - // autoHide: true, - // helper: "bi-resizer", - // start: function () { - // item.element.css("zIndex", ++self.zIndex); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); - // }, - // resize: function (e, ui) { - // // self._resize(item.attr("id"), ui.size); - // self._resize(item.attr("id"), e, ui.size, ui.position); - // }, - // stop: function (e, ui) { - // self._stopResize(item.attr("id"), ui.size); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); - // } - // }); - }, - - // _resize: function (name, e, size, position) { - // var self = this; - // this.scrollInterval(e, false, true, function (changedSize) { - // size.width += changedSize.offsetX; - // size.height += changedSize.offsetY; - // var containerWidth = self.arrangement.container.element.width(); - // var containerHeight = self.arrangement.container.element.height(); - // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); - // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); - // switch (self.getLayoutType()) { - // case BI.Arrangement.LAYOUT_TYPE.FREE: - // break; - // case BI.Arrangement.LAYOUT_TYPE.GRID: - // self.setRegionSize(name, size); - // break; - // } - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); - // }); - // }, - // - // _stopResize: function (name, size) { - // var self = this; - // this.scrollEnd(); - // switch (this.getLayoutType()) { - // case BI.Arrangement.LAYOUT_TYPE.FREE: - // this.setRegionSize(name, size); - // break; - // case BI.Arrangement.LAYOUT_TYPE.GRID: - // this.setRegionSize(name, size); - // break; - // } - // }, - - _getScrollOffset: function () { - return this.arrangement._getScrollOffset(); - }, - - getClientWidth: function () { - return this.arrangement.getClientWidth(); - }, - - getClientHeight: function () { - return this.arrangement.getClientHeight(); - }, - - addRegion: function (region, position) { - this._initResizable(region.el); - this._setSelect(region.el); - var self = this, flag; - var old = this.arrangement.getAllRegions(); - if (flag = this.arrangement.addRegion(region, position)) { - this._old = old; - } - return flag; - }, - - deleteRegion: function (name) { - var flag; - var old = this.getAllRegions(); - if (flag = this.arrangement.deleteRegion(name)) { - this._old = old; - } else { - this._old = this.getAllRegions(); - this.relayout(); - } - return flag; - }, - - setRegionSize: function (name, size) { - var flag; - var old = this.getAllRegions(); - if (flag = this.arrangement.setRegionSize(name, size)) { - this._old = old; - } - return flag; - }, - - setPosition: function (position, size) { - var self = this; - return this.arrangement.setPosition(position, size); - }, - - setRegionPosition: function (name, position) { - var region = this.getRegionByName(name); - return this.arrangement.setRegionPosition(name, position); - }, - - setDropPosition: function (position, size) { - return this.arrangement.setDropPosition(position, size); - }, - - scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { - var self = this; - var map = { - top: [-1, 0], - bottom: [1, 0], - left: [0, -1], - right: [0, 1] - }; - var clientSize = this.element.bounds(); - - function scrollTo(direction, callback) { - if (direction === "") { - self.lastActiveRegion = ""; - if (self._scrollInterval) { - clearInterval(self._scrollInterval); - self._scrollInterval = null; - } - return; - } - if (self.lastActiveRegion !== direction) { - self.lastActiveRegion = direction; - if (self._scrollInterval) { - clearInterval(self._scrollInterval); - self._scrollInterval = null; - } - var count = 0; - self._scrollInterval = setInterval(function () { - count++; - if (count <= 3) { - return; - } - var offset = self._getScrollOffset(); - var t = offset.top + map[direction][0] * 40; - var l = offset.left + map[direction][1] * 40; - if (t < 0 || l < 0) { - return; - } - callback({ - offsetX: map[direction][1] * 40, - offsetY: map[direction][0] * 40 - }); - self.scrollTo({ - top: t, - left: l - }); - }, 300); - } - } - - cb({ - offsetX: 0, - offsetY: 0 - }); - var offset = this.element.offset(); - var p = { - left: e.pageX - offset.left, - top: e.pageY - offset.top - }; - //向上滚 - if (isBorderScroll && p.top >= 0 && p.top <= 30) { - scrollTo("top", cb) - } - //向下滚 - else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { - scrollTo("bottom", cb) - } - //向左滚 - else if (isBorderScroll && p.left >= 0 && p.left <= 30) { - scrollTo("left", cb) - } - //向右滚 - else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { - scrollTo("right", cb) - } else { - if (isOverflowScroll === true) { - if (p.top < 0) { - scrollTo("top", cb); - } - else if (p.top > clientSize.height) { - scrollTo("bottom", cb); - } - else if (p.left < 0) { - scrollTo("left", cb); - } - else if (p.left > clientSize.width) { - scrollTo("right", cb); - } else { - scrollTo("", cb); - } - } else { - scrollTo("", cb); - } - } - }, - - scrollEnd: function () { - this.lastActiveRegion = ""; - if (this._scrollInterval) { - clearInterval(this._scrollInterval); - this._scrollInterval = null; - } - }, - - scrollTo: function (scroll) { - this.arrangement.scrollTo(scroll); - }, - - zoom: function (ratio) { - this.arrangement.zoom(ratio); - }, - - resize: function () { - this.arrangement.resize(); - }, - - relayout: function () { - return this.arrangement.relayout(); - }, - - setLayoutType: function (type) { - var self = this; - this.arrangement.setLayoutType(type); - }, - - getLayoutType: function () { - return this.arrangement.getLayoutType(); - }, - - getLayoutRatio: function () { - return this.arrangement.getLayoutRatio(); - }, - - getHelper: function () { - return this.arrangement.getHelper(); - }, - - getRegionByName: function (name) { - return this.arrangement.getRegionByName(name); - }, - - getAllRegions: function () { - return this.arrangement.getAllRegions(); - }, - - revoke: function () { - if (this._old) { - this.populate(BI.toArray(this._old)); - } - }, - - populate: function (items) { - var self = this; - BI.each(items, function (i, item) { - self._initResizable(item.el); - }); - this.arrangement.populate(items); - } -}); -BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; -BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; -BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; -BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; -BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; -BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** - * Arrangement的block面板 - * - * Created by GUY on 2016/3/1. - * @class BI.ArrangementBlock - * @extends BI.Widget - */ -BI.ArrangementBlock = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement-block bi-mask" - }); - } -}); -BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** - * Arrangement的drop面板 - * - * Created by GUY on 2016/3/1. - * @class BI.ArrangementDroppable - * @extends BI.Widget - */ -BI.ArrangementDroppable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement-droppable bi-resizer" - }); - } -}); -BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** - * 布局 - * - * Created by GUY on 2016/2/23. - * @class BI.Arrangement - * @extends BI.Widget - */ -BI.Arrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement", - layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, - items: [] - }); - }, - - _init: function () { - BI.Arrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.arrangement_droppable", - cls: "arrangement-block", - invisible: true - }); - this.block = BI.createWidget({ - type: "bi.arrangement_block", - invisible: true - }); - this.container = BI.createWidget({ - type: "bi.absolute", - cls: "arrangement-container", - items: o.items.concat([this.block, this.arrangement]) - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.adaptive", - width: "100%", - height: "100%", - scrollable: true, - items: [this.container] - }); - this.scrollContainer.element.scroll(function () { - self.fireEvent(BI.Arrangement.EVENT_SCROLL, { - scrollLeft: self.scrollContainer.element.scrollLeft(), - scrollTop: self.scrollContainer.element.scrollTop(), - clientWidth: self.scrollContainer.element[0].clientWidth, - clientHeight: self.scrollContainer.element[0].clientHeight - }); - }); - - BI.createWidget({ - type: "bi.adaptive", - element: this, - items: [this.scrollContainer] - }); - this.regions = {}; - if (o.items.length > 0) { - BI.nextTick(function () { - self.populate(o.items); - }); - } - }, - - ////初始化操作//// - _calculateRegions: function (items) { - var self = this, o = this.options; - this.regions = {}; - BI.each(items, function (i, item) { - var region = self._createOneRegion(item); - self.regions[region.id] = region; - }); - }, - - _isEqual: function (num1, num2) { - return Math.abs(num1 - num2) < 2; - }, - - _isLessThan: function (num1, num2) { - return num1 < num2 && !this._isEqual(num1, num2); - }, - - _isMoreThan: function (num1, num2) { - return num1 > num2 && !this._isEqual(num1, num2); - }, - - _isLessThanEqual: function (num1, num2) { - return num1 <= num2 || this._isEqual(num1, num2); - }, - - _isMoreThanEqual: function (num1, num2) { - return num1 >= num2 || this._isEqual(num1, num2); - }, - - //获取占有的最大Region - _getRegionOccupied: function (regions) { - var self = this, o = this.options; - if (BI.size(regions || this.regions) <= 0) { - return { - left: 0, - top: 0, - width: 0, - height: 0 - } - } - var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; - BI.each(regions || this.regions, function (id, region) { - minLeft = Math.min(minLeft, region.left); - maxLeft = Math.max(maxLeft, region.left + region.width); - minTop = Math.min(minTop, region.top); - maxTop = Math.max(maxTop, region.top + region.height); - }); - return { - left: minLeft, - top: minTop, - width: maxLeft - minLeft, - height: maxTop - minTop - } - }, - - //两个区域的交叉面积 - _getCrossArea: function (region1, region2) { - if (region1.left <= region2.left) { - if (region1.top <= region2.top) { - if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { - if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { - return 0; - } - return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); - } - } else { - if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { - if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { - return 0; - } - return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); - } - } - } else { - if (region1.top <= region2.top) { - if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { - if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { - return 0; - } - return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); - } - } else { - if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { - if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { - return 0; - } - return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); - } - } - } - return 0; - }, - - //是否有覆盖的组件 - _isRegionOverlay: function (regions) { - var reg = []; - BI.each(regions || this.regions, function (id, region) { - reg.push(new BI.Region(region.left, region.top, region.width, region.height)); - }); - for (var i = 0, len = reg.length; i < len; i++) { - for (var j = i + 1; j < len; j++) { - var area1 = { - left: reg[i].x, - top: reg[i].y, - width: reg[i].w, - height: reg[i].h - }; - var area2 = { - left: reg[j].x, - top: reg[j].y, - width: reg[j].w, - height: reg[j].h - }; - if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { - return true; - } - } - } - return false; - }, - - //布局是否是优良的 - _isArrangeFine: function (regions) { - switch (this.options.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - return true; - case BI.Arrangement.LAYOUT_TYPE.GRID: - // if (this._isRegionOverlay()) { - // return false; - // } - } - return true; - }, - - _getRegionNames: function (regions) { - var names = []; - BI.each(regions || this.regions, function (i, region) { - names.push(region.id || region.attr("id")); - }); - return names; - }, - - _getRegionsByNames: function (names, regions) { - names = BI.isArray(names) ? names : [names]; - regions = regions || this.regions; - if (BI.isArray(regions)) { - var result = []; - BI.each(regions, function (i, region) { - if (names.contains(region.id || region.attr("id"))) { - result.push(region); - } - }); - } else { - var result = {}; - BI.each(names, function (i, name) { - result[name] = regions[name]; - }); - } - return result; - }, - - _cloneRegion: function (regions) { - var clone = {}; - BI.each(regions || this.regions, function (id, region) { - clone[id] = {}; - clone[id].el = region.el; - clone[id].id = region.id; - clone[id].left = region.left; - clone[id].top = region.top; - clone[id].width = region.width; - clone[id].height = region.height; - }); - return clone; - }, - - //测试合法性 - _test: function (regions) { - var self = this; - return !BI.any(regions || this.regions, function (i, region) { - if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { - return true; - } - }) - }, - - _getScrollOffset: function () { - return { - left: this.scrollContainer.element[0].scrollLeft, - top: this.scrollContainer.element[0].scrollTop - } - }, - - ////操作//// - _createOneRegion: function (item) { - var el = BI.createWidget(item.el); - el.setVisible(true); - return { - id: el.attr("id"), - left: item.left, - top: item.top, - width: item.width, - height: item.height, - el: el - } - }, - - _applyRegion: function (regions) { - var self = this, o = this.options; - BI.each(regions || this.regions, function (i, region) { - region.el.element.css({ - left: region.left, - top: region.top, - width: region.width, - height: region.height - }); - }); - this._applyContainer(); - this.ratio = this.getLayoutRatio(); - }, - - _renderRegion: function () { - var items = BI.toArray(this.regions); - BI.each(items, function (i, item) { - if (BI.isNotNull(item.el)) { - item.el.options.key = item.id; - } else { - item.key = item.id; - } - }); - if (BI.isNull(this.wrapper)) { - this.wrapper = BI.createWidget({ - type: "bi.absolute", - element: this.container - }); - } - this.wrapper.populate(items); - }, - - getClientWidth: function () { - return this.scrollContainer.element[0].clientWidth; - }, - - getClientHeight: function () { - return this.scrollContainer.element[0].clientHeight; - }, - - _applyContainer: function () { - //先掩藏后显示能够明确滚动条是否出现 - this.scrollContainer.element.css("overflow", "hidden"); - var occupied = this._getRegionOccupied(); - this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); - this.scrollContainer.element.css("overflow", "auto"); - return occupied; - }, - - _modifyRegion: function (regions) { - BI.each(this.regions, function (id, region) { - if (regions[id]) { - region.left = regions[id].left; - region.top = regions[id].top; - region.width = regions[id].width; - region.height = regions[id].height; - } - }); - }, - - _addRegion: function (item) { - var region = this._createOneRegion(item); - this.regions[region.id] = region; - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [region] - }); - }, - - _deleteRegionByName: function (name) { - this.regions[name].el.setVisible(false); - delete this.regions[name]; - }, - - _setArrangeSize: function (size) { - this.arrangement.element.css({ - left: size.left, - top: size.top, - width: size.width, - height: size.height - }) - }, - - //Grid - _getOneWidthPortion: function () { - return this.getClientWidth() / BI.Arrangement.PORTION; - }, - _getOneHeightPortion: function () { - return this.getClientHeight() / BI.Arrangement.H_PORTION; - }, - - _getGridPositionAndSize: function (position) { - var perWidth = this._getOneWidthPortion(); - var perHeight = this._getOneHeightPortion(); - var widthPortion = Math.round(position.width / perWidth); - var leftPortion = Math.round(position.left / perWidth); - var topPortion = Math.round(position.top / perHeight); - var heightPortion = Math.round(position.height / perHeight); - // if (leftPortion > BI.Arrangement.PORTION) { - // leftPortion = BI.Arrangement.PORTION; - // } - // if (widthPortion > BI.Arrangement.PORTION) { - // widthPortion = BI.Arrangement.PORTION; - // } - // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { - // leftPortion = BI.Arrangement.PORTION - widthPortion; - // } - if (widthPortion === 0) { - widthPortion = 1; - } - if (heightPortion === 0) { - heightPortion = 1; - } - return { - x: leftPortion, - y: topPortion, - w: widthPortion, - h: heightPortion - } - }, - - _getBlockPositionAndSize: function (position) { - var perWidth = this._getOneWidthPortion(); - var perHeight = this._getOneHeightPortion(); - return { - left: position.x * perWidth, - top: position.y * perHeight, - width: position.w * perWidth, - height: position.h * perHeight - }; - }, - - _getLayoutsByRegions: function (regions) { - var self = this; - var result = []; - BI.each(regions || this.regions, function (id, region) { - result.push(BI.extend(self._getGridPositionAndSize(region), { - i: region.id - })) - }); - return result; - }, - - _getLayoutIndexByName: function (layout, name) { - return BI.findIndex(layout, function (i, l) { - return l.i === name; - }); - }, - - _setBlockPositionAndSize: function (size) { - this.block.element.css({ - left: size.left, - top: size.top, - width: size.width, - height: size.height - }); - }, - - _getRegionsByLayout: function (layout) { - var self = this; - var regions = {}; - BI.each(layout, function (i, ly) { - regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { - id: ly.i - }); - }); - return regions; - }, - - _setRegionsByLayout: function (regions, layout) { - var self = this; - regions || (regions = this.regions); - BI.each(layout, function (i, ly) { - if (regions[ly.i]) { - BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); - } - }); - return regions; - }, - - _moveElement: function (layout, l, x, y, isUserAction) { - var self = this; - if (l._static) { - return layout; - } - - if (l.y === y && l.x === x) { - return layout; - } - - var movingUp = y && l.y > y; - if (typeof x === 'number') { - l.x = x; - } - if (typeof y === 'number') { - l.y = y; - } - l.moved = true; - - var sorted = this._sortLayoutItemsByRowCol(layout); - if (movingUp) { - sorted = sorted.reverse(); - } - var collisions = getAllCollisions(sorted, l); - - for (var i = 0, len = collisions.length; i < len; i++) { - var collision = collisions[i]; - if (collision.moved) { - continue; - } - - if (l.y > collision.y && l.y - collision.y > collision.h / 4) { - continue; - } - - if (collision._static) { - layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); - } else { - layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); - } - } - - return layout; - - function getAllCollisions(layout, layoutItem) { - return BI.filter(layout, function (i, l) { - return self._collides(l, layoutItem); - }); - } - }, - - _sortLayoutItemsByRowCol: function (layout) { - return [].concat(layout).sort(function (a, b) { - if (a.y > b.y || (a.y === b.y && a.x > b.x)) { - return 1; - } - return -1; - }); - }, - - _collides: function (l1, l2) { - if (l1 === l2) { - return false; - } // same element - if (l1.x + l1.w <= l2.x) { - return false; - } // l1 is left of l2 - if (l1.x >= l2.x + l2.w) { - return false; - } // l1 is right of l2 - if (l1.y + l1.h <= l2.y) { - return false; - } // l1 is above l2 - if (l1.y >= l2.y + l2.h) { - return false; - } // l1 is below l2 - return true; // boxes overlap - }, - - _getFirstCollision: function (layout, layoutItem) { - for (var i = 0, len = layout.length; i < len; i++) { - if (this._collides(layout[i], layoutItem)) { - return layout[i]; - } - } - }, - - _moveElementAwayFromCollision: function (layout, collidesWith, - itemToMove, isUserAction) { - if (isUserAction) { - var fakeItem = { - x: itemToMove.x, - y: itemToMove.y, - w: itemToMove.w, - h: itemToMove.h, - i: '-1' - }; - fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); - if (!this._getFirstCollision(layout, fakeItem)) { - return this._moveElement(layout, itemToMove, undefined, fakeItem.y); - } - } - - return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); - }, - - _compactItem: function (compareWith, l, verticalCompact) { - if (verticalCompact) { - while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { - l.y--; - } - } - - var collides; - while ((collides = this._getFirstCollision(compareWith, l))) { - l.y = collides.y + collides.h; - } - return l; - }, - - compact: function (layout, verticalCompact) { - var compareWith = getStatics(layout); - var sorted = this._sortLayoutItemsByRowCol(layout); - var out = []; - - for (var i = 0, len = sorted.length; i < len; i++) { - var l = sorted[i]; - - if (!l._static) { - l = this._compactItem(compareWith, l, verticalCompact); - - compareWith.push(l); - } - - out[layout.indexOf(l)] = l; - - l.moved = false; - } - - return out; - - function getStatics(layout) { - return BI.filter(layout, function (i, l) { - return l._static; - }); - } - }, - - ////公有方法//// - getRegionByName: function (name) { - var obj = {}; - obj[name] = this.regions[name]; - return this._cloneRegion(obj)[name]; - }, - - getAllRegions: function () { - return BI.toArray(this._cloneRegion()); - }, - - getHelper: function () { - var helper = BI.createWidget({ - type: "bi.layout", - width: 18, - height: 18, - cls: "arrangement-helper bi-border" - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [helper] - }); - return helper; - }, - - _start: function () { - if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { - this.block.setVisible(true); - } else { - this.arrangement.setVisible(true); - } - }, - - _stop: function () { - this.arrangement.setVisible(false); - this.block.setVisible(false); - }, - - ////公有操作//// - setLayoutType: function (type) { - var self = this, o = this.options; - if (type !== o.layoutType) { - o.layoutType = type; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.relayout(); - break; - } - } - }, - - getLayoutType: function () { - return this.options.layoutType; - }, - - getLayoutRatio: function () { - var occupied = this._getRegionOccupied(); - var width = this.getClientWidth(), height = this.getClientHeight(); - return { - x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), - y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) - } - }, - - addRegion: function (region, position) { - if (position) { - this.setPosition(position, region); - } - var self = this, o = this.options; - if (!this.position) { - return false; - } - var test = this._cloneRegion(); - BI.each(this.position.regions, function (i, region) { - test[region.id].left = region.left; - test[region.id].top = region.top; - test[region.id].width = region.width; - test[region.id].height = region.height; - - }); - var item = BI.extend({}, region, { - left: this.position.insert.left, - top: this.position.insert.top, - width: this.position.insert.width, - height: this.position.insert.height - }); - var added = this._createOneRegion(item); - test[added.id] = added; - if (this._test(test)) { - delete test[added.id]; - this._modifyRegion(test); - this._addRegion(item); - this._populate(this.getAllRegions()); - return true; - } - return false; - }, - - deleteRegion: function (name) { - if (!this.regions[name]) { - return false; - } - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - this._deleteRegionByName(name); - this._populate(this.getAllRegions()); - return true; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this._deleteRegionByName(name); - this._populate(this.getAllRegions()); - this.resize(); - return true; - } - return false; - }, - - setRegionSize: function (name, size) { - var self = this, o = this.options; - var flag = false; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var clone = this._cloneRegion(); - BI.extend(clone[name], { - width: size.width, - height: size.height - }); - if (this._test(clone)) { - this._modifyRegion(clone); - flag = true; - } - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - var clone = this._cloneRegion(); - BI.extend(clone[name], { - width: size.width, - height: size.height - }); - if (this._test(clone)) { - var layout = this._getLayoutsByRegions(clone); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - flag = true; - } - break; - } - this._applyRegion(); - return flag; - }, - - setPosition: function (position, size) { - var self = this, o = this.options; - var insert, regions = [], cur; - if (position.left < 0 || position.top < 0) { - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.resize(); - break; - } - this._stop(); - this.position = null; - return null; - } - var offset = this._getScrollOffset(); - position = { - left: position.left + offset.left, - top: position.top + offset.top - }; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var insert = { - top: position.top < 0 ? 0 : position.top, - left: position.left < 0 ? 0 : position.left, - width: size.width, - height: size.height - }; - this.position = { - insert: insert - }; - this._setArrangeSize(insert); - this._start(); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - var p = { - top: position.top < 0 ? 0 : position.top, - left: position.left < 0 ? 0 : position.left, - width: size.width, - height: size.height - }; - this._setArrangeSize(p); - var cur = this._getGridPositionAndSize(p); - var layout = [{ - x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i - }].concat(this._getLayoutsByRegions()); - layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); - layout = this.compact(layout, true); - var regions = this._setRegionsByLayout(this._cloneRegion(), layout); - var insert = this._getBlockPositionAndSize(layout[0]); - this.position = { - insert: insert, - regions: regions - }; - this._applyRegion(regions); - this._setBlockPositionAndSize(insert); - this._start(); - break; - } - return this.position; - }, - - setRegionPosition: function (name, position) { - var self = this, o = this.options; - var offset = this._getScrollOffset(); - position = BI.extend(position, { - left: position.left + offset.left, - top: position.top + offset.top - }); - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - this._applyRegion(); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (!position.stop) { - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - var cloned = this._cloneRegion(); - var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - })); - var x = cur.x, y = cur.y; - cur = BI.extend(cur, { - x: 0, y: BI.MAX, i: -1 - }); - delete cloned[name]; - var layout = this._getLayoutsByRegions(cloned); - layout = this._moveElement([cur].concat(layout), cur, x, y, true); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - - this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); - this.block.setVisible(true); - } else { - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - var cloned = this._cloneRegion(); - var layout = this._getLayoutsByRegions(cloned); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - this.block.setVisible(false); - } - break; - } - }, - - setDropPosition: function (position, size) { - var self = this; - this.arrangement.setVisible(true); - var offset = this._getScrollOffset(); - this._setArrangeSize(BI.extend({}, size, { - left: position.left + offset.left, - top: position.top + offset.top - })); - return function () { - self.arrangement.setVisible(false); - } - }, - - scrollTo: function (scroll) { - this.scrollContainer.element.scrollTop(scroll.top); - this.scrollContainer.element.scrollLeft(scroll.left); - }, - - zoom: function (ratio) { - var self = this, o = this.options; - if (!ratio) { - return; - } - var occupied = this._applyContainer(); - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - if (this._isArrangeFine()) { - var width = this.getClientWidth(); - var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); - //var yRatio = ratio.y * height / (occupied.top + occupied.height); - var regions = this._cloneRegion(); - BI.each(regions, function (i, region) { - region.left = region.left * xRatio; - //region.top = region.top * yRatio; - region.width = region.width * xRatio; - //region.height = region.height * yRatio; - }); - if (this._test(regions)) { - this._modifyRegion(regions); - this._applyRegion(); - } - this.resize(); - // } else { - this.relayout(); - } - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (this._isArrangeFine()) { - var width = this.getClientWidth(), height = this.getClientHeight(); - var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); - var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); - var regions = this._cloneRegion(); - BI.each(regions, function (i, region) { - region.left = region.left * xRatio; - region.width = region.width * xRatio; - region.top = region.top * yRatio; - region.height = region.height * yRatio; - //做一下自适应布局到网格布局的兼容 - var perWidth = self._getOneWidthPortion(); - var widthPortion = Math.round(region.width / perWidth); - var leftPortion = Math.round(region.left / perWidth); - var comparePortion = Math.round((region.width + region.left) / perWidth); - if (leftPortion + widthPortion !== comparePortion) { - region.left = leftPortion * perWidth; - region.width = comparePortion * perWidth - region.left; - } - }); - if (this._test(regions)) { - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - } - } else { - this.relayout(); - } - break; - } - }, - - resize: function () { - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.zoom(this.ratio); - var regions = this._cloneRegion(); - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - break; - } - }, - - relayout: function () { - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (!this._isArrangeFine()) { - var perHeight = this._getOneHeightPortion(); - var width = this.getClientWidth(), height = this.getClientHeight(); - var regions = this._cloneRegion(); - var clone = BI.toArray(regions); - clone.sort(function (r1, r2) { - if (self._isEqual(r1.top, r2.top)) { - return r1.left - r2.left; - } - return r1.top - r2.top; - }); - var count = clone.length; - var cols = 4, rows = Math.floor((count - 1) / 4 + 1); - var w = width / cols, h = height / rows; - var store = {}; - BI.each(clone, function (i, region) { - var row = Math.floor(i / 4), col = i % 4; - BI.extend(region, { - top: row * perHeight * 6, - left: col * w, - width: w, - height: perHeight * 6 - }); - if (!store[row]) { - store[row] = {}; - } - store[row][col] = region; - }); - //非4的倍数 - // if (count % 4 !== 0) { - // var lasts = store[rows - 1]; - // var perWidth = width / (count % 4); - // BI.each(lasts, function (i, region) { - // BI.extend(region, { - // left: BI.parseInt(i) * perWidth, - // width: perWidth - // }); - // }); - // } - if (this._test(clone)) { - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._populate(clone); - } - } else { - this.resize(); - } - break; - } - }, - - _populate: function (items) { - this._stop(); - this._calculateRegions(items); - this._applyRegion(); - }, - - populate: function (items) { - this.regions = {}; - this._populate(items); - this._renderRegion(); - } -}); -BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; -BI.extend(BI.Arrangement, { - PORTION: 36, - H_PORTION: 18, - LAYOUT_TYPE: { - GRID: 0, - FREE: 1 - } -}); -BI.shortcut('bi.arrangement', BI.Arrangement);/** - * 日期控件中的月份下拉框 - * - * 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: 25 - }); - }, - _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" - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ - self.setValue(self.popup.getValue()); - }) - - - this.combo = BI.createWidget({ - type: "bi.combo", - offsetStyle: "center", - 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); - }); - }, - - setValue: function(v){ - this.trigger.setValue(v + 1); - 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', //最大日期 - height: 25 - }); - }, - _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", - 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, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: this.popup - } - }) - this.combo.on(BI.Combo.EVENT_CHANGE, function(){ - self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); - }) - }, - - 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 bi-background", - height: 25, - 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 = new Date().getFullYear(); - this._month = new Date().getMonth(); - 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 () { - if (self._month === 0) { - self.setValue({ - year: self.year.getValue() - 1, - month: 11 - }) - } 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: 25, - height: 25 - }); - - this.right.on(BI.IconButton.EVENT_CHANGE, function () { - if (self._month === 11) { - self.setValue({ - year: self.year.getValue() + 1, - month: 0 - }) - } 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", - 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" - }); - 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: this.left, - width: 25 - }, { - type: "bi.center_adapt", - items: [{ - type: "bi.horizontal", - width: 100, - items: [this.year, this.month] - }] - }, { - el: this.right, - width: 25 - }] - }) - this.setValue({ - year: this._year, - month: this._month - }) - }, - - _checkLeftValid: function () { - var o = this.options; - var valid = !(this._month === 0 && this._year === Date.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); - this.left.setEnable(valid); - return valid; - }, - - _checkRightValid: function () { - var o = this.options; - var valid = !(this._month === 11 && this._year === Date.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); - this.right.setEnable(valid); - return valid; - }, - - - - setValue: function (ob) { - this._year = ob.year; - this._month = 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.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 = new Date(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); - 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", - min: o.min, - max: o.max - }); - - this.calendar = BI.createWidget({ - direction: "top", - element: this, - 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); - }); - }, - - 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);/** - * 日期控件中的年份或月份trigger - * - * Created by GUY on 2015/9/7. - * @class BI.DateTriangleTrigger - * @extends BI.Trigger - */ -BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { - _const: { - height: 25, - iconWidth: 16, - iconHeight: 13 - }, - - _defaultConfig: function() { - return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", - height: 25 - }); - }, - _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 - }) - this.icon = BI.createWidget({ - type: "bi.icon", - width: c.iconWidth, - height: c.iconHeight - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [{ - type: "bi.center_adapt", - width: 50, - height: c.height, - items: [this.text, this.icon] - }] - }) - }, - - 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 GUY on 2015/9/7. - * @class BI.DateCombo - * @extends BI.Widget - */ -BI.DateCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-combo bi-border", - height: 25 - }); - }, - _init: function () { - BI.DateCombo.superclass._init.apply(this, arguments); - var self = this, - o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.date_trigger" - }); - - this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { - self.combo.toggle(); - }); - - this.popup = BI.createWidget({ - type: "bi.date_calendar_popup" - }); - - this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - width: 270, - el: this.popup, - stopPropagation: false - } - }) - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - triggerWidth: 30, - yearLength: 4, - yearMonthLength: 7 - }, - - _defaultConfig: function () { - return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-date-trigger", - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.DateTrigger.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) { - var date = v.match(/\d+/g); - self._autoAppend(v, date); - return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ - year: date[0], - month: date[1], - day: date[2] - }); - }, - 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"); - } - }); - this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.DateTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DateTrigger.EVENT_STOP); - }); - this.editor.on(BI.SignEditor.EVENT_VALID, function () { - self.fireEvent(BI.DateTrigger.EVENT_VALID); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DateTrigger.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)) { - var date = value.split("-"); - self.store_value = { - type: BI.DateTrigger.MULTI_DATE_CALENDAR, - value:{ - year: date[0] | 0, - month: date[1] - 1, - day: date[2] | 0 - } - }; - } - self.fireEvent(BI.DateTrigger.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.DateTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTrigger.EVENT_CHANGE); - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: BI.createWidget(), - width: 30 - }, { - el: this.editor - }] - }) - }, - _dateCheck: function (date) { - return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; - }, - _checkVoid: function (obj) { - return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; - }, - _autoAppend: function (v, dateObj) { - var self = this; - var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - var yearCheck = function (v) { - return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; - }; - var monthCheck = function (v) { - return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; - }; - if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { - switch (v.length) { - case this._const.yearLength: - if (yearCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - case this._const.yearMonthLength: - if (monthCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - } - } - }, - - setValue: function (v) { - var type, value, self = this; - var date = new Date(); - this.store_value = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; - if(BI.isNull(value)){ - value = v; - } - } - var _setInnerValue = function (date, text) { - var dateStr = date.print("%Y-%x-%e"); - self.editor.setState(dateStr); - self.editor.setValue(dateStr); - self.setTitle(text + ":" + dateStr); - }; - switch (type) { - case BI.DateTrigger.MULTI_DATE_YEAR_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; - date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; - date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; - date = new Date(date.getFullYear(), 0, 1); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; - date = new Date(date.getFullYear(), 11, 31); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; - date = new Date().getBeforeMulQuarter(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; - date = new Date().getAfterMulQuarter(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; - date = new Date().getQuarterStartDate(); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; - date = new Date().getQuarterEndDate(); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; - date = new Date().getBeforeMultiMonth(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; - date = new Date().getAfterMultiMonth(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; - date = new Date(date.getFullYear(), date.getMonth(), 1); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; - date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_WEEK_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; - date = date.getOffsetDate(-7 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; - date = date.getOffsetDate(7 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; - date = date.getOffsetDate(-1 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; - date = date.getOffsetDate(1 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_TODAY: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; - date = new Date(); - _setInnerValue(date, text); - break; - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - this.editor.setState(""); - this.editor.setValue(""); - this.setTitle(""); - } else { - var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - this.setTitle(dateStr); - } - break; - } - }, - - getKey: function () { - return this.editor.getValue(); - }, - getValue: function () { - return this.store_value; - } - -}); - -BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; -BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; -BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; -BI.DateTrigger.MULTI_DATE_YEAR_END = 4; - -BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; -BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; -BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; -BI.DateTrigger.MULTI_DATE_MONTH_END = 8; - -BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; -BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; -BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; -BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; - -BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; -BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; - -BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; -BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; -BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; - -BI.DateTrigger.MULTI_DATE_PARAM = 18; -BI.DateTrigger.MULTI_DATE_CALENDAR = 19; - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); - -BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DateTrigger.EVENT_START = "EVENT_START"; -BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; -BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.date_trigger", BI.DateTrigger);/** - * Created by zcf on 2017/2/20. - */ -BI.DatePaneWidget = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.DatePaneWidget.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.DatePaneWidget.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.today = new Date(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); - - this.selectedTime = o.selectedTime || { - year: this._year, - month: this._month - }; - - this.datePicker = BI.createWidget({ - type: "bi.date_picker", - min: o.min, - max: o.max - }); - 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 = BI.createWidget({ - direction: "top", - element: this, - logic: { - dynamic: false - }, - type: "bi.navigation", - tab: this.datePicker, - cardCreator: BI.bind(this._createNav, this) - - // afterCardCreated: function () { - // - // }, - // - // afterCardShow: function () { - // // this.setValue(self.selectedTime); - // } - }); - 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); - }); - - }, - - _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 = new Date(); - return { - year: today.getFullYear(), - month: today.getMonth() - } - }, - - _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.date_pane", BI.DatePaneWidget);/** - * 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', - width: 200, - height: 24 - }); - }, - _init: function () { - BI.DateTimeCombo.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - var date = new Date(); - this.storeValue = { - year: date.getFullYear(), - month: date.getMonth(), - 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 - }); - - this.popup = BI.createWidget({ - type: "bi.date_time_popup", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_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.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () { - self.trigger.setValue(self.popup.getValue()); - self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE); - }); - this.combo = BI.createWidget({ - type: 'bi.combo', - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: this.popup, - maxHeight: this.constants.popupHeight, - width: this.constants.popupWidth, - stopPropagation: false - } - }); - 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 bi-border-right", - width: 30, - height: 24 - }); - triggerBtn.on(BI.TriggerIconButton.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, - left: 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: 290 - }); - }, - _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", - min: self.options.min, - max: self.options.max - }); - self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - }); - - this.dateSelect = BI.createWidget({ - type: "bi.vertical_adapt", - cls: "bi-border-top", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Basic_Time"), - width: 45 - }, { - type: "bi.date_time_select", - max: 23, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.hour = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.minute = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.second = _ref; - } - }] - }); - - var date = new Date(); - this.dateCombo.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.hour.setValue(date.getHours()); - this.minute.setValue(date.getMinutes()); - this.second.setValue(date.getSeconds()); - - this.dateButton = BI.createWidget({ - type: "bi.grid", - items: [[this.cancelButton, this.okButton]] - }); - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this.dateCombo - }, { - el: this.dateSelect, - height: 50 - }, { - el: this.dateButton, - height: 30 - }] - }); - }, - - setValue: function (v) { - var value = v, date; - if (BI.isNull(value)) { - date = new Date(); - this.dateCombo.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.hour.setValue(date.getHours()); - this.minute.setValue(date.getMinutes()); - this.second.setValue(date.getSeconds()); - } else { - this.dateCombo.setValue({ - year: value.year, - month: value.month, - day: value.day - }); - this.hour.setValue(value.hour); - this.minute.setValue(value.minute); - this.second.setValue(value.second); - } - }, - - getValue: function () { - return { - year: this.dateCombo.getValue().year, - month: this.dateCombo.getValue().month, - day: this.dateCombo.getValue().day, - hour: this.hour.getValue(), - minute: this.minute.getValue(), - second: this.second.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.DateTimeSelect = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-time-select bi-border", - max: 23, - min: 0 - }) - }, - - _init: function () { - BI.DateTimeSelect.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - value: this._alertInEditorValue(o.min), - allowBlank: false, - errorText: BI.i18nText("BI-Please_Input_Natural_Number"), - validationChecker: function(v){ - return BI.isNaturalNumber(v); - } - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ - self._finetuning(0); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ - self._finetuning(1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-next-page-h-font bottom-button bi-border-left" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ - self._finetuning(-1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this._finetuning(0); - BI.createWidget({ - type: "bi.htape", - 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: 30 - }] - }); - }, - - _alertOutEditorValue: function(v){ - if (v > this.options.max){ - v = this.options.min; - } - if (v < this.options.min){ - v = this.options.max - } - return BI.parseInt(v); - }, - - _alertInEditorValue: function(v){ - if (v > this.options.max){ - v = this.options.min; - } - if (v < this.options.min){ - v = this.options.max; - } - v = v < 10 ? "0" + v : v; - return v; - }, - - _finetuning: function(add){ - var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); - this.editor.setValue(this._alertInEditorValue(v + add)); - }, - - getValue: function () { - var v = this.editor.getValue(); - return this._alertOutEditorValue(v); - }, - - setValue: function (v) { - this.editor.setValue(this._alertInEditorValue(v)); - this._finetuning(0); - } - -}); -BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimeTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - triggerWidth: 30 - }, - - _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: BI.createWidget(), - width: c.triggerWidth - }, { - el: this.text - }] - }) - }, - - _printTime: function (v) { - return v < 10 ? "0" + v : v; - }, - - setValue: function (v) { - var self = this; - var value = v, dateStr; - if(BI.isNull(value)){ - value = new Date(); - dateStr = value.print("%Y-%X-%d %H:%M:%S"); - } else { - var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second); - dateStr = date.print("%Y-%X-%d %H:%M:%S"); - - } - this.text.setText(dateStr); - this.text.setTitle(dateStr); - } - -}); -BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/** - * 带有方向的pathchooser - * - * Created by GUY on 2016/4/21. - * @class BI.DirectionPathChooser - * @extends BI.Widget - */ -BI.DirectionPathChooser = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#808080", - selectLineColor: "#009de3" - }, - - _defaultConfig: function () { - return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-excel-table", - items: [] - }); - }, - - _init: function () { - BI.DirectionPathChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.pathChooser = BI.createWidget({ - type: "bi.path_chooser", - element: this, - items: o.items - }); - this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { - //self._unselectAllArrows(); - self._setValue(start, index); - self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); - }); - this._drawArrows(); - - }, - - _unselectAllArrows: function () { - var self = this, lineColor = this._const.lineColor; - BI.each(this.arrows, function (region, rs) { - BI.each(rs, function (idx, arrows) { - BI.each(arrows, function (i, arrow) { - arrow.attr({fill: lineColor, stroke: lineColor}); - }); - }); - }); - }, - - _drawOneArrow: function (dot, direction) { - //0,1,2,3 上右下左 - var lineColor = this._const.lineColor; - var selectLineColor = this._const.selectLineColor; - var svg = this.pathChooser.svg; - var path = ""; - switch (direction) { - case 0: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 3) + "," + (dot.y + 5) - + "L" + (dot.x + 3) + "," + (dot.y + 5) - + "L" + dot.x + "," + dot.y; - break; - case 1: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 5) + "," + (dot.y - 3) - + "L" + (dot.x - 5) + "," + (dot.y + 3) - + "L" + dot.x + "," + dot.y; - break; - case 2: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 3) + "," + (dot.y - 5) - + "L" + (dot.x + 3) + "," + (dot.y - 5) - + "L" + dot.x + "," + dot.y; - break; - case 3: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x + 5) + "," + (dot.y - 3) - + "L" + (dot.x + 5) + "," + (dot.y + 3) - + "L" + dot.x + "," + dot.y; - break; - } - return svg.path(path).attr({fill: lineColor, stroke: lineColor}); - }, - - _drawArrows: function () { - var self = this, o = this.options; - var routes = this.pathChooser.routes; - var pathes = this.pathChooser.pathes; - var store = this.pathChooser.store; - this.arrows = {}; - BI.each(routes, function (region, ps) { - self.arrows[region] = []; - BI.each(ps, function (idx, path) { - self.arrows[region][idx] = []; - var dots = pathes[region][idx]; - BI.each(dots, function (i, dot) { - if (i > 0 && i < dots.length - 1) { - var arrow; - if (dot.y === dots[i - 1].y) { - if (dots[i + 1].y != dot.y) { - if (store[path[path.length - 2]].direction === -1) { - if (i - 1 > 0) { - arrow = self._drawOneArrow(dots[i - 1], 3); - } - } else { - arrow = self._drawOneArrow(dots[i], 1); - } - } - } else if (dot.x === dots[i - 1].x) { - if (dot.y > dots[i - 1].y) { - if (store[BI.first(path)].direction === -1) { - arrow = self._drawOneArrow(dots[i - 1], 0); - } else { - arrow = self._drawOneArrow(dot, 2); - } - } else { - if (store[path[path.length - 2]].direction === -1) { - arrow = self._drawOneArrow(dots[i - 1], 2); - } else { - arrow = self._drawOneArrow(dot, 0); - } - } - } - if (arrow) { - self.arrows[region][idx].push(arrow); - } - } - }); - BI.each(path, function (i, node) { - if (i !== 0) { - var arrow; - var from = path[i - 1]; - if (store[from].direction === -1) { - var regionIndex = self.pathChooser.getRegionIndexById(from); - var x = getXoffsetByRegionIndex(regionIndex, -1); - var y = getYByXoffset(dots, x); - arrow = self._drawOneArrow({x: x, y: y}, 3); - } else { - var regionIndex = self.pathChooser.getRegionIndexById(node); - var x = getXoffsetByRegionIndex(regionIndex); - var y = getYByXoffset(dots, x); - arrow = self._drawOneArrow({x: x, y: y}, 1); - } - if (arrow) { - self.arrows[region][idx].push(arrow); - } - } - }); - }) - }); - - function getXoffsetByRegionIndex(regionIndex, diregion) { - if (diregion === -1) { - return 100 * (regionIndex + 1) - 20; - } - return 100 * regionIndex + 20; - } - - function getYByXoffset(dots, xoffset) { - var finded = BI.find(dots, function (i, dot) { - if (i > 0) { - if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { - return true; - } - } - }); - return finded.y; - } - }, - - _setValue: function (start, index) { - var self = this; - var lineColor = this._const.lineColor; - var selectLineColor = this._const.selectLineColor; - var routes = this.pathChooser.routes; - var starts = this.pathChooser.start; - var each = [start]; - if (starts.contains(start)) { - each = starts; - } - BI.each(each, function (i, s) { - BI.each(self.arrows[s], function (j, arrows) { - BI.each(arrows, function (k, arrow) { - arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); - }); - }); - }); - BI.each(this.arrows[start][index], function (i, arrow) { - arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); - }); - var current = BI.last(routes[start][index]); - while (current && routes[current] && routes[current].length === 1) { - BI.each(self.arrows[current][0], function (i, arrow) { - arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); - }); - current = BI.last(routes[current][0]); - } - }, - - setValue: function (v) { - this.pathChooser.setValue(v); - this._unselectAllArrows(); - var routes = this.pathChooser.routes; - var nodes = BI.keys(routes), self = this; - var result = [], array = []; - BI.each(v, function (i, val) { - if (BI.contains(nodes, val)) { - if (array.length > 0) { - array.push(val); - result.push(array); - array = []; - } - } - array.push(val); - }); - if (array.length > 0) { - result.push(array); - } - //画这n条路径 - BI.each(result, function (idx, path) { - var start = path[0]; - var index = BI.findIndex(routes[start], function (idx, p) { - if (BI.isEqual(path, p)) { - return true; - } - }); - if (index >= 0) { - self._setValue(start, index); - } - }); - }, - - getValue: function () { - return this.pathChooser.getValue(); - }, - - populate: function (items) { - this.pathChooser.populate(items); - this._drawArrows(); - } -}); -BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; -BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** - * 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", - invalid: false, - height: 25, - items: [], - adjustLength: 0, - direction: "bottom", - trigger: "click", - 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 - }); - - 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, - adjustLength: o.adjustLength, - direction: o.direction, - 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 () { - this.downlistcombo.showView(); - }, - - 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 - }] - }); - 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.Single, { - _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: 25, - 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.icon_text_item", - element: this, - height: o.height, - text: o.text, - value: o.value, - logic: o.logic, - selected: o.selected, - disabled: o.disabled, - iconHeight: o.iconHeight, - iconWidth: o.iconWidth, - textHgap: o.textHgap, - textVgap: o.textVgap, - textLgap: o.textLgap, - textRgap: o.textRgap, - father: o.father - }); - this.text.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { - self.fireEvent(BI.DownListItem.EVENT_CHANGE); - }); - // this.setSelected(o.selected); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - isSelected: function () { - return this.text.isSelected(); - }, - - setSelected: function (b) { - this.text.setSelected(b); - // if (b === true) { - // this.element.addClass("dot-e-font"); - // } else { - // this.element.removeClass("dot-e-font"); - // } - }, - - setValue: function (v) { - this.text.setValue(v); - }, - - getValue: function () { - return this.text.getValue(); - } -}); -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: 25, - forceNotSelected: true - }); - - this.icon2 = BI.createWidget({ - type: "bi.icon_button", - cls: o.iconCls2, - width: 25, - forceNotSelected: true - }); - - var blank = BI.createWidget({ - type: "bi.layout", - width: 25 - }); - 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() - } - }); - }, - - 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) { - var self = this, o = this.options; - v = BI.isArray(v) ? v : [v]; - BI.find(v, function (idx, value) { - if (BI.contains(o.childValues, value)) { - self.icon1.setSelected(true); - return true; - } else { - self.icon1.setSelected(false); - } - }) - } -}); -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: 25, - 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 = {}; - var self = this, o = this.options, children = this._createChildren(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 - }], - 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 (!self.singleValues.contains(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] - }); - - }, - _createChildren: 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: 4, - el: { - type: "bi.button_tree", - chooseType: 0, - layouts: [{ - type: "bi.vertical" - }] - - } - }; - 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-border-top cursor-pointer", - height: 0 - } - - }], - cls: "bi-down-list-spliter-container cursor-pointer", - lgap: 10, - rgap: 10 - }); - 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 - }, - - populate: function (items) { - BI.DownListPopup.superclass.populate.apply(this, arguments); - var self = this; - self.childValueMap = {}; - self.fatherValueMap = {}; - self.singleValues = []; - var children = self._createChildren(items); - var popupItem = BI.createItems(children, - {}, { - adjustLength: -2 - } - ); - self.popup.populate(popupItem); - }, - - setValue: 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); - } - ); - this.popup.setValue(valueArray); - }, - - getValue: function () { - var self = this, result = []; - var values = this.popup.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 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", - height: 30, - 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, - errorText: o.errorText, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker - }); - 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.SearchEditor.EVENT_CLEAR); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: { - type: "bi.center_adapt", - cls: "search-font", - items: [{ - el: { - type: "bi.icon" - } - }] - }, - width: 25 - }, - { - el: self.editor - }, - { - el: this.clear, - width: 25 - } - ] - }); - 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]; - } - }, - - 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: 24 - }); - }, - - _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", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: false, - watermark: "", - errorText: "", - height: 30 - }) - }, - - _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: 25 - }); - }, - - _init: function () { - BI.SmallTextEditor.superclass._init.apply(this, arguments); - } -}); -BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** - * 文件管理控件组 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerButtonGroup - * @extends BI.Widget - */ -BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-button_group", - items: [] - }) - }, - - _init: function () { - BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.button_group = BI.createWidget({ - type: "bi.button_tree", - element: this, - chooseType: BI.Selection.Multi, - items: this._formatItems(o.items), - layouts: [{ - type: "bi.vertical" - }] - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _formatItems: function (items) { - var self = this, o = this.options; - BI.each(items, function (i, item) { - if (item.children && item.children.length > 0) { - item.type = "bi.file_manager_folder_item"; - } else { - item.type = "bi.file_manager_file_item"; - } - }); - return items; - }, - - setValue: function (v) { - this.button_group.setValue(v); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getNotSelectedValue: function () { - return this.button_group.getNotSelectedValue(); - }, - - getAllLeaves: function () { - return this.button_group.getAllLeaves(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - getSelectedButtons: function () { - return this.button_group.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.button_group.getNotSelectedButtons(); - }, - - populate: function (items) { - this.button_group.populate(this._formatItems(items)); - } -}); -BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManager - * @extends BI.Widget - */ -BI.FileManager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager", - el: {}, - items: [] - }) - }, - - _init: function () { - BI.FileManager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - var items = BI.Tree.transformToTreeFormat(o.items); - this.tree.initTree(items); - this.selectedValues = []; - this.nav = BI.createWidget({ - type: "bi.file_manager_nav", - items: BI.deepClone(items) - }); - this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { - if (value == "-1") {//根节点 - self.populate({children: self.tree.toJSON()}); - } else { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } - self.setValue(self.selectedValues); - }); - this.list = BI.createWidget(o.el, { - type: "bi.file_manager_list", - items: items - }); - this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { - if (type === BI.Events.CHANGE) { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } else if (type === BI.Events.CLICK) { - var values = []; - if (obj instanceof BI.MultiSelectBar) { - var t = self.list.getValue(); - selected = t.type === BI.Selection.All; - values = BI.concat(t.assist, t.value); - } else { - values = obj.getAllLeaves(); - } - BI.each(values, function (i, v) { - if (selected === true) { - self.selectedValues.pushDistinct(v); - } else { - self.selectedValues.remove(v); - } - }); - } - self.setValue(self.selectedValues); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.list, - left: 0, - right: 0, - top: 0, - bottom: 10 - }, { - el: this.nav, - left: 40, - right: 100, - top: 0 - }] - }); - }, - - setValue: function (value) { - this.selectedValues = value || []; - this.list.setValue(this.selectedValues); - }, - - getValue: function () { - var obj = this.list.getValue(); - var res = obj.type === BI.Selection.All ? obj.assist : obj.value; - res.pushDistinctArray(this.selectedValues); - return res; - }, - - _populate: function (items) { - this.list.populate(items); - }, - - getSelectedValue: function () { - return this.nav.getValue()[0]; - }, - - getSelectedId: function () { - return this.nav.getId()[0]; - }, - - populate: function (node) { - var clone = BI.deepClone(node); - this._populate(node.children); - this.nav.populate(clone); - } -}); -BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; -BI.shortcut("bi.file_manager", BI.FileManager);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFileItem - * @extends BI.Single - */ -BI.FileManagerFileItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", - height: 30 - }) - }, - - _init: function () { - BI.FileManagerFileItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-file-font" - }, - width: 20 - }, { - el: { - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - } - }] - }) - }, - - getAllLeaves: function(){ - return [this.options.value]; - }, - - isSelected: function () { - return this.checked.isSelected(); - }, - - setSelected: function (v) { - this.checked.setSelected(v); - } -}); -BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFolderItem - * @extends BI.Single - */ -BI.FileManagerFolderItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", - height: 30 - }) - }, - - _init: function () { - BI.FileManagerFolderItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button = BI.createWidget({ - type: "bi.text_button", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); - }); - - this.tree = new BI.Tree(); - this.tree.initTree([{ - id: o.id, - children: o.children - }]); - this.selectValue = []; - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-folder-font" - }, - width: 20 - }, { - el: this.button - }] - }) - }, - - setAllSelected: function (v) { - this.checked.setSelected(v); - this.selectValue = []; - }, - - setHalfSelected: function (v) { - this.checked.setHalfSelected(v); - if(!v){ - this.selectValue = []; - } - }, - - setValue: function (v) { - var self = this, o = this.options; - var isHalf = false; - var selectValue = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - if (BI.contains(v, node.get("data").value)) { - selectValue.push(node.get("data").value); - } else { - isHalf = true; - } - } - }); - this.setAllSelected(selectValue.length > 0 && !isHalf); - this.setHalfSelected(selectValue.length > 0 && isHalf); - if (this.checked.isHalfSelected()) { - this.selectValue = selectValue; - } - }, - - getAllButtons: function () { - return [this]; - }, - - getAllLeaves: function () { - var o = this.options; - var res = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value) - } - }); - return res; - }, - - getNotSelectedValue: function () { - var self = this, o = this.options; - var res = []; - var isAllSelected = this.checked.isSelected(); - if (isAllSelected === true) { - return res; - } - var isHalfSelected = this.checked.isHalfSelected(); - this.tree.traverse(function (node) { - if (node.isLeaf()) { - var v = node.get("data").value; - if (isHalfSelected === true) { - if (!BI.contains(self.selectValue, node.get("data").value)) { - res.push(v); - } - } else { - res.push(v); - } - } - }); - return res; - }, - - getValue: function () { - var res = []; - if (this.checked.isSelected()) { - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value); - } - }); - return res; - } - if (this.checked.isHalfSelected()) { - return this.selectValue; - } - return []; - } -}); -BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** - * 文件管理控件列表 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerList - * @extends BI.Widget - */ -BI.FileManagerList = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-list", - el: {}, - items: [] - }) - }, - - _init: function () { - BI.FileManagerList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.list = BI.createWidget({ - type: "bi.select_list", - element: this, - items: o.items, - toolbar: { - type: "bi.multi_select_bar", - height: 40, - text: "" - }, - el: { - type: "bi.list_pane", - el: BI.isWidget(o.el) ? o.el : BI.extend({ - type: "bi.file_manager_button_group" - }, o.el) - } - }); - this.list.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - setValue: function (v) { - this.list.setValue({ - value: v - }); - }, - - getValue: function () { - return this.list.getValue(); - }, - - populate: function (items) { - this.list.populate(items); - this.list.setToolBarVisible(true); - } -}); -BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** - * 文件管理导航按钮 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNavButton - * @extends BI.Widget - */ -BI.FileManagerNavButton = BI.inherit(BI.Widget, { - - _const: { - normal_color: "#ffffff", - select_color: "#eff1f4" - }, - _defaultConfig: function () { - return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav-button", - selected: false, - height: 40 - }) - }, - - _init: function () { - BI.FileManagerNavButton.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.button = BI.createWidget({ - type: "bi.text_button", - cls: "file-manager-nav-button-text bi-card", - once: true, - selected: o.selected, - text: o.text, - title: o.text, - value: o.value, - height: o.height, - lgap: 20, - rgap: 10 - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var svg = BI.createWidget({ - type: "bi.svg", - cls: "file-manager-nav-button-triangle", - width: 15, - height: o.height - }); - var path = svg.path("M0,0L15,20L0,40").attr({ - "stroke": c.select_color, - "fill": o.selected ? c.select_color : c.normal_color - }); - this.button.on(BI.TextButton.EVENT_CHANGE, function () { - if (this.isSelected()) { - path.attr("fill", c.select_color); - } else { - path.attr("fill", c.normal_color); - } - }); - BI.createWidget({ - type: "bi.default", - element: this, - items: [this.button] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: svg, - right: -15, - top: 0, - bottom: 0 - }] - }) - }, - - isSelected: function () { - return this.button.isSelected(); - }, - - setValue: function (v) { - this.button.setValue(v); - }, - - getValue: function () { - return this.button.getValue(); - }, - - populate: function (items) { - - } -}); -BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** - * 文件管理导航 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNav - * @extends BI.Widget - */ -BI.FileManagerNav = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav bi-border-left", - height: 40, - items: [] - }) - }, - - _init: function () { - BI.FileManagerNav.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - this.refreshTreeData(o.items); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - this.button_group = BI.createWidget({ - type: "bi.button_group", - element: this, - items: [{ - type: "bi.file_manager_nav_button", - text: BI.i18nText("BI-Created_By_Me"), - selected: true, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME, - value: BI.FileManagerNav.ROOT_CREATE_BY_ME - }], - layouts: [{ - type: "bi.horizontal" - }] - }); - 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.FileManagerNav.EVENT_CHANGE, arguments); - }); - }, - - _getAllParents: function (id) { - var node, res = []; - if (!id) { - node = this.tree.getRoot(); - } else { - node = this.tree.search(id); - } - while (node.parent) { - res.push(node); - node = node.parent; - } - res.push(node); - return res.reverse(); - }, - - _formatNodes: function (nodes) { - var res = []; - BI.each(nodes, function (i, node) { - res.push(BI.extend({ - type: "bi.file_manager_nav_button", - id: node.id - }, node.get("data"))); - }); - BI.last(res).selected = true; - return res; - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getId: function () { - var ids = []; - BI.each(this.button_group.getSelectedButtons(), function (i, btn) { - ids.push(btn.attr("id")); - }); - return ids; - }, - - refreshTreeData: function(items){ - this.tree.initTree(BI.Tree.transformToTreeFormat(items)); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - }, - - populate: function (node) { - var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); - this.button_group.populate(this._formatNodes(parents)); - } -}); -BI.extend(BI.FileManagerNav, { - ROOT_CREATE_BY_ME: "-1" -}); -BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** - * 交互行为布局 - * - * - * Created by GUY on 2016/7/23. - * @class BI.InteractiveArrangement - * @extends BI.Widget - */ -BI.InteractiveArrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-interactive-arrangement", - resizable: true, - layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, - items: [] - }); - }, - - _init: function () { - BI.InteractiveArrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.adaptive_arrangement", - element: this, - resizable: o.resizable, - layoutType: o.layoutType, - items: o.items - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { - self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { - self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); - }); - - this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { - var p = self._getRegionClientPosition(id); - self.draw({ - left: p.left, - top: p.top - }, size, id); - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { - self.stopDraw(); - self.setRegionSize(id, size); - }); - - this.tags = []; - - }, - - _isEqual: function (num1, num2) { - return this.arrangement._isEqual(num1, num2); - }, - - _getScrollOffset: function () { - return this.arrangement._getScrollOffset(); - }, - - _positionAt: function (position, regions) { - var self = this; - regions = regions || this.getAllRegions(); - var left = [], center = [], right = [], top = [], middle = [], bottom = []; - BI.each(regions, function (i, region) { - var client = self._getRegionClientPosition(region.id); - if (Math.abs(client.left - position.left) <= 3) { - left.push(region); - } - if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { - center.push(region); - } - if (Math.abs(client.left + client.width - position.left) <= 3) { - right.push(region); - } - if (Math.abs(client.top - position.top) <= 3) { - top.push(region); - } - if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { - middle.push(region); - } - if (Math.abs(client.top + client.height - position.top) <= 3) { - bottom.push(region); - } - }); - return { - left: left, - center: center, - right: right, - top: top, - middle: middle, - bottom: bottom - } - }, - - _getRegionClientPosition: function (name) { - var region = this.getRegionByName(name); - var offset = this.arrangement._getScrollOffset(); - return { - top: region.top - offset.top, - left: region.left - offset.left, - width: region.width, - height: region.height, - id: region.id - } - }, - - _vAlign: function (position, regions) { - var self = this; - var vs = this._positionAt(position, regions); - var positions = []; - var l; - if (vs.left.length > 0) { - l = this._getRegionClientPosition(vs.left[0].id).left; - } else if (vs.right.length > 0) { - var temp = this._getRegionClientPosition(vs.right[0].id); - l = temp.left + temp.width; - } else if (vs.center.length > 0) { - var temp = this._getRegionClientPosition(vs.center[0].id); - l = temp.left + temp.width / 2; - } - var rs = vs.left.concat(vs.right).concat(vs.center); - BI.each(rs, function (i, region) { - var p = self._getRegionClientPosition(region.id); - if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l) || self._isEqual(p.left + p.width / 2, l)) { - var topPoint = { - top: p.top + p.height / 2, - left: l - }; - positions.push({ - id: region.id, - start: topPoint, - end: { - left: l, - top: position.top - } - }); - } - }); - return positions; - }, - - _leftAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left, - top: position.top + size.height / 2 - }, regions); - }, - - _rightAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left + size.width, - top: position.top + size.height / 2 - }, regions); - }, - - _hAlign: function (position, regions) { - var self = this; - var hs = this._positionAt(position, regions); - var positions = []; - var t; - if (hs.top.length > 0) { - var temp = this._getRegionClientPosition(hs.top[0].id); - t = temp.top; - } else if (hs.bottom.length > 0) { - var temp = this._getRegionClientPosition(hs.bottom[0].id); - t = temp.top + temp.height; - } else if (hs.middle.length > 0) { - var temp = this._getRegionClientPosition(hs.middle[0].id); - t = temp.top + temp.height / 2; - } - var rs = hs.top.concat(hs.bottom).concat(hs.middle); - BI.each(rs, function (i, region) { - var p = self._getRegionClientPosition(region.id); - if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t) || self._isEqual(p.top + p.height / 2, t)) { - var leftPoint = { - top: t, - left: p.left + p.width / 2 - }; - positions.push({ - id: p.id, - start: leftPoint, - end: { - left: position.left, - top: t - } - }); - } - }); - return positions; - }, - - _topAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top - }, regions); - }, - - _bottomAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top + size.height - }, regions); - }, - - _centerAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left + size.width / 2, - top: position.top + size.height / 2 - }, regions); - }, - - _middleAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top + size.height / 2 - }, regions); - }, - - - _drawOneTag: function (start, end) { - var s = BI.createWidget({ - type: "bi.icon_button", - //invisible: true, - width: 13, - height: 13, - cls: "drag-tag-font interactive-arrangement-dragtag-icon" - }); - var e = BI.createWidget({ - type: "bi.icon_button", - //invisible: true, - width: 13, - height: 13, - cls: "drag-tag-font interactive-arrangement-dragtag-icon" - }); - if (this._isEqual(start.left, end.left)) { - var line = BI.createWidget({ - type: "bi.layout", - //invisible: true, - cls: "interactive-arrangement-dragtag-line", - width: 1, - height: Math.abs(start.top - end.top) - }); - } else { - var line = BI.createWidget({ - type: "bi.layout", - //invisible: true, - cls: "interactive-arrangement-dragtag-line", - height: 1, - width: Math.abs(start.left - end.left) - }); - } - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: s, - left: start.left - 6, - top: start.top - 7 - }, { - el: e, - left: end.left - 6, - top: end.top - 7 - }, { - el: line, - left: Math.min(start.left, end.left), - top: Math.min(start.top, end.top) - }] - }); - this.tags.push(s); - this.tags.push(e); - this.tags.push(line); - }, - - stopDraw: function () { - BI.each(this.tags, function (i, w) { - w.destroy(); - }); - this.tags = []; - }, - - _getRegionExcept: function (name, regions) { - var other = []; - BI.each(regions || this.getAllRegions(), function (i, region) { - if (!(name && region.id === name)) { - other.push(region); - } - }); - return other; - }, - - getClientWidth: function () { - return this.arrangement.getClientWidth(); - }, - - getClientHeight: function () { - return this.arrangement.getClientHeight(); - }, - - getPosition: function (name, position, size) { - var regions = this.getAllRegions(); - var me; - if (name) { - me = this._getRegionClientPosition(name); - } - var other = this._getRegionExcept(name, regions); - position = position || { - left: me.left, - top: me.top - }; - size = size || { - width: me.width, - height: me.height - }; - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - position.left = pos.end.left - size.width / 2; - }); - BI.each(right, function (i, pos) { - position.left = pos.end.left - size.width; - }); - BI.each(left, function (i, pos) { - position.left = pos.end.left; - }); - BI.each(middle, function (i, pos) { - position.top = pos.end.top - size.height / 2; - }); - BI.each(bottom, function (i, pos) { - position.top = pos.end.top - size.height; - }); - BI.each(top, function (i, pos) { - position.top = pos.end.top; - }); - return position; - }, - - //position不动 变size - getSize: function (name, position, size) { - var regions = this.getAllRegions(); - var me; - if (name) { - me = this._getRegionClientPosition(name); - } - var other = this._getRegionExcept(name, regions); - position = position || { - left: me.left, - top: me.top - }; - size = size || { - width: me.width, - height: me.height - }; - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - size.width = (pos.end.left - position.left) * 2; - }); - BI.each(right, function (i, pos) { - size.width = pos.end.left - position.left; - }); - BI.each(left, function (i, pos) { - }); - BI.each(middle, function (i, pos) { - size.height = (pos.end.top - position.top) * 2; - }); - BI.each(bottom, function (i, pos) { - size.height = pos.end.top - position.top; - }); - BI.each(top, function (i, pos) { - }); - return size; - }, - - draw: function (position, size, name) { - var self = this; - this.stopDraw(); - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var other = this._getRegionExcept(name); - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(right, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(left, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(middle, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(bottom, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(top, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - }, - - addRegion: function (region, position) { - this.stopDraw(); - return this.arrangement.addRegion(region, position); - }, - - deleteRegion: function (name) { - return this.arrangement.deleteRegion(name); - }, - - setRegionSize: function (name, size) { - size = this.getSize(name, null, size); - return this.arrangement.setRegionSize(name, size); - }, - - setPosition: function (position, size) { - var self = this; - this.stopDraw(); - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(null, position, size); - this.draw(position, size); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - var at = this.arrangement.setPosition(position, size); - return at; - }, - - setRegionPosition: function (name, position) { - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(name, position); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - return this.arrangement.setRegionPosition(name, position); - }, - - setDropPosition: function (position, size) { - var self = this; - this.stopDraw(); - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(null, position, size); - this.draw(position, size); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - var callback = self.arrangement.setDropPosition(position, size); - return function () { - callback(); - self.stopDraw(); - } - }, - - scrollInterval: function () { - this.arrangement.scrollInterval.apply(this.arrangement, arguments); - }, - - scrollEnd: function () { - this.arrangement.scrollEnd.apply(this.arrangement, arguments); - }, - - scrollTo: function (scroll) { - this.arrangement.scrollTo(scroll); - }, - - zoom: function (ratio) { - this.arrangement.zoom(ratio); - }, - - resize: function () { - return this.arrangement.resize(); - }, - - relayout: function () { - return this.arrangement.relayout(); - }, - - setLayoutType: function (type) { - this.arrangement.setLayoutType(type); - }, - - getLayoutType: function () { - return this.arrangement.getLayoutType(); - }, - - getLayoutRatio: function () { - return this.arrangement.getLayoutRatio(); - }, - - getHelper: function () { - return this.arrangement.getHelper(); - }, - - getRegionByName: function (name) { - return this.arrangement.getRegionByName(name); - }, - - getAllRegions: function () { - return this.arrangement.getAllRegions(); - }, - - revoke: function () { - return this.arrangement.revoke(); - }, - - populate: function (items) { - var self = this; - this.arrangement.populate(items); - } -}); -BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; -BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; -BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** - * 月份下拉框 - * - * 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: 25 - }); - }, - _init: function () { - BI.MonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.month_trigger" - }); - - 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 - }); - 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", - 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 () { - 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 = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; - 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 + 1 - }; - }); - }); - - 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 - }] - }); - - 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) { - 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, - triggerWidth: 25, - errorText: BI.i18nText("BI-Month_Trigger_Error_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-month-trigger bi-border", - height: 25 - }); - }, - _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: c.errorText - }); - 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: c.triggerWidth - }, - width: c.triggerWidth - }, { - el: { - type: "bi.trigger_icon_button", - width: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - 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);/** - * 普通控件 - * - * @class BI.MultiDateCard - * @extends BI.Widget - * @abstract - */ -BI.MultiDateCard = BI.inherit(BI.Widget, { - - constants: { - lgap: 80, - itemHeight: 35, - defaultEditorValue: "1" - }, - - _defaultConfig: function () { - return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this, arguments), {}); - }, - - dateConfig: function () { - - }, - - defaultSelectedItem: function () { - - }, - - _init: function () { - BI.MultiDateCard.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.label = BI.createWidget({ - type: 'bi.label', - height: this.constants.itemHeight, - textAlign: "left", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - cls: 'bi-multidate-inner-label bi-tips' - }); - this.radioGroup = BI.createWidget({ - type: "bi.button_group", - chooseType: 0, - items: BI.createItems(this.dateConfig(), { - type: 'bi.multidate_segment', - height: this.constants.itemHeight - }), - layouts: [{ - type: "bi.vertical" - }] - }); - - this.radioGroup.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CONFIRM) { - self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); - } - }); - this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE, function () { - self.setValue(self.getValue()); - self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); - }); - BI.createWidget({ - element: this, - type: 'bi.center_adapt', - lgap: this.constants.lgap, - items: [{ - type: 'bi.vertical', - items: [this.label, this.radioGroup] - }] - }); - }, - - getValue: function () { - var button = this.radioGroup.getSelectedButtons()[0]; - var type = button.getValue(), value = button.getInputValue(); - return { - type: type, - value: value - } - }, - - _isTypeAvaliable: function (type) { - var res = false; - BI.find(this.dateConfig(), function (i, item) { - if (item.value === type) { - res = true; - return true; - } - }); - return res; - }, - - setValue: function (v) { - var self = this; - if (BI.isNotNull(v) && this._isTypeAvaliable(v.type)) { - this.radioGroup.setValue(v.type); - BI.each(this.radioGroup.getAllButtons(), function (i, button) { - if (button.isEditorExist() === true && button.isSelected()) { - button.setInputValue(v.value); - } else { - button.setInputValue(self.constants.defaultEditorValue); - } - }); - } else { - this.radioGroup.setValue(this.defaultSelectedItem()); - BI.each(this.radioGroup.getAllButtons(), function (i, button) { - button.setInputValue(self.constants.defaultEditorValue); - }); - } - }, - - getCalculationValue: function () { - var valueObject = this.getValue(); - var type = valueObject.type, value = valueObject.value; - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - return new Date().getOffsetDate(-1 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - return new Date().getOffsetDate(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - return new Date(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - return new Date().getBeforeMultiMonth(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - return new Date().getAfterMultiMonth(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - return new Date(new Date().getFullYear(), new Date().getMonth(), 1); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - return new Date(new Date().getFullYear(), new Date().getMonth(), (new Date().getLastDateOfMonth()).getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - return new Date().getBeforeMulQuarter(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - return new Date().getAfterMulQuarter(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - return new Date().getQuarterStartDate(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - return new Date().getQuarterEndDate(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - return new Date().getOffsetDate(-7 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - return new Date().getOffsetDate(7 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - return new Date((new Date().getFullYear() - 1 * value), new Date().getMonth(), new Date().getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - return new Date((new Date().getFullYear() + 1 * value), new Date().getMonth(), new Date().getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - return new Date(new Date().getFullYear(), 0, 1); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - return new Date(new Date().getFullYear(), 11, 31); - } - } -}); -BI.MultiDateCard.EVENT_CHANGE = "EVENT_CHANGE"; -/** - * 日期控件 - * @class BI.MultiDateCombo - * @extends BI.Widget - */ -BI.MultiDateCombo = 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" - }, - _defaultConfig: function () { - return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-combo bi-border', - height: 24 - }); - }, - _init: function () { - BI.MultiDateCombo.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.storeTriggerValue = ""; - var date = new Date(); - this.storeValue = null; - this.trigger = BI.createWidget({ - type: 'bi.date_trigger', - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE - }); - this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - }); - this.trigger.on(BI.DateTrigger.EVENT_STOP, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { - self.combo.toggle(); - }); - this.trigger.on(BI.DateTrigger.EVENT_FOCUS, function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.MultiDateCombo.EVENT_FOCUS); - }); - this.trigger.on(BI.DateTrigger.EVENT_ERROR, function () { - self.storeValue = { - year: date.getFullYear(), - month: date.getMonth() - }; - self.popup.setValue(); - self.fireEvent(BI.MultiDateCombo.EVENT_ERROR); - }); - this.trigger.on(BI.DateTrigger.EVENT_VALID, function () { - self.fireEvent(BI.MultiDateCombo.EVENT_VALID); - }); - this.trigger.on(BI.DateTrigger.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); - }); - this.trigger.on(BI.DateTrigger.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()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup = BI.createWidget({ - type: "bi.multidate_popup", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE - }); - this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE, function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE, function () { - var date = new Date(); - self.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - //self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ - type: 'bi.combo', - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: this.popup, - maxHeight: this.constants.popupHeight, - width: this.constants.popupWidth, - stopPropagation: false - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW); - }); - - var triggerBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: 30, - height: 23 - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.changeIcon = BI.createWidget({ - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 30, - height: 23 - }); - - - var leftPart = BI.createWidget({ - type: "bi.absolute", - items: [{ - el: this.combo, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: triggerBtn, - top: 0, - left: 0 - }] - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [leftPart, { - el: this.changeIcon, - width: 30 - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } - }) - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type - } - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[1].width = 30; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[1].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.popup.setValue(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.shortcut('bi.multidate_combo', BI.MultiDateCombo); - -BI.MultiDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.MultiDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; -BI.MultiDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiDateCombo.EVENT_VALID = "EVENT_VALID"; -BI.MultiDateCombo.EVENT_ERROR = "EVENT_ERROR"; -BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW"; - -BI.extend(BI.MultiDateCombo, { - MULTI_DATE_YMD_CARD: 1, - MULTI_DATE_YEAR_CARD: 2, - MULTI_DATE_QUARTER_CARD: 3, - MULTI_DATE_MONTH_CARD: 4, - MULTI_DATE_WEEK_CARD: 5, - MULTI_DATE_DAY_CARD: 6 -}); - -BI.extend(BI.MultiDateCombo, { - DATE_TYPE: { - MULTI_DATE_YEAR_PREV: 1, - MULTI_DATE_YEAR_AFTER: 2, - MULTI_DATE_YEAR_BEGIN: 3, - MULTI_DATE_YEAR_END: 4, - MULTI_DATE_MONTH_PREV: 5, - MULTI_DATE_MONTH_AFTER: 6, - MULTI_DATE_MONTH_BEGIN: 7, - MULTI_DATE_MONTH_END: 8, - MULTI_DATE_QUARTER_PREV: 9, - MULTI_DATE_QUARTER_AFTER: 10, - MULTI_DATE_QUARTER_BEGIN: 11, - MULTI_DATE_QUARTER_END: 12, - MULTI_DATE_WEEK_PREV: 13, - MULTI_DATE_WEEK_AFTER: 14, - MULTI_DATE_DAY_PREV: 15, - MULTI_DATE_DAY_AFTER: 16, - MULTI_DATE_DAY_TODAY: 17, - MULTI_DATE_PARAM: 18, - MULTI_DATE_CALENDAR: 19, - YEAR_QUARTER: 20, - YEAR_MONTH: 21, - YEAR_WEEK: 22, - YEAR_DAY: 23, - MONTH_WEEK: 24, - MONTH_DAY: 25, - YEAR: 26, - SAME_PERIOD: 27, - LAST_SAME_PERIOD: 28 - } -}); -/** - * 普通控件 - * - * @class BI.DayCard - * @extends BI.MultiDateCard - */ -BI.DayCard = BI.inherit(BI.MultiDateCard, { - - _defaultConfig: function () { - return $.extend(BI.DayCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-daycard' - }); - }, - - _init: function () { - BI.DayCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - isEditorExist: true, - selected: true, - text: BI.i18nText("BI-Multi_Date_Day_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Day_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY, - text: BI.i18nText("BI-Multi_Date_Today") - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV - } -}); -BI.DayCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.daycard', BI.DayCard); -/** - * 普通控件 - * - * @class BI.MonthCard - * @extends BI.MultiDateCard - */ -BI.MonthCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-monthcard' - }); - }, - - _init: function () { - BI.MonthCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV, - text: BI.i18nText("BI-Multi_Date_Month_Prev") - }, - { - isEditorExist: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER, - text: BI.i18nText("BI-Multi_Date_Month_Next") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Month_Begin") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Month_End") - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV; - } -}); -BI.MonthCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.monthcard', BI.MonthCard); -/** - * 日期控件 - * @class BI.MultiDatePopup - * @extends BI.Widget - */ -BI.MultiDatePopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - tabWidth: 42, - titleHeight: 27, - itemHeight: 30, - triggerHeight: 24, - buttonWidth: 90, - buttonHeight: 25, - cardHeight: 229, - cardWidth: 270, - popupHeight: 259, - popupWidth: 270, - comboAdjustHeight: 1, - ymdWidth: 58, - lgap: 2, - border: 1 - }, - _defaultConfig: function () { - return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-popup', - width: 268, - height: 260 - }); - }, - _init: function () { - BI.MultiDatePopup.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.storeValue = ""; - this.textButton = BI.createWidget({ - type: 'bi.text_button', - forceCenter: true, - cls: 'bi-multidate-popup-label bi-border-left bi-border-right bi-border-top', - shadow: true, - text: BI.i18nText("BI-Multi_Date_Today") - }); - this.textButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE); - }); - this.clearButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: 'bi-multidate-popup-button bi-border-top', - shadow: true, - text: BI.i18nText("BI-Basic_Clear") - }); - this.clearButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE); - }); - this.okButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: 'bi-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.MultiDatePopup.BUTTON_OK_EVENT_CHANGE); - }); - this.dateTab = BI.createWidget({ - type: 'bi.tab', - tab: { - cls: "bi-multidate-popup-tab bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.MultiDateCombo.MULTI_DATE_YMD_CARD, - width: this.constants.ymdWidth - }, { - text: BI.i18nText("BI-Multi_Date_Year"), - value: BI.MultiDateCombo.MULTI_DATE_YEAR_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Quarter"), - value: BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Month"), - value: BI.MultiDateCombo.MULTI_DATE_MONTH_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Week"), - value: BI.MultiDateCombo.MULTI_DATE_WEEK_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Day"), - value: BI.MultiDateCombo.MULTI_DATE_DAY_CARD - }], { - width: this.constants.tabWidth, - textAlign: "center", - height: this.constants.itemHeight, - cls: 'bi-multidate-popup-item bi-list-item-active' - }), - layouts: [{ - type: 'bi.left' - }] - }, - cardCreator: function (v) { - switch (v) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - self.ymd = BI.createWidget({ - type: "bi.date_calendar_popup", - min: self.options.min, - max: self.options.max - }); - self.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE); - }); - return self.ymd; - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - self.year = BI.createWidget({ - type: "bi.yearcard" - }); - self.year.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.year, v); - }); - return self.year; - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - self.quarter = BI.createWidget({ - type: 'bi.quartercard' - }); - self.quarter.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.quarter, v); - }); - return self.quarter; - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - self.month = BI.createWidget({ - type: 'bi.monthcard' - }); - self.month.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.month, v); - }); - return self.month; - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - self.week = BI.createWidget({ - type: 'bi.weekcard' - }); - self.week.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.week, v); - }); - return self.week; - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - self.day = BI.createWidget({ - type: 'bi.daycard' - }); - self.day.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.day, v); - }); - return self.day; - } - } - }); - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_YMD_CARD; - this.dateTab.on(BI.Tab.EVENT_CHANGE, function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - var date = this.getTab(self.cur).getCalculationValue(); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - self._setInnerValue(self.ymd); - break; - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - self.year.setValue(self.storeValue); - self._setInnerValue(self.year); - break; - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - self.quarter.setValue(self.storeValue); - self._setInnerValue(self.quarter); - break; - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - self.month.setValue(self.storeValue); - self._setInnerValue(self.month); - break; - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - self.week.setValue(self.storeValue); - self._setInnerValue(self.week); - break; - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - self.day.setValue(self.storeValue); - self._setInnerValue(self.day); - break; - } - self.cur = v; - }); - this.dateButton = BI.createWidget({ - type: "bi.grid", - items: [[this.clearButton, this.textButton, this.okButton]] - }); - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this.dateTab - }, { - el: this.dateButton, - height: 30 - }] - }); - }, - _setInnerValue: function (obj) { - if (this.dateTab.getSelect() === BI.MultiDateCombo.MULTI_DATE_YMD_CARD) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); - } else { - var date = obj.getCalculationValue(); - date = date.print("%Y-%x-%e"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - setValue: function (v) { - this.storeValue = v; - var self = this, date; - var type, value; - if (BI.isNotNull(v)) { - type = v.type || BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR; - value = v.value; - if (BI.isNull(value)) { - value = v; - } - } - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD); - this.year.setValue({type: type, value: value}); - this.cur = BI.MultiDateCombo.MULTI_DATE_YEAR_CARD; - self._setInnerValue(this.year); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD; - this.quarter.setValue({type: type, value: value}); - self._setInnerValue(this.quarter); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_MONTH_CARD; - this.month.setValue({type: type, value: value}); - self._setInnerValue(this.month); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_WEEK_CARD; - this.week.setValue({type: type, value: value}); - self._setInnerValue(this.week); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_DAY_CARD; - this.day.setValue({type: type, value: value}); - self._setInnerValue(this.day); - break; - default: - if (BI.isNull(value) || BI.isEmptyObject(value)) { - var date = new Date(); - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } else { - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.ymd.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } - this.textButton.setEnable(true); - break; - } - }, - getValue: function () { - var tab = this.dateTab.getSelect(); - switch (tab) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - return this.ymd.getValue(); - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - return this.year.getValue(); - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - return this.quarter.getValue(); - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - return this.month.getValue(); - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - return this.week.getValue(); - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - return this.day.getValue(); - } - } -}); -BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.MultiDatePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; -BI.shortcut('bi.multidate_popup', BI.MultiDatePopup); -/** - * 普通控件 - * - * @class BI.QuarterCard - * @extends BI.MultiDateCard - */ -BI.QuarterCard = BI.inherit(BI.MultiDateCard, { - - _defaultConfig: function () { - return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-quartercard' - }); - }, - - _init: function () { - BI.QuarterCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Quarter_Prev") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Quarter_Next") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Quarter_Begin") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Quarter_End") - }] - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV; - } -}); -BI.QuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.quartercard', BI.QuarterCard); -/** - * 普通控件 - * - * @class BI.MultiDateSegment - * @extends BI.Single - */ -BI.MultiDateSegment = BI.inherit(BI.Single, { - constants: { - itemHeight: 24, - maxGap: 15, - minGap: 10, - textWidth: 30, - defaultEditorValue: "1" - }, - - _defaultConfig: function () { - return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-segment', - text: "", - width: 130, - height: 30, - isEditorExist: true, - selected: false, - defaultEditorValue: "1" - }); - }, - - _init: function () { - BI.MultiDateSegment.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.radio = BI.createWidget({ - type: "bi.radio", - selected: opts.selected - }); - this.radio.on(BI.Controller.EVENT_CHANGE, function (v) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textEditor = BI.createWidget({ - type: 'bi.text_editor', - value: this.constants.defaultEditorValue, - title: function () { - return self.textEditor.getValue(); - }, - tipType: "success", - cls: 'bi-multidate-editor', - width: this.constants.textWidth, - height: this.constants.itemHeight - }); - this.textEditor.on(BI.Controller.EVENT_CHANGE, function (v) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - cls: 'bi-multidate-normal-label', - text: opts.text, - height: this.constants.itemHeight - }); - this._createSegment(); - }, - _createSegment: function () { - if (this.options.isEditorExist === true) { - return BI.createWidget({ - element: this, - type: 'bi.left', - items: [{ - el: { - type: "bi.center_adapt", - items: [this.radio], - height: this.constants.itemHeight - }, - lgap: 0 - }, - { - el: { - type: "bi.center_adapt", - items: [this.textEditor], - widgetName: 'textEditor' - }, - lgap: this.constants.maxGap - }, - { - el: this.text, - lgap: this.constants.minGap - }] - }); - } - return BI.createWidget({ - element: this, - type: 'bi.left', - items: [{ - el: { - type: "bi.center_adapt", - items: [this.radio], - height: this.constants.itemHeight - }, - lgap: 0 - }, - { - el: this.text, - lgap: this.constants.maxGap - }] - }) - }, - setSelected: function (v) { - if (BI.isNotNull(this.radio)) { - this.radio.setSelected(v); - this.textEditor.setEnable(v); - } - }, - isSelected: function () { - return this.radio.isSelected(); - }, - getValue: function () { - return this.options.value; - }, - getInputValue: function () { - return this.textEditor.getValue() | 0; - }, - setInputValue: function (v) { - this.textEditor.setValue(v); - }, - isEditorExist: function () { - return this.options.isEditorExist; - } -}); -BI.MultiDateSegment.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multidate_segment', BI.MultiDateSegment);/** - * 普通控件 - * - * @class BI.WeekCard - * @extends BI.MultiDateCard - */ -BI.WeekCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-weekcard' - }); - }, - - _init: function () { - BI.WeekCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Week_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Week_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV; - } -}); -BI.WeekCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.weekcard', BI.WeekCard); -/** - * 普通控件 - * - * @class BI.YearCard - * @extends BI.MultiDateCard - */ -BI.YearCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.YearCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-yearcard' - }); - }, - - _init: function () { - BI.YearCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Year_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Year_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN, - text: BI.i18nText("BI-Multi_Date_Year_Begin") - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END, - text: BI.i18nText("BI-Multi_Date_Year_End") - }] - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV; - } -}); -BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.yearcard', BI.YearCard); -/** - * @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: 30, - text: "", - items: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_select_tree_popup", - isDefaultInit: o.isDefaultInit, - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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 - }) - }, - - _init: function () { - BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_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", - element: this, - 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, - - 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); - } - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - 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.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: [] - }); - }, - - _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, - itemsCreator: o.itemsCreator - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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/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: 30, - text: "", - itemsCreator: BI.emptyFn, - items: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_single_tree_popup", - isDefaultInit: o.isDefaultInit, - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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 - }) - }, - - _init: function () { - BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_single_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_single_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_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", - element: this, - expander: { - isDefaultInit: o.isDefaultInit, - el: {}, - popup: { - type: "bi.custom_tree" - } - }, - - items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (items) { - callback(BI.Tree.transformToTreeFormat(items), 0) - }) - }, - - el: { - type: "bi.button_tree", - chooseType: BI.Selection.Single, - 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); - } - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - 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.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 - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - 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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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 - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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 - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** - * - * 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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25, - lgap: 10, - tgap: 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 = {}; - 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.left', - cls: 'multi-select-continue-select', - items: [ - { - el: { - type: "bi.label", - text: BI.i18nText('BI-Selected_Data') - }, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }, - { - el: this.continueSelect, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }] - } - }, { - height: 'fill', - el: this.display - }] - }); - }, - - 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: 25, - 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 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: 28 - }); - }, - - _init: function () { - BI.MultiSelectCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = {}; - //标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - // adapter: this.popup, - masker: { - offset: { - left: 1, - top: 1, - right: 2, - bottom: 33 - } - }, - 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); - }); - } - }); - - 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 () { - //如果在不选的状态下直接把该值添加进来 - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - 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, - 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(); - }); - } - }, - 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 bi-border-left" - }); - 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.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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.pluck(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.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); - 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.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: 0, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** - * 多选加载数据面板 - * 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.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) && !self.storeValue.value.contains(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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - 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.MultiSelectLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - height: 25, - selected: this.isAllSelected() - }) - }, - - _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) { - 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.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** - * 带加载的多选下拉面板 - * @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 - }); - - 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 - }); - - 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.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, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - popup: {}, - adapter: o.adapter, - masker: o.masker - }); - 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 - }); - 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: 30 - }] - }); - - 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.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { - 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);/** - * 多选加载数据搜索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.button_group = BI.createWidget({ - type: "bi.select_list", - element: this, - logic: { - dynamic: false - }, - 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: 25, - selected: this.isAllSelected() - }) - }, - - 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.matched.concat(search.finded); - } - 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: 25, - 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()); - }]); - } - }); - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-select-check-selected-button bi-high-light', - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); - var self = this; - this.numberCounter = BI.createWidget({ - type: 'bi.text_button', - element: this, - hgap: 4, - text: "0", - textAlign: 'center', - textHeight: 15 - }); - 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(self._const.checkSelected); - }, function () { - self.numberCounter.setText(self.numberCounter.getTag()); - }); - this.setVisible(false); - }, - - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _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 - }); - - 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); - }, - - getValue: function () { - var v = this.editor.getState(); - if (BI.isArray(v) && v.length > 0) { - return v[v.length - 1]; - } else { - 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.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: {} - }); - }, - - _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 - }); - - 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) { - op.keyword = self.editor.getValue(); - this.setKeyword(op.keyword); - o.itemsCreator(op, callback); - } - }, 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); - }); - }, - - 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 (BI.size(ob.assist) === 1) { - this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); - } - } else { - if (BI.size(ob.value) === 1) { - this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); - } - } - }, - - 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 - }); - 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(); - } - }, 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.MultiSelectList = BI.inherit(BI.Widget, { - _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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](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.keyword = self.trigger.getKeyword(); - this.setKeyword(op.keyword); - 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 () { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword) - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }) - } else { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword) - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self.adapter.populate(); - if (self.storeValue.type === BI.Selection.Multi) { - 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: 30 - }, { - 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.MultiSelectList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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, - keyword: self.trigger.getKeyword() - }, function (ob) { - var items = BI.pluck(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: 0, - 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.Widget, { - _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: 30 - }, { - 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); - }, - - 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); - } - }); - - 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: 1, - left: 1, - right: 2, - bottom: 33 - } - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, - height: 25 - }); - }, - - _init: function () { - BI.MultiTreeCombo.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - var isInit = false; - var want2showCounter = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - // adapter: this.popup, - masker: { - offset: this.constants.offset - }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } - } - - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - 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() ? {1: 1} : {} - }; - 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(); - }); - } - }, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.storeValue = {value: {}}; - 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 val = { - type: BI.Selection.Multi, - value: this.getSearcher().hasChecked() ? {1: 1} : {} - }; - this.getSearcher().setState(val); - 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 bi-border-left" - }); - 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 - }); - - 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); - } - }); - - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _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', - width: 15, - height: 15, - stopPropagation: true - }); - - this.checkSelected = BI.createWidget({ - type: 'bi.text_button', - cls: "trigger-check-selected", - invisible: true, - hgap: 4, - text: this._const.checkSelected, - 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, - 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); - } - }, 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); - }); - }, - - 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) { - ob || (ob = {}); - ob.value || (ob.value = []); - if (ob.type === BI.Selection.All) { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); - } - }, - - 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", - validationChecker: function () { - return true; - }, - valueFormatter: function (v) { - return v; - }, - value: 0, - 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, - value: o.valueFormatter(o.value), - validationChecker: o.validationChecker, - errorText: o.errorText - }); - this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { - o.value = this.getValue(); - self.fireEvent(BI.NumberEditor.EVENT_CHANGE); - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" - }); - 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,", - cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" - }); - 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", - 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 - }] - }); - }, - - //微调 - _finetuning: function (add) { - var v = BI.parseFloat(this.getValue()); - this.setValue(v.add(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: 30, - rows: 1, - numberErrorCls: "number-error", - border: 1, - less: 0, - less_equal: 1, - numTip: "" - }, - _defaultConfig: function () { - var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments) - return BI.extend(conf, { - extraCls: "bi-number-interval", - height: 25, - validation: "valid" - }) - }, - _init: function () { - var self = this, c = this.constants, o = this.options; - BI.NumberInterval.superclass._init.apply(this, arguments) - this.smallEditor = BI.createWidget({ - type: "bi.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.min, - level: "warning", - tipType: "warning", - 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-top bi-border-bottom bi-border-left" - }); - - 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.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.max, - level: "warning", - tipType: "warning", - 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-top bi-border-bottom bi-border-right" - }); - - 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", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconClass: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconClass: "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", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconClass: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconClass: "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 * 2 - }] - - }); - this.right = BI.createWidget({ - type: "bi.htape", - items: [{ - el: self.bigCombo, - width: c.width - c.border * 2 - }, { - el: self.bigEditor - }] - }); - - - 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); - }, - - _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; - } else { - if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - } else { - 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; - } else { - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - } - } else { - 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; - } else { - 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: "center" - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "center" - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - 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: "center" - }); - 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: "center" - }); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - 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: "center" - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "center" - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - break; - default : - break; - } - self.fireEvent(BI.NumberInterval.EVENT_CHANGE); - }); - }, - - _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_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); - } - }, - - - 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; - } -}); -BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; -BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.shortcut("bi.number_interval", BI.NumberInterval);/** - * - * 表格 - * - * Created by GUY on 2015/9/22. - * @class BI.PageTableCell - * @extends BI.Single - */ -BI.PageTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table-cell", - text: "", - title: "" - }) - }, - - _init: function () { - BI.PageTableCell.superclass._init.apply(this, arguments); - var label = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "nowrap", - height: this.options.height, - text: this.options.text, - title: this.options.title, - value: this.options.value, - lgap: 5, - rgap: 5 - }); - - if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { - this.element.css(this.options.styles); - } - } -}); - -BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** - * 分页表格 - * - * Created by GUY on 2016/2/15. - * @class BI.PageTable - * @extends BI.Widget - */ -BI.PageTable = BI.inherit(BI.Widget, { - - _const: { - scrollWidth: 18, - minScrollWidth: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table", - el: { - type: "bi.sequence_table" - }, - pager: { - 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 - } - }, - - itemsCreator: BI.emptyFn, - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.PageTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.hCurr = 1; - this.vCurr = 1; - - this.table = BI.createWidget(o.el, { - type: "bi.sequence_table", - width: o.width, - height: o.height && o.height - 30, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.pager = BI.createWidget(o.pager, { - type: "bi.direction_pager", - height: 30 - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - var vpage = this.getVPage && this.getVPage(); - if (BI.isNull(vpage)) { - vpage = this.getCurrentPage(); - } - var hpage = this.getHPage && this.getHPage(); - o.itemsCreator({ - vpage: vpage, - hpage: hpage - }, function (items, header, crossItems, crossHeader) { - self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); - self.table.setHPage && self.table.setHPage(hpage); - self.populate.apply(self, arguments); - }); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.table, - left: 0, - top: 0 - }, { - el: this.pager, - left: 0, - right: 0, - bottom: 0 - }] - }) - }, - - setHPage: function (v) { - this.hCurr = v; - this.pager.setHPage && this.pager.setHPage(v); - this.table.setHPage && this.table.setHPage(v); - }, - - setVPage: function (v) { - this.vCurr = v; - this.pager.setVPage && this.pager.setVPage(v); - this.table.setVPage && this.table.setVPage(v); - }, - - getHPage: function () { - var hpage = this.pager.getHPage && this.pager.getHPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - return this.hpage; - }, - - getVPage: function () { - var vpage = this.pager.getVPage && this.pager.getVPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - return this.vpage; - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - var showPager = false; - if (this.pager.alwaysShowPager) { - showPager = true; - } else if (this.pager.hasHNext && this.pager.hasHNext()) { - showPager = true; - } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { - showPager = true; - } else if (this.pager.hasVNext && this.pager.hasVNext()) { - showPager = true; - } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { - showPager = true; - } else if (this.pager.hasNext && this.pager.hasNext()) { - showPager = true; - } else if (this.pager.hasPrev && this.pager.hasPrev()) { - showPager = true; - } - this.table.setHeight(height - (showPager ? 30 : 0)); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - restore: function () { - this.table.restore(); - }, - - attr: function () { - BI.PageTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function () { - this.pager.populate(); - this.table.populate.apply(this.table, arguments); - }, - - destroy: function () { - this.table.destroy(); - this.pager && this.pager.destroy(); - BI.PageTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.page_table', BI.PageTable);/** - * 路径选择 - * - * Created by GUY on 2015/12/4. - * @class BI.PathChooser - * @extends BI.Widget - */ -BI.PathChooser = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#d4dadd", - selectLineColor: "#3f8ce8" - }, - - _defaultConfig: function () { - return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-path-chooser", - items: [] - }) - }, - - _init: function () { - BI.PathChooser.superclass._init.apply(this, arguments); - this.populate(this.options.items); - }, - - _createRegions: function (regions) { - var self = this; - this.regions = BI.createWidgets(BI.map(regions, function (i, region) { - return { - type: "bi.path_region", - title: self.texts[region] || region - } - })); - this.regionMap = {}; - BI.each(regions, function (i, region) { - self.regionMap[region] = i; - }); - this.container = BI.createWidget({ - type: "bi.horizontal", - verticalAlign: "top", - scrollx: false, - scrolly: false, - hgap: 10, - items: this.regions - }); - BI.createWidget({ - type: "bi.vertical_adapt", - element: this, - scrollable: true, - hgap: 10, - items: [this.container] - }); - }, - - getRegionIndexById: function (id) { - var node = this.store[id]; - var regionType = node.get("region"); - return this.regionMap[regionType]; - }, - - _drawPath: function (start, offset, index) { - var self = this; - var starts = []; - if (BI.contains(this.start, start)) { - starts = this.start; - } else { - starts = [start]; - } - - BI.each(starts, function (i, s) { - BI.each(self.radios[s], function (i, rad) { - rad.setSelected(false); - }); - BI.each(self.lines[s], function (i, line) { - line.attr("stroke", self._const.lineColor); - }); - BI.each(self.regionIndexes[s], function (i, idx) { - self.regions[idx].reset(); - }); - }); - - BI.each(this.routes[start][index], function (i, id) { - var regionIndex = self.getRegionIndexById(id); - self.regions[regionIndex].setSelect(offset + index, id); - }); - var current = BI.last(this.routes[start][index]); - - while (current && this.routes[current] && this.routes[current].length === 1) { - BI.each(this.routes[current][0], function (i, id) { - var regionIndex = self.getRegionIndexById(id); - self.regions[regionIndex].setSelect(0, id); - }); - this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); - current = BI.last(this.routes[current][0]); - } - this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); - this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); - }, - - _drawRadio: function (start, offset, index, x, y) { - var self = this; - var radio = BI.createWidget({ - type: "bi.radio", - cls: "path-chooser-radio", - selected: offset + index === 0, - start: start, - index: index - }); - radio.on(BI.Radio.EVENT_CHANGE, function () { - self._drawPath(start, offset, index); - self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); - }); - if (!this.radios[start]) { - this.radios[start] = []; - } - this.radios[start].push(radio); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [{ - el: radio, - left: x - 6.5, - top: y - 6.5 - }] - }) - }, - - _drawLine: function (start, lines) { - var self = this; - if (!this.lines[start]) { - this.lines[start] = []; - } - if (!this.pathes[start]) { - this.pathes[start] = []; - } - var startRegionIndex = this.getRegionIndexById(start); - //start所在的位置,然后接着往下画其他的路径 - var offset = this.regions[startRegionIndex].getIndexByValue(start); - BI.each(lines, function (i, line) { - self.pathes[start][i] = []; - var idx = i + offset; - var path = ""; - var stop = 47.5 + 29 * idx; - var sleft = 50 + 100 * startRegionIndex; - var radioStartX = sleft, radioStartY = stop; - var etop = stop; - var endRegionIndex = self.getRegionIndexById(BI.last(line)); - var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); - var eleft = 50 + 100 * endRegionIndex; - if (BI.contains(self.start, start)) { - radioStartX = sleft - 50; - path += "M" + (sleft - 50) + "," + stop; - self.pathes[start][i].push({ - x: sleft - 50, - y: stop - }) - } else if (idx === 0) { - radioStartX = sleft + 50; - path += "M" + sleft + "," + stop; - self.pathes[start][i].push({ - x: sleft, - y: stop - }) - } else { - radioStartX = sleft + 50; - path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; - self.pathes[start][i].push({ - x: sleft, - y: 47.5 - }); - self.pathes[start][i].push({ - x: sleft + 50, - y: 47.5 - }); - self.pathes[start][i].push({ - x: sleft + 50, - y: stop - }); - } - if (idx > 0) { - var endY = endOffset * 29 + 47.5; - path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; - self.pathes[start][i].push({ - x: eleft - 50, - y: etop - }); - self.pathes[start][i].push({ - x: eleft - 50, - y: endY - }); - self.pathes[start][i].push({ - x: eleft, - y: endY - }); - } else { - path += "L" + eleft + "," + etop; - self.pathes[start][i].push({ - x: eleft, - y: etop - }); - } - - var graph = self.svg.path(path) - .attr({ - stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, - 'stroke-dasharray': '-' - }); - self.lines[start].push(graph); - if (lines.length > 1) { - self.lines[start][0].toFront(); - } - //第一个元素无论有多少个都要显示radio - if (BI.contains(self.start, start)) { - self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); - } - if (lines.length > 1 || BI.contains(self.start, start)) { - self._drawRadio(start, offset, i, radioStartX, radioStartY); - } - }); - }, - - _drawLines: function (routes) { - var self = this; - this.lines = {}; - this.pathes = {}; - this.radios = {}; - this.regionIndexes = {}; - BI.each(routes, function (k, route) { - if (!self.regionIndexes[k]) { - self.regionIndexes[k] = []; - } - BI.each(route, function (i, rs) { - BI.each(rs, function (j, id) { - var regionIndex = self.getRegionIndexById(id); - if (!BI.contains(self.regionIndexes[k], regionIndex)) { - self.regionIndexes[k].push(regionIndex); - } - }); - }) - }); - BI.each(routes, function (k, route) { - self._drawLine(k, route); - }); - }, - - _pushNodes: function (nodes) { - var self = this; - var indexes = []; - for (var i = 0; i < nodes.length; i++) { - var id = nodes[i]; - var index = self.getRegionIndexById(id); - indexes.push(index); - var region = self.regions[index]; - if (i === nodes.length - 1) { - if (!region.hasItem(id)) { - region.addItem(id, self.texts[id]); - } - break; - } - if (i > 0 || BI.contains(self.start, id)) { - region.addItem(id, self.texts[id]); - } - } - for (var i = BI.first(indexes); i < BI.last(indexes); i++) { - if (!BI.contains(indexes, i)) { - self.regions[i].addItem(""); - } - } - }, - - _createNodes: function () { - var self = this, o = this.options; - this.store = {}; - this.texts = {}; - this.start = []; - this.end = []; - BI.each(o.items, function (i, item) { - self.start.push(BI.first(item).value); - self.end.push(BI.last(item).value); - }); - this.start = BI.uniq(this.start); - this.end = BI.uniq(this.end); - var regions = []; - var tree = new BI.Tree(); - var branches = {}, max = 0; - BI.each(o.items, function (i, items) { - BI.each(items, function (j, item) { - if (!BI.has(branches, item.value)) { - branches[item.value] = 0; - } - branches[item.value]++; - max = Math.max(max, branches[item.value]); - var prev = {}; - if (j > 0) { - prev = items[j - 1]; - } - var parent = self.store[prev.value || ""]; - var node = self.store[item.value] || new BI.Node(item.value); - node.set(item); - self.store[item.value] = node; - self.texts[item.value] = item.text; - self.texts[item.region] = item.regionText; - parent = BI.isNull(parent) ? tree.getRoot() : parent; - if (parent.getChildIndex(item.value) === -1) { - tree.addNode(parent, node); - } - }) - }); - - //算出区域列表 - tree.traverse(function (node) { - BI.each(node.getChildren(), function (i, child) { - if (BI.contains(regions, child.get("region"))) { - var index1 = BI.indexOf(regions, node.get("region")); - var index2 = BI.indexOf(regions, child.get("region")); - //交换区域 - if (index1 > index2) { - var t = regions[index2]; - for (var j = index2; j < index1; j++) { - regions[j] = regions[j + 1]; - } - regions[index1] = t; - } - } else { - regions.push(child.get("region")); - } - }); - }); - this._createRegions(regions); - - //算出节点 - BI.each(branches, function (k, branch) { - if (branch < max) { - delete branches[k]; - } - }); - - //过滤节点 - var nodes = []; - var n = tree.getRoot(); - while (n && n.getChildrenLength() === 1) { - if (BI.has(branches, n.getChildren()[0].id)) { - delete branches[n.getChildren()[0].id]; - n = n.getChildren()[0]; - } else { - n = null; - } - } - tree.traverse(function (node) { - if (BI.has(branches, node.id)) { - nodes.push(node.id); - delete branches[node.id]; - } - }); - - //填充节点 - var routes = {}; - var s, e; - for (var i = 0, len = nodes.length; i < len + 1; i++) { - if (len === 0) { - s = []; - BI.each(this.start, function (i, id) { - s.push(tree.search(id)); - }); - e = []; - BI.each(this.end, function (i, id) { - e.push(tree.search(id)); - }); - } else if (i === len) { - s = e; - e = []; - BI.each(this.end, function (i, id) { - e.push(tree.search(id)); - }); - } else if (i === 0) { - s = []; - BI.each(this.start, function (i, id) { - s.push(tree.search(id)); - }); - e = [tree.search(nodes[i])]; - } else { - s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; - e = [tree.search(s[0], nodes[i])]; - } - BI.each(s, function (i, n) { - tree._recursion(n, [n.id], function (node, route) { - if (BI.contains(e, node)) { - if (!routes[n.id]) { - routes[n.id] = []; - } - routes[n.id].push(route); - self._pushNodes(route); - if (e.length <= 1) { - return true; - } - } - }) - }); - } - this.routes = routes; - this._drawLines(routes); - }, - - _unselectAllPath: function () { - var self = this; - BI.each(this.radios, function (idx, rad) { - BI.each(rad, function (i, r) { - r.setSelected(false); - }); - }); - BI.each(this.lines, function (idx, line) { - BI.each(line, function (i, li) { - li.attr("stroke", self._const.lineColor); - }); - }); - BI.each(this.regions, function (idx, region) { - region.reset(); - }); - }, - - populate: function (items) { - this.options.items = items || []; - var self = this; - this.empty(); - if (this.options.items.length <= 0) { - return; - } - this.svg = BI.createWidget({ - type: "bi.svg" - }); - this._createNodes(); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [{ - el: this.svg, - top: 0, - left: 0, - right: 0, - bottom: 0 - }] - }); - }, - - setValue: function (v) { - this._unselectAllPath(); - var nodes = BI.keys(this.routes), self = this; - var result = [], array = []; - BI.each(v, function (i, val) { - if (BI.contains(nodes, val)) { - if (array.length > 0) { - array.push(val); - result.push(array); - array = []; - } - } - array.push(val); - }); - if (array.length > 0) { - result.push(array); - } - //画这n条路径 - BI.each(result, function (idx, path) { - var start = path[0]; - var index = BI.findIndex(self.routes[start], function (idx, p) { - if (BI.isEqual(path, p)) { - return true; - } - }); - if (index >= 0) { - var startRegionIndex = self.getRegionIndexById(start); - var offset = self.regions[startRegionIndex].getIndexByValue(start); - self._drawPath(start, offset, index); - } - }); - }, - - getValue: function () { - var path = []; - BI.each(this.regions, function (i, region) { - var val = region.getValue(); - if (BI.isKey(val)) { - path.push(val); - } - }); - return path; - } -}); -BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; -BI.shortcut("bi.path_chooser", BI.PathChooser);/** - * 路径选择区域 - * - * Created by GUY on 2015/12/4. - * @class BI.PathRegion - * @extends BI.Widget - */ -BI.PathRegion = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-path-region bi-background", - width: 80, - title: "" - }) - }, - - _init: function () { - BI.PathRegion.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.zIndex = 100; - var title = BI.createWidget({ - type: "bi.label", - text: o.title, - title: o.title, - height: 30 - }); - title.element.css("zIndex", this.zIndex--); - this.items = []; - this.vertical = BI.createWidget({ - type: "bi.vertical", - element: this, - bgap: 5, - hgap: 10, - items: [title] - }) - }, - - hasItem: function (val) { - return BI.any(this.items, function (i, item) { - return val === item.getValue(); - }); - }, - - addItem: function (value, text) { - if (BI.isKey(value)) { - var label = BI.createWidget({ - type: "bi.label", - cls: "path-region-label bi-card bi-border bi-list-item-select", - text: text, - value: value, - title: text || value, - height: 24 - }); - } else { - var label = BI.createWidget({ - type: "bi.layout", - height: 24 - }); - } - label.element.css("zIndex", this.zIndex--); - this.items.push(label); - this.vertical.addItem(label); - if (this.items.length === 1) { - this.setSelect(0, value); - } - }, - - reset: function () { - BI.each(this.items, function (i, item) { - item.element.removeClass("active"); - }); - }, - - setSelect: function (index, value) { - this.reset(); - if (this.items.length <= 0) { - return; - } - if (this.items.length === 1) { - this.items[0].element.addClass("active"); - return; - } - if (this.items[index].attr("value") === value) { - this.items[index].element.addClass("active"); - } - }, - - setValue: function (value) { - this.setSelect(this.getIndexByValue(value), value); - }, - - getValueByIndex: function (idx) { - return this.items[idx].attr("value"); - }, - - getIndexByValue: function (value) { - return BI.findIndex(this.items, function (i, item) { - return item.attr("value") === value; - }); - }, - - getValue: function () { - var res; - BI.any(this.items, function (i, item) { - if (item.element.hasClass("active")) { - res = item.getValue(); - return true; - } - }); - return res; - } -}); -BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; -BI.shortcut("bi.path_region", BI.PathRegion);/** - * 预览表列 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableCell - * @extends BI.Widget - */ -BI.PreviewTableCell = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-cell", - text: "" - }); - }, - - _init: function () { - BI.PreviewTableCell.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value - }) - } -}); -BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableHeaderCell - * @extends BI.Widget - */ -BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-header-cell", - text: "" - }); - }, - - _init: function () { - BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value - }) - } -}); -BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTable - * @extends BI.Widget - */ -BI.PreviewTable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table", - isNeedFreeze: false, - freezeCols: [], - rowSize: null, - columnSize: [], - headerRowSize: 30, - header: [], - items: [] - }); - }, - - _init: function () { - BI.PreviewTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - isNeedResize: false, - - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - rowSize: o.rowSize, - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, - - header: BI.map(o.header, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_header_cell" - }, item); - }); - }), - items: BI.map(o.items, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_cell" - }, item); - }); - }) - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self._adjustColumns(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._adjustColumns(); - }); - }, - - //是否有自适应调节的列,即列宽为"" - _hasAdaptCol: function (columnSize) { - return BI.any(columnSize, function (i, size) { - return size === ""; - }) - }, - - _isPercentage: function (columnSize) { - return columnSize[0] <= 1; - }, - - _adjustColumns: function () { - var self = this, o = this.options; - if (o.isNeedFreeze === true) { - //如果存在百分比的情况 - if (this._isPercentage(o.columnSize)) { - if (this._hasAdaptCol(o.columnSize)) { - var findCols = [], remain = 0; - BI.each(o.columnSize, function (i, size) { - if (size === "") { - findCols.push(i); - } else { - remain += size; - } - }); - remain = 1 - remain; - var average = remain / findCols.length; - BI.each(findCols, function (i, col) { - o.columnSize[col] = average; - }); - } - var isRight = BI.first(o.freezeCols) !== 0; - var freezeSize = [], notFreezeSize = []; - BI.each(o.columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - freezeSize.push(size); - } else { - notFreezeSize.push(size); - } - }); - var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); - BI.each(freezeSize, function (i, size) { - freezeSize[i] = size / sumFreezeSize; - }); - BI.each(notFreezeSize, function (i, size) { - notFreezeSize[i] = size / sumNotFreezeSize; - }); - this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); - this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); - } - } else { - //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% - if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { - this.table.setRegionColumnSize(["100%"]); - } - } - }, - - setColumnSize: function (columnSize) { - return this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); - }, - - setHeaderColumnSize: function (columnSize) { - return this.table.setHeaderColumnSize(columnSize); - }, - - setRegionColumnSize: function (columnSize) { - return this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize() - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize() - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - return this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - return this.table.setLeftHorizontalScroll(scrollLeft) - }, - - setRightHorizontalScroll: function (scrollLeft) { - return this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - getColumns: function () { - return this.table.getColumns(); - }, - - populate: function (items, header) { - this.table.populate(items, header); - } -}); -BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; -BI.shortcut('bi.preview_table', BI.PreviewTable);/** - * 季度下拉框 - * - * 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" - }); - - 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 - }); - - 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", - 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 () { - 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: Date._QN[01], - value: 1 - }, { - text: Date._QN[2], - value: 2 - }, { - text: Date._QN[3], - value: 3 - }, { - text: 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" - }] - }); - - 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, - triggerWidth: 30, - textWidth: 40, - errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-quarter-trigger bi-border", - height: 25 - }); - }, - _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: c.errorText - }); - 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: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - - 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);/** - * 关联视图字段Item - * - * Created by GUY on 2015/12/23. - * @class BI.RelationViewItem - * @extends BI.Widget - */ -BI.RelationViewItem = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-item bi-list-item-active", - height: 25, - hoverIn: BI.emptyFn, - hoverOut: BI.emptyFn - }); - }, - - _init: function () { - BI.RelationViewItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.element.hover(o.hoverIn, o.hoverOut); - var items = []; - if (o.isPrimary) { - items.push({ - type: "bi.icon", - width: 16, - height: 16, - title: BI.i18nText("BI-Primary_Key") - }); - } - items.push({ - type: "bi.label", - text: o.text, - value: o.value, - height: o.height, - textAlign: "left", - width: o.isPrimary ? 70 : 90, - lgap: o.isPrimary ? 0 : 10 - }); - BI.createWidget({ - type: "bi.vertical_adapt", - element: this, - items: items, - cls: "primary-key-font", - lgap: 5 - }); - }, - - enableHover: function (opt) { - BI.RelationViewRegion.superclass.enableHover.apply(this, [{ - container: "body" - }]); - }, - - setSelected: function (b) { - this.element[b ? "addClass" : "removeClass"]("active"); - } -}); -BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** - * 关联视图 - * - * Created by GUY on 2015/12/22. - * @class BI.RelationView - * @extends BI.Widget - */ -BI.RelationView = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#c4c6c6", - selectLineColor: "#009de3" - }, - - _defaultConfig: function () { - return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view", - items: [] - }); - }, - - _init: function () { - BI.RelationView.superclass._init.apply(this, arguments); - this.populate(this.options.items); - }, - - _calculateWidths: function () { - var widths = []; - BI.each(this.views, function (i, items) { - BI.each(items, function (j, obj) { - if (!widths[j]) { - widths[j] = BI.MIN; - } - widths[j] = Math.max(widths[j], obj.getWidth()); - }) - }); - return widths; - }, - - _calculateHeights: function () { - var heights = BI.makeArray(BI.size(this.views), BI.MIN); - BI.each(this.views, function (i, items) { - BI.each(items, function (j, obj) { - heights[i] = Math.max(heights[i], obj.getHeight()); - }) - }); - return heights; - }, - - _hoverIn: function (target) { - var self = this, c = this._const; - BI.each(this.relations, function (start, rs) { - BI.each(rs, function (end, relation) { - if (relation[0].primary.value === target || relation[0].foreign.value === target) { - self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); - self.storeViews[start].setValue(relation[0].primary.value); - self.storeViews[end].setValue(relation[0].foreign.value); - } - }); - }); - }, - - _hoverOut: function (target) { - var self = this, c = this._const; - BI.each(this.relations, function (start, rs) { - BI.each(rs, function (end, relation) { - if (relation[0].primary.value === target || relation[0].foreign.value === target) { - self.lines[start][end].attr("stroke", c.lineColor); - self.storeViews[start].setValue([]); - self.storeViews[end].setValue([]); - } - }); - }); - }, - - previewRelationTables: function(relationTables, show) { - if (!show) { - BI.each(this.storeViews, function (i, view) { - view.toggleRegion(true); - view.setPreviewSelected(false); - }); - BI.each(this.lines, function (i, lines) { - BI.each(lines, function (j, line) { - line.show(); - }); - }); - return; - } - BI.each(this.storeViews, function (id, view) { - if (!relationTables.contains(id)) { - view.toggleRegion(false); - } else { - view.setPreviewSelected(true); - } - }); - BI.each(this.lines, function (id, lines) { - BI.each(lines, function (cId, line) { - if (!relationTables.contains(id) || !relationTables.contains(cId)) { - line.hide(); - } - }); - }); - }, - - populate: function (items) { - var self = this, o = this.options, c = this._const; - o.items = items || []; - this.empty(); - this.svg = BI.createWidget({ - type: "bi.svg" - }); - - //算出所有的区域和关联 - var regions = this.regions = {}, relations = this.relations = {}; - BI.each(items, function (i, item) { - var pr = item.primary.region, fr = item.foreign && item.foreign.region; - if (pr && !relations[pr]) { - relations[pr] = {}; - } - if (pr && fr && !relations[pr][fr]) { - relations[pr][fr] = []; - } - if (pr && !regions[pr]) { - regions[pr] = []; - } - if (fr && !regions[fr]) { - regions[fr] = []; - } - if (pr && !BI.deepContains(regions[pr], item.primary)) { - regions[pr].push(item.primary); - } - if (fr && !BI.deepContains(regions[fr], item.foreign)) { - regions[fr].push(item.foreign); - } - pr && fr && relations[pr][fr].push(item); - }); - //求拓扑 - var topology = []; - var rs = BI.clone(regions), store = {}; - while (!BI.isEmpty(rs)) { - var clone = BI.clone(rs); - BI.each(o.items, function (i, item) { - if (!store[item.primary.region]) { - delete clone[item.foreign && item.foreign.region]; - } - }); - topology.push(BI.keys(clone)); - BI.extend(store, clone); - BI.each(clone, function (k, v) { - delete rs[k]; - }); - } - //构建视图 - var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; - var verticals = []; - BI.each(topology, function (i, items) { - if (!views[i]) { - views[i] = {}; - } - var horizontal = []; - BI.each(items, function (j, region) { - var items = regions[region]; - views[i][j] = storeViews[region] = BI.createWidget({ - type: "bi.relation_view_region_container", - value: region, - header: items[0].regionTitle, - text: items.length > 0 ? items[0].regionText : "", - handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, - items: items, - belongPackage: items.length > 0 ? items[0].belongPackage : true - }); - if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { - views[i][j].doRedMark(items[0].keyword); - } - views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { - self._hoverIn(v); - }); - views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { - self._hoverOut(v); - }); - views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { - self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); - }); - indexes[region] = {i: i, j: j}; - horizontal.push(views[i][j]); - }); - verticals.push({ - type: "bi.horizontal", - items: horizontal - }) - }); - - //求每一行的高度 - var heights = this._calculateHeights(); - - //求每一列的宽度 - var widths = this._calculateWidths(); - - //求相对宽度和高度 - var offsetWidths = [0], offsetHeights = [0]; - BI.each(heights, function (i, h) { - if (i === 0) { - return; - } - offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; - }); - BI.each(widths, function (i, w) { - if (i === 0) { - return; - } - offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; - }); - - //画线 - var lines = this.lines = {};//缓存所有的线 - BI.each(relations, function (start, rs) { - BI.each(rs, function (end, relation) { - var startIndex = indexes[start], endIndex = indexes[end]; - var top = 0, right = 1, bottom = 2, left = 3; - var startDirection = bottom, endDirection = top; - // if (startIndex.j > endIndex.j) { - // startDirection = left; - // endDirection = right; - // } else if (startIndex.j < endIndex.j) { - // startDirection = right; - // endDirection = left; - // } else if (startIndex.i < endIndex.i) { - // startDirection = bottom; - // endDirection = top; - // } else if (startIndex.i > endIndex.i) { - // startDirection = top; - // endDirection = bottom; - // } - var draw = function (i, j, direction, isForeign) { - var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; - var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; - var path = "", position; - switch (direction) { - case top: - position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + x + "," + (y - 10); - y -= 10; - break; - case right: - position = views[i][j].getRightPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + (x + 10) + "," + y; - x += 10; - break; - case bottom: - position = views[i][j].getBottomPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + x + "," + (y + 10); - y += 10; - break; - case left: - position = views[i][j].getLeftPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + (x - 10) + "," + y; - x -= 10; - break; - } - return {x: x, y: y, path: path}; - }; - var path = ""; - var si = draw(startIndex.i, startIndex.j, startDirection); - var ei = draw(endIndex.i, endIndex.j, endDirection, true); - path += si.path + ei.path; - if (!lines[start]) { - lines[start] = {}; - } - path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; - var line = lines[start][end] = self.svg.path(path) - .attr({"stroke": c.lineColor, "stroke-width": "2"}) - .hover(function () { - line.attr("stroke", c.selectLineColor).toFront(); - storeViews[start].setValue(relation[0].primary.value); - storeViews[end].setValue(relation[0].foreign.value); - }, function () { - line.attr("stroke", c.lineColor); - storeViews[start].setValue([]); - storeViews[end].setValue([]); - }); - }); - }); - var container = BI.createWidget(); - BI.createWidget({ - type: "bi.vertical", - element: container, - items: verticals - }); - BI.createWidget({ - type: "bi.absolute", - element: container, - items: [{ - el: this.svg, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - - BI.createWidget({ - type: "bi.center_adapt", - scrollable: true, - element: this, - items: [container] - }); - } -}); -BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; -BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; -BI.shortcut('bi.relation_view', BI.RelationView);/** - * Created by Young's on 2017/3/10. - */ -BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-region-container", - width: 150 - }); - }, - - _init: function () { - BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.region = BI.createWidget({ - type: "bi.relation_view_region", - value: o.value, - header: o.header, - text: o.text, - handler: o.handler, - items: o.items, - belongPackage: o.belongPackage - }); - this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); - }); - this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); - }); - this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); - }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.region], - width: this.region.getWidth(), - height: this.region.getHeight() - }); - }, - - doRedMark: function () { - this.region.doRedMark.apply(this.region, arguments); - }, - - unRedMark: function () { - this.region.unRedMark.apply(this.region, arguments); - }, - - getWidth: function () { - return this.region.getWidth(); - }, - - getHeight: function () { - return this.region.getHeight(); - }, - - //获取上方开始划线的位置 - getTopLeftPosition: function () { - return this.region.getTopLeftPosition(); - }, - - getTopRightPosition: function () { - return this.region.getTopRightPosition(); - }, - - getBottomPosition: function () { - return this.region.getBottomPosition(); - }, - - getLeftPosition: function () { - return this.region.getLeftPosition(); - }, - - getRightPosition: function () { - return this.region.getRightPosition(); - }, - - setValue: function (v) { - this.region.setValue(v); - }, - - toggleRegion: function (v) { - v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); - }, - - setPreviewSelected: function(v) { - this.region.setPreviewSelected(v); - } -}); -BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; -BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; -BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; -BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** - * 关联视图 - * - * Created by GUY on 2015/12/23. - * @class BI.RelationViewRegion - * @extends BI.BasicButton - */ -BI.RelationViewRegion = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-region cursor-pointer", - width: 150, - text: "", - value: "", - header: "", - items: [], - belongPackage: true - }); - }, - - _init: function () { - BI.RelationViewRegion.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.preview = BI.createWidget({ - type: "bi.icon_button", - cls: "relation-table-preview-font", - width: 25, - height: 25, - stopPropagation: true - }); - this.preview.on(BI.IconButton.EVENT_CHANGE, function () { - self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); - }); - - this.title = BI.createWidget({ - type: "bi.label", - height: 25, - width: 70, - text: o.text, - value: o.value, - textAlign: "left" - }); - //title放body上 - if (BI.isKey(o.header)) { - this.title.setTitle(o.header, { - container: "body" - }) - } - - this.button_group = BI.createWidget({ - type: "bi.button_group", - items: this._createItems(o.items), - layouts: [{ - type: "bi.vertical" - }] - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [{ - type: "bi.vertical", - cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), - items: [{ - type: "bi.vertical_adapt", - cls: "relation-view-region-title bi-border-bottom", - items: [this.preview, this.title] - }, this.button_group] - }], - hgap: 25, - vgap: 20 - }) - }, - - _createItems: function (items) { - var self = this; - return BI.map(items, function (i, item) { - return BI.extend(item, { - type: "bi.relation_view_item", - hoverIn: function () { - self.setValue(item.value); - self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); - }, - hoverOut: function () { - self.setValue([]); - self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); - } - }) - }); - }, - - doRedMark: function () { - this.title.doRedMark.apply(this.title, arguments); - }, - - unRedMark: function () { - this.title.unRedMark.apply(this.title, arguments); - }, - - getWidth: function () { - return this.options.width; - }, - - getHeight: function () { - return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; - }, - - //获取上方开始划线的位置 - getTopLeftPosition: function () { - return { - x: 25 + 10, - y: 20 - } - }, - - getTopRightPosition: function () { - return { - x: this.getWidth() - 25 - 10, - y: 20 - } - }, - - getBottomPosition: function () { - return { - x: 25 + 10, - y: this.getHeight() - 20 - } - }, - - getLeftPosition: function () { - return { - x: 25, - y: 20 + 10 - } - }, - - getRightPosition: function () { - return { - x: this.getWidth() - 25, - y: 20 + 10 - } - }, - - setValue: function (v) { - this.button_group.setValue(v); - }, - - setPreviewSelected: function(v) { - this.preview.setSelected(v); - } -}); -BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; -BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; -BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; -BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** - * 自适应宽度的表格 - * - * Created by GUY on 2016/2/3. - * @class BI.ResponisveTable - * @extends BI.Widget - */ -BI.ResponisveTable = BI.inherit(BI.Widget, { - - _const: { - perColumnSize: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-responsive-table", - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, - - columnSize: [], - headerRowSize: 25, - footerRowSize: 25, - rowSize: 25, - - regionColumnSize: false, - - header: [], - footer: false, - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.ResponisveTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - header: o.header, - footer: o.footer, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - //important:在冻结并自适应列宽的情况下要随时变更表头宽度 - if (o.isNeedResize === true && self._isAdaptiveColumn()) { - self._resizeHeader(); - } - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self._resizeBody(); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _initRegionSize: function () { - var o = this.options; - if (o.isNeedFreeze === true) { - var regionColumnSize = this.table.getRegionColumnSize(); - var maxWidth = this.table.element.width(); - if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { - var freezeCols = o.freezeCols; - if (freezeCols.length === 0) { - this.table.setRegionColumnSize([0, "fill"]); - } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } else { - this.table.setRegionColumnSize(["fill", 0]); - } - } - } - }, - - _getBlockSize: function () { - var o = this.options; - var columnSize = this.table.getCalculateColumnSize(); - if (o.isNeedFreeze === true) { - var columnSizeLeft = [], columnSizeRight = []; - BI.each(columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - columnSizeLeft.push(size); - } else { - columnSizeRight.push(size); - } - }); - //因为有边框,所以加上数组长度的参数调整 - var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, - sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; - return { - sumLeft: sumLeft, - sumRight: sumRight, - left: columnSizeLeft, - right: columnSizeRight - } - } - return { - size: columnSize, - sum: BI.sum(columnSize) + columnSize.length - }; - }, - - _isAdaptiveColumn: function (columnSize) { - return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); - }, - - _resizeHeader: function () { - var self = this, o = this.options; - if (o.isNeedFreeze === true) { - //若是当前处于自适应调节阶段 - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.table.setHeaderColumnSize(columnSize); - } else { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - var columnSizeLeft = block.left, columnSizeRight = block.right; - columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; - columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; - - var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); - newLeft[newLeft.length - 1] = ""; - newRight[newRight.length - 1] = ""; - this.table.setColumnSize(newLeft.concat(newRight)); - - block = self._getBlockSize(); - if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { - columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] - } - if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { - columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] - } - - self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); - } - } else { - if (!this._isAdaptiveColumn()) { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sum = block.sum; - var size = block.size; - - size[size.length - 1] += regionColumnSize[0] - sum; - - var newSize = BI.clone(size); - newSize[newSize.length - 1] = ""; - this.table.setColumnSize(newSize); - block = this._getBlockSize(); - - if (size[size.length - 1] < block.size[block.size.length - 1]) { - size[size.length - 1] = block.size[block.size.length - 1] - } - this.table.setColumnSize(size); - } - } - }, - - _resizeBody: function () { - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.setColumnSize(columnSize); - } - }, - - _adjustRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { - this.table.setRegionColumnSize([sumLeft, "fill"]); - } - this._resizeRegion(); - } - }, - - _resizeRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var maxWidth = this.table.element.width(); - if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { - var freezeCols = o.freezeCols; - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } - } - }, - - - resize: function () { - this.table.resize(); - this._resizeRegion(); - this._resizeHeader(); - }, - - setColumnSize: function (columnSize) { - this.table.setColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); - }, - - setHeaderColumnSize: function (columnSize) { - this.table.setHeaderColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - setRegionColumnSize: function (columnSize) { - this.table.setRegionColumnSize(columnSize); - this._resizeHeader(); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - getColumns: function () { - return this.table.getColumns(); - }, - - attr: function () { - BI.ResponisveTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function (items) { - var self = this, o = this.options; - this.table.populate.apply(this.table, arguments); - if (o.isNeedFreeze === true) { - BI.nextTick(function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - }); - } - } -}); -BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** - * 加号表示的组节点 - * 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: 25 - }) - }, - _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, - 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: 25, - 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: 25 - }) - }, - _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, - 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: 25, - 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: 25 - }) - }, - _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, - 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: 25, - 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);/** - * @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: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.select_level_tree", - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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: "click", - 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(BI.extend({stopPropagation: true}, 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: [] - }); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {layer: layer}; - node.id = node.id || BI.UUID(); - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - self._formatItems(node.children); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.last_tree_leaf_item"; - break; - default : - extend.type = "bi.mid_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)), - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - 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(items); - } -}); - -BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** - * - * Created by GUY on 2016/8/10. - * @class BI.SequenceTableDynamicNumber - * @extends BI.SequenceTableTreeNumber - */ -BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-sequence-table-dynamic-number" - }); - }, - - _init: function () { - BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); - }, - - _formatNumber: function (nodes) { - var self = this, o = this.options; - var result = []; - var count = this._getStart(nodes); - - function getLeafCount(node) { - var cnt = 0; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - cnt += getLeafCount(child); - }); - if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - } -}); -BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTableListNumber - * @extends BI.Widget - */ -BI.SequenceTableListNumber = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table-list-number", - isNeedFreeze: false, - scrollTop: 0, - startSequence: 1,//开始的序号 - headerRowSize: 25, - rowSize: 25, - - sequenceHeaderCreator: null, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [], - - pageSize: 20 - }); - }, - - _init: function () { - BI.SequenceTableListNumber.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.start = o.startSequence; - this.renderedCells = []; - this.renderedKeys = []; - - this.container = BI.createWidget({ - type: "bi.absolute", - width: 60, - scrollable: false - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.vertical", - scrollable: false, - scrolly: false, - items: [this.container] - }); - - this.headerContainer = BI.createWidget({ - type: "bi.absolute", - cls: "bi-border", - width: 58, - scrollable: false - }); - - this.layout = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.headerContainer, - height: o.headerRowSize * o.header.length - 2 - }, { - el: {type: "bi.layout"}, - height: 2 - }, { - el: this.scrollContainer - }] - }); - this._populate(); - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = o.headerRowSize * o.header.length - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - this.container.setHeight(o.items.length * o.rowSize); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); - var start = Math.floor(scrollTop / o.rowSize); - var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); - var renderedCells = [], renderedKeys = []; - for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { - var index = BI.deepIndexOf(this.renderedKeys, this.start + i); - var top = i * o.rowSize; - if (index > -1) { - if (o.rowSize !== this.renderedCells[index]._height) { - this.renderedCells[index]._height = o.rowSize; - this.renderedCells[index].el.setHeight(o.rowSize); - } - if (this.renderedCells[index].top !== top) { - this.renderedCells[index].top = top; - this.renderedCells[index].el.element.css("top", top + "px"); - } - renderedCells.push(this.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - height: o.rowSize, - text: this.start + i, - styleGetter: function (index) { - return function () { - return o.sequenceCellStyleGetter(self.start + i - 1); - } - }(cnt) - })); - renderedCells.push({ - el: child, - left: 0, - top: top, - _height: o.rowSize - }); - } - renderedKeys.push(this.start + i); - } - - //已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]) - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - }, - - _populate: function () { - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - v = v < 1 ? 1 : v; - var o = this.options; - this.start = (v - 1) * o.pageSize + 1; - }, - - _restore: function () { - var o = this.options; - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - } - if (header && header !== this.options.header) { - o.header = header; - } - this._populate(); - } -}); -BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** - * 带有序号的表格 - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTable - * @extends BI.Widget - */ -BI.SequenceTable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table", - el: { - type: "bi.adaptive_table" - }, - - sequence: {}, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [], - - showSequence: false, - startSequence: 1//开始的序号 - }); - }, - - _init: function () { - BI.SequenceTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.sequence = BI.createWidget(o.sequence, { - type: "bi.sequence_table_list_number", - invisible: o.showSequence === false, - startSequence: o.startSequence, - isNeedFreeze: o.isNeedFreeze, - header: o.header, - items: o.items, - crossHeader: o.crossHeader, - crossItems: o.crossItems, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - width: 60, - height: o.height && o.height - BI.GridTableScrollbar.SIZE, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter - }); - this.table = BI.createWidget(o.el, { - type: "bi.adaptive_table", - width: o.showSequence === true ? o.width - 60 : o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { - if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { - self.sequence.setVerticalScroll(this.getVerticalScroll()); - self.sequence.populate(); - } - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.htape = BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.sequence, - left: 0, - top: 0 - }, { - el: this.table, - top: 0, - left: o.showSequence === true ? 60 : 0 - }] - }); - this._populate(); - }, - - _populate: function () { - var o = this.options; - if (o.showSequence === true) { - this.sequence.setVisible(true); - this.table.element.css("left", "60px"); - this.table.setWidth(o.width - 60); - } else { - this.sequence.setVisible(false); - this.table.element.css("left", "0px"); - this.table.setWidth(o.width); - } - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(this.options.showSequence ? width - 60 : width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - hasLeftHorizontalScroll: function () { - return this.table.hasLeftHorizontalScroll(); - }, - - hasRightHorizontalScroll: function () { - return this.table.hasRightHorizontalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - this.sequence.setVerticalScroll(scrollTop); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setVPage: function (page) { - this.sequence.setVPage && this.sequence.setVPage(page); - }, - - setHPage: function (page) { - this.sequence.setHPage && this.sequence.setHPage(page); - }, - - attr: function () { - BI.SequenceTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - this.sequence.attr.apply(this.sequence, arguments); - }, - - restore: function () { - this.table.restore(); - this.sequence.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - this.table.populate.apply(this.table, arguments); - this.sequence.populate.apply(this.sequence, arguments); - this.sequence.setVerticalScroll(this.table.getVerticalScroll()); - }, - - destroy: function () { - this.table.destroy(); - BI.SequenceTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.sequence_table', BI.SequenceTable);/** - * @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: 30, - text: "", - items: [] - }); - }, - - _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 - }, o.trigger)); - - this.popup = BI.createWidget({ - type: "bi.single_level_tree", - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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: [] - }); - }, - - _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, - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - 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: 30, - text: "", - items: [] - }); - }, - - _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 - }); - }, - - _checkTitle: function () { - var self = this, val = this.getValue(); - BI.any(this.options.items, function (i, item) { - if (val.contains(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);/** - * 可以单选多选切换的树 - * - * Created by GUY on 2015/12/21. - * @class BI.SwitchTree - * @extends BI.Widget - */ -BI.SwitchTree = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-switch-tree", - items: [] - }); - }, - - _init: function () { - BI.SwitchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tab = BI.createWidget({ - type: "bi.tab", - element: this, - tab: null, - defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, - cardCreator: BI.bind(this._createTree, this) - }); - }, - - _createTree: function (type) { - var self = this, o = this.options; - switch (type) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree = BI.createWidget({ - type: "bi.multilayer_single_level_tree", - isDefaultInit: true, - items: BI.deepClone(o.items) - }); - this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.levelTree; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree = BI.createWidget({ - type: "bi.simple_tree", - items: this._removeIsParent(BI.deepClone(o.items)) - }); - this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.tree; - } - }, - - _removeIsParent: function(items) { - BI.each(items, function(i, item) { - BI.isNotNull(item.isParent) && delete item.isParent; - }); - return items; - }, - - switchSelect: function () { - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.setSelect(BI.SwitchTree.SelectType.MultiSelect); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.setSelect(BI.SwitchTree.SelectType.SingleSelect); - break; - } - }, - - setSelect: function (v) { - this.tab.setSelect(v); - }, - - getSelect: function () { - return this.tab.getSelect(); - }, - - setValue: function (v) { - this.storeValue = v; - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree.setValue(v); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree.setValue(v); - break; - } - }, - - getValue: function () { - return this.tab.getValue(); - }, - - populate: function (items) { - this.options.items = items; - if (BI.isNotNull(this.levelTree)) { - this.levelTree.populate(BI.deepClone(items)); - } - if (BI.isNotNull(this.tree)) { - this.tree.populate(this._removeIsParent(BI.deepClone(items))); - } - } -}); -BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; -BI.SwitchTree.SelectType = { - SingleSelect: BI.Selection.Single, - MultiSelect: BI.Selection.Multi -}; -BI.shortcut('bi.switch_tree', BI.SwitchTree); -/** - * Created by Baron on 2015/10/19. - */ -BI.TimeInterval = BI.inherit(BI.Single, { - constants: { - height: 25, - width: 25, - lgap: 15, - offset: -15, - 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; - BI.TimeInterval.superclass._init.apply(this, arguments); - - this.left = this._createCombo(); - this.right = this._createCombo(); - 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 () { - var self = this; - var combo = BI.createWidget({ - type: 'bi.multidate_combo' - }); - combo.on(BI.MultiDateCombo.EVENT_ERROR, function () { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - }); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.left.hidePopupView(); - self.right.hidePopupView(); - }); - //combo.on(BI.MultiDateCombo.EVENT_CHANGE, 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.TimeInterval.EVENT_ERROR); - // } else { - // self._clearTitle(); - // self.element.removeClass(self.constants.timeErrorCls); - // } - //}); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - }else{ - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_CHANGE); - } - }); - return combo; - }, - _dateCheck: function (date) { - return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; - }, - _checkVoid: function (obj) { - return !Date.checkVoid(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) && Date.checkLegal(smallDate) && this._checkVoid({ - year: smallObj[0], - month: smallObj[1], - day: smallObj[2] - }) && this._dateCheck(bigDate) && Date.checkLegal(bigDate) && this._checkVoid({ - year: bigObj[0], - month: bigObj[1], - day: bigObj[2] - }); - }, - _compare: function (smallDate, bigDate) { - smallDate = Date.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); - bigDate = Date.parseDateTime(bigDate, "%Y-%X-%d").print("%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.TimeInterval.EVENT_VALID = "EVENT_VALID"; -BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.time_interval", BI.TimeInterval);/** - * 年份下拉框 - * - * Created by GUY on 2015/8/28. - * @class BI.YearCombo - * @extends BI.Widget - */ -BI.YearCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-combo", - behaviors: {}, - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.YearCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = ""; - this.trigger = BI.createWidget({ - type: "bi.year_trigger", - min: o.min, - max: o.max - }); - this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { - self.storeValue = this.getKey(); - }); - this.trigger.on(BI.YearTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { - self.combo.showView(); - }); - this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.YearTrigger.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.YearCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - destroyWhenHide: true, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: { - type: "bi.year_popup", - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.YearPopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearCombo.EVENT_CONFIRM); - } - }], - behaviors: o.behaviors, - min: o.min, - max: o.max - } - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - var value = self.trigger.getKey(); - if (BI.isNotNull(value)) { - self.popup.setValue(value); - } else if (!value && value !== self.storeValue) { - self.popup.setValue(self.storeValue); - } else { - self.setValue(); - } - self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - setValue: function (v) { - this.combo.setValue(v || ""); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_combo', BI.YearCombo);/** - * 年份展示面板 - * - * 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; - - this.selectedYear = this._year = new Date().getFullYear(); - - var backBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 25, - height: 25, - value: -1 - }); - - var preBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 25, - height: 25, - 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-border-top", - height: 25, - 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); - }); - }, - - getValue: function () { - return this.selectedYear; - }, - - setValue: function (v) { - var o = this.options; - if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { - v = new Date().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/8/21. - * @class BI.YearTrigger - * @extends BI.Trigger - */ -BI.YearTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - triggerWidth: 25, - errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), - errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-year-trigger bi-border", - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.YearTrigger.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) { - self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); - return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); - }, - quitChecker: function (v) { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - errorText: c.errorText - }) - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.YearTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.YearTrigger.EVENT_STOP); - }); - 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.YearTrigger.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.YearTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.YearTrigger.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: c.triggerWidth - }, - width: c.triggerWidth - }, { - el: { - type: "bi.trigger_icon_button", - width: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - setValue: function (v) { - this.editor.setState(v); - this.editor.setValue(v); - this.editor.setTitle(v); - }, - getKey: function () { - return this.editor.getValue() | 0; - } -}); -BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.YearTrigger.EVENT_START = "EVENT_START"; -BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; -BI.shortcut("bi.year_trigger", BI.YearTrigger);/** - * 年份 + 月份下拉框 - * - * @class BI.YearMonthCombo - * @extends BI.Widget - */ -BI.YearMonthCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-month-combo", - yearBehaviors: {}, - monthBehaviors: {}, - height: 25 - }); - }, - _init: function () { - BI.YearMonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.year = BI.createWidget({ - type: "bi.year_combo", - behaviors: o.yearBehaviors - }); - - this.month = BI.createWidget({ - type: "bi.month_combo", - behaviors: o.monthBehaviors - }); - - this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); - }); - this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - - this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); - }); - this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.center", - element: this, - hgap: 5, - items: [this.year, this.month] - }); - - }, - - setValue: function (v) { - v = v || {}; - this.month.setValue(v.month); - this.year.setValue(v.year); - }, - - getValue: function () { - return { - year: this.year.getValue(), - month: this.month.getValue() - }; - } -}); -BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** - * 年份 + 月份下拉框 - * - * @class BI.YearQuarterCombo - * @extends BI.Widget - */ -BI.YearQuarterCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-quarter-combo", - yearBehaviors: {}, - quarterBehaviors: {}, - height: 25 - }); - }, - _init: function () { - BI.YearQuarterCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.year = BI.createWidget({ - type: "bi.year_combo", - behaviors: o.yearBehaviors - }); - - this.quarter = BI.createWidget({ - type: "bi.quarter_combo", - behaviors: o.quarterBehaviors - }); - - this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); - }); - this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - - this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); - }); - this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.center", - element: this, - hgap: 5, - items: [this.year, this.quarter] - }); - - }, - - setValue: function (v) { - v = v || {}; - this.quarter.setValue(v.quarter); - this.year.setValue(v.year); - }, - - getValue: function () { - return { - year: this.year.getValue(), - quarter: this.quarter.getValue() - }; - } -}); -BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** - * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { - if (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.matched.concat(search.finded); - }); - 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', - element: this, - 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.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 () { - 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 () { - this.list.populate.apply(this.list, arguments); - } -}); -BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; -BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);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 - }); - }, - - _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 finded = search(parentValues, notSelectedValue, [], searched); - if (finded && 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 = [], finded = false; - //如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(p)) { - finded = true; - } else { - //从当前值开始搜 - finded = search(parentValues, notSelectedValue, result); - p = parentValues; - } - - if (finded === 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, parentValues.length - 1), 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); - var finded = BI.Func.getSearchResult([node.text || node.value], keyword); - return finded.finded.length > 0 || finded.matched.length > 0; - }, - - _getTreeNode: function (parentValues, v) { - var self = this; - var findedParentNode; - 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) { - findedParentNode = node; - return false; - } - if (node.value === parentValues[index]) { - index++; - return; - } - return true; - }); - return findedParentNode; - }, - - _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), - 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 () { - 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) { - 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(); - if (options.keyword) { - keywords.push(options.keyword); - } - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.matched.concat(search.finded); - }); - 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, - 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 () { - 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.populate(); - } - }, - - setValue: function (v) { - this.list.setValue(v); - }, - - getValue: function () { - var val = this.list.getValue() || {}; - return { - type: val.type, - value: val.value - } - }, - - populate: function () { - this.list.populate.apply(this.list, arguments); - } -}); -BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; +/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableTreeNumber + * @extends BI.Widget + */ +BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-tree-number", + isNeedFreeze: false, + startSequence: 1,//开始的序号 + scrollTop: 0, + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.vCurr = 1; + this.hCurr = 1; + this.tasks = []; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: this._getHeaderHeight() - 2 + }, {el: {type: "bi.layout"}, height: 2}, { + el: this.scrollContainer + }] + }); + //缓存第一行对应的序号 + this.start = this.options.startSequence; + this.cache = {}; + this._nextState(); + + this._populate(); + }, + + _getNextSequence: function (nodes) { + var self = this; + var start = this.start; + var cnt = this.start; + + function track(node) { + //如果已经有缓存了就不改计数了,复杂表会出现这种情况 + self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); + cnt++; + } + + BI.each(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = cnt = self.cache[child.text || child.value]; + } + } + track(child) + }); + } + }); + this.start = cnt; + return start; + }, + + _getStart: function (nodes) { + var self = this; + var start = this.start; + BI.some(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = self.cache[child.text || child.value]; + return true; + } + } + }); + } + }); + return start; + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = this._getHeaderHeight() - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _getHeaderHeight: function () { + var o = this.options; + return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); + }, + + _nextState: function () { + var o = this.options; + this._getNextSequence(o.items); + }, + + _prevState: function () { + var self = this, o = this.options; + var firstChild; + BI.some(o.items, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (j, child) { + firstChild = child; + return true; + }); + } + }); + if (firstChild && BI.isNotEmptyObject(this.cache)) { + this.start = this.cache[firstChild.text || firstChild.value]; + } else { + this.start = 1; + } + this._nextState(); + }, + + _getMaxScrollTop: function (numbers) { + var cnt = 0; + BI.each(numbers, function (i, number) { + cnt += number.cnt; + }); + return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + + var renderedCells = [], renderedKeys = []; + var numbers = this._formatNumber(o.items); + var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); + BI.each(numbers, function (i, number) { + intervalTree.set(i, number.height); + }); + var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); + var index = intervalTree.greatestLowerBound(scrollTop); + var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); + var height = offsetTop; + var bodyHeight = o.height - this._getHeaderHeight(); + while (height < bodyHeight && index < numbers.length) { + renderedKeys.push(index); + offsetTop += numbers[index].height; + height += numbers[index].height; + index++; + } + + BI.each(renderedKeys, function (i, key) { + var index = BI.deepIndexOf(self.renderedKeys, key); + if (index > -1) { + if (numbers[key].height !== self.renderedCells[index]._height) { + self.renderedCells[index]._height = numbers[key].height; + self.renderedCells[index].el.setHeight(numbers[key].height); + } + if (numbers[key].top !== self.renderedCells[index].top) { + self.renderedCells[index].top = numbers[key].top; + self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); + } + renderedCells.push(self.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + styleGetter: numbers[key].isSummary === true ? function () { + return o.summaryCellStyleGetter(true); + } : function (key) { + return function () { + return o.sequenceCellStyleGetter(key); + } + }(numbers[key].index) + }, numbers[key])); + renderedCells.push({ + el: child, + left: 0, + top: numbers[key].top, + _height: numbers[key].height + }); + } + }); + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + + this.container.setHeight(intervalTree.sumUntil(numbers.length)); + }, + + _restore: function () { + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + _populate: function () { + var self = this; + BI.each(this.tasks, function (i, task) { + task.apply(self); + }); + this.tasks = []; + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + if (v <= 1) { + this.cache = {}; + this.start = this.options.startSequence; + this._restore(); + this.tasks.push(this._nextState); + } else if (v === this.vCurr + 1) { + this.tasks.push(this._nextState); + } else if (v === this.vCurr - 1) { + this.tasks.push(this._prevState); + } + this.vCurr = v; + }, + + setHPage: function (v) { + if (v !== this.hCurr) { + this.tasks.push(this._prevState); + } + this.hCurr = v; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + this.tasks.push(this._prevState); + } + if (header && header !== this.options.header) { + o.header = header; + } + if (crossItems && crossItems !== this.options.crossItems) { + o.crossItems = crossItems; + } + if (crossHeader && crossHeader !== this.options.crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** + * 自适应布局 + * + * 1、resize + * 2、吸附 + * 3、当前组件在最上方 + * 4、可以撤销 + * 5、上下之间插入组件 + * + * Created by GUY on 2016/2/23. + * @class BI.AdaptiveArrangement + * @extends BI.Widget + */ +BI.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, + items: [] + }); + }, + + _init: function () { + BI.AdaptiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement", + element: this, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); + }); + this.zIndex = 0; + BI.each(o.items, function (i, item) { + self._initResizable(item.el); + }); + + $(document).mousedown(function (e) { + BI.each(self.getAllRegions(), function (i, region) { + if (region.el.element.find(e.target).length === 0) { + region.el.element.removeClass("selected"); + } + }); + }); + BI.ResizeDetector.addResizeListener(this, function () { + self.arrangement.resize(); + self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + }); + }, + + _isEqual: function () { + return this.arrangement._isEqual.apply(this.arrangement, arguments); + }, + + _setSelect: function (item) { + if (!item.element.hasClass("selected")) { + item.element.css("zIndex", ++this.zIndex); + BI.each(this.getAllRegions(), function (i, region) { + region.el.element.removeClass("selected"); + }); + item.element.addClass("selected"); + } + }, + + _initResizable: function (item) { + var self = this, o = this.options; + item.element.css("zIndex", ++this.zIndex); + item.element.mousedown(function () { + self._setSelect(item) + }); + // o.resizable && item.element.resizable({ + // handles: "e, s, se", + // minWidth: 20, + // minHeight: 20, + // autoHide: true, + // helper: "bi-resizer", + // start: function () { + // item.element.css("zIndex", ++self.zIndex); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); + // }, + // resize: function (e, ui) { + // // self._resize(item.attr("id"), ui.size); + // self._resize(item.attr("id"), e, ui.size, ui.position); + // }, + // stop: function (e, ui) { + // self._stopResize(item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + // } + // }); + }, + + // _resize: function (name, e, size, position) { + // var self = this; + // this.scrollInterval(e, false, true, function (changedSize) { + // size.width += changedSize.offsetX; + // size.height += changedSize.offsetY; + // var containerWidth = self.arrangement.container.element.width(); + // var containerHeight = self.arrangement.container.element.height(); + // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); + // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); + // switch (self.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // self.setRegionSize(name, size); + // break; + // } + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); + // }); + // }, + // + // _stopResize: function (name, size) { + // var self = this; + // this.scrollEnd(); + // switch (this.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // this.setRegionSize(name, size); + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // this.setRegionSize(name, size); + // break; + // } + // }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + addRegion: function (region, position) { + this._initResizable(region.el); + this._setSelect(region.el); + var self = this, flag; + var old = this.arrangement.getAllRegions(); + if (flag = this.arrangement.addRegion(region, position)) { + this._old = old; + } + return flag; + }, + + deleteRegion: function (name) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.deleteRegion(name)) { + this._old = old; + } else { + this._old = this.getAllRegions(); + this.relayout(); + } + return flag; + }, + + setRegionSize: function (name, size) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.setRegionSize(name, size)) { + this._old = old; + } + return flag; + }, + + setPosition: function (position, size) { + var self = this; + return this.arrangement.setPosition(position, size); + }, + + setRegionPosition: function (name, position) { + var region = this.getRegionByName(name); + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + return this.arrangement.setDropPosition(position, size); + }, + + scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { + var self = this; + var map = { + top: [-1, 0], + bottom: [1, 0], + left: [0, -1], + right: [0, 1] + }; + var clientSize = this.element.bounds(); + + function scrollTo(direction, callback) { + if (direction === "") { + self.lastActiveRegion = ""; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + return; + } + if (self.lastActiveRegion !== direction) { + self.lastActiveRegion = direction; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + var count = 0; + self._scrollInterval = setInterval(function () { + count++; + if (count <= 3) { + return; + } + var offset = self._getScrollOffset(); + var t = offset.top + map[direction][0] * 40; + var l = offset.left + map[direction][1] * 40; + if (t < 0 || l < 0) { + return; + } + callback({ + offsetX: map[direction][1] * 40, + offsetY: map[direction][0] * 40 + }); + self.scrollTo({ + top: t, + left: l + }); + }, 300); + } + } + + cb({ + offsetX: 0, + offsetY: 0 + }); + var offset = this.element.offset(); + var p = { + left: e.pageX - offset.left, + top: e.pageY - offset.top + }; + //向上滚 + if (isBorderScroll && p.top >= 0 && p.top <= 30) { + scrollTo("top", cb) + } + //向下滚 + else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { + scrollTo("bottom", cb) + } + //向左滚 + else if (isBorderScroll && p.left >= 0 && p.left <= 30) { + scrollTo("left", cb) + } + //向右滚 + else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { + scrollTo("right", cb) + } else { + if (isOverflowScroll === true) { + if (p.top < 0) { + scrollTo("top", cb); + } + else if (p.top > clientSize.height) { + scrollTo("bottom", cb); + } + else if (p.left < 0) { + scrollTo("left", cb); + } + else if (p.left > clientSize.width) { + scrollTo("right", cb); + } else { + scrollTo("", cb); + } + } else { + scrollTo("", cb); + } + } + }, + + scrollEnd: function () { + this.lastActiveRegion = ""; + if (this._scrollInterval) { + clearInterval(this._scrollInterval); + this._scrollInterval = null; + } + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + var self = this; + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + if (this._old) { + this.populate(BI.toArray(this._old)); + } + }, + + populate: function (items) { + var self = this; + BI.each(items, function (i, item) { + self._initResizable(item.el); + }); + this.arrangement.populate(items); + } +}); +BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; +BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** + * Arrangement的block面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementBlock + * @extends BI.Widget + */ +BI.ArrangementBlock = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-block bi-mask" + }); + } +}); +BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** + * Arrangement的drop面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementDroppable + * @extends BI.Widget + */ +BI.ArrangementDroppable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-droppable bi-resizer" + }); + } +}); +BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** + * 布局 + * + * Created by GUY on 2016/2/23. + * @class BI.Arrangement + * @extends BI.Widget + */ +BI.Arrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.Arrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement_droppable", + cls: "arrangement-block", + invisible: true + }); + this.block = BI.createWidget({ + type: "bi.arrangement_block", + invisible: true + }); + this.container = BI.createWidget({ + type: "bi.absolute", + cls: "arrangement-container", + items: o.items.concat([this.block, this.arrangement]) + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.adaptive", + width: "100%", + height: "100%", + scrollable: true, + items: [this.container] + }); + this.scrollContainer.element.scroll(function () { + self.fireEvent(BI.Arrangement.EVENT_SCROLL, { + scrollLeft: self.scrollContainer.element.scrollLeft(), + scrollTop: self.scrollContainer.element.scrollTop(), + clientWidth: self.scrollContainer.element[0].clientWidth, + clientHeight: self.scrollContainer.element[0].clientHeight + }); + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + items: [this.scrollContainer] + }); + this.regions = {}; + if (o.items.length > 0) { + BI.nextTick(function () { + self.populate(o.items); + }); + } + }, + + ////初始化操作//// + _calculateRegions: function (items) { + var self = this, o = this.options; + this.regions = {}; + BI.each(items, function (i, item) { + var region = self._createOneRegion(item); + self.regions[region.id] = region; + }); + }, + + _isEqual: function (num1, num2) { + return Math.abs(num1 - num2) < 2; + }, + + _isLessThan: function (num1, num2) { + return num1 < num2 && !this._isEqual(num1, num2); + }, + + _isMoreThan: function (num1, num2) { + return num1 > num2 && !this._isEqual(num1, num2); + }, + + _isLessThanEqual: function (num1, num2) { + return num1 <= num2 || this._isEqual(num1, num2); + }, + + _isMoreThanEqual: function (num1, num2) { + return num1 >= num2 || this._isEqual(num1, num2); + }, + + //获取占有的最大Region + _getRegionOccupied: function (regions) { + var self = this, o = this.options; + if (BI.size(regions || this.regions) <= 0) { + return { + left: 0, + top: 0, + width: 0, + height: 0 + } + } + var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; + BI.each(regions || this.regions, function (id, region) { + minLeft = Math.min(minLeft, region.left); + maxLeft = Math.max(maxLeft, region.left + region.width); + minTop = Math.min(minTop, region.top); + maxTop = Math.max(maxTop, region.top + region.height); + }); + return { + left: minLeft, + top: minTop, + width: maxLeft - minLeft, + height: maxTop - minTop + } + }, + + //两个区域的交叉面积 + _getCrossArea: function (region1, region2) { + if (region1.left <= region2.left) { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); + } + } else { + if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); + } + } + } else { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); + } + } else { + if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); + } + } + } + return 0; + }, + + //是否有覆盖的组件 + _isRegionOverlay: function (regions) { + var reg = []; + BI.each(regions || this.regions, function (id, region) { + reg.push(new BI.Region(region.left, region.top, region.width, region.height)); + }); + for (var i = 0, len = reg.length; i < len; i++) { + for (var j = i + 1; j < len; j++) { + var area1 = { + left: reg[i].x, + top: reg[i].y, + width: reg[i].w, + height: reg[i].h + }; + var area2 = { + left: reg[j].x, + top: reg[j].y, + width: reg[j].w, + height: reg[j].h + }; + if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { + return true; + } + } + } + return false; + }, + + //布局是否是优良的 + _isArrangeFine: function (regions) { + switch (this.options.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + // if (this._isRegionOverlay()) { + // return false; + // } + } + return true; + }, + + _getRegionNames: function (regions) { + var names = []; + BI.each(regions || this.regions, function (i, region) { + names.push(region.id || region.attr("id")); + }); + return names; + }, + + _getRegionsByNames: function (names, regions) { + names = BI.isArray(names) ? names : [names]; + regions = regions || this.regions; + if (BI.isArray(regions)) { + var result = []; + BI.each(regions, function (i, region) { + if (names.contains(region.id || region.attr("id"))) { + result.push(region); + } + }); + } else { + var result = {}; + BI.each(names, function (i, name) { + result[name] = regions[name]; + }); + } + return result; + }, + + _cloneRegion: function (regions) { + var clone = {}; + BI.each(regions || this.regions, function (id, region) { + clone[id] = {}; + clone[id].el = region.el; + clone[id].id = region.id; + clone[id].left = region.left; + clone[id].top = region.top; + clone[id].width = region.width; + clone[id].height = region.height; + }); + return clone; + }, + + //测试合法性 + _test: function (regions) { + var self = this; + return !BI.any(regions || this.regions, function (i, region) { + if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { + return true; + } + }) + }, + + _getScrollOffset: function () { + return { + left: this.scrollContainer.element[0].scrollLeft, + top: this.scrollContainer.element[0].scrollTop + } + }, + + ////操作//// + _createOneRegion: function (item) { + var el = BI.createWidget(item.el); + el.setVisible(true); + return { + id: el.attr("id"), + left: item.left, + top: item.top, + width: item.width, + height: item.height, + el: el + } + }, + + _applyRegion: function (regions) { + var self = this, o = this.options; + BI.each(regions || this.regions, function (i, region) { + region.el.element.css({ + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + this._applyContainer(); + this.ratio = this.getLayoutRatio(); + }, + + _renderRegion: function () { + var items = BI.toArray(this.regions); + BI.each(items, function (i, item) { + if (BI.isNotNull(item.el)) { + item.el.options.key = item.id; + } else { + item.key = item.id; + } + }); + if (BI.isNull(this.wrapper)) { + this.wrapper = BI.createWidget({ + type: "bi.absolute", + element: this.container + }); + } + this.wrapper.populate(items); + }, + + getClientWidth: function () { + return this.scrollContainer.element[0].clientWidth; + }, + + getClientHeight: function () { + return this.scrollContainer.element[0].clientHeight; + }, + + _applyContainer: function () { + //先掩藏后显示能够明确滚动条是否出现 + this.scrollContainer.element.css("overflow", "hidden"); + var occupied = this._getRegionOccupied(); + this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); + this.scrollContainer.element.css("overflow", "auto"); + return occupied; + }, + + _modifyRegion: function (regions) { + BI.each(this.regions, function (id, region) { + if (regions[id]) { + region.left = regions[id].left; + region.top = regions[id].top; + region.width = regions[id].width; + region.height = regions[id].height; + } + }); + }, + + _addRegion: function (item) { + var region = this._createOneRegion(item); + this.regions[region.id] = region; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [region] + }); + }, + + _deleteRegionByName: function (name) { + this.regions[name].el.setVisible(false); + delete this.regions[name]; + }, + + _setArrangeSize: function (size) { + this.arrangement.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }) + }, + + //Grid + _getOneWidthPortion: function () { + return this.getClientWidth() / BI.Arrangement.PORTION; + }, + _getOneHeightPortion: function () { + return this.getClientHeight() / BI.Arrangement.H_PORTION; + }, + + _getGridPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + var widthPortion = Math.round(position.width / perWidth); + var leftPortion = Math.round(position.left / perWidth); + var topPortion = Math.round(position.top / perHeight); + var heightPortion = Math.round(position.height / perHeight); + // if (leftPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION; + // } + // if (widthPortion > BI.Arrangement.PORTION) { + // widthPortion = BI.Arrangement.PORTION; + // } + // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION - widthPortion; + // } + if (widthPortion === 0) { + widthPortion = 1; + } + if (heightPortion === 0) { + heightPortion = 1; + } + return { + x: leftPortion, + y: topPortion, + w: widthPortion, + h: heightPortion + } + }, + + _getBlockPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + return { + left: position.x * perWidth, + top: position.y * perHeight, + width: position.w * perWidth, + height: position.h * perHeight + }; + }, + + _getLayoutsByRegions: function (regions) { + var self = this; + var result = []; + BI.each(regions || this.regions, function (id, region) { + result.push(BI.extend(self._getGridPositionAndSize(region), { + i: region.id + })) + }); + return result; + }, + + _getLayoutIndexByName: function (layout, name) { + return BI.findIndex(layout, function (i, l) { + return l.i === name; + }); + }, + + _setBlockPositionAndSize: function (size) { + this.block.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }); + }, + + _getRegionsByLayout: function (layout) { + var self = this; + var regions = {}; + BI.each(layout, function (i, ly) { + regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { + id: ly.i + }); + }); + return regions; + }, + + _setRegionsByLayout: function (regions, layout) { + var self = this; + regions || (regions = this.regions); + BI.each(layout, function (i, ly) { + if (regions[ly.i]) { + BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); + } + }); + return regions; + }, + + _moveElement: function (layout, l, x, y, isUserAction) { + var self = this; + if (l._static) { + return layout; + } + + if (l.y === y && l.x === x) { + return layout; + } + + var movingUp = y && l.y > y; + if (typeof x === 'number') { + l.x = x; + } + if (typeof y === 'number') { + l.y = y; + } + l.moved = true; + + var sorted = this._sortLayoutItemsByRowCol(layout); + if (movingUp) { + sorted = sorted.reverse(); + } + var collisions = getAllCollisions(sorted, l); + + for (var i = 0, len = collisions.length; i < len; i++) { + var collision = collisions[i]; + if (collision.moved) { + continue; + } + + if (l.y > collision.y && l.y - collision.y > collision.h / 4) { + continue; + } + + if (collision._static) { + layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); + } else { + layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); + } + } + + return layout; + + function getAllCollisions(layout, layoutItem) { + return BI.filter(layout, function (i, l) { + return self._collides(l, layoutItem); + }); + } + }, + + _sortLayoutItemsByRowCol: function (layout) { + return [].concat(layout).sort(function (a, b) { + if (a.y > b.y || (a.y === b.y && a.x > b.x)) { + return 1; + } + return -1; + }); + }, + + _collides: function (l1, l2) { + if (l1 === l2) { + return false; + } // same element + if (l1.x + l1.w <= l2.x) { + return false; + } // l1 is left of l2 + if (l1.x >= l2.x + l2.w) { + return false; + } // l1 is right of l2 + if (l1.y + l1.h <= l2.y) { + return false; + } // l1 is above l2 + if (l1.y >= l2.y + l2.h) { + return false; + } // l1 is below l2 + return true; // boxes overlap + }, + + _getFirstCollision: function (layout, layoutItem) { + for (var i = 0, len = layout.length; i < len; i++) { + if (this._collides(layout[i], layoutItem)) { + return layout[i]; + } + } + }, + + _moveElementAwayFromCollision: function (layout, collidesWith, + itemToMove, isUserAction) { + if (isUserAction) { + var fakeItem = { + x: itemToMove.x, + y: itemToMove.y, + w: itemToMove.w, + h: itemToMove.h, + i: '-1' + }; + fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); + if (!this._getFirstCollision(layout, fakeItem)) { + return this._moveElement(layout, itemToMove, undefined, fakeItem.y); + } + } + + return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); + }, + + _compactItem: function (compareWith, l, verticalCompact) { + if (verticalCompact) { + while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { + l.y--; + } + } + + var collides; + while ((collides = this._getFirstCollision(compareWith, l))) { + l.y = collides.y + collides.h; + } + return l; + }, + + compact: function (layout, verticalCompact) { + var compareWith = getStatics(layout); + var sorted = this._sortLayoutItemsByRowCol(layout); + var out = []; + + for (var i = 0, len = sorted.length; i < len; i++) { + var l = sorted[i]; + + if (!l._static) { + l = this._compactItem(compareWith, l, verticalCompact); + + compareWith.push(l); + } + + out[layout.indexOf(l)] = l; + + l.moved = false; + } + + return out; + + function getStatics(layout) { + return BI.filter(layout, function (i, l) { + return l._static; + }); + } + }, + + ////公有方法//// + getRegionByName: function (name) { + var obj = {}; + obj[name] = this.regions[name]; + return this._cloneRegion(obj)[name]; + }, + + getAllRegions: function () { + return BI.toArray(this._cloneRegion()); + }, + + getHelper: function () { + var helper = BI.createWidget({ + type: "bi.layout", + width: 18, + height: 18, + cls: "arrangement-helper bi-border" + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [helper] + }); + return helper; + }, + + _start: function () { + if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { + this.block.setVisible(true); + } else { + this.arrangement.setVisible(true); + } + }, + + _stop: function () { + this.arrangement.setVisible(false); + this.block.setVisible(false); + }, + + ////公有操作//// + setLayoutType: function (type) { + var self = this, o = this.options; + if (type !== o.layoutType) { + o.layoutType = type; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.relayout(); + break; + } + } + }, + + getLayoutType: function () { + return this.options.layoutType; + }, + + getLayoutRatio: function () { + var occupied = this._getRegionOccupied(); + var width = this.getClientWidth(), height = this.getClientHeight(); + return { + x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), + y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) + } + }, + + addRegion: function (region, position) { + if (position) { + this.setPosition(position, region); + } + var self = this, o = this.options; + if (!this.position) { + return false; + } + var test = this._cloneRegion(); + BI.each(this.position.regions, function (i, region) { + test[region.id].left = region.left; + test[region.id].top = region.top; + test[region.id].width = region.width; + test[region.id].height = region.height; + + }); + var item = BI.extend({}, region, { + left: this.position.insert.left, + top: this.position.insert.top, + width: this.position.insert.width, + height: this.position.insert.height + }); + var added = this._createOneRegion(item); + test[added.id] = added; + if (this._test(test)) { + delete test[added.id]; + this._modifyRegion(test); + this._addRegion(item); + this._populate(this.getAllRegions()); + return true; + } + return false; + }, + + deleteRegion: function (name) { + if (!this.regions[name]) { + return false; + } + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + this.resize(); + return true; + } + return false; + }, + + setRegionSize: function (name, size) { + var self = this, o = this.options; + var flag = false; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + this._modifyRegion(clone); + flag = true; + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(clone); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + flag = true; + } + break; + } + this._applyRegion(); + return flag; + }, + + setPosition: function (position, size) { + var self = this, o = this.options; + var insert, regions = [], cur; + if (position.left < 0 || position.top < 0) { + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.resize(); + break; + } + this._stop(); + this.position = null; + return null; + } + var offset = this._getScrollOffset(); + position = { + left: position.left + offset.left, + top: position.top + offset.top + }; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var insert = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this.position = { + insert: insert + }; + this._setArrangeSize(insert); + this._start(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var p = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this._setArrangeSize(p); + var cur = this._getGridPositionAndSize(p); + var layout = [{ + x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i + }].concat(this._getLayoutsByRegions()); + layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); + layout = this.compact(layout, true); + var regions = this._setRegionsByLayout(this._cloneRegion(), layout); + var insert = this._getBlockPositionAndSize(layout[0]); + this.position = { + insert: insert, + regions: regions + }; + this._applyRegion(regions); + this._setBlockPositionAndSize(insert); + this._start(); + break; + } + return this.position; + }, + + setRegionPosition: function (name, position) { + var self = this, o = this.options; + var offset = this._getScrollOffset(); + position = BI.extend(position, { + left: position.left + offset.left, + top: position.top + offset.top + }); + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + this._applyRegion(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!position.stop) { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + })); + var x = cur.x, y = cur.y; + cur = BI.extend(cur, { + x: 0, y: BI.MAX, i: -1 + }); + delete cloned[name]; + var layout = this._getLayoutsByRegions(cloned); + layout = this._moveElement([cur].concat(layout), cur, x, y, true); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + + this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); + this.block.setVisible(true); + } else { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var layout = this._getLayoutsByRegions(cloned); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + this.block.setVisible(false); + } + break; + } + }, + + setDropPosition: function (position, size) { + var self = this; + this.arrangement.setVisible(true); + var offset = this._getScrollOffset(); + this._setArrangeSize(BI.extend({}, size, { + left: position.left + offset.left, + top: position.top + offset.top + })); + return function () { + self.arrangement.setVisible(false); + } + }, + + scrollTo: function (scroll) { + this.scrollContainer.element.scrollTop(scroll.top); + this.scrollContainer.element.scrollLeft(scroll.left); + }, + + zoom: function (ratio) { + var self = this, o = this.options; + if (!ratio) { + return; + } + var occupied = this._applyContainer(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + if (this._isArrangeFine()) { + var width = this.getClientWidth(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + //var yRatio = ratio.y * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + //region.top = region.top * yRatio; + region.width = region.width * xRatio; + //region.height = region.height * yRatio; + }); + if (this._test(regions)) { + this._modifyRegion(regions); + this._applyRegion(); + } + this.resize(); + // } else { + this.relayout(); + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (this._isArrangeFine()) { + var width = this.getClientWidth(), height = this.getClientHeight(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + region.width = region.width * xRatio; + region.top = region.top * yRatio; + region.height = region.height * yRatio; + //做一下自适应布局到网格布局的兼容 + var perWidth = self._getOneWidthPortion(); + var widthPortion = Math.round(region.width / perWidth); + var leftPortion = Math.round(region.left / perWidth); + var comparePortion = Math.round((region.width + region.left) / perWidth); + if (leftPortion + widthPortion !== comparePortion) { + region.left = leftPortion * perWidth; + region.width = comparePortion * perWidth - region.left; + } + }); + if (this._test(regions)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + } + } else { + this.relayout(); + } + break; + } + }, + + resize: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.zoom(this.ratio); + var regions = this._cloneRegion(); + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + break; + } + }, + + relayout: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!this._isArrangeFine()) { + var perHeight = this._getOneHeightPortion(); + var width = this.getClientWidth(), height = this.getClientHeight(); + var regions = this._cloneRegion(); + var clone = BI.toArray(regions); + clone.sort(function (r1, r2) { + if (self._isEqual(r1.top, r2.top)) { + return r1.left - r2.left; + } + return r1.top - r2.top; + }); + var count = clone.length; + var cols = 4, rows = Math.floor((count - 1) / 4 + 1); + var w = width / cols, h = height / rows; + var store = {}; + BI.each(clone, function (i, region) { + var row = Math.floor(i / 4), col = i % 4; + BI.extend(region, { + top: row * perHeight * 6, + left: col * w, + width: w, + height: perHeight * 6 + }); + if (!store[row]) { + store[row] = {}; + } + store[row][col] = region; + }); + //非4的倍数 + // if (count % 4 !== 0) { + // var lasts = store[rows - 1]; + // var perWidth = width / (count % 4); + // BI.each(lasts, function (i, region) { + // BI.extend(region, { + // left: BI.parseInt(i) * perWidth, + // width: perWidth + // }); + // }); + // } + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._populate(clone); + } + } else { + this.resize(); + } + break; + } + }, + + _populate: function (items) { + this._stop(); + this._calculateRegions(items); + this._applyRegion(); + }, + + populate: function (items) { + this.regions = {}; + this._populate(items); + this._renderRegion(); + } +}); +BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; +BI.extend(BI.Arrangement, { + PORTION: 36, + H_PORTION: 18, + LAYOUT_TYPE: { + GRID: 0, + FREE: 1 + } +}); +BI.shortcut('bi.arrangement', BI.Arrangement);/** + * Created By Shichao on 2017/10/17 + * @class BI.CanvasCollectionView + * @extends BI.Widget + */ +BI.CanvasCollectionView = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasCollectionView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection", + overflowX: true, + overflowY: true, + cellSizeAndPositionGetter: BI.emptyFn, + horizontalOverscanSize: 0, + verticalOverscanSize: 0, + scrollLeft: 0, + scrollTop: 0, + items: [] + }) + }, + + _init: function () { + BI.CanvasCollectionView.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.renderedCells = []; + this.renderedKeys = []; + this._scrollLock = false; + this.scrollTop = this.scrollLeft = 0; + this.summaryScrollTop = this.summaryScrollLeft = 0; + this._debounceRelease = BI.debounce(function () { + self._scrollLock = false; + }, 1000 / 60); + this.canvas = BI.createWidget({ + type: "bi.canvas_new" + }); + $(document).keydown(BI.bind(this._onResize, this)); // 防止在使用ctrl + 滚轮调整窗口大小时触发mousewheel事件 + $(document).keyup(BI.bind(this._onResizeRelease, this)) + this.element.mousewheel(BI.bind(this._onMouseWheel, this)) + BI.createWidget({ + type: "bi.vertical", + element: this, + scrollable: false, + scrolly: false, + scrollx: false, + items: [this.canvas] + }); + if (o.items.length > 0) { + this._calculateSizeAndPositionData(); + this._populate(); + } + if (o.scrollLeft !== 0 || o.scrollTop !== 0) { + BI.nextTick(function () { + self.element.scrollTop(o.scrollTop); + self.element.scrollLeft(o.scrollLeft); + }); + } + }, + + _onMouseWheel: function (e) { + var o = this.options; + if (this._scrollLock) { + return; + } + if (!this._isCtrlPressed) { + o.scrollTop += -e.originalEvent.wheelDelta; + o.scrollTop = BI.clamp(o.scrollTop, 0, this.maxScrollTop); + this._calculateChildrenToRender(); + this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL, { + scrollLeft: o.scrollLeft, + scrollTop: o.scrollTop + }); + } + }, + + _onResize: function (e) { + if (e.ctrlKey) { + this._isCtrlPressed = true; + } else { + this._isCtrlPressed = false; + } + }, + + _onResizeRelease: function (e) { + var Keys = { + CTRL: 17 + }; + var keyCode = e.keyCode; + + if (keyCode === Keys.CTRL) { + this._isCtrlPressed = false; + } + }, + + _getMaxScrollTop: function () { + return this._height - this.options.height + }, + + _calculateSizeAndPositionData: function () { + var o = this.options; + var cellMetadata = []; + var sectionManager = new BI.SectionManager(); + var height = 0; + var width = 0; + + for (var index = 0, len = o.items.length; index < len; index++) { + var cellMetadatum = o.cellSizeAndPositionGetter(index); + + if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || + cellMetadatum.width == null || isNaN(cellMetadatum.width) || + cellMetadatum.x == null || isNaN(cellMetadatum.x) || + cellMetadatum.y == null || isNaN(cellMetadatum.y)) { + throw Error(); + } + + height = Math.max(height, cellMetadatum.y + cellMetadatum.height); + width = Math.max(width, cellMetadatum.x + cellMetadatum.width); + + cellMetadatum.index = index; + cellMetadata[index] = cellMetadatum; + sectionManager.registerCell(cellMetadatum, index); + } + + this._cellMetadata = cellMetadata; + this._sectionManager = sectionManager; + if (this._height === height && this._width === width) { + this._isNeedReset = false; + } else { + this._height = height; + this._width = width; + this._isNeedReset = true; + } + this.maxScrollTop = this._getMaxScrollTop(); + }, + + _cellRenderers: function (height, width, x, y) { + this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); + return this._cellGroupRenderer(); + }, + + _cellGroupRenderer: function () { + var self = this, o = this.options; + var rendered = []; + BI.each(this._lastRenderedCellIndices, function (i, index) { + var cellMetadata = self._sectionManager.getCellMetadata(index); + rendered.push(cellMetadata); + }); + return rendered; + }, + + _calculateChildrenToRender: function () { + var x, y, cellWidth, cellHeight, cellRow, cellCol, value, self = this, o = this.options; + var scrollLeft = o.scrollLeft; + var scrollTop = o.scrollTop; + var left = Math.max(0, scrollLeft - o.horizontalOverscanSize); + var top = Math.max(0, scrollTop - o.verticalOverscanSize); + var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); + var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); + if (right > 0 && bottom > 0) { + var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); + this.canvas.remove(this.scrollLeft, this.scrollTop, o.width, o.height); + for (var i = 0; i < childrenToDisplay.length; i++) { + var datum = childrenToDisplay[i]; + var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; + var rect_tl_x = datum.x, + rect_tl_y = datum.y, + rect_tr_x = rect_tl_x + datum.width, + rect_bl_y = rect_tl_y + datum.height, + cell = o.items[datum.index].cell || o.items[datum.index], + background, color, fontWeight, text; + while (BI.isNull(cell.styles) && !BI.isFunction(cell.styleGetter)) { + cell = cell.cell; + } + if (BI.isNull(cell.styles) && BI.isFunction(cell.styleGetter)) { + background = cell.styleGetter().background; + color = cell.styleGetter().color; + fontWeight = cell.styleGetter().fontWeight; + } else if (!BI.isNull(cell.styles)) { + background = cell.styles.background; + color = cell.styles.color; + fontWeight = cell.styles.fontWeight; + } + if (BI.isNull(cell.text)) { + text = ""; + } else { + text = cell.text; + } + if (!BI.isString(text)) { + text = text.toString(); + } + if (this.scrollLeft !== o.scrollLeft) { + this.canvas.translate(this.scrollLeft - o.scrollLeft, 0); + this.scrollLeft = o.scrollLeft; + } + if (this.scrollTop !== o.scrollTop) { + this.canvas.translate(0, this.scrollTop - o.scrollTop); + this.scrollTop = o.scrollTop; + } + if (datum.x === 0 && datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.x === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tr_x, rect_tl_y, rect_tr_x, rect_bl_y, rect_tl_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else { + this.canvas.solid(rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } + this.canvas.setFontWeight(fontWeight); + this.canvas.setFont(); + var font = this.canvas.getContext().font, + textSize = this._getTextPixel(font), + textHeight = textSize, + textWidth = this.canvas.getContext().measureText(text).width, + dotsWidth = this.canvas.getContext().measureText("...").width; + var offsetX = this._calcOffsetX(textWidth, datum.width, "center"), + offsetY = this._calcOffsetY(textHeight, datum.height, "center"); + if (textHeight > datum.height) { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, "...", color); + } else if (textWidth + 4 > datum.width) { + var sliceIndex = Math.floor((datum.width - dotsWidth - 4) / textWidth * text.length); + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text.slice(0, sliceIndex) + "...", color); + } else { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text, color); + } + this.canvas.stroke(); + } + } + }, + + _getTextPixel: function (font) { + var p = font.split("px")[0], + s = p.split(" "); + for (var c in s) { + var num; + num = BI.parseInt(s[c]); + if (!BI.isNaN(num)) { + return num; + } + } + }, + + _calcOffsetX: function (textWidth, cellWidth, position) { + switch (position) { + case "center": + if (textWidth >= cellWidth) { + return 4; + } else { + return (cellWidth - textWidth) / 2; + } + case "right": + if (textWidth >= cellWidth) { + return 0; + } else { + return cellWidth - textWidth; + } + default: + return 0; + } + }, + + _calcOffsetY: function (textHeight, cellHeight, position) { + switch (position) { + case "center": + if (textHeight >= cellHeight) { + return textHeight; + } else { + return (cellHeight + textHeight) / 2; + } + case "bottom": + if (textHeight >= cellHeight) { + return cellHeight; + } else { + return cellHeight + textHeight; + } + default: + return textHeight; + } + }, + + _populate: function (items) { + var o = this.options; + if (items && items !== this.options.items) { + this.options.items = items; + this._calculateSizeAndPositionData(); + } + if (o.items.length > 0) { + this.canvas.setBlock(); + this.canvas.setWidth(o.width); + this.canvas.setHeight(o.height); + this.restore(); + this._calculateChildrenToRender(); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); + } + }, + + populate: function (items) { + if (items && items !== this.options.items) { + this.restore(); + } + this._populate(items); + }, + + setWidth: function (width) { + BI.CanvasCollectionView.superclass.setWidth.apply(this, arguments); + this.options.width = width; + }, + + setHeight: function (height) { + BI.CanvasCollectionView.superclass.setHeight.apply(this, arguments); + this.options.height = height; + }, + + restore: function () { + this.canvas.remove(this.scrollLeft, this.scrollTop, this.options.width, this.options.height); + this.renderedKeys = []; + this._scrollLock = false; + }, + + setScrollLeft: function (scrollLeft) { + if (this.options.scrollLeft === scrollLeft) { + return; + } + this._scrollLock = true; + this.options.scrollLeft = scrollLeft; + 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 = scrollTop; + this._debounceRelease(); + this._calculateChildrenToRender(); + this.element.scrollTop(this.options.scrollTop); + }, + + getScrollLeft: function () { + return this.options.scrollLeft; + }, + + getScrollTop: function () { + return this.options.scrollTop; + } +}) +BI.CanvasCollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut("bi.canvas_collection_view", BI.CanvasCollectionView);/** + * Created by Shichao on 2017/10/18 + * @class BI.CanvasTable + * @extends BI.Widget + */ +BI.CanvasTable = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection-table", + headerRowSize: 25, + rowSize: 25, + columnSize: [], + isNeedFreeze: false, + freezeCols: [], + isNeedMerge: false, + mergeCols: [], + mergeRule: BI.emptyFn, + header: [], + items: [], + regionColumnSize: [] + }); + }, + + _init: function () { + BI.CanvasTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._scrollBarSize = BI.DOM.getScrollWidth(); + this.topLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topLeftItems[index]; + } + }); + this.topRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topRightItems[index]; + } + }); + this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomLeftItems[index]; + } + }); + this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollTop(scroll.scrollTop); + self.topLeftCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomRightItems[index]; + } + }); + this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomLeftCollection.setScrollTop(scroll.scrollTop); + self.topRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.topLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topLeftCollection] + }); + this.topRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topRightCollection] + }); + this.bottomLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomLeftCollection] + }); + this.bottomRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomRightCollection] + }); + this.contextLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topLeft, + top: 0, + left: 0, + }, { + el: this.topRight, + top: 0 + }, { + el: this.bottomLeft, + left: 0 + }, { + el: this.bottomRight, + }] + }); + + this.topScrollbar = BI.createWidget({ + type: "bi.grid_table_scrollbar", + width: BI.GridTableScrollbar.SIZE + }); + this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollTop) { + self.bottomLeftCollection.setScrollTop(scrollTop); + self.bottomRightCollection.setScrollTop(scrollTop); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.leftScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topLeftCollection.setScrollLeft(scrollLeft); + self.bottomLeftCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.rightScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topRightCollection.setScrollLeft(scrollLeft); + self.bottomRightCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.scrollBarLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topScrollbar, + right: 0, + top: 0 + }, { + el: this.leftScrollbar, + left: 0, + }, { + el: this.rightScrollbar, + }] + }); + this._width = o.width - BI.GridTableScrollbar.SIZE; + this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; + if (o.items.length > 0 || o.header.length > 0) { + this._digest(); + this._populate(); + } + }, + + attr: function () { + BI.CanvasTable.superclass.attr.apply(this, arguments); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; + }, + + getRegionSize: function () { + var o = this.options; + var regionSize = o.regionColumnSize[0] || 0; + if (o.isNeedFreeze === false || o.freezeCols.length === 0) { + return 0; + } + if (!regionSize) { + BI.each(o.freezeCols, function (i, col) { + regionSize += o.columnSize[col]; + }); + } + return regionSize; + }, + + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + + _digest: function () { + var o = this.options; + var freezeColLength = this._getFreezeColLength(); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } + }, + + _populateScrollbar: function () { + var o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + BI.each(o.columnSize, function (i, size) { + if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { + totalLeftColumnSize += size; + } else { + totalRightColumnSize += size; + } + totalColumnSize += size; + if (i === 0) { + summaryColumnSizeArray[i] = size; + } else { + summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; + } + }); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); + this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); + this.topScrollbar.populate(); + + this.leftScrollbar.setContentSize(totalLeftColumnSize); + this.leftScrollbar.setSize(regionSize); + this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft()); + this.leftScrollbar.populate(); + + this.rightScrollbar.setContentSize(totalRightColumnSize); + this.rightScrollbar.setSize(this._width - regionSize); + this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft()); + this.rightScrollbar.populate(); + + var items = this.scrollBarLayout.attr("items"); + items[0].top = this._getFreezeHeaderHeight(); + items[1].top = this._height; + items[2].top = this._height; + items[2].left = regionSize; + this.scrollBarLayout.attr("items", items); + this.scrollBarLayout.resize(); + }, + + _populateTable: function () { + var self = this, o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + var freezeColLength = this._getFreezeColLength(); + var otlw = regionSize; + var otlh = this._getFreezeHeaderHeight(); + var otrw = this._width - regionSize; + var otrh = this._getFreezeHeaderHeight(); + var oblw = regionSize; + var oblh = this._height - otlh; + var obrw = this._width - regionSize; + var obrh = this._height - otrh; + + var tlw = otlw + this._scrollBarSize; + var tlh = otlh + this._scrollBarSize; + var trw = otrw + this._scrollBarSize; + var trh = otrh + this._scrollBarSize; + var blw = oblw + this._scrollBarSize; + var blh = oblh + this._scrollBarSize; + var brw = obrw + this._scrollBarSize; + var brh = obrh + this._scrollBarSize; + + this.topLeft.setWidth(otlw); + this.topLeft.setHeight(otlh); + this.topRight.setWidth(otrw); + this.topRight.setHeight(otrh); + this.bottomLeft.setWidth(oblw); + this.bottomLeft.setHeight(oblh); + this.bottomRight.setWidth(obrw); + this.bottomRight.setHeight(obrh); + + this.topLeftCollection.setWidth(tlw); + this.topLeftCollection.setHeight(tlh); + this.topRightCollection.setWidth(trw); + this.topRightCollection.setHeight(trh); + this.bottomLeftCollection.setWidth(blw); + this.bottomLeftCollection.setHeight(blh); + this.bottomRightCollection.setWidth(brw); + this.bottomRightCollection.setHeight(brh); + + var items = this.contextLayout.attr("items"); + items[1].left = regionSize; + //items[2].top = this._getFreezeHeaderHeight(); + items[2].top = otrh; + items[3].left = regionSize; + //items[3].top = this._getFreezeHeaderHeight(); + items[3].top = otrh; + this.contextLayout.attr("items", items); + this.contextLayout.resize(); + + var leftHeader = [], rightHeader = [], leftItems = [], rightItems = []; + var run = function (positions, items, rendered) { + BI.each(positions, function (i, item) { + if (BI.isNull(items[item.row][item.col])) { + debugger + } + rendered.push(items[item.row][item.col]); + }); + }; + run(this.topLeftItems, o.header, leftHeader); + run(this.topRightItems, o.header, rightHeader); + run(this.bottomLeftItems, o.items, leftItems); + run(this.bottomRightItems, o.items, rightItems); + + this.topLeftCollection._populate(leftHeader); + this.topRightCollection._populate(rightHeader); + this.bottomLeftCollection._populate(leftItems); + this.bottomRightCollection._populate(rightItems); + }, + + _populate: function () { + if (this._width <= 0 || this._height <= 0) { + return; + } + if (this._isNeedDigest === true) { + this._digest(); + } + this._isNeedDigest = false; + this._populateTable(); + this._populateScrollbar(); + }, + + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; + var self = this, o = this.options; + var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; + var summaryColumnSize = []; + for (var i = startCol; i < endCol; i++) { + if (i === startCol) { + summaryColumnSize[i] = columnSize[i]; + } else { + summaryColumnSize[i] = summaryColumnSize[i - 1] + columnSize[i]; + } + } + var mergeRow = function (i, j) { + preCol[j]._height += rowHeight; + preCol[j].__mergeRows.push(i); + }; + + var mergeCol = function (i, j) { + preRow[i]._width += columnSize[j]; + preRow[i].__mergeCols.push(j); + }; + + var createOneEl = function (r, c) { + var width = columnSize[c]; + var height = rowHeight; + map[r][c]._row = r; + map[r][c]._col = c; + map[r][c]._width = width; + map[r][c]._height = height; + preCol[c] = map[r][c]; + preCol[c].__mergeRows = [r]; + preRow[r] = map[r][c]; + preRow[r].__mergeCols = [c]; + + result.push({ + x: summaryColumnSize[c] - columnSize[c], + y: +r * rowHeight, + item: map[r][c] + }); + }; + + BI.each(items, function (i, cols) { + for (var j = startCol; j < endCol; j++) { + if (!cache[i]) { + cache[i] = {}; + } + if (!map[i]) { + map[i] = {}; + } + cache[i][j] = cols[j]; + map[i][j] = {}; + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { + if (i === 0 && j === startCol) { + createOneEl(0, startCol); + } else if (j === startCol && i > 0) { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + if (isNeedMergeRow === true) { + mergeRow(i, j); + preRow[i] = preCol[j]; + } else { + createOneEl(i, j); + } + } else if (i === 0 && j > startCol) { + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol === true) { + mergeCol(i, j); + preCol[j] = preRow[i]; + } else { + createOneEl(i, j); + } + } else { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol && isNeedMergeRow) { + continue; + //mergeRow(i, j);//优先合并列 + } + if (isNeedMergeCol) { + mergeCol(i, j); + } + if (isNeedMergeRow) { + mergeRow(i, j); + } + if (!isNeedMergeCol && !isNeedMergeRow) { + createOneEl(i, j); + } + } + } else { + createOneEl(i, j); + } + } + }); + return BI.map(result, function (i, item) { + return { + x: item.x, + y: item.y, + row: item.item._row, + col: item.item._col, + width: item.item._width, + height: item.item._height + } + }); + }, + + populate: function (items, header) { + if (items && this.options.items !== items) { + this._isNeedDigest = true; + this.options.items = items; + this._restore(); + } + if (header && this.options.header !== header) { + this._isNeedDigest = true; + this.options.header = header; + this._restore(); + } + this._populate(); + }, + + _restore: function () { + this.topLeftCollection.restore(); + this.topRightCollection.restore(); + this.bottomLeftCollection.restore(); + this.bottomRightCollection.restore(); + }, + + restore: function () { + this._restore(); + }, + + setWidth: function (width) { + BI.CanvasTable.superclass.setWidth.apply(this, arguments); + this._width = width - BI.GridTableScrollbar.SIZE; + }, + + setHeight: function (height) { + BI.CanvasTable.superclass.setHeight.apply(this, arguments); + this._height = height - BI.GridTableScrollbar.SIZE; + }, + + setVerticalScroll: function (scrollTop) { + this.bottomLeftCollection.setScrollTop(scrollTop); + this.bottomRightCollection.setScrollTop(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.topLeftCollection.setScrollLeft(scrollLeft); + this.bottomLeftCollection.setScrollLeft(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.topRightCollection.setScrollLeft(scrollLeft); + this.bottomRightCollection.setScrollLeft(scrollLeft); + }, + + getVerticalScroll: function () { + return this.bottomRightCollection.getScrollTop(); + }, + + getLeftHorizontalScroll: function () { + return this.bottomLeftCollection.getScrollLeft(); + }, + + getRightHorizontalScroll: function () { + return this.bottomRightCollection.getScrollLeft(); + }, + + setColumnSize: function (columnSize) { + this._isNeedDigest = true; + this.options.columnSize = columnSize; + }, + + setRegionColumnSize: function (regionColumnSize) { + this._isNeedDigest = true; + this.options.regionColumnSize = regionColumnSize; + }, + + getColumnSize: function () { + return this.options.columnSize; + }, + + getRegionColumnSize: function () { + return this.options.regionColumnSize; + }, +}); + +BI.shortcut("bi.canvas_table", BI.CanvasTable);/** + * 日期控件中的月份下拉框 + * + * 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: 25 + }); + }, + _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" + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + 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); + }); + }, + + setValue: function(v){ + this.trigger.setValue(v + 1); + 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', //最大日期 + height: 25 + }); + }, + _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", + 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, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + }, + + 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 bi-background", + height: 25, + 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 = new Date().getFullYear(); + this._month = new Date().getMonth(); + 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 () { + if (self._month === 0) { + self.setValue({ + year: self.year.getValue() - 1, + month: 11 + }) + } 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: 25, + height: 25 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 11) { + self.setValue({ + year: self.year.getValue() + 1, + month: 0 + }) + } 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", + 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" + }); + 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: this.left, + width: 25 + }, { + type: "bi.center_adapt", + items: [{ + type: "bi.horizontal", + width: 100, + items: [this.year, this.month] + }] + }, { + el: this.right, + width: 25 + }] + }) + this.setValue({ + year: this._year, + month: this._month + }) + }, + + _checkLeftValid: function () { + var o = this.options; + var valid = !(this._month === 0 && this._year === Date.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); + this.left.setEnable(valid); + return valid; + }, + + _checkRightValid: function () { + var o = this.options; + var valid = !(this._month === 11 && this._year === Date.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); + this.right.setEnable(valid); + return valid; + }, + + + + setValue: function (ob) { + this._year = ob.year; + this._month = 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.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 = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + 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", + min: o.min, + max: o.max + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + 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); + }); + }, + + 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);/** + * 日期控件中的年份或月份trigger + * + * Created by GUY on 2015/9/7. + * @class BI.DateTriangleTrigger + * @extends BI.Trigger + */ +BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { + _const: { + height: 25, + iconWidth: 16, + iconHeight: 13 + }, + + _defaultConfig: function() { + return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", + height: 25 + }); + }, + _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 + }) + this.icon = BI.createWidget({ + type: "bi.icon", + width: c.iconWidth, + height: c.iconHeight + }); + + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [{ + type: "bi.center_adapt", + width: 50, + height: c.height, + items: [this.text, this.icon] + }] + }) + }, + + 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 GUY on 2015/9/7. + * @class BI.DateCombo + * @extends BI.Widget + */ +BI.DateCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-combo bi-border", + height: 25 + }); + }, + _init: function () { + BI.DateCombo.superclass._init.apply(this, arguments); + var self = this, + o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_trigger" + }); + + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + + this.popup = BI.createWidget({ + type: "bi.date_calendar_popup" + }); + + this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + width: 270, + el: this.popup, + stopPropagation: false + } + }) + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + yearLength: 4, + yearMonthLength: 7 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.DateTrigger.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) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ + year: date[0], + month: date[1], + day: date[2] + }); + }, + 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"); + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DateTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DateTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DateTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DateTrigger.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)) { + var date = value.split("-"); + self.store_value = { + type: BI.DateTrigger.MULTI_DATE_CALENDAR, + value:{ + year: date[0] | 0, + month: date[1] - 1, + day: date[2] | 0 + } + }; + } + self.fireEvent(BI.DateTrigger.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.DateTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: 30 + }, { + el: this.editor + }] + }) + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + var self = this; + var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + var yearCheck = function (v) { + return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; + }; + var monthCheck = function (v) { + return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; + }; + if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + if (monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = new Date(); + this.store_value = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; + if(BI.isNull(value)){ + value = v; + } + } + var _setInnerValue = function (date, text) { + var dateStr = date.print("%Y-%x-%e"); + self.editor.setState(dateStr); + self.editor.setValue(dateStr); + self.setTitle(text + ":" + dateStr); + }; + switch (type) { + case BI.DateTrigger.MULTI_DATE_YEAR_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; + date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; + date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; + date = new Date(date.getFullYear(), 0, 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; + date = new Date(date.getFullYear(), 11, 31); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; + date = new Date().getBeforeMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; + date = new Date().getAfterMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; + date = new Date().getQuarterStartDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; + date = new Date().getQuarterEndDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; + date = new Date().getBeforeMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; + date = new Date().getAfterMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; + date = new Date(date.getFullYear(), date.getMonth(), 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; + date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; + date = date.getOffsetDate(-7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; + date = date.getOffsetDate(7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; + date = date.getOffsetDate(-1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; + date = date.getOffsetDate(1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_TODAY: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; + date = new Date(); + _setInnerValue(date, text); + break; + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + this.setTitle(""); + } else { + var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + this.setTitle(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.store_value; + } + +}); + +BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; +BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; +BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; +BI.DateTrigger.MULTI_DATE_YEAR_END = 4; + +BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; +BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; +BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; +BI.DateTrigger.MULTI_DATE_MONTH_END = 8; + +BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; +BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; +BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; +BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; + +BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; +BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; + +BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; +BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; +BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; + +BI.DateTrigger.MULTI_DATE_PARAM = 18; +BI.DateTrigger.MULTI_DATE_CALENDAR = 19; + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); + +BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DateTrigger.EVENT_START = "EVENT_START"; +BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.date_trigger", BI.DateTrigger);/** + * Created by zcf on 2017/2/20. + */ +BI.DatePaneWidget = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePaneWidget.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.DatePaneWidget.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + 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 = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: false + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + + // afterCardCreated: function () { + // + // }, + // + // afterCardShow: function () { + // // this.setValue(self.selectedTime); + // } + }); + 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); + }); + + }, + + _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 = new Date(); + return { + year: today.getFullYear(), + month: today.getMonth() + } + }, + + _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.date_pane", BI.DatePaneWidget);/** + * 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', + width: 200, + height: 24 + }); + }, + _init: function () { + BI.DateTimeCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + var date = new Date(); + this.storeValue = { + year: date.getFullYear(), + month: date.getMonth(), + 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 + }); + + this.popup = BI.createWidget({ + type: "bi.date_time_popup", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_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.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () { + self.trigger.setValue(self.popup.getValue()); + self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE); + }); + this.combo = BI.createWidget({ + type: 'bi.combo', + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + maxHeight: this.constants.popupHeight, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + 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 bi-border-right", + width: 30, + height: 24 + }); + triggerBtn.on(BI.TriggerIconButton.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, + left: 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: 290 + }); + }, + _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", + min: self.options.min, + max: self.options.max + }); + self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + }); + + this.dateSelect = BI.createWidget({ + type: "bi.vertical_adapt", + cls: "bi-border-top", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Basic_Time"), + width: 45 + }, { + type: "bi.date_time_select", + max: 23, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.hour = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.minute = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.second = _ref; + } + }] + }); + + var date = new Date(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.cancelButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateCombo + }, { + el: this.dateSelect, + height: 50 + }, { + el: this.dateButton, + height: 30 + }] + }); + }, + + setValue: function (v) { + var value = v, date; + if (BI.isNull(value)) { + date = new Date(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + } else { + this.dateCombo.setValue({ + year: value.year, + month: value.month, + day: value.day + }); + this.hour.setValue(value.hour); + this.minute.setValue(value.minute); + this.second.setValue(value.second); + } + }, + + getValue: function () { + return { + year: this.dateCombo.getValue().year, + month: this.dateCombo.getValue().month, + day: this.dateCombo.getValue().day, + hour: this.hour.getValue(), + minute: this.minute.getValue(), + second: this.second.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.DateTimeSelect = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-time-select bi-border", + max: 23, + min: 0 + }) + }, + + _init: function () { + BI.DateTimeSelect.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.min), + allowBlank: false, + errorText: BI.i18nText("BI-Please_Input_Natural_Number"), + validationChecker: function(v){ + return BI.isNaturalNumber(v); + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ + self._finetuning(0); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-next-page-h-font bottom-button bi-border-left" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(-1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + 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: 30 + }] + }); + }, + + _alertOutEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max + } + return BI.parseInt(v); + }, + + _alertInEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max; + } + v = v < 10 ? "0" + v : v; + return v; + }, + + _finetuning: function(add){ + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + triggerWidth: 30 + }, + + _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: BI.createWidget(), + width: c.triggerWidth + }, { + el: this.text + }] + }) + }, + + _printTime: function (v) { + return v < 10 ? "0" + v : v; + }, + + setValue: function (v) { + var self = this; + var value = v, dateStr; + if(BI.isNull(value)){ + value = new Date(); + dateStr = value.print("%Y-%X-%d %H:%M:%S"); + } else { + var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second); + dateStr = date.print("%Y-%X-%d %H:%M:%S"); + + } + this.text.setText(dateStr); + this.text.setTitle(dateStr); + } + +}); +BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/** + * 带有方向的pathchooser + * + * Created by GUY on 2016/4/21. + * @class BI.DirectionPathChooser + * @extends BI.Widget + */ +BI.DirectionPathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#808080", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + items: [] + }); + }, + + _init: function () { + BI.DirectionPathChooser.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.pathChooser = BI.createWidget({ + type: "bi.path_chooser", + element: this, + items: o.items + }); + this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { + //self._unselectAllArrows(); + self._setValue(start, index); + self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); + }); + this._drawArrows(); + + }, + + _unselectAllArrows: function () { + var self = this, lineColor = this._const.lineColor; + BI.each(this.arrows, function (region, rs) { + BI.each(rs, function (idx, arrows) { + BI.each(arrows, function (i, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}); + }); + }); + }); + }, + + _drawOneArrow: function (dot, direction) { + //0,1,2,3 上右下左 + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var svg = this.pathChooser.svg; + var path = ""; + switch (direction) { + case 0: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y + 5) + + "L" + (dot.x + 3) + "," + (dot.y + 5) + + "L" + dot.x + "," + dot.y; + break; + case 1: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 5) + "," + (dot.y - 3) + + "L" + (dot.x - 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + case 2: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y - 5) + + "L" + (dot.x + 3) + "," + (dot.y - 5) + + "L" + dot.x + "," + dot.y; + break; + case 3: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x + 5) + "," + (dot.y - 3) + + "L" + (dot.x + 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + } + return svg.path(path).attr({fill: lineColor, stroke: lineColor}); + }, + + _drawArrows: function () { + var self = this, o = this.options; + var routes = this.pathChooser.routes; + var pathes = this.pathChooser.pathes; + var store = this.pathChooser.store; + this.arrows = {}; + BI.each(routes, function (region, ps) { + self.arrows[region] = []; + BI.each(ps, function (idx, path) { + self.arrows[region][idx] = []; + var dots = pathes[region][idx]; + BI.each(dots, function (i, dot) { + if (i > 0 && i < dots.length - 1) { + var arrow; + if (dot.y === dots[i - 1].y) { + if (dots[i + 1].y != dot.y) { + if (store[path[path.length - 2]].direction === -1) { + if (i - 1 > 0) { + arrow = self._drawOneArrow(dots[i - 1], 3); + } + } else { + arrow = self._drawOneArrow(dots[i], 1); + } + } + } else if (dot.x === dots[i - 1].x) { + if (dot.y > dots[i - 1].y) { + if (store[BI.first(path)].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 0); + } else { + arrow = self._drawOneArrow(dot, 2); + } + } else { + if (store[path[path.length - 2]].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 2); + } else { + arrow = self._drawOneArrow(dot, 0); + } + } + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + BI.each(path, function (i, node) { + if (i !== 0) { + var arrow; + var from = path[i - 1]; + if (store[from].direction === -1) { + var regionIndex = self.pathChooser.getRegionIndexById(from); + var x = getXoffsetByRegionIndex(regionIndex, -1); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 3); + } else { + var regionIndex = self.pathChooser.getRegionIndexById(node); + var x = getXoffsetByRegionIndex(regionIndex); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 1); + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + }) + }); + + function getXoffsetByRegionIndex(regionIndex, diregion) { + if (diregion === -1) { + return 100 * (regionIndex + 1) - 20; + } + return 100 * regionIndex + 20; + } + + function getYByXoffset(dots, xoffset) { + var finded = BI.find(dots, function (i, dot) { + if (i > 0) { + if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { + return true; + } + } + }); + return finded.y; + } + }, + + _setValue: function (start, index) { + var self = this; + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var routes = this.pathChooser.routes; + var starts = this.pathChooser.start; + var each = [start]; + if (starts.contains(start)) { + each = starts; + } + BI.each(each, function (i, s) { + BI.each(self.arrows[s], function (j, arrows) { + BI.each(arrows, function (k, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); + }); + }); + }); + BI.each(this.arrows[start][index], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + var current = BI.last(routes[start][index]); + while (current && routes[current] && routes[current].length === 1) { + BI.each(self.arrows[current][0], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + current = BI.last(routes[current][0]); + } + }, + + setValue: function (v) { + this.pathChooser.setValue(v); + this._unselectAllArrows(); + var routes = this.pathChooser.routes; + var nodes = BI.keys(routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + self._setValue(start, index); + } + }); + }, + + getValue: function () { + return this.pathChooser.getValue(); + }, + + populate: function (items) { + this.pathChooser.populate(items); + this._drawArrows(); + } +}); +BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; +BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** + * 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", + invalid: false, + height: 25, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + 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 + }); + + 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, + adjustLength: o.adjustLength, + direction: o.direction, + 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 () { + this.downlistcombo.showView(); + }, + + 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 + }] + }); + 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.Single, { + _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: 25, + 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.icon_text_item", + element: this, + height: o.height, + text: o.text, + value: o.value, + logic: o.logic, + selected: o.selected, + disabled: o.disabled, + iconHeight: o.iconHeight, + iconWidth: o.iconWidth, + textHgap: o.textHgap, + textVgap: o.textVgap, + textLgap: o.textLgap, + textRgap: o.textRgap, + father: o.father + }); + this.text.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { + self.fireEvent(BI.DownListItem.EVENT_CHANGE); + }); + // this.setSelected(o.selected); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + isSelected: function () { + return this.text.isSelected(); + }, + + setSelected: function (b) { + this.text.setSelected(b); + // if (b === true) { + // this.element.addClass("dot-e-font"); + // } else { + // this.element.removeClass("dot-e-font"); + // } + }, + + setValue: function (v) { + this.text.setValue(v); + }, + + getValue: function () { + return this.text.getValue(); + } +}); +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: 25, + forceNotSelected: true + }); + + this.icon2 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls2, + width: 25, + forceNotSelected: true + }); + + var blank = BI.createWidget({ + type: "bi.layout", + width: 25 + }); + 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() + } + }); + }, + + 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) { + var self = this, o = this.options; + v = BI.isArray(v) ? v : [v]; + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { + self.icon1.setSelected(true); + return true; + } else { + self.icon1.setSelected(false); + } + }) + } +}); +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: 25, + 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 = {}; + var self = this, o = this.options, children = this._createChildren(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 + }], + 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 (!self.singleValues.contains(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] + }); + + }, + _createChildren: 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: 4, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + } + }; + 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-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 10 + }); + 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 + }, + + populate: function (items) { + BI.DownListPopup.superclass.populate.apply(this, arguments); + var self = this; + self.childValueMap = {}; + self.fatherValueMap = {}; + self.singleValues = []; + var children = self._createChildren(items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + self.popup.populate(popupItem); + }, + + setValue: 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); + } + ); + this.popup.setValue(valueArray); + }, + + getValue: function () { + var self = this, result = []; + var values = this.popup.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 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", + height: 30, + 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, + errorText: o.errorText, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker + }); + 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.SearchEditor.EVENT_CLEAR); + }); + BI.createWidget({ + element: this, + type: "bi.htape", + items: [ + { + el: { + type: "bi.center_adapt", + cls: "search-font", + items: [{ + el: { + type: "bi.icon" + } + }] + }, + width: 25 + }, + { + el: self.editor + }, + { + el: this.clear, + width: 25 + } + ] + }); + 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]; + } + }, + + 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: 24 + }); + }, + + _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", + hgap: 4, + vgap: 2, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn, + allowBlank: false, + watermark: "", + errorText: "", + height: 30 + }) + }, + + _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: 25 + }); + }, + + _init: function () { + BI.SmallTextEditor.superclass._init.apply(this, arguments); + } +}); +BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** + * 文件管理控件组 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerButtonGroup + * @extends BI.Widget + */ +BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-button_group", + items: [] + }) + }, + + _init: function () { + BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.button_group = BI.createWidget({ + type: "bi.button_tree", + element: this, + chooseType: BI.Selection.Multi, + items: this._formatItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _formatItems: function (items) { + var self = this, o = this.options; + BI.each(items, function (i, item) { + if (item.children && item.children.length > 0) { + item.type = "bi.file_manager_folder_item"; + } else { + item.type = "bi.file_manager_file_item"; + } + }); + return items; + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getNotSelectedValue: function () { + return this.button_group.getNotSelectedValue(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + populate: function (items) { + this.button_group.populate(this._formatItems(items)); + } +}); +BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManager + * @extends BI.Widget + */ +BI.FileManager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + var items = BI.Tree.transformToTreeFormat(o.items); + this.tree.initTree(items); + this.selectedValues = []; + this.nav = BI.createWidget({ + type: "bi.file_manager_nav", + items: BI.deepClone(items) + }); + this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { + if (value == "-1") {//根节点 + self.populate({children: self.tree.toJSON()}); + } else { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } + self.setValue(self.selectedValues); + }); + this.list = BI.createWidget(o.el, { + type: "bi.file_manager_list", + items: items + }); + this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { + if (type === BI.Events.CHANGE) { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } else if (type === BI.Events.CLICK) { + var values = []; + if (obj instanceof BI.MultiSelectBar) { + var t = self.list.getValue(); + selected = t.type === BI.Selection.All; + values = BI.concat(t.assist, t.value); + } else { + values = obj.getAllLeaves(); + } + BI.each(values, function (i, v) { + if (selected === true) { + self.selectedValues.pushDistinct(v); + } else { + self.selectedValues.remove(v); + } + }); + } + self.setValue(self.selectedValues); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.list, + left: 0, + right: 0, + top: 0, + bottom: 10 + }, { + el: this.nav, + left: 40, + right: 100, + top: 0 + }] + }); + }, + + setValue: function (value) { + this.selectedValues = value || []; + this.list.setValue(this.selectedValues); + }, + + getValue: function () { + var obj = this.list.getValue(); + var res = obj.type === BI.Selection.All ? obj.assist : obj.value; + res.pushDistinctArray(this.selectedValues); + return res; + }, + + _populate: function (items) { + this.list.populate(items); + }, + + getSelectedValue: function () { + return this.nav.getValue()[0]; + }, + + getSelectedId: function () { + return this.nav.getId()[0]; + }, + + populate: function (node) { + var clone = BI.deepClone(node); + this._populate(node.children); + this.nav.populate(clone); + } +}); +BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; +BI.shortcut("bi.file_manager", BI.FileManager);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFileItem + * @extends BI.Single + */ +BI.FileManagerFileItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFileItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-file-font" + }, + width: 20 + }, { + el: { + type: "bi.label", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + } + }] + }) + }, + + getAllLeaves: function(){ + return [this.options.value]; + }, + + isSelected: function () { + return this.checked.isSelected(); + }, + + setSelected: function (v) { + this.checked.setSelected(v); + } +}); +BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFolderItem + * @extends BI.Single + */ +BI.FileManagerFolderItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFolderItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button = BI.createWidget({ + type: "bi.text_button", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); + }); + + this.tree = new BI.Tree(); + this.tree.initTree([{ + id: o.id, + children: o.children + }]); + this.selectValue = []; + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-folder-font" + }, + width: 20 + }, { + el: this.button + }] + }) + }, + + setAllSelected: function (v) { + this.checked.setSelected(v); + this.selectValue = []; + }, + + setHalfSelected: function (v) { + this.checked.setHalfSelected(v); + if(!v){ + this.selectValue = []; + } + }, + + setValue: function (v) { + var self = this, o = this.options; + var isHalf = false; + var selectValue = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + if (BI.contains(v, node.get("data").value)) { + selectValue.push(node.get("data").value); + } else { + isHalf = true; + } + } + }); + this.setAllSelected(selectValue.length > 0 && !isHalf); + this.setHalfSelected(selectValue.length > 0 && isHalf); + if (this.checked.isHalfSelected()) { + this.selectValue = selectValue; + } + }, + + getAllButtons: function () { + return [this]; + }, + + getAllLeaves: function () { + var o = this.options; + var res = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value) + } + }); + return res; + }, + + getNotSelectedValue: function () { + var self = this, o = this.options; + var res = []; + var isAllSelected = this.checked.isSelected(); + if (isAllSelected === true) { + return res; + } + var isHalfSelected = this.checked.isHalfSelected(); + this.tree.traverse(function (node) { + if (node.isLeaf()) { + var v = node.get("data").value; + if (isHalfSelected === true) { + if (!BI.contains(self.selectValue, node.get("data").value)) { + res.push(v); + } + } else { + res.push(v); + } + } + }); + return res; + }, + + getValue: function () { + var res = []; + if (this.checked.isSelected()) { + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + } + if (this.checked.isHalfSelected()) { + return this.selectValue; + } + return []; + } +}); +BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** + * 文件管理控件列表 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerList + * @extends BI.Widget + */ +BI.FileManagerList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-list", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManagerList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.select_list", + element: this, + items: o.items, + toolbar: { + type: "bi.multi_select_bar", + height: 40, + text: "" + }, + el: { + type: "bi.list_pane", + el: BI.isWidget(o.el) ? o.el : BI.extend({ + type: "bi.file_manager_button_group" + }, o.el) + } + }); + this.list.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + this.list.setValue({ + value: v + }); + }, + + getValue: function () { + return this.list.getValue(); + }, + + populate: function (items) { + this.list.populate(items); + this.list.setToolBarVisible(true); + } +}); +BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** + * 文件管理导航按钮 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNavButton + * @extends BI.Widget + */ +BI.FileManagerNavButton = BI.inherit(BI.Widget, { + + _const: { + normal_color: "#ffffff", + select_color: "#eff1f4" + }, + _defaultConfig: function () { + return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav-button", + selected: false, + height: 40 + }) + }, + + _init: function () { + BI.FileManagerNavButton.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.button = BI.createWidget({ + type: "bi.text_button", + cls: "file-manager-nav-button-text bi-card", + once: true, + selected: o.selected, + text: o.text, + title: o.text, + value: o.value, + height: o.height, + lgap: 20, + rgap: 10 + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + var svg = BI.createWidget({ + type: "bi.svg", + cls: "file-manager-nav-button-triangle", + width: 15, + height: o.height + }); + var path = svg.path("M0,0L15,20L0,40").attr({ + "stroke": c.select_color, + "fill": o.selected ? c.select_color : c.normal_color + }); + this.button.on(BI.TextButton.EVENT_CHANGE, function () { + if (this.isSelected()) { + path.attr("fill", c.select_color); + } else { + path.attr("fill", c.normal_color); + } + }); + BI.createWidget({ + type: "bi.default", + element: this, + items: [this.button] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: svg, + right: -15, + top: 0, + bottom: 0 + }] + }) + }, + + isSelected: function () { + return this.button.isSelected(); + }, + + setValue: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + return this.button.getValue(); + }, + + populate: function (items) { + + } +}); +BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** + * 文件管理导航 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNav + * @extends BI.Widget + */ +BI.FileManagerNav = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav bi-border-left", + height: 40, + items: [] + }) + }, + + _init: function () { + BI.FileManagerNav.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + this.refreshTreeData(o.items); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: [{ + type: "bi.file_manager_nav_button", + text: BI.i18nText("BI-Created_By_Me"), + selected: true, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME, + value: BI.FileManagerNav.ROOT_CREATE_BY_ME + }], + layouts: [{ + type: "bi.horizontal" + }] + }); + 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.FileManagerNav.EVENT_CHANGE, arguments); + }); + }, + + _getAllParents: function (id) { + var node, res = []; + if (!id) { + node = this.tree.getRoot(); + } else { + node = this.tree.search(id); + } + while (node.parent) { + res.push(node); + node = node.parent; + } + res.push(node); + return res.reverse(); + }, + + _formatNodes: function (nodes) { + var res = []; + BI.each(nodes, function (i, node) { + res.push(BI.extend({ + type: "bi.file_manager_nav_button", + id: node.id + }, node.get("data"))); + }); + BI.last(res).selected = true; + return res; + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getId: function () { + var ids = []; + BI.each(this.button_group.getSelectedButtons(), function (i, btn) { + ids.push(btn.attr("id")); + }); + return ids; + }, + + refreshTreeData: function(items){ + this.tree.initTree(BI.Tree.transformToTreeFormat(items)); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + }, + + populate: function (node) { + var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); + this.button_group.populate(this._formatNodes(parents)); + } +}); +BI.extend(BI.FileManagerNav, { + ROOT_CREATE_BY_ME: "-1" +}); +BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** + * 交互行为布局 + * + * + * Created by GUY on 2016/7/23. + * @class BI.InteractiveArrangement + * @extends BI.Widget + */ +BI.InteractiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-interactive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.InteractiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + element: this, + resizable: o.resizable, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); + }); + + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { + var p = self._getRegionClientPosition(id); + self.draw({ + left: p.left, + top: p.top + }, size, id); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { + self.stopDraw(); + self.setRegionSize(id, size); + }); + + this.tags = []; + + }, + + _isEqual: function (num1, num2) { + return this.arrangement._isEqual(num1, num2); + }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + _positionAt: function (position, regions) { + var self = this; + regions = regions || this.getAllRegions(); + var left = [], center = [], right = [], top = [], middle = [], bottom = []; + BI.each(regions, function (i, region) { + var client = self._getRegionClientPosition(region.id); + if (Math.abs(client.left - position.left) <= 3) { + left.push(region); + } + if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { + center.push(region); + } + if (Math.abs(client.left + client.width - position.left) <= 3) { + right.push(region); + } + if (Math.abs(client.top - position.top) <= 3) { + top.push(region); + } + if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { + middle.push(region); + } + if (Math.abs(client.top + client.height - position.top) <= 3) { + bottom.push(region); + } + }); + return { + left: left, + center: center, + right: right, + top: top, + middle: middle, + bottom: bottom + } + }, + + _getRegionClientPosition: function (name) { + var region = this.getRegionByName(name); + var offset = this.arrangement._getScrollOffset(); + return { + top: region.top - offset.top, + left: region.left - offset.left, + width: region.width, + height: region.height, + id: region.id + } + }, + + _vAlign: function (position, regions) { + var self = this; + var vs = this._positionAt(position, regions); + var positions = []; + var l; + if (vs.left.length > 0) { + l = this._getRegionClientPosition(vs.left[0].id).left; + } else if (vs.right.length > 0) { + var temp = this._getRegionClientPosition(vs.right[0].id); + l = temp.left + temp.width; + } else if (vs.center.length > 0) { + var temp = this._getRegionClientPosition(vs.center[0].id); + l = temp.left + temp.width / 2; + } + var rs = vs.left.concat(vs.right).concat(vs.center); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l) || self._isEqual(p.left + p.width / 2, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: l + }; + positions.push({ + id: region.id, + start: topPoint, + end: { + left: l, + top: position.top + } + }); + } + }); + return positions; + }, + + _leftAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left, + top: position.top + size.height / 2 + }, regions); + }, + + _rightAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width, + top: position.top + size.height / 2 + }, regions); + }, + + _hAlign: function (position, regions) { + var self = this; + var hs = this._positionAt(position, regions); + var positions = []; + var t; + if (hs.top.length > 0) { + var temp = this._getRegionClientPosition(hs.top[0].id); + t = temp.top; + } else if (hs.bottom.length > 0) { + var temp = this._getRegionClientPosition(hs.bottom[0].id); + t = temp.top + temp.height; + } else if (hs.middle.length > 0) { + var temp = this._getRegionClientPosition(hs.middle[0].id); + t = temp.top + temp.height / 2; + } + var rs = hs.top.concat(hs.bottom).concat(hs.middle); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t) || self._isEqual(p.top + p.height / 2, t)) { + var leftPoint = { + top: t, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: leftPoint, + end: { + left: position.left, + top: t + } + }); + } + }); + return positions; + }, + + _topAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + }, regions); + }, + + _bottomAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height + }, regions); + }, + + _centerAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + }, + + _middleAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + }, + + + _drawOneTag: function (start, end) { + var s = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + var e = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + if (this._isEqual(start.left, end.left)) { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + width: 1, + height: Math.abs(start.top - end.top) + }); + } else { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + height: 1, + width: Math.abs(start.left - end.left) + }); + } + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: s, + left: start.left - 6, + top: start.top - 7 + }, { + el: e, + left: end.left - 6, + top: end.top - 7 + }, { + el: line, + left: Math.min(start.left, end.left), + top: Math.min(start.top, end.top) + }] + }); + this.tags.push(s); + this.tags.push(e); + this.tags.push(line); + }, + + stopDraw: function () { + BI.each(this.tags, function (i, w) { + w.destroy(); + }); + this.tags = []; + }, + + _getRegionExcept: function (name, regions) { + var other = []; + BI.each(regions || this.getAllRegions(), function (i, region) { + if (!(name && region.id === name)) { + other.push(region); + } + }); + return other; + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + getPosition: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + position.left = pos.end.left - size.width / 2; + }); + BI.each(right, function (i, pos) { + position.left = pos.end.left - size.width; + }); + BI.each(left, function (i, pos) { + position.left = pos.end.left; + }); + BI.each(middle, function (i, pos) { + position.top = pos.end.top - size.height / 2; + }); + BI.each(bottom, function (i, pos) { + position.top = pos.end.top - size.height; + }); + BI.each(top, function (i, pos) { + position.top = pos.end.top; + }); + return position; + }, + + //position不动 变size + getSize: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + size.width = (pos.end.left - position.left) * 2; + }); + BI.each(right, function (i, pos) { + size.width = pos.end.left - position.left; + }); + BI.each(left, function (i, pos) { + }); + BI.each(middle, function (i, pos) { + size.height = (pos.end.top - position.top) * 2; + }); + BI.each(bottom, function (i, pos) { + size.height = pos.end.top - position.top; + }); + BI.each(top, function (i, pos) { + }); + return size; + }, + + draw: function (position, size, name) { + var self = this; + this.stopDraw(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var other = this._getRegionExcept(name); + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(right, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(left, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(middle, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(bottom, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(top, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + }, + + addRegion: function (region, position) { + this.stopDraw(); + return this.arrangement.addRegion(region, position); + }, + + deleteRegion: function (name) { + return this.arrangement.deleteRegion(name); + }, + + setRegionSize: function (name, size) { + size = this.getSize(name, null, size); + return this.arrangement.setRegionSize(name, size); + }, + + setPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var at = this.arrangement.setPosition(position, size); + return at; + }, + + setRegionPosition: function (name, position) { + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(name, position); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var callback = self.arrangement.setDropPosition(position, size); + return function () { + callback(); + self.stopDraw(); + } + }, + + scrollInterval: function () { + this.arrangement.scrollInterval.apply(this.arrangement, arguments); + }, + + scrollEnd: function () { + this.arrangement.scrollEnd.apply(this.arrangement, arguments); + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + return this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + return this.arrangement.revoke(); + }, + + populate: function (items) { + var self = this; + this.arrangement.populate(items); + } +}); +BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; +BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** + * 月份下拉框 + * + * 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: 25 + }); + }, + _init: function () { + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.month_trigger" + }); + + 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 + }); + 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", + 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 () { + 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 = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; + 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 + 1 + }; + }); + }); + + 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 + }] + }); + + 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) { + 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, + triggerWidth: 25, + errorText: BI.i18nText("BI-Month_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-month-trigger bi-border", + height: 25 + }); + }, + _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: c.errorText + }); + 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: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + 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);/** + * 普通控件 + * + * @class BI.MultiDateCard + * @extends BI.Widget + * @abstract + */ +BI.MultiDateCard = BI.inherit(BI.Widget, { + + constants: { + lgap: 80, + itemHeight: 35, + defaultEditorValue: "1" + }, + + _defaultConfig: function () { + return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this, arguments), {}); + }, + + dateConfig: function () { + + }, + + defaultSelectedItem: function () { + + }, + + _init: function () { + BI.MultiDateCard.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.label = BI.createWidget({ + type: 'bi.label', + height: this.constants.itemHeight, + textAlign: "left", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + cls: 'bi-multidate-inner-label bi-tips' + }); + this.radioGroup = BI.createWidget({ + type: "bi.button_group", + chooseType: 0, + items: BI.createItems(this.dateConfig(), { + type: 'bi.multidate_segment', + height: this.constants.itemHeight + }), + layouts: [{ + type: "bi.vertical" + }] + }); + + this.radioGroup.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CONFIRM) { + self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); + } + }); + this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE, function () { + self.setValue(self.getValue()); + self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); + }); + BI.createWidget({ + element: this, + type: 'bi.center_adapt', + lgap: this.constants.lgap, + items: [{ + type: 'bi.vertical', + items: [this.label, this.radioGroup] + }] + }); + }, + + getValue: function () { + var button = this.radioGroup.getSelectedButtons()[0]; + var type = button.getValue(), value = button.getInputValue(); + return { + type: type, + value: value + } + }, + + _isTypeAvaliable: function (type) { + var res = false; + BI.find(this.dateConfig(), function (i, item) { + if (item.value === type) { + res = true; + return true; + } + }); + return res; + }, + + setValue: function (v) { + var self = this; + if (BI.isNotNull(v) && this._isTypeAvaliable(v.type)) { + this.radioGroup.setValue(v.type); + BI.each(this.radioGroup.getAllButtons(), function (i, button) { + if (button.isEditorExist() === true && button.isSelected()) { + button.setInputValue(v.value); + } else { + button.setInputValue(self.constants.defaultEditorValue); + } + }); + } else { + this.radioGroup.setValue(this.defaultSelectedItem()); + BI.each(this.radioGroup.getAllButtons(), function (i, button) { + button.setInputValue(self.constants.defaultEditorValue); + }); + } + }, + + getCalculationValue: function () { + var valueObject = this.getValue(); + var type = valueObject.type, value = valueObject.value; + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + return new Date().getOffsetDate(-1 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + return new Date().getOffsetDate(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + return new Date(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + return new Date().getBeforeMultiMonth(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + return new Date().getAfterMultiMonth(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + return new Date(new Date().getFullYear(), new Date().getMonth(), 1); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + return new Date(new Date().getFullYear(), new Date().getMonth(), (new Date().getLastDateOfMonth()).getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + return new Date().getBeforeMulQuarter(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + return new Date().getAfterMulQuarter(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + return new Date().getQuarterStartDate(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + return new Date().getQuarterEndDate(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + return new Date().getOffsetDate(-7 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + return new Date().getOffsetDate(7 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + return new Date((new Date().getFullYear() - 1 * value), new Date().getMonth(), new Date().getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + return new Date((new Date().getFullYear() + 1 * value), new Date().getMonth(), new Date().getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + return new Date(new Date().getFullYear(), 0, 1); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + return new Date(new Date().getFullYear(), 11, 31); + } + } +}); +BI.MultiDateCard.EVENT_CHANGE = "EVENT_CHANGE"; +/** + * 日期控件 + * @class BI.MultiDateCombo + * @extends BI.Widget + */ +BI.MultiDateCombo = 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" + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-combo bi-border', + height: 24 + }); + }, + _init: function () { + BI.MultiDateCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.storeTriggerValue = ""; + var date = new Date(); + this.storeValue = null; + this.trigger = BI.createWidget({ + type: 'bi.date_trigger', + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } + }); + this.trigger.on(BI.DateTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + this.trigger.on(BI.DateTrigger.EVENT_FOCUS, function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.MultiDateCombo.EVENT_FOCUS); + }); + this.trigger.on(BI.DateTrigger.EVENT_ERROR, function () { + self.storeValue = { + year: date.getFullYear(), + month: date.getMonth() + }; + self.popup.setValue(); + self.fireEvent(BI.MultiDateCombo.EVENT_ERROR); + }); + this.trigger.on(BI.DateTrigger.EVENT_VALID, function () { + self.fireEvent(BI.MultiDateCombo.EVENT_VALID); + }); + this.trigger.on(BI.DateTrigger.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); + }); + this.trigger.on(BI.DateTrigger.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()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup = BI.createWidget({ + type: "bi.multidate_popup", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE, function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE, function () { + var date = new Date(); + self.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + //self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.combo = BI.createWidget({ + type: 'bi.combo', + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + maxHeight: this.constants.popupHeight, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW); + }); + + var triggerBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: 30, + height: 23 + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + this.changeIcon = BI.createWidget({ + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 30, + height: 23 + }); + + + var leftPart = BI.createWidget({ + type: "bi.absolute", + items: [{ + el: this.combo, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: triggerBtn, + top: 0, + left: 0 + }] + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [leftPart, { + el: this.changeIcon, + width: 30 + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }) + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type + } + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[1].width = 30; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[1].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.popup.setValue(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.shortcut('bi.multidate_combo', BI.MultiDateCombo); + +BI.MultiDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MultiDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.MultiDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiDateCombo.EVENT_VALID = "EVENT_VALID"; +BI.MultiDateCombo.EVENT_ERROR = "EVENT_ERROR"; +BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW"; + +BI.extend(BI.MultiDateCombo, { + MULTI_DATE_YMD_CARD: 1, + MULTI_DATE_YEAR_CARD: 2, + MULTI_DATE_QUARTER_CARD: 3, + MULTI_DATE_MONTH_CARD: 4, + MULTI_DATE_WEEK_CARD: 5, + MULTI_DATE_DAY_CARD: 6 +}); + +BI.extend(BI.MultiDateCombo, { + DATE_TYPE: { + MULTI_DATE_YEAR_PREV: 1, + MULTI_DATE_YEAR_AFTER: 2, + MULTI_DATE_YEAR_BEGIN: 3, + MULTI_DATE_YEAR_END: 4, + MULTI_DATE_MONTH_PREV: 5, + MULTI_DATE_MONTH_AFTER: 6, + MULTI_DATE_MONTH_BEGIN: 7, + MULTI_DATE_MONTH_END: 8, + MULTI_DATE_QUARTER_PREV: 9, + MULTI_DATE_QUARTER_AFTER: 10, + MULTI_DATE_QUARTER_BEGIN: 11, + MULTI_DATE_QUARTER_END: 12, + MULTI_DATE_WEEK_PREV: 13, + MULTI_DATE_WEEK_AFTER: 14, + MULTI_DATE_DAY_PREV: 15, + MULTI_DATE_DAY_AFTER: 16, + MULTI_DATE_DAY_TODAY: 17, + MULTI_DATE_PARAM: 18, + MULTI_DATE_CALENDAR: 19, + YEAR_QUARTER: 20, + YEAR_MONTH: 21, + YEAR_WEEK: 22, + YEAR_DAY: 23, + MONTH_WEEK: 24, + MONTH_DAY: 25, + YEAR: 26, + SAME_PERIOD: 27, + LAST_SAME_PERIOD: 28 + } +}); +/** + * 普通控件 + * + * @class BI.DayCard + * @extends BI.MultiDateCard + */ +BI.DayCard = BI.inherit(BI.MultiDateCard, { + + _defaultConfig: function () { + return $.extend(BI.DayCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-daycard' + }); + }, + + _init: function () { + BI.DayCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + isEditorExist: true, + selected: true, + text: BI.i18nText("BI-Multi_Date_Day_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Day_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY, + text: BI.i18nText("BI-Multi_Date_Today") + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV + } +}); +BI.DayCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.daycard', BI.DayCard); +/** + * 普通控件 + * + * @class BI.MonthCard + * @extends BI.MultiDateCard + */ +BI.MonthCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-monthcard' + }); + }, + + _init: function () { + BI.MonthCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV, + text: BI.i18nText("BI-Multi_Date_Month_Prev") + }, + { + isEditorExist: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER, + text: BI.i18nText("BI-Multi_Date_Month_Next") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Month_Begin") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Month_End") + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV; + } +}); +BI.MonthCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.monthcard', BI.MonthCard); +/** + * 日期控件 + * @class BI.MultiDatePopup + * @extends BI.Widget + */ +BI.MultiDatePopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + tabWidth: 42, + titleHeight: 27, + itemHeight: 30, + triggerHeight: 24, + buttonWidth: 90, + buttonHeight: 25, + cardHeight: 229, + cardWidth: 270, + popupHeight: 259, + popupWidth: 270, + comboAdjustHeight: 1, + ymdWidth: 58, + lgap: 2, + border: 1 + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-popup', + width: 268, + height: 260 + }); + }, + _init: function () { + BI.MultiDatePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.storeValue = ""; + this.textButton = BI.createWidget({ + type: 'bi.text_button', + forceCenter: true, + cls: 'bi-multidate-popup-label bi-border-left bi-border-right bi-border-top', + shadow: true, + text: BI.i18nText("BI-Multi_Date_Today") + }); + this.textButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE); + }); + this.clearButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: 'bi-multidate-popup-button bi-border-top', + shadow: true, + text: BI.i18nText("BI-Basic_Clear") + }); + this.clearButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE); + }); + this.okButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: 'bi-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.MultiDatePopup.BUTTON_OK_EVENT_CHANGE); + }); + this.dateTab = BI.createWidget({ + type: 'bi.tab', + tab: { + cls: "bi-multidate-popup-tab bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.MultiDateCombo.MULTI_DATE_YMD_CARD, + width: this.constants.ymdWidth + }, { + text: BI.i18nText("BI-Multi_Date_Year"), + value: BI.MultiDateCombo.MULTI_DATE_YEAR_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Quarter"), + value: BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Month"), + value: BI.MultiDateCombo.MULTI_DATE_MONTH_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Week"), + value: BI.MultiDateCombo.MULTI_DATE_WEEK_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Day"), + value: BI.MultiDateCombo.MULTI_DATE_DAY_CARD + }], { + width: this.constants.tabWidth, + textAlign: "center", + height: this.constants.itemHeight, + cls: 'bi-multidate-popup-item bi-list-item-active' + }), + layouts: [{ + type: 'bi.left' + }] + }, + cardCreator: function (v) { + switch (v) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + self.ymd = BI.createWidget({ + type: "bi.date_calendar_popup", + min: self.options.min, + max: self.options.max + }); + self.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE); + }); + return self.ymd; + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + self.year = BI.createWidget({ + type: "bi.yearcard" + }); + self.year.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.year, v); + }); + return self.year; + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + self.quarter = BI.createWidget({ + type: 'bi.quartercard' + }); + self.quarter.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.quarter, v); + }); + return self.quarter; + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + self.month = BI.createWidget({ + type: 'bi.monthcard' + }); + self.month.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.month, v); + }); + return self.month; + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + self.week = BI.createWidget({ + type: 'bi.weekcard' + }); + self.week.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.week, v); + }); + return self.week; + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + self.day = BI.createWidget({ + type: 'bi.daycard' + }); + self.day.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.day, v); + }); + return self.day; + } + } + }); + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_YMD_CARD; + this.dateTab.on(BI.Tab.EVENT_CHANGE, function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + var date = this.getTab(self.cur).getCalculationValue(); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + self._setInnerValue(self.ymd); + break; + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + self.year.setValue(self.storeValue); + self._setInnerValue(self.year); + break; + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + self.quarter.setValue(self.storeValue); + self._setInnerValue(self.quarter); + break; + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + self.month.setValue(self.storeValue); + self._setInnerValue(self.month); + break; + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + self.week.setValue(self.storeValue); + self._setInnerValue(self.week); + break; + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + self.day.setValue(self.storeValue); + self._setInnerValue(self.day); + break; + } + self.cur = v; + }); + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.clearButton, this.textButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateTab + }, { + el: this.dateButton, + height: 30 + }] + }); + }, + _setInnerValue: function (obj) { + if (this.dateTab.getSelect() === BI.MultiDateCombo.MULTI_DATE_YMD_CARD) { + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.textButton.setEnable(true); + } else { + var date = obj.getCalculationValue(); + date = date.print("%Y-%x-%e"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + setValue: function (v) { + this.storeValue = v; + var self = this, date; + var type, value; + if (BI.isNotNull(v)) { + type = v.type || BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR; + value = v.value; + if (BI.isNull(value)) { + value = v; + } + } + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD); + this.year.setValue({type: type, value: value}); + this.cur = BI.MultiDateCombo.MULTI_DATE_YEAR_CARD; + self._setInnerValue(this.year); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD; + this.quarter.setValue({type: type, value: value}); + self._setInnerValue(this.quarter); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_MONTH_CARD; + this.month.setValue({type: type, value: value}); + self._setInnerValue(this.month); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_WEEK_CARD; + this.week.setValue({type: type, value: value}); + self._setInnerValue(this.week); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_DAY_CARD; + this.day.setValue({type: type, value: value}); + self._setInnerValue(this.day); + break; + default: + if (BI.isNull(value) || BI.isEmptyObject(value)) { + var date = new Date(); + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } else { + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.ymd.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } + this.textButton.setEnable(true); + break; + } + }, + getValue: function () { + var tab = this.dateTab.getSelect(); + switch (tab) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + return this.ymd.getValue(); + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + return this.year.getValue(); + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + return this.quarter.getValue(); + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + return this.month.getValue(); + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + return this.week.getValue(); + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + return this.day.getValue(); + } + } +}); +BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.MultiDatePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; +BI.shortcut('bi.multidate_popup', BI.MultiDatePopup); +/** + * 普通控件 + * + * @class BI.QuarterCard + * @extends BI.MultiDateCard + */ +BI.QuarterCard = BI.inherit(BI.MultiDateCard, { + + _defaultConfig: function () { + return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-quartercard' + }); + }, + + _init: function () { + BI.QuarterCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Quarter_Prev") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Quarter_Next") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Quarter_Begin") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Quarter_End") + }] + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV; + } +}); +BI.QuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.quartercard', BI.QuarterCard); +/** + * 普通控件 + * + * @class BI.MultiDateSegment + * @extends BI.Single + */ +BI.MultiDateSegment = BI.inherit(BI.Single, { + constants: { + itemHeight: 24, + maxGap: 15, + minGap: 10, + textWidth: 30, + defaultEditorValue: "1" + }, + + _defaultConfig: function () { + return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-segment', + text: "", + width: 130, + height: 30, + isEditorExist: true, + selected: false, + defaultEditorValue: "1" + }); + }, + + _init: function () { + BI.MultiDateSegment.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.radio = BI.createWidget({ + type: "bi.radio", + selected: opts.selected + }); + this.radio.on(BI.Controller.EVENT_CHANGE, function (v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textEditor = BI.createWidget({ + type: 'bi.text_editor', + value: this.constants.defaultEditorValue, + title: function () { + return self.textEditor.getValue(); + }, + tipType: "success", + cls: 'bi-multidate-editor', + width: this.constants.textWidth, + height: this.constants.itemHeight + }); + this.textEditor.on(BI.Controller.EVENT_CHANGE, function (v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + cls: 'bi-multidate-normal-label', + text: opts.text, + height: this.constants.itemHeight + }); + this._createSegment(); + }, + _createSegment: function () { + if (this.options.isEditorExist === true) { + return BI.createWidget({ + element: this, + type: 'bi.left', + items: [{ + el: { + type: "bi.center_adapt", + items: [this.radio], + height: this.constants.itemHeight + }, + lgap: 0 + }, + { + el: { + type: "bi.center_adapt", + items: [this.textEditor], + widgetName: 'textEditor' + }, + lgap: this.constants.maxGap + }, + { + el: this.text, + lgap: this.constants.minGap + }] + }); + } + return BI.createWidget({ + element: this, + type: 'bi.left', + items: [{ + el: { + type: "bi.center_adapt", + items: [this.radio], + height: this.constants.itemHeight + }, + lgap: 0 + }, + { + el: this.text, + lgap: this.constants.maxGap + }] + }) + }, + setSelected: function (v) { + if (BI.isNotNull(this.radio)) { + this.radio.setSelected(v); + this.textEditor.setEnable(v); + } + }, + isSelected: function () { + return this.radio.isSelected(); + }, + getValue: function () { + return this.options.value; + }, + getInputValue: function () { + return this.textEditor.getValue() | 0; + }, + setInputValue: function (v) { + this.textEditor.setValue(v); + }, + isEditorExist: function () { + return this.options.isEditorExist; + } +}); +BI.MultiDateSegment.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multidate_segment', BI.MultiDateSegment);/** + * 普通控件 + * + * @class BI.WeekCard + * @extends BI.MultiDateCard + */ +BI.WeekCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-weekcard' + }); + }, + + _init: function () { + BI.WeekCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Week_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Week_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV; + } +}); +BI.WeekCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.weekcard', BI.WeekCard); +/** + * 普通控件 + * + * @class BI.YearCard + * @extends BI.MultiDateCard + */ +BI.YearCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.YearCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-yearcard' + }); + }, + + _init: function () { + BI.YearCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Year_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Year_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN, + text: BI.i18nText("BI-Multi_Date_Year_Begin") + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END, + text: BI.i18nText("BI-Multi_Date_Year_End") + }] + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV; + } +}); +BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.yearcard', BI.YearCard); +/** + * @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: 30, + text: "", + items: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_select_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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 + }) + }, + + _init: function () { + BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_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", + element: this, + 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, + + 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); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + 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.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: [] + }); + }, + + _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, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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/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: 30, + text: "", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_single_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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 + }) + }, + + _init: function () { + BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_single_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_single_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_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", + element: this, + expander: { + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback(BI.Tree.transformToTreeFormat(items), 0) + }) + }, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + 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); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + 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.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 + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + 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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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 + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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 + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** + * + * 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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25, + lgap: 10, + tgap: 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 = {}; + 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.left', + cls: 'multi-select-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: this.continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + } + }, { + height: 'fill', + el: this.display + }] + }); + }, + + 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: 25, + 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 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: 28 + }); + }, + + _init: function () { + BI.MultiSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = {}; + //标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: { + left: 1, + top: 1, + right: 2, + bottom: 33 + } + }, + 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); + }); + } + }); + + 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 () { + //如果在不选的状态下直接把该值添加进来 + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + 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, + 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(); + }); + } + }, + 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 bi-border-left" + }); + 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.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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.pluck(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.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); + 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.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: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** + * 多选加载数据面板 + * 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.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) && !self.storeValue.value.contains(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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + 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.MultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 25, + selected: this.isAllSelected() + }) + }, + + _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) { + 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.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** + * 带加载的多选下拉面板 + * @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 + }); + + 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 + }); + + 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.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, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker + }); + 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 + }); + 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: 30 + }] + }); + + 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.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + 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);/** + * 多选加载数据搜索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.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: { + dynamic: false + }, + 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: 25, + selected: this.isAllSelected() + }) + }, + + 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.matched.concat(search.finded); + } + 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: 25, + 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()); + }]); + } + }); + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-button bi-high-light', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.numberCounter = BI.createWidget({ + type: 'bi.text_button', + element: this, + hgap: 4, + text: "0", + textAlign: 'center', + textHeight: 15 + }); + 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(self._const.checkSelected); + }, function () { + self.numberCounter.setText(self.numberCounter.getTag()); + }); + this.setVisible(false); + }, + + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _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 + }); + + 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); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } else { + 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.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: {} + }); + }, + + _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 + }); + + 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) { + op.keyword = self.editor.getValue(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }, 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); + }); + }, + + 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 (BI.size(ob.assist) === 1) { + this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } + } else { + if (BI.size(ob.value) === 1) { + this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + } + }, + + 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 + }); + 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(); + } + }, 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.MultiSelectList = BI.inherit(BI.Widget, { + _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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](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.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + 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 () { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword) + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }) + } else { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword) + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self.adapter.populate(); + if (self.storeValue.type === BI.Selection.Multi) { + 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: 30 + }, { + 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.MultiSelectList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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, + keyword: self.trigger.getKeyword() + }, function (ob) { + var items = BI.pluck(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: 0, + 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.Widget, { + _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: 30 + }, { + 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); + }, + + 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); + } + }); + + 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: 1, + left: 1, + right: 2, + bottom: 33 + } + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-combo', + itemsCreator: BI.emptyFn, + height: 25 + }); + }, + + _init: function () { + BI.MultiTreeCombo.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + var isInit = false; + var want2showCounter = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: this.constants.offset + }, + searcher: { + type: "bi.multi_tree_searcher", + itemsCreator: o.itemsCreator + }, + switcher: { + el: { + type: "bi.multi_tree_check_selected_button" + }, + popup: { + type: "bi.multi_tree_check_pane", + itemsCreator: o.itemsCreator + } + } + + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + 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() ? {1: 1} : {} + }; + 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(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.storeValue = {value: {}}; + 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 val = { + type: BI.Selection.Multi, + value: this.getSearcher().hasChecked() ? {1: 1} : {} + }; + this.getSearcher().setState(val); + 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 bi-border-left" + }); + 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 + }); + + 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); + } + }); + + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _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', + width: 15, + height: 15, + stopPropagation: true + }); + + this.checkSelected = BI.createWidget({ + type: 'bi.text_button', + cls: "trigger-check-selected", + invisible: true, + hgap: 4, + text: this._const.checkSelected, + 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, + 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); + } + }, 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); + }); + }, + + 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) { + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + }, + + 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", + validationChecker: function () { + return true; + }, + valueFormatter: function (v) { + return v; + }, + value: 0, + 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, + value: o.valueFormatter(o.value), + validationChecker: o.validationChecker, + errorText: o.errorText + }); + this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { + o.value = this.getValue(); + self.fireEvent(BI.NumberEditor.EVENT_CHANGE); + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + 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,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + 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", + 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 + }] + }); + }, + + //微调 + _finetuning: function (add) { + var v = BI.parseFloat(this.getValue()); + this.setValue(v.add(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: 30, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "" + }, + _defaultConfig: function () { + var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments) + return BI.extend(conf, { + extraCls: "bi-number-interval", + height: 25, + validation: "valid" + }) + }, + _init: function () { + var self = this, c = this.constants, o = this.options; + BI.NumberInterval.superclass._init.apply(this, arguments) + this.smallEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + 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-top bi-border-bottom bi-border-left" + }); + + 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.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + 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-top bi-border-bottom bi-border-right" + }); + + 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", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "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", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "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 * 2 + }] + + }); + this.right = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.bigCombo, + width: c.width - c.border * 2 + }, { + el: self.bigEditor + }] + }); + + + 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); + }, + + _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; + } else { + if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } else { + 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; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } else { + 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; + } else { + 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: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + 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: "center" + }); + 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: "center" + }); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + 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: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + break; + } + self.fireEvent(BI.NumberInterval.EVENT_CHANGE); + }); + }, + + _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_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); + } + }, + + + 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; + } +}); +BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; +BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.shortcut("bi.number_interval", BI.NumberInterval);/** + * + * 表格 + * + * Created by GUY on 2015/9/22. + * @class BI.PageTableCell + * @extends BI.Single + */ +BI.PageTableCell = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table-cell", + text: "", + title: "" + }) + }, + + _init: function () { + BI.PageTableCell.superclass._init.apply(this, arguments); + var label = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "nowrap", + height: this.options.height, + text: this.options.text, + title: this.options.title, + value: this.options.value, + lgap: 5, + rgap: 5 + }); + + if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { + this.element.css(this.options.styles); + } + } +}); + +BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** + * 分页表格 + * + * Created by GUY on 2016/2/15. + * @class BI.PageTable + * @extends BI.Widget + */ +BI.PageTable = BI.inherit(BI.Widget, { + + _const: { + scrollWidth: 18, + minScrollWidth: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table", + el: { + type: "bi.sequence_table" + }, + pager: { + 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 + } + }, + + itemsCreator: BI.emptyFn, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.PageTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.hCurr = 1; + this.vCurr = 1; + + this.table = BI.createWidget(o.el, { + type: "bi.sequence_table", + width: o.width, + height: o.height && o.height - 30, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.pager = BI.createWidget(o.pager, { + type: "bi.direction_pager", + height: 30 + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + var vpage = this.getVPage && this.getVPage(); + if (BI.isNull(vpage)) { + vpage = this.getCurrentPage(); + } + var hpage = this.getHPage && this.getHPage(); + o.itemsCreator({ + vpage: vpage, + hpage: hpage + }, function (items, header, crossItems, crossHeader) { + self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); + self.table.setHPage && self.table.setHPage(hpage); + self.populate.apply(self, arguments); + }); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.table, + left: 0, + top: 0 + }, { + el: this.pager, + left: 0, + right: 0, + bottom: 0 + }] + }) + }, + + setHPage: function (v) { + this.hCurr = v; + this.pager.setHPage && this.pager.setHPage(v); + this.table.setHPage && this.table.setHPage(v); + }, + + setVPage: function (v) { + this.vCurr = v; + this.pager.setVPage && this.pager.setVPage(v); + this.table.setVPage && this.table.setVPage(v); + }, + + getHPage: function () { + var hpage = this.pager.getHPage && this.pager.getHPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + return this.hpage; + }, + + getVPage: function () { + var vpage = this.pager.getVPage && this.pager.getVPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + return this.vpage; + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + var showPager = false; + if (this.pager.alwaysShowPager) { + showPager = true; + } else if (this.pager.hasHNext && this.pager.hasHNext()) { + showPager = true; + } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { + showPager = true; + } else if (this.pager.hasVNext && this.pager.hasVNext()) { + showPager = true; + } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { + showPager = true; + } else if (this.pager.hasNext && this.pager.hasNext()) { + showPager = true; + } else if (this.pager.hasPrev && this.pager.hasPrev()) { + showPager = true; + } + this.table.setHeight(height - (showPager ? 30 : 0)); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + restore: function () { + this.table.restore(); + }, + + attr: function () { + BI.PageTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function () { + this.pager.populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + this.pager && this.pager.destroy(); + BI.PageTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.page_table', BI.PageTable);/** + * 路径选择 + * + * Created by GUY on 2015/12/4. + * @class BI.PathChooser + * @extends BI.Widget + */ +BI.PathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#d4dadd", + selectLineColor: "#3f8ce8" + }, + + _defaultConfig: function () { + return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-chooser", + items: [] + }) + }, + + _init: function () { + BI.PathChooser.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _createRegions: function (regions) { + var self = this; + this.regions = BI.createWidgets(BI.map(regions, function (i, region) { + return { + type: "bi.path_region", + title: self.texts[region] || region + } + })); + this.regionMap = {}; + BI.each(regions, function (i, region) { + self.regionMap[region] = i; + }); + this.container = BI.createWidget({ + type: "bi.horizontal", + verticalAlign: "top", + scrollx: false, + scrolly: false, + hgap: 10, + items: this.regions + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + scrollable: true, + hgap: 10, + items: [this.container] + }); + }, + + getRegionIndexById: function (id) { + var node = this.store[id]; + var regionType = node.get("region"); + return this.regionMap[regionType]; + }, + + _drawPath: function (start, offset, index) { + var self = this; + var starts = []; + if (BI.contains(this.start, start)) { + starts = this.start; + } else { + starts = [start]; + } + + BI.each(starts, function (i, s) { + BI.each(self.radios[s], function (i, rad) { + rad.setSelected(false); + }); + BI.each(self.lines[s], function (i, line) { + line.attr("stroke", self._const.lineColor); + }); + BI.each(self.regionIndexes[s], function (i, idx) { + self.regions[idx].reset(); + }); + }); + + BI.each(this.routes[start][index], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(offset + index, id); + }); + var current = BI.last(this.routes[start][index]); + + while (current && this.routes[current] && this.routes[current].length === 1) { + BI.each(this.routes[current][0], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(0, id); + }); + this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); + current = BI.last(this.routes[current][0]); + } + this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); + this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); + }, + + _drawRadio: function (start, offset, index, x, y) { + var self = this; + var radio = BI.createWidget({ + type: "bi.radio", + cls: "path-chooser-radio", + selected: offset + index === 0, + start: start, + index: index + }); + radio.on(BI.Radio.EVENT_CHANGE, function () { + self._drawPath(start, offset, index); + self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); + }); + if (!this.radios[start]) { + this.radios[start] = []; + } + this.radios[start].push(radio); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: radio, + left: x - 6.5, + top: y - 6.5 + }] + }) + }, + + _drawLine: function (start, lines) { + var self = this; + if (!this.lines[start]) { + this.lines[start] = []; + } + if (!this.pathes[start]) { + this.pathes[start] = []; + } + var startRegionIndex = this.getRegionIndexById(start); + //start所在的位置,然后接着往下画其他的路径 + var offset = this.regions[startRegionIndex].getIndexByValue(start); + BI.each(lines, function (i, line) { + self.pathes[start][i] = []; + var idx = i + offset; + var path = ""; + var stop = 47.5 + 29 * idx; + var sleft = 50 + 100 * startRegionIndex; + var radioStartX = sleft, radioStartY = stop; + var etop = stop; + var endRegionIndex = self.getRegionIndexById(BI.last(line)); + var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); + var eleft = 50 + 100 * endRegionIndex; + if (BI.contains(self.start, start)) { + radioStartX = sleft - 50; + path += "M" + (sleft - 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft - 50, + y: stop + }) + } else if (idx === 0) { + radioStartX = sleft + 50; + path += "M" + sleft + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: stop + }) + } else { + radioStartX = sleft + 50; + path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: stop + }); + } + if (idx > 0) { + var endY = endOffset * 29 + 47.5; + path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; + self.pathes[start][i].push({ + x: eleft - 50, + y: etop + }); + self.pathes[start][i].push({ + x: eleft - 50, + y: endY + }); + self.pathes[start][i].push({ + x: eleft, + y: endY + }); + } else { + path += "L" + eleft + "," + etop; + self.pathes[start][i].push({ + x: eleft, + y: etop + }); + } + + var graph = self.svg.path(path) + .attr({ + stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, + 'stroke-dasharray': '-' + }); + self.lines[start].push(graph); + if (lines.length > 1) { + self.lines[start][0].toFront(); + } + //第一个元素无论有多少个都要显示radio + if (BI.contains(self.start, start)) { + self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); + } + if (lines.length > 1 || BI.contains(self.start, start)) { + self._drawRadio(start, offset, i, radioStartX, radioStartY); + } + }); + }, + + _drawLines: function (routes) { + var self = this; + this.lines = {}; + this.pathes = {}; + this.radios = {}; + this.regionIndexes = {}; + BI.each(routes, function (k, route) { + if (!self.regionIndexes[k]) { + self.regionIndexes[k] = []; + } + BI.each(route, function (i, rs) { + BI.each(rs, function (j, id) { + var regionIndex = self.getRegionIndexById(id); + if (!BI.contains(self.regionIndexes[k], regionIndex)) { + self.regionIndexes[k].push(regionIndex); + } + }); + }) + }); + BI.each(routes, function (k, route) { + self._drawLine(k, route); + }); + }, + + _pushNodes: function (nodes) { + var self = this; + var indexes = []; + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i]; + var index = self.getRegionIndexById(id); + indexes.push(index); + var region = self.regions[index]; + if (i === nodes.length - 1) { + if (!region.hasItem(id)) { + region.addItem(id, self.texts[id]); + } + break; + } + if (i > 0 || BI.contains(self.start, id)) { + region.addItem(id, self.texts[id]); + } + } + for (var i = BI.first(indexes); i < BI.last(indexes); i++) { + if (!BI.contains(indexes, i)) { + self.regions[i].addItem(""); + } + } + }, + + _createNodes: function () { + var self = this, o = this.options; + this.store = {}; + this.texts = {}; + this.start = []; + this.end = []; + BI.each(o.items, function (i, item) { + self.start.push(BI.first(item).value); + self.end.push(BI.last(item).value); + }); + this.start = BI.uniq(this.start); + this.end = BI.uniq(this.end); + var regions = []; + var tree = new BI.Tree(); + var branches = {}, max = 0; + BI.each(o.items, function (i, items) { + BI.each(items, function (j, item) { + if (!BI.has(branches, item.value)) { + branches[item.value] = 0; + } + branches[item.value]++; + max = Math.max(max, branches[item.value]); + var prev = {}; + if (j > 0) { + prev = items[j - 1]; + } + var parent = self.store[prev.value || ""]; + var node = self.store[item.value] || new BI.Node(item.value); + node.set(item); + self.store[item.value] = node; + self.texts[item.value] = item.text; + self.texts[item.region] = item.regionText; + parent = BI.isNull(parent) ? tree.getRoot() : parent; + if (parent.getChildIndex(item.value) === -1) { + tree.addNode(parent, node); + } + }) + }); + + //算出区域列表 + tree.traverse(function (node) { + BI.each(node.getChildren(), function (i, child) { + if (BI.contains(regions, child.get("region"))) { + var index1 = BI.indexOf(regions, node.get("region")); + var index2 = BI.indexOf(regions, child.get("region")); + //交换区域 + if (index1 > index2) { + var t = regions[index2]; + for (var j = index2; j < index1; j++) { + regions[j] = regions[j + 1]; + } + regions[index1] = t; + } + } else { + regions.push(child.get("region")); + } + }); + }); + this._createRegions(regions); + + //算出节点 + BI.each(branches, function (k, branch) { + if (branch < max) { + delete branches[k]; + } + }); + + //过滤节点 + var nodes = []; + var n = tree.getRoot(); + while (n && n.getChildrenLength() === 1) { + if (BI.has(branches, n.getChildren()[0].id)) { + delete branches[n.getChildren()[0].id]; + n = n.getChildren()[0]; + } else { + n = null; + } + } + tree.traverse(function (node) { + if (BI.has(branches, node.id)) { + nodes.push(node.id); + delete branches[node.id]; + } + }); + + //填充节点 + var routes = {}; + var s, e; + for (var i = 0, len = nodes.length; i < len + 1; i++) { + if (len === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === len) { + s = e; + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = [tree.search(nodes[i])]; + } else { + s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; + e = [tree.search(s[0], nodes[i])]; + } + BI.each(s, function (i, n) { + tree._recursion(n, [n.id], function (node, route) { + if (BI.contains(e, node)) { + if (!routes[n.id]) { + routes[n.id] = []; + } + routes[n.id].push(route); + self._pushNodes(route); + if (e.length <= 1) { + return true; + } + } + }) + }); + } + this.routes = routes; + this._drawLines(routes); + }, + + _unselectAllPath: function () { + var self = this; + BI.each(this.radios, function (idx, rad) { + BI.each(rad, function (i, r) { + r.setSelected(false); + }); + }); + BI.each(this.lines, function (idx, line) { + BI.each(line, function (i, li) { + li.attr("stroke", self._const.lineColor); + }); + }); + BI.each(this.regions, function (idx, region) { + region.reset(); + }); + }, + + populate: function (items) { + this.options.items = items || []; + var self = this; + this.empty(); + if (this.options.items.length <= 0) { + return; + } + this.svg = BI.createWidget({ + type: "bi.svg" + }); + this._createNodes(); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + }, + + setValue: function (v) { + this._unselectAllPath(); + var nodes = BI.keys(this.routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(self.routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + var startRegionIndex = self.getRegionIndexById(start); + var offset = self.regions[startRegionIndex].getIndexByValue(start); + self._drawPath(start, offset, index); + } + }); + }, + + getValue: function () { + var path = []; + BI.each(this.regions, function (i, region) { + var val = region.getValue(); + if (BI.isKey(val)) { + path.push(val); + } + }); + return path; + } +}); +BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; +BI.shortcut("bi.path_chooser", BI.PathChooser);/** + * 路径选择区域 + * + * Created by GUY on 2015/12/4. + * @class BI.PathRegion + * @extends BI.Widget + */ +BI.PathRegion = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-region bi-background", + width: 80, + title: "" + }) + }, + + _init: function () { + BI.PathRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.zIndex = 100; + var title = BI.createWidget({ + type: "bi.label", + text: o.title, + title: o.title, + height: 30 + }); + title.element.css("zIndex", this.zIndex--); + this.items = []; + this.vertical = BI.createWidget({ + type: "bi.vertical", + element: this, + bgap: 5, + hgap: 10, + items: [title] + }) + }, + + hasItem: function (val) { + return BI.any(this.items, function (i, item) { + return val === item.getValue(); + }); + }, + + addItem: function (value, text) { + if (BI.isKey(value)) { + var label = BI.createWidget({ + type: "bi.label", + cls: "path-region-label bi-card bi-border bi-list-item-select", + text: text, + value: value, + title: text || value, + height: 24 + }); + } else { + var label = BI.createWidget({ + type: "bi.layout", + height: 24 + }); + } + label.element.css("zIndex", this.zIndex--); + this.items.push(label); + this.vertical.addItem(label); + if (this.items.length === 1) { + this.setSelect(0, value); + } + }, + + reset: function () { + BI.each(this.items, function (i, item) { + item.element.removeClass("active"); + }); + }, + + setSelect: function (index, value) { + this.reset(); + if (this.items.length <= 0) { + return; + } + if (this.items.length === 1) { + this.items[0].element.addClass("active"); + return; + } + if (this.items[index].attr("value") === value) { + this.items[index].element.addClass("active"); + } + }, + + setValue: function (value) { + this.setSelect(this.getIndexByValue(value), value); + }, + + getValueByIndex: function (idx) { + return this.items[idx].attr("value"); + }, + + getIndexByValue: function (value) { + return BI.findIndex(this.items, function (i, item) { + return item.attr("value") === value; + }); + }, + + getValue: function () { + var res; + BI.any(this.items, function (i, item) { + if (item.element.hasClass("active")) { + res = item.getValue(); + return true; + } + }); + return res; + } +}); +BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; +BI.shortcut("bi.path_region", BI.PathRegion);/** + * 预览表列 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableCell + * @extends BI.Widget + */ +BI.PreviewTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableHeaderCell + * @extends BI.Widget + */ +BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-header-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTable + * @extends BI.Widget + */ +BI.PreviewTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table", + isNeedFreeze: false, + freezeCols: [], + rowSize: null, + columnSize: [], + headerRowSize: 30, + header: [], + items: [] + }); + }, + + _init: function () { + BI.PreviewTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + isNeedResize: false, + + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + rowSize: o.rowSize, + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + + header: BI.map(o.header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }), + items: BI.map(o.items, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_cell" + }, item); + }); + }) + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._adjustColumns(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._adjustColumns(); + }); + }, + + //是否有自适应调节的列,即列宽为"" + _hasAdaptCol: function (columnSize) { + return BI.any(columnSize, function (i, size) { + return size === ""; + }) + }, + + _isPercentage: function (columnSize) { + return columnSize[0] <= 1; + }, + + _adjustColumns: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //如果存在百分比的情况 + if (this._isPercentage(o.columnSize)) { + if (this._hasAdaptCol(o.columnSize)) { + var findCols = [], remain = 0; + BI.each(o.columnSize, function (i, size) { + if (size === "") { + findCols.push(i); + } else { + remain += size; + } + }); + remain = 1 - remain; + var average = remain / findCols.length; + BI.each(findCols, function (i, col) { + o.columnSize[col] = average; + }); + } + var isRight = BI.first(o.freezeCols) !== 0; + var freezeSize = [], notFreezeSize = []; + BI.each(o.columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + freezeSize.push(size); + } else { + notFreezeSize.push(size); + } + }); + var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); + BI.each(freezeSize, function (i, size) { + freezeSize[i] = size / sumFreezeSize; + }); + BI.each(notFreezeSize, function (i, size) { + notFreezeSize[i] = size / sumNotFreezeSize; + }); + this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); + this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); + } + } else { + //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% + if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { + this.table.setRegionColumnSize(["100%"]); + } + } + }, + + setColumnSize: function (columnSize) { + return this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + return this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + return this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize() + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize() + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + return this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + return this.table.setLeftHorizontalScroll(scrollLeft) + }, + + setRightHorizontalScroll: function (scrollLeft) { + return this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + populate: function (items, header) { + this.table.populate(items, header); + } +}); +BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; +BI.shortcut('bi.preview_table', BI.PreviewTable);/** + * 季度下拉框 + * + * 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" + }); + + 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 + }); + + 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", + 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 () { + 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: Date._QN[01], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: 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" + }] + }); + + 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, + triggerWidth: 30, + textWidth: 40, + errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-quarter-trigger bi-border", + height: 25 + }); + }, + _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: c.errorText + }); + 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: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + + 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);/** + * 关联视图字段Item + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewItem + * @extends BI.Widget + */ +BI.RelationViewItem = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-item bi-list-item-active", + height: 25, + hoverIn: BI.emptyFn, + hoverOut: BI.emptyFn + }); + }, + + _init: function () { + BI.RelationViewItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.element.hover(o.hoverIn, o.hoverOut); + var items = []; + if (o.isPrimary) { + items.push({ + type: "bi.icon", + width: 16, + height: 16, + title: BI.i18nText("BI-Primary_Key") + }); + } + items.push({ + type: "bi.label", + text: o.text, + value: o.value, + height: o.height, + textAlign: "left", + width: o.isPrimary ? 70 : 90, + lgap: o.isPrimary ? 0 : 10 + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + items: items, + cls: "primary-key-font", + lgap: 5 + }); + }, + + enableHover: function (opt) { + BI.RelationViewRegion.superclass.enableHover.apply(this, [{ + container: "body" + }]); + }, + + setSelected: function (b) { + this.element[b ? "addClass" : "removeClass"]("active"); + } +}); +BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** + * 关联视图 + * + * Created by GUY on 2015/12/22. + * @class BI.RelationView + * @extends BI.Widget + */ +BI.RelationView = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#c4c6c6", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view", + items: [] + }); + }, + + _init: function () { + BI.RelationView.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _calculateWidths: function () { + var widths = []; + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + if (!widths[j]) { + widths[j] = BI.MIN; + } + widths[j] = Math.max(widths[j], obj.getWidth()); + }) + }); + return widths; + }, + + _calculateHeights: function () { + var heights = BI.makeArray(BI.size(this.views), BI.MIN); + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + heights[i] = Math.max(heights[i], obj.getHeight()); + }) + }); + return heights; + }, + + _hoverIn: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); + self.storeViews[start].setValue(relation[0].primary.value); + self.storeViews[end].setValue(relation[0].foreign.value); + } + }); + }); + }, + + _hoverOut: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.lineColor); + self.storeViews[start].setValue([]); + self.storeViews[end].setValue([]); + } + }); + }); + }, + + previewRelationTables: function(relationTables, show) { + if (!show) { + BI.each(this.storeViews, function (i, view) { + view.toggleRegion(true); + view.setPreviewSelected(false); + }); + BI.each(this.lines, function (i, lines) { + BI.each(lines, function (j, line) { + line.show(); + }); + }); + return; + } + BI.each(this.storeViews, function (id, view) { + if (!relationTables.contains(id)) { + view.toggleRegion(false); + } else { + view.setPreviewSelected(true); + } + }); + BI.each(this.lines, function (id, lines) { + BI.each(lines, function (cId, line) { + if (!relationTables.contains(id) || !relationTables.contains(cId)) { + line.hide(); + } + }); + }); + }, + + populate: function (items) { + var self = this, o = this.options, c = this._const; + o.items = items || []; + this.empty(); + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //算出所有的区域和关联 + var regions = this.regions = {}, relations = this.relations = {}; + BI.each(items, function (i, item) { + var pr = item.primary.region, fr = item.foreign && item.foreign.region; + if (pr && !relations[pr]) { + relations[pr] = {}; + } + if (pr && fr && !relations[pr][fr]) { + relations[pr][fr] = []; + } + if (pr && !regions[pr]) { + regions[pr] = []; + } + if (fr && !regions[fr]) { + regions[fr] = []; + } + if (pr && !BI.deepContains(regions[pr], item.primary)) { + regions[pr].push(item.primary); + } + if (fr && !BI.deepContains(regions[fr], item.foreign)) { + regions[fr].push(item.foreign); + } + pr && fr && relations[pr][fr].push(item); + }); + //求拓扑 + var topology = []; + var rs = BI.clone(regions), store = {}; + while (!BI.isEmpty(rs)) { + var clone = BI.clone(rs); + BI.each(o.items, function (i, item) { + if (!store[item.primary.region]) { + delete clone[item.foreign && item.foreign.region]; + } + }); + topology.push(BI.keys(clone)); + BI.extend(store, clone); + BI.each(clone, function (k, v) { + delete rs[k]; + }); + } + //构建视图 + var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; + var verticals = []; + BI.each(topology, function (i, items) { + if (!views[i]) { + views[i] = {}; + } + var horizontal = []; + BI.each(items, function (j, region) { + var items = regions[region]; + views[i][j] = storeViews[region] = BI.createWidget({ + type: "bi.relation_view_region_container", + value: region, + header: items[0].regionTitle, + text: items.length > 0 ? items[0].regionText : "", + handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, + items: items, + belongPackage: items.length > 0 ? items[0].belongPackage : true + }); + if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { + views[i][j].doRedMark(items[0].keyword); + } + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { + self._hoverIn(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { + self._hoverOut(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); + }); + indexes[region] = {i: i, j: j}; + horizontal.push(views[i][j]); + }); + verticals.push({ + type: "bi.horizontal", + items: horizontal + }) + }); + + //求每一行的高度 + var heights = this._calculateHeights(); + + //求每一列的宽度 + var widths = this._calculateWidths(); + + //求相对宽度和高度 + var offsetWidths = [0], offsetHeights = [0]; + BI.each(heights, function (i, h) { + if (i === 0) { + return; + } + offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; + }); + BI.each(widths, function (i, w) { + if (i === 0) { + return; + } + offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; + }); + + //画线 + var lines = this.lines = {};//缓存所有的线 + BI.each(relations, function (start, rs) { + BI.each(rs, function (end, relation) { + var startIndex = indexes[start], endIndex = indexes[end]; + var top = 0, right = 1, bottom = 2, left = 3; + var startDirection = bottom, endDirection = top; + // if (startIndex.j > endIndex.j) { + // startDirection = left; + // endDirection = right; + // } else if (startIndex.j < endIndex.j) { + // startDirection = right; + // endDirection = left; + // } else if (startIndex.i < endIndex.i) { + // startDirection = bottom; + // endDirection = top; + // } else if (startIndex.i > endIndex.i) { + // startDirection = top; + // endDirection = bottom; + // } + var draw = function (i, j, direction, isForeign) { + var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; + var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; + var path = "", position; + switch (direction) { + case top: + position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y - 10); + y -= 10; + break; + case right: + position = views[i][j].getRightPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x + 10) + "," + y; + x += 10; + break; + case bottom: + position = views[i][j].getBottomPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y + 10); + y += 10; + break; + case left: + position = views[i][j].getLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x - 10) + "," + y; + x -= 10; + break; + } + return {x: x, y: y, path: path}; + }; + var path = ""; + var si = draw(startIndex.i, startIndex.j, startDirection); + var ei = draw(endIndex.i, endIndex.j, endDirection, true); + path += si.path + ei.path; + if (!lines[start]) { + lines[start] = {}; + } + path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; + var line = lines[start][end] = self.svg.path(path) + .attr({"stroke": c.lineColor, "stroke-width": "2"}) + .hover(function () { + line.attr("stroke", c.selectLineColor).toFront(); + storeViews[start].setValue(relation[0].primary.value); + storeViews[end].setValue(relation[0].foreign.value); + }, function () { + line.attr("stroke", c.lineColor); + storeViews[start].setValue([]); + storeViews[end].setValue([]); + }); + }); + }); + var container = BI.createWidget(); + BI.createWidget({ + type: "bi.vertical", + element: container, + items: verticals + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; +BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; +BI.shortcut('bi.relation_view', BI.RelationView);/** + * Created by Young's on 2017/3/10. + */ +BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region-container", + width: 150 + }); + }, + + _init: function () { + BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.region = BI.createWidget({ + type: "bi.relation_view_region", + value: o.value, + header: o.header, + text: o.text, + handler: o.handler, + items: o.items, + belongPackage: o.belongPackage + }); + this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); + }); + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.region], + width: this.region.getWidth(), + height: this.region.getHeight() + }); + }, + + doRedMark: function () { + this.region.doRedMark.apply(this.region, arguments); + }, + + unRedMark: function () { + this.region.unRedMark.apply(this.region, arguments); + }, + + getWidth: function () { + return this.region.getWidth(); + }, + + getHeight: function () { + return this.region.getHeight(); + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return this.region.getTopLeftPosition(); + }, + + getTopRightPosition: function () { + return this.region.getTopRightPosition(); + }, + + getBottomPosition: function () { + return this.region.getBottomPosition(); + }, + + getLeftPosition: function () { + return this.region.getLeftPosition(); + }, + + getRightPosition: function () { + return this.region.getRightPosition(); + }, + + setValue: function (v) { + this.region.setValue(v); + }, + + toggleRegion: function (v) { + v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); + }, + + setPreviewSelected: function(v) { + this.region.setPreviewSelected(v); + } +}); +BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** + * 关联视图 + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewRegion + * @extends BI.BasicButton + */ +BI.RelationViewRegion = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region cursor-pointer", + width: 150, + text: "", + value: "", + header: "", + items: [], + belongPackage: true + }); + }, + + _init: function () { + BI.RelationViewRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.preview = BI.createWidget({ + type: "bi.icon_button", + cls: "relation-table-preview-font", + width: 25, + height: 25, + stopPropagation: true + }); + this.preview.on(BI.IconButton.EVENT_CHANGE, function () { + self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); + }); + + this.title = BI.createWidget({ + type: "bi.label", + height: 25, + width: 70, + text: o.text, + value: o.value, + textAlign: "left" + }); + //title放body上 + if (BI.isKey(o.header)) { + this.title.setTitle(o.header, { + container: "body" + }) + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", + items: this._createItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [{ + type: "bi.vertical", + cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), + items: [{ + type: "bi.vertical_adapt", + cls: "relation-view-region-title bi-border-bottom", + items: [this.preview, this.title] + }, this.button_group] + }], + hgap: 25, + vgap: 20 + }) + }, + + _createItems: function (items) { + var self = this; + return BI.map(items, function (i, item) { + return BI.extend(item, { + type: "bi.relation_view_item", + hoverIn: function () { + self.setValue(item.value); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); + }, + hoverOut: function () { + self.setValue([]); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); + } + }) + }); + }, + + doRedMark: function () { + this.title.doRedMark.apply(this.title, arguments); + }, + + unRedMark: function () { + this.title.unRedMark.apply(this.title, arguments); + }, + + getWidth: function () { + return this.options.width; + }, + + getHeight: function () { + return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return { + x: 25 + 10, + y: 20 + } + }, + + getTopRightPosition: function () { + return { + x: this.getWidth() - 25 - 10, + y: 20 + } + }, + + getBottomPosition: function () { + return { + x: 25 + 10, + y: this.getHeight() - 20 + } + }, + + getLeftPosition: function () { + return { + x: 25, + y: 20 + 10 + } + }, + + getRightPosition: function () { + return { + x: this.getWidth() - 25, + y: 20 + 10 + } + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + setPreviewSelected: function(v) { + this.preview.setSelected(v); + } +}); +BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.ResponisveTable + * @extends BI.Widget + */ +BI.ResponisveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-responsive-table", + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 25, + footerRowSize: 25, + rowSize: 25, + + regionColumnSize: false, + + header: [], + footer: false, + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.ResponisveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + footerRowSize: o.footerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + header: o.header, + footer: o.footer, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { + //important:在冻结并自适应列宽的情况下要随时变更表头宽度 + if (o.isNeedResize === true && self._isAdaptiveColumn()) { + self._resizeHeader(); + } + self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { + self._resizeBody(); + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _initRegionSize: function () { + var o = this.options; + if (o.isNeedFreeze === true) { + var regionColumnSize = this.table.getRegionColumnSize(); + var maxWidth = this.table.element.width(); + if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { + var freezeCols = o.freezeCols; + if (freezeCols.length === 0) { + this.table.setRegionColumnSize([0, "fill"]); + } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } else { + this.table.setRegionColumnSize(["fill", 0]); + } + } + } + }, + + _getBlockSize: function () { + var o = this.options; + var columnSize = this.table.getCalculateColumnSize(); + if (o.isNeedFreeze === true) { + var columnSizeLeft = [], columnSizeRight = []; + BI.each(columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + columnSizeLeft.push(size); + } else { + columnSizeRight.push(size); + } + }); + //因为有边框,所以加上数组长度的参数调整 + var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, + sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; + return { + sumLeft: sumLeft, + sumRight: sumRight, + left: columnSizeLeft, + right: columnSizeRight + } + } + return { + size: columnSize, + sum: BI.sum(columnSize) + columnSize.length + }; + }, + + _isAdaptiveColumn: function (columnSize) { + return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); + }, + + _resizeHeader: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //若是当前处于自适应调节阶段 + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.table.setHeaderColumnSize(columnSize); + } else { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + var columnSizeLeft = block.left, columnSizeRight = block.right; + columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; + columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; + + var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); + newLeft[newLeft.length - 1] = ""; + newRight[newRight.length - 1] = ""; + this.table.setColumnSize(newLeft.concat(newRight)); + + block = self._getBlockSize(); + if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { + columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] + } + if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { + columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] + } + + self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); + } + } else { + if (!this._isAdaptiveColumn()) { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sum = block.sum; + var size = block.size; + + size[size.length - 1] += regionColumnSize[0] - sum; + + var newSize = BI.clone(size); + newSize[newSize.length - 1] = ""; + this.table.setColumnSize(newSize); + block = this._getBlockSize(); + + if (size[size.length - 1] < block.size[block.size.length - 1]) { + size[size.length - 1] = block.size[block.size.length - 1] + } + this.table.setColumnSize(size); + } + } + }, + + _resizeBody: function () { + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.setColumnSize(columnSize); + } + }, + + _adjustRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { + this.table.setRegionColumnSize([sumLeft, "fill"]); + } + this._resizeRegion(); + } + }, + + _resizeRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var maxWidth = this.table.element.width(); + if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { + var freezeCols = o.freezeCols; + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } + } + }, + + + resize: function () { + this.table.resize(); + this._resizeRegion(); + this._resizeHeader(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + this._resizeHeader(); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + attr: function () { + BI.ResponisveTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function (items) { + var self = this, o = this.options; + this.table.populate.apply(this.table, arguments); + if (o.isNeedFreeze === true) { + BI.nextTick(function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + }); + } + } +}); +BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** + * 加号表示的组节点 + * 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: 25 + }) + }, + _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, + 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: 25, + 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: 25 + }) + }, + _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, + 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: 25, + 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: 25 + }) + }, + _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, + 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: 25, + 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);/** + * @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: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.select_level_tree", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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: "click", + 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(BI.extend({stopPropagation: true}, 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: [] + }); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {layer: layer}; + node.id = node.id || BI.UUID(); + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + self._formatItems(node.children); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.last_tree_leaf_item"; + break; + default : + extend.type = "bi.mid_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)), + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + 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(items); + } +}); + +BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** + * + * Created by GUY on 2016/8/10. + * @class BI.SequenceTableDynamicNumber + * @extends BI.SequenceTableTreeNumber + */ +BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-sequence-table-dynamic-number" + }); + }, + + _init: function () { + BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + } +}); +BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableListNumber + * @extends BI.Widget + */ +BI.SequenceTableListNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-list-number", + isNeedFreeze: false, + scrollTop: 0, + startSequence: 1,//开始的序号 + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + pageSize: 20 + }); + }, + + _init: function () { + BI.SequenceTableListNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.start = o.startSequence; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: o.headerRowSize * o.header.length - 2 + }, { + el: {type: "bi.layout"}, + height: 2 + }, { + el: this.scrollContainer + }] + }); + this._populate(); + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = o.headerRowSize * o.header.length - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + this.container.setHeight(o.items.length * o.rowSize); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); + var start = Math.floor(scrollTop / o.rowSize); + var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); + var renderedCells = [], renderedKeys = []; + for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { + var index = BI.deepIndexOf(this.renderedKeys, this.start + i); + var top = i * o.rowSize; + if (index > -1) { + if (o.rowSize !== this.renderedCells[index]._height) { + this.renderedCells[index]._height = o.rowSize; + this.renderedCells[index].el.setHeight(o.rowSize); + } + if (this.renderedCells[index].top !== top) { + this.renderedCells[index].top = top; + this.renderedCells[index].el.element.css("top", top + "px"); + } + renderedCells.push(this.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + height: o.rowSize, + text: this.start + i, + styleGetter: function (index) { + return function () { + return o.sequenceCellStyleGetter(self.start + i - 1); + } + }(cnt) + })); + renderedCells.push({ + el: child, + left: 0, + top: top, + _height: o.rowSize + }); + } + renderedKeys.push(this.start + i); + } + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + }, + + _populate: function () { + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + v = v < 1 ? 1 : v; + var o = this.options; + this.start = (v - 1) * o.pageSize + 1; + }, + + _restore: function () { + var o = this.options; + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + } + if (header && header !== this.options.header) { + o.header = header; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** + * 带有序号的表格 + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTable + * @extends BI.Widget + */ +BI.SequenceTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table", + el: { + type: "bi.adaptive_table" + }, + + sequence: {}, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + showSequence: false, + startSequence: 1//开始的序号 + }); + }, + + _init: function () { + BI.SequenceTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.sequence = BI.createWidget(o.sequence, { + type: "bi.sequence_table_list_number", + invisible: o.showSequence === false, + startSequence: o.startSequence, + isNeedFreeze: o.isNeedFreeze, + header: o.header, + items: o.items, + crossHeader: o.crossHeader, + crossItems: o.crossItems, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + width: 60, + height: o.height && o.height - BI.GridTableScrollbar.SIZE, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter + }); + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); + } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.htape = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.sequence, + left: 0, + top: 0 + }, { + el: this.table, + top: 0, + left: o.showSequence === true ? 60 : 0 + }] + }); + this._populate(); + }, + + _populate: function () { + var o = this.options; + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); + }, + + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); + }, + + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, + + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, arguments); + }, + + restore: function () { + this.table.restore(); + this.sequence.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); + }, + + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.sequence_table', BI.SequenceTable);/** + * @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: 30, + text: "", + items: [] + }); + }, + + _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 + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_level_tree", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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: [] + }); + }, + + _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, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + 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: 30, + text: "", + items: [] + }); + }, + + _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 + }); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(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);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", + items: [] + }); + }, + + _init: function () { + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); + }, + + _createTree: function (type) { + var self = this, o = this.options; + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items) + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)) + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } + }, + + _removeIsParent: function(items) { + BI.each(items, function(i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; + }); + return items; + }, + + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; + } + }, + + setSelect: function (v) { + this.tab.setSelect(v); + }, + + getSelect: function () { + return this.tab.getSelect(); + }, + + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } + }, + + getValue: function () { + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } + } +}); +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +BI.shortcut('bi.switch_tree', BI.SwitchTree); +/** + * Created by Baron on 2015/10/19. + */ +BI.TimeInterval = BI.inherit(BI.Single, { + constants: { + height: 25, + width: 25, + lgap: 15, + offset: -15, + 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; + BI.TimeInterval.superclass._init.apply(this, arguments); + + this.left = this._createCombo(); + this.right = this._createCombo(); + 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 () { + var self = this; + var combo = BI.createWidget({ + type: 'bi.multidate_combo' + }); + combo.on(BI.MultiDateCombo.EVENT_ERROR, function () { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + }); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.left.hidePopupView(); + self.right.hidePopupView(); + }); + //combo.on(BI.MultiDateCombo.EVENT_CHANGE, 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.TimeInterval.EVENT_ERROR); + // } else { + // self._clearTitle(); + // self.element.removeClass(self.constants.timeErrorCls); + // } + //}); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + }else{ + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_CHANGE); + } + }); + return combo; + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(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) && Date.checkLegal(smallDate) && this._checkVoid({ + year: smallObj[0], + month: smallObj[1], + day: smallObj[2] + }) && this._dateCheck(bigDate) && Date.checkLegal(bigDate) && this._checkVoid({ + year: bigObj[0], + month: bigObj[1], + day: bigObj[2] + }); + }, + _compare: function (smallDate, bigDate) { + smallDate = Date.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); + bigDate = Date.parseDateTime(bigDate, "%Y-%X-%d").print("%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.TimeInterval.EVENT_VALID = "EVENT_VALID"; +BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.time_interval", BI.TimeInterval);/** + * 年份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.YearCombo + * @extends BI.Widget + */ +BI.YearCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.year_trigger", + min: o.min, + max: o.max + }); + this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.YearTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.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.YearCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + destroyWhenHide: true, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + var value = self.trigger.getKey(); + if (BI.isNotNull(value)) { + self.popup.setValue(value); + } else if (!value && value !== self.storeValue) { + self.popup.setValue(self.storeValue); + } else { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.combo.setValue(v || ""); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_combo', BI.YearCombo);/** + * 年份展示面板 + * + * 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; + + this.selectedYear = this._year = new Date().getFullYear(); + + var backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25, + value: -1 + }); + + var preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25, + 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-border-top", + height: 25, + 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); + }); + }, + + getValue: function () { + return this.selectedYear; + }, + + setValue: function (v) { + var o = this.options; + if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { + v = new Date().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/8/21. + * @class BI.YearTrigger + * @extends BI.Trigger + */ +BI.YearTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), + errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-year-trigger bi-border", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearTrigger.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) { + self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); + return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }) + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.YearTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.YearTrigger.EVENT_STOP); + }); + 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.YearTrigger.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.YearTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.YearTrigger.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: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + getKey: function () { + return this.editor.getValue() | 0; + } +}); +BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.YearTrigger.EVENT_START = "EVENT_START"; +BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; +BI.shortcut("bi.year_trigger", BI.YearTrigger);/** + * 年份 + 月份下拉框 + * + * @class BI.YearMonthCombo + * @extends BI.Widget + */ +BI.YearMonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearMonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.month = BI.createWidget({ + type: "bi.month_combo", + behaviors: o.monthBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.month] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.month.setValue(v.month); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + }; + } +}); +BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** + * 年份 + 月份下拉框 + * + * @class BI.YearQuarterCombo + * @extends BI.Widget + */ +BI.YearQuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearQuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.quarter = BI.createWidget({ + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.quarter] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.quarter.setValue(v.quarter); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + quarter: this.quarter.getValue() + }; + } +}); +BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { + if (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.matched.concat(search.finded); + }); + 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', + element: this, + 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.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 () { + 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 () { + this.list.populate.apply(this.list, arguments); + } +}); +BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; +BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);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 + }); + }, + + _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 finded = search(parentValues, notSelectedValue, [], searched); + if (finded && 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 = [], finded = false; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(p)) { + finded = true; + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + p = parentValues; + } + + if (finded === 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, parentValues.length - 1), 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); + var finded = BI.Func.getSearchResult([node.text || node.value], keyword); + return finded.finded.length > 0 || finded.matched.length > 0; + }, + + _getTreeNode: function (parentValues, v) { + var self = this; + var findedParentNode; + 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) { + findedParentNode = node; + return false; + } + if (node.value === parentValues[index]) { + index++; + return; + } + return true; + }); + return findedParentNode; + }, + + _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), + 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 () { + 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) { + 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(); + if (options.keyword) { + keywords.push(options.keyword); + } + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + items = search.matched.concat(search.finded); + }); + 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, + 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 () { + 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.populate(); + } + }, + + setValue: function (v) { + this.list.setValue(v); + }, + + getValue: function () { + var val = this.list.getValue() || {}; + return { + type: val.type, + value: val.value + } + }, + + populate: function () { + this.list.populate.apply(this.list, arguments); + } +}); +BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane); \ No newline at end of file diff --git a/demo/js/case/combo/demo.bubble_combo.js b/demo/js/case/combo/demo.bubble_combo.js index cf129ffba..92a406b03 100644 --- a/demo/js/case/combo/demo.bubble_combo.js +++ b/demo/js/case/combo/demo.bubble_combo.js @@ -2,38 +2,12 @@ Demo.Func = BI.inherit(BI.Widget, { props: { baseCls: "demo-func" }, - _createNav: function(v){ - var m = this.MONTH, y = this.YEAR; - m += v; - while(m < 0){ - y--; - m += 12; - } - while(m > 11){ - y++; - m -= 12; - } - var calendar = BI.createWidget({ - type: "bi.calendar", - logic: { - dynamic: false - }, - year: y, - month: m, - day: this.DAY - }) - calendar.setValue(this.selectedTime); - return calendar; - }, - - _stringfyTimeObject: function(timeOb){ - return timeOb.year + "-" + (timeOb.month + 1) + "-" + timeOb.day; - }, render: function () { var self = this; var combo1 = BI.createWidget({ type: "bi.bubble_combo", + trigger: "click,hover", el: { type: "bi.button", text: "测试", diff --git a/demo/js/category/canvasTable/largeTableCanvas.js b/demo/js/category/canvasTable/largeTableCanvas.js new file mode 100644 index 000000000..c0a60e839 --- /dev/null +++ b/demo/js/category/canvasTable/largeTableCanvas.js @@ -0,0 +1,131 @@ +Demo.CanvasTable = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-face" + }, + + render: function () { + var self = this; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.sequence_table", + ref: function () { + self.table = this; + }, + isNeedFreeze: null, + isNeedMerge: false, + summaryCellStyleGetter: function (isLast) { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + sequenceCellStyleGetter: function (index) { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + headerCellStyleGetter: function () { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + el: { + type: "bi.adaptive_table", + el: { + type: "bi.resizable_table", + el: { + type: "bi.canvas_table" + } + } + }, + sequence: { + type: "bi.sequence_table_list_number", + pageSize: 100, + sequenceHeaderCreator: { + type: "bi.normal_sequence_header_cell", + styleGetter: function () { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + } + } + }, + itemsCreator: function (op, populate) { + } + }, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }; + }, + + mounted: function () { + var self = this; + var tableItems = this._expandData(TABLE_ITEMS, 3), + headItems = this._expandHeadData(TABLE_HEADER, 3); + this._resizeHandler = BI.debounce(function () { + var width = self.element.width(), height = self.element.height(); + if (self.table.getWidth() !== width || self.table.getHeight() !== height) { + self.table.setWidth(width); + self.table.setHeight(height); + self.table.populate(); + } + }, 0); + BI.ResizeDetector.addResizeListener(this, function () { + self._resizeHandler(); + }); + this.table.setWidth(this.element.width()); + this.table.setHeight(this.element.height()); + this.table.attr("columnSize", BI.makeArray(headItems[0].length, "")); + this.table.attr("minColumnSize", BI.makeArray(headItems[0].length, 60)); + this.table.attr("isNeedFreeze", true); + this.table.attr("freezeCols", []); + this.table.attr("showSequence", true); + this.table.attr("headerRowSize", 15); + this.table.attr("rowSize", 15); + this.table.populate(tableItems, headItems); + }, + + _expandData: function (items, times) { + var copy = BI.deepClone(items); + for (var m = 0; m < times - 1; m++) { + BI.each(items, function (i, row) { + copy.push(row); + }); + } + + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n % 100], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + }, + + _expandHeadData: function (items, times) { + var copy = BI.deepClone(items); + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + } +}); + +BI.shortcut("demo.canvas_table", Demo.CanvasTable); \ No newline at end of file diff --git a/demo/js/category/canvasTable/newCanvas.js b/demo/js/category/canvasTable/newCanvas.js new file mode 100644 index 000000000..da467c7e1 --- /dev/null +++ b/demo/js/category/canvasTable/newCanvas.js @@ -0,0 +1,228 @@ +/** + * canvas绘图 + * + * Created by Shichao on 2017/09/29. + * @class BI.CanvasNew + * @extends BI.Widget + */ +BI.CanvasNew = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.CanvasNew.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-new" + }) + }, + + _init: function () { + BI.CanvasNew.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var canvas = this._createHiDPICanvas(o.width, o.height); + this.element.append(canvas); + this.canvas = canvas; + this._queue = []; + }, + + _getContext: function () { + if (!this.ctx) { + this.ctx = this.canvas.getContext('2d'); + } + return this.ctx; + }, + + getContext: function () { + return this._getContext(); + }, + + _getPixelRatio: function () { + var ctx = document.createElement("canvas").getContext("2d"), + dpr = window.devicePixelRatio || 1, + bsr = ctx.webkitBackingStorePixelRatio || + ctx.mozBackingStorePixelRatio || + ctx.msBackingStorePixelRatio || + ctx.oBackingStorePixelRatio || + ctx.backingStorePixelRatio || 1; + return dpr / bsr; + }, + + getPixelRatio: function () { + return this._getPixelRatio(); + }, + + _createHiDPICanvas: function (w, h, ratio) { + if (!ratio) { + ratio = this._getPixelRatio(); + } + this.ratio = ratio; + var canvas = document.createElement("canvas"); + if (!document.createElement('canvas').getContext) { + canvas = window.G_vmlCanvasManager.initElement(canvas); + } + canvas.width = w * ratio; + canvas.height = h * ratio; + canvas.style.width = w + "px"; + canvas.style.height = h + "px"; + canvas.getContext("2d").setTransform(ratio, 0, 0, ratio, 0, 0); + return canvas; + }, + + _attr: function (key, value) { + var self = this; + if (BI.isNull(key)) { + return; + } + if (BI.isObject(key)) { + BI.each(key, function (k, v) { + self._queue.push({ k: k, v: v }); + }); + return; + } + this._queue.push({ k: key, v: value }); + }, + + _line: function (x0, y0) { + var self = this; + var args = [].slice.call(arguments, 2); + if (BI.isOdd(args.length)) { + this._attr(BI.last(args)); + args = BI.initial(args); + } + this._attr("moveTo", [x0, y0]); + var odd = BI.filter(args, function (i) { + return i % 2 === 0; + }); + var even = BI.filter(args, function (i) { + return i % 2 !== 0; + }); + args = BI.zip(odd, even); + BI.each(args, function (i, point) { + self._attr("lineTo", point); + }); + }, + + line: function (x0, y0, x1, y1) { + this._line.apply(this, arguments); + this._attr("stroke", []); + }, + + rect: function (x, y, w, h, color) { + this._attr("fillStyle", color); + this._attr("fillRect", [x, y, w, h]); + }, + + circle: function (x, y, radius, color) { + this._attr({ + fillStyle: color, + beginPath: [], + arc: [x, y, radius, 0, Math.PI * 2, true], + closePath: [], + fill: [] + }); + }, + + hollow: function () { + this._attr("beginPath", []); + this._line.apply(this, arguments); + this._attr("closePath", []); + this._attr("stroke", []); + }, + + solid: function () { + this.hollow.apply(this, arguments); + this._attr("fill", []); + }, + + text: function (x, y, text, fillStyle) { + this._attr("fillStyle", BI.isNull(fillStyle) ? "rgb(102, 102, 102)" : fillStyle); + this._attr("fillText", [text, x, y]); + }, + + setFontStyle: function (fontStyle) { + this.fontStyle = fontStyle; + }, + + setFontVariant: function (fontVariant) { + this.fontVariant = fontVariant; + }, + + setFontWeight: function (fontWeight) { + this.fontWeight = fontWeight; + }, + + setFontSize: function (fontSize) { + this.fontSize = fontSize; + }, + + setFontFamily: function (fontFamily) { + this.fontFamily = fontFamily; + }, + + setFont: function () { + var fontStyle = this.fontStyle || "", + fontVariant = this.fontVariant || "", + fontWeight = this.fontWeight || "", + fontSize = this.fontSize || "12px", + fontFamily = this.fontFamily || "sans-serif", + font = fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + " " + fontFamily; + this._getContext().font = font; + }, + + gradient: function (x0, y0, x1, y1, start, end) { + var grd = this._getContext().createLinearGradient(x0, y0, x1, y1); + grd.addColorStop(0, start); + grd.addColorStop(1, end); + return grd; + }, + + reset: function (x, y) { + this._getContext().clearRect(x, y, this.canvas.width, this.canvas.height); + }, + + remove: function (x, y, width, height) { + this._getContext().clearRect(x, y, width, height); + }, + + stroke: function (callback) { + var self = this; + BI.nextTick(function () { + var ctx = self._getContext(); + BI.each(self._queue, function (i, q) { + if (BI.isFunction(ctx[q.k])) { + ctx[q.k].apply(ctx, q.v); + } else { + ctx[q.k] = q.v; + } + }); + self._queue = []; + callback && callback(); + }); + }, + + setWidth: function (width) { + BI.CanvasNew.superclass.setWidth.apply(this, arguments); + this.ratio = this._getPixelRatio(); + this.canvas.width = width * this.ratio; + this.canvas.style.width = width + "px"; + this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); + }, + + setHeight: function (height) { + BI.CanvasNew.superclass.setHeight.apply(this, arguments); + this.ratio = this._getPixelRatio(); + this.canvas.height = height * this.ratio; + this.canvas.style.height = height + "px"; + this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); + }, + + setBlock: function () { + this.canvas.style.display = "block"; + }, + + transform: function (a, b, c, d, e, f) { + this._attr("transform", [a, b, c, d, e, f]); + }, + + translate: function (x, y) { + this._attr("translate", [x, y]); + } + }); + BI.shortcut("bi.canvas_new", BI.CanvasNew); \ No newline at end of file diff --git a/demo/js/category/largeTable/largeTable.js b/demo/js/category/largeTable/largeTable.js index a0e113849..d0330bccb 100644 --- a/demo/js/category/largeTable/largeTable.js +++ b/demo/js/category/largeTable/largeTable.js @@ -72,6 +72,8 @@ Demo.Face = BI.inherit(BI.Widget, { mounted: function () { var self = this; + var tableItems = this._expandData(TABLE_ITEMS, 3), + headItems = this._expandHeadData(TABLE_HEADER, 3); this._resizeHandler = BI.debounce(function () { var width = self.element.width(), height = self.element.height(); if (self.table.getWidth() !== width || self.table.getHeight() !== height) { @@ -85,14 +87,44 @@ Demo.Face = BI.inherit(BI.Widget, { }); this.table.setWidth(this.element.width()); this.table.setHeight(this.element.height()); - this.table.attr("columnSize", BI.makeArray(26, "")); - this.table.attr("minColumnSize", BI.makeArray(26, 80)); + this.table.attr("columnSize", BI.makeArray(headItems[0].length, "")); + this.table.attr("minColumnSize", BI.makeArray(headItems[0].length, 60)); this.table.attr("isNeedFreeze", true); this.table.attr("freezeCols", []); this.table.attr("showSequence", true); - this.table.attr("headerRowSize", 25); - this.table.attr("rowSize", 25); - this.table.populate(TABLE_ITEMS, TABLE_HEADER); + this.table.attr("headerRowSize", 15); + this.table.attr("rowSize", 15); + this.table.populate(tableItems, headItems); + }, + + _expandData: function (items, times) { + var copy = BI.deepClone(items); + for (var m = 0; m < times - 1; m++) { + BI.each(items, function (i, row) { + copy.push(row); + }); + } + + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n % 100], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + }, + + _expandHeadData: function (items, times) { + var copy = BI.deepClone(items); + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; } }); BI.shortcut("demo.large_table", Demo.Face); \ No newline at end of file diff --git a/demo/js/config/category.js b/demo/js/config/category.js index 8d806c02e..93c5ea765 100644 --- a/demo/js/config/category.js +++ b/demo/js/config/category.js @@ -9,6 +9,10 @@ Demo.CATEGORY_CONFIG = [{ pId: 100000, text: "大表格", value: "demo.large_table" +}, { + pId: 100000, + text: "Canvas大表格", + value: "demo.canvas_table" }, { pId: 100000, text: "可以排序的树", diff --git a/dist/bundle.js b/dist/bundle.js index 3f1c8adb4..223caa6a6 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -15901,7 +15901,7 @@ BI.View.registerVMRouter = function (viewRouter, modelRouter) { }; BI.createWidget = function (item, options) { - var el; + var el, w; options || (options = {}); if (BI.isEmpty(item) && BI.isEmpty(options)) { return BI.createWidget({ @@ -15913,11 +15913,13 @@ BI.View.registerVMRouter = function (viewRouter, modelRouter) { } if (item && (item.type || options.type)) { el = BI.extend({}, options, item); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && BI.isWidget(item.el)) { return item.el; @@ -80353,6 +80355,894 @@ BI.extend(BI.Arrangement, { } }); BI.shortcut('bi.arrangement', BI.Arrangement);/** + * Created By Shichao on 2017/10/17 + * @class BI.CanvasCollectionView + * @extends BI.Widget + */ +BI.CanvasCollectionView = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasCollectionView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection", + overflowX: true, + overflowY: true, + cellSizeAndPositionGetter: BI.emptyFn, + horizontalOverscanSize: 0, + verticalOverscanSize: 0, + scrollLeft: 0, + scrollTop: 0, + items: [] + }) + }, + + _init: function () { + BI.CanvasCollectionView.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.renderedCells = []; + this.renderedKeys = []; + this._scrollLock = false; + this.scrollTop = this.scrollLeft = 0; + this.summaryScrollTop = this.summaryScrollLeft = 0; + this._debounceRelease = BI.debounce(function () { + self._scrollLock = false; + }, 1000 / 60); + this.canvas = BI.createWidget({ + type: "bi.canvas_new" + }); + $(document).keydown(BI.bind(this._onResize, this)); // 防止在使用ctrl + 滚轮调整窗口大小时触发mousewheel事件 + $(document).keyup(BI.bind(this._onResizeRelease, this)) + this.element.mousewheel(BI.bind(this._onMouseWheel, this)) + BI.createWidget({ + type: "bi.vertical", + element: this, + scrollable: false, + scrolly: false, + scrollx: false, + items: [this.canvas] + }); + if (o.items.length > 0) { + this._calculateSizeAndPositionData(); + this._populate(); + } + if (o.scrollLeft !== 0 || o.scrollTop !== 0) { + BI.nextTick(function () { + self.element.scrollTop(o.scrollTop); + self.element.scrollLeft(o.scrollLeft); + }); + } + }, + + _onMouseWheel: function (e) { + var o = this.options; + if (this._scrollLock) { + return; + } + if (!this._isCtrlPressed) { + o.scrollTop += -e.originalEvent.wheelDelta; + o.scrollTop = BI.clamp(o.scrollTop, 0, this.maxScrollTop); + this._calculateChildrenToRender(); + this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL, { + scrollLeft: o.scrollLeft, + scrollTop: o.scrollTop + }); + } + }, + + _onResize: function (e) { + if (e.ctrlKey) { + this._isCtrlPressed = true; + } else { + this._isCtrlPressed = false; + } + }, + + _onResizeRelease: function (e) { + var Keys = { + CTRL: 17 + }; + var keyCode = e.keyCode; + + if (keyCode === Keys.CTRL) { + this._isCtrlPressed = false; + } + }, + + _getMaxScrollTop: function () { + return this._height - this.options.height + }, + + _calculateSizeAndPositionData: function () { + var o = this.options; + var cellMetadata = []; + var sectionManager = new BI.SectionManager(); + var height = 0; + var width = 0; + + for (var index = 0, len = o.items.length; index < len; index++) { + var cellMetadatum = o.cellSizeAndPositionGetter(index); + + if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || + cellMetadatum.width == null || isNaN(cellMetadatum.width) || + cellMetadatum.x == null || isNaN(cellMetadatum.x) || + cellMetadatum.y == null || isNaN(cellMetadatum.y)) { + throw Error(); + } + + height = Math.max(height, cellMetadatum.y + cellMetadatum.height); + width = Math.max(width, cellMetadatum.x + cellMetadatum.width); + + cellMetadatum.index = index; + cellMetadata[index] = cellMetadatum; + sectionManager.registerCell(cellMetadatum, index); + } + + this._cellMetadata = cellMetadata; + this._sectionManager = sectionManager; + if (this._height === height && this._width === width) { + this._isNeedReset = false; + } else { + this._height = height; + this._width = width; + this._isNeedReset = true; + } + this.maxScrollTop = this._getMaxScrollTop(); + }, + + _cellRenderers: function (height, width, x, y) { + this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); + return this._cellGroupRenderer(); + }, + + _cellGroupRenderer: function () { + var self = this, o = this.options; + var rendered = []; + BI.each(this._lastRenderedCellIndices, function (i, index) { + var cellMetadata = self._sectionManager.getCellMetadata(index); + rendered.push(cellMetadata); + }); + return rendered; + }, + + _calculateChildrenToRender: function () { + var x, y, cellWidth, cellHeight, cellRow, cellCol, value, self = this, o = this.options; + var scrollLeft = o.scrollLeft; + var scrollTop = o.scrollTop; + var left = Math.max(0, scrollLeft - o.horizontalOverscanSize); + var top = Math.max(0, scrollTop - o.verticalOverscanSize); + var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); + var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); + if (right > 0 && bottom > 0) { + var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); + this.canvas.remove(this.scrollLeft, this.scrollTop, o.width, o.height); + for (var i = 0; i < childrenToDisplay.length; i++) { + var datum = childrenToDisplay[i]; + var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; + var rect_tl_x = datum.x, + rect_tl_y = datum.y, + rect_tr_x = rect_tl_x + datum.width, + rect_bl_y = rect_tl_y + datum.height, + cell = o.items[datum.index].cell || o.items[datum.index], + background, color, fontWeight, text; + while (BI.isNull(cell.styles) && !BI.isFunction(cell.styleGetter)) { + cell = cell.cell; + } + if (BI.isNull(cell.styles) && BI.isFunction(cell.styleGetter)) { + background = cell.styleGetter().background; + color = cell.styleGetter().color; + fontWeight = cell.styleGetter().fontWeight; + } else if (!BI.isNull(cell.styles)) { + background = cell.styles.background; + color = cell.styles.color; + fontWeight = cell.styles.fontWeight; + } + if (BI.isNull(cell.text)) { + text = ""; + } else { + text = cell.text; + } + if (!BI.isString(text)) { + text = text.toString(); + } + if (this.scrollLeft !== o.scrollLeft) { + this.canvas.translate(this.scrollLeft - o.scrollLeft, 0); + this.scrollLeft = o.scrollLeft; + } + if (this.scrollTop !== o.scrollTop) { + this.canvas.translate(0, this.scrollTop - o.scrollTop); + this.scrollTop = o.scrollTop; + } + if (datum.x === 0 && datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.x === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tr_x, rect_tl_y, rect_tr_x, rect_bl_y, rect_tl_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else { + this.canvas.solid(rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } + this.canvas.setFontWeight(fontWeight); + this.canvas.setFont(); + var font = this.canvas.getContext().font, + textSize = this._getTextPixel(font), + textHeight = textSize, + textWidth = this.canvas.getContext().measureText(text).width, + dotsWidth = this.canvas.getContext().measureText("...").width; + var offsetX = this._calcOffsetX(textWidth, datum.width, "center"), + offsetY = this._calcOffsetY(textHeight, datum.height, "center"); + if (textHeight > datum.height) { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, "...", color); + } else if (textWidth + 4 > datum.width) { + var sliceIndex = Math.floor((datum.width - dotsWidth - 4) / textWidth * text.length); + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text.slice(0, sliceIndex) + "...", color); + } else { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text, color); + } + this.canvas.stroke(); + } + } + }, + + _getTextPixel: function (font) { + var p = font.split("px")[0], + s = p.split(" "); + for (var c in s) { + var num; + num = BI.parseInt(s[c]); + if (!BI.isNaN(num)) { + return num; + } + } + }, + + _calcOffsetX: function (textWidth, cellWidth, position) { + switch (position) { + case "center": + if (textWidth >= cellWidth) { + return 4; + } else { + return (cellWidth - textWidth) / 2; + } + case "right": + if (textWidth >= cellWidth) { + return 0; + } else { + return cellWidth - textWidth; + } + default: + return 0; + } + }, + + _calcOffsetY: function (textHeight, cellHeight, position) { + switch (position) { + case "center": + if (textHeight >= cellHeight) { + return textHeight; + } else { + return (cellHeight + textHeight) / 2; + } + case "bottom": + if (textHeight >= cellHeight) { + return cellHeight; + } else { + return cellHeight + textHeight; + } + default: + return textHeight; + } + }, + + _populate: function (items) { + var o = this.options; + if (items && items !== this.options.items) { + this.options.items = items; + this._calculateSizeAndPositionData(); + } + if (o.items.length > 0) { + this.canvas.setBlock(); + this.canvas.setWidth(o.width); + this.canvas.setHeight(o.height); + this.restore(); + this._calculateChildrenToRender(); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); + } + }, + + populate: function (items) { + if (items && items !== this.options.items) { + this.restore(); + } + this._populate(items); + }, + + setWidth: function (width) { + BI.CanvasCollectionView.superclass.setWidth.apply(this, arguments); + this.options.width = width; + }, + + setHeight: function (height) { + BI.CanvasCollectionView.superclass.setHeight.apply(this, arguments); + this.options.height = height; + }, + + restore: function () { + this.canvas.remove(this.scrollLeft, this.scrollTop, this.options.width, this.options.height); + this.renderedKeys = []; + this._scrollLock = false; + }, + + setScrollLeft: function (scrollLeft) { + if (this.options.scrollLeft === scrollLeft) { + return; + } + this._scrollLock = true; + this.options.scrollLeft = scrollLeft; + 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 = scrollTop; + this._debounceRelease(); + this._calculateChildrenToRender(); + this.element.scrollTop(this.options.scrollTop); + }, + + getScrollLeft: function () { + return this.options.scrollLeft; + }, + + getScrollTop: function () { + return this.options.scrollTop; + } +}) +BI.CanvasCollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut("bi.canvas_collection_view", BI.CanvasCollectionView);/** + * Created by Shichao on 2017/10/18 + * @class BI.CanvasTable + * @extends BI.Widget + */ +BI.CanvasTable = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection-table", + headerRowSize: 25, + rowSize: 25, + columnSize: [], + isNeedFreeze: false, + freezeCols: [], + isNeedMerge: false, + mergeCols: [], + mergeRule: BI.emptyFn, + header: [], + items: [], + regionColumnSize: [] + }); + }, + + _init: function () { + BI.CanvasTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._scrollBarSize = BI.DOM.getScrollWidth(); + this.topLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topLeftItems[index]; + } + }); + this.topRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topRightItems[index]; + } + }); + this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomLeftItems[index]; + } + }); + this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollTop(scroll.scrollTop); + self.topLeftCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomRightItems[index]; + } + }); + this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomLeftCollection.setScrollTop(scroll.scrollTop); + self.topRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.topLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topLeftCollection] + }); + this.topRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topRightCollection] + }); + this.bottomLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomLeftCollection] + }); + this.bottomRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomRightCollection] + }); + this.contextLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topLeft, + top: 0, + left: 0, + }, { + el: this.topRight, + top: 0 + }, { + el: this.bottomLeft, + left: 0 + }, { + el: this.bottomRight, + }] + }); + + this.topScrollbar = BI.createWidget({ + type: "bi.grid_table_scrollbar", + width: BI.GridTableScrollbar.SIZE + }); + this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollTop) { + self.bottomLeftCollection.setScrollTop(scrollTop); + self.bottomRightCollection.setScrollTop(scrollTop); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.leftScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topLeftCollection.setScrollLeft(scrollLeft); + self.bottomLeftCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.rightScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topRightCollection.setScrollLeft(scrollLeft); + self.bottomRightCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.scrollBarLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topScrollbar, + right: 0, + top: 0 + }, { + el: this.leftScrollbar, + left: 0, + }, { + el: this.rightScrollbar, + }] + }); + this._width = o.width - BI.GridTableScrollbar.SIZE; + this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; + if (o.items.length > 0 || o.header.length > 0) { + this._digest(); + this._populate(); + } + }, + + attr: function () { + BI.CanvasTable.superclass.attr.apply(this, arguments); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; + }, + + getRegionSize: function () { + var o = this.options; + var regionSize = o.regionColumnSize[0] || 0; + if (o.isNeedFreeze === false || o.freezeCols.length === 0) { + return 0; + } + if (!regionSize) { + BI.each(o.freezeCols, function (i, col) { + regionSize += o.columnSize[col]; + }); + } + return regionSize; + }, + + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + + _digest: function () { + var o = this.options; + var freezeColLength = this._getFreezeColLength(); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } + }, + + _populateScrollbar: function () { + var o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + BI.each(o.columnSize, function (i, size) { + if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { + totalLeftColumnSize += size; + } else { + totalRightColumnSize += size; + } + totalColumnSize += size; + if (i === 0) { + summaryColumnSizeArray[i] = size; + } else { + summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; + } + }); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); + this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); + this.topScrollbar.populate(); + + this.leftScrollbar.setContentSize(totalLeftColumnSize); + this.leftScrollbar.setSize(regionSize); + this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft()); + this.leftScrollbar.populate(); + + this.rightScrollbar.setContentSize(totalRightColumnSize); + this.rightScrollbar.setSize(this._width - regionSize); + this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft()); + this.rightScrollbar.populate(); + + var items = this.scrollBarLayout.attr("items"); + items[0].top = this._getFreezeHeaderHeight(); + items[1].top = this._height; + items[2].top = this._height; + items[2].left = regionSize; + this.scrollBarLayout.attr("items", items); + this.scrollBarLayout.resize(); + }, + + _populateTable: function () { + var self = this, o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + var freezeColLength = this._getFreezeColLength(); + var otlw = regionSize; + var otlh = this._getFreezeHeaderHeight(); + var otrw = this._width - regionSize; + var otrh = this._getFreezeHeaderHeight(); + var oblw = regionSize; + var oblh = this._height - otlh; + var obrw = this._width - regionSize; + var obrh = this._height - otrh; + + var tlw = otlw + this._scrollBarSize; + var tlh = otlh + this._scrollBarSize; + var trw = otrw + this._scrollBarSize; + var trh = otrh + this._scrollBarSize; + var blw = oblw + this._scrollBarSize; + var blh = oblh + this._scrollBarSize; + var brw = obrw + this._scrollBarSize; + var brh = obrh + this._scrollBarSize; + + this.topLeft.setWidth(otlw); + this.topLeft.setHeight(otlh); + this.topRight.setWidth(otrw); + this.topRight.setHeight(otrh); + this.bottomLeft.setWidth(oblw); + this.bottomLeft.setHeight(oblh); + this.bottomRight.setWidth(obrw); + this.bottomRight.setHeight(obrh); + + this.topLeftCollection.setWidth(tlw); + this.topLeftCollection.setHeight(tlh); + this.topRightCollection.setWidth(trw); + this.topRightCollection.setHeight(trh); + this.bottomLeftCollection.setWidth(blw); + this.bottomLeftCollection.setHeight(blh); + this.bottomRightCollection.setWidth(brw); + this.bottomRightCollection.setHeight(brh); + + var items = this.contextLayout.attr("items"); + items[1].left = regionSize; + //items[2].top = this._getFreezeHeaderHeight(); + items[2].top = otrh; + items[3].left = regionSize; + //items[3].top = this._getFreezeHeaderHeight(); + items[3].top = otrh; + this.contextLayout.attr("items", items); + this.contextLayout.resize(); + + var leftHeader = [], rightHeader = [], leftItems = [], rightItems = []; + var run = function (positions, items, rendered) { + BI.each(positions, function (i, item) { + if (BI.isNull(items[item.row][item.col])) { + debugger + } + rendered.push(items[item.row][item.col]); + }); + }; + run(this.topLeftItems, o.header, leftHeader); + run(this.topRightItems, o.header, rightHeader); + run(this.bottomLeftItems, o.items, leftItems); + run(this.bottomRightItems, o.items, rightItems); + + this.topLeftCollection._populate(leftHeader); + this.topRightCollection._populate(rightHeader); + this.bottomLeftCollection._populate(leftItems); + this.bottomRightCollection._populate(rightItems); + }, + + _populate: function () { + if (this._width <= 0 || this._height <= 0) { + return; + } + if (this._isNeedDigest === true) { + this._digest(); + } + this._isNeedDigest = false; + this._populateTable(); + this._populateScrollbar(); + }, + + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; + var self = this, o = this.options; + var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; + var summaryColumnSize = []; + for (var i = startCol; i < endCol; i++) { + if (i === startCol) { + summaryColumnSize[i] = columnSize[i]; + } else { + summaryColumnSize[i] = summaryColumnSize[i - 1] + columnSize[i]; + } + } + var mergeRow = function (i, j) { + preCol[j]._height += rowHeight; + preCol[j].__mergeRows.push(i); + }; + + var mergeCol = function (i, j) { + preRow[i]._width += columnSize[j]; + preRow[i].__mergeCols.push(j); + }; + + var createOneEl = function (r, c) { + var width = columnSize[c]; + var height = rowHeight; + map[r][c]._row = r; + map[r][c]._col = c; + map[r][c]._width = width; + map[r][c]._height = height; + preCol[c] = map[r][c]; + preCol[c].__mergeRows = [r]; + preRow[r] = map[r][c]; + preRow[r].__mergeCols = [c]; + + result.push({ + x: summaryColumnSize[c] - columnSize[c], + y: +r * rowHeight, + item: map[r][c] + }); + }; + + BI.each(items, function (i, cols) { + for (var j = startCol; j < endCol; j++) { + if (!cache[i]) { + cache[i] = {}; + } + if (!map[i]) { + map[i] = {}; + } + cache[i][j] = cols[j]; + map[i][j] = {}; + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { + if (i === 0 && j === startCol) { + createOneEl(0, startCol); + } else if (j === startCol && i > 0) { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + if (isNeedMergeRow === true) { + mergeRow(i, j); + preRow[i] = preCol[j]; + } else { + createOneEl(i, j); + } + } else if (i === 0 && j > startCol) { + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol === true) { + mergeCol(i, j); + preCol[j] = preRow[i]; + } else { + createOneEl(i, j); + } + } else { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol && isNeedMergeRow) { + continue; + //mergeRow(i, j);//优先合并列 + } + if (isNeedMergeCol) { + mergeCol(i, j); + } + if (isNeedMergeRow) { + mergeRow(i, j); + } + if (!isNeedMergeCol && !isNeedMergeRow) { + createOneEl(i, j); + } + } + } else { + createOneEl(i, j); + } + } + }); + return BI.map(result, function (i, item) { + return { + x: item.x, + y: item.y, + row: item.item._row, + col: item.item._col, + width: item.item._width, + height: item.item._height + } + }); + }, + + populate: function (items, header) { + if (items && this.options.items !== items) { + this._isNeedDigest = true; + this.options.items = items; + this._restore(); + } + if (header && this.options.header !== header) { + this._isNeedDigest = true; + this.options.header = header; + this._restore(); + } + this._populate(); + }, + + _restore: function () { + this.topLeftCollection.restore(); + this.topRightCollection.restore(); + this.bottomLeftCollection.restore(); + this.bottomRightCollection.restore(); + }, + + restore: function () { + this._restore(); + }, + + setWidth: function (width) { + BI.CanvasTable.superclass.setWidth.apply(this, arguments); + this._width = width - BI.GridTableScrollbar.SIZE; + }, + + setHeight: function (height) { + BI.CanvasTable.superclass.setHeight.apply(this, arguments); + this._height = height - BI.GridTableScrollbar.SIZE; + }, + + setVerticalScroll: function (scrollTop) { + this.bottomLeftCollection.setScrollTop(scrollTop); + this.bottomRightCollection.setScrollTop(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.topLeftCollection.setScrollLeft(scrollLeft); + this.bottomLeftCollection.setScrollLeft(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.topRightCollection.setScrollLeft(scrollLeft); + this.bottomRightCollection.setScrollLeft(scrollLeft); + }, + + getVerticalScroll: function () { + return this.bottomRightCollection.getScrollTop(); + }, + + getLeftHorizontalScroll: function () { + return this.bottomLeftCollection.getScrollLeft(); + }, + + getRightHorizontalScroll: function () { + return this.bottomRightCollection.getScrollLeft(); + }, + + setColumnSize: function (columnSize) { + this._isNeedDigest = true; + this.options.columnSize = columnSize; + }, + + setRegionColumnSize: function (regionColumnSize) { + this._isNeedDigest = true; + this.options.regionColumnSize = regionColumnSize; + }, + + getColumnSize: function () { + return this.options.columnSize; + }, + + getRegionColumnSize: function () { + return this.options.regionColumnSize; + }, +}); + +BI.shortcut("bi.canvas_table", BI.CanvasTable);/** * 日期控件中的月份下拉框 * * Created by GUY on 2015/9/7. diff --git a/dist/bundle.min.js b/dist/bundle.min.js index 2956f6abe..e043f010c 100644 --- a/dist/bundle.min.js +++ b/dist/bundle.min.js @@ -4,7 +4,7 @@ function accAdd(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g return[c<0?c+b:c]}),even:k(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:k(function(a,b,c){for(var d=c<0?c+b:c;++d1?ia.unique(c):c),c.selector=(this.selector?this.selector+" ":"")+a,c},has:function(a){var b,c=ia(a,this),d=c.length;return this.filter(function(){for(b=0;b=0:ia.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=Sa.test(a)||"string"!=typeof a?ia(a,b||this.context):0;d-1:ia.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}return this.pushStack(f.length>1?ia.unique(f):f)},index:function(a){return a?"string"==typeof a?ia.inArray(this[0],ia(a)):ia.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){var c="string"==typeof a?ia(a,b):ia.makeArray(a&&a.nodeType?[a]:a),d=ia.merge(this.get(),c);return this.pushStack(ia.unique(d))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),ia.fn.andSelf=ia.fn.addBack,ia.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return ia.dir(a,"parentNode")},parentsUntil:function(a,b,c){return ia.dir(a,"parentNode",c)},next:function(a){return k(a,"nextSibling")},prev:function(a){return k(a,"previousSibling")},nextAll:function(a){return ia.dir(a,"nextSibling")},prevAll:function(a){return ia.dir(a,"previousSibling")},nextUntil:function(a,b,c){return ia.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return ia.dir(a,"previousSibling",c)},siblings:function(a){return ia.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return ia.sibling(a.firstChild)},contents:function(a){return ia.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:ia.merge([],a.childNodes)}},function(a,b){ia.fn[a]=function(c,d){var e=ia.map(this,b,c);return Pa.test(a)||(d=c),d&&"string"==typeof d&&(e=ia.filter(d,e)),e=this.length>1&&!Ta[a]?ia.unique(e):e,this.length>1&&Qa.test(a)&&(e=e.reverse()),this.pushStack(e)}}),ia.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),1===b.length?ia.find.matchesSelector(b[0],a)?[b[0]]:[]:ia.find.matches(a,b)},dir:function(a,c,d){for(var e=[],f=a[c];f&&9!==f.nodeType&&(d===b||1!==f.nodeType||!ia(f).is(d));)1===f.nodeType&&e.push(f),f=f[c];return e},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}});var Ua="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Va=/ jQuery\d+="(?:null|\d+)"/g,Wa=new RegExp("<(?:"+Ua+")[\\s/>]","i"),Xa=/^\s+/,Ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Za=/<([\w:]+)/,$a=/\s*$/g,gb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:ia.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},hb=m(W),ib=hb.appendChild(W.createElement("div"));gb.optgroup=gb.option,gb.tbody=gb.tfoot=gb.colgroup=gb.caption=gb.thead,gb.th=gb.td,ia.fn.extend({text:function(a){return ia.access(this,function(a){return a===b?ia.text(this):this.empty().append((this[0]&&this[0].ownerDocument||W).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(ia.isFunction(a))return this.each(function(b){ia(this).wrapAll(a.call(this,b))});if(this[0]){var b=ia(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return ia.isFunction(a)?this.each(function(b){ia(this).wrapInner(a.call(this,b))}):this.each(function(){var b=ia(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=ia.isFunction(a);return this.each(function(c){ia(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){ia.nodeName(this,"body")||ia(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.insertBefore(a,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||ia.filter(a,[c]).length>0)&&(b||1!==c.nodeType||ia.cleanData(t(c)),c.parentNode&&(b&&ia.contains(c.ownerDocument,c)&&q(t(c,"script")),c.parentNode.removeChild(c)));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){for(1===a.nodeType&&ia.cleanData(t(a,!1));a.firstChild;)a.removeChild(a.firstChild);a.options&&ia.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return ia.clone(this,a,b)})},html:function(a){return ia.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Va,""):b;if("string"==typeof a&&!ab.test(a)&&(ia.support.htmlSerialize||!Wa.test(a))&&(ia.support.leadingWhitespace||!Xa.test(a))&&!gb[(Za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ya,"<$1>");try{for(;d")?f=a.cloneNode(!0):(ib.innerHTML=a.outerHTML,ib.removeChild(f=ib.firstChild)),!(ia.support.noCloneEvent&&ia.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||ia.isXMLDoc(a)))for(d=t(f),h=t(a),g=0;null!=(e=h[g]);++g)d[g]&&s(e,d[g]);if(b)if(c)for(h=h||t(a),d=d||t(f),g=0;null!=(e=h[g]);g++)r(e,d[g]);else r(a,f);return d=t(f,"script"),d.length>0&&q(d,!i&&t(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,l=a.length,n=m(b),o=[],p=0;p")+k[2],e=k[0];e--;)h=h.lastChild;if(!ia.support.leadingWhitespace&&Xa.test(f)&&o.push(b.createTextNode(Xa.exec(f)[0])),!ia.support.tbody)for(f="table"!==i||$a.test(f)?""!==k[1]||$a.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;e--;)ia.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j);for(ia.merge(o,h.childNodes),h.textContent="";h.firstChild;)h.removeChild(h.firstChild);h=n.lastChild}else o.push(b.createTextNode(f));for(h&&n.removeChild(h),ia.support.appendChecked||ia.grep(t(o,"input"),u),p=0;f=o[p++];)if((!d||ia.inArray(f,d)===-1)&&(g=ia.contains(f.ownerDocument,f),h=t(n.appendChild(f),"script"),g&&q(h),c))for(e=0;f=h[e++];)db.test(f.type||"")&&c.push(f);return h=null,n},cleanData:function(a,b){for(var c,d,e,f,g=0,h=ia.expando,i=ia.cache,j=ia.support.deleteExpando,k=ia.event.special;null!=(c=a[g]);g++)if((b||ia.acceptData(c))&&(e=c[h],f=e&&i[e])){if(f.events)for(d in f.events)k[d]?ia.event.remove(c,d):ia.removeEvent(c,d,f.handle);i[e]&&(delete i[e],j?delete c[h]:typeof c.removeAttribute!==V?c.removeAttribute(h):c[h]=null,_.push(e))}}});var jb,kb,lb,mb=/alpha\([^)]*\)/i,nb=/opacity\s*=\s*([^)]*)/,ob=/^(top|right|bottom|left)$/,pb=/^(none|table(?!-c[ea]).+)/,qb=/^margin/,rb=new RegExp("^("+ja+")(.*)$","i"),sb=new RegExp("^("+ja+")(?!px)[a-z%]+$","i"),tb=new RegExp("^([+-])=("+ja+")","i"),ub={BODY:"block"},vb={position:"absolute",visibility:"hidden",display:"block"},wb={letterSpacing:0,fontWeight:400},xb=["Top","Right","Bottom","Left"],yb=["Webkit","O","Moz","ms"];ia.fn.extend({css:function(a,c){return ia.access(this,function(a,c,d){var e,f,g={},h=0;if(ia.isArray(c)){for(f=kb(a),e=c.length;h1)},show:function(){return x(this,!0)},hide:function(){return x(this)},toggle:function(a){var b="boolean"==typeof a;return this.each(function(){(b?a:w(this))?ia(this).show():ia(this).hide()})}}),ia.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=lb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ia.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=ia.camelCase(c),j=a.style;if(c=ia.cssProps[i]||(ia.cssProps[i]=v(j,i)),h=ia.cssHooks[c]||ia.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=tb.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(ia.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||ia.cssNumber[i]||(d+="px"),ia.support.clearCloneStyle||""!==d||0!==c.indexOf("background")||(j[c]="inherit"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=ia.camelCase(c);return c=ia.cssProps[i]||(ia.cssProps[i]=v(a.style,i)),h=ia.cssHooks[c]||ia.cssHooks[i],h&&"get"in h&&(g=h.get(a,!0,d)),g===b&&(g=lb(a,c,e)),"normal"===g&&c in wb&&(g=wb[c]),""===d||d?(f=parseFloat(g),d===!0||ia.isNumeric(f)?f||0:g):g},swap:function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e}}),a.getComputedStyle?(kb=function(b){return a.getComputedStyle(b,null)},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h.getPropertyValue(c)||h[c]:b,j=a.style;return h&&(""!==i||ia.contains(a.ownerDocument,a)||(i=ia.style(a,c)),sb.test(i)&&qb.test(c)&&(e=j.width,f=j.minWidth,g=j.maxWidth,j.minWidth=j.maxWidth=j.width=i,i=h.width,j.width=e,j.minWidth=f,j.maxWidth=g)),i}):W.documentElement.currentStyle&&(kb=function(a){return a.currentStyle},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h[c]:b,j=a.style;return null==i&&j&&j[c]&&(i=j[c]),sb.test(i)&&!ob.test(c)&&(e=j.left,f=a.runtimeStyle,g=f&&f.left,g&&(f.left=a.currentStyle.left),j.left="fontSize"===c?"1em":i,i=j.pixelLeft+"px",j.left=e,g&&(f.left=g)),""===i?"auto":i}),ia.each(["height","width"],function(a,b){ia.cssHooks[b]={get:function(a,c,d){if(c)return 0===a.offsetWidth&&pb.test(ia.css(a,"display"))?ia.swap(a,vb,function(){return A(a,b,d)}):A(a,b,d)},set:function(a,c,d){var e=d&&kb(a);return y(a,c,d?z(a,b,d,ia.support.boxSizing&&"border-box"===ia.css(a,"boxSizing",!1,e),e):0)}}}),ia.support.opacity||(ia.cssHooks.opacity={get:function(a,b){return nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=ia.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===ia.trim(f.replace(mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=mb.test(f)?f.replace(mb,e):f+" "+e)}}),ia(function(){ia.support.reliableMarginRight||(ia.cssHooks.marginRight={get:function(a,b){if(b)return ia.swap(a,{display:"inline-block"},lb,[a,"marginRight"])}}),!ia.support.pixelPosition&&ia.fn.position&&ia.each(["top","left"],function(a,b){ia.cssHooks[b]={get:function(a,c){if(c)return c=lb(a,b),sb.test(c)?ia(a).position()[b]+"px":c}}})}),ia.expr&&ia.expr.filters&&(ia.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!ia.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||ia.css(a,"display"))},ia.expr.filters.visible=function(a){return!ia.expr.filters.hidden(a)}),ia.each({margin:"",padding:"",border:"Width"},function(a,b){ia.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+xb[d]+b]=f[d]||f[d-2]||f[0];return e}},qb.test(a)||(ia.cssHooks[a+b].set=y)});var zb=/%20/g,Ab=/\[\]$/,Bb=/\r?\n/g,Cb=/^(?:submit|button|image|reset|file)$/i,Db=/^(?:input|select|textarea|keygen)/i;ia.fn.extend({serialize:function(){return ia.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=ia.prop(this,"elements");return a?ia.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!ia(this).is(":disabled")&&Db.test(this.nodeName)&&!Cb.test(a)&&(this.checked||!bb.test(a))}).map(function(a,b){var c=ia(this).val();return null==c?null:ia.isArray(c)?ia.map(c,function(a){return{name:b.name,value:a.replace(Bb,"\r\n")}}):{name:b.name,value:c.replace(Bb,"\r\n")}}).get()}}),ia.param=function(a,c){var d,e=[],f=function(a,b){b=ia.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=ia.ajaxSettings&&ia.ajaxSettings.traditional),ia.isArray(a)||a.jquery&&!ia.isPlainObject(a))ia.each(a,function(){f(this.name,this.value)});else for(d in a)D(d,a[d],c,f);return e.join("&").replace(zb,"+")},ia.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){ia.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),ia.fn.hover=function(a,b){return this.mouseenter(a).mouseleave(b||a)};var Eb,Fb,Gb=ia.now(),Hb=/\?/,Ib=/#.*$/,Jb=/([?&])_=[^&]*/,Kb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Lb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mb=/^(?:GET|HEAD)$/,Nb=/^\/\//,Ob=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Pb=ia.fn.load,Qb={},Rb={},Sb="*/".concat("*");try{Fb=X.href}catch(Tb){Fb=W.createElement("a"),Fb.href="",Fb=Fb.href}Eb=Ob.exec(Fb.toLowerCase())||[],ia.fn.load=function(a,c,d){if("string"!=typeof a&&Pb)return Pb.apply(this,arguments);var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),ia.isFunction(c)?(d=c,c=b):c&&"object"==typeof c&&(g="POST"),h.length>0&&ia.ajax({url:a,type:g,dataType:"html",data:c}).done(function(a){f=arguments,h.html(e?ia("
").append(ia.parseHTML(a)).find(e):a)}).complete(d&&function(a,b){h.each(d,f||[a.responseText,b,a])}),this},ia.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){ia.fn[b]=function(a){return this.on(b,a)}}),ia.each(["get","post"],function(a,c){ia[c]=function(a,d,e,f){return ia.isFunction(d)&&(f=f||e,e=d,d=b),ia.ajax({url:a,type:c,dataType:f,data:d,success:e})}}),ia.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fb,type:"GET",isLocal:Lb.test(Eb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Sb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":ia.parseJSON,"text xml":ia.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?G(G(a,ia.ajaxSettings),b):G(ia.ajaxSettings,a)},ajaxPrefilter:E(Qb),ajaxTransport:E(Rb),ajax:function(a,c){function d(a,c,d,e){var f,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),k=b,h=e||"",w.readyState=a>0?4:0,d&&(t=H(m,w,d)),a>=200&&a<300||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&(ia.lastModified[g]=v),v=w.getResponseHeader("etag"),v&&(ia.etag[g]=v)),204===a?(f=!0,x="nocontent"):304===a?(f=!0,x="notmodified"):(f=I(m,t),x=f.state,l=f.data,s=f.error,f=!s)):(s=x,!a&&x||(x="error",a<0&&(a=0))),w.status=a,w.statusText=(c||x)+"",f?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,j&&o.trigger(f?"ajaxSuccess":"ajaxError",[w,m,f?l:s]),q.fireWith(n,[w,x]),j&&(o.trigger("ajaxComplete",[w,m]),--ia.active||ia.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=ia.ajaxSetup({},c),n=m.context||m,o=m.context&&(n.nodeType||n.jquery)?ia(n):ia.event,p=ia.Deferred(),q=ia.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,getResponseHeader:function(a){var b;if(2===u){if(!l)for(l={};b=Kb.exec(h);)l[b[1].toLowerCase()]=b[2];b=l[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===u?h:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return u||(a=t[c]=t[c]||a,s[a]=b),this},overrideMimeType:function(a){return u||(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(u<2)for(b in a)r[b]=[r[b],a[b]];else w.always(a[w.status]);return this},abort:function(a){var b=a||v;return k&&k.abort(b),d(0,b),this}};if(p.promise(w).complete=q.add,w.success=w.done,w.error=w.fail,m.url=((a||m.url||Fb)+"").replace(Ib,"").replace(Nb,Eb[1]+"//"),m.type=c.method||c.type||m.method||m.type,m.dataTypes=ia.trim(m.dataType||"*").toLowerCase().match(ka)||[""],null==m.crossDomain&&(e=Ob.exec(m.url.toLowerCase()),m.crossDomain=!(!e||e[1]===Eb[1]&&e[2]===Eb[2]&&(e[3]||("http:"===e[1]?80:443))==(Eb[3]||("http:"===Eb[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=ia.param(m.data,m.traditional)),F(Qb,m,c,w),2===u)return w;j=m.global,j&&0===ia.active++&&ia.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!Mb.test(m.type),g=m.url,m.hasContent||(m.data&&(g=m.url+=(Hb.test(g)?"&":"?")+m.data,delete m.data),m.cache===!1&&(m.url=Jb.test(g)?g.replace(Jb,"$1_="+Gb++):g+(Hb.test(g)?"&":"?")+"_="+Gb++)),m.ifModified&&(ia.lastModified[g]&&w.setRequestHeader("If-Modified-Since",ia.lastModified[g]),ia.etag[g]&&w.setRequestHeader("If-None-Match",ia.etag[g])),(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Sb+"; q=0.01":""):m.accepts["*"]);for(f in m.headers)w.setRequestHeader(f,m.headers[f]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(f in{success:1,error:1,complete:1})w[f](m[f]);if(k=F(Rb,m,c,w)){w.readyState=1,j&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,k.send(s,d)}catch(x){if(!(u<2))throw x;d(-1,x)}}else d(-1,"No Transport");return w},getScript:function(a,c){return ia.get(a,b,c,"script")},getJSON:function(a,b,c){return ia.get(a,b,c,"json")}}),ia.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return ia.globalEval(a),a}}}),ia.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),ia.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=W.head||ia("head")[0]||W.documentElement;return{send:function(b,e){c=W.createElement("script"),c.async=!0,a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,b){(b||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c.parentNode&&c.parentNode.removeChild(c),c=null,b||e(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(b,!0)}}}});var Ub=[],Vb=/(=)\?(?=&|$)|\?\?/;ia.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Ub.pop()||ia.expando+"_"+Gb++;return this[a]=!0,a}}),ia.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.jsonp!==!1&&(Vb.test(c.url)?"url":"string"==typeof c.data&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vb.test(c.data)&&"data");if(i||"jsonp"===c.dataTypes[0])return f=c.jsonpCallback=ia.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,i?c[i]=c[i].replace(Vb,"$1"+f):c.jsonp!==!1&&(c.url+=(Hb.test(c.url)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||ia.error(f+" was not called"),h[0]},c.dataTypes[0]="json",g=a[f],a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Ub.push(f)),h&&ia.isFunction(g)&&g(h[0]),h=g=b}),"script"});var Wb,Xb,Yb=0,Zb=a.ActiveXObject&&function(){var a;for(a in Wb)Wb[a](b,!0)};ia.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&J()||K()}:J,Xb=ia.ajaxSettings.xhr(),ia.support.cors=!!Xb&&"withCredentials"in Xb,Xb=ia.support.ajax=!!Xb,Xb&&ia.ajaxTransport(function(c){if(!c.crossDomain||ia.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=ia.noop,Zb&&delete Wb[g]),e)4!==i.readyState&&i.abort();else{l={},h=i.status,j=i.getAllResponseHeaders(),"string"==typeof i.responseText&&(l.text=i.responseText);try{k=i.statusText}catch(m){k=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(n){e||f(-1,n)}l&&f(h,k,l,j)},c.async?4===i.readyState?setTimeout(d):(g=++Yb,Zb&&(Wb||(Wb={},ia(a).unload(Zb)),Wb[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(b,!0)}}}});var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+ja+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[P],ec={"*":[function(a,b){var c,d,e=this.createTween(a,b),f=bc.exec(b),g=e.cur(),h=+g||0,i=1,j=20;if(f){if(c=+f[2],d=f[3]||(ia.cssNumber[a]?"":"px"),"px"!==d&&h){h=ia.css(e.elem,a,!0)||c||1;do i=i||".5",h/=i,ia.style(e.elem,a,h+d);while(i!==(i=e.cur()/g)&&1!==i&&--j)}e.unit=d,e.start=h,e.end=f[1]?h+(f[1]+1)*c:c}return e}]};ia.Animation=ia.extend(N,{tweener:function(a,b){ia.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;d-1,l={},m={};k?(m=g.position(),e=m.top,f=m.left):(e=parseFloat(i)||0,f=parseFloat(j)||0),ia.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(l.top=b.top-h.top+e),null!=b.left&&(l.left=b.left-h.left+f),"using"in b?b.using.call(a,l):g.css(l)}},ia.fn.extend({position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===ia.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),ia.nodeName(a[0],"html")||(c=a.offset()),c.top+=ia.css(a[0],"borderTopWidth",!0),c.left+=ia.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-ia.css(d,"marginTop",!0),left:b.left-c.left-ia.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||W.documentElement;a&&!ia.nodeName(a,"html")&&"static"===ia.css(a,"position");)a=a.offsetParent;return a||W.documentElement})}}),ia.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);ia.fn[a]=function(e){return ia.access(this,function(a,e,f){var g=S(a);return f===b?g?c in g?g[c]:g.document.documentElement[e]:a[e]:void(g?g.scrollTo(d?ia(g).scrollLeft():f,d?f:ia(g).scrollTop()):a[e]=f)},a,e,arguments.length,null)}}),ia.each({Height:"height",Width:"width"},function(a,c){ia.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){ia.fn[e]=function(e,f){var g=arguments.length&&(d||"boolean"!=typeof e),h=d||(e===!0||f===!0?"margin":"border");return ia.access(this,function(c,d,e){var f;return ia.isWindow(c)?c.document.documentElement["client"+a]:9===c.nodeType?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?ia.css(c,d,h):ia.style(c,d,e,h)},c,g?e:b,g,null)}})}),a.jQuery=a.$=ia,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return ia})}(window),function(){function a(a){function b(b,c,d,e,f,g){for(;f>=0&&f0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function b(a){return function(b,c,d){c=t(c,d);for(var e=null!=b&&b.length,f=a>0?0:e-1;f>=0&&f=0&&b<=w};r.each=r.forEach=function(a,b,c){b=s(b,c);var d,e;if(x(a))for(d=0,e=a.length;d=0},r.invoke=function(a,b){var c=j.call(arguments,2),d=r.isFunction(b);return r.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},r.pluck=function(a,b){return r.map(a,r.property(b))},r.where=function(a,b){return r.filter(a,r.matcher(b))},r.findWhere=function(a,b){return r.find(a,r.matcher(b))},r.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=x(a)?a:r.values(a);for(var h=0,i=a.length;hf&&(f=d)}else b=t(b,c),r.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},r.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=x(a)?a:r.values(a);for(var h=0,i=a.length;hd||void 0===c)return 1;if(c=0;)if(a[d]===b)return d;return-1},r.findIndex=b(1),r.findLastIndex=b(-1),r.sortedIndex=function(a,b,c,d){c=t(c,d,1);for(var e=c(b),f=0,g=a.length;fb?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},r.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=r.now()-g;j=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=r.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},r.wrap=function(a,b){return r.partial(b,a)},r.negate=function(a){return function(){return!a.apply(this,arguments)}},r.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},r.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},r.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},r.once=r.partial(r.before,2);var B=!{toString:null}.propertyIsEnumerable("toString"),C=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];r.keys=function(a){if(!r.isObject(a))return[];if(n)return n(a);var b=[];for(var d in a)r.has(a,d)&&b.push(d);return B&&c(a,b),b},r.allKeys=function(a){if(!r.isObject(a))return[];var b=[];for(var d in a)b.push(d);return B&&c(a,b),b},r.values=function(a){for(var b=r.keys(a),c=b.length,d=Array(c),e=0;e":">",'"':""","'":"'","`":"`"},F=r.invert(E),G=function(a){var b=function(b){return a[b]},c="(?:"+r.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};r.escape=G(E),r.unescape=G(F),r.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),r.isFunction(d)?d.call(a):d};var H=0;r.uniqueId=function(a){var b=++H+"";return a?a+b:b},r.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var I=/(.)^/,J={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},K=/\\|'|\r|\n|\u2028|\u2029/g,L=function(a){return"\\"+J[a]};r.template=function(a,b,c){!b&&c&&(b=c),b=r.defaults({},b,r.templateSettings);var d=RegExp([(b.escape||I).source,(b.interpolate||I).source,(b.evaluate||I).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(K,L),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,r)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},r.chain=function(a){var b=r(a);return b._chain=!0,b};var M=function(a,b){return a._chain?r(b).chain():b};r.mixin=function(a){r.each(r.functions(a),function(b){var c=r[b]=a[b];r.prototype[b]=function(){var a=[this._wrapped];return i.apply(a,arguments),M(this,c.apply(r,a))}})},r.mixin(r),r.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=f[a];r.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],M(this,c)}}),r.each(["concat","join","slice"],function(a){var b=f[a];r.prototype[a]=function(){return M(this,b.apply(this._wrapped,arguments))}}),r.prototype.value=function(){return this._wrapped},r.prototype.valueOf=r.prototype.toJSON=r.prototype.value,r.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return r})}.call(this),null==window.BI&&(window.BI={}),BI.Factory={parsePath:function(a){var b=a.split(".");return function(a){for(var c=0;c1)for(var d=1;d=0;c--)a=BI.map(a,function(a,d){return BI.extend({},b[c],{items:[BI.extend({},b[c].el,{el:d})]})});return a},formatEL:function(a){return a&&!a.type&&a.el?a:{el:a}},stripEL:function(a){return a.type&&a||a.el||a},trans2Element:function(a){return BI.map(a,function(a,b){return b.element})}}),_.each(["where","findWhere","contains","invoke","pluck","shuffle","sample","toArray","size"],function(a){BI[a]=d(a)}),_.each(["each","map","reduce","reduceRight","find","filter","reject","every","all","some","any","max","min","sortBy","groupBy","indexBy","countBy","partition"],function(a){BI[a]=e(a)}),_.extend(BI,{clamp:function(a,b,c){return ac&&(a=c),a},count:function(a,b,c){var d;if(c)for(d=a;d=0;d--)b(d,a[d],a);return!1},backAny:function(a,b,c){b=BI.iteratee(b,c);for(var d=a.length-1;d>=0;d--)if(b(d,a[d],a))return!0;return!1},backEvery:function(a,b,c){b=BI.iteratee(b,c);for(var d=a.length-1;d>=0;d--)if(!b(d,a[d],a))return!1;return!0},backFindKey:function(a,b,c){b=BI.iteratee(b,c);for(var d,e=_.keys(a),f=e.length-1;f>=0;f--)if(d=e[f],b(a[d],d,a))return d},backFind:function(a,b,c){var d;if(d=BI.isArray(a)?BI.findLastIndex(a,b,c):BI.backFindKey(a,b,c),void 0!==d&&d!==-1)return a[d]},remove:function(a,b,c){var d=BI.isFunction(b);b=d||BI.isArray(b)?b:[b];var e;if(BI.isArray(a))for(e=0;e(2147483646-a.charAt(d).charCodeAt(0)+c.charCodeAt(0))/26)return 0;return b},int2Abc:function(a){var b=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],c=a,d="";if(0===a)return"";for(;0!==c;){var e=c%26;0===e&&(e=26),d=b[e-1]+d,c=(c-e)/26}return d}}),_.each(["first","initial","last","rest","compact","flatten","without","union","intersection","difference","zip","unzip","object","indexOf","lastIndexOf","sortedIndex","range"],function(a){BI[a]=d(a)}),_.each(["findIndex","findLastIndex"],function(a){BI[a]=e(a)}),_.extend(BI,{makeArray:function(a,b){for(var c=[],d=0;d0},isCapitalEqual:function(a,b){return a=BI.isNull(a)?a:(""+a).toLowerCase(),b=BI.isNull(b)?b:(""+b).toLowerCase(),BI.isEqual(a,b)},isWidthOrHeight:function(a){return"number"==typeof a?a>=0:"string"==typeof a?/^\d{1,3}%$/.exec(a)||"auto"==a||/^\d+px$/.exec(a):void 0},isNotNull:function(a){return!BI.isNull(a)},isNull:function(a){return"undefined"==typeof a||null===a},isPlainObject:function(){return a.isPlainObject.apply(a,arguments)},isEmptyArray:function(a){return BI.isArray(a)&&BI.isEmpty(a)},isNotEmptyArray:function(a){return BI.isArray(a)&&!BI.isEmpty(a)},isEmptyObject:function(a){return BI.isEqual(a,{})},isNotEmptyObject:function(a){return BI.isPlainObject(a)&&!BI.isEmptyObject(a)},isEmptyString:function(a){return BI.isString(a)&&0===a.length},isNotEmptyString:function(a){return BI.isString(a)&&!BI.isEmptyString(a)},isWindow:function(){return a.isWindow.apply(a,arguments)}}),_.extend(BI,{deepClone:function(a){if(null===a||a===b)return a;var c=Object.prototype.toString.call(a);if("[object Date]"===c)return new Date(a.getTime());var d,e;if("[object Array]"===c)for(d=a.length,e=[];d--;)e[d]=BI.deepClone(a[d]);else if("[object Object]"===c&&a.constructor===Object){e={};for(var d in a)_.has(a,d)&&(e[d]=BI.deepClone(a[d]))}return e||a},isDeepMatch:function(a,b){var c=BI.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;f10;)c=(parseInt(c.substring(0,10))+parseInt(c.substring(10,c.length),10)).toString();c=(f*c+g)%h;for(var j="",k="",d=0;d10;)c=(parseInt(c.substring(0,10),10)+parseInt(c.substring(10,c.length),10)).toString();c=(g*c+h)%i;for(var k="",l="",d=0;d1?j.unshift(BI.deepClone(d[f[f.length-1]])):j.unshift(BI.deepClone(g)),f.length>1?(delete d[f[f.length-1]],c[h](f[0],g,{silent:!0})):c[i](a,{silent:!0}),!BI.has(c._tmp,f[0])&&c.parent&&c.parent._change(c),c.splice.apply(c,j),c.trigger("splice",j),BI.remove(c._childs,b)}).on("copy",function(){ -var b,d,e=a.split("."),f=c.get(e[0]),g=c._tmp[e[0]]?"tmp":"set";BI.each(e,function(a,c){return 0===a?void(d=f):(b=d,void(d=d[c]))});var h=BI.UUID(),i=BI.clone(e);e.length>1?i.unshift(BI.deepClone(b[e[e.length-1]])):i.unshift(BI.deepClone(f));var j=c.similar.apply(c,i);BI.isKey(j.id)&&(h=j.id,delete j.id),e.length>1?(b[h]=j,c[g](e[0],f,{silent:!0})):c[g](h,j,{silent:!0}),e.unshift(h),!BI.has(c._tmp,e[0])&&c.parent&&c.parent._change(c),c.duplicate.apply(c,e),c.trigger("duplicate",e)})},removeChild:function(a,b){return BI.isArray(this._childs[a])?(BI.remove(this._childs[a],b),void(BI.isEmpty(this._childs[a])&&delete this._childs[a])):void delete this._childs[a]},has:function(a,b){return b===!0?_.has(this.tmp,a):(this._start===!0&&this._changing_===!1&&(this._hass[a]=!0),BI.Model.superclass.has.apply(this,arguments))},cat:function(a){if(_.has(this._tmp,a))return this._tmp[a];if(this._start===!0&&this._hass[a])switch(delete this._hass[a],a){case"default":break;case"current":break;default:this._gets.push(a)}if(_.has(this.attributes,a))return this.attributes[a];var b=_.result(this,"_static");return BI.isFunction(b[a])?b[a].apply(this,Array.prototype.slice.apply(arguments,[1])):b[a]},get:function(){return BI.deepClone(this.cat.apply(this,arguments))},set:function(a,b,c){return this._start===!0||this._changing_===!0?(this._F.push({f:this.set,arg:arguments}),this):BI.Model.superclass.set.apply(this,arguments)},unset:function(a,b){var c=this;return BI.each(this._childs,function(b,d){b+="";var e=b.split(".");_.isEqual(a,e[0])&&(delete c._childs[a],BI.isArray(d)||(d=[d]),BI.each(d,function(a,b){b.trigger("unset")}))}),BI.Model.superclass.unset.apply(this,arguments)},tmp:function(a,b,c){if(this._start===!0||this._changing_===!0)return this._F.push({f:this.tmp,arg:arguments}),this;var d,e,f,g,h,i,j,k,l;if(null==a)return this;"object"==typeof a?(e=a,c=b):(e={})[a]=b,c||(c={}),f=c.unset,h=c.silent,g=[],i=this._changingTmp,this._changingTmp=!0,i||(this._previousTmp=_.clone(this._tmp),this.changedTmp={}),this._previousTmp||(this._previousTmp=_.clone(this._tmp)),l=this._tmp,k=this._previousTmp;for(d in e)b=e[d],_.isEqual(l[d],b)||g.push(d),_.isEqual(k[d],b)?delete this.changedTmp[d]:this.changedTmp[d]=b,f?delete l[d]:l[d]=b;if(!h){g.length&&(this._pendingTmp=c);for(var m=0,n=g.length;m0&&this.refresh(b)}).listenTo(this.model,"change",function(a){this.delegateEvents()}).listenTo(this.model,"changed",function(a,b,c,d){if(BI.has(a,"current")&&BI.size(a)>1)throw new Error("refresh操作不能调用set操作");var e=!BI.has(a,"current")&&!this.local()&&this.notifyParent().notify();this.model.actionEnd()&&this.actionEnd(),this.model._changing_=!0,e&&!BI.isEmpty(a)&&this.change(a,b,c,d),this.model._changing_=!1,this.model.actionEnd()&&this.actionEnd()}).listenTo(this.model,"destroy",function(){this._destroy()}).listenTo(this.model,"unset",function(){this._destroy()}).listenTo(this.model,"splice",function(a){this.splice.apply(this,a)}).listenTo(this.model,"duplicate",function(a){this.duplicate.apply(this,a)}),this._F=[];var b=["_init","_defaultConfig","_vessel","_render","getName","listenEnd","local","refresh","load","change"];b=BI.makeObject(b,!0),BI.each(this.constructor.caller.caller.prototype,function(c){if(!b[c]){var d=a[c];BI.isFunction(d)&&(a[c]=BI.bind(function(){return this.model._start===!0?void this._F.push({f:d,arg:arguments}):d.apply(this,arguments)},a))}}),this.created&&this.created()},change:function(a,b){},actionEnd:function(){var a=this,b=this._F.slice(0);return this._F=[],BI.each(b,function(b,c){c.f.apply(a,c.arg)}),this},delegateEvents:function(a){if(!a&&!(a=BI.deepClone(_.result(this,"events"))))return this;var b=/^(\S+)\s*(.*)$/;for(var c in a){var d=a[c];if(_.isFunction(d)||(d=this[a[c]]),d){var e=c.match(b),f=!0;switch(e[1]){case"draggable":break;case"droppable":break;case"sortable":break;case"resizable":break;case"hover":break;default:f=!1}var g=new BI.OffList({event:e[1]+".delegateEvents"+this.cid}),h=e[2].split("."),i=h[1],j=f?new BI.EventList({event:e[1],handle:i,callback:BI.bind(d,this)}):new BI.ListenerList({event:e[1]+".delegateEvents"+this.cid,handle:i,callback:BI.bind(d,this),context:this}),k=[];this[h[0]]&&(this[h[0]]instanceof $||this[h[0]].element instanceof $)?(k=[this[h[0]]],delete a[c]):(BI.isArray(this[h[0]])||BI.isPlainObject(this[h[0]]))&&(k=this[h[0]],delete a[c]),g.populate(k),j.populate(k)}}return BI.View.superclass.delegateEvents.apply(this,[a])},_vessel:function(){this._cardLayouts={},this._cardLayouts[this.getName()]=new BI.CardLayout({element:this});var a=BI.createWidget();return this._cardLayouts[this.getName()].addCardByName(this.getName(),a),a},render:function(a){return this},addSubVessel:function(a,b,c){c||(c={}),this._cardLayouts||(this._cardLayouts={});var d=a+this.cid;return c.isLayer&&(b=BI.Layers.has(d)?BI.Layers.get(d):BI.Layers.create(d,b)),this._cardLayouts[a]?(c.defaultShowName&&this._cardLayouts[a].setDefaultShowName(c.defaultShowName),this):(this._cardLayouts[a]=BI.createWidget({type:"bi.card",element:b,defaultShowName:c.defaultShowName}),this)},removeSubVessel:function(a){var b=this,c=a+this.cid;BI.Layers.remove(c);var d=this._cardLayouts[a]&&this._cardLayouts[a].getAllCardNames();return BI.each(d,function(a,c){delete b._cards[c]}),this._cardLayouts[a]&&this._cardLayouts[a]._destroy(),this},createView:function(a,b,c,d){return BI.Factory.createView(a,this.get(a),b,c,d)},skipTo:function(a,b,c,d,e){if(this.model._start===!0||this._changing_===!0)return this._F.push({f:this.skipTo,arg:arguments}),this;var f=this,g=BI.isKey(c),h=void 0;if(BI.isKey(b)&&(b+=""),b=b||this.getName(),e||(e={}),g){c+="";var i=c.split(".");BI.each(i,function(a,b){h=0===a?f.model.get(b)||{}:h[b]||{}}),h.id=e.id||i[i.length-1]}else h=c;BI.extend(h,e.data);var j=e.action||new BI.ShowAction,k=this._cardLayouts[b];if(!k)return this;if(k.setVisible(!0),BI.isKey(a)&&!k.isCardExisted(a)){var l=this.createView(this.rootURL+"/"+a,h,d,this);g&&this.model.addChild(c,l.model),l.listenTo(l.model,"destroy",function(){delete f._cards[a],k.deleteCardByName(a),k.isAllCardHide()&&(k.setVisible(!1),BI.Layers.hide(b+f.cid))}).listenTo(l.model,"unset",function(){delete f._cards[a],k.deleteCardByName(a)}),k.addCardByName(a,l),this._cards||(this._cards={}),this._cards[a]=l,h={},this.on("end:"+l.cid,function(){var d,e,h=!1;g&&(e=c.split("."),BI.each(e,function(a,b){d=0===a?f.model.get(b)||(h=!0):d[b]||(h=!0)})),h&&(delete f._cards[a],f.model.removeChild(c,l.model),k.deleteCardByName(a),l._destroy(),k.setVisible(!1)),j.actionBack(l,null,function(){k.isAllCardHide()&&(k.setVisible(!1),BI.Layers.hide(b+f.cid)),!h&&f.listenEnd.apply(f,g?e:[c])!==!1&&f.populate()})}).on("change:"+l.cid,_.bind(this.notifyParent,this))}return BI.isKey(a)&&BI.Layers.show(b+this.cid),k.showCardByName(a,j,function(){BI.isKey(a)&&f._cards[a].populate(h,e)}),!BI.isKey(a)&&BI.Layers.hide(b+this.cid),this._cards[a]},listenEnd:function(a,b,c){return this},notifyParentEnd:function(a){return this.parent&&this.parent.trigger("end:"+this.cid),this.trigger("end"),!a&&this.notify(),this},notifyParent:function(){return this.parent&&this.parent.notify().trigger("change:"+this.cid),this},notify:function(){return this.model.unset("current",{silent:!0}),this},getName:function(){return"VIEW"},refresh:function(a){},local:function(){return!1},load:function(a){},readData:function(a,b){function c(a){d.model.load(a),d.load(a),BI.each(e,function(b,c){BI.isFunction(c)&&c.apply(d,[a])})}b||(b={});var d=this,e=[].slice.call(arguments,2);if(!a&&this._readed===!0)return void c(this.model.toJSON());var f=b.success;this.model.read(BI.extend({silent:!0},b,{success:function(b,e){c(b),!a&&(d._readed=!0),d.delegateEvents(),f&&f(b,e)}}))},cat:function(){return this.model.cat.apply(this.model,arguments)},get:function(){return this.model.get.apply(this.model,arguments)},set:function(){return this.model.set.apply(this.model,arguments)},has:function(){return this.model.has.apply(this.model,arguments)},getEditing:function(){return this.model.getEditing()},reading:function(a){var b=this,c=BI.UUID();this.model.read(BI.extend({},a,{beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},updating:function(a){var b=this,c=BI.UUID();this.model.update(BI.extend({},a,{noset:!0,beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},patching:function(a){var b=this,c=BI.UUID();this.model.patch(BI.extend({},a,{noset:!0,beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},populate:function(a,b){if(b||(b={}),b.force===!0&&this.notify(),this._cardLayouts&&this._cardLayouts[this.getName()]&&this._cardLayouts[this.getName()].showCardByName(this.getName()),this._F.length>0)throw new Error("流程错误");if(b.force===!0)return void this.model.set(a,b).set({current:this.model.get("default")});if(b.force===!1)return void this.model.set(a);var c=BI.clone(a||{});delete c.id;var d=BI.has(this.model.toJSON(),_.keys(c)),e=BI.isEmpty(c)||d&&this.model.matches(a);e===!0?this.model.set({current:this.model.get("default")}):d===!1?this.model.set(a):this.model.set(a,b).set({current:this.model.get("default")})},splice:function(a,b,c,d){},duplicate:function(a,b,c,d){},_unMount:function(){this.beforeDestroy&&this.beforeDestroy(),BI.each(this._cardLayouts,function(a,b){b&&b._unMount()}),delete this._cardLayouts,delete this._cards,this.destroyed&&this.destroyed(),this.trigger(BI.Events.UNMOUNT),this.off()},_destroy:function(){var a=this;BI.each(this._cardLayouts,function(b,c){c&&c._unMount(),BI.Layers.remove(b+a.cid)}),delete this._cardLayouts,delete this._cards,this.destroyed&&this.destroyed(),this.remove(),this.trigger(BI.Events.DESTROY),this.off()}}),BI.View.registerVMRouter=function(a,b){BI.View.createView=BI.View.prototype.createView=function(c,d,e,f){return BI.Factory.createView(c,a.get(c),_.extend({},b.get(c),d),e||{},f)}},function(){var a={};BI.shortcut=function(b,c){if(null!=a[b])throw"shortcut:["+b+"] has been registed";a[b]=c};var b=function(b){if(b.classType)return new(new Function("return "+b.classType+";")())(b);var c=a[b.type];return new c(b)};BI.createWidget=function(a,c){var d;if(c||(c={}),BI.isEmpty(a)&&BI.isEmpty(c))return BI.createWidget({type:"bi.layout"});if(BI.isWidget(a))return a;if(a&&(a.type||c.type))return d=BI.extend({},c,a),BI.Plugin.getObject(d.type,b(BI.Plugin.getWidget(d.type,d)));if(a&&a.el&&(a.el.type||c.type))return d=BI.extend({},c,a.el),BI.Plugin.getObject(d.type,b(BI.Plugin.getWidget(d.type,d)));if(a&&BI.isWidget(a.el))return a.el;throw new Error("无法根据item创建组件")}}(),function(a,b){function c(a){return function(b,c,d){var e,f=b[c];f&&f.target==b||(e=b[c]=function(){for(var a,b=e.before,c=arguments,d=b.length;d--;){if(a=b[d].advice.apply(this,c),a===!1)return!1;c=a||c}for(var f=e.method.apply(this,c),g=e.after,h=0,i=g.length;h127&&d<2048?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},c=function(a){for(var b="",c=0,d=0,e=0,f=0;c191&&d<224?(f=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&f),c+=2):(f=a.charCodeAt(c+1),e=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&f)<<6|63&e),c+=3);return b};_.extend(BI,{encode:function(c){var d,e,f,g,h,i,j,k="",l=0;for(c=b(c);l>2,h=(3&d)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k=k+a.charAt(g)+a.charAt(h)+a.charAt(i)+a.charAt(j);return k},decode:function(b){var d,e,f,g,h,i,j,k="",l=0;for(b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");l>4,e=(15&h)<<4|i>>2,f=(3&i)<<6|j,k+=String.fromCharCode(d),64!=i&&(k+=String.fromCharCode(e)),64!=j&&(k+=String.fromCharCode(f));return k=c(k)}})}(),BI.CellSizeAndPositionManager=function(a,b,c){this._cellSizeGetter=b,this._cellCount=a,this._estimatedCellSize=c,this._cellSizeAndPositionData={},this._lastMeasuredIndex=-1},BI.CellSizeAndPositionManager.prototype={constructor:BI.CellSizeAndPositionManager,configure:function(a,b){this._cellCount=a,this._estimatedCellSize=b},getCellCount:function(){return this._cellCount},getEstimatedCellSize:function(){return this._estimatedCellSize},getLastMeasuredIndex:function(){return this._lastMeasuredIndex},getSizeAndPositionOfCell:function(a){if(!(a<0||a>=this._cellCount)){if(a>this._lastMeasuredIndex){for(var b=this.getSizeAndPositionOfLastMeasuredCell(),c=b.offset+b.size,d=this._lastMeasuredIndex+1;d<=a;d++){var e=this._cellSizeGetter(d);null==e||isNaN(e)||(this._cellSizeAndPositionData[d]={offset:c,size:e},c+=e)}this._lastMeasuredIndex=a}return this._cellSizeAndPositionData[a]}},getSizeAndPositionOfLastMeasuredCell:function(){return this._lastMeasuredIndex>=0?this._cellSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}},getTotalSize:function(){var a=this.getSizeAndPositionOfLastMeasuredCell();return a.offset+a.size+(this._cellCount-this._lastMeasuredIndex-1)*this._estimatedCellSize},getUpdatedOffsetForIndex:function(a,b,c,d){var e,f=this.getSizeAndPositionOfCell(d),g=f.offset,h=g-b+f.size;switch(a){case"start":e=g;break;case"end":e=h;break;case"center":e=g-(b-f.size)/2;break;default:e=Math.max(h,Math.min(g,c))}var i=this.getTotalSize();return Math.max(0,Math.min(i-b,e))},getVisibleCellRange:function(a,b){var c=this.getTotalSize();if(0===c)return{};var d=b+a,e=this._findNearestCell(b),f=this.getSizeAndPositionOfCell(e);b=f.offset+f.size;for(var g=e;bc&&(a=d-1)}if(b>0)return b-1},_exponentialSearch:function(a,b){for(var c=1;a=a?this._binarySearch(c,0,a):this._exponentialSearch(c,a)}}},BI.ScalingCellSizeAndPositionManager=function(a,b,c,d){this._cellSizeAndPositionManager=new BI.CellSizeAndPositionManager(a,b,c),this._maxScrollSize=d||1e7},BI.ScalingCellSizeAndPositionManager.prototype={constructor:BI.ScalingCellSizeAndPositionManager,configure:function(){this._cellSizeAndPositionManager.configure.apply(this._cellSizeAndPositionManager,arguments)},getCellCount:function(){return this._cellSizeAndPositionManager.getCellCount()},getEstimatedCellSize:function(){return this._cellSizeAndPositionManager.getEstimatedCellSize()},getLastMeasuredIndex:function(){return this._cellSizeAndPositionManager.getLastMeasuredIndex()},getOffsetAdjustment:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize(),e=this._getOffsetPercentage(a,b,d);return Math.round(e*(d-c))},getSizeAndPositionOfCell:function(a){return this._cellSizeAndPositionManager.getSizeAndPositionOfCell(a)},getSizeAndPositionOfLastMeasuredCell:function(){return this._cellSizeAndPositionManager.getSizeAndPositionOfLastMeasuredCell()},getTotalSize:function(){return Math.min(this._maxScrollSize,this._cellSizeAndPositionManager.getTotalSize())},getUpdatedOffsetForIndex:function(a,b,c,d){c=this._safeOffsetToOffset(b,c);var e=this._cellSizeAndPositionManager.getUpdatedOffsetForIndex(a,b,c,d);return this._offsetToSafeOffset(b,e)},getVisibleCellRange:function(a,b){return b=this._safeOffsetToOffset(a,b),this._cellSizeAndPositionManager.getVisibleCellRange(a,b)},resetCell:function(a){this._cellSizeAndPositionManager.resetCell(a)},_getOffsetPercentage:function(a,b,c){return c<=a?0:b/(c-a)},_offsetToSafeOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,c);return Math.round(e*(d-a))},_safeOffsetToOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,d);return Math.round(e*(c-a))}},!function(){var a="YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZJJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZYRJXSDLTYZCQKCNNJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQTGLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMBDTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZASYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXHLGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJFFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJKQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJCLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJGBMCLYYMKXJQLBMLLKMDXXKWYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLLSDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYLJSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYLYMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHNGPYXSHMYQJXZTDPPBFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBMLSFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZSZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZYGPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJPWXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGXXZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDYTCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTXJCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTTTKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZWGPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDGCYYFGYDXKSSEBDHYKDKDKHNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTLFYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSLCMBJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZSYMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZHQKZBYJTZBXHFDXKDASWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGSXWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJSZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMCPJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXYYRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHHARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMTCJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDHZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKKBXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJYZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHLYQRWHSYCSQYYBYAYWJJJQFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEEYYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQYTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYWYWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZSQXBDGCPZSWDWCSQZGMDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMTYBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDPJHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBSDZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZXJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLRDTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFHTSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQYPKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBMYHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWSZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCPMMGCCCCCMTZTASMGQZJHKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQJSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQHHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBBZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZKDDZQANZHJKDRTLZLSWJLJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDSDPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCSZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZBYWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQGYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCXTCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJYEMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGDXJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZQAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYSPYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZSXYFYMNCWDABAZLXKTCSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJKHWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLKQUNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJYJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZRNYDZZCDGPJAFJFZKNZBLCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZDQQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYSJTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPHZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPBYKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHLLQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRTQZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZSXQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQXRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBPCCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZCQQCJYLLZLTJYLLZLLBNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDESJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJMHQNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXSRGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFFYTZZGZYSKYJXQYJZQBHMBZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQPWQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQXSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSYCZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQDFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJHFXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYSYXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYPJYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLWTGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWTYYDCHQLXKPZWBGQYBKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYLMSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLTYXHQLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRPYWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQYWRGYQLXBBZLJSYLPSYTJZYHYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCRYLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTMLRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCDJJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYSLBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXXTXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYXLSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHXCJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZXRWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNTYJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLYCYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGWHKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZMDPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZQYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTYYMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPPMHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMXCTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHKZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGENQLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDFXQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYGZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZLLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZZYJGTSMTFXQYXQSTDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTCTSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQXQKYSJYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJPDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXBQKDJJQYRFKZTJDHCZKLBSDZCFJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQGKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSLDLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZLSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFLCJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSSNXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFSZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJHZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWBZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXYWGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBTYNSYSXJBQLPXZQPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXSTJTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGWSGWHRLFSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFXPYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJHCLLJTOLNJPZLJLHYMHEYDYDSQYCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJFZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPKYGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJKYHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJPXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDKNTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJXYCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSGLJJSYFPYYCCYLTJANTJJPWYCMMGQYYSXDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBGMYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJYHPLQLSZDJRBCQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJDQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGKGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKXWYYFLXXNCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCXTLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYYZLBLXBZLQMYLXPGHDSLSSDMXMBDZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBHAWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJBZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBLZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZKBXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQYQQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFYWLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGCULKJXTMXMYJSXHYBRWFYMWFRXYQMXYSZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJLLQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLLLPYPSYJYSXCQQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDWFGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQTTFZXBDKTYYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLYXXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJCJZCJGDZZSXQGSJGGCXHQXSNQLZZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZYXXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXWWGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZLJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWDXZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSRNQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJHOJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYBSQMJMZJMTZQLPJYQZCGQHXJHHLXXHLHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPXYYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZBYZDZYPSWYJZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQSQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLGYJDXJDZZKZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLCTZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDFQTDDGLRLAJJTKUYMKQLLTZYTDYYCZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZFYBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBBCBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWSCSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYEBHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYYLLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYMRBESJYYHKXXSTMXRCZZYWXYQYBMCLLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZXJCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLFNDXQKCZFYWHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZCZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZYZTCGHZTLMLWZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLMLHBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMSTPXLSKLZYNWRTSQLSZBPSPSGZWYHTLKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQJZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZMLLJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGYZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZLPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPCQDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQKTWPXXHCPTHTWUMSSYHBWCRWXHJMKMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDLMJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZSJNYQYQQXYJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYADTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQTMYSTQXKBTZPKJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQHYWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQBSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFSYZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZNSDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJPZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPCQBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZTDKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDDNXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSDDTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZHLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJYHSLLLMZXELGLXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZBYFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHLRMGRXXZCLHNELJJTJTPWJYBJJBXJJTJTEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTMXGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPNHMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZGLHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJXY",b={ +var b,d,e=a.split("."),f=c.get(e[0]),g=c._tmp[e[0]]?"tmp":"set";BI.each(e,function(a,c){return 0===a?void(d=f):(b=d,void(d=d[c]))});var h=BI.UUID(),i=BI.clone(e);e.length>1?i.unshift(BI.deepClone(b[e[e.length-1]])):i.unshift(BI.deepClone(f));var j=c.similar.apply(c,i);BI.isKey(j.id)&&(h=j.id,delete j.id),e.length>1?(b[h]=j,c[g](e[0],f,{silent:!0})):c[g](h,j,{silent:!0}),e.unshift(h),!BI.has(c._tmp,e[0])&&c.parent&&c.parent._change(c),c.duplicate.apply(c,e),c.trigger("duplicate",e)})},removeChild:function(a,b){return BI.isArray(this._childs[a])?(BI.remove(this._childs[a],b),void(BI.isEmpty(this._childs[a])&&delete this._childs[a])):void delete this._childs[a]},has:function(a,b){return b===!0?_.has(this.tmp,a):(this._start===!0&&this._changing_===!1&&(this._hass[a]=!0),BI.Model.superclass.has.apply(this,arguments))},cat:function(a){if(_.has(this._tmp,a))return this._tmp[a];if(this._start===!0&&this._hass[a])switch(delete this._hass[a],a){case"default":break;case"current":break;default:this._gets.push(a)}if(_.has(this.attributes,a))return this.attributes[a];var b=_.result(this,"_static");return BI.isFunction(b[a])?b[a].apply(this,Array.prototype.slice.apply(arguments,[1])):b[a]},get:function(){return BI.deepClone(this.cat.apply(this,arguments))},set:function(a,b,c){return this._start===!0||this._changing_===!0?(this._F.push({f:this.set,arg:arguments}),this):BI.Model.superclass.set.apply(this,arguments)},unset:function(a,b){var c=this;return BI.each(this._childs,function(b,d){b+="";var e=b.split(".");_.isEqual(a,e[0])&&(delete c._childs[a],BI.isArray(d)||(d=[d]),BI.each(d,function(a,b){b.trigger("unset")}))}),BI.Model.superclass.unset.apply(this,arguments)},tmp:function(a,b,c){if(this._start===!0||this._changing_===!0)return this._F.push({f:this.tmp,arg:arguments}),this;var d,e,f,g,h,i,j,k,l;if(null==a)return this;"object"==typeof a?(e=a,c=b):(e={})[a]=b,c||(c={}),f=c.unset,h=c.silent,g=[],i=this._changingTmp,this._changingTmp=!0,i||(this._previousTmp=_.clone(this._tmp),this.changedTmp={}),this._previousTmp||(this._previousTmp=_.clone(this._tmp)),l=this._tmp,k=this._previousTmp;for(d in e)b=e[d],_.isEqual(l[d],b)||g.push(d),_.isEqual(k[d],b)?delete this.changedTmp[d]:this.changedTmp[d]=b,f?delete l[d]:l[d]=b;if(!h){g.length&&(this._pendingTmp=c);for(var m=0,n=g.length;m0&&this.refresh(b)}).listenTo(this.model,"change",function(a){this.delegateEvents()}).listenTo(this.model,"changed",function(a,b,c,d){if(BI.has(a,"current")&&BI.size(a)>1)throw new Error("refresh操作不能调用set操作");var e=!BI.has(a,"current")&&!this.local()&&this.notifyParent().notify();this.model.actionEnd()&&this.actionEnd(),this.model._changing_=!0,e&&!BI.isEmpty(a)&&this.change(a,b,c,d),this.model._changing_=!1,this.model.actionEnd()&&this.actionEnd()}).listenTo(this.model,"destroy",function(){this._destroy()}).listenTo(this.model,"unset",function(){this._destroy()}).listenTo(this.model,"splice",function(a){this.splice.apply(this,a)}).listenTo(this.model,"duplicate",function(a){this.duplicate.apply(this,a)}),this._F=[];var b=["_init","_defaultConfig","_vessel","_render","getName","listenEnd","local","refresh","load","change"];b=BI.makeObject(b,!0),BI.each(this.constructor.caller.caller.prototype,function(c){if(!b[c]){var d=a[c];BI.isFunction(d)&&(a[c]=BI.bind(function(){return this.model._start===!0?void this._F.push({f:d,arg:arguments}):d.apply(this,arguments)},a))}}),this.created&&this.created()},change:function(a,b){},actionEnd:function(){var a=this,b=this._F.slice(0);return this._F=[],BI.each(b,function(b,c){c.f.apply(a,c.arg)}),this},delegateEvents:function(a){if(!a&&!(a=BI.deepClone(_.result(this,"events"))))return this;var b=/^(\S+)\s*(.*)$/;for(var c in a){var d=a[c];if(_.isFunction(d)||(d=this[a[c]]),d){var e=c.match(b),f=!0;switch(e[1]){case"draggable":break;case"droppable":break;case"sortable":break;case"resizable":break;case"hover":break;default:f=!1}var g=new BI.OffList({event:e[1]+".delegateEvents"+this.cid}),h=e[2].split("."),i=h[1],j=f?new BI.EventList({event:e[1],handle:i,callback:BI.bind(d,this)}):new BI.ListenerList({event:e[1]+".delegateEvents"+this.cid,handle:i,callback:BI.bind(d,this),context:this}),k=[];this[h[0]]&&(this[h[0]]instanceof $||this[h[0]].element instanceof $)?(k=[this[h[0]]],delete a[c]):(BI.isArray(this[h[0]])||BI.isPlainObject(this[h[0]]))&&(k=this[h[0]],delete a[c]),g.populate(k),j.populate(k)}}return BI.View.superclass.delegateEvents.apply(this,[a])},_vessel:function(){this._cardLayouts={},this._cardLayouts[this.getName()]=new BI.CardLayout({element:this});var a=BI.createWidget();return this._cardLayouts[this.getName()].addCardByName(this.getName(),a),a},render:function(a){return this},addSubVessel:function(a,b,c){c||(c={}),this._cardLayouts||(this._cardLayouts={});var d=a+this.cid;return c.isLayer&&(b=BI.Layers.has(d)?BI.Layers.get(d):BI.Layers.create(d,b)),this._cardLayouts[a]?(c.defaultShowName&&this._cardLayouts[a].setDefaultShowName(c.defaultShowName),this):(this._cardLayouts[a]=BI.createWidget({type:"bi.card",element:b,defaultShowName:c.defaultShowName}),this)},removeSubVessel:function(a){var b=this,c=a+this.cid;BI.Layers.remove(c);var d=this._cardLayouts[a]&&this._cardLayouts[a].getAllCardNames();return BI.each(d,function(a,c){delete b._cards[c]}),this._cardLayouts[a]&&this._cardLayouts[a]._destroy(),this},createView:function(a,b,c,d){return BI.Factory.createView(a,this.get(a),b,c,d)},skipTo:function(a,b,c,d,e){if(this.model._start===!0||this._changing_===!0)return this._F.push({f:this.skipTo,arg:arguments}),this;var f=this,g=BI.isKey(c),h=void 0;if(BI.isKey(b)&&(b+=""),b=b||this.getName(),e||(e={}),g){c+="";var i=c.split(".");BI.each(i,function(a,b){h=0===a?f.model.get(b)||{}:h[b]||{}}),h.id=e.id||i[i.length-1]}else h=c;BI.extend(h,e.data);var j=e.action||new BI.ShowAction,k=this._cardLayouts[b];if(!k)return this;if(k.setVisible(!0),BI.isKey(a)&&!k.isCardExisted(a)){var l=this.createView(this.rootURL+"/"+a,h,d,this);g&&this.model.addChild(c,l.model),l.listenTo(l.model,"destroy",function(){delete f._cards[a],k.deleteCardByName(a),k.isAllCardHide()&&(k.setVisible(!1),BI.Layers.hide(b+f.cid))}).listenTo(l.model,"unset",function(){delete f._cards[a],k.deleteCardByName(a)}),k.addCardByName(a,l),this._cards||(this._cards={}),this._cards[a]=l,h={},this.on("end:"+l.cid,function(){var d,e,h=!1;g&&(e=c.split("."),BI.each(e,function(a,b){d=0===a?f.model.get(b)||(h=!0):d[b]||(h=!0)})),h&&(delete f._cards[a],f.model.removeChild(c,l.model),k.deleteCardByName(a),l._destroy(),k.setVisible(!1)),j.actionBack(l,null,function(){k.isAllCardHide()&&(k.setVisible(!1),BI.Layers.hide(b+f.cid)),!h&&f.listenEnd.apply(f,g?e:[c])!==!1&&f.populate()})}).on("change:"+l.cid,_.bind(this.notifyParent,this))}return BI.isKey(a)&&BI.Layers.show(b+this.cid),k.showCardByName(a,j,function(){BI.isKey(a)&&f._cards[a].populate(h,e)}),!BI.isKey(a)&&BI.Layers.hide(b+this.cid),this._cards[a]},listenEnd:function(a,b,c){return this},notifyParentEnd:function(a){return this.parent&&this.parent.trigger("end:"+this.cid),this.trigger("end"),!a&&this.notify(),this},notifyParent:function(){return this.parent&&this.parent.notify().trigger("change:"+this.cid),this},notify:function(){return this.model.unset("current",{silent:!0}),this},getName:function(){return"VIEW"},refresh:function(a){},local:function(){return!1},load:function(a){},readData:function(a,b){function c(a){d.model.load(a),d.load(a),BI.each(e,function(b,c){BI.isFunction(c)&&c.apply(d,[a])})}b||(b={});var d=this,e=[].slice.call(arguments,2);if(!a&&this._readed===!0)return void c(this.model.toJSON());var f=b.success;this.model.read(BI.extend({silent:!0},b,{success:function(b,e){c(b),!a&&(d._readed=!0),d.delegateEvents(),f&&f(b,e)}}))},cat:function(){return this.model.cat.apply(this.model,arguments)},get:function(){return this.model.get.apply(this.model,arguments)},set:function(){return this.model.set.apply(this.model,arguments)},has:function(){return this.model.has.apply(this.model,arguments)},getEditing:function(){return this.model.getEditing()},reading:function(a){var b=this,c=BI.UUID();this.model.read(BI.extend({},a,{beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},updating:function(a){var b=this,c=BI.UUID();this.model.update(BI.extend({},a,{noset:!0,beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},patching:function(a){var b=this,c=BI.UUID();this.model.patch(BI.extend({},a,{noset:!0,beforeSend:function(){var a=BI.createWidget({type:"bi.vertical",items:[{type:"bi.layout",height:30,cls:"loading-background"}],element:BI.Maskers.make(c,b)});a.setVisible(!0)},complete:function(b){a.complete&&a.complete(b),BI.Maskers.remove(c)}}))},populate:function(a,b){if(b||(b={}),b.force===!0&&this.notify(),this._cardLayouts&&this._cardLayouts[this.getName()]&&this._cardLayouts[this.getName()].showCardByName(this.getName()),this._F.length>0)throw new Error("流程错误");if(b.force===!0)return void this.model.set(a,b).set({current:this.model.get("default")});if(b.force===!1)return void this.model.set(a);var c=BI.clone(a||{});delete c.id;var d=BI.has(this.model.toJSON(),_.keys(c)),e=BI.isEmpty(c)||d&&this.model.matches(a);e===!0?this.model.set({current:this.model.get("default")}):d===!1?this.model.set(a):this.model.set(a,b).set({current:this.model.get("default")})},splice:function(a,b,c,d){},duplicate:function(a,b,c,d){},_unMount:function(){this.beforeDestroy&&this.beforeDestroy(),BI.each(this._cardLayouts,function(a,b){b&&b._unMount()}),delete this._cardLayouts,delete this._cards,this.destroyed&&this.destroyed(),this.trigger(BI.Events.UNMOUNT),this.off()},_destroy:function(){var a=this;BI.each(this._cardLayouts,function(b,c){c&&c._unMount(),BI.Layers.remove(b+a.cid)}),delete this._cardLayouts,delete this._cards,this.destroyed&&this.destroyed(),this.remove(),this.trigger(BI.Events.DESTROY),this.off()}}),BI.View.registerVMRouter=function(a,b){BI.View.createView=BI.View.prototype.createView=function(c,d,e,f){return BI.Factory.createView(c,a.get(c),_.extend({},b.get(c),d),e||{},f)}},function(){var a={};BI.shortcut=function(b,c){if(null!=a[b])throw"shortcut:["+b+"] has been registed";a[b]=c};var b=function(b){if(b.classType)return new(new Function("return "+b.classType+";")())(b);var c=a[b.type];return new c(b)};BI.createWidget=function(a,c){var d,e;if(c||(c={}),BI.isEmpty(a)&&BI.isEmpty(c))return BI.createWidget({type:"bi.layout"});if(BI.isWidget(a))return a;if(a&&(a.type||c.type))return d=BI.extend({},c,a),e=BI.Plugin.getWidget(d.type,d),BI.Plugin.getObject(d.type,e.type===d.type?b(e):BI.createWidget(BI.extend({},a,{type:e.type},c)));if(a&&a.el&&(a.el.type||c.type))return d=BI.extend({},c,a.el),e=BI.Plugin.getWidget(d.type,d),BI.Plugin.getObject(d.type,e.type===d.type?b(e):BI.createWidget(BI.extend({},a,{type:e.type},c)));if(a&&BI.isWidget(a.el))return a.el;throw new Error("无法根据item创建组件")}}(),function(a,b){function c(a){return function(b,c,d){var e,f=b[c];f&&f.target==b||(e=b[c]=function(){for(var a,b=e.before,c=arguments,d=b.length;d--;){if(a=b[d].advice.apply(this,c),a===!1)return!1;c=a||c}for(var f=e.method.apply(this,c),g=e.after,h=0,i=g.length;h127&&d<2048?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},c=function(a){for(var b="",c=0,d=0,e=0,f=0;c191&&d<224?(f=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&f),c+=2):(f=a.charCodeAt(c+1),e=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&f)<<6|63&e),c+=3);return b};_.extend(BI,{encode:function(c){var d,e,f,g,h,i,j,k="",l=0;for(c=b(c);l>2,h=(3&d)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k=k+a.charAt(g)+a.charAt(h)+a.charAt(i)+a.charAt(j);return k},decode:function(b){var d,e,f,g,h,i,j,k="",l=0;for(b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");l>4,e=(15&h)<<4|i>>2,f=(3&i)<<6|j,k+=String.fromCharCode(d),64!=i&&(k+=String.fromCharCode(e)),64!=j&&(k+=String.fromCharCode(f));return k=c(k)}})}(),BI.CellSizeAndPositionManager=function(a,b,c){this._cellSizeGetter=b,this._cellCount=a,this._estimatedCellSize=c,this._cellSizeAndPositionData={},this._lastMeasuredIndex=-1},BI.CellSizeAndPositionManager.prototype={constructor:BI.CellSizeAndPositionManager,configure:function(a,b){this._cellCount=a,this._estimatedCellSize=b},getCellCount:function(){return this._cellCount},getEstimatedCellSize:function(){return this._estimatedCellSize},getLastMeasuredIndex:function(){return this._lastMeasuredIndex},getSizeAndPositionOfCell:function(a){if(!(a<0||a>=this._cellCount)){if(a>this._lastMeasuredIndex){for(var b=this.getSizeAndPositionOfLastMeasuredCell(),c=b.offset+b.size,d=this._lastMeasuredIndex+1;d<=a;d++){var e=this._cellSizeGetter(d);null==e||isNaN(e)||(this._cellSizeAndPositionData[d]={offset:c,size:e},c+=e)}this._lastMeasuredIndex=a}return this._cellSizeAndPositionData[a]}},getSizeAndPositionOfLastMeasuredCell:function(){return this._lastMeasuredIndex>=0?this._cellSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}},getTotalSize:function(){var a=this.getSizeAndPositionOfLastMeasuredCell();return a.offset+a.size+(this._cellCount-this._lastMeasuredIndex-1)*this._estimatedCellSize},getUpdatedOffsetForIndex:function(a,b,c,d){var e,f=this.getSizeAndPositionOfCell(d),g=f.offset,h=g-b+f.size;switch(a){case"start":e=g;break;case"end":e=h;break;case"center":e=g-(b-f.size)/2;break;default:e=Math.max(h,Math.min(g,c))}var i=this.getTotalSize();return Math.max(0,Math.min(i-b,e))},getVisibleCellRange:function(a,b){var c=this.getTotalSize();if(0===c)return{};var d=b+a,e=this._findNearestCell(b),f=this.getSizeAndPositionOfCell(e);b=f.offset+f.size;for(var g=e;bc&&(a=d-1)}if(b>0)return b-1},_exponentialSearch:function(a,b){for(var c=1;a=a?this._binarySearch(c,0,a):this._exponentialSearch(c,a)}}},BI.ScalingCellSizeAndPositionManager=function(a,b,c,d){this._cellSizeAndPositionManager=new BI.CellSizeAndPositionManager(a,b,c),this._maxScrollSize=d||1e7},BI.ScalingCellSizeAndPositionManager.prototype={constructor:BI.ScalingCellSizeAndPositionManager,configure:function(){this._cellSizeAndPositionManager.configure.apply(this._cellSizeAndPositionManager,arguments)},getCellCount:function(){return this._cellSizeAndPositionManager.getCellCount()},getEstimatedCellSize:function(){return this._cellSizeAndPositionManager.getEstimatedCellSize()},getLastMeasuredIndex:function(){return this._cellSizeAndPositionManager.getLastMeasuredIndex()},getOffsetAdjustment:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize(),e=this._getOffsetPercentage(a,b,d);return Math.round(e*(d-c))},getSizeAndPositionOfCell:function(a){return this._cellSizeAndPositionManager.getSizeAndPositionOfCell(a)},getSizeAndPositionOfLastMeasuredCell:function(){return this._cellSizeAndPositionManager.getSizeAndPositionOfLastMeasuredCell()},getTotalSize:function(){return Math.min(this._maxScrollSize,this._cellSizeAndPositionManager.getTotalSize())},getUpdatedOffsetForIndex:function(a,b,c,d){c=this._safeOffsetToOffset(b,c);var e=this._cellSizeAndPositionManager.getUpdatedOffsetForIndex(a,b,c,d);return this._offsetToSafeOffset(b,e)},getVisibleCellRange:function(a,b){return b=this._safeOffsetToOffset(a,b),this._cellSizeAndPositionManager.getVisibleCellRange(a,b)},resetCell:function(a){this._cellSizeAndPositionManager.resetCell(a)},_getOffsetPercentage:function(a,b,c){return c<=a?0:b/(c-a)},_offsetToSafeOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,c);return Math.round(e*(d-a))},_safeOffsetToOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,d);return Math.round(e*(c-a))}},!function(){var a="YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZJJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZYRJXSDLTYZCQKCNNJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQTGLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMBDTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZASYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXHLGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJFFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJKQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJCLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJGBMCLYYMKXJQLBMLLKMDXXKWYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLLSDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYLJSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYLYMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHNGPYXSHMYQJXZTDPPBFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBMLSFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZSZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZYGPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJPWXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGXXZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDYTCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTXJCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTTTKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZWGPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDGCYYFGYDXKSSEBDHYKDKDKHNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTLFYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSLCMBJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZSYMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZHQKZBYJTZBXHFDXKDASWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGSXWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJSZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMCPJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXYYRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHHARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMTCJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDHZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKKBXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJYZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHLYQRWHSYCSQYYBYAYWJJJQFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEEYYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQYTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYWYWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZSQXBDGCPZSWDWCSQZGMDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMTYBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDPJHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBSDZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZXJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLRDTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFHTSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQYPKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBMYHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWSZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCPMMGCCCCCMTZTASMGQZJHKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQJSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQHHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBBZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZKDDZQANZHJKDRTLZLSWJLJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDSDPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCSZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZBYWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQGYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCXTCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJYEMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGDXJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZQAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYSPYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZSXYFYMNCWDABAZLXKTCSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJKHWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLKQUNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJYJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZRNYDZZCDGPJAFJFZKNZBLCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZDQQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYSJTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPHZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPBYKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHLLQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRTQZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZSXQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQXRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBPCCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZCQQCJYLLZLTJYLLZLLBNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDESJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJMHQNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXSRGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFFYTZZGZYSKYJXQYJZQBHMBZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQPWQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQXSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSYCZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQDFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJHFXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYSYXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYPJYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLWTGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWTYYDCHQLXKPZWBGQYBKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYLMSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLTYXHQLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRPYWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQYWRGYQLXBBZLJSYLPSYTJZYHYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCRYLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTMLRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCDJJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYSLBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXXTXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYXLSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHXCJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZXRWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNTYJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLYCYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGWHKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZMDPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZQYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTYYMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPPMHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMXCTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHKZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGENQLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDFXQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYGZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZLLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZZYJGTSMTFXQYXQSTDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTCTSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQXQKYSJYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJPDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXBQKDJJQYRFKZTJDHCZKLBSDZCFJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQGKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSLDLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZLSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFLCJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSSNXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFSZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJHZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWBZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXYWGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBTYNSYSXJBQLPXZQPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXSTJTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGWSGWHRLFSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFXPYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJHCLLJTOLNJPZLJLHYMHEYDYDSQYCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJFZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPKYGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJKYHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJPXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDKNTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJXYCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSGLJJSYFPYYCCYLTJANTJJPWYCMMGQYYSXDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBGMYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJYHPLQLSZDJRBCQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJDQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGKGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKXWYYFLXXNCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCXTLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYYZLBLXBZLQMYLXPGHDSLSSDMXMBDZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBHAWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJBZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBLZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZKBXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQYQQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFYWLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGCULKJXTMXMYJSXHYBRWFYMWFRXYQMXYSZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJLLQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLLLPYPSYJYSXCQQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDWFGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQTTFZXBDKTYYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLYXXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJCJZCJGDZZSXQGSJGGCXHQXSNQLZZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZYXXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXWWGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZLJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWDXZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSRNQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJHOJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYBSQMJMZJMTZQLPJYQZCGQHXJHHLXXHLHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPXYYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZBYZDZYPSWYJZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQSQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLGYJDXJDZZKZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLCTZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDFQTDDGLRLAJJTKUYMKQLLTZYTDYYCZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZFYBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBBCBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWSCSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYEBHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYYLLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYMRBESJYYHKXXSTMXRCZZYWXYQYBMCLLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZXJCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLFNDXQKCZFYWHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZCZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZYZTCGHZTLMLWZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLMLHBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMSTPXLSKLZYNWRTSQLSZBPSPSGZWYHTLKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQJZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZMLLJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGYZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZLPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPCQDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQKTWPXXHCPTHTWUMSSYHBWCRWXHJMKMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDLMJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZSJNYQYQQXYJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYADTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQTMYSTQXKBTZPKJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQHYWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQBSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFSYZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZNSDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJPZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPCQBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZTDKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDDNXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSDDTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZHLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJYHSLLLMZXELGLXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZBYFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHLRMGRXXZCLHNELJJTJTPWJYBJJBXJJTJTEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTMXGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPNHMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZGLHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJXY",b={ 19969:"DZ",19975:"WM",19988:"QJ",20048:"YL",20056:"SC",20060:"NM",20094:"QG",20127:"QJ",20167:"QC",20193:"YG",20250:"KH",20256:"ZC",20282:"SC",20285:"QJG",20291:"TD",20314:"YD",20340:"NE",20375:"TD",20389:"YJ",20391:"CZ",20415:"PB",20446:"YS",20447:"SQ",20504:"TC",20608:"KG",20854:"QJ",20857:"ZC",20911:"PF",20504:"TC",20608:"KG",20854:"QJ",20857:"ZC",20911:"PF",20985:"AW",21032:"PB",21048:"XQ",21049:"SC",21089:"YS",21119:"JC",21242:"SB",21273:"SC",21305:"YP",21306:"QO",21330:"ZC",21333:"SDC",21345:"QK",21378:"CA",21397:"SC",21414:"XS",21442:"SC",21477:"JG",21480:"TD",21484:"ZS",21494:"YX",21505:"YX",21512:"HG",21523:"XH",21537:"PB",21542:"PF",21549:"KH",21571:"E",21574:"DA",21588:"TD",21589:"O",21618:"ZC",21621:"KHA",21632:"ZJ",21654:"KG",21679:"LKG",21683:"KH",21710:"A",21719:"YH",21734:"WOE",21769:"A",21780:"WN",21804:"XH",21834:"A",21899:"ZD",21903:"RN",21908:"WO",21939:"ZC",21956:"SA",21964:"YA",21970:"TD",22003:"A",22031:"JG",22040:"XS",22060:"ZC",22066:"ZC",22079:"MH",22129:"XJ",22179:"XA",22237:"NJ",22244:"TD",22280:"JQ",22300:"YH",22313:"XW",22331:"YQ",22343:"YJ",22351:"PH",22395:"DC",22412:"TD",22484:"PB",22500:"PB",22534:"ZD",22549:"DH",22561:"PB",22612:"TD",22771:"KQ",22831:"HB",22841:"JG",22855:"QJ",22865:"XQ",23013:"ML",23081:"WM",23487:"SX",23558:"QJ",23561:"YW",23586:"YW",23614:"YW",23615:"SN",23631:"PB",23646:"ZS",23663:"ZT",23673:"YG",23762:"TD",23769:"ZS",23780:"QJ",23884:"QK",24055:"XH",24113:"DC",24162:"ZC",24191:"GA",24273:"QJ",24324:"NL",24377:"TD",24378:"QJ",24439:"PF",24554:"ZS",24683:"TD",24694:"WE",24733:"LK",24925:"TN",25094:"ZG",25100:"XQ",25103:"XH",25153:"PB",25170:"PB",25179:"KG",25203:"PB",25240:"ZS",25282:"FB",25303:"NA",25324:"KG",25341:"ZY",25373:"WZ",25375:"XJ",25384:"A",25457:"A",25528:"SD",25530:"SC",25552:"TD",25774:"ZC",25874:"ZC",26044:"YW",26080:"WM",26292:"PB",26333:"PB",26355:"ZY",26366:"CZ",26397:"ZC",26399:"QJ",26415:"ZS",26451:"SB",26526:"ZC",26552:"JG",26561:"TD",26588:"JG",26597:"CZ",26629:"ZS",26638:"YL",26646:"XQ",26653:"KG",26657:"XJ",26727:"HG",26894:"ZC",26937:"ZS",26946:"ZC",26999:"KJ",27099:"KJ",27449:"YQ",27481:"XS",27542:"ZS",27663:"ZS",27748:"TS",27784:"SC",27788:"ZD",27795:"TD",27812:"O",27850:"PB",27852:"MB",27895:"SL",27898:"PL",27973:"QJ",27981:"KH",27986:"HX",27994:"XJ",28044:"YC",28065:"WG",28177:"SM",28267:"QJ",28291:"KH",28337:"ZQ",28463:"TL",28548:"DC",28601:"TD",28689:"PB",28805:"JG",28820:"QG",28846:"PB",28952:"TD",28975:"ZC",29100:"A",29325:"QJ",29575:"SL",29602:"FB",30010:"TD",30044:"CX",30058:"PF",30091:"YSP",30111:"YN",30229:"XJ",30427:"SC",30465:"SX",30631:"YQ",30655:"QJ",30684:"QJG",30707:"SD",30729:"XH",30796:"LG",30917:"PB",31074:"NM",31085:"JZ",31109:"SC",31181:"ZC",31192:"MLB",31293:"JQ",31400:"YX",31584:"YJ",31896:"ZN",31909:"ZY",31995:"XJ",32321:"PF",32327:"ZY",32418:"HG",32420:"XQ",32421:"HG",32438:"LG",32473:"GJ",32488:"TD",32521:"QJ",32527:"PB",32562:"ZSQ",32564:"JZ",32735:"ZD",32793:"PB",33071:"PF",33098:"XL",33100:"YA",33152:"PB",33261:"CX",33324:"BP",33333:"TD",33406:"YA",33426:"WM",33432:"PB",33445:"JG",33486:"ZN",33493:"TS",33507:"QJ",33540:"QJ",33544:"ZC",33564:"XQ",33617:"YT",33632:"QJ",33636:"XH",33637:"YX",33694:"WG",33705:"PF",33728:"YW",33882:"SR",34067:"WM",34074:"YW",34121:"QJ",34255:"ZC",34259:"XL",34425:"JH",34430:"XH",34485:"KH",34503:"YS",34532:"HG",34552:"XS",34558:"YE",34593:"ZL",34660:"YQ",34892:"XH",34928:"SC",34999:"QJ",35048:"PB",35059:"SC",35098:"ZC",35203:"TQ",35265:"JX",35299:"JX",35782:"SZ",35828:"YS",35830:"E",35843:"TD",35895:"YG",35977:"MH",36158:"JG",36228:"QJ",36426:"XQ",36466:"DC",36710:"JC",36711:"ZYG",36767:"PB",36866:"SK",36951:"YW",37034:"YX",37063:"XH",37218:"ZC",37325:"ZC",38063:"PB",38079:"TD",38085:"QY",38107:"DC",38116:"TD",38123:"YD",38224:"HG",38241:"XTC",38271:"ZC",38415:"YE",38426:"KH",38461:"YD",38463:"AE",38466:"PB",38477:"XJ",38518:"YT",38551:"WK",38585:"ZC",38704:"XS",38739:"LJ",38761:"GJ",38808:"SQ",39048:"JG",39049:"XJ",39052:"HG",39076:"CZ",39271:"XT",39534:"TD",39552:"TD",39584:"PB",39647:"SB",39730:"LG",39748:"TPB",40109:"ZQ",40479:"ND",40516:"HG",40536:"HG",40583:"QJ",40765:"YQ",40784:"QJ",40840:"YK",40863:"QJG"},c=function(c){var d=c.charCodeAt(0);return d>40869||d<19968?c:b[d]?b[d]:a.charAt(d-19968)},d=function(a){for(var b,c=[""],d=0,e=a.length;d div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',b=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css",d.styleSheet?d.styleSheet.cssText=a:d.appendChild(document.createTextNode(a)),b.appendChild(d),c=!0}},v=function(a,c){b?(a.__resizeTriggers__||("static"===getComputedStyle(a).position&&(a.style.position="relative"),u(),a.__resizeLast__={},a.__resizeListeners__=[],(a.__resizeTriggers__=document.createElement("div")).className="resize-triggers",a.__resizeTriggers__.innerHTML='
',a.appendChild(a.__resizeTriggers__),f(a),a.addEventListener("scroll",h,!0),l&&a.__resizeTriggers__.addEventListener(l,function(b){b.animationName===r&&f(a)})),a.__resizeListeners__.push(c)):a.attachEvent("onresize",c)},w=function(a,c){b?(a.__resizeListeners__.splice(a.__resizeListeners__.indexOf(c),1),a.__resizeListeners__.length||(a.removeEventListener("scroll",h,!0),a.__resizeTriggers__=!a.removeChild(a.__resizeTriggers__))):a.detachEvent("onresize",c)};BI.ResizeDetector={addResizeListener:function(a,b){return v(a.element[0],b),function(){w(a.element[0],b)}},removeResizeListener:function(a,b){w(a.element[0],b)}}}(),function(){function a(a,b){return a0&&(this._items[0]=b,this._sinkDown(0)),a}},push:function(a){this._items[this._size++]=a,this._bubbleUp(this._size-1)},size:function(){return this._size},peek:function(){if(0!==this._size)return this._items[0]},_heapify:function(){for(var a=Math.floor((this._size+1)/2);a>=0;a--)this._sinkDown(a)},_bubbleUp:function(a){for(var b=this._items[a];a>0;){var c=Math.floor((a+1)/2)-1,d=this._items[c];if(this._comparator(d,b))return;this._items[c]=b,this._items[a]=d,a=c}},_sinkDown:function(a){for(var b=this._items[a];;){var c=2*(a+1)-1,d=2*(a+1),e=-1;if(cc?c:b},b=5,c={index:0,offset:0,position:0,contentHeight:0};BI.TableScrollHelper=function(a,b,c,d){this._rowOffsets=BI.PrefixIntervalTree.uniform(a,b),this._storedHeights=new Array(a);for(var e=0;e=0&&c>=a-b;){var d=this._updateRowHeight(c);this._position+=d,c--}},_updateRowHeight:function(a){if(a<0||a>=this._rowCount)return 0;var b=this._rowHeightGetter(a);if(b!==this._storedHeights[a]){var c=b-this._storedHeights[a];return this._rowOffsets.set(a,b),this._storedHeights[a]=b,this._contentHeight+=c,c}return 0},getRowPosition:function(a){return this._updateRowHeight(a),this._rowOffsets.sumUntil(a)},scrollBy:function(b){if(0===this._rowCount)return c;var d=this._rowOffsets.greatestLowerBound(this._position);d=a(d,0,Math.max(this._rowCount-1,0));var e=this._rowOffsets.sumUntil(d),f=d,g=this._position,h=this._updateRowHeight(f);0!==e&&(g+=h);var i=this._storedHeights[f]-(g-e);if(b>=0)for(;b>0&&f0&&f>=0;)if(b=0){var k=this._updateRowHeight(f);j=this._storedHeights[f],g+=k}}var l=this._contentHeight-this._viewportHeight;g=a(g,0,l),this._position=g;var m=this._rowOffsets.greatestLowerBound(g);m=a(m,0,Math.max(this._rowCount-1,0)),e=this._rowOffsets.sumUntil(m);var n=e-g;return this._updateHeightsInViewport(m,n),this._updateHeightsAboveViewport(m),{index:m,offset:n,position:this._position,contentHeight:this._contentHeight}},_getRowAtEndPosition:function(a){this._updateRowHeight(a);for(var b=a,c=this._storedHeights[b];c=0;)b--,b>=0&&(this._updateRowHeight(b),c+=this._storedHeights[b]);var d=this._rowOffsets.sumTo(a)-this._viewportHeight;return d<0&&(d=0),d},scrollTo:function(b){if(0===this._rowCount)return c;if(b<=0)return this._position=0,this._updateHeightsInViewport(0,0),{index:0,offset:0,position:this._position,contentHeight:this._contentHeight};if(b>=this._contentHeight-this._viewportHeight){var d=this._rowCount-1;b=this._getRowAtEndPosition(d)}this._position=b;var e=this._rowOffsets.greatestLowerBound(b);e=a(e,0,Math.max(this._rowCount-1,0));var f=this._rowOffsets.sumUntil(e),g=f-b;return this._updateHeightsInViewport(e,g),this._updateHeightsAboveViewport(e),{index:e,offset:g,position:this._position,contentHeight:this._contentHeight}},scrollToRow:function(b,c){b=a(b,0,Math.max(this._rowCount-1,0)),c=a(c,-this._storedHeights[b],0);var d=this._rowOffsets.sumUntil(b);return this.scrollTo(d-c)},scrollRowIntoView:function(b){b=a(b,0,Math.max(this._rowCount-1,0));var c=this._rowOffsets.sumUntil(b),d=c+this._storedHeights[b];if(c=a&&e<=b)return null;var f;a-d>e-b?(f=d,this._smallValues.pop()):(f=e,this._largeValues.pop());var g=this._valueToPositionMap[f];return delete this._valueToPositionMap[f],this._valueToPositionMap[c]=g,this._pushToHeaps(g,c),g},_pushToHeaps:function(a,b){var c={position:a,value:b};this._smallValues.push(c),this._largeValues.push(c)},_cleanHeaps:function(){this._cleanHeap(this._smallValues),this._cleanHeap(this._largeValues);var a=Math.min(this._smallValues.size(),this._largeValues.size()),b=Math.max(this._smallValues.size(),this._largeValues.size());b>10*a&&this._recreateHeaps()},_recreateHeaps:function(){for(var a=this._smallValues.size()b.value}},!function(){BI.LinkHashMap=function(){this.array=[],this.map={}},BI.LinkHashMap.prototype={constructor:BI.LinkHashMap,has:function(a){return a in this.map},add:function(a,b){"undefined"!=typeof a&&(a in this.map?this.map[a]=b:(this.array.push(a),this.map[a]=b))},remove:function(a){if(a in this.map){delete this.map[a];for(var b=0;b>5]|=128<>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;g16&&(c=this.core_md5(c,a.length*this.chrsz));for(var d=Array(16),e=Array(16),f=0;f<16;f++)d[f]=909522486^c[f],e[f]=1549556828^c[f];var g=this.core_md5(d.concat(this.str2binl(b)),512+b.length*this.chrsz);return this.core_md5(e.concat(g),640)},a.prototype.safe_add=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},a.prototype.bit_rol=function(a,b){return a<>>32-b},a.prototype.str2binl=function(a){for(var b=Array(),c=(1<>5]|=(a.charCodeAt(d/this.chrsz)&c)<>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},a.prototype.binl2b64=function(a){for(var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="",d=0;d<4*a.length;d+=3)for(var e=(a[d>>2]>>8*(d%4)&255)<<16|(a[d+1>>2]>>8*((d+1)%4)&255)<<8|a[d+2>>2]>>8*((d+2)%4)&255,f=0;f<4;f++)c+=8*d+6*f>32*a.length?this.b64pad:b.charAt(e>>6*(3-f)&63);return c},BI.MD5=new a}(),function(){var a=function(a){return Math.floor(a/2)},b=window.Int32Array||function(a){for(var b=[],c=a-1;c>=0;--c)b[c]=0;return b},c=function(a){for(var b=1;b0;--d)this._heap[d]=this._heap[2*d]+this._heap[2*d+1]},BI.PrefixIntervalTree.prototype={constructor:BI.PrefixIntervalTree,set:function(b,c){var d=this._half+b;for(this._heap[d]=c,d=a(d);0!==d;d=a(d))this._heap[d]=this._heap[2*d]+this._heap[2*d+1]},get:function(a){var b=this._half+a;return this._heap[b]},getSize:function(){return this._size},sumUntil:function(b){if(0===b)return 0;for(var c=this._half+b-1,d=this._heap[c];1!==c;c=a(c))c%2===1&&(d+=this._heap[c-1]);return d},sumTo:function(a){return this.sumUntil(a+1)},sum:function(a,b){return this.sumUntil(b)-this.sumUntil(a)},greatestLowerBound:function(a){if(a<0)return-1;var b=1;if(this._heap[b]<=a)return this._size;for(;b=0;--d)c[d]=b;return new BI.PrefixIntervalTree(c)},BI.PrefixIntervalTree.empty=function(a){return BI.PrefixIntervalTree.uniform(a,0)}}(),!function(){BI.Queue=function(a){this.capacity=a,this.array=[]},BI.Queue.prototype={constructor:BI.Queue,contains:function(a){return this.array.contains(a)},indexOf:function(a){return this.array.contains(a)},getElementByIndex:function(a){return this.array[a]},push:function(a){this.array.push(a),this.capacity&&this.array.length>this.capacity&&this.array.shift()},pop:function(){this.array.pop()},shift:function(){this.array.shift()},unshift:function(a){this.array.unshift(a),this.capacity&&this.array.length>this.capacity&&this.array.pop()},remove:function(a){this.array.remove(a)},splice:function(){this.array.splice.apply(this.array,arguments)},slice:function(){this.array.slice.apply(this.array,arguments)},size:function(){return this.array.length},each:function(a,b){var b=b||window,a=a||null;if(null!=a&&"function"==typeof a)for(var c=0;cc?c:a},b=6,c=10;BI.TableRowBuffer=function(d,e,f,g){this._bufferSet=new BI.IntegerBufferSet,this._defaultRowHeight=e,this._viewportRowsBegin=0,this._viewportRowsEnd=0,this._maxVisibleRowCount=Math.ceil(f/e)+1,this._bufferRowsCount=a(Math.floor(this._maxVisibleRowCount/2),b,c),this._rowsCount=d,this._rowHeightGetter=g,this._rows=[],this._viewportHeight=f},BI.TableRowBuffer.prototype={constructor:BI.TableRowBuffer,getRowsWithUpdatedBuffer:function(){for(var a=2*this._bufferRowsCount,b=Math.max(this._viewportRowsBegin-this._bufferRowsCount,0);b0;)this._addRowToBuffer(b,this._viewportRowsBegin,this._viewportRowsEnd-1),b++,a--;return this._rows},getRows:function(a,b){var c=b,d=c,e=a,f=Math.min(a+this._maxVisibleRowCount,this._rowsCount);for(this._viewportRowsBegin=a;e=f&&(d=this._bufferSet.replaceFurthestValuePosition(b,c,a)),null===d?(d=this._bufferSet.getNewPositionForValue(a),this._rows[d]=a):this._rows[d]=a}}}(),function(){BI.Tree=function(){this.root=new BI.Node(BI.UUID())},BI.Tree.prototype={constructor:BI.Tree,addNode:function(a,b,c){BI.isNull(b)?this.root.addChild(a,c):BI.isNull(a)?this.root.addChild(b,c):a.addChild(b,c)},isRoot:function(a){return a===this.root},getRoot:function(){return this.root},clear:function(){this.root.clear()},initTree:function(a){var b=this;this.clear();var c=[];for(BI.each(a,function(a,d){var e=new BI.Node(d);e.set("data",d),b.addNode(e),c.push(e)});!BI.isEmpty(c);){var d=c.shift(),e=d.get("data");BI.each(e.children,function(a,e){var f=new BI.Node(e);f.set("data",e),c.push(f),b.addNode(d,f)})}},_toJSON:function(a){var b=this,c=[];return BI.each(a.getChildren(),function(a,d){c.push(b._toJSON(d))}),BI.extend({id:a.id},BI.deepClone(a.get("data")),c.length>0?{children:c}:{})},toJSON:function(a){var b=this,c=[];return BI.each((a||this.root).getChildren(),function(a,d){c.push(b._toJSON(d))}),c},_toJSONWithNode:function(a){var b=this,c=[];return BI.each(a.getChildren(),function(a,d){c.push(b._toJSONWithNode(d))}),BI.extend({id:a.id},BI.deepClone(a.get("data")),{node:a},c.length>0?{children:c}:{})},toJSONWithNode:function(a){var b=this,c=[];return BI.each((a||this.root).getChildren(),function(a,d){c.push(b._toJSONWithNode(d))}),c},search:function(a,b,c){if(!(a instanceof BI.Node))return arguments.callee.apply(this,[this.root,a,b]);var d=this,e=null;return BI.isNull(b)?null:BI.isEqual(a[c||"id"],b)?a:(BI.any(a.getChildren(),function(a,f){if(e=d.search(f,b,c),null!==e)return!0}),e)},_traverse:function(a,b){var c=[];for(c.push(a);!BI.isEmpty(c);){var d=c.shift(),e=b&&b(d);if(e===!1)break;e!==!0&&null!=d&&(c=c.concat(d.getChildren()))}},traverse:function(a){this._traverse(this.root,a)},_recursion:function(a,b,c){var d=this;return BI.every(a.getChildren(),function(a,e){var f=BI.clone(b);f.push(e.id);var g=c&&c(e,f);return g!==!1&&(g===!0||d._recursion(e,f,c))})},recursion:function(a){this._recursion(this.root,[],a)},inOrderTraverse:function(a){this._inOrderTraverse(this.root,a)},_inOrderTraverse:function(a,b){null!=a&&(this._inOrderTraverse(a.getLeft()),b&&b(a),this._inOrderTraverse(a.getRight()))},nrInOrderTraverse:function(a){for(var b=[],c=this.root;null!=c||!BI.isEmpty(b);){for(;null!=c;)b.push(c),c=c.getLeft();c=b.pop(),a&&a(c),c=c.getRight()}},preOrderTraverse:function(a){this._preOrderTraverse(this.root,a)},_preOrderTraverse:function(a,b){null!=a&&(b&&b(a),this._preOrderTraverse(a.getLeft()),this._preOrderTraverse(a.getRight()))},nrPreOrderTraverse:function(a){for(var b=[],c=this.root;null!=c||!BI.isEmpty(b);){for(;null!=c;)a&&a(c),b.push(c),c=c.getLeft();c=b.pop(),c=c.getRight()}},postOrderTraverse:function(a){this._postOrderTraverse(this.root,a)},_postOrderTraverse:function(a,b){null!=a&&(this._postOrderTraverse(a.getLeft()),this._postOrderTraverse(a.getRight()),b&&b(a))},nrPostOrderTraverse:function(a){for(var b=[],c=this.root,d=null;null!=c||!BI.isEmpty(b);){for(;null!=c;)b.push(c),c=c.getLeft();c=BI.last(b),null==c.getRight()||c.getRight()==d?(a&&a(c),c=b.pop(),d=c,c=null):c=c.getRight()}}},BI.Node=function(a){BI.isObject(a)?BI.extend(this,a):this.id=a,this.clear.apply(this,arguments)},BI.Node.prototype={constructor:BI.Node,set:function(a,b){return BI.isObject(a)?void BI.extend(this,a):void(this[a]=b)},get:function(a){return this[a]},isLeaf:function(){return BI.isEmpty(this.children)},getChildren:function(){return this.children},getChildrenLength:function(){return this.children.length},getFirstChild:function(){return BI.first(this.children)},getLastChild:function(){return BI.last(this.children)},setLeft:function(a){this.left=a},getLeft:function(){return this.left},setRight:function(a){this.right=a},getRight:function(){return this.right},setParent:function(a){this.parent=a},getParent:function(){return this.parent},getChild:function(a){return this.children[a]},getChildIndex:function(a){return BI.findIndex(this.children,function(b,c){return c.get("id")===a})},removeChild:function(a){this.removeChildByIndex(this.getChildIndex(a))},removeChildByIndex:function(a){var b=this.getChild(a-1),c=this.getChild(a+1); null!=b&&b.setRight(c||null),null!=c&&c.setLeft(b||null),this.children.splice(a,1)},removeAllChilds:function(){this.children=[]},addChild:function(a,b){var c=null;c=BI.isUndefined(b)?this.children.length-1:b-1,a.setParent(this),c>=0&&(this.getChild(c)&&this.getChild(c).setRight(a),a.setLeft(this.getChild(c))),BI.isUndefined(b)?this.children.push(a):this.children.splice(b,0,a)},equals:function(a){return this===a||this.id===a.id},clear:function(){this.parent=null,this.left=null,this.right=null,this.children=[]}},BI.extend(BI.Tree,{transformToArrayFormat:function(a,b){if(!a)return[];var c=[];if(BI.isArray(a))for(var d=0,e=a.length;d=this.x&&a<=this.x+this.w&&b>=this.y&&b<=this.y+this.h)},getPosition:function(){var a=[];return a.push(this.x+this.w/2),a.push(this.y+this.h/2),a}},BI.BehaviorFactory={createBehavior:function(a,b){var c;switch(a){case"highlight":c=BI.HighlightBehavior;break;case"redmark":c=BI.RedMarkBehavior}return new c(b)}},BI.Behavior=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.Behavior.superclass._defaultConfig.apply(this,arguments),{rule:function(){return!0}})},_init:function(){BI.Behavior.superclass._init.apply(this,arguments)},doBehavior:function(){}}),BI.Layout=BI.inherit(BI.Widget,{props:function(){return{scrollable:null,scrollx:!1,scrolly:!1,items:[]}},render:function(){this._init4Margin(),this._init4Scroll()},_init4Margin:function(){this.options.top&&this.element.css("top",this.options.top),this.options.left&&this.element.css("left",this.options.left),this.options.bottom&&this.element.css("bottom",this.options.bottom),this.options.right&&this.element.css("right",this.options.right)},_init4Scroll:function(){switch(this.options.scrollable){case!0:this.element.css("overflow","auto");break;case!1:this.element.css("overflow","hidden")}this.options.scrollx&&this.element.css({"overflow-x":"auto","overflow-y":"hidden"}),this.options.scrolly&&this.element.css({"overflow-x":"hidden","overflow-y":"auto"})},_mountChildren:function(){var a=this,b=document.createDocumentFragment(),c=!1;BI.each(this._children,function(d,e){e.element!==a.element&&(b.appendChild(e.element[0]),c=!0)}),c===!0&&this.element.append(b)},_getChildName:function(a){return a+""},_addElement:function(a,b){var c,d=this;return this.hasWidget(this._getChildName(a))?c=this.getWidgetByName(this._getChildName(a)):(c=BI.createWidget(b),c.on(BI.Events.DESTROY,function(){BI.each(d._children,function(a,b){b===c&&(BI.remove(d._children,b),d.removeItemAt(0|a))})}),this.addWidget(this._getChildName(a),c)),c},_getOptions:function(a){return a instanceof BI.Widget&&(a=a.options),a=BI.stripEL(a),a instanceof BI.Widget&&(a=a.options),a},_compare:function(a,b){function c(a,b,e,f){if(a===b)return 0!==a||1/a===1/b;if(null==a||null==b)return a===b;var g=Object.prototype.toString.call(a);switch(g){case"[object RegExp]":case"[object String]":return""+a==""+b;case"[object Number]":return+a!==+a?+b!==+b:0===+a?1/+a===1/b:+a===+b;case"[object Date]":case"[object Boolean]":return+a===+b}var h="[object Array]"===g;if(!h){if(BI.isFunction(a)&&BI.isFunction(b))return!0;a=d._getOptions(a),b=d._getOptions(b)}e=e||[],f=f||[];for(var i=e.length;i--;)if(e[i]===a)return f[i]===b;if(e.push(a),f.push(b),h){if(i=a.length,i!==b.length)return!1;for(;i--;)if(!c(a[i],b[i],e,f))return!1}else{var j,k=_.keys(a);if(i=k.length,_.keys(b).length!==i)return!1;for(;i--;)if(j=k[i],!_.has(b,j)||!c(a[j],b[j],e,f))return!1}return e.pop(),f.pop(),!0}var d=this;return c(a,b)},_getWrapper:function(){return this.element},_addItemAt:function(a,b){for(var c=this.options.items.length;c>a;c--)this._children[this._getChildName(c)]=this._children[this._getChildName(c-1)];delete this._children[this._getChildName(a)],this.options.items.splice(a,0,b)},_removeItemAt:function(a){for(var b=a;bthis.options.items.length)){this._addItemAt(a,b);var c=this._addElement(a,b);return a>0?this._children[this._getChildName(a-1)].element.after(c.element):c.element.prependTo(this._getWrapper()),c._mount(),c}},removeItemAt:function(a){a=BI.isArray(a)?a:[a];for(var b=[],c=[],d={},e=0,f=this.options.items.length;ethis.options.items.length-1)){var c,d=this._children[this._getChildName(a)];if(c=d.update(this._getOptions(b)))return c;var e=this._children[this._getChildName(a)];delete this._children[this._getChildName(a)],this.options.items.splice(a,1);var f=this._addElement(a,b);this.options.items.splice(a,0,b),this._children[this._getChildName(a)]=f,a>0?this._children[this._getChildName(a-1)].element.after(f.element):f.element.prependTo(this._getWrapper()),e._destroy(),f._mount()}},addItems:function(a){var b=this,c=this.options,d=document.createDocumentFragment(),e=[];BI.each(a,function(a,f){var g=b._addElement(c.items.length,f);b._children[b._getChildName(c.items.length)]=g,c.items.push(f),e.push(g),d.appendChild(g.element[0])}),this._getWrapper().append(d),BI.each(e,function(a,b){b._mount()})},prependItems:function(a){var b=this;a=a||[];for(var c=document.createDocumentFragment(),d=[],e=a.length-1;e>=0;e--){this._addItemAt(0,a[e]);var f=this._addElement(0,a[e]);b._children[b._getChildName(0)]=f,this.options.items.unshift(a[e]),d.push(f),c.appendChild(f.element[0])}this._getWrapper().prepend(c),BI.each(d,function(a,b){b._mount()})},getValue:function(){var a,b=this,c=[];return BI.each(this.options.items,function(d){if(a=b._children[b._getChildName(d)]){var e=a.getValue();e=BI.isArray(e)?e:[e],c=c.concat(e)}}),c},setValue:function(a){var b,c=this;BI.each(this.options.items,function(d){(b=c._children[c._getChildName(d)])&&b.setValue(a)})},setText:function(a){var b,c=this;BI.each(this.options.items,function(d){(b=c._children[c._getChildName(d)])&&b.setText(a)})},patchItem:function(a,b,c){if(!this._compare(a,b))return this.updateItemAt(c,b)},updateChildren:function(a,b){function c(a,b,c,d){return a=j._getOptions(a),b=j._getOptions(b),BI.isKey(a.key)?a.key===b.key:c>=0?c===d:void 0}function d(a,b){var c=j._getOptions(a),d=null==c.key?b:c.key;return s[d]=j._addElement(d,a)}function e(a,b,c,e){for(;c<=e;++c){var f=d(b[c],c);g(f,a,!1,c)}}function f(a,b,c){for(;b<=c;++b){var d=j._getOptions(a[b]),e=null==d.key?b:d.key;s[e]._destroy()}}function g(a,b,c,d){a=j._getOptions(a),b=b&&j._getOptions(b);var e=BI.isKey(a.key)?a.key:d;if(b&&s[b.key]){var f,g=BI.isKey(b.key)?b.key:d;f=c?s[g].element.next():s[g].element,f.length>0?f.before(s[e].element):j._getWrapper().append(s[e].element)}else j._getWrapper().append(s[e].element)}var h,i,j=this,k=0,l=0,m=a.length-1,n=a[0],o=a[m],p=b.length-1,q=b[0],r=b[p],s={};for(BI.each(a,function(a,b){b=j._getOptions(b);var c=null==b.key?a:b.key;BI.isKey(c)&&(s[c]=j._children[j._getChildName(a)])});k<=m&&l<=p;)if(BI.isNull(n))n=a[++k];else if(BI.isNull(o))o=a[--m];else if(c(n,q,k,l))i=this.patchItem(n,q,k)||i,s[this._getChildName(k)]=this._children[this._getChildName(k)],n=a[++k],q=b[++l];else if(c(o,r,m,p))i=this.patchItem(o,r,m)||i,s[this._getChildName(m)]=this._children[this._getChildName(m)],o=a[--m],r=b[--p];else if(c(n,r))i=this.patchItem(n,r,k)||i,s[this._getChildName(k)]=this._children[this._getChildName(k)],g(n,o,!0),n=a[++k],r=b[--p];else if(c(o,q))i=this.patchItem(o,q,m)||i,s[this._getChildName(m)]=this._children[this._getChildName(m)],g(o,n),o=a[--m],q=b[++l];else{var t=d(q);g(t,n),q=b[++l]}return k>m?(h=BI.isNull(b[p+1])?null:b[p+1].elm,e(h,b,l,p)):l>p&&f(a,k,m),this._children={},BI.each(b,function(a,b){var c=j._getOptions(b),d=null==c.key?a:c.key;s[d]._mount(),j._children[j._getChildName(a)]=s[d]}),i},update:function(a){var b=this.options,c=a.items||[],d=this.updateChildren(b.items,c);return this.options.items=c,d},stroke:function(a){var b=this;BI.each(a,function(a,c){c&&b._addElement(a,c)})},removeWidget:function(a){var b;BI.isWidget(a)?BI.each(this._children,function(c,d){d===a&&(b=c)}):b=a,b&&this._removeItemAt(0|b)},empty:function(){BI.Layout.superclass.empty.apply(this,arguments),this.options.items=[]},destroy:function(){BI.Layout.superclass.destroy.apply(this,arguments),this.options.items=[]},populate:function(a){this.options;return a=a||[],this._isMounted?void this.update({items:a}):(this.options.items=a,void this.stroke(a))},resize:function(){}}),BI.shortcut("bi.layout",BI.Layout),BI.Action=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.Action.superclass._defaultConfig.apply(this,arguments),{src:null,tar:null})},_init:function(){BI.Action.superclass._init.apply(this,arguments)},actionPerformed:function(a,b,c){},actionBack:function(a,b,c){}}),BI.ActionFactory={createAction:function(a,b){var c;switch(a){case"show":c=BI.ShowAction}return new c(b)}},BI.ShowAction=BI.inherit(BI.Action,{_defaultConfig:function(){return BI.extend(BI.ShowAction.superclass._defaultConfig.apply(this,arguments),{})},_init:function(){BI.ShowAction.superclass._init.apply(this,arguments)},actionPerformed:function(a,b,c){b=b||this.options.tar,b.setVisible(!0),c&&c()},actionBack:function(a,b,c){a=a||this.options.tar,a.setVisible(!1),c&&c()}}),BI.FloatSection=BI.inherit(BI.View,{_init:function(){BI.FloatSection.superclass._init.apply(this,arguments);var a=this,b=["_init","_defaultConfig","_vessel","_render","getName","listenEnd","local","refresh","load","change"];b=BI.makeObject(b,!0),BI.each(this.constructor.caller.caller.caller.prototype,function(c){if(!b[c]){var d=a[c];BI.isFunction(d)&&(a[c]=BI.bind(function(){return this.model._start===!0?void this._F.push({f:d,arg:arguments}):d.apply(this,arguments)},a))}})},rebuildNorth:function(a){return!0},rebuildCenter:function(a){},rebuildSouth:function(a){return!1},close:function(){this.notifyParentEnd(),this.trigger(BI.PopoverSection.EVENT_CLOSE)},end:function(){}}),BI.PopoverSection=BI.inherit(BI.Widget,{_init:function(){BI.PopoverSection.superclass._init.apply(this,arguments)},rebuildNorth:function(a){return!0},rebuildCenter:function(a){},rebuildSouth:function(a){return!1},close:function(){this.fireEvent(BI.PopoverSection.EVENT_CLOSE)},end:function(){}}),BI.PopoverSection.EVENT_CLOSE="EVENT_CLOSE",function(){function a(a){var b=""===a||null===a||void 0===a;return b}function b(a){return"Invalid Date"==a||"NaN"==a}function c(a,b){var c=b.indexOf("E"),d=b.substr(0,c),e=b.substr(c+1);if(/^[0\.-]+$/.test(a))a=BI._numberFormat(0,d)+"E"+BI._numberFormat(0,e);else{var f=a<0;f&&(a=a.substr(1));var g=(d.split(".")[0]||"").length,h=a.indexOf(".");h<0&&(h=a.length);var i=0;a=a.replace(".","");for(var j=a.length;i="1")break}var l=h-i-g,m=a.substr(i,g),n=i+g-a.length;if(n>0)for(var o=0;o-1)return a>=0?d(a+"",b.substring(0,c)):d(-a+"",b.substr(c+1));if(+a<0&&"-"!==b.charAt(0))return d(-a+"","-"+b);var g=a.split("."),h=b.split("."),i=g[0]||"",j=h[0]||"",k=g[1]||"",l=h[1]||"";if(/[%‰]$/.test(b)){var m=/[%]$/.test(b)?"00":"000";k+=m,i+=k.substr(0,m.length),i=i.replace(/^0+/gi,""),k=k.substr(m.length).replace(/0+$/gi,"")}var n=e(k,l);n.leftPlus&&(i=parseInt(i)+1+"",i=isNaN(i)?"1":i),n=n.num;var o=f(i,j);return/[0-9]/.test(o)||(o+="0"),/[0-9]/.test(n)?o+"."+n:o+n}function e(b,c){for(var d="",e=0,f=0,g=c.length;f4){k.leftPlus=!0;var l=d.match(/^[0-9]+/);if(l){var m=l[0],n=m.length,o=parseInt(m)+1+"";o.length>n?o=o.substr(1):(o=String.leftPad(o,n,"0"),k.leftPlus=!1),d=d.replace(/^[0-9]+/,o)}}return k.num=d,k}function f(b,c){for(var d="",e=b.length-1,f=-1,g=-1,h=c.length-1;h>=0;h--){var i=c.charAt(h),j=b.charAt(e);switch(i){case"0":a(j)&&(j="0"),g=-1,d=j+d,e--;break;case"#":g=h,d=j+d,e--;break;case",":if(!a(j)){var k=c.match(/,[#0]+/);k&&(f=k[0].length-1),d=","+d}break;default:d=i+d}}if(g>-1){var l=b.substr(0,e+1);d=d.substr(0,g)+l+d.substr(g)}if(f>0){var m=d.match(/[0-9]+,/);if(m){m=m[0];for(var n="",o=m.length-1-f;o>=0;o-=f)n=m.substr(o,f)+","+n;var p=m.substr(0,o+f);a(p)||(n=p+","+n)}d=d.replace(/[0-9]+,/,n)}return d}window.BI||(window.BI={}),BI.cjkEncode=function(a){if("string"!=typeof a)return a;for(var b="",c=0;c=128||91===d||93===d?"["+d.toString(16)+"]":a.charAt(c)}return b},BI.cjkEncodeDO=function(a){if(BI.isPlainObject(a)){var b={};return $.each(a,function(a,c){"string"!=typeof c&&(c=BI.jsonEncode(c)),a=BI.cjkEncode(a),b[a]=BI.cjkEncode(c)}),b}return a},BI.jsonEncode=function(a){var b=!!{}.hasOwnProperty,c={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},d=function(a){return/["\\\x00-\x1f]/.test(a)?'"'+a.replace(/([\x00-\x1f\\"])/g,function(a,b){var d=c[b];return d?d:(d=b.charCodeAt(),"\\u00"+Math.floor(d/16).toString(16)+(d%16).toString(16))})+'"':'"'+a+'"'},e=function(a){var b,c,d,e=["["],f=a.length;for(c=0;c2?Date._MN[b.getMonth()]:d<2?b.getMonth()+1:String.leftPad(b.getMonth()+1+"",2,"0");break;case"d":c=d>1?String.leftPad(b.getDate()+"",2,"0"):b.getDate();break;case"h":var f=b.getHours()%12;0===f&&(f=12),c=d>1?String.leftPad(f+"",2,"0"):f;break;case"H":c=d>1?String.leftPad(b.getHours()+"",2,"0"):b.getHours();break;case"m":c=d>1?String.leftPad(b.getMinutes()+"",2,"0"):b.getMinutes();break;case"s":c=d>1?String.leftPad(b.getSeconds()+"",2,"0"):b.getSeconds();break;case"a":c=b.getHours()<12?"am":"pm";break;case"z":c=b.getTimezone();break;default:c=a.str}return c}if(!a)return"";var d=b.length,e="";if(d>0){for(var f=b.charAt(0),g=0,h=f,i=1;i$("body").outerWidth()&&(l-=k.element.outerWidth()),m+k.element.outerHeight()>$("body").outerHeight()?(m-=k.element.outerHeight()+15, j=h.top-k.element.outerHeight()-5,!f.belowMouse&&(m=Math.min(m,j))):!f.belowMouse&&(m=Math.max(m,j)),k.element.css({left:l<0?0:l+"px",top:m<0?0:m+"px"}),k.element.hover(function(){g.remove(b),e.element.trigger("mouseleave.title"+e.getName())}),this},add:function(a,b){return this.has(a)?this:(this.set(a,b),this)},get:function(a){return this.tooltipsManager[a]},set:function(a,b){this.tooltipsManager[a]=b},has:function(a){return null!=this.tooltipsManager[a]},remove:function(a){return this.has(a)?(this.tooltipsManager[a].destroy(),delete this.tooltipsManager[a],this):this}}),BI.FloatBoxRouter=BI.inherit(BI.WRouter,{routes:{},_init:function(){this.store={},this.views={}},createView:function(a,b,c,d){return BI.Factory.createView(a,this.get(a),b||{},c||{},d)},open:function(a,b,c,d,e){var f=this,g=BI.isKey(b);e||(e={}),a=d.rootURL+"/"+a;var h=void 0;if(g){b+="";var i=b.split(".");BI.each(i,function(a,b){h=0===a?d.model.get(b)||{}:h[b]||{}}),h.id=e.id||i[i.length-1]}else h=b;if(BI.extend(h,e.data),this.controller||(this.controller=new BI.FloatBoxController),!this.store[a]){this.store[a]=BI.createWidget({type:"bi.float_box"},e);var j=this.createView(a,h,c,d);g&&d.model.addChild(b,j.model),j.listenTo(j.model,"destroy",function(){f.remove(a,d)}),d.on(BI.Events.UNMOUNT,function(){f.remove(a,d)}),this.store[a].populate(j),this.views[a]=j,this.controller.add(a,this.store[a]),d&&d.on("end:"+j.cid,function(){BI.nextTick(function(){f.close(a),d.listenEnd.apply(d,g?b.split("."):[b])!==!1&&d.populate()},30)}).on("change:"+j.cid,_.bind(d.notifyParent,d))}return this.controller.open(a),this.views[a].populate(h,e.force||!0),this},close:function(a){return this.controller&&this.controller.close(a),this},remove:function(a,b){return a=b.rootURL+"/"+a,this.controller&&(this.controller.remove(a),delete this.store[a],this.views[a]&&this.views[a].model.destroy(),delete this.views[a]),this}}),BI.EventList=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.EventList.superclass._defaultConfig.apply(this,arguments),{event:"click",callback:BI.emptyFn,handle:"",items:[]})},_init:function(){BI.EventList.superclass._init.apply(this,arguments),this.populate(this.options.items)},_getHandle:function(a){var b=this.options.handle?_.result(a,this.options.handle):a;return b.element||b},populate:function(a){var b=this,c=this.options.event,d=this.options.callback;BI.nextTick(function(){BI.each(a,function(a,e){var f=d(e);BI.isFunction(f)&&(f=BI.debounce(f,BI.EVENT_RESPONSE_TIME,!0)),b._getHandle(e)[c](f)})})}}),BI.ListenerList=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.ListenerList.superclass._defaultConfig.apply(this,arguments),{event:"click",callback:BI.emptyFn,items:[]})},_init:function(){BI.ListenerList.superclass._init.apply(this,arguments),this.populate(this.options.items)},_getHandle:function(a){var b=this.options.handle?_.result(a,this.options.handle):a;return b.element||b},populate:function(a){var b=this,c=this.options.event,d=this.options.callback;BI.nextTick(function(){BI.each(a,function(a,e){var f=d(e);BI.isFunction(f)&&(f=BI.debounce(f,BI.EVENT_RESPONSE_TIME,!0)),b._getHandle(e).on(c,f)})})}}),BI.OffList=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.OffList.superclass._defaultConfig.apply(this,arguments),{event:"click",items:[]})},_init:function(){BI.OffList.superclass._init.apply(this,arguments),this.populate(this.options.items)},_getHandle:function(a){var b=this.options.handle?_.result(a,this.options.handle):a;return b.element||b},populate:function(a){var b=this,c=this.options.event;BI.each(a,function(a,d){b._getHandle(d).off(c)})}}),_.extend(BI,{Events:{KEYDOWN:"_KEYDOWN",BACKSPACE:"_BACKSPACE",SPACE:"_SPACE",ENTER:"_ENTER",CONFIRM:"_CONFIRM",ERROR:"_ERROR",PAUSE:"_PAUSE",DESTROY:"_DESTROY",UNMOUNT:"_UNMOUNT",CLEAR:"_CLEAR",ADD:"_ADD",EDITING:"_EDITING",EMPTY:"_EMPTY",VIEW:"_VIEW",RESIZE:"_RESIZE",BEFOREEDIT:"_BEFOREEDIT",AFTEREDIT:"_AFTEREDIT",STARTEDIT:"_STARTEDIT",STOPEDIT:"_STOPEDIT",CHANGE:"_CHANGE",EXPAND:"_EXPAND",COLLAPSE:"_COLLAPSE",CALLBACK:"_CALLBACK",CLICK:"_CLICK",STATECHANGE:"_STATECHANGE",BEFORESTATECHANGE:"_BEFORESTATECHANGE",INIT:"_INIT",AFTERINIT:"_AFTERINIT",SCROLL:"_SCROLL",STARTLOAD:"_STARTLOAD",AFTERLOAD:"_AFTERLOAD",BS:"beforesubmit",AS:"aftersubmit",SC:"submitcomplete",SF:"submitfailure",SS:"submitsuccess",BVW:"beforeverifywrite",AVW:"afterverifywrite",AV:"afterverify",BW:"beforewrite",AW:"afterwrite",WS:"writesuccess",WF:"writefailure",BA:"beforeappend",AA:"afterappend",BD:"beforedelete",AD:"beforedelete",UC:"unloadcheck",BTOPDF:"beforetopdf",ATOPDF:"aftertopdf",BTOEXCEL:"beforetoexcel",ATOEXCEL:"aftertoexcel",BTOWORD:"beforetoword",ATOWORD:"aftertoword",BTOIMAGE:"beforetoimage",ATOIMAGE:"aftertoimage",BTOHTML:"beforetohtml",ATOHTML:"aftertohtml",BIMEXCEL:"beforeimportexcel",AIMEXCEL:"afterimportexcel",BPDFPRINT:"beforepdfprint",APDFPRINT:"afterpdfprint",BFLASHPRINT:"beforeflashprint",AFLASHPRINT:"afterflashprint",BAPPLETPRINT:"beforeappletprint",AAPPLETPRINT:"afterappletprint",BSEVERPRINT:"beforeserverprint",ASERVERPRINT:"afterserverprint",BEMAIL:"beforeemail",AEMAIL:"afteremail"}}),BI.extend(jQuery.fn,{destroy:function(){this.remove(),BI.isIE()===!0&&(this[0].outerHTML="")},__textKeywordMarked__:function(a,b,c){if(!BI.isKey(b)||(a+"").length>100)return this.text((a+"").replaceAll(" "," "));b+="",b=BI.toUpperCase(b);var d=(a||"")+"";for(c=(c||BI.makeFirstPY(a))+"",null!=c&&(c=BI.toUpperCase(c)),this.empty();;){var e=BI.toUpperCase(d).indexOf(b),f=null;if(null!=c&&(f=c.indexOf(b),f>=0&&(f%=a.length)),e>=0)this.append(d.substr(0,e)),this.append($("").addClass("bi-keyword-red-mark").text(d.substr(e,b.length).replaceAll(" "," "))),d=d.substr(e+b.length),null!=c&&(c=c.substr(e+b.length));else{if(!(null!=f&&f>=0&&Math.floor(f/a.length)===Math.floor((f+b.length-1)/a.length))){this.append(d);break}this.append(d.substr(0,f)),this.append($("").addClass("bi-keyword-red-mark").text(d.substr(f,b.length).replaceAll(" "," "))),null!=c&&(c=c.substr(f+b.length)),d=d.substr(f+b.length)}}return this},getDomHeight:function(a){var b=$(this).clone();b.appendTo($(a||"body"));var c=b.height();return b.remove(),c},hasVerticalScroll:function(){return this.height()>0&&this[0].clientWidth0&&this[0].clientHeightb.left+this.outerWidth()||a.pageYb.top+this.outerHeight())},__hasZIndexMask__:function(a){return a&&null!=this.zIndexMask[a]},__buildZIndexMask__:function(a,b){this.zIndexMask=this.zIndexMask||{},this.indexMask=this.indexMask||[];var c=BI.createWidget({type:"bi.center_adapt",cls:"bi-z-index-mask",items:b});return c.element.css({"z-index":a}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:c,left:0,right:0,top:0,bottom:0}]}),this.indexMask.push(c),a&&(this.zIndexMask[a]=c),c.element},__releaseZIndexMask__:function(a){if(a&&this.zIndexMask[a])return this.indexMask.remove(this.zIndexMask[a]),void this.zIndexMask[a].destroy();this.indexMask=this.indexMask||[];var b=this.indexMask.pop();b&&b.destroy()}}),BI.extend(jQuery,{getLeftPosition:function(a,b,c){return{left:a.element.offset().left-b.element.outerWidth()-(c||0)}},getRightPosition:function(a,b,c){var d=a.element;return{left:d.offset().left+d.outerWidth()+(c||0)}},getTopPosition:function(a,b,c){return{top:a.element.offset().top-b.element.outerHeight()-(c||0)}},getBottomPosition:function(a,b,c){var d=a.element;return{top:d.offset().top+d.outerHeight()+(c||0)}},isLeftSpaceEnough:function(a,b,c){return $.getLeftPosition(a,b,c).left>=0},isRightSpaceEnough:function(a,b,c){var d=b.element.bounds(),e=$("body").bounds();return $.getRightPosition(a,b,c).left+d.width<=e.width},isTopSpaceEnough:function(a,b,c){return $.getTopPosition(a,b,c).top>=0},isBottomSpaceEnough:function(a,b,c){var d=b.element.bounds(),e=$("body").bounds();return $.getBottomPosition(a,b,c).top+d.height<=e.height},isRightSpaceLarger:function(a){var b=$("body").bounds();return b.width-a.element.offset().left-a.element.bounds().width>=a.element.offset().left},isBottomSpaceLarger:function(a){var b=$("body").bounds();return b.height-a.element.offset().top-a.element.bounds().height>=a.element.offset().top},getLeftAlignPosition:function(a,b,c){var d=b.element.bounds(),e=$("body").bounds(),f=a.element.offset().left+c;return f+d.width>e.width&&(f=e.width-d.width),f<0&&(f=0),{left:f}},getLeftAdaptPosition:function(a,b,c){return $.isLeftSpaceEnough(a,b,c)?$.getLeftPosition(a,b,c):{left:0}},getRightAlignPosition:function(a,b,c){var d=a.element.bounds(),e=b.element.bounds(),f=a.element.offset().left+d.width-e.width-c;return f<0&&(f=0),{left:f}},getRightAdaptPosition:function(a,b,c){return $.isRightSpaceEnough(a,b,c)?$.getRightPosition(a,b,c):{left:$("body").bounds().width-b.element.bounds().width}},getTopAlignPosition:function(a,b,c,d){var e,f,g=a.element.offset(),h=a.element.bounds(),i=b.element.bounds(),j=$("body").bounds();return $.isBottomSpaceEnough(a,b,-1*h.height+c)?e=g.top+c:d?(e=g.top+c,f=j.height-e):(e=j.height-i.height,ef.height?{top:0,adaptHeight:f.height-c}:{top:0}},getBottomAlignPosition:function(a,b,c,d){var e,f,g=a.element.offset(),h=a.element.bounds(),i=b.element.bounds(),j=$("body").bounds();return $.isTopSpaceEnough(a,b,-1*h.height+c)?e=g.top+h.height-i.height-c:d?(e=0,f=g.top+h.height-c):(e=0,i.height+c>j.height&&(f=j.height-c)),e<0&&(e=0),f?{top:e,adaptHeight:f}:{top:e}},getBottomAdaptPosition:function(a,b,c,d){var e=a.element.offset(),f=a.element.bounds(),g=b.element.bounds(),h=$("body").bounds();return $.isBottomSpaceEnough(a,b,c)?$.getBottomPosition(a,b,c):d?{top:e.top+f.height+c,adaptHeight:h.height-e.top-f.height-c}:g.height+c>h.height?{top:c,adaptHeight:h.height-c}:{top:h.height-g.height-c}},getCenterAdaptPosition:function(a,b){var c,d=a.element.offset(),e=a.element.bounds(),f=b.element.bounds(),g=$("body").bounds();return c=d.left+e.width/2+f.width/2>g.width?g.width-f.width:d.left+e.width/2-f.width/2,c<0&&(c=0),{left:c}},getMiddleAdaptPosition:function(a,b){var c,d=a.element.offset(),e=a.element.bounds(),f=b.element.bounds(),g=$("body").bounds();return c=d.top+e.height/2+f.height/2>g.height?g.height-f.height:d.top+e.height/2-f.height/2,c<0&&(c=0),{top:c}},getComboPositionByDirections:function(a,b,c,d,e,f){c||(c=0),d||(d=0);var g,h,i,j,k,l=[],m=[],n=!1,o=!1,p=!1;for(g=0;g-1?f===b?d?h.push(j):h[a]=j:d?i.push(j):i[a]=j:(k=g.indexOf(b),k>-1&&Math.floor(k/f.length)===Math.floor((k+b.length-1)/f.length)&&(f===b||b.length===f.length?d?h.push(j):h[a]=j:d?i.push(j):i[a]=j))}),{matched:h,finded:i}}}),BI.DOM={},BI.extend(BI.DOM,{hang:function(a){if(!BI.isEmpty(a)){var b=document.createDocumentFragment();return BI.each(a,function(a,c){c instanceof BI.Widget&&(c=c.element),c instanceof $&&c[0]&&b.appendChild(c[0])}),b}},isExist:function(a){return $("body").find(a.element).length>0},preloadImages:function(a,b){function c(){d++,d>=a.length&&b()}var d=0,e=[];BI.each(a,function(a,b){e[a]=new Image,e[a].src=b,e[a].onload=function(){c()},e[a].onerror=function(){c()}})},isColor:function(a){return a&&(this.isRGBColor(a)||this.isHexColor(a))},isRGBColor:function(a){return!!a&&"rgb"===a.substr(0,3)},isHexColor:function(a){return!!a&&("#"===a[0]&&7===a.length)},isDarkColor:function(a){if(!a||!this.isHexColor(a))return!1;var b=this.rgb2json(this.hex2rgb(a)),c=Math.round(.299*b.r+.587*b.g+.114*b.b);return c<192},getContrastColor:function(a){return a&&this.isColor(a)?this.isDarkColor(a)?"#ffffff":"#1a1a1a":""},rgb2hex:function(a){if(!a||"rgb"!=a.substr(0,3))return"";var b=a.match(/\d+(\.\d+)?/g),c=BI.parseInt(b[0]),d=BI.parseInt(b[1]),e=BI.parseInt(b[2]),f="#"+this.int2hex(c)+this.int2hex(d)+this.int2hex(e);return f},rgb2json:function(a){if(!a)return{};if(!this.isRGBColor(a))return{};var b=a.match(/\d+(\.\d+)?/g);return{r:BI.parseInt(b[0]),g:BI.parseInt(b[1]),b:BI.parseInt(b[2])}},rgba2json:function(a){if(!a)return{};var b=a.match(/\d+(\.\d+)?/g);return{r:BI.parseInt(b[0]),g:BI.parseInt(b[1]),b:BI.parseInt(b[2]),a:BI.parseFloat(b[3])}},json2rgb:function(a){return BI.isKey(a.r)&&BI.isKey(a.g)&&BI.isKey(a.b)?"rgb("+a.r+","+a.g+","+a.b+")":""},json2rgba:function(a){return BI.isKey(a.r)&&BI.isKey(a.g)&&BI.isKey(a.b)?"rgba("+a.r+","+a.g+","+a.b+","+a.a+")":""},int2hex:function(a){var b=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return b[a>>>4]+""+b[15&a]},hex2rgb:function(a){if(!a)return"";if(!this.isHexColor(a))return a;var b,c="rgb(";return 7===a.length?b=[BI.parseInt("0x"+a.substring(1,3)),BI.parseInt("0x"+a.substring(3,5)),BI.parseInt("0x"+a.substring(5,7))]:4===a.length&&(b=[BI.parseInt("0x"+a.substring(1,2)),BI.parseInt("0x"+a.substring(2,3)),BI.parseInt("0x"+a.substring(3,4))]),c+=b[0]+",",c+=b[1]+",",c+=b[2]+")"},rgba2rgb:function(a,b){if(BI.isNull(b)&&(b=1),"rgba"!=a.substr(0,4))return"";var c=a.match(/\d+(\.\d+)?/g);if(c.length<4)return"";var d=BI.parseFloat(c[0]),e=BI.parseFloat(c[1]),f=BI.parseFloat(c[2]),g=BI.parseFloat(c[3]);return"rgb("+Math.floor(255*(b*(1-g))+d*g)+","+Math.floor(255*(b*(1-g))+e*g)+","+Math.floor(255*(b*(1-g))+f*g)+")"},getTextSizeWidth:function(a,b){var c=$("").addClass("text-width-span").appendTo($("body"));null==b&&(b=12),b+="px",c.css("font-size",b).text(a);var d=c.width();return c.remove(),d},getScrollWidth:function(){if(null==this._scrollWidth){var a=$("
").width(50).height(50).css({position:"absolute",top:"-9999px",overflow:"scroll"}).appendTo($("body"));this._scrollWidth=a[0].offsetWidth-a[0].clientWidth,a.destroy()}return this._scrollWidth}}),BI.ShowListener=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.ShowListener.superclass._defaultConfig.apply(this,arguments),{eventObj:BI.createWidget(),cardLayout:null,cardNameCreator:function(a){return a},cardCreator:BI.emptyFn,afterCardCreated:BI.emptyFn,afterCardShow:BI.emptyFn})},_init:function(){BI.ShowListener.superclass._init.apply(this,arguments);var a=this,b=this.options;b.eventObj.on(BI.Controller.EVENT_CHANGE,function(c,d,e){if(c===BI.Events.CLICK){if(d=d||b.eventObj.getValue(),d=BI.isArray(d)?d.length>1?d.toString():d[0]:d,BI.isNull(d))throw new Error("value cannot be null");var f=b.cardNameCreator(d);if(!b.cardLayout.isCardExisted(f)){var g=b.cardCreator(f);b.cardLayout.addCardByName(f,g),b.afterCardCreated(f)}b.cardLayout.showCardByName(f),BI.nextTick(function(){b.afterCardShow(f),a.fireEvent(BI.ShowListener.EVENT_CHANGE,f)})}})}}),BI.ShowListener.EVENT_CHANGE="ShowListener.EVENT_CHANGE",BI.StyleLoaderManager=BI.inherit(BI.OB,{_defaultConfig:function(){return BI.extend(BI.StyleLoaderManager.superclass._defaultConfig.apply(this,arguments),{})},_init:function(){BI.StyleLoaderManager.superclass._init.apply(this,arguments),this.stylesManager={}},loadStyle:function(a,b){var c=document,d=c.createElement("style");return c.getElementsByTagName("head")[0].appendChild(d),d.setAttribute("type","text/css"),d.styleSheet?d.styleSheet.cssText=b:d.appendChild(document.createTextNode(b)),this.stylesManager[a]=d,this},get:function(a){return this.stylesManager[a]},has:function(a){return null!=this.stylesManager[a]},removeStyle:function(a){return this.has(a)?(this.stylesManager[a].parentNode.removeChild(this.stylesManager[a]),delete this.stylesManager[a],this):this}}),BI.Logic=BI.inherit(BI.OB,{createLogic:function(){return this.options||{}}}),BI.LogicFactory={Type:{Vertical:"vertical",Horizontal:"horizontal",Table:"table",HorizontalFill:"horizontal_fill"},createLogic:function(a,b){var c;switch(a){case BI.LogicFactory.Type.Vertical:c=BI.VerticalLayoutLogic;break;case BI.LogicFactory.Type.Horizontal:c=BI.HorizontalLayoutLogic;break;case BI.LogicFactory.Type.Table:c=BI.TableLayoutLogic;break;case BI.LogicFactory.Type.HorizontalFill:c=BI.HorizontalFillLayoutLogic;break;default:c=BI.Logic}return new c(b).createLogic()},createLogicTypeByDirection:function(a){switch(a){case BI.Direction.Top:case BI.Direction.Bottom:case BI.Direction.Custom:return BI.LogicFactory.Type.Vertical;case BI.Direction.Left:case BI.Direction.Right:return BI.LogicFactory.Type.Horizontal}},createLogicItemsByDirection:function(a){var b,c=Array.prototype.slice.call(arguments,1);switch(c=BI.map(c,function(a,b){return BI.isWidget(b)?{el:b,width:b.options.width,height:b.options.height}:b}),a){case BI.Direction.Bottom:b=BI.LogicFactory.Type.Vertical,c.reverse();break;case BI.Direction.Right:b=BI.LogicFactory.Type.Horizontal,c.reverse();break;case BI.Direction.Custom:c=c.slice(1)}return c}},BI.VerticalLayoutLogic=BI.inherit(BI.Logic,{_defaultConfig:function(){return BI.extend(BI.VerticalLayoutLogic.superclass._defaultConfig.apply(this,arguments),{dynamic:!1,scrollable:null,scrolly:!1,scrollx:!1,items:[],hgap:0,vgap:0,lgap:0,rgap:0,tgap:0,bgap:0})},createLogic:function(){var a,b=this.options;return a=b.dynamic?"bi.vertical":"bi.vtape",{type:a,scrollable:b.scrollable,scrolly:b.scrolly,scrollx:b.scrollx,hgap:b.hgap,vgap:b.vgap,lgap:b.lgap,rgap:b.rgap,tgap:b.tgap,bgap:b.bgap,items:b.items}},_init:function(){BI.VerticalLayoutLogic.superclass._init.apply(this,arguments)}}),BI.HorizontalLayoutLogic=BI.inherit(BI.Logic,{_defaultConfig:function(){return BI.extend(BI.HorizontalLayoutLogic.superclass._defaultConfig.apply(this,arguments),{dynamic:!1,scrollable:null,scrolly:!1,scrollx:!1,items:[],hgap:0,vgap:0,lgap:0,rgap:0,tgap:0,bgap:0})},createLogic:function(){var a,b=this.options;return a=b.dynamic?"bi.vertical_adapt":"bi.htape",{type:a,scrollable:b.scrollable,scrolly:b.scrolly,scrollx:b.scrollx,hgap:b.hgap,vgap:b.vgap,lgap:b.lgap,rgap:b.rgap,tgap:b.tgap,bgap:b.bgap,items:b.items}},_init:function(){BI.HorizontalLayoutLogic.superclass._init.apply(this,arguments)}}),BI.TableLayoutLogic=BI.inherit(BI.Logic,{_defaultConfig:function(){return BI.extend(BI.TableLayoutLogic.superclass._defaultConfig.apply(this,arguments),{dynamic:!1,scrollable:null,scrolly:!1,scrollx:!1,columns:0,rows:0,columnSize:[],rowSize:[],hgap:0,vgap:0,items:[]})},createLogic:function(){var a,b=this.options;return a=b.dynamic?"bi.table":"bi.window",{type:a,scrollable:b.scrollable,scrolly:b.scrolly,scrollx:b.scrollx,columns:b.columns,rows:b.rows,columnSize:b.columnSize,rowSize:b.rowSize,hgap:b.hgap,vgap:b.vgap,items:b.items}},_init:function(){BI.TableLayoutLogic.superclass._init.apply(this,arguments)}}),BI.HorizontalFillLayoutLogic=BI.inherit(BI.Logic,{_defaultConfig:function(){return BI.extend(BI.HorizontalFillLayoutLogic.superclass._defaultConfig.apply(this,arguments),{dynamic:!1,scrollable:null,scrolly:!1,scrollx:!1,items:[],hgap:0,vgap:0,lgap:0,rgap:0,tgap:0,bgap:0})},createLogic:function(){var a,b=this.options,c=[];return BI.each(b.items,function(a,b){c.push(b.width||0)}),a=b.dynamic?"bi.horizontal_adapt":"bi.htape",{type:a,columnSize:c,scrollable:b.scrollable,scrolly:b.scrolly,scrollx:b.scrollx,hgap:b.hgap,vgap:b.vgap,lgap:b.lgap,rgap:b.rgap,tgap:b.tgap,bgap:b.bgap,items:b.items}},_init:function(){BI.HorizontalFillLayoutLogic.superclass._init.apply(this,arguments)}}),BI.Plugin=BI.Plugin||{},function(){var a={},b={};BI.extend(BI.Plugin,{getWidget:function(b,c){if(a[b])for(var d,e=a[b].length-1;e>=0;e--)if(d=a[b][e](c))return d;return c},registerWidget:function(b,c){a[b]||(a[b]=[]),a[b].length>0&&console.log("组件已经注册过了!"),a[b].push(c)},relieveWidget:function(b){delete a[b]},getObject:function(a,c){if(b[a])for(var d,e=0,f=b[a].length;e0&&console.log("对象已经注册过了!"),b[a].push(c)},relieveObject:function(a){delete b[a]}})}(),$.extend(Array.prototype,{contains:function(a){return this.indexOf(a)>-1},remove:function(a){var b=this.indexOf(a);return b!==-1&&this.splice(b,1),this},pushArray:function(a){for(var b=0;b=0;a--){var b=localStorage.key(a);b&&0===b.indexOf(BI.Cache._getKeyPrefix())&&localStorage.removeItem(b)}},keys:function(){for(var a=[],b=localStorage.length;b>=0;b--){var c=localStorage.key(b);if(c){var d=BI.Cache._getKeyPrefix();0===c.indexOf(d)&&(a[a.length]=c.substring(d.length))}}return a},addCookie:function(a,b,c,d){var e=a+"="+escape(b);if(d&&d>0){var f=new Date;f.setTime(f.getTime()+3600*d*1e3),e=e+"; expires="+f.toGMTString()}c&&(e=e+"; path="+c),document.cookie=e},getCookie:function(a){var b,c=new RegExp("(^| )"+a+"=([^;]*)(;|$)");return(b=document.cookie.match(c))?unescape(b[2]):null},deleteCookie:function(a,b){var c=new Date;c.setTime(c.getTime()-1e4);var d=a+"=v; expires="+c.toGMTString();b&&(d=d+"; path="+b),document.cookie=d}},Date._DN=[BI.i18nText("BI-Basic_Sunday"),BI.i18nText("BI-Basic_Monday"),BI.i18nText("BI-Basic_Tuesday"),BI.i18nText("BI-Basic_Wednesday"),BI.i18nText("BI-Basic_Thursday"),BI.i18nText("BI-Basic_Friday"),BI.i18nText("BI-Basic_Saturday"),BI.i18nText("BI-Basic_Sunday")],Date._SDN=[BI.i18nText("BI-Basic_Simple_Sunday"),BI.i18nText("BI-Basic_Simple_Monday"),BI.i18nText("BI-Basic_Simple_Tuesday"),BI.i18nText("BI-Basic_Simple_Wednesday"),BI.i18nText("BI-Basic_Simple_Thursday"),BI.i18nText("BI-Basic_Simple_Friday"),BI.i18nText("BI-Basic_Simple_Saturday"),BI.i18nText("BI-Basic_Simple_Sunday")],Date._FD=1,Date._MN=[BI.i18nText("BI-Basic_January"),BI.i18nText("BI-Basic_February"),BI.i18nText("BI-Basic_March"),BI.i18nText("BI-Basic_April"),BI.i18nText("BI-Basic_May"),BI.i18nText("BI-Basic_June"),BI.i18nText("BI-Basic_July"),BI.i18nText("BI-Basic_August"),BI.i18nText("BI-Basic_September"),BI.i18nText("BI-Basic_October"),BI.i18nText("BI-Basic_November"),BI.i18nText("BI-Basic_December")],Date._SMN=[0,1,2,3,4,5,6,7,8,9,10,11],Date._QN=["",BI.i18nText("BI-Quarter_1"),BI.i18nText("BI-Quarter_2"),BI.i18nText("BI-Quarter_3"),BI.i18nText("BI-Quarter_4")],Date._MD=[31,28,31,30,31,30,31,31,30,31,30,31],Date.SECOND=1e3,Date.MINUTE=60*Date.SECOND,Date.HOUR=60*Date.MINUTE,Date.DAY=24*Date.HOUR,Date.WEEK=7*Date.DAY,Date.prototype.getTimezone=function(){return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/,"$1$2").replace(/[^A-Z]/g,"")},Date.prototype.getMonthDays=function(a){var b=this.getFullYear();return"undefined"==typeof a&&(a=this.getMonth()),0!=b%4||0==b%100&&0!=b%400||1!=a?Date._MD[a]:29},Date.prototype.getLastDateOfMonth=function(){return new Date(this.getFullYear(),this.getMonth(),this.getMonthDays())},Date.prototype.getDayOfYear=function(){var a=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=new Date(this.getFullYear(),0,0,0,0,0),c=a-b;return Math.floor(c/Date.DAY)},Date.prototype.getWeekNumber=function(){var a=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=a.getDay();if(0===this.getMonth()&&this.getDate()<=b)return 1;a.setDate(this.getDate()-b);var c=a.valueOf();a.setMonth(0),a.setDate(1);var d=Math.floor((c-a.valueOf())/6048e5)+1;return a.getDay()>0&&d++,d},Date.prototype.getOffsetDate=function(a){return new Date(this.getTime()+864e5*a)},Date.prototype.getAfterMulQuarter=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()+3*a),b},Date.prototype.getBeforeMulQuarter=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()-3*a),b},Date.prototype.getQuarterStartMonth=function(){var a=0,b=this.getMonth();return b<3&&(a=0),28&&(a=9),a},Date.prototype.getQuarterStartDate=function(){return new Date(this.getFullYear(),this.getQuarterStartMonth(),1)},Date.prototype.getQuarterEndDate=function(){var a=this.getQuarterStartMonth()+2;return new Date(this.getFullYear(),a,this.getMonthDays(a))},Date.prototype.getAfterMultiMonth=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()+a|0),b},Date.prototype.getBeforeMultiMonth=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()-a|0),b},Date.prototype.getAfterMulQuarter=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()+3*a),b},Date.prototype.getBeforeMulQuarter=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()-3*a),b},Date.prototype.getQuarterStartMonth=function(){var a=0,b=this.getMonth();return b<3&&(a=0),28&&(a=9),a},Date.prototype.getOffsetMonth=function(a){var b=new Date(this.getTime()),c=b.getDate(),d=new Date(b.getFullYear(),b.getMonth()+parseInt(a),1).getMonthDays();return c>d&&(c=d),b.setDate(c),b.setMonth(b.getMonth()+parseInt(a)),b},Date.prototype.getWeekStartDate=function(){var a=this.getDay();return this.getOffsetDate(-a)},Date.prototype.getWeekEndDate=function(){var a=this.getDay(),b=0===a?6:6-a;return this.getOffsetDate(b)},Date.prototype.getQuarterStartDate=function(){return new Date(this.getFullYear(),this.getQuarterStartMonth(),1)},Date.prototype.getQuarterEndDate=function(){var a=this.getQuarterStartMonth()+2;return new Date(this.getFullYear(),a,this.getMonthDays(a))},Date.prototype.getAfterMultiMonth=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()+a|0),b},Date.prototype.getBeforeMultiMonth=function(a){var b=new Date(this.getTime());return b.setMonth(b.getMonth()-a|0),b},Date.prototype.equalsTo=function(a){return this.getFullYear()==a.getFullYear()&&this.getMonth()==a.getMonth()&&this.getDate()==a.getDate()&&this.getHours()==a.getHours()&&this.getMinutes()==a.getMinutes()&&this.getSeconds()==a.getSeconds()},Date.prototype.setDateOnly=function(a){var b=new Date(a);this.setDate(1),this.setFullYear(b.getFullYear()),this.setMonth(b.getMonth()),this.setDate(b.getDate())},Date.prototype.print=function(a){var b=this.getMonth(),c=this.getDate(),d=this.getFullYear(),e=this.getWeekNumber(),f=this.getDay(),g={},h=this.getHours(),i=h>=12,j=i?h-12:h,k=this.getDayOfYear();0==j&&(j=12);var l=this.getMinutes(),m=this.getSeconds();g["%a"]=Date._SDN[f],g["%A"]=Date._DN[f],g["%b"]=Date._SMN[b],g["%B"]=Date._MN[b],g["%C"]=1+Math.floor(d/100),g["%d"]=c<10?"0"+c:c,g["%e"]=c,g["%H"]=h<10?"0"+h:h,g["%I"]=j<10?"0"+j:j,g["%j"]=k<100?k<10?"00"+k:"0"+k:k,g["%k"]=h,g["%l"]=j,g["%X"]=b<9?"0"+(1+b):1+b,g["%x"]=b+1,g["%M"]=l<10?"0"+l:l,g["%n"]="\n",g["%p"]=i?"PM":"AM",g["%P"]=i?"pm":"am",g["%s"]=Math.floor(this.getTime()/1e3),g["%S"]=m<10?"0"+m:m,g["%t"]="\t",g["%U"]=g["%W"]=g["%V"]=e<10?"0"+e:e,g["%u"]=f+1,g["%w"]=f,g["%y"]=(""+d).substr(2,2),g["%Y"]=d,g["%%"]="%";var n=/%./g;if(!BI.isKhtml())return a.replace(n,function(a){return g[a]||a});for(var o=a.match(n),p=0;pe[0]?f=["y",1]:a>=d[0]&&a<=e[0]&&(a==d[0]&&(be[1]?f=["m",1]:b==e[1]&&c>e[2]&&(f=["d",1]))),f},Date.checkLegal=function(a){var b=a.match(/\d+/g),c=0|b[0],d=0|b[1],e=0|b[2];if(b.length<=1)return!0;if(b.length<=2)return d>=1&&d<=12;var f=Date._MD.slice(0);return f[1]=Date.isLeap(c)?29:28,d>=1&&d<=12&&e<=f[d-1]},Date.parseDateTime=function(a,b){var c=new Date,d=0,e=0,f=1,g=a.split(/\W+/);if("%y%x"==b.toLowerCase()||"%y%x%d"==b.toLowerCase()){var h=4,i=2;g[0]=a.substring(0,h),g[1]=a.substring(h,h+i),g[2]=a.substring(h+i,h+2*i)}var j=b.match(/%./g),k=0,l=0,m=0,n=0,o=0;for(k=0;k29?1900:2e3);break;case"%b":case"%B":for(l=0;l<12;++l)if(Date._MN[l].substr(0,g[k].length).toLowerCase()==g[k].toLowerCase()){ @@ -36,13 +36,13 @@ this},c.widgetCoords=function(a){var b,d,e=a.target||a.srcElement,f=c.wheel;if(" tgap:b.tgap,bgap:b.bgap,vgap:b.vgap,hgap:b.hgap},b.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(a){this.options.items=a.concat(this.options.items),this.button_group.prependItems.apply(this.button_group,arguments),this.check()},addItems:function(a){this.options.items=this.options.items.concat(a),this.button_group.addItems.apply(this.button_group,arguments),this.check()},removeItemAt:function(a){a=a||[],BI.removeAt(this.options.items,a),this.button_group.removeItemAt.apply(this.button_group,arguments),this.check()},populate:function(a){var b=this;this.options;return 0===arguments.length&&BI.isFunction(this.button_group.attr("itemsCreator"))?void this.button_group.attr("itemsCreator").apply(this,[{times:1},function(){if(0===arguments.length)throw new Error("参数不能为空");b.populate.apply(b,arguments)}]):(BI.ListPane.superclass.populate.apply(this,arguments),void 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(a){return this.button_group.getIndexByValue(a)},getNodeById:function(a){return this.button_group.getNodeById(a)},getNodeByValue:function(a){return this.button_group.getNodeByValue(a)}}),BI.ListPane.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.list_pane",BI.ListPane),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:!1}})},_init:function(){BI.Panel.superclass._init.apply(this,arguments);var a=this.options;BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic("vertical",BI.extend(a.logic,{items:BI.LogicFactory.createLogicItemsByDirection("top",this._createTitle(),this.options.el)}))))},_createTitle:function(){var a=this,b=this.options;return this.text=BI.createWidget({type:"bi.label",cls:"panel-title-text",text:b.title,height:30}),this.button_group=BI.createWidget({type:"bi.button_group",items:b.titleButtons,layouts:[{type:"bi.center_adapt",lgap:10}]}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.ButtonGroup.EVENT_CHANGE,function(b,c){a.fireEvent(BI.Panel.EVENT_CHANGE,b,c)}),{el:{type:"bi.left_right_vertical_adapt",cls:"panel-title bi-tips bi-border-bottom bi-background",height:30,items:{left:[this.text],right:[this.button_group]},lhgap:10,rhgap:10},height:30}},setTitle:function(a){this.text.setValue(a)}}),BI.Panel.EVENT_CHANGE="Panel.EVENT_CHANGE",BI.shortcut("bi.panel",BI.Panel),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,logic:{dynamic:!0},items:[],itemsCreator:BI.emptyFn,hasNext:BI.emptyFn,onLoaded:BI.emptyFn,toolbar:{type:"bi.multi_select_bar"},el:{type:"bi.list_pane"}})},_init:function(){BI.SelectList.superclass._init.apply(this,arguments);var a=this,b=this.options;this.toolbar=BI.createWidget(b.toolbar),this.toolbar.on(BI.Controller.EVENT_CHANGE,function(b,c,d){var e=this.isSelected();b===BI.Events.CLICK&&(a.setAllSelected(e),a.fireEvent(BI.SelectList.EVENT_CHANGE,c,d)),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.list=BI.createWidget(b.el,{type:"bi.list_pane",items:b.items,itemsCreator:function(c,d){1===c.times&&a.toolbar.setVisible(!1),b.itemsCreator(c,function(b){d.apply(a,arguments),1===c.times&&(a.toolbar.setVisible(b&&b.length>0),a.toolbar.setEnable(b&&b.length>0)),a._checkAllSelected()})},onLoaded:b.onLoaded,hasNext:b.hasNext}),this.list.on(BI.Controller.EVENT_CHANGE,function(b,c,d){b===BI.Events.CLICK&&(a._checkAllSelected(),a.fireEvent(BI.SelectList.EVENT_CHANGE,c,d)),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(b.direction),BI.extend({scrolly:!0},b.logic,{items:BI.LogicFactory.createLogicItemsByDirection(b.direction,this.toolbar,this.list)})))),b.items.length<=0&&(this.toolbar.setVisible(!1),this.toolbar.setEnable(!1))},_checkAllSelected:function(){var a=this.list.getValue().length,b=this.getAllLeaves().length-a,c=this.list.hasNext(),d=this.toolbar.isSelected(),e=a>0&&(b>0||!d&&c);e=e||b>0&&c&&d,this.toolbar.setHalfSelected(e),!e&&this.toolbar.setSelected(a>0&&b<=0&&(!c||d))},setAllSelected:function(a){BI.each(this.getAllButtons(),function(b,c){(c.setSelected||c.setAllSelected).apply(c,[a])}),this.toolbar.setSelected(a),this.toolbar.setHalfSelected(!1)},setToolBarVisible:function(a){this.toolbar.setVisible(a)},isAllSelected:function(){return this.toolbar.isSelected()},hasPrev:function(){return this.list.hasPrev()},hasNext:function(){return this.list.hasNext()},prependItems:function(a){this.list.prependItems.apply(this.list,arguments)},addItems:function(a){this.list.addItems.apply(this.list,arguments)},setValue:function(a){var b=a.type===BI.ButtonGroup.CHOOSE_TYPE_ALL;this.setAllSelected(b),this.list[b?"setNotSelectedValue":"setValue"](a.value),this._checkAllSelected()},getValue:function(){return this.isAllSelected()===!1?{type:BI.ButtonGroup.CHOOSE_TYPE_MULTI,value:this.list.getValue(),assist:this.list.getNotSelectedValue()}:{type:BI.ButtonGroup.CHOOSE_TYPE_ALL,value:this.list.getNotSelectedValue(),assist:this.list.getValue()}},empty:function(){this.list.empty()},populate:function(a){this.toolbar.setVisible(!BI.isEmptyArray(a)),this.toolbar.setEnable(!BI.isEmptyArray(a)),this.list.populate.apply(this.list,arguments),this._checkAllSelected()},_setEnable:function(a){BI.SelectList.superclass._setEnable.apply(this,arguments),this.toolbar.setEnable(a)},resetHeight:function(a){var b=(this.toolbar.element.outerHeight()||25)*(this.toolbar.isVisible()?1:0);this.list.resetHeight?this.list.resetHeight(a-b):this.list.element.css({"max-height":a-b+"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(a){return this.list.getIndexByValue(a)},getNodeById:function(a){return this.list.getNodeById(a)},getNodeByValue:function(a){return this.list.getNodeByValue(a)}}),BI.SelectList.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.select_list",BI.SelectList),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 a=this,b=this.options;BI.LazyLoader.superclass._init.apply(this,arguments);var c=b.items.length;this.loader=BI.createWidget({type:"bi.loader",element:this,el:b.el,itemsCreator:function(b,c){c(a._getNextItems(b))},hasNext:function(a){return a.count=1)},setValue:function(a){this.pager.setValue(a)},setVPage:function(a){this.pager.setValue(a)},setCount:function(a){this.rowCount.setText(a),this.rowCount.setTitle(a)},getCurrentPage:function(){return this.pager.getCurrentPage()},hasPrev:function(){return this.pager.hasPrev()},hasNext:function(){return this.pager.hasNext()},setPagerVisible:function(a){this.editor.setVisible(a),this.allPages.setVisible(a),this.pager.setVisible(a)},populate:function(){this.pager.populate()}}),BI.AllCountPager.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.all_count_pager",BI.AllCountPager),BI.DirectionPager=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DirectionPager.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-direction-pager",height:30,horizontal:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn},vertical:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn}})},_init:function(){BI.DirectionPager.superclass._init.apply(this,arguments);var a=this.options;a.vertical,a.horizontal;this._createVPager(),this._createHPager(),this.layout=BI.createWidget({type:"bi.absolute",scrollable:!1,element:this,items:[{el:this.vpager,top:5,right:74},{el:this.vlabel,top:5,right:111},{el:this.hpager,top:5,right:-9},{el:this.hlabel,top:5,right:28}]})},_createVPager:function(){var a=this,b=this.options,c=b.vertical;this.vlabel=BI.createWidget({type:"bi.label",width:24,height:20,value:c.curr,title:c.curr,invisible:!0}),this.vpager=BI.createWidget({type:"bi.pager",width:76,layouts:[{type:"bi.horizontal",scrollx:!1,rgap:24,vgap:1}],invisible:!0,dynamicShow:!1,pages:c.pages,curr:c.curr,groups:0,first:!1,last:!1,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:c.hasPrev,hasNext:c.hasNext,firstPage:c.firstPage,lastPage:c.lastPage}),this.vpager.on(BI.Pager.EVENT_CHANGE,function(){a.fireEvent(BI.DirectionPager.EVENT_CHANGE)}),this.vpager.on(BI.Pager.EVENT_AFTER_POPULATE,function(){a.vlabel.setValue(this.getCurrentPage()),a.vlabel.setTitle(this.getCurrentPage())})},_createHPager:function(){var a=this,b=this.options,c=b.horizontal;this.hlabel=BI.createWidget({type:"bi.label",width:24,height:20,value:c.curr,title:c.curr,invisible:!0}),this.hpager=BI.createWidget({type:"bi.pager",width:76,layouts:[{type:"bi.horizontal",scrollx:!1,rgap:24,vgap:1}],invisible:!0,dynamicShow:!1,pages:c.pages,curr:c.curr,groups:0,first:!1,last:!1,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:c.hasPrev,hasNext:c.hasNext,firstPage:c.firstPage,lastPage:c.lastPage}),this.hpager.on(BI.Pager.EVENT_CHANGE,function(){a.fireEvent(BI.DirectionPager.EVENT_CHANGE)}),this.hpager.on(BI.Pager.EVENT_AFTER_POPULATE,function(){a.hlabel.setValue(this.getCurrentPage()),a.hlabel.setTitle(this.getCurrentPage())})},getVPage:function(){return this.vpager.getCurrentPage()},getHPage:function(){return this.hpager.getCurrentPage()},setVPage:function(a){this.vpager.setValue(a),this.vlabel.setValue(a),this.vlabel.setTitle(a)},setHPage:function(a){this.hpager.setValue(a),this.hlabel.setValue(a),this.hlabel.setTitle(a)},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(a){this.hpager.setVisible(a),this.hlabel.setVisible(a)},setVPagerVisible:function(a){this.vpager.setVisible(a),this.vlabel.setVisible(a)},populate:function(){this.vpager.populate(),this.hpager.populate();var a=!1,b=!1;this.hasHNext()||this.hasHPrev()?(this.setHPagerVisible(!0),b=!0):this.setHPagerVisible(!1),this.hasVNext()||this.hasVPrev()?(this.setVPagerVisible(!0),a=!0):this.setVPagerVisible(!1),this.setVisible(b||a);var c=[74,111,-9,28],d=this.layout.attr("items");a===!0&&b===!0?(d[0].right=c[0],d[1].right=c[1],d[2].right=c[2],d[3].right=c[3]):a===!0?(d[0].right=c[2],d[1].right=c[3]):b===!0&&(d[2].right=c[2],d[3].right=c[3]),this.layout.attr("items",d),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),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:!0,dynamicShowFirstLast:!1,dynamicShowPrevNext:!1,pages:!1,curr:function(){return 1},groups:0,jump:BI.emptyFn,first:!1,last:!1,prev:"上一页",next:"下一页",firstPage:1,lastPage:function(){return 1},hasPrev:BI.emptyFn,hasNext:BI.emptyFn})},_init:function(){BI.DetailPager.superclass._init.apply(this,arguments);var a=this;this.currPage=BI.result(this.options,"curr"),this._lock=!1,this._debouce=BI.debounce(function(){a._lock=!1},300),this._populate()},_populate:function(){var a=this,b=this.options,c=[],d={};this.empty();var e=BI.result(b,"pages"),f=BI.result(this,"currPage"),g=BI.result(b,"groups"),h=BI.result(b,"first"),i=BI.result(b,"last"),j=BI.result(b,"prev"),k=BI.result(b,"next");e===!1?(g=0,h=!1,i=!1):g>e&&(g=e),d.index=Math.ceil((f+(g>1&&g!==e?1:0))/(0===g?1:g)),(!b.dynamicShow&&!b.dynamicShowPrevNext||f>1)&&j!==!1&&(BI.isKey(j)?c.push({text:j,value:"prev",disabled:e===!1?b.hasPrev(f)===!1:!(f>1&&j!==!1)}):c.push(BI.extend({disabled:e===!1?b.hasPrev(f)===!1:!(f>1&&j!==!1)},j))),(!b.dynamicShow&&!b.dynamicShowFirstLast||d.index>1&&0!==g)&&h&&(c.push({text:h,value:"first",disabled:!(d.index>1&&0!==g)}),d.index>1&&0!==g&&c.push({type:"bi.label",cls:"page-ellipsis",text:"…"})),d.poor=Math.floor((g-1)/2),d.start=d.index>1?f-d.poor:1,d.end=d.index>1?function(){var a=f+(g-d.poor-1);return a>e?e:a}():g,d.end-d.start1&&0!==g&&e>g&&d.endg&&d.endg&&d.endg&&d.end1},hasNext:function(a){a||(a=1);var b=this.options,c=this.options.pages;return c===!1?b.hasNext(a):ac?c:(d=BI.result(b,"firstPage"),ab.pages?b.pages:a,this.currPage=a;this._populate()},getValue:function(){var a=this.button_group.getValue()[0];switch(a){case"prev":return-1;case"next":return 1;case"first":return BI.MIN;case"last":return BI.MAX;default:return a}},attr:function(a,b){BI.DetailPager.superclass.attr.apply(this,arguments),"curr"===a&&(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),BI.SegmentButton=BI.inherit(BI.BasicButton,{_defaultConfig:function(){var a=BI.SegmentButton.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-segment-button bi-list-item-active",shadow:!0,readonly:!0,hgap:5})},_init:function(){BI.SegmentButton.superclass._init.apply(this,arguments);var a=this.options;this.text=BI.createWidget({type:"bi.label",element:this,height:a.height-2,whiteSpace:a.whiteSpace,text:a.text,value:a.value,hgap:a.hgap})},setSelected:function(){BI.SegmentButton.superclass.setSelected.apply(this,arguments)},setText:function(a){BI.SegmentButton.superclass.setText.apply(this,arguments),this.text.setText(a)},destroy:function(){BI.SegmentButton.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.segment_button",BI.SegmentButton),BI.Segment=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.Segment.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-segment",items:[],height:30})},_init:function(){BI.Segment.superclass._init.apply(this,arguments);var a=this,b=this.options;this.buttonGroup=BI.createWidget({element:this,type:"bi.button_group",items:BI.createItems(b.items,{type:"bi.segment_button",height:b.height-2,whiteSpace:b.whiteSpace}),layout:[{type:"bi.center"}]}),this.buttonGroup.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.buttonGroup.on(BI.ButtonGroup.EVENT_CHANGE,function(b,c){a.fireEvent(BI.Segment.EVENT_CHANGE,b,c)})},setValue:function(a){this.buttonGroup.setValue(a)},setEnabledValue:function(a){this.buttonGroup.setEnabledValue(a)},getValue:function(){return this.buttonGroup.getValue()}}),BI.Segment.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.segment",BI.Segment),BI.AdaptiveTable=BI.inherit(BI.Widget,{_const:{perColumnSize:100},_defaultConfig:function(){return BI.extend(BI.AdaptiveTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-adaptive-table",el:{type:"bi.resizable_table"},isNeedResize:!0,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],header:[],items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.AdaptiveTable.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._digest();this.table=BI.createWidget(b.el,{type:"bi.resizable_table",element:this,width:b.width,height:b.height,isNeedResize:b.isNeedResize,isResizeAdapt:!1,isNeedFreeze:b.isNeedFreeze,freezeCols:c.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:c.columnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:c.regionColumnSize,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),a._populate(),a.table.populate(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.columnSize=this.getColumnSize(),a._populate(),a.table.populate(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)})},_getFreezeColLength:function(){return this.options.isNeedFreeze===!0?this.options.freezeCols.length:0},_digest:function(){var a=this.options,b=a.columnSize.slice(),c=a.regionColumnSize.slice(),d=a.freezeCols.slice(),e=a.regionColumnSize[0],f=this._getFreezeColLength();(!e||e>a.width-10||e<10)&&(e=(f>a.columnSize.length/2?2/3:1/3)*a.width),0===f&&(e=0),d.length>=b.length&&(d=[]),BI.isNumber(b[0])||(b=a.minColumnSize.slice());var g=0,h=0;return BI.each(b,function(a,b){a0&&(b[f-1]=BI.clamp(e-(g-b[f-1]),a.minColumnSize[f-1]||10,a.maxColumnSize[f-1]||Number.MAX_VALUE)),b.length>0&&(b[b.length-1]=BI.clamp(a.width-BI.GridTableScrollbar.SIZE-e-(h-g-b[b.length-1]),a.minColumnSize[b.length-1]||10,a.maxColumnSize[b.length-1]||Number.MAX_VALUE)),c[0]=e,{freezeCols:d,columnSize:b,regionColumnSize:c}},_populate:function(){var a=this.options,b=this._digest();a.regionColumnSize=b.regionColumnSize,a.columnSize=b.columnSize,this.table.setColumnSize(b.columnSize),this.table.setRegionColumnSize(b.regionColumnSize),this.table.attr("freezeCols",b.freezeCols)},setWidth:function(a){BI.AdaptiveTable.superclass.setWidth.apply(this,arguments),this.table.setWidth(a)},setHeight:function(a){BI.AdaptiveTable.superclass.setHeight.apply(this,arguments),this.table.setHeight(a)},setColumnSize:function(a){this.options.columnSize=a},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.regionColumnSize=a},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},attr:function(a,b){var c=BI.AdaptiveTable.superclass.attr.apply(this,arguments); return"freezeCols"===a?c:this.table.attr.apply(this.table,arguments)},restore:function(){this.table.restore()},populate:function(a){this.options;this._populate(),this.table.populate.apply(this.table,arguments)},destroy:function(){this.table.destroy(),BI.AdaptiveTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.adaptive_table",BI.AdaptiveTable),BI.DynamicSummaryLayerTreeTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DynamicSummaryLayerTreeTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-dynamic-summary-layer-tree-table",el:{type:"bi.resizable_table"},isNeedResize:!0,isResizeAdapt:!0,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!0,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,footerRowSize:25,rowSize:25,regionColumnSize:[],rowHeaderCreator:null,headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],footer:!1,items:[],crossHeader:[],crossItems:[]})},_getVDeep:function(){return this.options.crossHeader.length},_getHDeep:function(){var a=this.options;return Math.max(a.mergeCols.length,a.freezeCols.length,BI.TableTree.maxDeep(a.items)-1)},_createHeader:function(a){var b=this.options,c=b.header||[],d=b.crossHeader||[],e=BI.TableTree.formatCrossItems(b.crossItems,a,b.headerCellStyleGetter),f=[];if(BI.each(e,function(a,b){var c=[d[a]];f.push(c.concat(b||[]))}),c&&c.length>0){var g=this._formatColumns(c),h=this._getHDeep();h<=0?g.unshift(b.rowHeaderCreator||{type:"bi.table_style_cell",text:BI.i18nText("BI-Row_Header"),styleGetter:b.headerCellStyleGetter}):g[0]=b.rowHeaderCreator||{type:"bi.table_style_cell",text:BI.i18nText("BI-Row_Header"),styleGetter:b.headerCellStyleGetter},f.push(g)}return f},_formatItems:function(a,b,c){function d(a,b){a.type||(a.type="bi.layer_tree_table_cell"),a.layer=b;var c=[a];c=c.concat(a.values||[]),c.length>0&&f.push(c),BI.isNotEmptyArray(a.children)&&BI.each(a.children,function(a,c){d(c,b+1)})}var e=this.options,f=[];return BI.each(a,function(a,b){if(BI.each(b.children,function(a,b){d(b,0)}),BI.isArray(b.values)){var c=[{type:"bi.table_style_cell",text:BI.i18nText("BI-Summary_Values"),styleGetter:function(){return e.summaryCellStyleGetter(!0)}}].concat(b.values);f.push(c)}}),BI.DynamicSummaryTreeTable.formatSummaryItems(f,b,e.crossItems,1)},_formatColumns:function(a,b){return BI.isNotEmptyArray(a)?(b=b||this._getHDeep(),a.slice(Math.max(0,b-1))):a},_formatFreezeCols:function(){return this.options.freezeCols.length>0?[0]:[]},_formatColumnSize:function(a,b){if(a.length<=0)return[];var c=[0];return b=b||this._getHDeep(),BI.each(a,function(a,d){return a1)for(var c=0;c1)&&BI.isNotEmptyArray(g.values)){for(var i={text:BI.i18nText("BI-Summary_Values"),type:"bi.table_style_cell",styleGetter:function(){return d(a===-1)}},j=h.length;j0)if(c)for(var k=0,l=g.values.length;k0&&f.push(h);h.length>0&&f.push(h)}}var f=[];return BI.each(a,function(a,b){e(-1,b)}),BI.each(f,function(a,c){for(var d=BI.last(c),e=c.length;e1?g+=a.values.length:g++}var f=[],g=0;if(BI.each(c,function(a,b){e(b)}),f.length>0){var h=[],i=[];BI.each(b,function(a,b){var c=b.slice();BI.removeAt(c,f),h.push(c)}),BI.each(a,function(a,b){var c=b.slice();BI.removeAt(c,f),i.push(c)}),b=h,a=i}return{items:a,header:b,deletedCols:f}}}),BI.shortcut("bi.dynamic_summary_tree_table",BI.DynamicSummaryTreeTable),BI.LayerTreeTableCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.LayerTreeTableCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-layer-tree-table-cell",layer:0,text:""})},_init:function(){BI.LayerTreeTableCell.superclass._init.apply(this,arguments);var a=this.options;BI.createWidget({type:"bi.label",element:this.element,textAlign:"left",whiteSpace:"nowrap",height:a.height,text:a.text,value:a.value,lgap:5+30*a.layer,rgap:5})}}),BI.shortcut("bi.layer_tree_table_cell",BI.LayerTreeTableCell),BI.LayerTreeTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.LayerTreeTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-layer-tree-table",el:{type:"bi.resizable_table"},isNeedResize:!1,isResizeAdapt:!0,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!0,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],rowHeaderCreator:null,headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[]})},_getVDeep:function(){return this.options.crossHeader.length},_getHDeep:function(){var a=this.options;return Math.max(a.mergeCols.length,a.freezeCols.length,BI.TableTree.maxDeep(a.items)-1)},_createHeader:function(a){var b=this.options,c=b.header||[],d=b.crossHeader||[],e=BI.TableTree.formatCrossItems(b.crossItems,a,b.headerCellStyleGetter),f=[];if(BI.each(e,function(a,b){var c=[d[a]];f.push(c.concat(b||[]))}),c&&c.length>0){var g=this._formatColumns(c),h=this._getHDeep();h<=0?g.unshift(b.rowHeaderCreator||{type:"bi.table_style_cell",text:BI.i18nText("BI-Row_Header"),styleGetter:b.headerCellStyleGetter}):g[0]=b.rowHeaderCreator||{type:"bi.table_style_cell",text:BI.i18nText("BI-Row_Header"),styleGetter:b.headerCellStyleGetter},f.push(g)}return f},_formatItems:function(a){function b(a,c){a.type||(a.type="bi.layer_tree_table_cell"),a.layer=c;var e=[a];e=e.concat(a.values||[]),e.length>0&&d.push(e),BI.isNotEmptyArray(a.children)&&BI.each(a.children,function(a,d){b(d,c+1)})}var c=this.options,d=[];return BI.each(a,function(a,e){if(BI.each(e.children,function(a,c){b(c,0)}),BI.isArray(e.values)){var f=[{type:"bi.table_style_cell",text:BI.i18nText("BI-Summary_Values"),styleGetter:function(){return c.summaryCellStyleGetter(!0)}}].concat(e.values);d.push(f)}}),d},_formatColumns:function(a,b){return BI.isNotEmptyArray(a)?(b=b||this._getHDeep(),a.slice(Math.max(0,b-1))):a},_formatFreezeCols:function(){return this.options.freezeCols.length>0?[0]:[]},_formatColumnSize:function(a,b){if(a.length<=0)return[];var c=[0];return b=b||this._getHDeep(),BI.each(a,function(a,d){return a0&&(c=BI.makeArray(b,a[0]/b)),c.concat(a.slice(1))},setRegionColumnSize:function(a){this.options.regionColumnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},attr:function(a,b){var c=this;if(BI.isObject(a))return void BI.each(a,function(a,b){c.attr(a,b)});switch(BI.LayerTreeTable.superclass.attr.apply(this,arguments),a){case"columnSize":case"minColumnSize":case"maxColumnSize":case"freezeCols":case"mergeCols":return}this.table.attr.apply(this.table,[a,b])},restore:function(){this.table.restore()},populate:function(a,b,c,d){var e=this.options;e.items=a||[],b&&(e.header=b),c&&(e.crossItems=c),d&&(e.crossHeader=d);var f=this._digest();this.table.setColumnSize(f.columnSize),this.table.attr("freezeCols",f.freezeCols),this.table.attr("minColumnSize",f.minColumnSize),this.table.attr("maxColumnSize",f.maxColumnSize),this.table.populate(f.items,f.header)},destroy:function(){this.table.destroy(),BI.LayerTreeTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.layer_tree_table",BI.LayerTreeTable),BI.TableStyleCell=BI.inherit(BI.Single,{_defaultConfig:function(){return BI.extend(BI.TableStyleCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-table-style-cell",styleGetter:BI.emptyFn})},_init:function(){BI.TableStyleCell.superclass._init.apply(this,arguments);var a=this.options;this.text=BI.createWidget({type:"bi.label",element:this,textAlign:"left",forceCenter:!0,hgap:5,text:a.text}),this._digestStyle()},_digestStyle:function(){var a=this.options,b=a.styleGetter();b&&this.text.element.css(b)},setText:function(a){this.text.setText(a)},populate:function(){this._digestStyle()}}),BI.shortcut("bi.table_style_cell",BI.TableStyleCell),BI.TableTree=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.TableTree.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-table-tree",el:{type:"bi.resizable_table"},isNeedResize:!0,isResizeAdapt:!0,freezeCols:[],isNeedMerge:!0,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[]})},_getVDeep:function(){return this.options.crossHeader.length},_getHDeep:function(){var a=this.options;return Math.max(a.mergeCols.length,a.freezeCols.length,BI.TableTree.maxDeep(a.items)-1)},_init:function(){BI.TableTree.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._digest();this.table=BI.createWidget(b.el,{type:"bi.resizable_table",element:this,width:b.width,height:b.height,isNeedResize:b.isNeedResize,isResizeAdapt:b.isResizeAdapt,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,minColumnSize:b.minColumnSize,maxColumnSize:b.maxColumnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,header:c.header,items:c.items}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)})},_digest:function(){var a=this.options,b=this._getHDeep(),c=this._getVDeep(),d=BI.TableTree.formatHeader(a.header,a.crossHeader,a.crossItems,b,c,a.headerCellStyleGetter),e=BI.TableTree.formatItems(a.items,b,!1,a.summaryCellStyleGetter);return{header:d,items:e}},setWidth:function(a){BI.TableTree.superclass.setWidth.apply(this,arguments),this.table.setWidth(a)},setHeight:function(a){BI.TableTree.superclass.setHeight.apply(this,arguments),this.table.setHeight(a)},setColumnSize:function(a){this.options.columnSize=a,this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.regionColumnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},attr:function(){BI.TableTree.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments)},restore:function(){this.table.restore()},populate:function(a,b,c,d){var e=this.options;a&&(e.items=a||[]),b&&(e.header=b),c&&(e.crossItems=c),d&&(e.crossHeader=d);var f=this._digest();this.table.populate(f.items,f.header)},destroy:function(){this.table.destroy(),BI.TableTree.superclass.destroy.apply(this,arguments)}}),BI.extend(BI.TableTree,{formatHeader:function(a,b,c,d,e,f){for(var g=BI.TableTree.formatCrossItems(c,e,f),h=[],i=0;i0&&h.push(a),h},formatItems:function(a,b,c,d){function e(a,g){var h;if(BI.isArray(g.children)){if(BI.each(g.children,function(b,c){var d;a!=-1?(d=a.slice(),d.push(g)):d=[],e(d,c)}),a!=-1?(h=a.slice(),h.push(g)):h=[],BI.isNotEmptyArray(g.values)){for(var i={text:BI.i18nText("BI-Summary_Values"),type:"bi.table_style_cell",styleGetter:function(){return d(a===-1)}},j=h.length;j0)if(c)for(var k=0,l=g.values.length;k0&&f.push(h);h.length>0&&f.push(h)}}var f=[];return BI.each(a,function(a,b){e(-1,b)}),BI.each(f,function(a,c){for(var d=BI.last(c),e=c.length;e0}})},_init:function(){BI.MultiSelectBar.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.checkbox",stopPropagation:!0,handler:function(){a.setSelected(a.isSelected())}}),this.half=BI.createWidget({type:"bi.half_icon_button",stopPropagation:!0,handler:function(){a.setSelected(!0)}}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,BI.Events.CLICK,a.isSelected(),a)}),this.half.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,BI.Events.CLICK,a.isSelected(),a)}),this.half.on(BI.HalfIconButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectBar.EVENT_CHANGE,a.isSelected(),a)}),this.checkbox.on(BI.Checkbox.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectBar.EVENT_CHANGE,a.isSelected(),a)}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,keyword:b.keyword,value:b.value,py:b.py}),BI.createWidget({type:"bi.htape",element:this,items:[{width:36,el:{type:"bi.center_adapt",items:[this.checkbox,this.half]}},{el:this.text}]}),this.half.invisible()},beforeClick:function(){var a=this.isHalfSelected(),b=this.isSelected();a===!0?this.setSelected(!0):this.setSelected(!b)},setSelected:function(a){this.checkbox.setSelected(a),this.setHalfSelected(!1)},setHalfSelected:function(a){this._half=!!a,a===!0?(this.half.visible(),this.checkbox.invisible()):(this.half.invisible(),this.checkbox.visible())},isHalfSelected:function(){return!!this._half},isSelected:function(){return this.checkbox.isSelected()},setValue:function(a){BI.MultiSelectBar.superclass.setValue.apply(this,arguments);var b=this.options.isAllCheckedBySelectedValue.apply(this,arguments);this.setSelected(b),!b&&this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this,arguments))}}),BI.MultiSelectBar.EVENT_CHANGE="MultiSelectBar.EVENT_CHANGE",BI.shortcut("bi.multi_select_bar",BI.MultiSelectBar),BI.BranchRelation=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-branch-relation-tree",items:[],centerOffset:0,direction:BI.Direction.Bottom,align:BI.VerticalAlign.Top})},_init:function(){BI.BranchRelation.superclass._init.apply(this,arguments),this.populate(this.options.items)},_stratification:function(){var a=[];return this.tree.recursion(function(b,c){b.leaf=b.isLeaf(),a[c.length-1]||(a[c.length-1]=[]),a[c.length-1].push(b)}),a},_calculateLeaves:function(){function a(b){var c=0;return b.isLeaf()?1:(BI.each(b.getChildren(),function(b,d){c+=a(d)}),b.set("leaves",c),c)}var b=0;return b=a(this.tree.getRoot())},_translate:function(a){var b=[],c=a.length;return BI.each(a,function(d,e){b[d]||(b[d]=[]),BI.each(e,function(f,g){if(g.isLeaf()&&d0){var j=e[f-1].getLastChild();i=a[d+1].indexOf(j)+1}a[d+1].splice(i,0,g);var k=g.parent.getChildIndex(g.id);g.parent.removeChildByIndex(k),g.parent.addChild(h,k),h.addChild(g),b[d].push(h),e[f]=h}else b[d].push(g)})}),b},_fill:function(a){var b=[],c=a.length;return BI.each(a,function(d,e){b[d]||(b[d]=[]),BI.each(e,function(f,g){if(g.isLeaf()&&d0){var j=e[f-1].getLastChild();i=a[d+1].indexOf(j)+1}a[d+1].splice(i,0,h),g.addChild(h)}b[d].push(g)})}),b},_adjust:function(a){for(;;){var b=!1;if(BI.backEach(a,function(a,c){BI.each(c,function(a,c){if(!c.isNew){var d=!0;if(BI.any(c.getChildren(),function(a,b){if(!b.isNew)return d=!1,!0}),!c.isLeaf()&&d===!0){var e=[];BI.each(c.getChildren(),function(a,b){e=e.concat(b.getChildren())}),c.removeAllChilds(),BI.each(e,function(a,b){c.addChild(b)});var f=new BI.Node(BI.UUID());f.isNew=!0;var g=c.parent.getChildIndex(c.id);c.parent.removeChildByIndex(g),c.parent.addChild(f,g),f.addChild(c),b=!0}}})}),b===!1)break;a=this._stratification()}return a},_calculateWidth:function(){function a(b){var c=0;return b.isLeaf()?b.width:(BI.each(b.getChildren(),function(b,d){c+=a(d)}),c)}function b(a){var c=0;return a.isLeaf()?a.height:(BI.each(a.getChildren(),function(a,d){c+=b(d)}),c)}var c=(this.options,0);return c=this._isVertical()?a(this.tree.getRoot()):b(this.tree.getRoot())},_isVertical:function(){var a=this.options;return a.direction===BI.Direction.Top||a.direction===BI.Direction.Bottom},_calculateHeight:function(){function a(b){var c=0;return BI.each(b.getChildren(),function(b,d){c=Math.max(c,a(d))}),c+(b.height||0)}function b(a){var c=0;return BI.each(a.getChildren(),function(a,d){c=Math.max(c,b(d))}),c+(a.width||0)}var c=(this.options,0);return c=this._isVertical()?a(this.tree.getRoot()):b(this.tree.getRoot())},_calculateXY:function(a){var b=(this.options,this._calculateWidth()),c=this._calculateHeight(),d=a.length,e=this._calculateLeaves(),f={},g=c/d;return BI.each(a,function(a,c){var d=[];BI.each(c,function(a,b){d[a]=(b.get("leaves")||1)/e}),BI.each(c,function(c,e){var h=BI.sum(d.slice(0,c)),i=h*b+d[c]*b/2,j=a*g+g/2;f[e.id]={x:i,y:j}})}),f},_stroke:function(a,b){var c=this._calculateHeight(),d=a.length,e=c/d,f=this,g=this.options;switch(g.direction){case BI.Direction.Top:BI.each(a,function(a,c){BI.each(c,function(a,c){if(c.getChildrenLength()>0&&!c.leaf){var d="",h=b[c.id],i=h.y+e/2;d+="M"+h.x+","+(h.y+g.centerOffset)+"L"+h.x+","+i;var j=[];BI.each(c.getChildren(),function(a,c){var e=j[a]=b[c.id];d+="M"+e.x+","+(e.y+g.centerOffset)+"L"+e.x+","+i}),j.length>0&&(d+="M"+BI.first(j).x+","+i+"L"+BI.last(j).x+","+i),f.svg.path(d).attr("stroke","#d4dadd")}})});break;case BI.Direction.Bottom:BI.each(a,function(a,c){BI.each(c,function(a,c){if(c.getChildrenLength()>0&&!c.leaf){var d="",h=b[c.id],i=h.y-e/2;d+="M"+h.x+","+(h.y-g.centerOffset)+"L"+h.x+","+i;var j=[];BI.each(c.getChildren(),function(a,c){var e=j[a]=b[c.id];d+="M"+e.x+","+(e.y-g.centerOffset)+"L"+e.x+","+i}),j.length>0&&(d+="M"+BI.first(j).x+","+i+"L"+BI.last(j).x+","+i),f.svg.path(d).attr("stroke","#d4dadd")}})});break;case BI.Direction.Left:BI.each(a,function(a,c){BI.each(c,function(a,c){if(c.getChildrenLength()>0&&!c.leaf){var d="",h=b[c.id],i=h.y+e/2;d+="M"+(h.y+g.centerOffset)+","+h.x+"L"+i+","+h.x;var j=[];BI.each(c.getChildren(),function(a,c){var e=j[a]=b[c.id];d+="M"+(e.y+g.centerOffset)+","+e.x+"L"+i+","+e.x}),j.length>0&&(d+="M"+i+","+BI.first(j).x+"L"+i+","+BI.last(j).x),f.svg.path(d).attr("stroke","#d4dadd")}})});break;case BI.Direction.Right:BI.each(a,function(a,c){BI.each(c,function(a,c){if(c.getChildrenLength()>0&&!c.leaf){var d="",h=b[c.id],i=h.y-e/2;d+="M"+(h.y-g.centerOffset)+","+h.x+"L"+i+","+h.x;var j=[];BI.each(c.getChildren(),function(a,c){var e=j[a]=b[c.id];d+="M"+(e.y-g.centerOffset)+","+e.x+"L"+i+","+e.x}),j.length>0&&(d+="M"+i+","+BI.first(j).x+"L"+i+","+BI.last(j).x),f.svg.path(d).attr("stroke","#d4dadd")}})})}},_createBranches:function(a){var b=this.options;b.direction!==BI.Direction.Bottom&&b.direction!==BI.Direction.Right||(a=a.reverse());var c=this._calculateXY(a);this._stroke(a,c)},_isNeedAdjust:function(){var a=this.options;return a.direction===BI.Direction.Top&&a.align===BI.VerticalAlign.Bottom||a.direction===BI.Direction.Bottom&&a.align===BI.VerticalAlign.Top||a.direction===BI.Direction.Left&&a.align===BI.HorizontalAlign.Right||a.direction===BI.Direction.Right&&a.align===BI.HorizontalAlign.Left},setValue:function(a){},getValue:function(){},_transformToTreeFormat:function(a){var b,c;if(!a)return[];if(BI.isArray(a)){var d=[],e=[];for(b=0,c=a.length;b0&&(b.text=b.value+"("+BI.i18nText("BI-Basic_Altogether")+b.count+BI.i18nText("BI-Basic_Count")+")")}),a},initTree:function(a,b){var b=b||this._configSetting();this.nodes=$.fn.zTree.init(this.tree.element,b,a)},destroy:function(){BI.DisplayTree.superclass.destroy.apply(this,arguments)}}),BI.DisplayTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.display_tree",BI.DisplayTree),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:[]})},_init:function(){BI.LevelTree.superclass._init.apply(this,arguments),this.initTree(this.options.items)},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={layer:b};if(BI.isKey(e.id)||(e.id=BI.UUID()),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.first_plus_group_node";break;case a.length-1:f.type="bi.last_plus_group_node";break;default:f.type="bi.mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children,b+1)}else{switch(d){case a.length-1:f.type="bi.last_tree_leaf_item";break;default:f.type="bi.mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_assertId:function(a){BI.each(a,function(a,b){BI.isKey(b.id)||(b.id=BI.UUID())})},initTree:function(a){var b=this,c=this.options;this.empty(),this._assertId(a),this.tree=BI.createWidget({type:"bi.custom_tree",element:this,expander:BI.extend({el:{},popup:{type:"bi.custom_tree"}},c.expander),items:this._formatItems(BI.Tree.transformToTreeFormat(a),0),el:BI.extend({type:"bi.button_tree",chooseType:0,layouts:[{type:"bi.vertical"}]},c.el)}),this.tree.on(BI.Controller.EVENT_CHANGE,function(a){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.LevelTree.EVENT_CHANGE,arguments)})},stroke:function(a){this.tree.stroke.apply(this.tree,arguments)},populate:function(a){a=this._formatItems(BI.Tree.transformToTreeFormat(a),0),this.tree.populate(a)},setValue:function(a){this.tree.setValue(a)},getValue:function(){return this.tree.getValue()},getAllLeaves:function(){return this.tree.getAllLeaves()},getNodeById:function(a){return this.tree.getNodeById(a)},getNodeByValue:function(a){return this.tree.getNodeByValue(a)}}),BI.LevelTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.level_tree",BI.LevelTree),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 a=this,b=this.options;this.structure=new BI.Tree,this.tree=BI.createWidget({type:"bi.tree_view",element:this,itemsCreator:function(c,d){var e=function(b){d({items:b}),a.structure.initTree(BI.Tree.transformToTreeFormat(b))};BI.isNotNull(b.items)?e(b.items):b.itemsCreator(c,e)}}),this.tree.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.SimpleTreeView.EVENT_CHANGE,arguments)}),BI.isNotEmptyArray(b.items)&&this.populate()},populate:function(a,b){a&&(this.options.items=a),this.tree.stroke({keyword:b})},setValue:function(a){a||(a=[]);var b=this,c={},d=[];BI.each(a,function(a,e){var f=b.structure.search(e,"value");if(f){var g=f;for(g=g.getParent(),g&&(c[g.value]||(c[g.value]=0),c[g.value]++);g&&g.getChildrenLength()<=c[g.value];)d.push(g.value),g=g.getParent(),g&&(c[g.value]||(c[g.value]=0),c[g.value]++)}}),this.tree.setValue(BI.makeObject(a.concat(d)))},_getValue:function(){var a=[],b=this.tree.getValue(),c=function(b){BI.each(b,function(b,d){BI.isEmpty(d)?a.push(b):c(d)})};return c(b),a},empty:function(){this.tree.empty()},getValue:function(){var a=this,b=[],c=this._getValue();return BI.each(c,function(c,d){var e=a.structure.search(d,"value");e&&a.structure._traverse(e,function(a){a.isLeaf()&&b.push(a.value)})}),b}}),BI.SimpleTreeView.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.simple_tree",BI.SimpleTreeView),BI.EditorTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4},_defaultConfig:function(){var a=BI.EditorTrigger.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-editor-trigger bi-border",height:30,validationChecker:BI.emptyFn,quitChecker:BI.emptyFn,allowBlank:!1,watermark:"",errorText:"",triggerWidth:30})},_init:function(){this.options.height-=2,BI.EditorTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options;this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,value:b.value,validationChecker:b.validationChecker,quitChecker:b.quitChecker,allowBlank:b.allowBlank,watermark:b.watermark,errorText:b.errorText}),this.editor.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.EditorTrigger.EVENT_CHANGE,arguments)}),BI.createWidget({element:this,type:"bi.htape",items:[{el:this.editor},{el:{type:"bi.trigger_icon_button",cls:"bi-border-left",width:b.triggerWidth},width:b.triggerWidth}]})},getValue:function(){return this.editor.getValue()},setValue:function(a){this.editor.setValue(a)},setText:function(a){this.editor.setState(a)}}),BI.EditorTrigger.EVENT_CHANGE="BI.EditorTrigger.EVENT_CHANGE",BI.shortcut("bi.editor_trigger",BI.EditorTrigger),BI.IconTrigger=BI.inherit(BI.Trigger,{_defaultConfig:function(){return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-icon-trigger",el:{},height:30})},_init:function(){var a=this.options;BI.IconTrigger.superclass._init.apply(this,arguments),this.iconButton=BI.createWidget(a.el,{type:"bi.trigger_icon_button",element:this,width:a.width,height:a.height})}}),BI.shortcut("bi.icon_trigger",BI.IconTrigger),BI.IconTextTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,triggerWidth:30},_defaultConfig:function(){var a=BI.IconTextTrigger.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-text-trigger",height:30})},_init:function(){BI.IconTextTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.text=BI.createWidget({type:"bi.label",textAlign:"left",height:b.height,text:b.text,hgap:c.hgap}),this.trigerButton=BI.createWidget({type:"bi.trigger_icon_button",cls:"bi-border-left",width:c.triggerWidth}),BI.createWidget({element:this,type:"bi.htape",items:[{el:{type:"bi.icon_change_button",cls:"icon-combo-trigger-icon "+b.iconClass,ref:function(b){a.icon=b},disableSelected:!0},width:24},{el:this.text},{el:this.trigerButton,width:c.triggerWidth}]})},setValue:function(a){this.text.setValue(a),this.text.setTitle(a)},setIcon:function(a){this.icon.setIcon(a)},setText:function(a){this.text.setText(a),this.text.setTitle(a)}}),BI.shortcut("bi.icon_text_trigger",BI.IconTextTrigger),BI.TextTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4},_defaultConfig:function(){var a=BI.TextTrigger.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-text-trigger",height:30,triggerWidth:30})},_init:function(){BI.TextTrigger.superclass._init.apply(this,arguments);var a=this.options,b=this._const;this.text=BI.createWidget({type:"bi.label",textAlign:"left",height:a.height,text:a.text,hgap:b.hgap,readonly:a.readonly}),this.trigerButton=BI.createWidget({type:"bi.trigger_icon_button",cls:"bi-border-left",width:a.triggerWidth}),BI.createWidget({element:this,type:"bi.htape",items:[{el:this.text},{el:this.trigerButton,width:a.triggerWidth}]})},setValue:function(a){this.text.setValue(a),this.text.setTitle(a)},setText:function(a){this.text.setText(a),this.text.setTitle(a)}}),BI.shortcut("bi.text_trigger",BI.TextTrigger),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",height:24})},_init:function(){this.options.height-=2,BI.SelectTextTrigger.superclass._init.apply(this,arguments);var a=this.options;this.trigger=BI.createWidget({type:"bi.text_trigger",element:this,height:a.height}),BI.isKey(a.text)&&this.setValue(a.text)},setValue:function(a){var b=this.options;a=BI.isArray(a)?a:[a];var c=[],d=BI.Tree.transformToArrayFormat(this.options.items);BI.each(d,function(b,d){BI.deepContains(a,d.value)&&!c.contains(d.text||d.value)&&c.push(d.text||d.value)}),c.length>0?this.trigger.setText(c.join(",")):this.trigger.setText(b.text)},populate:function(a){this.options.items=a}}),BI.shortcut("bi.select_text_trigger",BI.SelectTextTrigger),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 a=this.options;this.trigger=BI.createWidget({type:"bi.small_text_trigger",element:this,height:a.height-2}),BI.isKey(a.text)&&this.setValue(a.text)},setValue:function(a){var b=this.options;a=BI.isArray(a)?a:[a];var c=[],d=BI.Tree.transformToArrayFormat(this.options.items);BI.each(d,function(b,d){BI.deepContains(a,d.value)&&!c.contains(d.text||d.value)&&c.push(d.text||d.value)}),c.length>0?(this.trigger.element.removeClass("bi-water-mark"),this.trigger.setText(c.join(","))):(this.trigger.element.addClass("bi-water-mark"),this.trigger.setText(b.text))},populate:function(a){this.options.items=a}}),BI.shortcut("bi.small_select_text_trigger",BI.SmallSelectTextTrigger),BI.SmallTextTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4},_defaultConfig:function(){var a=BI.SmallTextTrigger.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-text-trigger",height:20,triggerWidth:20})},_init:function(){BI.SmallTextTrigger.superclass._init.apply(this,arguments);var a=this.options,b=this._const;this.text=BI.createWidget({type:"bi.label",textAlign:"left",height:a.height,text:a.text,hgap:b.hgap}),this.trigerButton=BI.createWidget({type:"bi.trigger_icon_button",width:a.triggerWidth}),BI.createWidget({element:this,type:"bi.htape",items:[{el:this.text},{el:this.trigerButton,width:a.triggerWidth}]})},setValue:function(a){this.text.setValue(a)},setText:function(a){this.text.setText(a)}}),BI.shortcut("bi.small_text_trigger",BI.SmallTextTrigger),BI.SequenceTableTreeNumber=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-sequence-table-tree-number",isNeedFreeze:!1,startSequence:1,scrollTop:0,headerRowSize:25,rowSize:25,sequenceHeaderCreator:null,header:[],items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.SequenceTableTreeNumber.superclass._init.apply(this,arguments);this.options;this.vCurr=1,this.hCurr=1,this.tasks=[],this.renderedCells=[],this.renderedKeys=[],this.container=BI.createWidget({type:"bi.absolute",width:60,scrollable:!1}),this.scrollContainer=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.container]}),this.headerContainer=BI.createWidget({type:"bi.absolute",cls:"bi-border",width:58,scrollable:!1}),this.layout=BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.headerContainer,height:this._getHeaderHeight()-2},{el:{type:"bi.layout"},height:2},{el:this.scrollContainer}]}),this.start=this.options.startSequence,this.cache={},this._nextState(),this._populate()},_getNextSequence:function(a){function b(a){c.cache[a.text||a.value]||(c.cache[a.text||a.value]=e),e++}var c=this,d=this.start,e=this.start;return BI.each(a,function(a,f){BI.isNotEmptyArray(f.children)&&BI.each(f.children,function(a,f){0===a&&c.cache[f.text||f.value]&&(d=e=c.cache[f.text||f.value]),b(f)})}),this.start=e,d},_getStart:function(a){var b=this,c=this.start;return BI.some(a,function(a,d){if(BI.isNotEmptyArray(d.children))return BI.some(d.children,function(a,d){if(0===a&&b.cache[d.text||d.value])return c=b.cache[d.text||d.value],!0})}),c},_formatNumber:function(a){function b(a){var c=0;return BI.isNotEmptyArray(a.children)?(BI.each(a.children,function(a,d){c+=b(d)}),BI.isNotEmptyArray(a.values)&&c++):c++,c}var c=this.options,d=[],e=this._getStart(a),f=0,g=0;return BI.each(a,function(a,h){BI.isArray(h.children)&&(BI.each(h.children,function(a,h){var i=b(h);d.push({text:e++,start:f,top:g,cnt:i,index:a,height:i*c.rowSize}),f+=i,g+=i*c.rowSize}),BI.isNotEmptyArray(h.values)&&(d.push({text:BI.i18nText("BI-Summary_Values"),start:f++,top:g,cnt:1,isSummary:!0,height:c.rowSize}),g+=c.rowSize))}),d},_layout:function(){var a=this.options,b=this._getHeaderHeight()-2,c=this.layout.attr("items");a.isNeedFreeze===!1?(c[0].height=0,c[1].height=0):a.isNeedFreeze===!0&&(c[0].height=b,c[1].height=2),this.layout.attr("items",c),this.layout.resize();try{this.scrollContainer.element.scrollTop(a.scrollTop)}catch(d){}},_getHeaderHeight:function(){var a=this.options;return a.headerRowSize*(a.crossHeader.length+(a.header.length>0?1:0))},_nextState:function(){var a=this.options;this._getNextSequence(a.items)},_prevState:function(){var a,b=this.options;BI.some(b.items,function(b,c){if(BI.isNotEmptyArray(c.children))return BI.some(c.children,function(b,c){return a=c,!0})}),a&&BI.isNotEmptyObject(this.cache)?this.start=this.cache[a.text||a.value]:this.start=1,this._nextState()},_getMaxScrollTop:function(a){var b=0;return BI.each(a,function(a,c){b+=c.cnt}),Math.max(0,b*this.options.rowSize-(this.options.height-this._getHeaderHeight())+BI.DOM.getScrollWidth())},_createHeader:function(){var a=this.options;BI.createWidget({type:"bi.absolute",element:this.headerContainer,items:[{el:a.sequenceHeaderCreator||{type:"bi.table_style_cell",cls:"sequence-table-title-cell",styleGetter:a.headerCellStyleGetter,text:BI.i18nText("BI-Number_Index")},left:0,top:0,right:0,bottom:0}]})},_calculateChildrenToRender:function(){var a=this,b=this.options,c=[],d=[],e=this._formatNumber(b.items),f=BI.PrefixIntervalTree.uniform(e.length,0);BI.each(e,function(a,b){f.set(a,b.height)});for(var g=BI.clamp(b.scrollTop,0,this._getMaxScrollTop(e)),h=f.greatestLowerBound(g),i=-(g-(h>0?f.sumTo(h-1):0)),j=i,k=b.height-this._getHeaderHeight();j-1)e[f].height!==a.renderedCells[g]._height&&(a.renderedCells[g]._height=e[f].height,a.renderedCells[g].el.setHeight(e[f].height)),e[f].top!==a.renderedCells[g].top&&(a.renderedCells[g].top=e[f].top,a.renderedCells[g].el.element.css("top",e[f].top+"px")),c.push(a.renderedCells[g]);else{var h=BI.createWidget(BI.extend({type:"bi.table_style_cell",cls:"sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",width:60,styleGetter:e[f].isSummary===!0?function(){return b.summaryCellStyleGetter(!0)}:function(a){return function(){return b.sequenceCellStyleGetter(a)}}(e[f].index)},e[f]));c.push({el:h,left:0,top:e[f].top,_height:e[f].height})}});var l={},m={},n=[];BI.each(d,function(b,c){BI.deepContains(a.renderedKeys,c)?l[b]=c:m[b]=c}),BI.each(this.renderedKeys,function(a,b){BI.deepContains(l,b)||BI.deepContains(m,b)||n.push(a)}),BI.each(n,function(b,c){a.renderedCells[c].el.destroy()});var o=[];BI.each(m,function(a){o.push(c[a])}),BI.createWidget({type:"bi.absolute",element:this.container,items:o}),this.renderedCells=c,this.renderedKeys=d,this.container.setHeight(f.sumUntil(e.length))},_restore:function(){BI.each(this.renderedCells,function(a,b){b.el.destroy()}),this.renderedCells=[],this.renderedKeys=[]},_populate:function(){var a=this;BI.each(this.tasks,function(b,c){c.apply(a)}),this.tasks=[],this.headerContainer.empty(),this._createHeader(),this._layout(),this._calculateChildrenToRender()},setVerticalScroll:function(a){if(this.options.scrollTop!==a){this.options.scrollTop=a;try{this.scrollContainer.element.scrollTop(a)}catch(b){}}},getVerticalScroll:function(){return this.options.scrollTop},setVPage:function(a){a<=1?(this.cache={},this.start=this.options.startSequence,this._restore(),this.tasks.push(this._nextState)):a===this.vCurr+1?this.tasks.push(this._nextState):a===this.vCurr-1&&this.tasks.push(this._prevState),this.vCurr=a},setHPage:function(a){a!==this.hCurr&&this.tasks.push(this._prevState),this.hCurr=a},restore:function(){this._restore()},populate:function(a,b,c,d){var e=this.options;a&&a!==this.options.items&&(e.items=a,this._restore(),this.tasks.push(this._prevState)),b&&b!==this.options.header&&(e.header=b),c&&c!==this.options.crossItems&&(e.crossItems=c),d&&d!==this.options.crossHeader&&(e.crossHeader=d),this._populate()}}),BI.shortcut("bi.sequence_table_tree_number",BI.SequenceTableTreeNumber),BI.AdaptiveArrangement=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-adaptive-arrangement",resizable:!0,layoutType:BI.Arrangement.LAYOUT_TYPE.FREE,items:[]})},_init:function(){BI.AdaptiveArrangement.superclass._init.apply(this,arguments);var a=this,b=this.options;this.arrangement=BI.createWidget({type:"bi.arrangement",element:this,layoutType:b.layoutType,items:b.items}),this.arrangement.on(BI.Arrangement.EVENT_SCROLL,function(){a.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL,arguments)}),this.zIndex=0,BI.each(b.items,function(b,c){a._initResizable(c.el)}),$(document).mousedown(function(b){BI.each(a.getAllRegions(),function(a,c){0===c.el.element.find(b.target).length&&c.el.element.removeClass("selected")})}),BI.ResizeDetector.addResizeListener(this,function(){a.arrangement.resize(),a.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE)})},_isEqual:function(){return this.arrangement._isEqual.apply(this.arrangement,arguments)},_setSelect:function(a){a.element.hasClass("selected")||(a.element.css("zIndex",++this.zIndex),BI.each(this.getAllRegions(),function(a,b){b.el.element.removeClass("selected")}),a.element.addClass("selected"))},_initResizable:function(a){var b=this;this.options;a.element.css("zIndex",++this.zIndex),a.element.mousedown(function(){b._setSelect(a)})},_getScrollOffset:function(){return this.arrangement._getScrollOffset()},getClientWidth:function(){return this.arrangement.getClientWidth()},getClientHeight:function(){return this.arrangement.getClientHeight()},addRegion:function(a,b){this._initResizable(a.el),this._setSelect(a.el);var c,d=this.arrangement.getAllRegions();return(c=this.arrangement.addRegion(a,b))&&(this._old=d),c},deleteRegion:function(a){var b,c=this.getAllRegions();return(b=this.arrangement.deleteRegion(a))?this._old=c:(this._old=this.getAllRegions(),this.relayout()),b},setRegionSize:function(a,b){var c,d=this.getAllRegions();return(c=this.arrangement.setRegionSize(a,b))&&(this._old=d),c},setPosition:function(a,b){return this.arrangement.setPosition(a,b)},setRegionPosition:function(a,b){this.getRegionByName(a);return this.arrangement.setRegionPosition(a,b)},setDropPosition:function(a,b){return this.arrangement.setDropPosition(a,b)},scrollInterval:function(a,b,c,d){function e(a,b){if(""===a)return f.lastActiveRegion="",void(f._scrollInterval&&(clearInterval(f._scrollInterval),f._scrollInterval=null));if(f.lastActiveRegion!==a){f.lastActiveRegion=a,f._scrollInterval&&(clearInterval(f._scrollInterval),f._scrollInterval=null);var c=0;f._scrollInterval=setInterval(function(){if(c++,!(c<=3)){var d=f._getScrollOffset(),e=d.top+40*g[a][0],h=d.left+40*g[a][1];e<0||h<0||(b({offsetX:40*g[a][1],offsetY:40*g[a][0]}),f.scrollTo({top:e,left:h}))}},300)}}var f=this,g={top:[-1,0],bottom:[1,0],left:[0,-1],right:[0,1]},h=this.element.bounds();d({offsetX:0,offsetY:0});var i=this.element.offset(),j={left:a.pageX-i.left,top:a.pageY-i.top};b&&j.top>=0&&j.top<=30?e("top",d):b&&j.top>=h.height-30&&j.top<=h.height?e("bottom",d):b&&j.left>=0&&j.left<=30?e("left",d):b&&j.left>=h.width-30&&j.left<=h.width?e("right",d):c===!0?j.top<0?e("top",d):j.top>h.height?e("bottom",d):j.left<0?e("left",d):j.left>h.width?e("right",d):e("",d):e("",d)},scrollEnd:function(){this.lastActiveRegion="",this._scrollInterval&&(clearInterval(this._scrollInterval),this._scrollInterval=null)},scrollTo:function(a){this.arrangement.scrollTo(a)},zoom:function(a){this.arrangement.zoom(a)},resize:function(){this.arrangement.resize()},relayout:function(){return this.arrangement.relayout()},setLayoutType:function(a){this.arrangement.setLayoutType(a)},getLayoutType:function(){return this.arrangement.getLayoutType()},getLayoutRatio:function(){return this.arrangement.getLayoutRatio()},getHelper:function(){return this.arrangement.getHelper()},getRegionByName:function(a){return this.arrangement.getRegionByName(a)},getAllRegions:function(){return this.arrangement.getAllRegions()},revoke:function(){this._old&&this.populate(BI.toArray(this._old))},populate:function(a){var b=this;BI.each(a,function(a,c){b._initResizable(c.el)}),this.arrangement.populate(a)}}),BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE="AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE",BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE="AdaptiveArrangement.EVENT_ELEMENT_RESIZE",BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE="AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE",BI.AdaptiveArrangement.EVENT_RESIZE="AdaptiveArrangement.EVENT_RESIZE",BI.AdaptiveArrangement.EVENT_SCROLL="AdaptiveArrangement.EVENT_SCROLL",BI.shortcut("bi.adaptive_arrangement",BI.AdaptiveArrangement),BI.ArrangementBlock=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-arrangement-block bi-mask"})}}),BI.shortcut("bi.arrangement_block",BI.ArrangementBlock),BI.ArrangementDroppable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-arrangement-droppable bi-resizer"})}}),BI.shortcut("bi.arrangement_droppable",BI.ArrangementDroppable),BI.Arrangement=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-arrangement",layoutType:BI.Arrangement.LAYOUT_TYPE.GRID,items:[]})},_init:function(){BI.Arrangement.superclass._init.apply(this,arguments);var a=this,b=this.options;this.arrangement=BI.createWidget({type:"bi.arrangement_droppable",cls:"arrangement-block",invisible:!0}),this.block=BI.createWidget({type:"bi.arrangement_block",invisible:!0}),this.container=BI.createWidget({type:"bi.absolute",cls:"arrangement-container",items:b.items.concat([this.block,this.arrangement])}),this.scrollContainer=BI.createWidget({type:"bi.adaptive",width:"100%",height:"100%",scrollable:!0,items:[this.container]}),this.scrollContainer.element.scroll(function(){a.fireEvent(BI.Arrangement.EVENT_SCROLL,{scrollLeft:a.scrollContainer.element.scrollLeft(),scrollTop:a.scrollContainer.element.scrollTop(),clientWidth:a.scrollContainer.element[0].clientWidth,clientHeight:a.scrollContainer.element[0].clientHeight})}),BI.createWidget({type:"bi.adaptive",element:this,items:[this.scrollContainer]}),this.regions={},b.items.length>0&&BI.nextTick(function(){a.populate(b.items)})},_calculateRegions:function(a){var b=this;this.options;this.regions={},BI.each(a,function(a,c){var d=b._createOneRegion(c);b.regions[d.id]=d})},_isEqual:function(a,b){return Math.abs(a-b)<2},_isLessThan:function(a,b){return ab&&!this._isEqual(a,b)},_isLessThanEqual:function(a,b){return a<=b||this._isEqual(a,b)},_isMoreThanEqual:function(a,b){return a>=b||this._isEqual(a,b)},_getRegionOccupied:function(a){this.options;if(BI.size(a||this.regions)<=0)return{left:0,top:0,width:0,height:0};var b=BI.MAX,c=BI.MIN,d=BI.MAX,e=BI.MIN;return BI.each(a||this.regions,function(a,f){b=Math.min(b,f.left),c=Math.max(c,f.left+f.width),d=Math.min(d,f.top),e=Math.max(e,f.top+f.height)}),{left:b,top:d,width:c-b,height:e-d}},_getCrossArea:function(a,b){if(a.left<=b.left){if(a.top<=b.top){if(a.top+a.height>b.top&&a.left+a.width>b.left)return this._isEqual(a.top+a.height,b.top)||this._isEqual(a.left+a.width,b.left)?0:(a.top+a.height-b.top)*(a.left+a.width-b.left)}else if(b.top+b.height>a.top&&a.left+a.width>b.left)return this._isEqual(b.top+b.height,a.top)||this._isEqual(a.left+a.width,b.left)?0:(b.top+b.height-a.top)*(a.left+a.width-b.left)}else if(a.top<=b.top){if(a.top+a.height>b.top&&b.left+b.width>a.left)return this._isEqual(a.top+a.height,b.top)||this._isEqual(b.left+b.width,a.left)?0:(a.top+a.height-b.top)*(b.left+b.width-a.left)}else if(b.top+b.height>a.top&&b.left+b.width>a.left)return this._isEqual(b.top+b.height,a.top)||this._isEqual(b.left+b.width,a.left)?0:(b.top+b.height-a.top)*(b.left+b.width-a.left);return 0},_isRegionOverlay:function(a){var b=[];BI.each(a||this.regions,function(a,c){b.push(new BI.Region(c.left,c.top,c.width,c.height))});for(var c=0,d=b.length;c1)return!0}return!1},_isArrangeFine:function(a){switch(this.options.layoutType){case BI.Arrangement.LAYOUT_TYPE.FREE:return!0;case BI.Arrangement.LAYOUT_TYPE.GRID:}return!0},_getRegionNames:function(a){var b=[];return BI.each(a||this.regions,function(a,c){ -b.push(c.id||c.attr("id"))}),b},_getRegionsByNames:function(a,b){if(a=BI.isArray(a)?a:[a],b=b||this.regions,BI.isArray(b)){var c=[];BI.each(b,function(b,d){a.contains(d.id||d.attr("id"))&&c.push(d)})}else{var c={};BI.each(a,function(a,d){c[d]=b[d]})}return c},_cloneRegion:function(a){var b={};return BI.each(a||this.regions,function(a,c){b[a]={},b[a].el=c.el,b[a].id=c.id,b[a].left=c.left,b[a].top=c.top,b[a].width=c.width,b[a].height=c.height}),b},_test:function(a){return!BI.any(a||this.regions,function(a,b){if(BI.isNaN(b.width)||BI.isNaN(b.height)||b.width<=21||b.height<=21)return!0})},_getScrollOffset:function(){return{left:this.scrollContainer.element[0].scrollLeft,top:this.scrollContainer.element[0].scrollTop}},_createOneRegion:function(a){var b=BI.createWidget(a.el);return b.setVisible(!0),{id:b.attr("id"),left:a.left,top:a.top,width:a.width,height:a.height,el:b}},_applyRegion:function(a){this.options;BI.each(a||this.regions,function(a,b){b.el.element.css({left:b.left,top:b.top,width:b.width,height:b.height})}),this._applyContainer(),this.ratio=this.getLayoutRatio()},_renderRegion:function(){var a=BI.toArray(this.regions);BI.each(a,function(a,b){BI.isNotNull(b.el)?b.el.options.key=b.id:b.key=b.id}),BI.isNull(this.wrapper)&&(this.wrapper=BI.createWidget({type:"bi.absolute",element:this.container})),this.wrapper.populate(a)},getClientWidth:function(){return this.scrollContainer.element[0].clientWidth},getClientHeight:function(){return this.scrollContainer.element[0].clientHeight},_applyContainer:function(){this.scrollContainer.element.css("overflow","hidden");var a=this._getRegionOccupied();return this.container.element.width(a.left+a.width).height(a.top+a.height),this.scrollContainer.element.css("overflow","auto"),a},_modifyRegion:function(a){BI.each(this.regions,function(b,c){a[b]&&(c.left=a[b].left,c.top=a[b].top,c.width=a[b].width,c.height=a[b].height)})},_addRegion:function(a){var b=this._createOneRegion(a);this.regions[b.id]=b,BI.createWidget({type:"bi.absolute",element:this.container,items:[b]})},_deleteRegionByName:function(a){this.regions[a].el.setVisible(!1),delete this.regions[a]},_setArrangeSize:function(a){this.arrangement.element.css({left:a.left,top:a.top,width:a.width,height:a.height})},_getOneWidthPortion:function(){return this.getClientWidth()/BI.Arrangement.PORTION},_getOneHeightPortion:function(){return this.getClientHeight()/BI.Arrangement.H_PORTION},_getGridPositionAndSize:function(a){var b=this._getOneWidthPortion(),c=this._getOneHeightPortion(),d=Math.round(a.width/b),e=Math.round(a.left/b),f=Math.round(a.top/c),g=Math.round(a.height/c);return 0===d&&(d=1),0===g&&(g=1),{x:e,y:f,w:d,h:g}},_getBlockPositionAndSize:function(a){var b=this._getOneWidthPortion(),c=this._getOneHeightPortion();return{left:a.x*b,top:a.y*c,width:a.w*b,height:a.h*c}},_getLayoutsByRegions:function(a){var b=this,c=[];return BI.each(a||this.regions,function(a,d){c.push(BI.extend(b._getGridPositionAndSize(d),{i:d.id}))}),c},_getLayoutIndexByName:function(a,b){return BI.findIndex(a,function(a,c){return c.i===b})},_setBlockPositionAndSize:function(a){this.block.element.css({left:a.left,top:a.top,width:a.width,height:a.height})},_getRegionsByLayout:function(a){var b=this,c={};return BI.each(a,function(a,d){c[d.i]=BI.extend(b._getBlockPositionAndSize(d),{id:d.i})}),c},_setRegionsByLayout:function(a,b){var c=this;return a||(a=this.regions),BI.each(b,function(b,d){a[d.i]&&BI.extend(a[d.i],c._getBlockPositionAndSize(d))}),a},_moveElement:function(a,b,c,d,e){function f(a,b){return BI.filter(a,function(a,c){return g._collides(c,b)})}var g=this;if(b._static)return a;if(b.y===d&&b.x===c)return a;var h=d&&b.y>d;"number"==typeof c&&(b.x=c),"number"==typeof d&&(b.y=d),b.moved=!0;var i=this._sortLayoutItemsByRowCol(a);h&&(i=i.reverse());for(var j=f(i,b),k=0,l=j.length;km.y&&b.y-m.y>m.h/4||(a=m._static?this._moveElementAwayFromCollision(a,m,b,e):this._moveElementAwayFromCollision(a,b,m,e))}return a},_sortLayoutItemsByRowCol:function(a){return[].concat(a).sort(function(a,b){return a.y>b.y||a.y===b.y&&a.x>b.x?1:-1})},_collides:function(a,b){return a!==b&&(!(a.x+a.w<=b.x)&&(!(a.x>=b.x+b.w)&&(!(a.y+a.h<=b.y)&&!(a.y>=b.y+b.h))))},_getFirstCollision:function(a,b){for(var c=0,d=a.length;c0&&!this._getFirstCollision(a,b);)b.y--;for(var d;d=this._getFirstCollision(a,b);)b.y=d.y+d.h;return b},compact:function(a,b){function c(a){return BI.filter(a,function(a,b){return b._static})}for(var d=c(a),e=this._sortLayoutItemsByRowCol(a),f=[],g=0,h=e.length;g=c.options.min&&d<=c.options.max},f=function(a){return Date.parseDateTime(a,"%Y-%X").print("%Y-%X")==a&&d>=c.options.min&&d<=c.options.max};if(BI.isNotNull(b)&&Date.checkLegal(a))switch(a.length){case this._const.yearLength:e(a)&&this.editor.setValue(a+"-");break;case this._const.yearMonthLength:f(a)&&this.editor.setValue(a+"-")}},setValue:function(a){var b,c,d=this,e=new Date;this.store_value=a,BI.isNotNull(a)&&(b=a.type||BI.DateTrigger.MULTI_DATE_CALENDAR,c=a.value,BI.isNull(c)&&(c=a));var f=function(a,b){var c=a.print("%Y-%x-%e");d.editor.setState(c),d.editor.setValue(c),d.setTitle(b+":"+c)};switch(b){case BI.DateTrigger.MULTI_DATE_YEAR_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];e=new Date(e.getFullYear()-1*c,e.getMonth(),e.getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];e=new Date(e.getFullYear()+1*c,e.getMonth(),e.getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];e=new Date(e.getFullYear(),0,1),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];e=new Date(e.getFullYear(),11,31),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];e=(new Date).getBeforeMulQuarter(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];e=(new Date).getAfterMulQuarter(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];e=(new Date).getQuarterStartDate(),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];e=(new Date).getQuarterEndDate(),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];e=(new Date).getBeforeMultiMonth(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];e=(new Date).getAfterMultiMonth(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];e=new Date(e.getFullYear(),e.getMonth(),1),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];e=new Date(e.getFullYear(),e.getMonth(),e.getLastDateOfMonth().getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_WEEK_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];e=e.getOffsetDate(-7*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];e=e.getOffsetDate(7*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];e=e.getOffsetDate(-1*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];e=e.getOffsetDate(1*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_TODAY:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];e=new Date,f(e,g);break;default:if(BI.isNull(c)||BI.isNull(c.day))this.editor.setState(""),this.editor.setValue(""),this.setTitle("");else{var h=c.year+"-"+(c.month+1)+"-"+c.day;this.editor.setState(h),this.editor.setValue(h),this.setTitle(h)}}},getKey:function(){return this.editor.getValue()},getValue:function(){return this.store_value}}),BI.DateTrigger.MULTI_DATE_YEAR_PREV=1,BI.DateTrigger.MULTI_DATE_YEAR_AFTER=2,BI.DateTrigger.MULTI_DATE_YEAR_BEGIN=3,BI.DateTrigger.MULTI_DATE_YEAR_END=4,BI.DateTrigger.MULTI_DATE_MONTH_PREV=5,BI.DateTrigger.MULTI_DATE_MONTH_AFTER=6,BI.DateTrigger.MULTI_DATE_MONTH_BEGIN=7,BI.DateTrigger.MULTI_DATE_MONTH_END=8,BI.DateTrigger.MULTI_DATE_QUARTER_PREV=9,BI.DateTrigger.MULTI_DATE_QUARTER_AFTER=10,BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN=11,BI.DateTrigger.MULTI_DATE_QUARTER_END=12,BI.DateTrigger.MULTI_DATE_WEEK_PREV=13,BI.DateTrigger.MULTI_DATE_WEEK_AFTER=14,BI.DateTrigger.MULTI_DATE_DAY_PREV=15,BI.DateTrigger.MULTI_DATE_DAY_AFTER=16,BI.DateTrigger.MULTI_DATE_DAY_TODAY=17,BI.DateTrigger.MULTI_DATE_PARAM=18,BI.DateTrigger.MULTI_DATE_CALENDAR=19,BI.DateTrigger.MULTI_DATE_SEGMENT_NUM={},BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]=BI.i18nText("BI-Multi_Date_Year_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]=BI.i18nText("BI-Multi_Date_Year_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]=BI.i18nText("BI-Multi_Date_Year_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]=BI.i18nText("BI-Multi_Date_Year_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]=BI.i18nText("BI-Multi_Date_Quarter_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]=BI.i18nText("BI-Multi_Date_Quarter_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]=BI.i18nText("BI-Multi_Date_Quarter_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]=BI.i18nText("BI-Multi_Date_Quarter_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]=BI.i18nText("BI-Multi_Date_Month_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]=BI.i18nText("BI-Multi_Date_Month_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]=BI.i18nText("BI-Multi_Date_Month_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]=BI.i18nText("BI-Multi_Date_Month_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]=BI.i18nText("BI-Multi_Date_Week_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]=BI.i18nText("BI-Multi_Date_Week_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]=BI.i18nText("BI-Multi_Date_Day_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]=BI.i18nText("BI-Multi_Date_Day_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]=BI.i18nText("BI-Multi_Date_Today"),BI.DateTrigger.EVENT_FOCUS="EVENT_FOCUS",BI.DateTrigger.EVENT_START="EVENT_START",BI.DateTrigger.EVENT_STOP="EVENT_STOP",BI.DateTrigger.EVENT_CONFIRM="EVENT_CONFIRM",BI.DateTrigger.EVENT_CHANGE="EVENT_CHANGE",BI.DateTrigger.EVENT_VALID="EVENT_VALID",BI.DateTrigger.EVENT_ERROR="EVENT_ERROR",BI.DateTrigger.EVENT_TRIGGER_CLICK="EVENT_TRIGGER_CLICK",BI.DateTrigger.EVENT_KEY_DOWN="EVENT_KEY_DOWN",BI.shortcut("bi.date_trigger",BI.DateTrigger),BI.DatePaneWidget=BI.inherit(BI.Widget,{_defaultConfig:function(){var a=BI.DatePaneWidget.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-date-pane",min:"1900-01-01",max:"2099-12-31",selectedTime:null})},_init:function(){BI.DatePaneWidget.superclass._init.apply(this,arguments);var a=this,b=this.options;this.today=new Date,this._year=this.today.getFullYear(),this._month=this.today.getMonth(),this.selectedTime=b.selectedTime||{year:this._year,month:this._month},this.datePicker=BI.createWidget({type:"bi.date_picker",min:b.min,max:b.max}),this.datePicker.on(BI.DatePicker.EVENT_CHANGE,function(){a.selectedTime=a.datePicker.getValue(),a.calendar.setSelect(BI.Calendar.getPageByDateJSON(a.selectedTime))}),this.calendar=BI.createWidget({direction:"top",element:this,logic:{dynamic:!1},type:"bi.navigation",tab:this.datePicker,cardCreator:BI.bind(this._createNav,this)}),this.calendar.on(BI.Navigation.EVENT_CHANGE,function(){a.selectedTime=a.calendar.getValue(),a.calendar.empty(),a.setValue(a.selectedTime),a.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE)})},_createNav:function(a){var b=BI.Calendar.getDateJSONByPage(a),c=BI.createWidget({type:"bi.calendar",logic:{dynamic:!1},min:this.options.min,max:this.options.max,year:b.year,month:b.month,day:this.selectedTime.day});return c},_getNewCurrentDate:function(){var a=new Date;return{year:a.getFullYear(),month:a.getMonth()}},_setCalenderValue:function(a){this.calendar.setSelect(BI.Calendar.getPageByDateJSON(a)),this.calendar.setValue(a),this.selectedTime=a},_setDatePicker:function(a){BI.isNull(a)||BI.isNull(a.year)||BI.isNull(a.month)?this.datePicker.setValue(this._getNewCurrentDate()):this.datePicker.setValue(a)},_setCalendar:function(a){BI.isNull(a)||BI.isNull(a.day)?(this.calendar.empty(), -this._setCalenderValue(this._getNewCurrentDate())):this._setCalenderValue(a)},setValue:function(a){this._setDatePicker(a),this._setCalendar(a)},getValue:function(){return this.selectedTime}}),BI.shortcut("bi.date_pane",BI.DatePaneWidget),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",width:200,height:24})},_init:function(){BI.DateTimeCombo.superclass._init.apply(this,arguments);var a=this,b=(this.options,new Date);this.storeValue={year:b.getFullYear(),month:b.getMonth(),day:b.getDate(),hour:b.getHours(),minute:b.getMinutes(),second:b.getSeconds()},this.trigger=BI.createWidget({type:"bi.date_time_trigger",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.popup=BI.createWidget({type:"bi.date_time_popup",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),a.setValue(this.storeValue),this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE,function(){a.setValue(a.storeValue),a.hidePopupView(),a.fireEvent(BI.DateTimeCombo.EVENT_CANCEL)}),this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE,function(){a.storeValue=a.popup.getValue(),a.setValue(a.storeValue),a.hidePopupView(),a.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM)}),this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE,function(){a.trigger.setValue(a.popup.getValue()),a.fireEvent(BI.DateTimeCombo.EVENT_CHANGE)}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,adjustLength:this.constants.comboAdjustHeight,popup:{el:this.popup,maxHeight:this.constants.popupHeight,width:this.constants.popupWidth,stopPropagation:!1}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.popup.setValue(a.storeValue),a.fireEvent(BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW)});var c=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-font bi-border-right",width:30,height:24});c.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.combo.isViewVisible()?a.combo.hideView():a.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:c,top:0,left:0}]}]})},setValue:function(a){this.storeValue=a,this.popup.setValue(a),this.trigger.setValue(a)},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),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:290})},_init:function(){BI.DateTimePopup.superclass._init.apply(this,arguments);var a=this;this.options;this.cancelButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"multidate-popup-button bi-border-top bi-border-right",shadow:!0,text:BI.i18nText("BI-Basic_Cancel")}),this.cancelButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE)}),this.okButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_OK")}),this.okButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE)}),this.dateCombo=BI.createWidget({type:"bi.date_calendar_popup",min:a.options.min,max:a.options.max}),a.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}),this.dateSelect=BI.createWidget({type:"bi.vertical_adapt",cls:"bi-border-top",items:[{type:"bi.label",text:BI.i18nText("BI-Basic_Time"),width:45},{type:"bi.date_time_select",max:23,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.hour=b}},{type:"bi.label",text:":",width:15},{type:"bi.date_time_select",max:59,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.minute=b}},{type:"bi.label",text:":",width:15},{type:"bi.date_time_select",max:59,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.second=b}}]});var b=new Date;this.dateCombo.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.hour.setValue(b.getHours()),this.minute.setValue(b.getMinutes()),this.second.setValue(b.getSeconds()),this.dateButton=BI.createWidget({type:"bi.grid",items:[[this.cancelButton,this.okButton]]}),BI.createWidget({element:this,type:"bi.vtape",items:[{el:this.dateCombo},{el:this.dateSelect,height:50},{el:this.dateButton,height:30}]})},setValue:function(a){var b,c=a;BI.isNull(c)?(b=new Date,this.dateCombo.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.hour.setValue(b.getHours()),this.minute.setValue(b.getMinutes()),this.second.setValue(b.getSeconds())):(this.dateCombo.setValue({year:c.year,month:c.month,day:c.day}),this.hour.setValue(c.hour),this.minute.setValue(c.minute),this.second.setValue(c.second))},getValue:function(){return{year:this.dateCombo.getValue().year,month:this.dateCombo.getValue().month,day:this.dateCombo.getValue().day,hour:this.hour.getValue(),minute:this.minute.getValue(),second:this.second.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),BI.DateTimeSelect=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-date-time-select bi-border",max:23,min:0})},_init:function(){BI.DateTimeSelect.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.sign_editor",value:this._alertInEditorValue(b.min),allowBlank:!1,errorText:BI.i18nText("BI-Please_Input_Natural_Number"),validationChecker:function(a){return BI.isNaturalNumber(a)}}),this.editor.on(BI.TextEditor.EVENT_CONFIRM,function(){a._finetuning(0),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this.topBtn=BI.createWidget({type:"bi.icon_button",cls:"column-pre-page-h-font top-button bi-border-left bi-border-bottom"}),this.topBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(1),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this.bottomBtn=BI.createWidget({type:"bi.icon_button",cls:"column-next-page-h-font bottom-button bi-border-left"}),this.bottomBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(-1),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this._finetuning(0),BI.createWidget({type:"bi.htape",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:30}]})},_alertOutEditorValue:function(a){return a>this.options.max&&(a=this.options.min),athis.options.max&&(a=this.options.min),a0&&a[c-1].xb)return!0});return c.y}var c=this,d=(this.options,this.pathChooser.routes),e=this.pathChooser.pathes,f=this.pathChooser.store;this.arrows={},BI.each(d,function(d,g){c.arrows[d]=[],BI.each(g,function(g,h){c.arrows[d][g]=[];var i=e[d][g];BI.each(i,function(a,b){if(a>0&&a0&&(e=c._drawOneArrow(i[a-1],3)):e=c._drawOneArrow(i[a],1)):b.x===i[a-1].x&&(e=b.y>i[a-1].y?f[BI.first(h)].direction===-1?c._drawOneArrow(i[a-1],0):c._drawOneArrow(b,2):f[h[h.length-2]].direction===-1?c._drawOneArrow(i[a-1],2):c._drawOneArrow(b,0)),e&&c.arrows[d][g].push(e)}}),BI.each(h,function(e,j){if(0!==e){var k,l=h[e-1];if(f[l].direction===-1){var m=c.pathChooser.getRegionIndexById(l),n=a(m,-1),o=b(i,n);k=c._drawOneArrow({x:n,y:o},3)}else{var m=c.pathChooser.getRegionIndexById(j),n=a(m),o=b(i,n);k=c._drawOneArrow({x:n,y:o},1)}k&&c.arrows[d][g].push(k)}})})})},_setValue:function(a,b){var c=this,d=this._const.lineColor,e=this._const.selectLineColor,f=this.pathChooser.routes,g=this.pathChooser.start,h=[a];g.contains(a)&&(h=g),BI.each(h,function(a,b){BI.each(c.arrows[b],function(a,b){BI.each(b,function(a,b){b.attr({fill:d,stroke:d}).toFront()})})}),BI.each(this.arrows[a][b],function(a,b){b.attr({fill:e,stroke:e}).toFront()});for(var i=BI.last(f[a][b]);i&&f[i]&&1===f[i].length;)BI.each(c.arrows[i][0],function(a,b){b.attr({fill:e,stroke:e}).toFront()}),i=BI.last(f[i][0])},setValue:function(a){this.pathChooser.setValue(a),this._unselectAllArrows();var b=this.pathChooser.routes,c=BI.keys(b),d=this,e=[],f=[];BI.each(a,function(a,b){BI.contains(c,b)&&f.length>0&&(f.push(b),e.push(f),f=[]),f.push(b)}),f.length>0&&e.push(f),BI.each(e,function(a,c){var e=c[0],f=BI.findIndex(b[e],function(a,b){if(BI.isEqual(c,b))return!0});f>=0&&d._setValue(e,f)})},getValue:function(){return this.pathChooser.getValue()},populate:function(a){this.pathChooser.populate(a),this._drawArrows()}}),BI.DirectionPathChooser.EVENT_CHANGE="DirectionPathChooser.EVENT_CHANGE",BI.shortcut("bi.direction_path_chooser",BI.DirectionPathChooser),BI.DownListCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-down-list-combo",invalid:!1,height:25,items:[],adjustLength:0,direction:"bottom",trigger:"click",el:{}})},_init:function(){BI.DownListCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.popupview=BI.createWidget({type:"bi.down_list_popup",items:b.items,chooseType:b.chooseType}),this.popupview.on(BI.DownListPopup.EVENT_CHANGE,function(b){a.fireEvent(BI.DownListCombo.EVENT_CHANGE,b),a.downlistcombo.hideView()}),this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE,function(b,c){a.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE,b,c),a.downlistcombo.hideView()}),this.downlistcombo=BI.createWidget({element:this,type:"bi.combo",trigger:b.trigger,isNeedAdjustWidth:!1,adjustLength:b.adjustLength,direction:b.direction,el:BI.createWidget(b.el,{type:"bi.icon_trigger",extraCls:b.iconCls?b.iconCls:"pull-down-font",width:b.width,height:b.height}),popup:{el:this.popupview,stopPropagation:!0,maxHeight:1e3}}),this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW)})},hideView:function(){this.downlistcombo.hideView()},showView:function(){this.downlistcombo.showView()},populate:function(a){this.popupview.populate(a)},setValue:function(a){this.popupview.setValue(a)},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),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 a=this.options,b=this;this.downlistgroup=BI.createWidget({element:this,type:"bi.button_tree",items:a.items,chooseType:0,layouts:[{type:"bi.vertical",hgap:0,vgap:0}]}),this.downlistgroup.on(BI.Controller.EVENT_CHANGE,function(a){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.DownListGroup.EVENT_CHANGE,arguments)})},getValue:function(){return this.downlistgroup.getValue()},setValue:function(a){this.downlistgroup.setValue(a)}}),BI.DownListGroup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_group",BI.DownListGroup),BI.DownListItem=BI.inherit(BI.Single,{_defaultConfig:function(){var a=BI.DownListItem.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-down-list-item bi-list-item-active",cls:"",height:25,logic:{dynamic:!0},selected:!1,iconHeight:null,iconWidth:null,textHgap:0,textVgap:0,textLgap:0,textRgap:0})},_init:function(){BI.DownListItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.text=BI.createWidget({type:"bi.icon_text_item",element:this,height:b.height,text:b.text,value:b.value,logic:b.logic,selected:b.selected,disabled:b.disabled,iconHeight:b.iconHeight,iconWidth:b.iconWidth,textHgap:b.textHgap,textVgap:b.textVgap,textLgap:b.textLgap,textRgap:b.textRgap,father:b.father}),this.text.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.text.on(BI.IconTextItem.EVENT_CHANGE,function(){a.fireEvent(BI.DownListItem.EVENT_CHANGE)})},doRedMark:function(){this.text.doRedMark.apply(this.text,arguments)},unRedMark:function(){this.text.unRedMark.apply(this.text,arguments)},isSelected:function(){return this.text.isSelected()},setSelected:function(a){this.text.setSelected(a)},setValue:function(a){this.text.setValue(a)},getValue:function(){return this.text.getValue()}}),BI.DownListItem.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_item",BI.DownListItem),BI.DownListGroupItem=BI.inherit(BI.BasicButton,{_defaultConfig:function(){var a=BI.DownListGroupItem.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-down-list-group-item",logic:{dynamic:!1},iconCls1:"dot-e-font",iconCls2:"pull-right-e-font"})},_init:function(){BI.DownListGroupItem.superclass._init.apply(this,arguments);var a=this.options,b=this;this.text=BI.createWidget({type:"bi.label",cls:"list-group-item-text",textAlign:"left",text:a.text,value:a.value,height:a.height}),this.icon1=BI.createWidget({type:"bi.icon_button",cls:a.iconCls1,width:25,forceNotSelected:!0}),this.icon2=BI.createWidget({type:"bi.icon_button",cls:a.iconCls2,width:25,forceNotSelected:!0});var c=BI.createWidget({type:"bi.layout",width:25});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(a.logic,{items:BI.LogicFactory.createLogicItemsByDirection("left",this.icon1,this.text,c)})))),this.element.hover(function(){b.isEnabled()&&b.hover()},function(){b.isEnabled()&&b.dishover()})},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),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(a){var b=this,c=this.options;a=BI.isArray(a)?a:[a],BI.find(a,function(a,d){return BI.contains(c.childValues,d)?(b.icon1.setSelected(!0),!0):void b.icon1.setSelected(!1)})}}),BI.DownListGroupItem.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_group_item",BI.DownListGroupItem),BI.DownListPopup=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 a=BI.DownListPopup.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{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={};var a=this,b=this.options,c=this._createChildren(b.items);this.popup=BI.createWidget({type:"bi.button_tree",items:BI.createItems(c,{},{adjustLength:-2}),layouts:[{type:"bi.vertical",hgap:this.constants.hgap,vgap:this.constants.vgap}],chooseType:b.chooseType}),this.popup.on(BI.ButtonTree.EVENT_CHANGE,function(b,c){var d=b;if(BI.isNotNull(a.childValueMap[b])?(d=a.childValueMap[b],a.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE,d,a.fatherValueMap[b])):a.fireEvent(BI.DownListPopup.EVENT_CHANGE,d,c),!a.singleValues.contains(d)){var e=a.getValue(),f=[];BI.each(e,function(a,b){b.value!=d&&f.push(b)}),a.setValue(f)}}),BI.createWidget({type:"bi.vertical",element:this,items:[this.popup]})},_createChildren:function(a){var b=this,c=[];return BI.each(a,function(d,e){var f={type:"bi.down_list_group",items:[]};if(BI.each(e,function(a,c){BI.isNotEmptyArray(c.children)&&!BI.isEmpty(c.el)?(c.type="bi.combo_group",c.cls="down-list-group",c.trigger="hover",c.isNeedAdjustWidth=!1,c.el.title=c.el.title||c.el.text,c.el.type="bi.down_list_group_item",c.el.logic={dynamic:!0},c.el.height=b.constants.height,c.el.iconCls2=b.constants.nextIcon,c.popup={lgap:4,el:{type:"bi.button_tree",chooseType:0,layouts:[{type:"bi.vertical"}]}},c.el.childValues=[],BI.each(c.children,function(a,d){var e=BI.deepClone(c.el.value),f=BI.deepClone(d.value);b.singleValues.push(d.value),d.type="bi.down_list_item",d.extraCls=" child-down-list-item",d.title=d.title||d.text,d.textRgap=10,d.isNeedAdjustWidth=!1,d.logic={dynamic:!0},d.father=e,b.fatherValueMap[b._createChildValue(e,f)]=e,b.childValueMap[b._createChildValue(e,f)]=f,d.value=b._createChildValue(e,f),c.el.childValues.push(d.value)})):(c.type="bi.down_list_item",c.title=c.title||c.text,c.textRgap=10,c.isNeedAdjustWidth=!1,c.logic={dynamic:!0});var d={};d.el=c,f.items.push(d)}),b._isGroup(f.items)&&BI.each(f.items,function(a,c){b.singleValues.push(c.el.value)}),c.push(f),b._needSpliter(d,a.length)){var g=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:10});c.push(g)}}),c},_isGroup:function(a){return a.length>1},_needSpliter:function(a,b){return a0?b.type="bi.file_manager_folder_item":b.type="bi.file_manager_file_item"}),a},setValue:function(a){this.button_group.setValue(a)},getValue:function(){return this.button_group.getValue()},getNotSelectedValue:function(){return this.button_group.getNotSelectedValue()},getAllLeaves:function(){return this.button_group.getAllLeaves()},getAllButtons:function(){return this.button_group.getAllButtons()},getSelectedButtons:function(){return this.button_group.getSelectedButtons()},getNotSelectedButtons:function(){return this.button_group.getNotSelectedButtons(); -},populate:function(a){this.button_group.populate(this._formatItems(a))}}),BI.FileManagerButtonGroup.EVENT_CHANGE="FileManagerButtonGroup.EVENT_CHANGE",BI.shortcut("bi.file_manager_button_group",BI.FileManagerButtonGroup),BI.FileManager=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager",el:{},items:[]})},_init:function(){BI.FileManager.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=new BI.Tree;var c=BI.Tree.transformToTreeFormat(b.items);this.tree.initTree(c),this.selectedValues=[],this.nav=BI.createWidget({type:"bi.file_manager_nav",items:BI.deepClone(c)}),this.nav.on(BI.FileManagerNav.EVENT_CHANGE,function(b,c){if("-1"==b)a.populate({children:a.tree.toJSON()});else{var d=a.tree.search(c.attr("id"));a.populate(BI.extend({id:d.id},d.get("data"),{children:a.tree.toJSON(d)}))}a.setValue(a.selectedValues)}),this.list=BI.createWidget(b.el,{type:"bi.file_manager_list",items:c}),this.list.on(BI.Controller.EVENT_CHANGE,function(b,c,d){if(b===BI.Events.CHANGE){var e=a.tree.search(d.attr("id"));a.populate(BI.extend({id:e.id},e.get("data"),{children:a.tree.toJSON(e)}))}else if(b===BI.Events.CLICK){var f=[];if(d instanceof BI.MultiSelectBar){var g=a.list.getValue();c=g.type===BI.Selection.All,f=BI.concat(g.assist,g.value)}else f=d.getAllLeaves();BI.each(f,function(b,d){c===!0?a.selectedValues.pushDistinct(d):a.selectedValues.remove(d)})}a.setValue(a.selectedValues)}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.list,left:0,right:0,top:0,bottom:10},{el:this.nav,left:40,right:100,top:0}]})},setValue:function(a){this.selectedValues=a||[],this.list.setValue(this.selectedValues)},getValue:function(){var a=this.list.getValue(),b=a.type===BI.Selection.All?a.assist:a.value;return b.pushDistinctArray(this.selectedValues),b},_populate:function(a){this.list.populate(a)},getSelectedValue:function(){return this.nav.getValue()[0]},getSelectedId:function(){return this.nav.getId()[0]},populate:function(a){var b=BI.deepClone(a);this._populate(a.children),this.nav.populate(b)}}),BI.FileManager.EVENT_CHANGE="FileManager.EVENT_CHANGE",BI.shortcut("bi.file_manager",BI.FileManager),BI.FileManagerFileItem=BI.inherit(BI.Single,{_defaultConfig:function(){return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-file-item bi-list-item bi-border-bottom",height:30})},_init:function(){BI.FileManagerFileItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checked=BI.createWidget({type:"bi.multi_select_bar",text:"",width:36,height:b.height}),this.checked.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),BI.createWidget({type:"bi.htape",element:this,items:[{el:this.checked,width:36},{el:{type:"bi.icon_button",cls:"create-by-me-file-font"},width:20},{el:{type:"bi.label",textAlign:"left",height:b.height,text:b.text,value:b.value}}]})},getAllLeaves:function(){return[this.options.value]},isSelected:function(){return this.checked.isSelected()},setSelected:function(a){this.checked.setSelected(a)}}),BI.FileManagerFileItem.EVENT_CHANGE="FileManagerFileItem.EVENT_CHANGE",BI.shortcut("bi.file_manager_file_item",BI.FileManagerFileItem),BI.FileManagerFolderItem=BI.inherit(BI.Single,{_defaultConfig:function(){return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-folder-item bi-list-item bi-border-bottom",height:30})},_init:function(){BI.FileManagerFolderItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checked=BI.createWidget({type:"bi.multi_select_bar",text:"",width:36,height:b.height}),this.checked.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button=BI.createWidget({type:"bi.text_button",textAlign:"left",height:b.height,text:b.text,value:b.value}),this.button.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,BI.Events.CHANGE,b.value,a)}),this.tree=new BI.Tree,this.tree.initTree([{id:b.id,children:b.children}]),this.selectValue=[],BI.createWidget({type:"bi.htape",element:this,items:[{el:this.checked,width:36},{el:{type:"bi.icon_button",cls:"create-by-me-folder-font"},width:20},{el:this.button}]})},setAllSelected:function(a){this.checked.setSelected(a),this.selectValue=[]},setHalfSelected:function(a){this.checked.setHalfSelected(a),a||(this.selectValue=[])},setValue:function(a){var b=(this.options,!1),c=[];this.tree.traverse(function(d){d.isLeaf()&&(BI.contains(a,d.get("data").value)?c.push(d.get("data").value):b=!0)}),this.setAllSelected(c.length>0&&!b),this.setHalfSelected(c.length>0&&b),this.checked.isHalfSelected()&&(this.selectValue=c)},getAllButtons:function(){return[this]},getAllLeaves:function(){var a=(this.options,[]);return this.tree.traverse(function(b){b.isLeaf()&&a.push(b.get("data").value)}),a},getNotSelectedValue:function(){var a=this,b=(this.options,[]),c=this.checked.isSelected();if(c===!0)return b;var d=this.checked.isHalfSelected();return this.tree.traverse(function(c){if(c.isLeaf()){var e=c.get("data").value;d===!0?BI.contains(a.selectValue,c.get("data").value)||b.push(e):b.push(e)}}),b},getValue:function(){var a=[];return this.checked.isSelected()?(this.tree.traverse(function(b){b.isLeaf()&&a.push(b.get("data").value)}),a):this.checked.isHalfSelected()?this.selectValue:[]}}),BI.FileManagerFolderItem.EVENT_CHANGE="FileManagerFolderItem.EVENT_CHANGE",BI.shortcut("bi.file_manager_folder_item",BI.FileManagerFolderItem),BI.FileManagerList=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-list",el:{},items:[]})},_init:function(){BI.FileManagerList.superclass._init.apply(this,arguments);var a=this,b=this.options;this.list=BI.createWidget({type:"bi.select_list",element:this,items:b.items,toolbar:{type:"bi.multi_select_bar",height:40,text:""},el:{type:"bi.list_pane",el:BI.isWidget(b.el)?b.el:BI.extend({type:"bi.file_manager_button_group"},b.el)}}),this.list.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)})},setValue:function(a){this.list.setValue({value:a})},getValue:function(){return this.list.getValue()},populate:function(a){this.list.populate(a),this.list.setToolBarVisible(!0)}}),BI.FileManagerList.EVENT_CHANGE="FileManagerList.EVENT_CHANGE",BI.shortcut("bi.file_manager_list",BI.FileManagerList),BI.FileManagerNavButton=BI.inherit(BI.Widget,{_const:{normal_color:"#ffffff",select_color:"#eff1f4"},_defaultConfig:function(){return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-nav-button",selected:!1,height:40})},_init:function(){BI.FileManagerNavButton.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.button=BI.createWidget({type:"bi.text_button",cls:"file-manager-nav-button-text bi-card",once:!0,selected:b.selected,text:b.text,title:b.text,value:b.value,height:b.height,lgap:20,rgap:10}),this.button.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var d=BI.createWidget({type:"bi.svg",cls:"file-manager-nav-button-triangle",width:15,height:b.height}),e=d.path("M0,0L15,20L0,40").attr({stroke:c.select_color,fill:b.selected?c.select_color:c.normal_color});this.button.on(BI.TextButton.EVENT_CHANGE,function(){this.isSelected()?e.attr("fill",c.select_color):e.attr("fill",c.normal_color)}),BI.createWidget({type:"bi.default",element:this,items:[this.button]}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:d,right:-15,top:0,bottom:0}]})},isSelected:function(){return this.button.isSelected()},setValue:function(a){this.button.setValue(a)},getValue:function(){return this.button.getValue()},populate:function(a){}}),BI.FileManagerNavButton.EVENT_CHANGE="FileManagerNavButton.EVENT_CHANGE",BI.shortcut("bi.file_manager_nav_button",BI.FileManagerNavButton),BI.FileManagerNav=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-nav bi-border-left",height:40,items:[]})},_init:function(){BI.FileManagerNav.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=new BI.Tree,this.refreshTreeData(b.items),this.tree.getRoot().set("data",{text:BI.i18nText("BI-Created_By_Me"),value:BI.FileManagerNav.ROOT_CREATE_BY_ME,id:BI.FileManagerNav.ROOT_CREATE_BY_ME}),this.button_group=BI.createWidget({type:"bi.button_group",element:this,items:[{type:"bi.file_manager_nav_button",text:BI.i18nText("BI-Created_By_Me"),selected:!0,id:BI.FileManagerNav.ROOT_CREATE_BY_ME,value:BI.FileManagerNav.ROOT_CREATE_BY_ME}],layouts:[{type:"bi.horizontal"}]}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.ButtonGroup.EVENT_CHANGE,function(b,c){a.fireEvent(BI.FileManagerNav.EVENT_CHANGE,arguments)})},_getAllParents:function(a){var b,c=[];for(b=a?this.tree.search(a):this.tree.getRoot();b.parent;)c.push(b),b=b.parent;return c.push(b),c.reverse()},_formatNodes:function(a){var b=[];return BI.each(a,function(a,c){b.push(BI.extend({type:"bi.file_manager_nav_button",id:c.id},c.get("data")))}),BI.last(b).selected=!0,b},getValue:function(){return this.button_group.getValue()},getId:function(){var a=[];return BI.each(this.button_group.getSelectedButtons(),function(b,c){a.push(c.attr("id"))}),a},refreshTreeData:function(a){this.tree.initTree(BI.Tree.transformToTreeFormat(a)),this.tree.getRoot().set("data",{text:BI.i18nText("BI-Created_By_Me"),value:BI.FileManagerNav.ROOT_CREATE_BY_ME,id:BI.FileManagerNav.ROOT_CREATE_BY_ME})},populate:function(a){var b=BI.isNull(a)?[this.tree.getRoot()]:this._getAllParents(a.id);this.button_group.populate(this._formatNodes(b))}}),BI.extend(BI.FileManagerNav,{ROOT_CREATE_BY_ME:"-1"}),BI.FileManagerNav.EVENT_CHANGE="FileManagerNav.EVENT_CHANGE",BI.shortcut("bi.file_manager_nav",BI.FileManagerNav),BI.InteractiveArrangement=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-interactive-arrangement",resizable:!0,layoutType:BI.Arrangement.LAYOUT_TYPE.GRID,items:[]})},_init:function(){BI.InteractiveArrangement.superclass._init.apply(this,arguments);var a=this,b=this.options;this.arrangement=BI.createWidget({type:"bi.adaptive_arrangement",element:this,resizable:b.resizable,layoutType:b.layoutType,items:b.items}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL,function(){a.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL,arguments)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE,function(){a.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE,arguments)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE,function(b,c){var d=a._getRegionClientPosition(b);a.draw({left:d.left,top:d.top},c,b)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE,function(b,c){a.stopDraw(),a.setRegionSize(b,c)}),this.tags=[]},_isEqual:function(a,b){return this.arrangement._isEqual(a,b)},_getScrollOffset:function(){return this.arrangement._getScrollOffset()},_positionAt:function(a,b){var c=this;b=b||this.getAllRegions();var d=[],e=[],f=[],g=[],h=[],i=[];return BI.each(b,function(b,j){var k=c._getRegionClientPosition(j.id);Math.abs(k.left-a.left)<=3&&d.push(j),Math.abs(k.left+k.width/2-a.left)<=3&&e.push(j),Math.abs(k.left+k.width-a.left)<=3&&f.push(j),Math.abs(k.top-a.top)<=3&&g.push(j),Math.abs(k.top+k.height/2-a.top)<=3&&h.push(j),Math.abs(k.top+k.height-a.top)<=3&&i.push(j)}),{left:d,center:e,right:f,top:g,middle:h,bottom:i}},_getRegionClientPosition:function(a){var b=this.getRegionByName(a),c=this.arrangement._getScrollOffset();return{top:b.top-c.top,left:b.left-c.left,width:b.width,height:b.height,id:b.id}},_vAlign:function(a,b){var c,d=this,e=this._positionAt(a,b),f=[];if(e.left.length>0)c=this._getRegionClientPosition(e.left[0].id).left;else if(e.right.length>0){var g=this._getRegionClientPosition(e.right[0].id);c=g.left+g.width}else if(e.center.length>0){var g=this._getRegionClientPosition(e.center[0].id);c=g.left+g.width/2}var h=e.left.concat(e.right).concat(e.center);return BI.each(h,function(b,e){var g=d._getRegionClientPosition(e.id);if(d._isEqual(g.left,c)||d._isEqual(g.left+g.width,c)||d._isEqual(g.left+g.width/2,c)){var h={top:g.top+g.height/2,left:c};f.push({id:e.id,start:h,end:{left:c,top:a.top}})}}),f},_leftAlign:function(a,b,c){return this._vAlign({left:a.left,top:a.top+b.height/2},c)},_rightAlign:function(a,b,c){return this._vAlign({left:a.left+b.width,top:a.top+b.height/2},c)},_hAlign:function(a,b){var c,d=this,e=this._positionAt(a,b),f=[];if(e.top.length>0){var g=this._getRegionClientPosition(e.top[0].id);c=g.top}else if(e.bottom.length>0){var g=this._getRegionClientPosition(e.bottom[0].id);c=g.top+g.height}else if(e.middle.length>0){var g=this._getRegionClientPosition(e.middle[0].id);c=g.top+g.height/2}var h=e.top.concat(e.bottom).concat(e.middle);return BI.each(h,function(b,e){var g=d._getRegionClientPosition(e.id);if(d._isEqual(g.top,c)||d._isEqual(g.top+g.height,c)||d._isEqual(g.top+g.height/2,c)){var h={top:c,left:g.left+g.width/2};f.push({id:g.id,start:h,end:{left:a.left,top:c}})}}),f},_topAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top},c)},_bottomAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top+b.height},c)},_centerAlign:function(a,b,c){return this._vAlign({left:a.left+b.width/2,top:a.top+b.height/2},c)},_middleAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top+b.height/2},c)},_drawOneTag:function(a,b){var c=BI.createWidget({type:"bi.icon_button",width:13,height:13,cls:"drag-tag-font interactive-arrangement-dragtag-icon"}),d=BI.createWidget({type:"bi.icon_button",width:13,height:13,cls:"drag-tag-font interactive-arrangement-dragtag-icon"});if(this._isEqual(a.left,b.left))var e=BI.createWidget({type:"bi.layout",cls:"interactive-arrangement-dragtag-line",width:1,height:Math.abs(a.top-b.top)});else var e=BI.createWidget({type:"bi.layout",cls:"interactive-arrangement-dragtag-line",height:1,width:Math.abs(a.left-b.left)});BI.createWidget({type:"bi.absolute",element:this,items:[{el:c,left:a.left-6,top:a.top-7},{el:d,left:b.left-6,top:b.top-7},{el:e,left:Math.min(a.left,b.left),top:Math.min(a.top,b.top)}]}),this.tags.push(c),this.tags.push(d),this.tags.push(e)},stopDraw:function(){BI.each(this.tags,function(a,b){b.destroy()}),this.tags=[]},_getRegionExcept:function(a,b){var c=[];return BI.each(b||this.getAllRegions(),function(b,d){a&&d.id===a||c.push(d)}),c},getClientWidth:function(){return this.arrangement.getClientWidth()},getClientHeight:function(){return this.arrangement.getClientHeight()},getPosition:function(a,b,c){var d,e=this.getAllRegions();a&&(d=this._getRegionClientPosition(a));var f=this._getRegionExcept(a,e);b=b||{left:d.left,top:d.top},c=c||{width:d.width,height:d.height};var g=this._leftAlign(b,c,f),h=this._rightAlign(b,c,f),i=this._topAlign(b,c,f,f),j=this._bottomAlign(b,c,f),k=this._centerAlign(b,c,f),l=this._middleAlign(b,c,f);return BI.each(k,function(a,d){b.left=d.end.left-c.width/2}),BI.each(h,function(a,d){b.left=d.end.left-c.width}),BI.each(g,function(a,c){b.left=c.end.left}),BI.each(l,function(a,d){b.top=d.end.top-c.height/2}),BI.each(j,function(a,d){b.top=d.end.top-c.height}),BI.each(i,function(a,c){b.top=c.end.top}),b},getSize:function(a,b,c){var d,e=this.getAllRegions();a&&(d=this._getRegionClientPosition(a));var f=this._getRegionExcept(a,e);b=b||{left:d.left,top:d.top},c=c||{width:d.width,height:d.height};var g=this._leftAlign(b,c,f),h=this._rightAlign(b,c,f),i=this._topAlign(b,c,f,f),j=this._bottomAlign(b,c,f),k=this._centerAlign(b,c,f),l=this._middleAlign(b,c,f);return BI.each(k,function(a,d){c.width=2*(d.end.left-b.left)}),BI.each(h,function(a,d){c.width=d.end.left-b.left}),BI.each(g,function(a,b){}),BI.each(l,function(a,d){c.height=2*(d.end.top-b.top)}),BI.each(j,function(a,d){c.height=d.end.top-b.top}),BI.each(i,function(a,b){}),c},draw:function(a,b,c){var d=this;switch(this.stopDraw(),this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:var e=this._getRegionExcept(c),f=this._leftAlign(a,b,e),g=this._rightAlign(a,b,e),h=this._topAlign(a,b,e),i=this._bottomAlign(a,b,e),j=this._centerAlign(a,b,e),k=this._middleAlign(a,b,e);BI.each(j,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(g,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(f,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(k,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(i,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(h,function(a,b){d._drawOneTag(b.start,b.end)});break;case BI.Arrangement.LAYOUT_TYPE.GRID:}},addRegion:function(a,b){return this.stopDraw(),this.arrangement.addRegion(a,b)},deleteRegion:function(a){return this.arrangement.deleteRegion(a)},setRegionSize:function(a,b){return b=this.getSize(a,null,b),this.arrangement.setRegionSize(a,b)},setPosition:function(a,b){if(this.stopDraw(),a.left>0&&a.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:a=this.getPosition(null,a,b),this.draw(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}var c=this.arrangement.setPosition(a,b);return c},setRegionPosition:function(a,b){if(b.left>0&&b.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:b=this.getPosition(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}return this.arrangement.setRegionPosition(a,b)},setDropPosition:function(a,b){var c=this;if(this.stopDraw(),a.left>0&&a.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:a=this.getPosition(null,a,b),this.draw(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}var d=c.arrangement.setDropPosition(a,b);return function(){d(),c.stopDraw()}},scrollInterval:function(){this.arrangement.scrollInterval.apply(this.arrangement,arguments)},scrollEnd:function(){this.arrangement.scrollEnd.apply(this.arrangement,arguments)},scrollTo:function(a){this.arrangement.scrollTo(a)},zoom:function(a){this.arrangement.zoom(a)},resize:function(){return this.arrangement.resize()},relayout:function(){return this.arrangement.relayout()},setLayoutType:function(a){this.arrangement.setLayoutType(a)},getLayoutType:function(){return this.arrangement.getLayoutType()},getLayoutRatio:function(){return this.arrangement.getLayoutRatio()},getHelper:function(){return this.arrangement.getHelper()},getRegionByName:function(a){return this.arrangement.getRegionByName(a)},getAllRegions:function(){return this.arrangement.getAllRegions()},revoke:function(){return this.arrangement.revoke()},populate:function(a){this.arrangement.populate(a)}}),BI.InteractiveArrangement.EVENT_RESIZE="InteractiveArrangement.EVENT_RESIZE",BI.InteractiveArrangement.EVENT_SCROLL="InteractiveArrangement.EVENT_SCROLL",BI.shortcut("bi.interactive_arrangement",BI.InteractiveArrangement),BI.MonthCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-month-combo",behaviors:{},height:25})},_init:function(){BI.MonthCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.month_trigger"}),this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM,function(b){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getValue()):this.getKey()||a.setValue(),a.fireEvent(BI.MonthCombo.EVENT_CONFIRM))}),this.trigger.on(BI.MonthTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.MonthTrigger.EVENT_START,function(){a.combo.hideView()}),this.trigger.on(BI.MonthTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.popup=BI.createWidget({type:"bi.month_popup",behaviors:b.behaviors}),this.popup.on(BI.MonthPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MonthCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,el:this.popup}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){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),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 a=this,b=this.options,c=[0,6,1,7,2,8,3,9,4,10,5,11],d=[];d.push(c.slice(0,2)),d.push(c.slice(2,4)),d.push(c.slice(4,6)),d.push(c.slice(6,8)),d.push(c.slice(8,10)),d.push(c.slice(10,12)),d=BI.map(d,function(a,b){return BI.map(b,function(a,b){return{type:"bi.text_item",cls:"bi-list-item-active",textAlign:"center",whiteSpace:"nowrap",once:!1,forceSelected:!0,height:23,width:38,value:b,text:b+1}})}),this.month=BI.createWidget({type:"bi.button_group",element:this,behaviors:b.behaviors,items:BI.createItems(d,{}),layouts:[BI.LogicFactory.createLogic("table",BI.extend({dynamic:!0},{columns:2,rows:6,columnSize:[.5,.5],rowSize:25})),{type:"bi.center_adapt",vgap:1,hgap:2}]}),this.month.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),b===BI.Events.CLICK&&a.fireEvent(BI.MonthPopup.EVENT_CHANGE)})},getValue:function(){return this.month.getValue()[0]},setValue:function(a){this.month.setValue([a])}}),BI.MonthPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.month_popup",BI.MonthPopup),BI.MonthTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:25,errorText:BI.i18nText("BI-Month_Trigger_Error_Text")},_defaultConfig:function(){return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-month-trigger bi-border",height:25})},_init:function(){BI.MonthTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(a){return""===a||BI.isPositiveInteger(a)&&a>=1&&a<=12},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.MonthTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.MonthTrigger.EVENT_CHANGE)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.MonthTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.MonthTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.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:c.triggerWidth},width:c.triggerWidth},{el:{type:"bi.trigger_icon_button",width:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){return BI.isNotNull(a)?(this.editor.setState(a+1),this.editor.setValue(a+1),void this.editor.setTitle(a+1)):(this.editor.setState(""),this.editor.setValue(""),void this.editor.setTitle(""))},getKey:function(){return 0|this.editor.getValue()},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),BI.MultiDateCard=BI.inherit(BI.Widget,{constants:{lgap:80,itemHeight:35,defaultEditorValue:"1"},_defaultConfig:function(){return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this,arguments),{})},dateConfig:function(){},defaultSelectedItem:function(){},_init:function(){BI.MultiDateCard.superclass._init.apply(this,arguments);var a=this;this.options;this.label=BI.createWidget({type:"bi.label",height:this.constants.itemHeight,textAlign:"left",text:BI.i18nText("BI-Multi_Date_Relative_Current_Time"),cls:"bi-multidate-inner-label bi-tips"}),this.radioGroup=BI.createWidget({type:"bi.button_group",chooseType:0,items:BI.createItems(this.dateConfig(),{type:"bi.multidate_segment",height:this.constants.itemHeight}),layouts:[{type:"bi.vertical"}]}),this.radioGroup.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CONFIRM&&a.fireEvent(BI.MultiDateCard.EVENT_CHANGE)}),this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE,function(){a.setValue(a.getValue()),a.fireEvent(BI.MultiDateCard.EVENT_CHANGE)}),BI.createWidget({element:this,type:"bi.center_adapt",lgap:this.constants.lgap,items:[{type:"bi.vertical",items:[this.label,this.radioGroup]}]})},getValue:function(){var a=this.radioGroup.getSelectedButtons()[0],b=a.getValue(),c=a.getInputValue();return{type:b,value:c}},_isTypeAvaliable:function(a){var b=!1;return BI.find(this.dateConfig(),function(c,d){if(d.value===a)return b=!0,!0}),b},setValue:function(a){var b=this;BI.isNotNull(a)&&this._isTypeAvaliable(a.type)?(this.radioGroup.setValue(a.type),BI.each(this.radioGroup.getAllButtons(),function(c,d){d.isEditorExist()===!0&&d.isSelected()?d.setInputValue(a.value):d.setInputValue(b.constants.defaultEditorValue)})):(this.radioGroup.setValue(this.defaultSelectedItem()),BI.each(this.radioGroup.getAllButtons(),function(a,c){c.setInputValue(b.constants.defaultEditorValue)}))},getCalculationValue:function(){var a=this.getValue(),b=a.type,c=a.value;switch(b){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:return(new Date).getOffsetDate(-1*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:return(new Date).getOffsetDate(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:return new Date;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:return(new Date).getBeforeMultiMonth(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:return(new Date).getAfterMultiMonth(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:return new Date((new Date).getFullYear(),(new Date).getMonth(),1);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:return new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getLastDateOfMonth().getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:return(new Date).getBeforeMulQuarter(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:return(new Date).getAfterMulQuarter(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:return(new Date).getQuarterStartDate();case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:return(new Date).getQuarterEndDate();case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:return(new Date).getOffsetDate(-7*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:return(new Date).getOffsetDate(7*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:return new Date((new Date).getFullYear()-1*c,(new Date).getMonth(),(new Date).getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:return new Date((new Date).getFullYear()+1*c,(new Date).getMonth(),(new Date).getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:return new Date((new Date).getFullYear(),0,1);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:return new Date((new Date).getFullYear(),11,31)}}}),BI.MultiDateCard.EVENT_CHANGE="EVENT_CHANGE",BI.MultiDateCombo=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"},_defaultConfig:function(){return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-combo bi-border",height:24})},_init:function(){BI.MultiDateCombo.superclass._init.apply(this,arguments);var a=this;this.options;this.storeTriggerValue="";var b=new Date;this.storeValue=null,this.trigger=BI.createWidget({type:"bi.date_trigger",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.DateTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK,function(){a.combo.toggle()}),this.trigger.on(BI.DateTrigger.EVENT_FOCUS,function(){a.storeTriggerValue=a.trigger.getKey(),a.combo.isViewVisible()||a.combo.showView(),a.fireEvent(BI.MultiDateCombo.EVENT_FOCUS)}),this.trigger.on(BI.DateTrigger.EVENT_ERROR,function(){a.storeValue={year:b.getFullYear(),month:b.getMonth()},a.popup.setValue(),a.fireEvent(BI.MultiDateCombo.EVENT_ERROR)}),this.trigger.on(BI.DateTrigger.EVENT_VALID,function(){a.fireEvent(BI.MultiDateCombo.EVENT_VALID)}),this.trigger.on(BI.DateTrigger.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDateCombo.EVENT_CHANGE)}),this.trigger.on(BI.DateTrigger.EVENT_CONFIRM,function(){if(!a.combo.isViewVisible()){var b=a.storeTriggerValue,c=a.trigger.getKey();BI.isNotEmptyString(c)&&!BI.isEqual(c,b)?(a.storeValue=a.trigger.getValue(),a.setValue(a.trigger.getValue())):BI.isEmptyString(c)&&(a.storeValue=null,a.trigger.setValue()),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}}),this.popup=BI.createWidget({type:"bi.multidate_popup",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE,function(){a.setValue(),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE,function(){var b=new Date;a.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,adjustLength:this.constants.comboAdjustHeight,popup:{el:this.popup,maxHeight:this.constants.popupHeight,width:this.constants.popupWidth,stopPropagation:!1}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.popup.setValue(a.storeValue),a.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW)});var c=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-font",width:30,height:23});c.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.combo.isViewVisible()?a.combo.hideView():a.combo.showView()}),this.changeIcon=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-change-h-font",width:30,height:23});var d=BI.createWidget({type:"bi.absolute",items:[{el:this.combo,top:0,left:0,right:0,bottom:0},{el:c,top:0,left:0}]});BI.createWidget({type:"bi.htape",element:this,items:[d,{el:this.changeIcon,width:30}],ref:function(b){a.comboWrapper=b}})},_checkDynamicValue:function(a){var b=null;switch(BI.isNotNull(a)&&(b=a.type),b){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: -case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:this.changeIcon.setVisible(!0),this.comboWrapper.attr("items")[1].width=30,this.comboWrapper.resize();break;default:this.comboWrapper.attr("items")[1].width=0,this.comboWrapper.resize(),this.changeIcon.setVisible(!1)}},setValue:function(a){this.storeValue=a,this.popup.setValue(a),this.trigger.setValue(a),this._checkDynamicValue(a)},getValue:function(){return this.storeValue},getKey:function(){return this.trigger.getKey()},hidePopupView:function(){this.combo.hideView()}}),BI.shortcut("bi.multidate_combo",BI.MultiDateCombo),BI.MultiDateCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.MultiDateCombo.EVENT_FOCUS="EVENT_FOCUS",BI.MultiDateCombo.EVENT_CHANGE="EVENT_CHANGE",BI.MultiDateCombo.EVENT_VALID="EVENT_VALID",BI.MultiDateCombo.EVENT_ERROR="EVENT_ERROR",BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW="BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW",BI.extend(BI.MultiDateCombo,{MULTI_DATE_YMD_CARD:1,MULTI_DATE_YEAR_CARD:2,MULTI_DATE_QUARTER_CARD:3,MULTI_DATE_MONTH_CARD:4,MULTI_DATE_WEEK_CARD:5,MULTI_DATE_DAY_CARD:6}),BI.extend(BI.MultiDateCombo,{DATE_TYPE:{MULTI_DATE_YEAR_PREV:1,MULTI_DATE_YEAR_AFTER:2,MULTI_DATE_YEAR_BEGIN:3,MULTI_DATE_YEAR_END:4,MULTI_DATE_MONTH_PREV:5,MULTI_DATE_MONTH_AFTER:6,MULTI_DATE_MONTH_BEGIN:7,MULTI_DATE_MONTH_END:8,MULTI_DATE_QUARTER_PREV:9,MULTI_DATE_QUARTER_AFTER:10,MULTI_DATE_QUARTER_BEGIN:11,MULTI_DATE_QUARTER_END:12,MULTI_DATE_WEEK_PREV:13,MULTI_DATE_WEEK_AFTER:14,MULTI_DATE_DAY_PREV:15,MULTI_DATE_DAY_AFTER:16,MULTI_DATE_DAY_TODAY:17,MULTI_DATE_PARAM:18,MULTI_DATE_CALENDAR:19,YEAR_QUARTER:20,YEAR_MONTH:21,YEAR_WEEK:22,YEAR_DAY:23,MONTH_WEEK:24,MONTH_DAY:25,YEAR:26,SAME_PERIOD:27,LAST_SAME_PERIOD:28}}),BI.DayCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.DayCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-daycard"})},_init:function(){BI.DayCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{isEditorExist:!0,selected:!0,text:BI.i18nText("BI-Multi_Date_Day_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Day_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY,text:BI.i18nText("BI-Multi_Date_Today")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV}}),BI.DayCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.daycard",BI.DayCard),BI.MonthCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-monthcard"})},_init:function(){BI.MonthCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV,text:BI.i18nText("BI-Multi_Date_Month_Prev")},{isEditorExist:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER,text:BI.i18nText("BI-Multi_Date_Month_Next")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Month_Begin")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Month_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV}}),BI.MonthCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.monthcard",BI.MonthCard),BI.MultiDatePopup=BI.inherit(BI.Widget,{constants:{tabHeight:30,tabWidth:42,titleHeight:27,itemHeight:30,triggerHeight:24,buttonWidth:90,buttonHeight:25,cardHeight:229,cardWidth:270,popupHeight:259,popupWidth:270,comboAdjustHeight:1,ymdWidth:58,lgap:2,border:1},_defaultConfig:function(){return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-popup",width:268,height:260})},_init:function(){BI.MultiDatePopup.superclass._init.apply(this,arguments);var a=this;this.options;this.storeValue="",this.textButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-label bi-border-left bi-border-right bi-border-top",shadow:!0,text:BI.i18nText("BI-Multi_Date_Today")}),this.textButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE)}),this.clearButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_Clear")}),this.clearButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE)}),this.okButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_OK")}),this.okButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE)}),this.dateTab=BI.createWidget({type:"bi.tab",tab:{cls:"bi-multidate-popup-tab bi-border-bottom",height:this.constants.tabHeight,items:BI.createItems([{text:BI.i18nText("BI-Multi_Date_YMD"),value:BI.MultiDateCombo.MULTI_DATE_YMD_CARD,width:this.constants.ymdWidth},{text:BI.i18nText("BI-Multi_Date_Year"),value:BI.MultiDateCombo.MULTI_DATE_YEAR_CARD},{text:BI.i18nText("BI-Multi_Date_Quarter"),value:BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD},{text:BI.i18nText("BI-Multi_Date_Month"),value:BI.MultiDateCombo.MULTI_DATE_MONTH_CARD},{text:BI.i18nText("BI-Multi_Date_Week"),value:BI.MultiDateCombo.MULTI_DATE_WEEK_CARD},{text:BI.i18nText("BI-Multi_Date_Day"),value:BI.MultiDateCombo.MULTI_DATE_DAY_CARD}],{width:this.constants.tabWidth,textAlign:"center",height:this.constants.itemHeight,cls:"bi-multidate-popup-item bi-list-item-active"}),layouts:[{type:"bi.left"}]},cardCreator:function(b){switch(b){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:return a.ymd=BI.createWidget({type:"bi.date_calendar_popup",min:a.options.min,max:a.options.max}),a.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE)}),a.ymd;case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:return a.year=BI.createWidget({type:"bi.yearcard"}),a.year.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.year,b)}),a.year;case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:return a.quarter=BI.createWidget({type:"bi.quartercard"}),a.quarter.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.quarter,b)}),a.quarter;case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:return a.month=BI.createWidget({type:"bi.monthcard"}),a.month.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.month,b)}),a.month;case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:return a.week=BI.createWidget({type:"bi.weekcard"}),a.week.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.week,b)}),a.week;case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:return a.day=BI.createWidget({type:"bi.daycard"}),a.day.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.day,b)}),a.day}}}),this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_YMD_CARD,this.dateTab.on(BI.Tab.EVENT_CHANGE,function(){var b=a.dateTab.getSelect();switch(b){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:var c=this.getTab(a.cur).getCalculationValue();a.ymd.setValue({year:c.getFullYear(),month:c.getMonth(),day:c.getDate()}),a._setInnerValue(a.ymd);break;case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:a.year.setValue(a.storeValue),a._setInnerValue(a.year);break;case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:a.quarter.setValue(a.storeValue),a._setInnerValue(a.quarter);break;case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:a.month.setValue(a.storeValue),a._setInnerValue(a.month);break;case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:a.week.setValue(a.storeValue),a._setInnerValue(a.week);break;case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:a.day.setValue(a.storeValue),a._setInnerValue(a.day)}a.cur=b}),this.dateButton=BI.createWidget({type:"bi.grid",items:[[this.clearButton,this.textButton,this.okButton]]}),BI.createWidget({element:this,type:"bi.vtape",items:[{el:this.dateTab},{el:this.dateButton,height:30}]})},_setInnerValue:function(a){if(this.dateTab.getSelect()===BI.MultiDateCombo.MULTI_DATE_YMD_CARD)this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")),this.textButton.setEnable(!0);else{var b=a.getCalculationValue();b=b.print("%Y-%x-%e"),this.textButton.setValue(b),this.textButton.setEnable(!1)}},setValue:function(a){this.storeValue=a;var b,c,d,e=this;switch(BI.isNotNull(a)&&(c=a.type||BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR,d=a.value,BI.isNull(d)&&(d=a)),c){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD),this.year.setValue({type:c,value:d}),this.cur=BI.MultiDateCombo.MULTI_DATE_YEAR_CARD,e._setInnerValue(this.year);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD,this.quarter.setValue({type:c,value:d}),e._setInnerValue(this.quarter);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_MONTH_CARD,this.month.setValue({type:c,value:d}),e._setInnerValue(this.month);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_WEEK_CARD,this.week.setValue({type:c,value:d}),e._setInnerValue(this.week);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_DAY_CARD,this.day.setValue({type:c,value:d}),e._setInnerValue(this.day);break;default:if(BI.isNull(d)||BI.isEmptyObject(d)){var b=new Date;this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.ymd.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"))}else this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.ymd.setValue(d),this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));this.textButton.setEnable(!0)}},getValue:function(){var a=this.dateTab.getSelect();switch(a){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:return this.ymd.getValue();case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:return this.year.getValue();case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:return this.quarter.getValue();case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:return this.month.getValue();case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:return this.week.getValue();case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:return this.day.getValue()}}}),BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE="BUTTON_OK_EVENT_CHANGE",BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE="BUTTON_lABEL_EVENT_CHANGE",BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE="BUTTON_CLEAR_EVENT_CHANGE",BI.MultiDatePopup.CALENDAR_EVENT_CHANGE="CALENDAR_EVENT_CHANGE",BI.shortcut("bi.multidate_popup",BI.MultiDatePopup),BI.QuarterCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-quartercard"})},_init:function(){BI.QuarterCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Quarter_Prev")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Quarter_Next")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Quarter_Begin")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Quarter_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV}}),BI.QuarterCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.quartercard",BI.QuarterCard),BI.MultiDateSegment=BI.inherit(BI.Single,{constants:{itemHeight:24,maxGap:15,minGap:10,textWidth:30,defaultEditorValue:"1"},_defaultConfig:function(){return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-segment",text:"",width:130,height:30,isEditorExist:!0,selected:!1,defaultEditorValue:"1"})},_init:function(){BI.MultiDateSegment.superclass._init.apply(this,arguments);var a=this,b=this.options;this.radio=BI.createWidget({type:"bi.radio",selected:b.selected}),this.radio.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.textEditor=BI.createWidget({type:"bi.text_editor",value:this.constants.defaultEditorValue,title:function(){return a.textEditor.getValue()},tipType:"success",cls:"bi-multidate-editor",width:this.constants.textWidth,height:this.constants.itemHeight}),this.textEditor.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",cls:"bi-multidate-normal-label",text:b.text,height:this.constants.itemHeight}),this._createSegment()},_createSegment:function(){return this.options.isEditorExist===!0?BI.createWidget({element:this,type:"bi.left",items:[{el:{type:"bi.center_adapt",items:[this.radio],height:this.constants.itemHeight},lgap:0},{el:{type:"bi.center_adapt",items:[this.textEditor],widgetName:"textEditor"},lgap:this.constants.maxGap},{el:this.text,lgap:this.constants.minGap}]}):BI.createWidget({element:this,type:"bi.left",items:[{el:{type:"bi.center_adapt",items:[this.radio],height:this.constants.itemHeight},lgap:0},{el:this.text,lgap:this.constants.maxGap}]})},setSelected:function(a){BI.isNotNull(this.radio)&&(this.radio.setSelected(a),this.textEditor.setEnable(a))},isSelected:function(){return this.radio.isSelected()},getValue:function(){return this.options.value},getInputValue:function(){return 0|this.textEditor.getValue()},setInputValue:function(a){this.textEditor.setValue(a)},isEditorExist:function(){return this.options.isEditorExist}}),BI.MultiDateSegment.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multidate_segment",BI.MultiDateSegment),BI.WeekCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-weekcard"})},_init:function(){BI.WeekCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Week_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Week_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV}}),BI.WeekCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.weekcard",BI.WeekCard),BI.YearCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.YearCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-yearcard"})},_init:function(){BI.YearCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Year_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Year_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN,text:BI.i18nText("BI-Multi_Date_Year_Begin")},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END,text:BI.i18nText("BI-Multi_Date_Year_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV}}),BI.YearCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.yearcard",BI.YearCard),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:!1,height:30,text:"",items:[]})},_init:function(){BI.MultiLayerSelectTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.multilayer_select_tree_popup",isDefaultInit:b.isDefaultInit,items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE)})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.MultiLayerSelectTreeCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_tree_combo",BI.MultiLayerSelectTreeCombo),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:!1,items:[],itemsCreator:BI.emptyFn})},_init:function(){BI.MultiLayerSelectLevelTree.superclass._init.apply(this,arguments),this.initTree(this.options.items)},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={};if(e.layer=b,BI.isKey(e.id)||(e.id=BI.UUID()),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.multilayer_select_tree_first_plus_group_node";break;case a.length-1:f.type="bi.multilayer_select_tree_last_plus_group_node";break;default:f.type="bi.multilayer_select_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children,b+1)}else{switch(d){case a.length-1:f.type="bi.multilayer_single_tree_last_tree_leaf_item";break;default:f.type="bi.multilayer_single_tree_mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_assertId:function(a){BI.each(a,function(a,b){b.id=b.id||BI.UUID()})},initTree:function(a){var b=this,c=this.options;this.empty(),this._assertId(a),this.tree=BI.createWidget({type:"bi.custom_tree",element:this,expander:{type:"bi.select_tree_expander",isDefaultInit:c.isDefaultInit,el:{},popup:{type:"bi.custom_tree"}},items:this._formatItems(BI.Tree.transformToTreeFormat(a),0),itemsCreator:c.itemsCreator,el:{type:"bi.button_tree",chooseType:BI.Selection.Single,layouts:[{type:"bi.vertical"}]}}),this.tree.on(BI.Controller.EVENT_CHANGE,function(a){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE,arguments)})},populate:function(a){this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(a),0))},setValue:function(a){this.tree.setValue(a)},getValue:function(){return this.tree.getValue()},getAllLeaves:function(){return this.tree.getAllLeaves()},getNodeById:function(a){return this.tree.getNodeById(a)},getNodeByValue:function(a){return this.tree.getNodeByValue(a)}}),BI.MultiLayerSelectLevelTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_level_tree",BI.MultiLayerSelectLevelTree),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:!1,itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSelectTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.multilayer_select_level_tree",isDefaultInit:b.isDefaultInit,items:b.items,itemsCreator:b.itemsCreator}),BI.createWidget({type:"bi.vertical",scrolly:!1,scrollable:!0,element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.MultiLayerSelectTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.MultiLayerSelectTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_tree_popup",BI.MultiLayerSelectTreePopup),BI.MultiLayerSelectTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_first_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},isOnce:function(){return!0},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(a){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.NodeButton.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_first_plus_group_node",BI.MultiLayerSelectTreeFirstPlusGroupNode),BI.MultiLayerSelectTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_last_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_last_plus_group_node",BI.MultiLayerSelectTreeLastPlusGroupNode),BI.MultiLayerSelectTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_mid_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node",BI.MultiLayerSelectTreeMidPlusGroupNode),BI.MultiLayerSingleTreeCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multilayer-singletree-combo",isDefaultInit:!1,height:30,text:"",itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSingleTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.multilayer_single_tree_popup",isDefaultInit:b.isDefaultInit,items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE)})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.MultiLayerSingleTreeCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_tree_combo",BI.MultiLayerSingleTreeCombo),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:!1,items:[],itemsCreator:BI.emptyFn})},_init:function(){BI.MultiLayerSingleLevelTree.superclass._init.apply(this,arguments),this.initTree(this.options.items)},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={};if(e.layer=b,BI.isKey(e.id)||(e.id=BI.UUID()),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.multilayer_single_tree_first_plus_group_node";break;case a.length-1:f.type="bi.multilayer_single_tree_last_plus_group_node";break;default:f.type="bi.multilayer_single_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children,b+1)}else{switch(d){case a.length-1:f.type="bi.multilayer_single_tree_last_tree_leaf_item";break;default:f.type="bi.multilayer_single_tree_mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_assertId:function(a){BI.each(a,function(a,b){b.id=b.id||BI.UUID()})},initTree:function(a){var b=this,c=this.options;this.empty(),this._assertId(a),this.tree=BI.createWidget({type:"bi.custom_tree",element:this,expander:{isDefaultInit:c.isDefaultInit,el:{},popup:{type:"bi.custom_tree"}},items:this._formatItems(BI.Tree.transformToTreeFormat(a),0),itemsCreator:function(a,b){c.itemsCreator(a,function(a){b(BI.Tree.transformToTreeFormat(a),0)})},el:{type:"bi.button_tree",chooseType:BI.Selection.Single,layouts:[{type:"bi.vertical"}]}}),this.tree.on(BI.Controller.EVENT_CHANGE,function(a,c){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE,c)})},populate:function(a){this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(a),0))},setValue:function(a){this.tree.setValue(a)},getValue:function(){return this.tree.getValue()},getAllLeaves:function(){return this.tree.getAllLeaves()},getNodeById:function(a){return this.tree.getNodeById(a)},getNodeByValue:function(a){return this.tree.getNodeByValue(a)}}),BI.MultiLayerSingleLevelTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_level_tree",BI.MultiLayerSingleLevelTree),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:!1,itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSingleTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.multilayer_single_level_tree",isDefaultInit:b.isDefaultInit,items:b.items,itemsCreator:b.itemsCreator}),BI.createWidget({type:"bi.vertical",scrolly:!1,scrollable:!0,element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.MultiLayerSingleTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.MultiLayerSingleTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_tree_popup",BI.MultiLayerSingleTreePopup),BI.MultiLayerSingleTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments); -return BI.extend(a,{extraCls:"bi-multilayer-single-tree-first-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.first_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_first_plus_group_node",BI.MultiLayerSingleTreeFirstPlusGroupNode),BI.MultiLayerSingleTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-single-tree-last-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.last_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_last_plus_group_node",BI.MultiLayerSingleTreeLastPlusGroupNode),BI.MultiLayerSingleTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-single-tree-mid-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.mid_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node",BI.MultiLayerSingleTreeMidPlusGroupNode),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.first_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item",BI.MultiLayerSingleTreeFirstTreeLeafItem),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.last_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item",BI.MultiLayerSingleTreeLastTreeLeafItem),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.mid_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item",BI.MultiLayerSingleTreeMidTreeLeafItem),BI.MultiSelectCheckPane=BI.inherit(BI.Widget,{constants:{height:25,lgap:10,tgap: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 a=this,b=this.options;this.storeValue={},this.display=BI.createWidget({type:"bi.display_selected_list",items:b.items,itemsCreator:function(c,d){return c=BI.extend(c||{},{selectedValues:a.storeValue.value}),a.storeValue.type===BI.Selection.Multi?void d({items:BI.map(a.storeValue.value,function(a,c){var d=b.valueFormatter(c)||c;return{text:d,value:c,title:d}})}):void b.itemsCreator(c,d)}}),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(){b.onClickContinueSelect()}),BI.createWidget({type:"bi.vtape",element:this,items:[{height:this.constants.height,el:{type:"bi.left",cls:"multi-select-continue-select",items:[{el:{type:"bi.label",text:BI.i18nText("BI-Selected_Data")},lgap:this.constants.lgap,tgap:this.constants.tgap},{el:this.continueSelect,lgap:this.constants.lgap,tgap:this.constants.tgap}]}},{height:"fill",el:this.display}]})},setValue:function(a){this.storeValue=a||{}},empty:function(){this.display.empty()},populate:function(){this.display.populate.apply(this.display,arguments)}}),BI.shortcut("bi.multi_select_check_pane",BI.MultiSelectCheckPane),BI.DisplaySelectedList=BI.inherit(BI.Pane,{constants:{height:25,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 a=this,b=this.options;this.hasNext=!1,this.button_group=BI.createWidget({type:"bi.list_pane",element:this,el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},items:this._createItems(b.items),chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,layouts:[{type:"bi.vertical",lgap:10}]},itemsCreator:function(c,d){b.itemsCreator(c,function(b){a.hasNext=!!b.hasNext,d(a._createItems(b.items))})},hasNext:function(){return a.hasNext}})},_createItems:function(a){return BI.createItems(a,{type:"bi.icon_text_item",cls:"cursor-default check-font display-list-item bi-tips",once:!0,invalid:!0,selected:!0,height:this.constants.height,logic:{dynamic:!0}})},empty:function(){this.button_group.empty()},populate:function(a){0===arguments.length?this.button_group.populate():this.button_group.populate(this._createItems(a))}}),BI.shortcut("bi.display_selected_list",BI.DisplaySelectedList),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:28})},_init:function(){BI.MultiSelectCombo.superclass._init.apply(this,arguments);var a=this,b=this.options,c=function(){BI.isKey(a._startValue)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](a._startValue),a.trigger.getSearcher().setState(a.storeValue),a.trigger.getCounter().setButtonChecked(a.storeValue)};this.storeValue={},this.requesting=!1,this.trigger=BI.createWidget({type:"bi.multi_select_trigger",height:b.height,masker:{offset:{left:1,top:1,right:2,bottom:33}},valueFormatter:b.valueFormatter,itemsCreator:function(c,d){b.itemsCreator(c,function(b){1===c.times&&BI.isNotNull(c.keywords)&&a.trigger.setValue(BI.deepClone(a.getValue())),d.apply(a,arguments)})}}),this.trigger.on(BI.MultiSelectTrigger.EVENT_START,function(){a._setStartValue(""),this.getSearcher().setValue(a.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP,function(){a._setStartValue("")}),this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE,function(){var b=this.getSearcher().getKeyword();a._join({type:BI.Selection.Multi,value:[b]},function(){a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a.combo.setValue(a.storeValue),a._setStartValue(b),c(),a.populate(),a._setStartValue("")})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING,function(b){var d=BI.last(b);b=BI.initial(b||[]),b.length>0&&a._joinKeywords(b,function(){BI.isEndWithBlank(d)?(a.combo.setValue(a.storeValue),c(),a.combo.populate(),a._setStartValue("")):(a.combo.setValue(a.storeValue),c())})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE,function(b,d){d instanceof BI.MultiSelectBar?a._joinAll(this.getValue(),function(){c()}):a._join(this.getValue(),function(){c()})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,function(){this.getCounter().setValue(a.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK,function(){a.combo.isViewVisible()||a.combo.showView()}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,el:this.trigger,adjustLength:1,popup:{type:"bi.multi_select_popup_view",ref:function(){a.popup=this,a.trigger.setAdapter(this)},listeners:[{eventName:BI.MultiSelectPopupView.EVENT_CHANGE,action:function(){a.storeValue=this.getValue(),a._adjust(function(){c()})}},{eventName:BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,action:function(){a._defaultState()}},{eventName:BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,action:function(){a.setValue(),a._defaultState()}}],itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,onLoaded:function(){BI.nextTick(function(){a.combo.adjustWidth(),a.combo.adjustHeight(),a.trigger.getCounter().adjustView(),a.trigger.getSearcher().adjustView()})}},hideChecker:function(a){return 0===d.element.find(a.target).length}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){this.setValue(a.storeValue),BI.nextTick(function(){a.populate()})}),this.wants2Quit=!1,this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW,function(){a.trigger.stopEditing(),a.requesting===!0?a.wants2Quit=!0:a.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM)});var d=BI.createWidget({type:"bi.trigger_icon_button",width:b.height,height:b.height,cls:"multi-select-trigger-icon-button bi-border-left"});d.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.trigger.getCounter().hideView(),a.combo.isViewVisible()?a.combo.hideView():a.combo.showView()}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.combo,left:0,right:0,top:0,bottom:0},{el:d,right:0,top:0,bottom:0}]})},_defaultState:function(){this.trigger.stopEditing(),this.combo.hideView()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},_makeMap:function(a){return BI.makeObject(a||[])},_joinKeywords:function(a,b){function c(c){var e=d._makeMap(c);BI.each(a,function(a,b){BI.isNotNull(e[b])&&d.storeValue.value[d.storeValue.type===BI.Selection.Multi?"pushDistinct":"remove"](b)}),d._adjust(b)}var d=this,e=this.options;this._assertValue(this.storeValue),this.requesting=!0,e.itemsCreator({type:BI.MultiSelectCombo.REQ_GET_ALL_DATA,keywords:a},function(a){var b=BI.pluck(a.items,"value");c(b)})},_joinAll:function(a,b){var c=this,d=this.options;this._assertValue(a),this.requesting=!0,d.itemsCreator({type:BI.MultiSelectCombo.REQ_GET_ALL_DATA,keywords:[this.trigger.getKey()]},function(d){var e=BI.pluck(d.items,"value");if(c.storeValue.type===a.type){var f=!1,g=c._makeMap(c.storeValue.value);return BI.each(e,function(a,b){BI.isNotNull(g[b])&&(f=!0,delete g[b])}),f&&(c.storeValue.value=BI.values(g)),void c._adjust(b)}var h=c._makeMap(c.storeValue.value),i=c._makeMap(a.value),j=[];BI.each(e,function(a,b){BI.isNotNull(h[e[a]])&&delete h[e[a]],BI.isNull(i[e[a]])&&j.push(b)}),c.storeValue.value=j.concat(BI.values(h)),c._adjust(b)})},_adjust:function(a){function b(){c.wants2Quit===!0&&(c.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM),c.wants2Quit=!1),c.requesting=!1}var c=this;this.options;b(),a()},_join:function(a,b){var c=this;this.options;if(this._assertValue(a),this._assertValue(this.storeValue),this.storeValue.type===a.type){var d=this._makeMap(this.storeValue.value);BI.each(a.value,function(a,b){d[b]||(c.storeValue.value.push(b),d[b]=b)});var e=!1;return BI.each(a.assist,function(a,b){BI.isNotNull(d[b])&&(e=!0,delete d[b])}),e&&(this.storeValue.value=BI.values(d)),void c._adjust(b)}this._joinAll(a,b)},_setStartValue:function(a){this._startValue=a,this.popup.setStartValue(a)},setValue:function(a){this.storeValue=a||{},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:0,REQ_GET_ALL_DATA:-1}),BI.MultiSelectCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.shortcut("bi.multi_select_combo",BI.MultiSelectCombo),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:!0},el:{height:400},valueFormatter:BI.emptyFn,itemsCreator:BI.emptyFn,onLoaded:BI.emptyFn})},_init:function(){BI.MultiSelectLoader.superclass._init.apply(this,arguments);var a=this,b=this.options,c=!1;this.button_group=BI.createWidget({type:"bi.select_list",element:this,logic:b.logic,el:BI.extend({onLoaded:b.onLoaded,el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},el:{chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,behaviors:{redmark:function(){return!0}},layouts:[{type:"bi.vertical"}]}}},b.el),itemsCreator:function(d,e){var f=a._startValue;a.storeValue&&(d=BI.extend(d||{},{selectedValues:BI.isKey(f)&&a.storeValue.type===BI.Selection.Multi?a.storeValue.value.concat(f):a.storeValue.value})),b.itemsCreator(d,function(g){c=g.hasNext;var h=[];if(1===d.times&&a.storeValue){var i=BI.map(a.storeValue.value,function(c,d){var e=b.valueFormatter(d)||d;return{text:e,value:d,title:e,selected:a.storeValue.type===BI.Selection.Multi}});if(BI.isKey(a._startValue)&&!a.storeValue.value.contains(a._startValue)){var j=b.valueFormatter(f)||f;i.unshift({text:j,value:f,title:j,selected:!0})}h=a._createItems(i)}e(h.concat(a._createItems(g.items)),g.keyword||""),1===d.times&&a.storeValue&&(BI.isKey(f)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](f),a.setValue(a.storeValue)),1===d.times&&a._scrollToTop()})},hasNext:function(){return c}}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.SelectList.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE,arguments)})},_createItems:function(a){return BI.createItems(a,{type:"bi.multi_select_item",logic:this.options.logic,height:25,selected:this.isAllSelected()})},_scrollToTop:function(){var a=this;BI.delay(function(){a.button_group.element.scrollTop(0)},30)},isAllSelected:function(){return this.button_group.isAllSelected()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},setStartValue:function(a){this._startValue=a},setValue:function(a){this.storeValue=a||{},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(a){this.button_group.populate.apply(this.button_group,arguments)},resetHeight:function(a){this.button_group.resetHeight(a)},resetWidth:function(a){this.button_group.resetWidth(a)}}),BI.MultiSelectLoader.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_loader",BI.MultiSelectLoader),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 a=this,b=this.options;this.loader=BI.createWidget({type:"bi.multi_select_loader",itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,onLoaded:b.onLoaded}),this.popupView=BI.createWidget({type:"bi.multi_popup_view",stopPropagation:!1,maxWidth:b.maxWidth,minWidth:b.minWidth,maxHeight:b.maxHeight,element:this,buttons:[BI.i18nText("BI-Basic_Clears"),BI.i18nText("BI-Basic_Sure")],el:this.loader}),this.popupView.on(BI.MultiPopupView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE)}),this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,function(b){switch(b){case 0:a.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);break;case 1:a.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM)}})},isAllSelected:function(){return this.loader.isAllSelected()},setStartValue:function(a){this.loader.setStartValue(a)},setValue:function(a){this.popupView.setValue(a)},getValue:function(){return this.popupView.getValue()},populate:function(a){this.popupView.populate.apply(this.popupView,arguments)},resetHeight:function(a){this.popupView.resetHeight(a)},resetWidth:function(a){this.popupView.resetWidth(a)}}),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),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 a=this,b=this.options;b.height&&this.setHeight(b.height-2),this.searcher=BI.createWidget(b.searcher,{type:"bi.multi_select_searcher",height:b.height,itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,popup:{},adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.MultiSelectSearcher.EVENT_START,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_START)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING,arguments)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_STOP)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE,arguments)}),this.numberCounter=BI.createWidget(b.switcher,{type:"bi.multi_select_check_selected_switcher",valueFormatter:b.valueFormatter,itemsCreator:b.itemsCreator,adapter:b.adapter,masker:b.masker}),this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK)}),this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW)});var c=BI.createWidget({type:"bi.right_vertical_adapt",hgap:4,items:[{el:this.numberCounter}]}),d=BI.createWidget({type:"bi.htape",element:this,items:[{el:this.searcher,width:"fill"},{el:c,width:0},{el:BI.createWidget(),width:30}]});this.numberCounter.on(BI.Events.VIEW,function(b){BI.nextTick(function(){d.attr("items")[1].width=b===!0?a.numberCounter.element.outerWidth()+8:0,d.resize()})}),this.element.click(function(b){a.element.__isMouseInBounds__(b)&&!a.numberCounter.element.__isMouseInBounds__(b)&&a.numberCounter.hideView()})},getCounter:function(){return this.numberCounter},getSearcher:function(){return this.searcher},stopEditing:function(){this.searcher.stopSearch(),this.numberCounter.hideView()},setAdapter:function(a){this.searcher.setAdapter(a),this.numberCounter.setAdapter(a)},setValue:function(a){this.searcher.setValue(a),this.numberCounter.setValue(a)},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),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 a=this,b=this.options,c=!1;this.button_group=BI.createWidget({type:"bi.select_list",element:this,logic:{dynamic:!1},el:{tipText:BI.i18nText("BI-No_Select"),el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},el:{chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,behaviors:{redmark:function(){return!0}},layouts:[{type:"bi.vertical"}]}}},itemsCreator:function(d,e){a.storeValue&&(d=BI.extend(d||{},{selectedValues:a.storeValue.value})),b.itemsCreator(d,function(f){var g=f.keyword=b.keywordGetter();c=f.hasNext;var h=[];if(1===d.times&&a.storeValue){var i=a._filterValues(a.storeValue);h=a._createItems(i)}e(h.concat(a._createItems(f.items)),g),1===d.times&&a.storeValue&&a.setValue(a.storeValue)})},hasNext:function(){return c}}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.SelectList.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE,arguments)})},_createItems:function(a){return BI.createItems(a,{type:"bi.multi_select_item",logic:{dynamic:!1},height:25,selected:this.isAllSelected()})},isAllSelected:function(){return this.button_group.isAllSelected()},_filterValues:function(a){var b=this.options,c=b.keywordGetter(),d=BI.deepClone(a.value)||[],e=BI.map(d,function(a,c){return{text:b.valueFormatter(c)||c,value:c}});if(BI.isKey(c)){var f=BI.Func.getSearchResult(e,c);d=f.matched.concat(f.finded)}return BI.map(d,function(b,c){return{text:c.text,title:c.text,value:c.value,selected:a.type===BI.Selection.All}})},setValue:function(a){this.storeValue=BI.deepClone(a),this.button_group.setValue(a)},getValue:function(){return this.button_group.getValue()},getAllButtons:function(){return this.button_group.getAllButtons()},empty:function(){this.button_group.empty()},populate:function(a){this.button_group.populate.apply(this.button_group,arguments)},resetHeight:function(a){this.button_group.resetHeight(a)},resetWidth:function(a){this.button_group.resetWidth(a)}}),BI.MultiSelectSearchLoader.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_search_loader",BI.MultiSelectSearchLoader),BI.MultiSelectSearchPane=BI.inherit(BI.Widget,{constants:{height:25,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 a=this,b=this.options;this.tooltipClick=BI.createWidget({type:"bi.label",invisible:!0,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:b.keywordGetter,valueFormatter:b.valueFormatter,itemsCreator:function(c,d){b.itemsCreator.apply(a,[c,function(c){d(c),a.setKeyword(b.keywordGetter())}])}}),this.loader.on(BI.Controller.EVENT_CHANGE,function(){a.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(!1)},setKeyword:function(a){var b,c=this.loader.getAllButtons().length>0&&(b=this.loader.getAllButtons()[0])&&a===b.getValue();c!==this.tooltipClick.isVisible()&&(this.tooltipClick.setVisible(c),this.resizer.attr("items")[0].height=c?this.constants.height:0,this.resizer.resize())},isAllSelected:function(){return this.loader.isAllSelected()},hasMatched:function(){return this.tooltipClick.isVisible()},setValue:function(a){this.loader.setValue(a)},getValue:function(){return this.loader.getValue()},empty:function(){this.loader.empty()},populate:function(a){this.loader.populate.apply(this.loader,arguments)}}),BI.MultiSelectSearchPane.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_search_pane",BI.MultiSelectSearchPane),BI.MultiSelectCheckSelectedButton=BI.inherit(BI.Single,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_defaultConfig:function(){return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multi-select-check-selected-button bi-high-light",itemsCreator:BI.emptyFn})},_init:function(){BI.MultiSelectCheckSelectedButton.superclass._init.apply(this,arguments);var a=this;this.numberCounter=BI.createWidget({type:"bi.text_button",element:this,hgap:4,text:"0",textAlign:"center",textHeight:15}),this.numberCounter.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.numberCounter.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE,arguments)}),this.numberCounter.element.hover(function(){a.numberCounter.setTag(a.numberCounter.getText()),a.numberCounter.setText(a._const.checkSelected)},function(){a.numberCounter.setText(a.numberCounter.getTag())}),this.setVisible(!1)},setValue:function(a){var b=this,c=this.options;return a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[]),a.type===BI.Selection.All?void c.itemsCreator({ -type:BI.MultiSelectCombo.REQ_GET_DATA_LENGTH},function(c){var d=c.count-a.value.length;BI.nextTick(function(){b.numberCounter.setText(d),b.setVisible(d>0)})}):void BI.nextTick(function(){b.numberCounter.setText(a.value.length),b.setVisible(a.value.length>0)})},getValue:function(){}}),BI.MultiSelectCheckSelectedButton.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_check_selected_button",BI.MultiSelectCheckSelectedButton),BI.MultiSelectEditor=BI.inherit(BI.Widget,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_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 a=this,b=this.options;this.editor=BI.createWidget(b.el,{type:"bi.state_editor",element:this,height:b.height,watermark:BI.i18nText("BI-Basic_Search"),allowBlank:!0}),this.editor.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.editor.on(BI.StateEditor.EVENT_PAUSE,function(){a.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(a){this.editor.setState(a)},setValue:function(a){this.editor.setValue(a)},getValue:function(){var a=this.editor.getState();return BI.isArray(a)&&a.length>0?a[a.length-1]:""},getKeywords:function(){var a=this.editor.getLastValidValue(),b=a.match(/[\S]+/g);return BI.isEndWithBlank(a)?b.concat([" "]):b},populate:function(a){}}),BI.MultiSelectEditor.EVENT_PAUSE="MultiSelectEditor.EVENT_PAUSE",BI.shortcut("bi.multi_select_editor",BI.MultiSelectEditor),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:{}})},_init:function(){BI.MultiSelectSearcher.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget(b.el,{type:"bi.multi_select_editor",height:b.height}),this.searcher=BI.createWidget({type:"bi.searcher",element:this,height:b.height,isAutoSearch:!1,isAutoSync:!1,onSearch:function(a,b){b()},el:this.editor,popup:BI.extend({type:"bi.multi_select_search_pane",valueFormatter:b.valueFormatter,keywordGetter:function(){return a.editor.getValue()},itemsCreator:function(c,d){c.keyword=a.editor.getValue(),this.setKeyword(c.keyword),b.itemsCreator(c,d)}},b.popup),adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.Searcher.EVENT_START,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_START)}),this.searcher.on(BI.Searcher.EVENT_PAUSE,function(){this.hasMatched(),a.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE)}),this.searcher.on(BI.Searcher.EVENT_STOP,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_STOP)}),this.searcher.on(BI.Searcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE,arguments)}),this.searcher.on(BI.Searcher.EVENT_SEARCHING,function(){var b=this.getKeywords();a.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING,b)})},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(a){this.searcher.setAdapter(a)},setState:function(a){var b=this.options;a||(a={}),a.value||(a.value=[]),a.type===BI.Selection.All?1===BI.size(a.assist)?this.editor.setState(b.valueFormatter(a.assist[0]+"")||a.assist[0]+""):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.All):1===BI.size(a.value)?this.editor.setState(b.valueFormatter(a.value[0]+"")||a.value[0]+""):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.None)},setValue:function(a){this.setState(a),this.searcher.setValue(a)},getKey:function(){return this.editor.getValue()},getValue:function(){return this.searcher.getValue()},populate:function(a){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),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 a=this,b=this.options;this.button=BI.createWidget(b.el,{type:"bi.multi_select_check_selected_button",itemsCreator:b.itemsCreator}),this.button.on(BI.Events.VIEW,function(){a.fireEvent(BI.Events.VIEW,arguments)}),this.switcher=BI.createWidget({type:"bi.switcher",toggle:!1,element:this,el:this.button,popup:BI.extend({type:"bi.multi_select_check_pane",valueFormatter:b.valueFormatter,itemsCreator:b.itemsCreator,onClickContinueSelect:function(){a.switcher.hideView()}},b.popup),adapter:b.adapter,masker:b.masker}),this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE)}),this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW)}),this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW,function(){var a=this;BI.nextTick(function(){a.populate()})}),this.switcher.element.click(function(a){a.stopPropagation()})},adjustView:function(){this.switcher.adjustView()},hideView:function(){this.switcher.empty(),this.switcher.hideView()},setAdapter:function(a){this.switcher.setAdapter(a)},setValue:function(a){this.switcher.setValue(a)},setButtonChecked:function(a){this.button.setValue(a)},getValue:function(){},populate:function(a){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),BI.MultiSelectList=BI.inherit(BI.Widget,{_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 a=this,b=this.options;this.storeValue={};var c=function(){BI.isKey(a._startValue)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](a._startValue)};this.adapter=BI.createWidget({type:"bi.multi_select_loader",cls:"popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,logic:{dynamic:!1},el:{}}),this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE,function(){a.storeValue=this.getValue(),a._adjust(function(){c(),a.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:b.valueFormatter,keywordGetter:function(){return a.trigger.getKeyword()},itemsCreator:function(c,d){c.keyword=a.trigger.getKeyword(),this.setKeyword(c.keyword),b.itemsCreator(c,d)}}),this.searcherPane.setVisible(!1),this.trigger=BI.createWidget({type:"bi.searcher",isAutoSearch:!1,isAutoSync:!1,onSearch:function(a,b){b()},adapter:this.adapter,popup:this.searcherPane,height:200,masker:!1,listeners:[{eventName:BI.Searcher.EVENT_START,action:function(){a._showSearcherPane(),a._setStartValue(""),this.setValue(BI.deepClone(a.storeValue))}},{eventName:BI.Searcher.EVENT_STOP,action:function(){a._showAdapter(),a._setStartValue(""),a.adapter.setValue(a.storeValue),a.adapter.populate()}},{eventName:BI.Searcher.EVENT_PAUSE,action:function(){var b=this.getKeyword();this.hasMatched()?a._join({type:BI.Selection.Multi,value:[b]},function(){a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a._showAdapter(),a.adapter.setValue(a.storeValue),a._setStartValue(b),c(),a.adapter.populate(),a._setStartValue(""),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)}):(a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a._showAdapter(),a.adapter.setValue(a.storeValue),a.adapter.populate(),a.storeValue.type===BI.Selection.Multi&&a.fireEvent(BI.MultiSelectList.EVENT_CHANGE))}},{eventName:BI.Searcher.EVENT_SEARCHING,action:function(){var b=this.getKeyword(),d=BI.last(b);b=BI.initial(b||[]),b.length>0&&a._joinKeywords(b,function(){BI.isEndWithBlank(d)?(a.adapter.setValue(a.storeValue),c(),a.adapter.populate(),a._setStartValue("")):(a.adapter.setValue(a.storeValue),c())})}},{eventName:BI.Searcher.EVENT_CHANGE,action:function(b,d){d instanceof BI.MultiSelectBar?a._joinAll(this.getValue(),function(){c(),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)}):a._join(this.getValue(),function(){c(),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)})}}]}),BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.trigger,height:30},{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(!0),this.searcherPane.setVisible(!1)},_showSearcherPane:function(){this.searcherPane.setVisible(!0),this.adapter.setVisible(!1)},_defaultState:function(){this.trigger.stopEditing()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},_makeMap:function(a){return BI.makeObject(a||[])},_joinKeywords:function(a,b){function c(c){var e=d._makeMap(c);BI.each(a,function(a,b){BI.isNotNull(e[b])&&d.storeValue.value[d.storeValue.type===BI.Selection.Multi?"pushDistinct":"remove"](b)}),d._adjust(b)}var d=this,e=this.options;this._assertValue(this.storeValue),this._allData?c(this._allData):e.itemsCreator({type:BI.MultiSelectList.REQ_GET_ALL_DATA},function(a){d._allData=BI.pluck(a.items,"value"),c(d._allData)})},_joinAll:function(a,b){var c=this,d=this.options;this._assertValue(a),d.itemsCreator({type:BI.MultiSelectList.REQ_GET_ALL_DATA,keyword:c.trigger.getKeyword()},function(d){var e=BI.pluck(d.items,"value");if(c.storeValue.type===a.type){var f=!1,g=c._makeMap(c.storeValue.value);return BI.each(e,function(a,b){BI.isNotNull(g[b])&&(f=!0,delete g[b])}),f&&(c.storeValue.value=BI.values(g)),void c._adjust(b)}var h=c._makeMap(c.storeValue.value),i=c._makeMap(a.value),j=[];BI.each(e,function(a,b){BI.isNotNull(h[e[a]])&&delete h[e[a]],BI.isNull(i[e[a]])&&j.push(b)}),c.storeValue.value=j.concat(BI.values(h)),c._adjust(b)})},_adjust:function(a){function b(){}this.options;b(),a()},_join:function(a,b){var c=this;this.options;if(this._assertValue(a),this._assertValue(this.storeValue),this.storeValue.type===a.type){var d=this._makeMap(this.storeValue.value);BI.each(a.value,function(a,b){d[b]||(c.storeValue.value.push(b),d[b]=b)});var e=!1;return BI.each(a.assist,function(a,b){BI.isNotNull(d[b])&&(e=!0,delete d[b])}),e&&(this.storeValue.value=BI.values(d)),void c._adjust(b)}this._joinAll(a,b)},_setStartValue:function(a){this._startValue=a,this.adapter.setStartValue(a)},isAllSelected:function(){return this.adapter.isAllSelected()},resize:function(){},setValue:function(a){this.storeValue=a||{},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:0,REQ_GET_ALL_DATA:-1}),BI.MultiSelectList.EVENT_CHANGE="BI.MultiSelectList.EVENT_CHANGE",BI.shortcut("bi.multi_select_list",BI.MultiSelectList),BI.MultiSelectTree=BI.inherit(BI.Widget,{_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 a=this,b=this.options;this.storeValue={value:{}},this.adapter=BI.createWidget({type:"bi.multi_select_tree_popup",itemsCreator:b.itemsCreator}),this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE,function(){a.searcher.isSearching()?a.storeValue={value:a.searcherPane.getValue()}:a.storeValue={value:a.adapter.getValue()},a.setSelectedValue(a.storeValue.value),a.fireEvent(BI.MultiSelectTree.EVENT_CHANGE)}),this.searcherPane=BI.createWidget({type:"bi.multi_tree_search_pane",cls:"bi-border-left bi-border-right bi-border-bottom",keywordGetter:function(){return a.searcher.getKeyword()},itemsCreator:function(c,d){c.keyword=a.searcher.getKeyword(),b.itemsCreator(c,d)}}),this.searcherPane.setVisible(!1),this.searcher=BI.createWidget({type:"bi.searcher",isAutoSearch:!1,isAutoSync:!1,onSearch:function(b,c){c({keyword:a.searcher.getKeyword()})},adapter:this.adapter,popup:this.searcherPane,masker:!1,listeners:[{eventName:BI.Searcher.EVENT_START,action:function(){a._showSearcherPane()}},{eventName:BI.Searcher.EVENT_STOP,action:function(){a._showAdapter(),BI.nextTick(function(){a.adapter.populate()})}},{eventName:BI.Searcher.EVENT_CHANGE,action:function(){a.searcher.isSearching()?a.storeValue={value:a.searcherPane.getValue()}:a.storeValue={value:a.adapter.getValue()},a.setSelectedValue(a.storeValue.value),a.fireEvent(BI.MultiSelectTree.EVENT_CHANGE)}},{eventName:BI.Searcher.EVENT_PAUSE,action:function(){a._showAdapter()}}]}),BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.searcher,height:30},{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(!0),this.searcherPane.setVisible(!1)},_showSearcherPane:function(){this.searcherPane.setVisible(!0),this.adapter.setVisible(!1)},resize:function(){},setSelectedValue:function(a){this.storeValue.value=a||{},this.adapter.setSelectedValue(a),this.searcherPane.setSelectedValue(a),this.searcher.setValue({value:a||{}})},setValue:function(a){this.adapter.setValue(a)},stopSearch:function(){this.searcher.stopSearch()},updateValue:function(a){this.adapter.updateValue(a)},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),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 a=this,b=this.options;this.popup=BI.createWidget({type:"bi.async_tree",element:this,itemsCreator:b.itemsCreator}),this.popup.on(BI.TreeView.EVENT_AFTERINIT,function(){a.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)}),this.popup.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)})},hasChecked:function(){return this.popup.hasChecked()},getValue:function(){return this.popup.getValue()},setValue:function(a){a||(a={}),this.popup.setValue(a)},setSelectedValue:function(a){a||(a={}),this.popup.setSelectedValue(a)},updateValue:function(a){this.popup.updateValue(a),this.popup.refresh()},populate:function(a){this.popup.stroke(a)}}),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),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 a=this,b=this.options;this.selectedValues={};var c=BI.createWidget({type:"bi.text_button",text:BI.i18nText("BI-Continue_Select"),cls:"multi-tree-check-selected"});c.on(BI.TextButton.EVENT_CHANGE,function(){b.onClickContinueSelect(),BI.nextTick(function(){a.empty()})});var d=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:c,lgap:this.constants.lgap,tgap:this.constants.tgap}]});this.display=BI.createWidget({type:"bi.display_tree",cls:"bi-multi-tree-display",itemsCreator:function(a,c){a.type=BI.TreeView.REQ_TYPE_GET_SELECTED_DATA,b.itemsCreator(a,c)}}),this.display.on(BI.Events.AFTERINIT,function(){a.fireEvent(BI.Events.AFTERINIT)}),this.display.on(BI.TreeView.EVENT_INIT,function(){d.setVisible(!1)}),this.display.on(BI.TreeView.EVENT_AFTERINIT,function(){d.setVisible(!0)}),BI.createWidget({type:"bi.vtape",element:this,items:[{height:this.constants.height,el:d},{height:"fill",el:this.display}]})},empty:function(){this.display.empty()},populate:function(a){this.display.stroke(a)},setValue:function(a){a||(a={}),this.display.setSelectedValue(a.value)},getValue:function(){}}),BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK="EVENT_CONTINUE_CLICK",BI.shortcut("bi.multi_tree_check_pane",BI.MultiTreeCheckPane),BI.MultiTreeCombo=BI.inherit(BI.Single,{constants:{offset:{top:1,left:1,right:2,bottom:33}},_defaultConfig:function(){return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multi-tree-combo",itemsCreator:BI.emptyFn,height:25})},_init:function(){function a(){h()?b.storeValue={value:b.trigger.getValue()}:i()&&(b.storeValue={value:b.combo.getValue()}),b.trigger.setValue(b.storeValue)}BI.MultiTreeCombo.superclass._init.apply(this,arguments);var b=this,c=this.options,d=!1,e=!1;this.trigger=BI.createWidget({type:"bi.multi_select_trigger",height:c.height,masker:{offset:this.constants.offset},searcher:{type:"bi.multi_tree_searcher",itemsCreator:c.itemsCreator},switcher:{el:{type:"bi.multi_tree_check_selected_button"},popup:{type:"bi.multi_tree_check_pane",itemsCreator:c.itemsCreator}}}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,el:this.trigger,adjustLength:1,popup:{type:"bi.multi_tree_popup_view",ref:function(){b.popup=this,b.trigger.setAdapter(this)},listeners:[{eventName:BI.MultiTreePopup.EVENT_AFTERINIT,action:function(){b.trigger.getCounter().adjustView(),d=!0,e===!0&&a()}},{eventName:BI.MultiTreePopup.EVENT_CHANGE,action:function(){f=!0;var a={type:BI.Selection.Multi,value:this.hasChecked()?{1:1}:{}};b.trigger.getSearcher().setState(a),b.trigger.getCounter().setButtonChecked(a)}},{eventName:BI.MultiTreePopup.EVENT_CLICK_CONFIRM,action:function(){b.combo.hideView()}},{eventName:BI.MultiTreePopup.EVENT_CLICK_CLEAR,action:function(){g=!0,b.setValue(),b._defaultState()}}],itemsCreator:c.itemsCreator,onLoaded:function(){BI.nextTick(function(){b.trigger.getCounter().adjustView(),b.trigger.getSearcher().adjustView()})}},hideChecker:function(a){return 0===j.element.find(a.target).length}}),this.storeValue={value:{}};var f=!1,g=!1,h=function(){return b.trigger.getSearcher().isSearching()},i=function(){return b.combo.isViewVisible()};this.trigger.on(BI.MultiSelectTrigger.EVENT_START,function(){b.storeValue={value:b.combo.getValue()},this.setValue(b.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP,function(){b.storeValue={value:this.getValue()},b.combo.setValue(b.storeValue),BI.nextTick(function(){i()&&b.combo.populate()})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,function(){e===!1&&(e=!0),d===!0&&(e=null,a())}),this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK,function(){b.combo.toggle()}),this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK,function(){b.combo.isViewVisible()||b.combo.showView()}),this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE,function(){var a={type:BI.Selection.Multi,value:this.getSearcher().hasChecked()?{1:1}:{}};this.getSearcher().setState(a),this.getCounter().setButtonChecked(a)}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){h()||(f===!0&&(b.storeValue={value:b.combo.getValue()},f=!1),b.combo.setValue(b.storeValue),b.populate())}),this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW,function(){h()?(b.trigger.stopEditing(),b.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM)):i()&&(b.trigger.stopEditing(),b.storeValue={value:b.combo.getValue()},g===!0&&(b.storeValue={value:{}}),b.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM)),g=!1,f=!1});var j=BI.createWidget({type:"bi.trigger_icon_button",width:c.height,height:c.height,cls:"multi-select-trigger-icon-button bi-border-left"});j.on(BI.TriggerIconButton.EVENT_CHANGE,function(){b.trigger.getCounter().hideView(),b.combo.isViewVisible()?b.combo.hideView():b.combo.showView()}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.combo,left:0,right:0,top:0,bottom:0},{el:j,right:0,top:0,bottom:0}]})},_defaultState:function(){this.trigger.stopEditing(),this.combo.hideView()},setValue:function(a){this.storeValue.value=a||{},this.combo.setValue({value:a||{}})},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),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 a=this,b=this.options;this.selectedValues={},this.tree=BI.createWidget({type:"bi.async_tree",height:400,cls:"popup-view-tree",itemsCreator:b.itemsCreator,onLoaded:b.onLoaded}),this.popupView=BI.createWidget({type:"bi.multi_popup_view",element:this,stopPropagation:!1,maxWidth:b.maxWidth,minWidth:b.minWidth,maxHeight:b.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(b){switch(b){case 0:a.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);break;case 1:a.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM)}}),this.tree.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreePopup.EVENT_CHANGE)}),this.tree.on(BI.TreeView.EVENT_AFTERINIT,function(){a.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT)})},getValue:function(){return this.tree.getValue()},setValue:function(a){a||(a={}),this.tree.setSelectedValue(a.value)},populate:function(a){this.tree.stroke(a)},hasChecked:function(){return this.tree.hasChecked()},resetHeight:function(a){this.popupView.resetHeight(a)},resetWidth:function(a){this.popupView.resetWidth(a)}}),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),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 a=this,b=this.options;this.partTree=BI.createWidget({type:"bi.part_tree",element:this,tipText:BI.i18nText("BI-No_Select"),itemsCreator:function(a,c){a.keyword=b.keywordGetter(),b.itemsCreator(a,c)}}),this.partTree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.partTree.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE)})},hasChecked:function(){return this.partTree.hasChecked()},setValue:function(a){this.setSelectedValue(a.value)},setSelectedValue:function(a){a||(a={}),this.partTree.setSelectedValue(a)},getValue:function(){return this.partTree.getValue()},empty:function(){this.partTree.empty()},populate:function(a){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),BI.MultiTreeCheckSelectedButton=BI.inherit(BI.Single,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_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 a=this;this.indicator=BI.createWidget({type:"bi.icon_button",cls:"check-font trigger-check-selected",width:15,height:15,stopPropagation:!0}),this.checkSelected=BI.createWidget({type:"bi.text_button",cls:"trigger-check-selected",invisible:!0,hgap:4,text:this._const.checkSelected,textAlign:"center",textHeight:15}),this.checkSelected.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.checkSelected.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE,arguments)}),BI.createWidget({type:"bi.horizontal",element:this,items:[this.indicator,this.checkSelected]}),this.element.hover(function(){a.indicator.setVisible(!1),a.checkSelected.setVisible(!0)},function(){a.indicator.setVisible(!0),a.checkSelected.setVisible(!1)}),this.setVisible(!1)},setValue:function(a){a||(a={}),this.setVisible(BI.size(a.value)>0)}}),BI.MultiTreeCheckSelectedButton.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_tree_check_selected_button",BI.MultiTreeCheckSelectedButton),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,popup:{},adapter:null,masker:{}})},_init:function(){BI.MultiTreeSearcher.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.multi_select_editor",height:b.height,el:{type:"bi.simple_state_editor",height:b.height}}),this.searcher=BI.createWidget({type:"bi.searcher",element:this,isAutoSearch:!1,isAutoSync:!1,onSearch:function(b,c){c({keyword:a.editor.getValue()})},el:this.editor,popup:BI.extend({type:"bi.multi_tree_search_pane",keywordGetter:function(){return a.editor.getValue()},itemsCreator:function(c,d){c.keyword=a.editor.getValue(),b.itemsCreator(c,d)}},b.popup),adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.Searcher.EVENT_START,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_START)}),this.searcher.on(BI.Searcher.EVENT_PAUSE,function(){this.hasMatched(),a.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE)}),this.searcher.on(BI.Searcher.EVENT_STOP,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_STOP)}),this.searcher.on(BI.Searcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE,arguments)})},adjustView:function(){this.searcher.adjustView()},setAdapter:function(a){this.searcher.setAdapter(a)},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(a){a||(a={}),a.value||(a.value=[]),a.type===BI.Selection.All?this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.All):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.None)},setValue:function(a){this.setState(a),this.searcher.setValue(a)},getKey:function(){return this.editor.getValue()},getValue:function(){return this.searcher.getValue()},populate:function(a){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),BI.NumberEditor=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-number-editor bi-border",validationChecker:function(){return!0},valueFormatter:function(a){return a},value:0,errorText:"",step:1})},_init:function(){BI.NumberEditor.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,value:b.valueFormatter(b.value),validationChecker:b.validationChecker,errorText:b.errorText}),this.editor.on(BI.TextEditor.EVENT_CHANGE,function(){b.value=this.getValue(),a.fireEvent(BI.NumberEditor.EVENT_CHANGE)}),this.editor.on(BI.TextEditor.EVENT_CONFIRM,function(){a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),this.topBtn=BI.createWidget({type:"bi.icon_button",trigger:"lclick,",cls:"column-pre-page-h-font top-button bi-border-left bi-border-bottom"}),this.topBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(b.step),a.fireEvent(BI.NumberEditor.EVENT_CHANGE),a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),this.bottomBtn=BI.createWidget({type:"bi.icon_button",trigger:"lclick,",cls:"column-next-page-h-font bottom-button bi-border-left bi-border-top"}),this.bottomBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(-b.step),a.fireEvent(BI.NumberEditor.EVENT_CHANGE),a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),BI.createWidget({type:"bi.htape",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}]})},_finetuning:function(a){var b=BI.parseFloat(this.getValue());this.setValue(b.add(a))},setUpEnable:function(a){this.topBtn.setEnable(!!a)},setDownEnable:function(a){this.bottomBtn.setEnable(!!a)},getValue:function(){return this.options.value},setValue:function(a){var b=this.options;b.value=a,this.editor.setValue(b.valueFormatter(a))}}),BI.NumberEditor.EVENT_CONFIRM="EVENT_CONFIRM",BI.NumberEditor.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.number_editor",BI.NumberEditor),BI.NumberInterval=BI.inherit(BI.Single,{constants:{typeError:"typeBubble",numberError:"numberBubble",signalError:"signalBubble",editorWidth:114,columns:5,width:30,rows:1,numberErrorCls:"number-error",border:1,less:0,less_equal:1,numTip:""},_defaultConfig:function(){var a=BI.NumberInterval.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-number-interval",height:25,validation:"valid"})},_init:function(){var a=this,b=this.constants,c=this.options;BI.NumberInterval.superclass._init.apply(this,arguments),this.smallEditor=BI.createWidget({type:"bi.editor",height:c.height-2,watermark:BI.i18nText("BI-Basic_Unrestricted"), -allowBlank:!0,value:c.min,level:"warning",tipType:"warning",quitChecker:function(){return!1},validationChecker:function(c){return!!BI.isNumeric(c)||(a.smallEditorBubbleType=b.typeError,!1)},cls:"number-interval-small-editor bi-border-top bi-border-bottom bi-border-left"}),this.smallTip=BI.createWidget({type:"bi.label",text:c.numTip,height:c.height-2,invisible:!0}),BI.createWidget({type:"bi.absolute",element:this.smallEditor.element,items:[{el:this.smallTip,top:0,right:5}]}),this.bigEditor=BI.createWidget({type:"bi.editor",height:c.height-2,watermark:BI.i18nText("BI-Basic_Unrestricted"),allowBlank:!0,value:c.max,level:"warning",tipType:"warning",quitChecker:function(){return!1},validationChecker:function(c){return!!BI.isNumeric(c)||(a.bigEditorBubbleType=b.typeError,!1)},cls:"number-interval-big-editor bi-border-top bi-border-bottom bi-border-right"}),this.bigTip=BI.createWidget({type:"bi.label",text:c.numTip,height:c.height-2,invisible:!0}),BI.createWidget({type:"bi.absolute",element:this.bigEditor.element,items:[{el:this.bigTip,top:0,right:5}]}),this.smallCombo=BI.createWidget({type:"bi.icon_combo",cls:"number-interval-small-combo bi-border",height:c.height-2,items:[{text:"("+BI.i18nText("BI-Less_Than")+")",iconClass:"less-font",value:0},{text:"("+BI.i18nText("BI-Less_And_Equal")+")",value:1,iconClass:"less-equal-font"}]}),c.closemin===!0?this.smallCombo.setValue(1):this.smallCombo.setValue(0),this.bigCombo=BI.createWidget({type:"bi.icon_combo",cls:"number-interval-big-combo bi-border",height:c.height-2,items:[{text:"("+BI.i18nText("BI-Less_Than")+")",iconClass:"less-font",value:0},{text:"("+BI.i18nText("BI-Less_And_Equal")+")",value:1,iconClass:"less-equal-font"}]}),c.closemax===!0?this.bigCombo.setValue(1):this.bigCombo.setValue(0),this.label=BI.createWidget({type:"bi.label",text:BI.i18nText("BI-Basic_Value"),textHeight:c.height-2*b.border,width:b.width-2*b.border,height:c.height-2*b.border,level:"warning",tipType:"warning"}),this.left=BI.createWidget({type:"bi.htape",items:[{el:a.smallEditor},{el:a.smallCombo,width:b.width-2*b.border}]}),this.right=BI.createWidget({type:"bi.htape",items:[{el:a.bigCombo,width:b.width-2*b.border},{el:a.bigEditor}]}),BI.createWidget({element:a,type:"bi.center",hgap:15,height:c.height,items:[{type:"bi.absolute",items:[{el:a.left,left:-15,right:0,top:0,bottom:0}]},{type:"bi.absolute",items:[{el:a.right,left:0,right:-15,top:0,bottom:0}]}]}),BI.createWidget({element:a,type:"bi.horizontal_auto",items:[a.label]}),a._setValidEvent(a.bigEditor,b.bigEditor),a._setValidEvent(a.smallEditor,b.smallEditor),a._setErrorEvent(a.bigEditor,b.bigEditor),a._setErrorEvent(a.smallEditor,b.smallEditor),a._setBlurEvent(a.bigEditor),a._setBlurEvent(a.smallEditor),a._setFocusEvent(a.bigEditor),a._setFocusEvent(a.smallEditor),a._setComboValueChangedEvent(a.bigCombo),a._setComboValueChangedEvent(a.smallCombo),a._setEditorValueChangedEvent(a.bigEditor),a._setEditorValueChangedEvent(a.smallEditor)},_checkValidation:function(){var a=this,b=this.constants,c=this.options;if(a._setTitle(""),BI.Bubbles.hide(b.typeError),BI.Bubbles.hide(b.numberError),BI.Bubbles.hide(b.signalError),a.smallEditor.isValid()&&a.bigEditor.isValid()){if(BI.isEmptyString(a.smallEditor.getValue())||BI.isEmptyString(a.bigEditor.getValue()))return a.element.removeClass("number-error"),c.validation="valid","";var d=parseFloat(a.smallEditor.getValue()),e=parseFloat(a.bigEditor.getValue()),f=a.bigCombo.getValue(),g=a.smallCombo.getValue();return f[0]===b.less_equal&&g[0]===b.less_equal?d>e?(a.element.addClass("number-error"),c.validation="invalid",b.numberError):(a.element.removeClass("number-error"),c.validation="valid",""):d>e?(a.element.addClass("number-error"),c.validation="invalid",b.numberError):d===e?(a.element.addClass("number-error"),c.validation="invalid",b.signalError):(a.element.removeClass("number-error"),c.validation="valid","")}return a.element.removeClass("number-error"),c.validation="invalid",b.typeError},_setTitle:function(a){var b=this;b.bigEditor.setTitle(a),b.smallEditor.setTitle(a),b.label.setTitle(a)},_setFocusEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_FOCUS,function(){switch(b._setTitle(""),b._checkValidation()){case c.typeError:BI.Bubbles.show(c.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),b,{offsetStyle:"center"});break;case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"});break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"});break;default:return}})},_setBlurEvent:function(a){var b=this.constants,c=this;a.on(BI.Editor.EVENT_BLUR,function(){switch(BI.Bubbles.hide(b.typeError),BI.Bubbles.hide(b.numberError),BI.Bubbles.hide(b.signalError),c._checkValidation()){case b.typeError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));break;case b.numberError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));break;case b.signalError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));break;default:c._setTitle("")}})},_setErrorEvent:function(a){var b=this.constants,c=this;a.on(BI.Editor.EVENT_ERROR,function(){c._checkValidation(),BI.Bubbles.show(b.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),c,{offsetStyle:"center"}),c.fireEvent(BI.NumberInterval.EVENT_ERROR)})},_setValidEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_VALID,function(){switch(b._checkValidation()){case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"}),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"}),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;default:b.fireEvent(BI.NumberInterval.EVENT_VALID)}})},_setEditorValueChangedEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_CHANGE,function(){switch(b._checkValidation()){case c.typeError:BI.Bubbles.show(c.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),b,{offsetStyle:"center"});break;case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"});break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"})}b.fireEvent(BI.NumberInterval.EVENT_CHANGE)})},_setComboValueChangedEvent:function(a){var b=this,c=this.constants;a.on(BI.IconCombo.EVENT_CHANGE,function(){switch(b._checkValidation()){case c.typeError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.numberError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.signalError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;default:b.fireEvent(BI.NumberInterval.EVENT_CHANGE),b.fireEvent(BI.NumberInterval.EVENT_VALID)}})},isStateValid:function(){return"valid"===this.options.validation},setMinEnable:function(a){this.smallEditor.setEnable(a)},setCloseMinEnable:function(a){this.smallCombo.setEnable(a)},setMaxEnable:function(a){this.bigEditor.setEnable(a)},setCloseMaxEnable:function(a){this.bigCombo.setEnable(a)},showNumTip:function(){this.smallTip.setVisible(!0),this.bigTip.setVisible(!0)},hideNumTip:function(){this.smallTip.setVisible(!1),this.bigTip.setVisible(!1)},setNumTip:function(a){this.smallTip.setText(a),this.bigTip.setText(a)},getNumTip:function(){return this.smallTip.getText()},setValue:function(a){a=a||{};var b,c=this;(BI.isNumeric(a.min)||BI.isEmptyString(a.min))&&c.smallEditor.setValue(a.min),BI.isNotNull(a.min)||c.smallEditor.setValue(""),(BI.isNumeric(a.max)||BI.isEmptyString(a.max))&&c.bigEditor.setValue(a.max),BI.isNotNull(a.max)||c.bigEditor.setValue(""),BI.isNull(a.closemin)||(b=a.closemin===!0?1:0,c.smallCombo.setValue(b)),BI.isNull(a.closemax)||(b=a.closemax===!0?1:0,c.bigCombo.setValue(b))},getValue:function(){var a=this,b={},c=a.smallCombo.getValue(),d=a.bigCombo.getValue();return b.min=a.smallEditor.getValue(),b.max=a.bigEditor.getValue(),0===c[0]?b.closemin=!1:b.closemin=!0,0===d[0]?b.closemax=!1:b.closemax=!0,b}}),BI.NumberInterval.EVENT_CHANGE="EVENT_CHANGE",BI.NumberInterval.EVENT_VALID="EVENT_VALID",BI.NumberInterval.EVENT_ERROR="EVENT_ERROR",BI.shortcut("bi.number_interval",BI.NumberInterval),BI.PageTableCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-page-table-cell",text:"",title:""})},_init:function(){BI.PageTableCell.superclass._init.apply(this,arguments);BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"nowrap",height:this.options.height,text:this.options.text,title:this.options.title,value:this.options.value,lgap:5,rgap:5});BI.isNotNull(this.options.styles)&&BI.isObject(this.options.styles)&&this.element.css(this.options.styles)}}),BI.shortcut("bi.page_table_cell",BI.PageTableCell),BI.PageTable=BI.inherit(BI.Widget,{_const:{scrollWidth:18,minScrollWidth:100},_defaultConfig:function(){return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-page-table",el:{type:"bi.sequence_table"},pager:{horizontal:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn},vertical:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn}},itemsCreator:BI.emptyFn,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.PageTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.hCurr=1,this.vCurr=1,this.table=BI.createWidget(b.el,{type:"bi.sequence_table",width:b.width,height:b.height&&b.height-30,isNeedResize:!0,isResizeAdapt:!1,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,minColumnSize:b.minColumnSize,maxColumnSize:b.maxColumnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)}),this.pager=BI.createWidget(b.pager,{type:"bi.direction_pager",height:30}),this.pager.on(BI.Pager.EVENT_CHANGE,function(){var c=this.getVPage&&this.getVPage();BI.isNull(c)&&(c=this.getCurrentPage());var d=this.getHPage&&this.getHPage();b.itemsCreator({vpage:c,hpage:d},function(b,e,f,g){a.table.setVPage?a.table.setVPage(c):a.table.setValue(c),a.table.setHPage&&a.table.setHPage(d),a.populate.apply(a,arguments)})}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.table,left:0,top:0},{el:this.pager,left:0,right:0,bottom:0}]})},setHPage:function(a){this.hCurr=a,this.pager.setHPage&&this.pager.setHPage(a),this.table.setHPage&&this.table.setHPage(a)},setVPage:function(a){this.vCurr=a,this.pager.setVPage&&this.pager.setVPage(a),this.table.setVPage&&this.table.setVPage(a)},getHPage:function(){var a=this.pager.getHPage&&this.pager.getHPage();return BI.isNotNull(a)?a:(a=this.pager.getCurrentPage&&this.pager.getCurrentPage(),BI.isNotNull(a)?a:this.hpage)},getVPage:function(){var a=this.pager.getVPage&&this.pager.getVPage();return BI.isNotNull(a)?a:(a=this.pager.getCurrentPage&&this.pager.getCurrentPage(),BI.isNotNull(a)?a:this.vpage)},setWidth:function(a){BI.PageTable.superclass.setWidth.apply(this,arguments),this.table.setWidth(a)},setHeight:function(a){BI.PageTable.superclass.setHeight.apply(this,arguments);var b=!1;this.pager.alwaysShowPager?b=!0:this.pager.hasHNext&&this.pager.hasHNext()?b=!0:this.pager.hasHPrev&&this.pager.hasHPrev()?b=!0:this.pager.hasVNext&&this.pager.hasVNext()?b=!0:this.pager.hasVPrev&&this.pager.hasVPrev()?b=!0:this.pager.hasNext&&this.pager.hasNext()?b=!0:this.pager.hasPrev&&this.pager.hasPrev()&&(b=!0),this.table.setHeight(a-(b?30:0))},setColumnSize:function(a){this.options.columnSize=a,this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.columnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getVerticalScroll:function(){return this.table.getVerticalScroll()},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},restore:function(){this.table.restore()},attr:function(){BI.PageTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments)},populate:function(){this.pager.populate(),this.table.populate.apply(this.table,arguments)},destroy:function(){this.table.destroy(),this.pager&&this.pager.destroy(),BI.PageTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.page_table",BI.PageTable),BI.PathChooser=BI.inherit(BI.Widget,{_const:{lineColor:"#d4dadd",selectLineColor:"#3f8ce8"},_defaultConfig:function(){return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-path-chooser",items:[]})},_init:function(){BI.PathChooser.superclass._init.apply(this,arguments),this.populate(this.options.items)},_createRegions:function(a){var b=this;this.regions=BI.createWidgets(BI.map(a,function(a,c){return{type:"bi.path_region",title:b.texts[c]||c}})),this.regionMap={},BI.each(a,function(a,c){b.regionMap[c]=a}),this.container=BI.createWidget({type:"bi.horizontal",verticalAlign:"top",scrollx:!1,scrolly:!1,hgap:10,items:this.regions}),BI.createWidget({type:"bi.vertical_adapt",element:this,scrollable:!0,hgap:10,items:[this.container]})},getRegionIndexById:function(a){var b=this.store[a],c=b.get("region");return this.regionMap[c]},_drawPath:function(a,b,c){var d=this,e=[];e=BI.contains(this.start,a)?this.start:[a],BI.each(e,function(a,b){BI.each(d.radios[b],function(a,b){b.setSelected(!1)}),BI.each(d.lines[b],function(a,b){b.attr("stroke",d._const.lineColor)}),BI.each(d.regionIndexes[b],function(a,b){d.regions[b].reset()})}),BI.each(this.routes[a][c],function(a,e){var f=d.getRegionIndexById(e);d.regions[f].setSelect(b+c,e)});for(var f=BI.last(this.routes[a][c]);f&&this.routes[f]&&1===this.routes[f].length;)BI.each(this.routes[f][0],function(a,b){var c=d.getRegionIndexById(b);d.regions[c].setSelect(0,b)}),this.lines[f][0].attr("stroke",d._const.selectLineColor).toFront(),f=BI.last(this.routes[f][0]);this.lines[a][c].attr("stroke",d._const.selectLineColor).toFront(),this.radios[a]&&this.radios[a][c]&&this.radios[a][c].setSelected(!0)},_drawRadio:function(a,b,c,d,e){var f=this,g=BI.createWidget({type:"bi.radio",cls:"path-chooser-radio",selected:b+c===0,start:a,index:c});g.on(BI.Radio.EVENT_CHANGE,function(){f._drawPath(a,b,c),f.fireEvent(BI.PathChooser.EVENT_CHANGE,a,c)}),this.radios[a]||(this.radios[a]=[]),this.radios[a].push(g),BI.createWidget({type:"bi.absolute",element:this.container,items:[{el:g,left:d-6.5,top:e-6.5}]})},_drawLine:function(a,b){var c=this;this.lines[a]||(this.lines[a]=[]),this.pathes[a]||(this.pathes[a]=[]);var d=this.getRegionIndexById(a),e=this.regions[d].getIndexByValue(a);BI.each(b,function(f,g){c.pathes[a][f]=[];var h=f+e,i="",j=47.5+29*h,k=50+100*d,l=k,m=j,n=j,o=c.getRegionIndexById(BI.last(g)),p=c.regions[o].getIndexByValue(BI.last(g)),q=50+100*o;if(BI.contains(c.start,a)?(l=k-50,i+="M"+(k-50)+","+j,c.pathes[a][f].push({x:k-50,y:j})):0===h?(l=k+50,i+="M"+k+","+j,c.pathes[a][f].push({x:k,y:j})):(l=k+50,i+="M"+k+",47.5L"+(k+50)+",47.5L"+(k+50)+","+j,c.pathes[a][f].push({x:k,y:47.5}),c.pathes[a][f].push({x:k+50,y:47.5}),c.pathes[a][f].push({x:k+50,y:j})),h>0){var r=29*p+47.5;i+="L"+(q-50)+","+n+"L"+(q-50)+","+r+"L"+q+","+r,c.pathes[a][f].push({x:q-50,y:n}),c.pathes[a][f].push({x:q-50,y:r}),c.pathes[a][f].push({x:q,y:r})}else i+="L"+q+","+n,c.pathes[a][f].push({x:q,y:n});var s=c.svg.path(i).attr({stroke:0===h?c._const.selectLineColor:c._const.lineColor,"stroke-dasharray":"-"});c.lines[a].push(s),b.length>1&&c.lines[a][0].toFront(),BI.contains(c.start,a)&&c.lines[c.regions[0].getValueByIndex(0)][0].toFront(),(b.length>1||BI.contains(c.start,a))&&c._drawRadio(a,e,f,l,m)})},_drawLines:function(a){var b=this;this.lines={},this.pathes={},this.radios={},this.regionIndexes={},BI.each(a,function(a,c){b.regionIndexes[a]||(b.regionIndexes[a]=[]),BI.each(c,function(c,d){BI.each(d,function(c,d){var e=b.getRegionIndexById(d);BI.contains(b.regionIndexes[a],e)||b.regionIndexes[a].push(e)})})}),BI.each(a,function(a,c){b._drawLine(a,c)})},_pushNodes:function(a){for(var b=this,c=[],d=0;d0||BI.contains(b.start,e))&&g.addItem(e,b.texts[e])}for(var d=BI.first(c);d0&&(h=c[b-1]);var i=a.store[h.value||""],j=a.store[g.value]||new BI.Node(g.value);j.set(g),a.store[g.value]=j,a.texts[g.value]=g.text,a.texts[g.region]=g.regionText,i=BI.isNull(i)?d.getRoot():i,i.getChildIndex(g.value)===-1&&d.addNode(i,j)})}),d.traverse(function(a){BI.each(a.getChildren(),function(b,d){if(BI.contains(c,d.get("region"))){var e=BI.indexOf(c,a.get("region")),f=BI.indexOf(c,d.get("region"));if(e>f){for(var g=c[f],h=f;h0&&(e.push(c),d.push(e),e=[]),e.push(c)}),e.length>0&&d.push(e),BI.each(d,function(a,b){var d=b[0],e=BI.findIndex(c.routes[d],function(a,c){if(BI.isEqual(b,c))return!0});if(e>=0){var f=c.getRegionIndexById(d),g=c.regions[f].getIndexByValue(d);c._drawPath(d,g,e)}})},getValue:function(){var a=[];return BI.each(this.regions,function(b,c){var d=c.getValue();BI.isKey(d)&&a.push(d)}),a}}),BI.PathChooser.EVENT_CHANGE="PathChooser.EVENT_CHANGE",BI.shortcut("bi.path_chooser",BI.PathChooser),BI.PathRegion=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-path-region bi-background",width:80,title:""})},_init:function(){BI.PathRegion.superclass._init.apply(this,arguments);var a=this.options;this.zIndex=100;var b=BI.createWidget({type:"bi.label",text:a.title,title:a.title,height:30});b.element.css("zIndex",this.zIndex--),this.items=[],this.vertical=BI.createWidget({type:"bi.vertical",element:this,bgap:5,hgap:10,items:[b]})},hasItem:function(a){return BI.any(this.items,function(b,c){return a===c.getValue()})},addItem:function(a,b){if(BI.isKey(a))var c=BI.createWidget({type:"bi.label",cls:"path-region-label bi-card bi-border bi-list-item-select",text:b,value:a,title:b||a,height:24});else var c=BI.createWidget({type:"bi.layout",height:24});c.element.css("zIndex",this.zIndex--),this.items.push(c),this.vertical.addItem(c),1===this.items.length&&this.setSelect(0,a)},reset:function(){BI.each(this.items,function(a,b){b.element.removeClass("active")})},setSelect:function(a,b){if(this.reset(),!(this.items.length<=0))return 1===this.items.length?void this.items[0].element.addClass("active"):void(this.items[a].attr("value")===b&&this.items[a].element.addClass("active"))},setValue:function(a){this.setSelect(this.getIndexByValue(a),a)},getValueByIndex:function(a){return this.items[a].attr("value")},getIndexByValue:function(a){return BI.findIndex(this.items,function(b,c){return c.attr("value")===a})},getValue:function(){var a;return BI.any(this.items,function(b,c){if(c.element.hasClass("active"))return a=c.getValue(),!0}),a}}),BI.PathRegion.EVENT_CHANGE="PathRegion.EVENT_CHANGE",BI.shortcut("bi.path_region",BI.PathRegion),BI.PreviewTableCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table-cell",text:""})},_init:function(){BI.PreviewTableCell.superclass._init.apply(this,arguments);this.options;BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"normal",height:this.options.height,text:this.options.text,value:this.options.value})}}),BI.shortcut("bi.preview_table_cell",BI.PreviewTableCell),BI.PreviewTableHeaderCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table-header-cell",text:""})},_init:function(){BI.PreviewTableHeaderCell.superclass._init.apply(this,arguments);this.options;BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"normal",height:this.options.height,text:this.options.text,value:this.options.value})}}),BI.shortcut("bi.preview_table_header_cell",BI.PreviewTableHeaderCell),BI.PreviewTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table",isNeedFreeze:!1,freezeCols:[],rowSize:null,columnSize:[],headerRowSize:30,header:[],items:[]})},_init:function(){BI.PreviewTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.table=BI.createWidget({type:"bi.table_view",element:this,isNeedResize:!1,isResizeAdapt:!1,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,rowSize:b.rowSize,columnSize:b.columnSize,headerRowSize:b.headerRowSize,header:BI.map(b.header,function(a,b){return BI.map(b,function(a,b){return BI.extend({type:"bi.preview_table_header_cell"},b)})}),items:BI.map(b.items,function(a,b){return BI.map(b,function(a,b){return BI.extend({type:"bi.preview_table_cell"},b)})})}),this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT,function(){a._adjustColumns(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT,arguments)}),this.table.on(BI.Table.EVENT_TABLE_RESIZE,function(){a._adjustColumns()})},_hasAdaptCol:function(a){return BI.any(a,function(a,b){return""===b})},_isPercentage:function(a){return a[0]<=1},_adjustColumns:function(){var a=this.options;if(a.isNeedFreeze===!0){if(this._isPercentage(a.columnSize)){if(this._hasAdaptCol(a.columnSize)){var b=[],c=0;BI.each(a.columnSize,function(a,d){""===d?b.push(a):c+=d}),c=1-c;var d=c/b.length;BI.each(b,function(b,c){a.columnSize[c]=d})}var e=0!==BI.first(a.freezeCols),f=[],g=[];BI.each(a.columnSize,function(b,c){a.freezeCols.contains(b)?f.push(c):g.push(c)});var h=BI.sum(f),i=BI.sum(g);BI.each(f,function(a,b){f[a]=b/h}),BI.each(g,function(a,b){g[a]=b/i}),this.table.setRegionColumnSize(e?["fill",h]:[h,"fill"]),this.table.setColumnSize(e?g.concat(f):f.concat(g))}}else(this._hasAdaptCol(a.columnSize)||this._isPercentage(a.columnSize))&&this.table.setRegionColumnSize(["100%"])},setColumnSize:function(a){return this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},getCalculateColumnSize:function(){return this.table.getCalculateColumnSize()},setHeaderColumnSize:function(a){return this.table.setHeaderColumnSize(a)},setRegionColumnSize:function(a){return this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getCalculateRegionColumnSize:function(){return this.table.getCalculateRegionColumnSize()},getCalculateRegionRowSize:function(){return this.table.getCalculateRegionRowSize()},getClientRegionColumnSize:function(){return this.table.getClientRegionColumnSize()},getScrollRegionColumnSize:function(){return this.table.getScrollRegionColumnSize()},getScrollRegionRowSize:function(){return this.table.getScrollRegionRowSize()},hasVerticalScroll:function(){return this.table.hasVerticalScroll()},setVerticalScroll:function(a){return this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){return this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){return this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},getColumns:function(){return this.table.getColumns()},populate:function(a,b){this.table.populate(a,b)}}),BI.PreviewTable.EVENT_CHANGE="PreviewTable.EVENT_CHANGE",BI.shortcut("bi.preview_table",BI.PreviewTable),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 a=this,b=this.options;this.storeValue="",this.trigger=BI.createWidget({type:"bi.quarter_trigger"}),this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.QuarterTrigger.EVENT_START,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.QuarterTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM,function(){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getKey()):this.getKey()||a.setValue(),a.fireEvent(BI.QuarterCombo.EVENT_CONFIRM))}),this.popup=BI.createWidget({type:"bi.quarter_popup",behaviors:b.behaviors}),this.popup.on(BI.QuarterPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.QuarterCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,el:this.popup}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){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),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 a=this,b=this.options,c=[{text:Date._QN[1],value:1},{text:Date._QN[2],value:2},{text:Date._QN[3],value:3},{text:Date._QN[4],value:4}];c=BI.map(c,function(a,b){return BI.extend(b,{type:"bi.text_item",cls:"bi-list-item-active",textAlign:"left",whiteSpace:"nowrap",once:!1,forceSelected:!0,height:25})}),this.quarter=BI.createWidget({type:"bi.button_group",element:this,behaviors:b.behaviors,items:BI.createItems(c,{}),layouts:[{type:"bi.vertical"}]}),this.quarter.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),b===BI.Events.CLICK&&a.fireEvent(BI.MonthPopup.EVENT_CHANGE)})},getValue:function(){return this.quarter.getValue()[0]},setValue:function(a){this.quarter.setValue([a])}}),BI.QuarterPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.quarter_popup",BI.QuarterPopup),BI.QuarterTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:30,textWidth:40,errorText:BI.i18nText("BI-Quarter_Trigger_Error_Text")},_defaultConfig:function(){return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-quarter-trigger bi-border",height:25})},_init:function(){BI.QuarterTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(a){return""===a||BI.isPositiveInteger(a)&&a>=1&&a<=4},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.QuarterTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.QuarterTrigger.EVENT_CHANGE)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.QuarterTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.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:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){a=a||"",this.editor.setState(a),this.editor.setValue(a),this.editor.setTitle(a)},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),BI.RelationViewItem=BI.inherit(BI.BasicButton,{_defaultConfig:function(){return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this,arguments),{ -baseCls:"bi-relation-view-item bi-list-item-active",height:25,hoverIn:BI.emptyFn,hoverOut:BI.emptyFn})},_init:function(){BI.RelationViewItem.superclass._init.apply(this,arguments);var a=this.options;this.element.hover(a.hoverIn,a.hoverOut);var b=[];a.isPrimary&&b.push({type:"bi.icon",width:16,height:16,title:BI.i18nText("BI-Primary_Key")}),b.push({type:"bi.label",text:a.text,value:a.value,height:a.height,textAlign:"left",width:a.isPrimary?70:90,lgap:a.isPrimary?0:10}),BI.createWidget({type:"bi.vertical_adapt",element:this,items:b,cls:"primary-key-font",lgap:5})},enableHover:function(a){BI.RelationViewRegion.superclass.enableHover.apply(this,[{container:"body"}])},setSelected:function(a){this.element[a?"addClass":"removeClass"]("active")}}),BI.shortcut("bi.relation_view_item",BI.RelationViewItem),BI.RelationView=BI.inherit(BI.Widget,{_const:{lineColor:"#c4c6c6",selectLineColor:"#009de3"},_defaultConfig:function(){return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view",items:[]})},_init:function(){BI.RelationView.superclass._init.apply(this,arguments),this.populate(this.options.items)},_calculateWidths:function(){var a=[];return BI.each(this.views,function(b,c){BI.each(c,function(b,c){a[b]||(a[b]=BI.MIN),a[b]=Math.max(a[b],c.getWidth())})}),a},_calculateHeights:function(){var a=BI.makeArray(BI.size(this.views),BI.MIN);return BI.each(this.views,function(b,c){BI.each(c,function(c,d){a[b]=Math.max(a[b],d.getHeight())})}),a},_hoverIn:function(a){var b=this,c=this._const;BI.each(this.relations,function(d,e){BI.each(e,function(e,f){f[0].primary.value!==a&&f[0].foreign.value!==a||(b.lines[d][e].attr("stroke",c.selectLineColor).toFront(),b.storeViews[d].setValue(f[0].primary.value),b.storeViews[e].setValue(f[0].foreign.value))})})},_hoverOut:function(a){var b=this,c=this._const;BI.each(this.relations,function(d,e){BI.each(e,function(e,f){f[0].primary.value!==a&&f[0].foreign.value!==a||(b.lines[d][e].attr("stroke",c.lineColor),b.storeViews[d].setValue([]),b.storeViews[e].setValue([]))})})},previewRelationTables:function(a,b){return b?(BI.each(this.storeViews,function(b,c){a.contains(b)?c.setPreviewSelected(!0):c.toggleRegion(!1)}),void BI.each(this.lines,function(b,c){BI.each(c,function(c,d){a.contains(b)&&a.contains(c)||d.hide()})})):(BI.each(this.storeViews,function(a,b){b.toggleRegion(!0),b.setPreviewSelected(!1)}),void BI.each(this.lines,function(a,b){BI.each(b,function(a,b){b.show()})}))},populate:function(a){var b=this,c=this.options,d=this._const;c.items=a||[],this.empty(),this.svg=BI.createWidget({type:"bi.svg"});var e=this.regions={},f=this.relations={};BI.each(a,function(a,b){var c=b.primary.region,d=b.foreign&&b.foreign.region;c&&!f[c]&&(f[c]={}),c&&d&&!f[c][d]&&(f[c][d]=[]),c&&!e[c]&&(e[c]=[]),d&&!e[d]&&(e[d]=[]),c&&!BI.deepContains(e[c],b.primary)&&e[c].push(b.primary),d&&!BI.deepContains(e[d],b.foreign)&&e[d].push(b.foreign),c&&d&&f[c][d].push(b)});for(var g=[],h=BI.clone(e),i={};!BI.isEmpty(h);){var j=BI.clone(h);BI.each(c.items,function(a,b){i[b.primary.region]||delete j[b.foreign&&b.foreign.region]}),g.push(BI.keys(j)),BI.extend(i,j),BI.each(j,function(a,b){delete h[a]})}var k=this.views={},l=this.storeViews={},m=this.indexes={},n=[];BI.each(g,function(a,c){k[a]||(k[a]={});var d=[];BI.each(c,function(c,f){var g=e[f];k[a][c]=l[f]=BI.createWidget({type:"bi.relation_view_region_container",value:f,header:g[0].regionTitle,text:g.length>0?g[0].regionText:"",handler:g.length>0?g[0].regionHandler:BI.emptyFn,items:g,belongPackage:!(g.length>0)||g[0].belongPackage}),BI.isNotNull(g[0])&&BI.isNotNull(g[0].keyword)&&k[a][c].doRedMark(g[0].keyword),k[a][c].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN,function(a){b._hoverIn(a)}),k[a][c].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT,function(a){b._hoverOut(a)}),k[a][c].on(BI.RelationViewRegionContainer.EVENT_PREVIEW,function(a){b.fireEvent(BI.RelationView.EVENT_PREVIEW,f,a)}),m[f]={i:a,j:c},d.push(k[a][c])}),n.push({type:"bi.horizontal",items:d})});var o=this._calculateHeights(),p=this._calculateWidths(),q=[0],r=[0];BI.each(o,function(a,b){0!==a&&(r[a]=r[a-1]+o[a-1])}),BI.each(p,function(a,b){0!==a&&(q[a]=q[a-1]+p[a-1])});var s=this.lines={};BI.each(f,function(a,c){BI.each(c,function(c,e){var f=m[a],g=m[c],h=0,i=1,j=2,n=3,t=j,u=h,v=function(a,b,c,d){var e,f=q[b]+(p[b]-k[a][b].getWidth())/2,g=r[a]+(o[a]-k[a][b].getHeight())/2,l="";switch(c){case h:e=d?k[a][b].getTopRightPosition():k[a][b].getTopLeftPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+f+","+(g-10),g-=10;break;case i:e=k[a][b].getRightPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+(f+10)+","+g,f+=10;break;case j:e=k[a][b].getBottomPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+f+","+(g+10),g+=10;break;case n:e=k[a][b].getLeftPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+(f-10)+","+g,f-=10}return{x:f,y:g,path:l}},w="",x=v(f.i,f.j,t),y=v(g.i,g.j,u,!0);w+=x.path+y.path,s[a]||(s[a]={}),w+="M"+x.x+","+x.y+"L"+y.x+","+y.y;var z=s[a][c]=b.svg.path(w).attr({stroke:d.lineColor,"stroke-width":"2"}).hover(function(){z.attr("stroke",d.selectLineColor).toFront(),l[a].setValue(e[0].primary.value),l[c].setValue(e[0].foreign.value)},function(){z.attr("stroke",d.lineColor),l[a].setValue([]),l[c].setValue([])})})});var t=BI.createWidget();BI.createWidget({type:"bi.vertical",element:t,items:n}),BI.createWidget({type:"bi.absolute",element:t,items:[{el:this.svg,left:0,right:0,top:0,bottom:0}]}),BI.createWidget({type:"bi.center_adapt",scrollable:!0,element:this,items:[t]})}}),BI.RelationView.EVENT_CHANGE="RelationView.EVENT_CHANGE",BI.RelationView.EVENT_PREVIEW="EVENT_PREVIEW",BI.shortcut("bi.relation_view",BI.RelationView),BI.RelationViewRegionContainer=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view-region-container",width:150})},_init:function(){BI.RelationViewRegionContainer.superclass._init.apply(this,arguments);var a=this,b=this.options;this.region=BI.createWidget({type:"bi.relation_view_region",value:b.value,header:b.header,text:b.text,handler:b.handler,items:b.items,belongPackage:b.belongPackage}),this.region.on(BI.RelationViewRegion.EVENT_PREVIEW,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW,b)}),this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN,b)}),this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT,b)}),BI.createWidget({type:"bi.vertical",element:this,items:[this.region],width:this.region.getWidth(),height:this.region.getHeight()})},doRedMark:function(){this.region.doRedMark.apply(this.region,arguments)},unRedMark:function(){this.region.unRedMark.apply(this.region,arguments)},getWidth:function(){return this.region.getWidth()},getHeight:function(){return this.region.getHeight()},getTopLeftPosition:function(){return this.region.getTopLeftPosition()},getTopRightPosition:function(){return this.region.getTopRightPosition()},getBottomPosition:function(){return this.region.getBottomPosition()},getLeftPosition:function(){return this.region.getLeftPosition()},getRightPosition:function(){return this.region.getRightPosition()},setValue:function(a){this.region.setValue(a)},toggleRegion:function(a){a===!0?this.region.element.fadeIn():this.region.element.fadeOut()},setPreviewSelected:function(a){this.region.setPreviewSelected(a)}}),BI.RelationViewRegionContainer.EVENT_HOVER_IN="RelationViewRegion.EVENT_HOVER_IN",BI.RelationViewRegionContainer.EVENT_HOVER_OUT="RelationViewRegion.EVENT_HOVER_OUT",BI.RelationViewRegionContainer.EVENT_PREVIEW="RelationViewRegion.EVENT_PREVIEW",BI.shortcut("bi.relation_view_region_container",BI.RelationViewRegionContainer),BI.RelationViewRegion=BI.inherit(BI.BasicButton,{_defaultConfig:function(){return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view-region cursor-pointer",width:150,text:"",value:"",header:"",items:[],belongPackage:!0})},_init:function(){BI.RelationViewRegion.superclass._init.apply(this,arguments);var a=this,b=this.options;this.preview=BI.createWidget({type:"bi.icon_button",cls:"relation-table-preview-font",width:25,height:25,stopPropagation:!0}),this.preview.on(BI.IconButton.EVENT_CHANGE,function(){a.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW,this.isSelected())}),this.title=BI.createWidget({type:"bi.label",height:25,width:70,text:b.text,value:b.value,textAlign:"left"}),BI.isKey(b.header)&&this.title.setTitle(b.header,{container:"body"}),this.button_group=BI.createWidget({type:"bi.button_group",items:this._createItems(b.items),layouts:[{type:"bi.vertical"}]}),BI.createWidget({type:"bi.vertical",element:this,items:[{type:"bi.vertical",cls:"relation-view-region-container bi-card bi-border "+(b.belongPackage?"":"other-package"),items:[{type:"bi.vertical_adapt",cls:"relation-view-region-title bi-border-bottom",items:[this.preview,this.title]},this.button_group]}],hgap:25,vgap:20})},_createItems:function(a){var b=this;return BI.map(a,function(a,c){return BI.extend(c,{type:"bi.relation_view_item",hoverIn:function(){b.setValue(c.value),b.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN,c.value)},hoverOut:function(){b.setValue([]),b.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT,c.value)}})})},doRedMark:function(){this.title.doRedMark.apply(this.title,arguments)},unRedMark:function(){this.title.unRedMark.apply(this.title,arguments)},getWidth:function(){return this.options.width},getHeight:function(){return 25*this.button_group.getAllButtons().length+25+40+3},getTopLeftPosition:function(){return{x:35,y:20}},getTopRightPosition:function(){return{x:this.getWidth()-25-10,y:20}},getBottomPosition:function(){return{x:35,y:this.getHeight()-20}},getLeftPosition:function(){return{x:25,y:30}},getRightPosition:function(){return{x:this.getWidth()-25,y:30}},setValue:function(a){this.button_group.setValue(a)},setPreviewSelected:function(a){this.preview.setSelected(a)}}),BI.RelationViewRegion.EVENT_HOVER_IN="RelationViewRegion.EVENT_HOVER_IN",BI.RelationViewRegion.EVENT_HOVER_OUT="RelationViewRegion.EVENT_HOVER_OUT",BI.RelationViewRegion.EVENT_PREVIEW="RelationViewRegion.EVENT_PREVIEW",BI.shortcut("bi.relation_view_region",BI.RelationViewRegion),BI.ResponisveTable=BI.inherit(BI.Widget,{_const:{perColumnSize:100},_defaultConfig:function(){return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-responsive-table",isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:function(a,b){return BI.isEqual(a,b)},columnSize:[],headerRowSize:25,footerRowSize:25,rowSize:25,regionColumnSize:!1,header:[],footer:!1,items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.ResponisveTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.table=BI.createWidget({type:"bi.table_view",element:this,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,headerRowSize:b.headerRowSize,footerRowSize:b.footerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,header:b.header,footer:b.footer,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT,function(){a._initRegionSize(),a.table.resize(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT,arguments)}),this.table.on(BI.Table.EVENT_TABLE_RESIZE,function(){a._resizeRegion(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE,function(){a.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE,function(){b.isNeedResize===!0&&a._isAdaptiveColumn()&&a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE,function(){a._resizeBody(),a.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE,function(){a.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){a._resizeRegion(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)})},_initRegionSize:function(){var a=this.options;if(a.isNeedFreeze===!0){var b=this.table.getRegionColumnSize(),c=this.table.element.width();if(!b[0]||"fill"===b[0]||b[0]>c||b[1]>c){var d=a.freezeCols;if(0===d.length)this.table.setRegionColumnSize([0,"fill"]);else if(d.length>0&&d.lengtha.columnSize.length/2&&(e=2*c/3),this.table.setRegionColumnSize([e,"fill"])}else this.table.setRegionColumnSize(["fill",0])}}},_getBlockSize:function(){var a=this.options,b=this.table.getCalculateColumnSize();if(a.isNeedFreeze===!0){var c=[],d=[];BI.each(b,function(b,e){a.freezeCols.contains(b)?c.push(e):d.push(e)});var e=BI.sum(c)+c.length,f=BI.sum(d)+d.length;return{sumLeft:e,sumRight:f,left:c,right:d}}return{size:b,sum:BI.sum(b)+b.length}},_isAdaptiveColumn:function(a){return!(BI.last(a||this.table.getColumnSize())>1.05)},_resizeHeader:function(){var a=this,b=this.options;if(b.isNeedFreeze===!0)if(this._isAdaptiveColumn()){var c=this.table.getCalculateColumnSize();this.table.setHeaderColumnSize(c)}else{var d=this.table.getClientRegionColumnSize(),e=this._getBlockSize(),f=e.sumLeft,g=e.sumRight,h=e.left,i=e.right;h[h.length-1]+=d[0]-f,i[i.length-1]+=d[1]-g;var j=BI.clone(h),k=BI.clone(i);j[j.length-1]="",k[k.length-1]="",this.table.setColumnSize(j.concat(k)),e=a._getBlockSize(),h[h.length-1]0&&a.freezeCols.length=d+e)&&this.table.setRegionColumnSize([d,"fill"]),this._resizeRegion()}},_resizeRegion:function(){var a=this.options,b=this.table.getCalculateRegionColumnSize();if(a.isNeedFreeze===!0&&a.freezeCols.length>0&&a.freezeCols.lengtha.columnSize.length/2&&(e=2*c/3),this.table.setRegionColumnSize([e,"fill"])}}},resize:function(){this.table.resize(),this._resizeRegion(),this._resizeHeader()},setColumnSize:function(a){this.table.setColumnSize(a),this._adjustRegion(),this._resizeHeader()},getColumnSize:function(){return this.table.getColumnSize()},getCalculateColumnSize:function(){return this.table.getCalculateColumnSize()},setHeaderColumnSize:function(a){this.table.setHeaderColumnSize(a),this._adjustRegion(),this._resizeHeader()},setRegionColumnSize:function(a){this.table.setRegionColumnSize(a),this._resizeHeader()},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getCalculateRegionColumnSize:function(){return this.table.getCalculateRegionColumnSize()},getCalculateRegionRowSize:function(){return this.table.getCalculateRegionRowSize()},getClientRegionColumnSize:function(){return this.table.getClientRegionColumnSize()},getScrollRegionColumnSize:function(){return this.table.getScrollRegionColumnSize()},getScrollRegionRowSize:function(){return this.table.getScrollRegionRowSize()},hasVerticalScroll:function(){return this.table.hasVerticalScroll()},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},getColumns:function(){return this.table.getColumns()},attr:function(){BI.ResponisveTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments)},populate:function(a){var b=this,c=this.options;this.table.populate.apply(this.table,arguments),c.isNeedFreeze===!0&&BI.nextTick(function(){b._initRegionSize(),b.table.resize(),b._resizeHeader()})}}),BI.shortcut("bi.responsive_table",BI.ResponisveTable),BI.SelectTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-first-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.first_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_first_plus_group_node",BI.SelectTreeFirstPlusGroupNode),BI.SelectTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-last-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.last_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_last_plus_group_node",BI.SelectTreeLastPlusGroupNode),BI.SelectTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-mid-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.mid_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_mid_plus_group_node",BI.SelectTreeMidPlusGroupNode),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:[]})},_init:function(){BI.SelectTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.select_level_tree",items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.SingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView()})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.shortcut("bi.select_tree_combo",BI.SelectTreeCombo),BI.SelectTreeExpander=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-select-tree-expander",trigger:"click",toggle:!0,direction:"bottom",isDefaultInit:!0,el:{},popup:{}})},_init:function(){BI.SelectTreeExpander.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget(BI.extend({stopPropagation:!0},b.el)),this.trigger.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&this.isSelected()&&a.expander.setValue([]),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.expander=BI.createWidget({type:"bi.expander",element:this,trigger:b.trigger,toggle:b.toggle,direction:b.direction,isDefaultInit:b.isDefaultInit,el:this.trigger,popup:b.popup}),this.expander.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&a.trigger.setSelected(!1),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)})},setValue:function(a){BI.contains(a,this.trigger.getValue())?(this.trigger.setSelected(!0),this.expander.setValue([])):(this.trigger.setSelected(!1),this.expander.setValue(a))},getValue:function(){return this.trigger.isSelected()?[this.trigger.getValue()]:this.expander.getValue()},populate:function(a){this.expander.populate(a)}}),BI.shortcut("bi.select_tree_expander",BI.SelectTreeExpander),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:[]})},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={layer:b};if(e.id=e.id||BI.UUID(),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.select_tree_first_plus_group_node";break;case a.length-1:f.type="bi.select_tree_last_plus_group_node";break;default:f.type="bi.select_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children)}else{switch(d){case a.length-1:f.type="bi.last_tree_leaf_item";break;default:f.type="bi.mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_init:function(){BI.SelectTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.level_tree",expander:{type:"bi.select_tree_expander",isDefaultInit:!0},items:this._formatItems(BI.Tree.transformToTreeFormat(b.items)),chooseType:BI.Selection.Single}),BI.createWidget({type:"bi.vertical",element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.LevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.SelectTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.SelectTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.SelectTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.select_level_tree",BI.SelectTreePopup),BI.SequenceTableDynamicNumber=BI.inherit(BI.SequenceTableTreeNumber,{_defaultConfig:function(){return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-sequence-table-dynamic-number"})},_init:function(){BI.SequenceTableDynamicNumber.superclass._init.apply(this,arguments)},_formatNumber:function(a){function b(a){var c=0;return BI.isNotEmptyArray(a.children)?(BI.each(a.children,function(a,d){c+=b(d)}),a.children.length>1&&BI.isNotEmptyArray(a.values)&&c++):c++,c}var c=this.options,d=[],e=this._getStart(a),f=0,g=0;return BI.each(a,function(a,h){BI.isArray(h.children)&&(BI.each(h.children,function(a,h){var i=b(h);d.push({text:e++,start:f,top:g,cnt:i,index:a,height:i*c.rowSize}),f+=i,g+=i*c.rowSize}),BI.isNotEmptyArray(h.values)&&(d.push({text:BI.i18nText("BI-Summary_Values"),start:f++,top:g,cnt:1,isSummary:!0,height:c.rowSize}),g+=c.rowSize))}),d}}),BI.shortcut("bi.sequence_table_dynamic_number",BI.SequenceTableDynamicNumber),BI.SequenceTableListNumber=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-sequence-table-list-number",isNeedFreeze:!1,scrollTop:0,startSequence:1,headerRowSize:25,rowSize:25,sequenceHeaderCreator:null,header:[],items:[],crossHeader:[],crossItems:[],pageSize:20})},_init:function(){BI.SequenceTableListNumber.superclass._init.apply(this,arguments);var a=this.options;this.start=a.startSequence,this.renderedCells=[],this.renderedKeys=[],this.container=BI.createWidget({type:"bi.absolute",width:60,scrollable:!1}),this.scrollContainer=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.container]}),this.headerContainer=BI.createWidget({type:"bi.absolute",cls:"bi-border",width:58,scrollable:!1}),this.layout=BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.headerContainer,height:a.headerRowSize*a.header.length-2},{el:{type:"bi.layout"},height:2},{el:this.scrollContainer}]}),this._populate()},_layout:function(){var a=this.options,b=a.headerRowSize*a.header.length-2,c=this.layout.attr("items");a.isNeedFreeze===!1?(c[0].height=0,c[1].height=0):a.isNeedFreeze===!0&&(c[0].height=b,c[1].height=2),this.layout.attr("items",c),this.layout.resize(),this.container.setHeight(a.items.length*a.rowSize);try{this.scrollContainer.element.scrollTop(a.scrollTop)}catch(d){}},_createHeader:function(){var a=this.options;BI.createWidget({type:"bi.absolute",element:this.headerContainer,items:[{el:a.sequenceHeaderCreator||{type:"bi.table_style_cell",cls:"sequence-table-title-cell",styleGetter:a.headerCellStyleGetter,text:BI.i18nText("BI-Number_Index")},left:0,top:0,right:0,bottom:0}]})},_calculateChildrenToRender:function(){for(var a=this,b=this.options,c=BI.clamp(b.scrollTop,0,b.rowSize*b.items.length-(b.height-b.header.length*b.headerRowSize)+BI.DOM.getScrollWidth()),d=Math.floor(c/b.rowSize),e=d+Math.floor((b.height-b.header.length*b.headerRowSize)/b.rowSize),f=[],g=[],h=d,i=0;h<=e&&h-1)b.rowSize!==this.renderedCells[j]._height&&(this.renderedCells[j]._height=b.rowSize,this.renderedCells[j].el.setHeight(b.rowSize)),this.renderedCells[j].top!==k&&(this.renderedCells[j].top=k,this.renderedCells[j].el.element.css("top",k+"px")),f.push(this.renderedCells[j]);else{var l=BI.createWidget(BI.extend({type:"bi.table_style_cell",cls:"sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",width:60,height:b.rowSize,text:this.start+h,styleGetter:function(c){return function(){return b.sequenceCellStyleGetter(a.start+h-1)}}(i)}));f.push({el:l,left:0,top:k,_height:b.rowSize})}g.push(this.start+h)}var m={},n={},o=[];BI.each(g,function(b,c){BI.deepContains(a.renderedKeys,c)?m[b]=c:n[b]=c}),BI.each(this.renderedKeys,function(a,b){BI.deepContains(m,b)||BI.deepContains(n,b)||o.push(a)}),BI.each(o,function(b,c){a.renderedCells[c].el.destroy()});var p=[];BI.each(n,function(a){p.push(f[a])}),BI.createWidget({type:"bi.absolute",element:this.container,items:p}),this.renderedCells=f,this.renderedKeys=g},_populate:function(){this.headerContainer.empty(),this._createHeader(),this._layout(),this._calculateChildrenToRender()},setVerticalScroll:function(a){if(this.options.scrollTop!==a){this.options.scrollTop=a;try{this.scrollContainer.element.scrollTop(a)}catch(b){}}},getVerticalScroll:function(){return this.options.scrollTop},setVPage:function(a){a=a<1?1:a;var b=this.options;this.start=(a-1)*b.pageSize+1},_restore:function(){this.options;BI.each(this.renderedCells,function(a,b){b.el.destroy()}),this.renderedCells=[],this.renderedKeys=[]},restore:function(){this._restore()},populate:function(a,b){var c=this.options;a&&a!==this.options.items&&(c.items=a,this._restore()),b&&b!==this.options.header&&(c.header=b),this._populate()}}),BI.shortcut("bi.sequence_table_list_number",BI.SequenceTableListNumber),BI.SequenceTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-sequence-table",el:{type:"bi.adaptive_table"},sequence:{},isNeedResize:!0,isResizeAdapt:!1,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[],showSequence:!1,startSequence:1})},_init:function(){BI.SequenceTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.sequence=BI.createWidget(b.sequence,{type:"bi.sequence_table_list_number",invisible:b.showSequence===!1,startSequence:b.startSequence,isNeedFreeze:b.isNeedFreeze,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems,headerRowSize:b.headerRowSize,rowSize:b.rowSize, -width:60,height:b.height&&b.height-BI.GridTableScrollbar.SIZE,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter}),this.table=BI.createWidget(b.el,{type:"bi.adaptive_table",width:b.showSequence===!0?b.width-60:b.width,height:b.height,isNeedResize:b.isNeedResize,isResizeAdapt:b.isResizeAdapt,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,minColumnSize:b.minColumnSize,maxColumnSize:b.maxColumnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(b){a.sequence.getVerticalScroll()!==this.getVerticalScroll()&&(a.sequence.setVerticalScroll(this.getVerticalScroll()),a.sequence.populate()),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)}),this.htape=BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.sequence,left:0,top:0},{el:this.table,top:0,left:b.showSequence===!0?60:0}]}),this._populate()},_populate:function(){var a=this.options;a.showSequence===!0?(this.sequence.setVisible(!0),this.table.element.css("left","60px"),this.table.setWidth(a.width-60)):(this.sequence.setVisible(!1),this.table.element.css("left","0px"),this.table.setWidth(a.width))},setWidth:function(a){BI.PageTable.superclass.setWidth.apply(this,arguments),this.table.setWidth(this.options.showSequence?a-60:a)},setHeight:function(a){BI.PageTable.superclass.setHeight.apply(this,arguments),this.table.setHeight(a),this.sequence.setHeight(a-BI.GridTableScrollbar.SIZE)},setColumnSize:function(a){this.options.columnSize=a,this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.columnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},hasLeftHorizontalScroll:function(){return this.table.hasLeftHorizontalScroll()},hasRightHorizontalScroll:function(){return this.table.hasRightHorizontalScroll()},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},setVerticalScroll:function(a){this.table.setVerticalScroll(a),this.sequence.setVerticalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},setVPage:function(a){this.sequence.setVPage&&this.sequence.setVPage(a)},setHPage:function(a){this.sequence.setHPage&&this.sequence.setHPage(a)},attr:function(){BI.SequenceTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments),this.sequence.attr.apply(this.sequence,arguments)},restore:function(){this.table.restore(),this.sequence.restore()},populate:function(a,b,c,d){var e=this.options;a&&(e.items=a),b&&(e.header=b),c&&(e.crossItems=c),d&&(e.crossHeader=d),this._populate(),this.table.populate.apply(this.table,arguments),this.sequence.populate.apply(this.sequence,arguments),this.sequence.setVerticalScroll(this.table.getVerticalScroll())},destroy:function(){this.table.destroy(),BI.SequenceTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.sequence_table",BI.SequenceTable),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:30,text:"",items:[]})},_init:function(){BI.SingleTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget(BI.extend({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items},b.trigger)),this.popup=BI.createWidget({type:"bi.single_level_tree",items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW,arguments)}),this.popup.on(BI.SingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE)})},populate:function(a){this.combo.populate(a)},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},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),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:[]})},_init:function(){BI.SingleTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.level_tree",expander:{isDefaultInit:!0},items:b.items,chooseType:BI.Selection.Single}),BI.createWidget({type:"bi.vertical",element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.LevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.SingleTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.SingleTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.SingleTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.single_level_tree",BI.SingleTreePopup),BI.SingleTreeTrigger=BI.inherit(BI.Trigger,{_defaultConfig:function(){return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-single-tree-trigger",height:30,text:"",items:[]})},_init:function(){BI.SingleTreeTrigger.superclass._init.apply(this,arguments);var a=this.options;this.trigger=BI.createWidget({type:"bi.select_text_trigger",element:this,text:a.text,items:a.items,height:a.height})},_checkTitle:function(){var a=this,b=this.getValue();BI.any(this.options.items,function(c,d){if(b.contains(d.value))return a.trigger.setTitle(d.text||d.value),!0})},setValue:function(a){a=BI.isArray(a)?a:[a],this.options.value=a,this.trigger.setValue(a),this._checkTitle()},getValue:function(){return this.options.value||[]},populate:function(a){BI.SingleTreeTrigger.superclass.populate.apply(this,arguments),this.trigger.populate(a)}}),BI.shortcut("bi.single_tree_trigger",BI.SingleTreeTrigger),BI.SwitchTree=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-switch-tree",items:[]})},_init:function(){BI.SwitchTree.superclass._init.apply(this,arguments);this.options;this.tab=BI.createWidget({type:"bi.tab",element:this,tab:null,defaultShowIndex:BI.SwitchTree.SelectType.SingleSelect,cardCreator:BI.bind(this._createTree,this)})},_createTree:function(a){var b=this,c=this.options;switch(a){case BI.SwitchTree.SelectType.SingleSelect:return this.levelTree=BI.createWidget({type:"bi.multilayer_single_level_tree",isDefaultInit:!0,items:BI.deepClone(c.items)}),this.levelTree.on(BI.LevelTree.EVENT_CHANGE,function(){b.fireEvent(BI.SwitchTree.EVENT_CHANGE,arguments)}),this.levelTree;case BI.SwitchTree.SelectType.MultiSelect:return this.tree=BI.createWidget({type:"bi.simple_tree",items:this._removeIsParent(BI.deepClone(c.items))}),this.tree.on(BI.SimpleTreeView.EVENT_CHANGE,function(){b.fireEvent(BI.SwitchTree.EVENT_CHANGE,arguments)}),this.tree}},_removeIsParent:function(a){return BI.each(a,function(a,b){BI.isNotNull(b.isParent)&&delete b.isParent}),a},switchSelect:function(){switch(this.getSelect()){case BI.SwitchTree.SelectType.SingleSelect:this.setSelect(BI.SwitchTree.SelectType.MultiSelect);break;case BI.SwitchTree.SelectType.MultiSelect:this.setSelect(BI.SwitchTree.SelectType.SingleSelect)}},setSelect:function(a){this.tab.setSelect(a)},getSelect:function(){return this.tab.getSelect()},setValue:function(a){switch(this.storeValue=a,this.getSelect()){case BI.SwitchTree.SelectType.SingleSelect:this.levelTree.setValue(a);break;case BI.SwitchTree.SelectType.MultiSelect:this.tree.setValue(a)}},getValue:function(){return this.tab.getValue()},populate:function(a){this.options.items=a,BI.isNotNull(this.levelTree)&&this.levelTree.populate(BI.deepClone(a)),BI.isNotNull(this.tree)&&this.tree.populate(this._removeIsParent(BI.deepClone(a)))}}),BI.SwitchTree.EVENT_CHANGE="SwitchTree.EVENT_CHANGE",BI.SwitchTree.SelectType={SingleSelect:BI.Selection.Single,MultiSelect:BI.Selection.Multi},BI.shortcut("bi.switch_tree",BI.SwitchTree),BI.TimeInterval=BI.inherit(BI.Single,{constants:{height:25,width:25,lgap:15,offset:-15,timeErrorCls:"time-error",DATE_MIN_VALUE:"1900-01-01",DATE_MAX_VALUE:"2099-12-31"},_defaultConfig:function(){var a=BI.TimeInterval.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-time-interval"})},_init:function(){var a=this;BI.TimeInterval.superclass._init.apply(this,arguments),this.left=this._createCombo(),this.right=this._createCombo(),this.label=BI.createWidget({type:"bi.label",height:this.constants.height,width:this.constants.width,text:"-"}),BI.createWidget({element:a,type:"bi.center",hgap:15,height:this.constants.height,items:[{type:"bi.absolute",items:[{el:a.left,left:this.constants.offset,right:0,top:0,bottom:0}]},{type:"bi.absolute",items:[{el:a.right,left:0,right:this.constants.offset,top:0,bottom:0}]}]}),BI.createWidget({type:"bi.horizontal_auto",element:this,items:[a.label]})},_createCombo:function(){var a=this,b=BI.createWidget({type:"bi.multidate_combo"});return b.on(BI.MultiDateCombo.EVENT_ERROR,function(){a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_ERROR)}),b.on(BI.MultiDateCombo.EVENT_VALID,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),BI.Bubbles.show("error",BI.i18nText("BI-Time_Interval_Error_Text"),a,{offsetStyle:"center"}),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls))}),b.on(BI.MultiDateCombo.EVENT_FOCUS,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),BI.Bubbles.show("error",BI.i18nText("BI-Time_Interval_Error_Text"),a,{offsetStyle:"center"}),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls))}),b.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW,function(){a.left.hidePopupView(),a.right.hidePopupView()}),b.on(BI.MultiDateCombo.EVENT_CONFIRM,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_CHANGE))}),b},_dateCheck:function(a){return Date.parseDateTime(a,"%Y-%x-%d").print("%Y-%x-%d")==a||Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d")==a||Date.parseDateTime(a,"%Y-%x-%e").print("%Y-%x-%e")==a||Date.parseDateTime(a,"%Y-%X-%e").print("%Y-%X-%e")==a},_checkVoid:function(a){return!Date.checkVoid(a.year,a.month,a.day,this.constants.DATE_MIN_VALUE,this.constants.DATE_MAX_VALUE)[0]},_check:function(a,b){var c=a.match(/\d+/g),d=b.match(/\d+/g);return this._dateCheck(a)&&Date.checkLegal(a)&&this._checkVoid({year:c[0],month:c[1],day:c[2]})&&this._dateCheck(b)&&Date.checkLegal(b)&&this._checkVoid({year:d[0],month:d[1],day:d[2]})},_compare:function(a,b){return a=Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d"),b=Date.parseDateTime(b,"%Y-%X-%d").print("%Y-%X-%d"),BI.isNotNull(a)&&BI.isNotNull(b)&&a>b},_setTitle:function(a){this.left.setTitle(a),this.right.setTitle(a),this.label.setTitle(a)},_clearTitle:function(){this.left.setTitle(""),this.right.setTitle(""),this.label.setTitle("")},setValue:function(a){a=a||{},this.left.setValue(a.start),this.right.setValue(a.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),BI.YearCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-combo",behaviors:{},min:"1900-01-01",max:"2099-12-31",height:25})},_init:function(){BI.YearCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.storeValue="",this.trigger=BI.createWidget({type:"bi.year_trigger",min:b.min,max:b.max}),this.trigger.on(BI.YearTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.YearTrigger.EVENT_START,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.YearTrigger.EVENT_STOP,function(){a.combo.showView()}),this.trigger.on(BI.YearTrigger.EVENT_ERROR,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.YearTrigger.EVENT_CONFIRM,function(){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getKey()):this.getKey()||a.setValue(),a.fireEvent(BI.YearCombo.EVENT_CONFIRM))}),this.combo=BI.createWidget({type:"bi.combo",element:this,destroyWhenHide:!0,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,stopPropagation:!1,el:{type:"bi.year_popup",ref:function(){a.popup=this},listeners:[{eventName:BI.YearPopup.EVENT_CHANGE,action:function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.YearCombo.EVENT_CONFIRM)}}],behaviors:b.behaviors,min:b.min,max:b.max}}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){var b=a.trigger.getKey();BI.isNotNull(b)?a.popup.setValue(b):b||b===a.storeValue?a.setValue():a.popup.setValue(a.storeValue),a.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.combo.setValue(a||"")},getValue:function(){return this.popup.getValue()}}),BI.YearCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_combo",BI.YearCombo),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(a){var b=this.options,c=this._year,d=BI.createWidget({type:"bi.year_calendar",behaviors:b.behaviors,min:b.min,max:b.max,logic:{dynamic:!0},year:c+12*a});return d.setValue(this._year),d},_init:function(){BI.YearPopup.superclass._init.apply(this,arguments);var a=this;this.selectedYear=this._year=(new Date).getFullYear();var b=BI.createWidget({type:"bi.icon_button",cls:"pre-page-h-font",width:25,height:25,value:-1}),c=BI.createWidget({type:"bi.icon_button",cls:"next-page-h-font",width:25,height:25,value:1});this.navigation=BI.createWidget({type:"bi.navigation",element:this,single:!0,logic:{dynamic:!0},tab:{cls:"year-popup-navigation bi-high-light bi-border-top",height:25,items:[b,c]},cardCreator:BI.bind(this._createYearCalendar,this),afterCardShow:function(){this.setValue(a.selectedYear);var d=this.getSelectedCard();b.setEnable(!d.isFrontYear()),c.setEnable(!d.isFinalYear())}}),this.navigation.on(BI.Navigation.EVENT_CHANGE,function(){a.selectedYear=this.getValue(),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a.fireEvent(BI.YearPopup.EVENT_CHANGE,a.selectedYear)})},getValue:function(){return this.selectedYear},setValue:function(a){var b=this.options;Date.checkVoid(a,1,1,b.min,b.max)[0]?(a=(new Date).getFullYear(),this.selectedYear="",this.navigation.setSelect(BI.YearCalendar.getPageByYear(a)),this.navigation.setValue("")):(this.selectedYear=a,this.navigation.setSelect(BI.YearCalendar.getPageByYear(a)),this.navigation.setValue(a))}}),BI.YearPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.year_popup",BI.YearPopup),BI.YearTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:25,errorText:BI.i18nText("BI-Please_Input_Positive_Integer"),errorTextInvalid:BI.i18nText("BI-Year_Trigger_Invalid_Text")},_defaultConfig:function(){return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-year-trigger bi-border",min:"1900-01-01",max:"2099-12-31",height:25})},_init:function(){BI.YearTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(d){return a.editor.setErrorText(BI.isPositiveInteger(d)?c.errorTextInvalid:c.errorText),""===d||BI.isPositiveInteger(d)&&!Date.checkVoid(d,1,1,b.min,b.max)[0]},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.YearTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.fireEvent(BI.YearTrigger.EVENT_STOP)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.YearTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.YearTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_ERROR,function(){a.fireEvent(BI.YearTrigger.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:c.triggerWidth},width:c.triggerWidth},{el:{type:"bi.trigger_icon_button",width:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){this.editor.setState(a),this.editor.setValue(a),this.editor.setTitle(a)},getKey:function(){return 0|this.editor.getValue()}}),BI.YearTrigger.EVENT_FOCUS="EVENT_FOCUS",BI.YearTrigger.EVENT_ERROR="EVENT_ERROR",BI.YearTrigger.EVENT_START="EVENT_START",BI.YearTrigger.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearTrigger.EVENT_STOP="EVENT_STOP",BI.shortcut("bi.year_trigger",BI.YearTrigger),BI.YearMonthCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-month-combo",yearBehaviors:{},monthBehaviors:{},height:25})},_init:function(){BI.YearMonthCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.year=BI.createWidget({type:"bi.year_combo",behaviors:b.yearBehaviors}),this.month=BI.createWidget({type:"bi.month_combo",behaviors:b.monthBehaviors}),this.year.on(BI.YearCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM)}),this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW)}),this.month.on(BI.MonthCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM)}),this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW)}),BI.createWidget({type:"bi.center",element:this,hgap:5,items:[this.year,this.month]})},setValue:function(a){a=a||{},this.month.setValue(a.month),this.year.setValue(a.year)},getValue:function(){return{year:this.year.getValue(),month:this.month.getValue()}}}),BI.YearMonthCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_month_combo",BI.YearMonthCombo),BI.YearQuarterCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-quarter-combo",yearBehaviors:{},quarterBehaviors:{},height:25})},_init:function(){BI.YearQuarterCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.year=BI.createWidget({type:"bi.year_combo",behaviors:b.yearBehaviors}),this.quarter=BI.createWidget({type:"bi.quarter_combo",behaviors:b.quarterBehaviors}),this.year.on(BI.YearCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM)}),this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW)}),this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM)}),this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW)}),BI.createWidget({type:"bi.center",element:this,hgap:5,items:[this.year,this.quarter]})},setValue:function(a){a=a||{},this.quarter.setValue(a.quarter),this.year.setValue(a.year)},getValue:function(){return{year:this.year.getValue(),quarter:this.quarter.getValue()}}}),BI.YearQuarterCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_quarter_combo",BI.YearQuarterCombo),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:!0})},_valueFormatter:function(a){var b=a;return BI.isNotNull(this.items)&&BI.some(this.items,function(c,d){if(d.value===a)return b=d.text,!0}),b},_itemsCreator:function(a,b){function c(c){var d=(a.keywords||[]).slice();if(a.keyword&&d.push(a.keyword),BI.each(d,function(a,b){var d=BI.Func.getSearchResult(c,b);c=d.matched.concat(d.finded)}),a.selectedValues){var e=BI.makeObject(a.selectedValues,!0);c=BI.filter(c,function(a,b){return!e[b.value]})}return a.type===BI.MultiSelectCombo.REQ_GET_ALL_DATA?void b({items:c}):a.type===BI.MultiSelectCombo.REQ_GET_DATA_LENGTH?void b({count:c.length}):void b({items:c,hasNext:!1})}var d=this,e=this.options;e.cache&&this.items?c(this.items):e.itemsCreator({},function(a){d.items=a,c(a)})}}),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:!0})},_init:function(){BI.AllValueChooserCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;BI.isNotNull(b.items)&&(this.items=b.items),this.combo=BI.createWidget({type:"bi.multi_select_combo",element:this,itemsCreator:BI.bind(this._itemsCreator,this),valueFormatter:BI.bind(this._valueFormatter,this),width:b.width,height:b.height}),this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM)})},setValue:function(a){this.combo.setValue({type:BI.Selection.Multi,value:a||[]})},getValue:function(){var a=this.combo.getValue()||{};return a.type===BI.Selection.All?a.assist:a.value||[]},populate:function(){this.combo.populate.apply(this,arguments)}}),BI.AllValueChooserCombo.EVENT_CONFIRM="AllValueChooserCombo.EVENT_CONFIRM",BI.shortcut("bi.all_value_chooser_combo",BI.AllValueChooserCombo),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:!0})},_init:function(){BI.AllValueChooserPane.superclass._init.apply(this,arguments);var a=this,b=this.options;BI.isNotNull(b.items)&&(this.items=b.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:b.width,height:b.height}),this.list.on(BI.MultiSelectList.EVENT_CHANGE,function(){a.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE)})},setValue:function(a){this.list.setValue({type:BI.Selection.Multi,value:a||[]})},getValue:function(){var a=this.list.getValue()||{};return a.type===BI.Selection.All?a.assist:a.value||[]},populate:function(){this.list.populate.apply(this.list,arguments)}}),BI.AllValueChooserPane.EVENT_CHANGE="AllValueChooserPane.EVENT_CHANGE",BI.shortcut("bi.all_value_chooser_pane",BI.AllValueChooserPane),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})},_initData:function(a){this.items=a;var b=BI.Tree.treeFormat(a);this.tree=new BI.Tree,this.tree.initTree(b)},_itemsCreator:function(a,b){function c(){switch(a.type){case BI.TreeView.REQ_TYPE_INIT_DATA:d._reqInitTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_ADJUST_DATA:d._reqAdjustTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_SELECT_DATA:d._reqSelectedTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:d._reqDisplayTreeNode(a,b);break;default:d._reqTreeNode(a,b)}}var d=this,e=this.options;this.items?c():e.itemsCreator({},function(a){d._initData(a),c()})},_reqDisplayTreeNode:function(a,b){function c(a,b,g){return null==g||BI.isEmpty(g)?void BI.each(b.getChildren(),function(d,g){var h=BI.clone(a);h.push(g.value);var i=f._getChildCount(h);e(g,b.id,i),c(h,g,{})}):void BI.each(g,function(b){var h=f._getTreeNode(a,b),i=BI.clone(a);i.push(h.value),e(h,h.parent&&h.parent.id,d(g[b],i)),c(i,h,g[b])})}function d(a,b){return null==a?0:BI.isEmpty(a)?f._getChildCount(b):BI.size(a)}function e(a,b,c){g.push({id:a.id,pId:b,text:a.text+(c>0?"("+BI.i18nText("BI-Basic_Altogether")+c+BI.i18nText("BI-Basic_Count")+")":""),value:a.value,open:!0})}var f=this,g=[],h=a.selectedValues;return null==h||BI.isEmpty(h)?void b({}):(c([],this.tree.getRoot(),h),void b({items:g}))},_reqSelectedTreeNode:function(a,b){function c(a){var b=m.concat(k);if(g(a,b))if(f(b))i._deleteNode(a,b);else{var c=[],j=e(m,k,[],c);j&&BI.isNotEmptyArray(c)&&BI.each(c,function(b,c){var e=i._getNode(a,c);e?i._deleteNode(a,c):d(a,c,BI.last(c))})}if(h(a,b)){var l=[],j=!1;f(b)?j=!0:(j=e(m,k,l),b=m),j===!0&&(d(a,b,k),l.length>0&&BI.each(l,function(b,c){i._buildTree(a,c)}))}}function d(a,b,c){var d=a,e=[],f=[];BI.some(b,function(g,h){var j=d[h];if(null==j){if(0===g)return!0;if(!BI.isEmpty(d))return!0;var k=b.slice(0,g),l=i._getChildren(k);if(f.push(k),e.push(l.length),g===b.length-1&&1===l.length&&l[0]===c)for(var m=e.length-1;m>=0&&1===e[m];m--)i._deleteNode(a,f[m]);else BI.each(l,function(a,e){return g===b.length-1&&e.value===c||void(d[e.value]={})});d=d[h]}else d=j})}function e(a,b,c,d){var f=BI.clone(a);if(f.push(b),i._isMatch(a,b,l))return d&&d.push(f),!0;var g=i._getChildren(f),h=[],j=!1;return BI.each(g,function(a,b){e(f,b.value,c,d)?j=!0:h.push(b.value)}),j===!0&&BI.each(h,function(a,b){var d=BI.clone(f);d.push(b),c.push(d)}),j}function f(a){for(var b=0,c=a.length;bj._const.perPage)break}return f}function d(a,b,c,i,k){if(j._isMatch(b,c,l)){var m=i||h(b,c);return e(b,c,!1,m,!i&&f(b,c),!0,k),[!0,m]}var n=BI.clone(b);n.push(c);var o=j._getChildren(n),p=!1,m=!1,q=i||g(b,c);return BI.each(o,function(b,c){var e=d(a+1,n,c.value,q,k);e[1]===!0&&(m=!0),e[0]===!0&&(p=!0)}),p===!0&&(m=q||h(b,c)&&m,e(b,c,!0,m,!1,!1,k)),[p,m]}function e(a,b,c,d,e,f,g){var h=j._getTreeNode(a,b);g.push({id:h.id,pId:h.pId,text:h.text,value:h.value,title:h.title,isParent:h.getChildrenLength()>0,open:c,checked:d,halfCheck:e,flag:f})}function f(a,b){var c=i(a);return null==c?null:BI.any(c,function(a,c){if(a===b&&null!=c&&!BI.isEmpty(c))return!0})}function g(a,b){var c=i(a);return null==c?null:BI.any(c,function(a,c){if(a===b&&null!=c&&BI.isEmpty(c))return!0})}function h(a,b){var c=i(a);return null!=c&&BI.any(c,function(a){if(a===b)return!0})}function i(a){var b=m;return null==b?null:(BI.every(a,function(a,c){return b=b[c],null!=b}),b)}var j=this,k=[],l=a.keyword||"",m=a.selectedValues,n=a.lastSearchValue||"",o=c();BI.nextTick(function(){b({hasNext:o.length>j._const.perPage,items:k,lastSearchValue:BI.last(o)})})},_reqTreeNode:function(a,b){function c(a,b){var c={};return BI.each(a,function(a,c){b=b[c]||{}}),BI.each(b,function(a,b){if(BI.isNull(b))return void(c[a]=[0,0]);if(BI.isEmpty(b))return void(c[a]=[2,0]);var d={};BI.each(b,function(a,b){(BI.isNull(b)||BI.isEmpty(b))&&(d[a]=!0)}),c[a]=[1,BI.size(d)]}),c}function d(a,b,c,d){var f=d.checked,g=d.half,h=!1,i=!1;if(BI.has(c,a))if(1===c[a][0]){var j=BI.clone(b);j.push(a);var k=e._getChildCount(j);k>0&&k!==c[a][1]&&(i=!0)}else 2===c[a][0]&&(h=!0);var l;return l=f||i||h?(h||f)&&!g||BI.has(c,a):BI.has(c,a),[l,i]}var e=this,f=[],g=a.times,h=a.checkState||{},i=a.parentValues||[],j=a.selectedValues||{},k={};k=c(i,j);for(var l=this._getChildren(i),m=(g-1)*this._const.perPage;l[m]&&m0,checked:n[0],halfCheck:n[1]})}BI.nextTick(function(){b({items:f,hasNext:l.length>g*e._const.perPage})})},_getNode:function(a,b){for(var c=a,d=0,e=b.length;d0&&BI.isEmpty(e);)c=d[d.length-1],d=d.slice(0,d.length-1),e=this._getNode(a,d),null!=e&&delete e[c]},_buildTree:function(a,b){var c=a;BI.each(b,function(a,b){BI.has(c,b)||(c[b]={}),c=c[b]})},_isMatch:function(a,b,c){var d=this._getTreeNode(a,b),e=BI.Func.getSearchResult([d.text||d.value],c);return e.finded.length>0||e.matched.length>0},_getTreeNode:function(a,b){var c,d=this,e=0;return this.tree.traverse(function(f){if(!d.tree.isRoot(f))return!(e>a.length)&&(e===a.length&&f.value===b?(c=f,!1):f.value!==a[e]||void e++)}),c},_getChildren:function(a){ -if(a.length>0)var b=BI.last(a),c=this._getTreeNode(a.slice(0,a.length-1),b);else var c=this.tree.getRoot();return c.getChildren()},_getChildCount:function(a){return this._getChildren(a).length}}),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 a=this,b=this.options;BI.isNotNull(b.items)&&this._initData(b.items),this.combo=BI.createWidget({type:"bi.multi_tree_combo",element:this,itemsCreator:BI.bind(this._itemsCreator,this),width:b.width,height:b.height}),this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM)})},setValue:function(a){this.combo.setValue(a)},getValue:function(){return this.combo.getValue()},populate:function(){this.combo.populate.apply(this.combo,arguments)}}),BI.TreeValueChooserCombo.EVENT_CONFIRM="TreeValueChooserCombo.EVENT_CONFIRM",BI.shortcut("bi.tree_value_chooser_combo",BI.TreeValueChooserCombo),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 a=this,b=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(){a.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE)}),BI.isNotNull(b.items)&&(this._initData(b.items),this.populate())},setSelectedValue:function(a){this.pane.setSelectedValue(a)},setValue:function(a){this.pane.setValue(a)},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),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:!0})},_valueFormatter:function(a){var b=a;return BI.isNotNull(this.items)&&BI.some(this.items,function(c,d){if(d.value===a)return b=d.text,!0}),b},_getItemsByTimes:function(a,b){for(var c=[],d=(b-1)*this._const.perPage;a[d]&&dd;"number"==typeof c&&(b.x=c),"number"==typeof d&&(b.y=d),b.moved=!0;var i=this._sortLayoutItemsByRowCol(a);h&&(i=i.reverse());for(var j=f(i,b),k=0,l=j.length;km.y&&b.y-m.y>m.h/4||(a=m._static?this._moveElementAwayFromCollision(a,m,b,e):this._moveElementAwayFromCollision(a,b,m,e))}return a},_sortLayoutItemsByRowCol:function(a){return[].concat(a).sort(function(a,b){return a.y>b.y||a.y===b.y&&a.x>b.x?1:-1})},_collides:function(a,b){return a!==b&&(!(a.x+a.w<=b.x)&&(!(a.x>=b.x+b.w)&&(!(a.y+a.h<=b.y)&&!(a.y>=b.y+b.h))))},_getFirstCollision:function(a,b){for(var c=0,d=a.length;c0&&!this._getFirstCollision(a,b);)b.y--;for(var d;d=this._getFirstCollision(a,b);)b.y=d.y+d.h;return b},compact:function(a,b){function c(a){return BI.filter(a,function(a,b){return b._static})}for(var d=c(a),e=this._sortLayoutItemsByRowCol(a),f=[],g=0,h=e.length;g0&&(this._calculateSizeAndPositionData(),this._populate()),0===b.scrollLeft&&0===b.scrollTop||BI.nextTick(function(){a.element.scrollTop(b.scrollTop),a.element.scrollLeft(b.scrollLeft)})},_onMouseWheel:function(a){var b=this.options;this._scrollLock||this._isCtrlPressed||(b.scrollTop+=-a.originalEvent.wheelDelta,b.scrollTop=BI.clamp(b.scrollTop,0,this.maxScrollTop),this._calculateChildrenToRender(),this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL,{scrollLeft:b.scrollLeft,scrollTop:b.scrollTop}))},_onResize:function(a){a.ctrlKey?this._isCtrlPressed=!0:this._isCtrlPressed=!1},_onResizeRelease:function(a){var b={CTRL:17},c=a.keyCode;c===b.CTRL&&(this._isCtrlPressed=!1)},_getMaxScrollTop:function(){return this._height-this.options.height},_calculateSizeAndPositionData:function(){for(var a=this.options,b=[],c=new BI.SectionManager,d=0,e=0,f=0,g=a.items.length;f0&&g>0){var h=this._cellRenderers(g-e,f-d,d,e);this.canvas.remove(this.scrollLeft,this.scrollTop,a.width,a.height);for(var i=0;in.height)this.canvas.text(n.x+y,n.y+z,"...",k);else if(w+4>n.width){var A=Math.floor((n.width-x-4)/w*m.length);this.canvas.text(n.x+y,n.y+z,m.slice(0,A)+"...",k)}else this.canvas.text(n.x+y,n.y+z,m,k);this.canvas.stroke()}}},_getTextPixel:function(a){var b=a.split("px")[0],c=b.split(" ");for(var d in c){var e;if(e=BI.parseInt(c[d]),!BI.isNaN(e))return e}},_calcOffsetX:function(a,b,c){switch(c){case"center":return a>=b?4:(b-a)/2;case"right":return a>=b?0:b-a;default:return 0}},_calcOffsetY:function(a,b,c){switch(c){case"center":return a>=b?a:(b+a)/2;case"bottom":return a>=b?b:b+a;default:return a}},_populate:function(a){var b=this.options;a&&a!==this.options.items&&(this.options.items=a,this._calculateSizeAndPositionData()),b.items.length>0&&(this.canvas.setBlock(),this.canvas.setWidth(b.width),this.canvas.setHeight(b.height),this.restore(),this._calculateChildrenToRender(),this.element.scrollTop(b.scrollTop),this.element.scrollLeft(b.scrollLeft))},populate:function(a){a&&a!==this.options.items&&this.restore(),this._populate(a)},setWidth:function(a){BI.CanvasCollectionView.superclass.setWidth.apply(this,arguments),this.options.width=a},setHeight:function(a){BI.CanvasCollectionView.superclass.setHeight.apply(this,arguments),this.options.height=a},restore:function(){this.canvas.remove(this.scrollLeft,this.scrollTop,this.options.width,this.options.height),this.renderedKeys=[],this._scrollLock=!1},setScrollLeft:function(a){this.options.scrollLeft!==a&&(this._scrollLock=!0,this.options.scrollLeft=a,this._debounceRelease(),this._calculateChildrenToRender(),this.element.scrollLeft(this.options.scrollLeft))},setScrollTop:function(a){this.options.scrollTop!==a&&(this._scrollLock=!0,this.options.scrollTop=a,this._debounceRelease(),this._calculateChildrenToRender(),this.element.scrollTop(this.options.scrollTop))},getScrollLeft:function(){return this.options.scrollLeft},getScrollTop:function(){return this.options.scrollTop}}),BI.CanvasCollectionView.EVENT_SCROLL="EVENT_SCROLL",BI.shortcut("bi.canvas_collection_view",BI.CanvasCollectionView),BI.CanvasTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-canvas-collection-table",headerRowSize:25,rowSize:25,columnSize:[],isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,header:[],items:[],regionColumnSize:[]})},_init:function(){BI.CanvasTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this._scrollBarSize=BI.DOM.getScrollWidth(),this.topLeftCollection=BI.createWidget({type:"bi.canvas_collection_view",cellSizeAndPositionGetter:function(b){return a.topLeftItems[b]}}),this.topRightCollection=BI.createWidget({type:"bi.canvas_collection_view",cellSizeAndPositionGetter:function(b){return a.topRightItems[b]}}),this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL,function(b){a.bottomRightCollection.setScrollLeft(b.scrollLeft),a._populateScrollbar(),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.bottomLeftCollection=BI.createWidget({type:"bi.canvas_collection_view",cellSizeAndPositionGetter:function(b){return a.bottomLeftItems[b]}}),this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL,function(b){a.bottomRightCollection.setScrollTop(b.scrollTop),a.topLeftCollection.setScrollLeft(b.scrollLeft),a._populateScrollbar(),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.bottomRightCollection=BI.createWidget({type:"bi.canvas_collection_view",cellSizeAndPositionGetter:function(b){return a.bottomRightItems[b]}}),this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL,function(b){a.bottomLeftCollection.setScrollTop(b.scrollTop),a.topRightCollection.setScrollLeft(b.scrollLeft),a._populateScrollbar(),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.topLeft=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.topLeftCollection]}),this.topRight=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.topRightCollection]}),this.bottomLeft=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.bottomLeftCollection]}),this.bottomRight=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.bottomRightCollection]}),this.contextLayout=BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.topLeft,top:0,left:0},{el:this.topRight,top:0},{el:this.bottomLeft,left:0},{el:this.bottomRight}]}),this.topScrollbar=BI.createWidget({type:"bi.grid_table_scrollbar",width:BI.GridTableScrollbar.SIZE}),this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL,function(b){a.bottomLeftCollection.setScrollTop(b),a.bottomRightCollection.setScrollTop(b),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.leftScrollbar=BI.createWidget({type:"bi.grid_table_horizontal_scrollbar",height:BI.GridTableScrollbar.SIZE}),this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL,function(b){a.topLeftCollection.setScrollLeft(b),a.bottomLeftCollection.setScrollLeft(b),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.rightScrollbar=BI.createWidget({type:"bi.grid_table_horizontal_scrollbar",height:BI.GridTableScrollbar.SIZE}),this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL,function(b){a.topRightCollection.setScrollLeft(b),a.bottomRightCollection.setScrollLeft(b),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.scrollBarLayout=BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.topScrollbar,right:0,top:0},{el:this.leftScrollbar,left:0},{el:this.rightScrollbar}]}),this._width=b.width-BI.GridTableScrollbar.SIZE,this._height=b.height-BI.GridTableScrollbar.SIZE},mounted:function(){var a=this.options;(a.items.length>0||a.header.length>0)&&(this._digest(),this._populate())},attr:function(){BI.CanvasTable.superclass.attr.apply(this,arguments)},_getFreezeColLength:function(){return this.options.isNeedFreeze?this.options.freezeCols.length:0},getRegionSize:function(){var a=this.options,b=a.regionColumnSize[0]||0;return a.isNeedFreeze===!1||0===a.freezeCols.length?0:(b||BI.each(a.freezeCols,function(c,d){b+=a.columnSize[d]}),b)},_getFreezeHeaderHeight:function(){var a=this.options;return a.header.length*a.headerRowSize>=this._height?0:a.header.length*a.headerRowSize},_getActualItems:function(){var a=this.options;return a.header.length*a.headerRowSize>=this._height?a.header.concat(a.items):a.items},_digest:function(){var a=this.options,b=this._getFreezeColLength();this._getFreezeHeaderHeight()<=0?(this.topLeftItems=[],this.topRightItems=[],this.bottomLeftItems=this._serialize(this._getActualItems(),0,b,a.rowSize,a.columnSize,a.mergeCols,BI.range(a.header.length)),this.bottomRightItems=this._serialize(this._getActualItems(),b,a.columnSize.length,a.rowSize,a.columnSize,a.mergeCols,BI.range(a.header.length))):(this.topLeftItems=this._serialize(a.header,0,b,a.headerRowSize,a.columnSize,a.mergeCols),this.topRightItems=this._serialize(a.header,b,a.columnSize.length,a.headerRowSize,a.columnSize,!0),this.bottomLeftItems=this._serialize(a.items,0,b,a.rowSize,a.columnSize,a.mergeCols),this.bottomRightItems=this._serialize(a.items,b,a.columnSize.length,a.rowSize,a.columnSize,a.mergeCols))},_populateScrollbar:function(){var a=this.options,b=this.getRegionSize(),c=0,d=0,e=0,f=[];BI.each(a.columnSize,function(b,g){a.isNeedFreeze===!0&&a.freezeCols.contains(b)?c+=g:d+=g,e+=g,0===b?f[b]=g:f[b]=f[b-1]+g}),this.topScrollbar.setContentSize(this._getActualItems().length*a.rowSize),this.topScrollbar.setSize(this._height-this._getFreezeHeaderHeight()),this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()),this.topScrollbar.populate(),this.leftScrollbar.setContentSize(c),this.leftScrollbar.setSize(b),this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft()),this.leftScrollbar.populate(),this.rightScrollbar.setContentSize(d),this.rightScrollbar.setSize(this._width-b),this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft()),this.rightScrollbar.populate();var g=this.scrollBarLayout.attr("items");g[0].top=this._getFreezeHeaderHeight(),g[1].top=this._height,g[2].top=this._height,g[2].left=b,this.scrollBarLayout.attr("items",g),this.scrollBarLayout.resize()},_populateTable:function(){var a=this.options,b=this.getRegionSize(),c=(this._getFreezeColLength(),b),d=this._getFreezeHeaderHeight(),e=this._width-b,f=this._getFreezeHeaderHeight(),g=b,h=this._height-d,i=this._width-b,j=this._height-f,k=c+this._scrollBarSize,l=d+this._scrollBarSize,m=e+this._scrollBarSize,n=f+this._scrollBarSize,o=g+this._scrollBarSize,p=h+this._scrollBarSize,q=i+this._scrollBarSize,r=j+this._scrollBarSize;this.topLeft.setWidth(c),this.topLeft.setHeight(d),this.topRight.setWidth(e),this.topRight.setHeight(f),this.bottomLeft.setWidth(g),this.bottomLeft.setHeight(h),this.bottomRight.setWidth(i),this.bottomRight.setHeight(j),this.topLeftCollection.setWidth(k),this.topLeftCollection.setHeight(l),this.topRightCollection.setWidth(m),this.topRightCollection.setHeight(n),this.bottomLeftCollection.setWidth(o),this.bottomLeftCollection.setHeight(p),this.bottomRightCollection.setWidth(q),this.bottomRightCollection.setHeight(r);var s=this.contextLayout.attr("items");s[1].left=b,s[2].top=f,s[3].left=b,s[3].top=f,this.contextLayout.attr("items",s),this.contextLayout.resize();var t=[],u=[],v=[],w=[],x=function(a,b,c){BI.each(a,function(a,d){BI.isNull(b[d.row][d.col]),c.push(b[d.row][d.col])})};x(this.topLeftItems,a.header,t),x(this.topRightItems,a.header,u),x(this.bottomLeftItems,a.items,v),x(this.bottomRightItems,a.items,w),this.topLeftCollection._populate(t),this.topRightCollection._populate(u),this.bottomLeftCollection._populate(v),this.bottomRightCollection._populate(w)},_populate:function(){this._width<=0||this._height<=0||(this._isNeedDigest===!0&&this._digest(),this._isNeedDigest=!1,this._populateTable(),this._populateScrollbar())},_serialize:function(a,b,c,d,e,f,g){f=f||[],g=g||[];for(var h=this.options,i=[],j={},k={},l={},m={},n=[],o=b;o-1||g===!0||g.indexOf(a)>-1)if(0===a&&e===b)r(0,b);else if(e===b&&a>0){var i=h.mergeRule(j[a][e],j[a-1][e]);i===!0?(p(a,e),l[a]=k[e]):r(a,e)}else if(0===a&&e>b){var n=h.mergeRule(j[a][e],j[a][e-1]);n===!0?(q(a,e),k[e]=l[a]):r(a,e)}else{var i=h.mergeRule(j[a][e],j[a-1][e]),n=h.mergeRule(j[a][e],j[a][e-1]);if(n&&i)continue;n&&q(a,e),i&&p(a,e),n||i||r(a,e)}else r(a,e)}),BI.map(i,function(a,b){return{x:b.x,y:b.y,row:b.item._row,col:b.item._col,width:b.item._width,height:b.item._height}})},populate:function(a,b){a&&this.options.items!==a&&(this._isNeedDigest=!0,this.options.items=a,this._restore()),b&&this.options.header!==b&&(this._isNeedDigest=!0,this.options.header=b,this._restore()),this._populate()},_restore:function(){this.topLeftCollection.restore(),this.topRightCollection.restore(),this.bottomLeftCollection.restore(),this.bottomRightCollection.restore()},restore:function(){this._restore()},setWidth:function(a){BI.CanvasTable.superclass.setWidth.apply(this,arguments),this._width=a-BI.GridTableScrollbar.SIZE},setHeight:function(a){BI.CanvasTable.superclass.setHeight.apply(this,arguments),this._height=a-BI.GridTableScrollbar.SIZE},setVerticalScroll:function(a){this.bottomLeftCollection.setScrollTop(a),this.bottomRightCollection.setScrollTop(a)},setLeftHorizontalScroll:function(a){this.topLeftCollection.setScrollLeft(a),this.bottomLeftCollection.setScrollLeft(a)},setRightHorizontalScroll:function(a){this.topRightCollection.setScrollLeft(a),this.bottomRightCollection.setScrollLeft(a)},getVerticalScroll:function(){return this.bottomRightCollection.getScrollTop()},getLeftHorizontalScroll:function(){return this.bottomLeftCollection.getScrollLeft()},getRightHorizontalScroll:function(){return this.bottomRightCollection.getScrollLeft()},setColumnSize:function(a){this._isNeedDigest=!0,this.options.columnSize=a},setRegionColumnSize:function(a){this._isNeedDigest=!0,this.options.regionColumnSize=a},getColumnSize:function(){return this.options.columnSize},getRegionColumnSize:function(){return this.options.regionColumnSize}}),BI.shortcut("bi.canvas_table",BI.CanvasTable),BI.MonthDateCombo=BI.inherit(BI.Trigger,{_defaultConfig:function(){return BI.extend(BI.MonthDateCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-month-combo",height:25})},_init:function(){BI.MonthDateCombo.superclass._init.apply(this,arguments);var a=this;this.options;this.trigger=BI.createWidget({type:"bi.date_triangle_trigger"}),this.popup=BI.createWidget({type:"bi.month_popup"}),this.popup.on(BI.YearPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue())}),this.combo=BI.createWidget({type:"bi.combo",offsetStyle:"center",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,stopPropagation:!1,el:this.popup}}),this.combo.on(BI.Combo.EVENT_CHANGE,function(){a.combo.hideView(),a.fireEvent(BI.MonthDateCombo.EVENT_CHANGE)})},setValue:function(a){this.trigger.setValue(a+1),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()}}),BI.MonthDateCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.month_date_combo",BI.MonthDateCombo),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",height:25})},_init:function(){BI.YearDateCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.date_triangle_trigger"}),this.popup=BI.createWidget({type:"bi.year_popup",min:b.min,max:b.max}),this.popup.on(BI.YearPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.YearDateCombo.EVENT_CHANGE)}),this.combo=BI.createWidget({type:"bi.combo",offsetStyle:"center",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,stopPropagation:!1,el:this.popup}}),this.combo.on(BI.Combo.EVENT_CHANGE,function(){a.fireEvent(BI.YearDateCombo.EVENT_CHANGE)})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()}}),BI.YearDateCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.year_date_combo",BI.YearDateCombo),BI.DatePicker=BI.inherit(BI.Widget,{_defaultConfig:function(){var a=BI.DatePicker.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-date-picker bi-background",height:25,min:"1900-01-01",max:"2099-12-31"})},_init:function(){BI.DatePicker.superclass._init.apply(this,arguments);var a=this,b=this.options;this._year=(new Date).getFullYear(),this._month=(new Date).getMonth(),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(){ +0===a._month?a.setValue({year:a.year.getValue()-1,month:11}):a.setValue({year:a.year.getValue(),month:a.month.getValue()-1}),a.fireEvent(BI.DatePicker.EVENT_CHANGE),a._checkLeftValid(),a._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(){11===a._month?a.setValue({year:a.year.getValue()+1,month:0}):a.setValue({year:a.year.getValue(),month:a.month.getValue()+1}),a.fireEvent(BI.DatePicker.EVENT_CHANGE),a._checkLeftValid(),a._checkRightValid()}),this.year=BI.createWidget({type:"bi.year_date_combo",min:b.min,max:b.max}),this.year.on(BI.YearDateCombo.EVENT_CHANGE,function(){a.setValue({year:a.year.getValue(),month:a.month.getValue()}),a.fireEvent(BI.DatePicker.EVENT_CHANGE)}),this.month=BI.createWidget({type:"bi.month_date_combo"}),this.month.on(BI.MonthDateCombo.EVENT_CHANGE,function(){a.setValue({year:a.year.getValue(),month:a.month.getValue()}),a.fireEvent(BI.DatePicker.EVENT_CHANGE)}),BI.createWidget({type:"bi.htape",element:this,items:[{el:this.left,width:25},{type:"bi.center_adapt",items:[{type:"bi.horizontal",width:100,items:[this.year,this.month]}]},{el:this.right,width:25}]}),this.setValue({year:this._year,month:this._month})},_checkLeftValid:function(){var a=this.options,b=!(0===this._month&&this._year===Date.parseDateTime(a.min,"%Y-%X-%d").getFullYear());return this.left.setEnable(b),b},_checkRightValid:function(){var a=this.options,b=!(11===this._month&&this._year===Date.parseDateTime(a.max,"%Y-%X-%d").getFullYear());return this.right.setEnable(b),b},setValue:function(a){this._year=a.year,this._month=a.month,this.year.setValue(a.year),this.month.setValue(a.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),BI.DateCalendarPopup=BI.inherit(BI.Widget,{_defaultConfig:function(){var a=BI.DateCalendarPopup.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-date-calendar-popup",min:"1900-01-01",max:"2099-12-31",selectedTime:null})},_createNav:function(a){var b=BI.Calendar.getDateJSONByPage(a),c=BI.createWidget({type:"bi.calendar",logic:{dynamic:!0},min:this.options.min,max:this.options.max,year:b.year,month:b.month,day:this.selectedTime.day});return c},_init:function(){BI.DateCalendarPopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.today=new Date,this._year=this.today.getFullYear(),this._month=this.today.getMonth(),this._day=this.today.getDate(),this.selectedTime=b.selectedTime||{year:this._year,month:this._month,day:this._day},this.datePicker=BI.createWidget({type:"bi.date_picker",min:b.min,max:b.max}),this.calendar=BI.createWidget({direction:"top",element:this,logic:{dynamic:!0},type:"bi.navigation",tab:this.datePicker,cardCreator:BI.bind(this._createNav,this),afterCardCreated:function(){},afterCardShow:function(){this.setValue(a.selectedTime)}}),this.datePicker.on(BI.DatePicker.EVENT_CHANGE,function(){a.selectedTime=a.datePicker.getValue(),a.selectedTime.day=1,a.calendar.setSelect(BI.Calendar.getPageByDateJSON(a.selectedTime))}),this.calendar.on(BI.Navigation.EVENT_CHANGE,function(){a.selectedTime=a.calendar.getValue(),a.setValue(a.selectedTime),a.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE)})},setValue:function(a){this.datePicker.setValue(a),this.calendar.setSelect(BI.Calendar.getPageByDateJSON(a)),this.calendar.setValue(a),this.selectedTime=a},getValue:function(){return this.selectedTime}}),BI.DateCalendarPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.date_calendar_popup",BI.DateCalendarPopup),BI.DateTriangleTrigger=BI.inherit(BI.Trigger,{_const:{height:25,iconWidth:16,iconHeight:13},_defaultConfig:function(){return BI.extend(BI.DateTriangleTrigger.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-date-triangle-trigger pull-down-ha-font cursor-pointer",height:25})},_init:function(){BI.DateTriangleTrigger.superclass._init.apply(this,arguments);var a=this.options,b=this._const;this.text=BI.createWidget({type:"bi.label",cls:"list-item-text",textAlign:"right",text:a.text,value:a.value,height:b.height}),this.icon=BI.createWidget({type:"bi.icon",width:b.iconWidth,height:b.iconHeight}),BI.createWidget({type:"bi.center_adapt",element:this,items:[{type:"bi.center_adapt",width:50,height:b.height,items:[this.text,this.icon]}]})},setValue:function(a){this.text.setValue(a)},getValue:function(){return this.text.getValue()},setText:function(a){this.text.setText(a)},getText:function(){return this.item.getText()},getKey:function(){}}),BI.shortcut("bi.date_triangle_trigger",BI.DateTriangleTrigger),BI.DateCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-date-combo bi-border",height:25})},_init:function(){BI.DateCombo.superclass._init.apply(this,arguments);var a=this;this.options;this.trigger=BI.createWidget({type:"bi.date_trigger"}),this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK,function(){a.combo.toggle()}),this.popup=BI.createWidget({type:"bi.date_calendar_popup"}),this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue())}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{width:270,el:this.popup,stopPropagation:!1}})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()}}),BI.shortcut("bi.date_combo",BI.DateCombo),BI.DateTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:30,yearLength:4,yearMonthLength:7},_defaultConfig:function(){return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-date-trigger",min:"1900-01-01",max:"2099-12-31",height:25})},_init:function(){BI.DateTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(b){var c=b.match(/\d+/g);return a._autoAppend(b,c),a._dateCheck(b)&&Date.checkLegal(b)&&a._checkVoid({year:c[0],month:c[1],day:c[2]})},quitChecker:function(){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,watermark:BI.i18nText("BI-Basic_Unrestricted"),errorText:function(){return a.editor.isEditing()?BI.i18nText("BI-Date_Trigger_Error_Text"):BI.i18nText("BI-Year_Trigger_Invalid_Text")}}),this.editor.on(BI.SignEditor.EVENT_KEY_DOWN,function(){a.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN)}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.DateTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.fireEvent(BI.DateTrigger.EVENT_STOP)}),this.editor.on(BI.SignEditor.EVENT_VALID,function(){a.fireEvent(BI.DateTrigger.EVENT_VALID)}),this.editor.on(BI.SignEditor.EVENT_ERROR,function(){a.fireEvent(BI.DateTrigger.EVENT_ERROR)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();if(BI.isNotNull(b)&&a.editor.setState(b),BI.isNotEmptyString(b)){var c=b.split("-");a.store_value={type:BI.DateTrigger.MULTI_DATE_CALENDAR,value:{year:0|c[0],month:c[1]-1,day:0|c[2]}}}a.fireEvent(BI.DateTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.DateTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.DateTrigger.EVENT_CHANGE)}),BI.createWidget({type:"bi.htape",element:this,items:[{el:BI.createWidget(),width:30},{el:this.editor}]})},_dateCheck:function(a){return Date.parseDateTime(a,"%Y-%x-%d").print("%Y-%x-%d")==a||Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d")==a||Date.parseDateTime(a,"%Y-%x-%e").print("%Y-%x-%e")==a||Date.parseDateTime(a,"%Y-%X-%e").print("%Y-%X-%e")==a},_checkVoid:function(a){return!Date.checkVoid(a.year,a.month,a.day,this.options.min,this.options.max)[0]},_autoAppend:function(a,b){var c=this,d=Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d"),e=function(a){return Date.parseDateTime(a,"%Y").print("%Y")==a&&d>=c.options.min&&d<=c.options.max},f=function(a){return Date.parseDateTime(a,"%Y-%X").print("%Y-%X")==a&&d>=c.options.min&&d<=c.options.max};if(BI.isNotNull(b)&&Date.checkLegal(a))switch(a.length){case this._const.yearLength:e(a)&&this.editor.setValue(a+"-");break;case this._const.yearMonthLength:f(a)&&this.editor.setValue(a+"-")}},setValue:function(a){var b,c,d=this,e=new Date;this.store_value=a,BI.isNotNull(a)&&(b=a.type||BI.DateTrigger.MULTI_DATE_CALENDAR,c=a.value,BI.isNull(c)&&(c=a));var f=function(a,b){var c=a.print("%Y-%x-%e");d.editor.setState(c),d.editor.setValue(c),d.setTitle(b+":"+c)};switch(b){case BI.DateTrigger.MULTI_DATE_YEAR_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV];e=new Date(e.getFullYear()-1*c,e.getMonth(),e.getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER];e=new Date(e.getFullYear()+1*c,e.getMonth(),e.getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN];e=new Date(e.getFullYear(),0,1),f(e,g);break;case BI.DateTrigger.MULTI_DATE_YEAR_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END];e=new Date(e.getFullYear(),11,31),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV];e=(new Date).getBeforeMulQuarter(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER];e=(new Date).getAfterMulQuarter(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN];e=(new Date).getQuarterStartDate(),f(e,g);break;case BI.DateTrigger.MULTI_DATE_QUARTER_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END];e=(new Date).getQuarterEndDate(),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV];e=(new Date).getBeforeMultiMonth(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER];e=(new Date).getAfterMultiMonth(c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN];e=new Date(e.getFullYear(),e.getMonth(),1),f(e,g);break;case BI.DateTrigger.MULTI_DATE_MONTH_END:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END];e=new Date(e.getFullYear(),e.getMonth(),e.getLastDateOfMonth().getDate()),f(e,g);break;case BI.DateTrigger.MULTI_DATE_WEEK_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV];e=e.getOffsetDate(-7*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_WEEK_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER];e=e.getOffsetDate(7*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_PREV:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV];e=e.getOffsetDate(-1*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_AFTER:var g=c+BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER];e=e.getOffsetDate(1*c),f(e,g);break;case BI.DateTrigger.MULTI_DATE_DAY_TODAY:var g=BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY];e=new Date,f(e,g);break;default:if(BI.isNull(c)||BI.isNull(c.day))this.editor.setState(""),this.editor.setValue(""),this.setTitle("");else{var h=c.year+"-"+(c.month+1)+"-"+c.day;this.editor.setState(h),this.editor.setValue(h),this.setTitle(h)}}},getKey:function(){return this.editor.getValue()},getValue:function(){return this.store_value}}),BI.DateTrigger.MULTI_DATE_YEAR_PREV=1,BI.DateTrigger.MULTI_DATE_YEAR_AFTER=2,BI.DateTrigger.MULTI_DATE_YEAR_BEGIN=3,BI.DateTrigger.MULTI_DATE_YEAR_END=4,BI.DateTrigger.MULTI_DATE_MONTH_PREV=5,BI.DateTrigger.MULTI_DATE_MONTH_AFTER=6,BI.DateTrigger.MULTI_DATE_MONTH_BEGIN=7,BI.DateTrigger.MULTI_DATE_MONTH_END=8,BI.DateTrigger.MULTI_DATE_QUARTER_PREV=9,BI.DateTrigger.MULTI_DATE_QUARTER_AFTER=10,BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN=11,BI.DateTrigger.MULTI_DATE_QUARTER_END=12,BI.DateTrigger.MULTI_DATE_WEEK_PREV=13,BI.DateTrigger.MULTI_DATE_WEEK_AFTER=14,BI.DateTrigger.MULTI_DATE_DAY_PREV=15,BI.DateTrigger.MULTI_DATE_DAY_AFTER=16,BI.DateTrigger.MULTI_DATE_DAY_TODAY=17,BI.DateTrigger.MULTI_DATE_PARAM=18,BI.DateTrigger.MULTI_DATE_CALENDAR=19,BI.DateTrigger.MULTI_DATE_SEGMENT_NUM={},BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]=BI.i18nText("BI-Multi_Date_Year_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]=BI.i18nText("BI-Multi_Date_Year_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]=BI.i18nText("BI-Multi_Date_Year_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]=BI.i18nText("BI-Multi_Date_Year_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]=BI.i18nText("BI-Multi_Date_Quarter_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]=BI.i18nText("BI-Multi_Date_Quarter_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]=BI.i18nText("BI-Multi_Date_Quarter_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]=BI.i18nText("BI-Multi_Date_Quarter_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]=BI.i18nText("BI-Multi_Date_Month_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]=BI.i18nText("BI-Multi_Date_Month_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]=BI.i18nText("BI-Multi_Date_Month_Begin"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]=BI.i18nText("BI-Multi_Date_Month_End"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]=BI.i18nText("BI-Multi_Date_Week_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]=BI.i18nText("BI-Multi_Date_Week_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]=BI.i18nText("BI-Multi_Date_Day_Prev"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]=BI.i18nText("BI-Multi_Date_Day_Next"),BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]=BI.i18nText("BI-Multi_Date_Today"),BI.DateTrigger.EVENT_FOCUS="EVENT_FOCUS",BI.DateTrigger.EVENT_START="EVENT_START",BI.DateTrigger.EVENT_STOP="EVENT_STOP",BI.DateTrigger.EVENT_CONFIRM="EVENT_CONFIRM",BI.DateTrigger.EVENT_CHANGE="EVENT_CHANGE",BI.DateTrigger.EVENT_VALID="EVENT_VALID",BI.DateTrigger.EVENT_ERROR="EVENT_ERROR",BI.DateTrigger.EVENT_TRIGGER_CLICK="EVENT_TRIGGER_CLICK",BI.DateTrigger.EVENT_KEY_DOWN="EVENT_KEY_DOWN",BI.shortcut("bi.date_trigger",BI.DateTrigger),BI.DatePaneWidget=BI.inherit(BI.Widget,{_defaultConfig:function(){var a=BI.DatePaneWidget.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-date-pane",min:"1900-01-01",max:"2099-12-31",selectedTime:null})},_init:function(){BI.DatePaneWidget.superclass._init.apply(this,arguments);var a=this,b=this.options;this.today=new Date,this._year=this.today.getFullYear(),this._month=this.today.getMonth(),this.selectedTime=b.selectedTime||{year:this._year,month:this._month},this.datePicker=BI.createWidget({type:"bi.date_picker",min:b.min,max:b.max}),this.datePicker.on(BI.DatePicker.EVENT_CHANGE,function(){a.selectedTime=a.datePicker.getValue(),a.calendar.setSelect(BI.Calendar.getPageByDateJSON(a.selectedTime))}),this.calendar=BI.createWidget({direction:"top",element:this,logic:{dynamic:!1},type:"bi.navigation",tab:this.datePicker,cardCreator:BI.bind(this._createNav,this)}),this.calendar.on(BI.Navigation.EVENT_CHANGE,function(){a.selectedTime=a.calendar.getValue(),a.calendar.empty(),a.setValue(a.selectedTime),a.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE)})},_createNav:function(a){var b=BI.Calendar.getDateJSONByPage(a),c=BI.createWidget({type:"bi.calendar",logic:{dynamic:!1},min:this.options.min,max:this.options.max,year:b.year,month:b.month,day:this.selectedTime.day});return c},_getNewCurrentDate:function(){var a=new Date;return{year:a.getFullYear(),month:a.getMonth()}},_setCalenderValue:function(a){this.calendar.setSelect(BI.Calendar.getPageByDateJSON(a)),this.calendar.setValue(a),this.selectedTime=a},_setDatePicker:function(a){BI.isNull(a)||BI.isNull(a.year)||BI.isNull(a.month)?this.datePicker.setValue(this._getNewCurrentDate()):this.datePicker.setValue(a)},_setCalendar:function(a){BI.isNull(a)||BI.isNull(a.day)?(this.calendar.empty(),this._setCalenderValue(this._getNewCurrentDate())):this._setCalenderValue(a)},setValue:function(a){this._setDatePicker(a),this._setCalendar(a)},getValue:function(){return this.selectedTime}}),BI.shortcut("bi.date_pane",BI.DatePaneWidget),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",width:200,height:24})},_init:function(){BI.DateTimeCombo.superclass._init.apply(this,arguments);var a=this,b=(this.options,new Date);this.storeValue={year:b.getFullYear(),month:b.getMonth(),day:b.getDate(),hour:b.getHours(),minute:b.getMinutes(),second:b.getSeconds()},this.trigger=BI.createWidget({type:"bi.date_time_trigger",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.popup=BI.createWidget({type:"bi.date_time_popup",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),a.setValue(this.storeValue),this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE,function(){a.setValue(a.storeValue),a.hidePopupView(),a.fireEvent(BI.DateTimeCombo.EVENT_CANCEL)}),this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE,function(){a.storeValue=a.popup.getValue(),a.setValue(a.storeValue),a.hidePopupView(),a.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM)}),this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE,function(){a.trigger.setValue(a.popup.getValue()),a.fireEvent(BI.DateTimeCombo.EVENT_CHANGE)}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,adjustLength:this.constants.comboAdjustHeight,popup:{el:this.popup,maxHeight:this.constants.popupHeight,width:this.constants.popupWidth,stopPropagation:!1}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.popup.setValue(a.storeValue),a.fireEvent(BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW)});var c=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-font bi-border-right",width:30,height:24});c.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.combo.isViewVisible()?a.combo.hideView():a.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:c,top:0,left:0}]}]})},setValue:function(a){this.storeValue=a,this.popup.setValue(a),this.trigger.setValue(a)},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),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:290})},_init:function(){BI.DateTimePopup.superclass._init.apply(this,arguments);var a=this;this.options;this.cancelButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"multidate-popup-button bi-border-top bi-border-right",shadow:!0,text:BI.i18nText("BI-Basic_Cancel")}),this.cancelButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE)}),this.okButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_OK")}),this.okButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE)}),this.dateCombo=BI.createWidget({type:"bi.date_calendar_popup",min:a.options.min,max:a.options.max}),a.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE,function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}),this.dateSelect=BI.createWidget({type:"bi.vertical_adapt",cls:"bi-border-top",items:[{type:"bi.label",text:BI.i18nText("BI-Basic_Time"),width:45},{type:"bi.date_time_select",max:23,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.hour=b}},{type:"bi.label",text:":",width:15},{type:"bi.date_time_select",max:59,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.minute=b}},{type:"bi.label",text:":",width:15},{type:"bi.date_time_select",max:59,min:0,width:60,height:30,listeners:[{eventName:BI.DateTimeSelect.EVENT_CONFIRM,action:function(){a.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE)}}],ref:function(b){a.second=b}}]});var b=new Date;this.dateCombo.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.hour.setValue(b.getHours()),this.minute.setValue(b.getMinutes()),this.second.setValue(b.getSeconds()),this.dateButton=BI.createWidget({type:"bi.grid",items:[[this.cancelButton,this.okButton]]}),BI.createWidget({element:this,type:"bi.vtape",items:[{el:this.dateCombo},{el:this.dateSelect,height:50},{el:this.dateButton,height:30}]})},setValue:function(a){var b,c=a;BI.isNull(c)?(b=new Date,this.dateCombo.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.hour.setValue(b.getHours()),this.minute.setValue(b.getMinutes()),this.second.setValue(b.getSeconds())):(this.dateCombo.setValue({year:c.year,month:c.month,day:c.day}),this.hour.setValue(c.hour),this.minute.setValue(c.minute),this.second.setValue(c.second))},getValue:function(){return{year:this.dateCombo.getValue().year,month:this.dateCombo.getValue().month,day:this.dateCombo.getValue().day,hour:this.hour.getValue(),minute:this.minute.getValue(),second:this.second.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),BI.DateTimeSelect=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-date-time-select bi-border",max:23,min:0})},_init:function(){BI.DateTimeSelect.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.sign_editor",value:this._alertInEditorValue(b.min),allowBlank:!1,errorText:BI.i18nText("BI-Please_Input_Natural_Number"),validationChecker:function(a){return BI.isNaturalNumber(a)}}),this.editor.on(BI.TextEditor.EVENT_CONFIRM,function(){a._finetuning(0),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this.topBtn=BI.createWidget({type:"bi.icon_button",cls:"column-pre-page-h-font top-button bi-border-left bi-border-bottom"}),this.topBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(1),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this.bottomBtn=BI.createWidget({type:"bi.icon_button",cls:"column-next-page-h-font bottom-button bi-border-left"}),this.bottomBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(-1),a.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM)}),this._finetuning(0),BI.createWidget({type:"bi.htape",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:30}]})},_alertOutEditorValue:function(a){return a>this.options.max&&(a=this.options.min),athis.options.max&&(a=this.options.min),a0&&a[c-1].xb)return!0});return c.y}var c=this,d=(this.options,this.pathChooser.routes),e=this.pathChooser.pathes,f=this.pathChooser.store;this.arrows={},BI.each(d,function(d,g){c.arrows[d]=[],BI.each(g,function(g,h){c.arrows[d][g]=[];var i=e[d][g];BI.each(i,function(a,b){if(a>0&&a0&&(e=c._drawOneArrow(i[a-1],3)):e=c._drawOneArrow(i[a],1)):b.x===i[a-1].x&&(e=b.y>i[a-1].y?f[BI.first(h)].direction===-1?c._drawOneArrow(i[a-1],0):c._drawOneArrow(b,2):f[h[h.length-2]].direction===-1?c._drawOneArrow(i[a-1],2):c._drawOneArrow(b,0)),e&&c.arrows[d][g].push(e)}}),BI.each(h,function(e,j){if(0!==e){var k,l=h[e-1];if(f[l].direction===-1){var m=c.pathChooser.getRegionIndexById(l),n=a(m,-1),o=b(i,n);k=c._drawOneArrow({x:n,y:o},3)}else{var m=c.pathChooser.getRegionIndexById(j),n=a(m),o=b(i,n);k=c._drawOneArrow({x:n,y:o},1)}k&&c.arrows[d][g].push(k)}})})})},_setValue:function(a,b){var c=this,d=this._const.lineColor,e=this._const.selectLineColor,f=this.pathChooser.routes,g=this.pathChooser.start,h=[a];g.contains(a)&&(h=g),BI.each(h,function(a,b){BI.each(c.arrows[b],function(a,b){BI.each(b,function(a,b){b.attr({fill:d,stroke:d}).toFront()})})}),BI.each(this.arrows[a][b],function(a,b){b.attr({fill:e,stroke:e}).toFront()});for(var i=BI.last(f[a][b]);i&&f[i]&&1===f[i].length;)BI.each(c.arrows[i][0],function(a,b){b.attr({fill:e,stroke:e}).toFront()}),i=BI.last(f[i][0])},setValue:function(a){this.pathChooser.setValue(a),this._unselectAllArrows();var b=this.pathChooser.routes,c=BI.keys(b),d=this,e=[],f=[];BI.each(a,function(a,b){BI.contains(c,b)&&f.length>0&&(f.push(b),e.push(f),f=[]),f.push(b)}),f.length>0&&e.push(f),BI.each(e,function(a,c){var e=c[0],f=BI.findIndex(b[e],function(a,b){if(BI.isEqual(c,b))return!0});f>=0&&d._setValue(e,f)})},getValue:function(){return this.pathChooser.getValue()},populate:function(a){this.pathChooser.populate(a),this._drawArrows()}}),BI.DirectionPathChooser.EVENT_CHANGE="DirectionPathChooser.EVENT_CHANGE",BI.shortcut("bi.direction_path_chooser",BI.DirectionPathChooser),BI.DownListCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-down-list-combo",invalid:!1,height:25,items:[],adjustLength:0,direction:"bottom",trigger:"click",el:{}})},_init:function(){BI.DownListCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.popupview=BI.createWidget({type:"bi.down_list_popup",items:b.items,chooseType:b.chooseType}),this.popupview.on(BI.DownListPopup.EVENT_CHANGE,function(b){a.fireEvent(BI.DownListCombo.EVENT_CHANGE,b),a.downlistcombo.hideView()}),this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE,function(b,c){a.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE,b,c),a.downlistcombo.hideView()}),this.downlistcombo=BI.createWidget({element:this,type:"bi.combo",trigger:b.trigger,isNeedAdjustWidth:!1,adjustLength:b.adjustLength,direction:b.direction,el:BI.createWidget(b.el,{type:"bi.icon_trigger",extraCls:b.iconCls?b.iconCls:"pull-down-font",width:b.width,height:b.height}),popup:{el:this.popupview,stopPropagation:!0,maxHeight:1e3}}),this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW)})},hideView:function(){this.downlistcombo.hideView()},showView:function(){this.downlistcombo.showView()},populate:function(a){this.popupview.populate(a)},setValue:function(a){this.popupview.setValue(a)},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),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 a=this.options,b=this;this.downlistgroup=BI.createWidget({element:this,type:"bi.button_tree",items:a.items,chooseType:0,layouts:[{type:"bi.vertical",hgap:0,vgap:0}]}),this.downlistgroup.on(BI.Controller.EVENT_CHANGE,function(a){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.DownListGroup.EVENT_CHANGE,arguments); +})},getValue:function(){return this.downlistgroup.getValue()},setValue:function(a){this.downlistgroup.setValue(a)}}),BI.DownListGroup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_group",BI.DownListGroup),BI.DownListItem=BI.inherit(BI.Single,{_defaultConfig:function(){var a=BI.DownListItem.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:"bi-down-list-item bi-list-item-active",cls:"",height:25,logic:{dynamic:!0},selected:!1,iconHeight:null,iconWidth:null,textHgap:0,textVgap:0,textLgap:0,textRgap:0})},_init:function(){BI.DownListItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.text=BI.createWidget({type:"bi.icon_text_item",element:this,height:b.height,text:b.text,value:b.value,logic:b.logic,selected:b.selected,disabled:b.disabled,iconHeight:b.iconHeight,iconWidth:b.iconWidth,textHgap:b.textHgap,textVgap:b.textVgap,textLgap:b.textLgap,textRgap:b.textRgap,father:b.father}),this.text.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.text.on(BI.IconTextItem.EVENT_CHANGE,function(){a.fireEvent(BI.DownListItem.EVENT_CHANGE)})},doRedMark:function(){this.text.doRedMark.apply(this.text,arguments)},unRedMark:function(){this.text.unRedMark.apply(this.text,arguments)},isSelected:function(){return this.text.isSelected()},setSelected:function(a){this.text.setSelected(a)},setValue:function(a){this.text.setValue(a)},getValue:function(){return this.text.getValue()}}),BI.DownListItem.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_item",BI.DownListItem),BI.DownListGroupItem=BI.inherit(BI.BasicButton,{_defaultConfig:function(){var a=BI.DownListGroupItem.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-down-list-group-item",logic:{dynamic:!1},iconCls1:"dot-e-font",iconCls2:"pull-right-e-font"})},_init:function(){BI.DownListGroupItem.superclass._init.apply(this,arguments);var a=this.options,b=this;this.text=BI.createWidget({type:"bi.label",cls:"list-group-item-text",textAlign:"left",text:a.text,value:a.value,height:a.height}),this.icon1=BI.createWidget({type:"bi.icon_button",cls:a.iconCls1,width:25,forceNotSelected:!0}),this.icon2=BI.createWidget({type:"bi.icon_button",cls:a.iconCls2,width:25,forceNotSelected:!0});var c=BI.createWidget({type:"bi.layout",width:25});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(a.logic,{items:BI.LogicFactory.createLogicItemsByDirection("left",this.icon1,this.text,c)})))),this.element.hover(function(){b.isEnabled()&&b.hover()},function(){b.isEnabled()&&b.dishover()})},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),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(a){var b=this,c=this.options;a=BI.isArray(a)?a:[a],BI.find(a,function(a,d){return BI.contains(c.childValues,d)?(b.icon1.setSelected(!0),!0):void b.icon1.setSelected(!1)})}}),BI.DownListGroupItem.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.down_list_group_item",BI.DownListGroupItem),BI.DownListPopup=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 a=BI.DownListPopup.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{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={};var a=this,b=this.options,c=this._createChildren(b.items);this.popup=BI.createWidget({type:"bi.button_tree",items:BI.createItems(c,{},{adjustLength:-2}),layouts:[{type:"bi.vertical",hgap:this.constants.hgap,vgap:this.constants.vgap}],chooseType:b.chooseType}),this.popup.on(BI.ButtonTree.EVENT_CHANGE,function(b,c){var d=b;if(BI.isNotNull(a.childValueMap[b])?(d=a.childValueMap[b],a.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE,d,a.fatherValueMap[b])):a.fireEvent(BI.DownListPopup.EVENT_CHANGE,d,c),!a.singleValues.contains(d)){var e=a.getValue(),f=[];BI.each(e,function(a,b){b.value!=d&&f.push(b)}),a.setValue(f)}}),BI.createWidget({type:"bi.vertical",element:this,items:[this.popup]})},_createChildren:function(a){var b=this,c=[];return BI.each(a,function(d,e){var f={type:"bi.down_list_group",items:[]};if(BI.each(e,function(a,c){BI.isNotEmptyArray(c.children)&&!BI.isEmpty(c.el)?(c.type="bi.combo_group",c.cls="down-list-group",c.trigger="hover",c.isNeedAdjustWidth=!1,c.el.title=c.el.title||c.el.text,c.el.type="bi.down_list_group_item",c.el.logic={dynamic:!0},c.el.height=b.constants.height,c.el.iconCls2=b.constants.nextIcon,c.popup={lgap:4,el:{type:"bi.button_tree",chooseType:0,layouts:[{type:"bi.vertical"}]}},c.el.childValues=[],BI.each(c.children,function(a,d){var e=BI.deepClone(c.el.value),f=BI.deepClone(d.value);b.singleValues.push(d.value),d.type="bi.down_list_item",d.extraCls=" child-down-list-item",d.title=d.title||d.text,d.textRgap=10,d.isNeedAdjustWidth=!1,d.logic={dynamic:!0},d.father=e,b.fatherValueMap[b._createChildValue(e,f)]=e,b.childValueMap[b._createChildValue(e,f)]=f,d.value=b._createChildValue(e,f),c.el.childValues.push(d.value)})):(c.type="bi.down_list_item",c.title=c.title||c.text,c.textRgap=10,c.isNeedAdjustWidth=!1,c.logic={dynamic:!0});var d={};d.el=c,f.items.push(d)}),b._isGroup(f.items)&&BI.each(f.items,function(a,c){b.singleValues.push(c.el.value)}),c.push(f),b._needSpliter(d,a.length)){var g=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:10});c.push(g)}}),c},_isGroup:function(a){return a.length>1},_needSpliter:function(a,b){return a0?b.type="bi.file_manager_folder_item":b.type="bi.file_manager_file_item"}),a},setValue:function(a){this.button_group.setValue(a)},getValue:function(){return this.button_group.getValue()},getNotSelectedValue:function(){return this.button_group.getNotSelectedValue()},getAllLeaves:function(){return this.button_group.getAllLeaves()},getAllButtons:function(){return this.button_group.getAllButtons()},getSelectedButtons:function(){return this.button_group.getSelectedButtons()},getNotSelectedButtons:function(){return this.button_group.getNotSelectedButtons()},populate:function(a){this.button_group.populate(this._formatItems(a))}}),BI.FileManagerButtonGroup.EVENT_CHANGE="FileManagerButtonGroup.EVENT_CHANGE",BI.shortcut("bi.file_manager_button_group",BI.FileManagerButtonGroup),BI.FileManager=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager",el:{},items:[]})},_init:function(){BI.FileManager.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=new BI.Tree;var c=BI.Tree.transformToTreeFormat(b.items);this.tree.initTree(c),this.selectedValues=[],this.nav=BI.createWidget({type:"bi.file_manager_nav",items:BI.deepClone(c)}),this.nav.on(BI.FileManagerNav.EVENT_CHANGE,function(b,c){if("-1"==b)a.populate({children:a.tree.toJSON()});else{var d=a.tree.search(c.attr("id"));a.populate(BI.extend({id:d.id},d.get("data"),{children:a.tree.toJSON(d)}))}a.setValue(a.selectedValues)}),this.list=BI.createWidget(b.el,{type:"bi.file_manager_list",items:c}),this.list.on(BI.Controller.EVENT_CHANGE,function(b,c,d){if(b===BI.Events.CHANGE){var e=a.tree.search(d.attr("id"));a.populate(BI.extend({id:e.id},e.get("data"),{children:a.tree.toJSON(e)}))}else if(b===BI.Events.CLICK){var f=[];if(d instanceof BI.MultiSelectBar){var g=a.list.getValue();c=g.type===BI.Selection.All,f=BI.concat(g.assist,g.value)}else f=d.getAllLeaves();BI.each(f,function(b,d){c===!0?a.selectedValues.pushDistinct(d):a.selectedValues.remove(d)})}a.setValue(a.selectedValues)}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.list,left:0,right:0,top:0,bottom:10},{el:this.nav,left:40,right:100,top:0}]})},setValue:function(a){this.selectedValues=a||[],this.list.setValue(this.selectedValues)},getValue:function(){var a=this.list.getValue(),b=a.type===BI.Selection.All?a.assist:a.value;return b.pushDistinctArray(this.selectedValues),b},_populate:function(a){this.list.populate(a)},getSelectedValue:function(){return this.nav.getValue()[0]},getSelectedId:function(){return this.nav.getId()[0]},populate:function(a){var b=BI.deepClone(a);this._populate(a.children),this.nav.populate(b)}}),BI.FileManager.EVENT_CHANGE="FileManager.EVENT_CHANGE",BI.shortcut("bi.file_manager",BI.FileManager),BI.FileManagerFileItem=BI.inherit(BI.Single,{_defaultConfig:function(){return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-file-item bi-list-item bi-border-bottom",height:30})},_init:function(){BI.FileManagerFileItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checked=BI.createWidget({type:"bi.multi_select_bar",text:"",width:36,height:b.height}),this.checked.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),BI.createWidget({type:"bi.htape",element:this,items:[{el:this.checked,width:36},{el:{type:"bi.icon_button",cls:"create-by-me-file-font"},width:20},{el:{type:"bi.label",textAlign:"left",height:b.height,text:b.text,value:b.value}}]})},getAllLeaves:function(){return[this.options.value]},isSelected:function(){return this.checked.isSelected()},setSelected:function(a){this.checked.setSelected(a)}}),BI.FileManagerFileItem.EVENT_CHANGE="FileManagerFileItem.EVENT_CHANGE",BI.shortcut("bi.file_manager_file_item",BI.FileManagerFileItem),BI.FileManagerFolderItem=BI.inherit(BI.Single,{_defaultConfig:function(){return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-folder-item bi-list-item bi-border-bottom",height:30})},_init:function(){BI.FileManagerFolderItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checked=BI.createWidget({type:"bi.multi_select_bar",text:"",width:36,height:b.height}),this.checked.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button=BI.createWidget({type:"bi.text_button",textAlign:"left",height:b.height,text:b.text,value:b.value}),this.button.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,BI.Events.CHANGE,b.value,a)}),this.tree=new BI.Tree,this.tree.initTree([{id:b.id,children:b.children}]),this.selectValue=[],BI.createWidget({type:"bi.htape",element:this,items:[{el:this.checked,width:36},{el:{type:"bi.icon_button",cls:"create-by-me-folder-font"},width:20},{el:this.button}]})},setAllSelected:function(a){this.checked.setSelected(a),this.selectValue=[]},setHalfSelected:function(a){this.checked.setHalfSelected(a),a||(this.selectValue=[])},setValue:function(a){var b=(this.options,!1),c=[];this.tree.traverse(function(d){d.isLeaf()&&(BI.contains(a,d.get("data").value)?c.push(d.get("data").value):b=!0)}),this.setAllSelected(c.length>0&&!b),this.setHalfSelected(c.length>0&&b),this.checked.isHalfSelected()&&(this.selectValue=c)},getAllButtons:function(){return[this]},getAllLeaves:function(){var a=(this.options,[]);return this.tree.traverse(function(b){b.isLeaf()&&a.push(b.get("data").value)}),a},getNotSelectedValue:function(){var a=this,b=(this.options,[]),c=this.checked.isSelected();if(c===!0)return b;var d=this.checked.isHalfSelected();return this.tree.traverse(function(c){if(c.isLeaf()){var e=c.get("data").value;d===!0?BI.contains(a.selectValue,c.get("data").value)||b.push(e):b.push(e)}}),b},getValue:function(){var a=[];return this.checked.isSelected()?(this.tree.traverse(function(b){b.isLeaf()&&a.push(b.get("data").value)}),a):this.checked.isHalfSelected()?this.selectValue:[]}}),BI.FileManagerFolderItem.EVENT_CHANGE="FileManagerFolderItem.EVENT_CHANGE",BI.shortcut("bi.file_manager_folder_item",BI.FileManagerFolderItem),BI.FileManagerList=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-list",el:{},items:[]})},_init:function(){BI.FileManagerList.superclass._init.apply(this,arguments);var a=this,b=this.options;this.list=BI.createWidget({type:"bi.select_list",element:this,items:b.items,toolbar:{type:"bi.multi_select_bar",height:40,text:""},el:{type:"bi.list_pane",el:BI.isWidget(b.el)?b.el:BI.extend({type:"bi.file_manager_button_group"},b.el)}}),this.list.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)})},setValue:function(a){this.list.setValue({value:a})},getValue:function(){return this.list.getValue()},populate:function(a){this.list.populate(a),this.list.setToolBarVisible(!0)}}),BI.FileManagerList.EVENT_CHANGE="FileManagerList.EVENT_CHANGE",BI.shortcut("bi.file_manager_list",BI.FileManagerList),BI.FileManagerNavButton=BI.inherit(BI.Widget,{_const:{normal_color:"#ffffff",select_color:"#eff1f4"},_defaultConfig:function(){return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-nav-button",selected:!1,height:40})},_init:function(){BI.FileManagerNavButton.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.button=BI.createWidget({type:"bi.text_button",cls:"file-manager-nav-button-text bi-card",once:!0,selected:b.selected,text:b.text,title:b.text,value:b.value,height:b.height,lgap:20,rgap:10}),this.button.on(BI.Controller.EVENT_CHANGE,function(){arguments[2]=a,a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var d=BI.createWidget({type:"bi.svg",cls:"file-manager-nav-button-triangle",width:15,height:b.height}),e=d.path("M0,0L15,20L0,40").attr({stroke:c.select_color,fill:b.selected?c.select_color:c.normal_color});this.button.on(BI.TextButton.EVENT_CHANGE,function(){this.isSelected()?e.attr("fill",c.select_color):e.attr("fill",c.normal_color)}),BI.createWidget({type:"bi.default",element:this,items:[this.button]}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:d,right:-15,top:0,bottom:0}]})},isSelected:function(){return this.button.isSelected()},setValue:function(a){this.button.setValue(a)},getValue:function(){return this.button.getValue()},populate:function(a){}}),BI.FileManagerNavButton.EVENT_CHANGE="FileManagerNavButton.EVENT_CHANGE",BI.shortcut("bi.file_manager_nav_button",BI.FileManagerNavButton),BI.FileManagerNav=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-file-manager-nav bi-border-left",height:40,items:[]})},_init:function(){BI.FileManagerNav.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=new BI.Tree,this.refreshTreeData(b.items),this.tree.getRoot().set("data",{text:BI.i18nText("BI-Created_By_Me"),value:BI.FileManagerNav.ROOT_CREATE_BY_ME,id:BI.FileManagerNav.ROOT_CREATE_BY_ME}),this.button_group=BI.createWidget({type:"bi.button_group",element:this,items:[{type:"bi.file_manager_nav_button",text:BI.i18nText("BI-Created_By_Me"),selected:!0,id:BI.FileManagerNav.ROOT_CREATE_BY_ME,value:BI.FileManagerNav.ROOT_CREATE_BY_ME}],layouts:[{type:"bi.horizontal"}]}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.ButtonGroup.EVENT_CHANGE,function(b,c){a.fireEvent(BI.FileManagerNav.EVENT_CHANGE,arguments)})},_getAllParents:function(a){var b,c=[];for(b=a?this.tree.search(a):this.tree.getRoot();b.parent;)c.push(b),b=b.parent;return c.push(b),c.reverse()},_formatNodes:function(a){var b=[];return BI.each(a,function(a,c){b.push(BI.extend({type:"bi.file_manager_nav_button",id:c.id},c.get("data")))}),BI.last(b).selected=!0,b},getValue:function(){return this.button_group.getValue()},getId:function(){var a=[];return BI.each(this.button_group.getSelectedButtons(),function(b,c){a.push(c.attr("id"))}),a},refreshTreeData:function(a){this.tree.initTree(BI.Tree.transformToTreeFormat(a)),this.tree.getRoot().set("data",{text:BI.i18nText("BI-Created_By_Me"),value:BI.FileManagerNav.ROOT_CREATE_BY_ME,id:BI.FileManagerNav.ROOT_CREATE_BY_ME})},populate:function(a){var b=BI.isNull(a)?[this.tree.getRoot()]:this._getAllParents(a.id);this.button_group.populate(this._formatNodes(b))}}),BI.extend(BI.FileManagerNav,{ROOT_CREATE_BY_ME:"-1"}),BI.FileManagerNav.EVENT_CHANGE="FileManagerNav.EVENT_CHANGE",BI.shortcut("bi.file_manager_nav",BI.FileManagerNav),BI.InteractiveArrangement=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-interactive-arrangement",resizable:!0,layoutType:BI.Arrangement.LAYOUT_TYPE.GRID,items:[]})},_init:function(){BI.InteractiveArrangement.superclass._init.apply(this,arguments);var a=this,b=this.options;this.arrangement=BI.createWidget({type:"bi.adaptive_arrangement",element:this,resizable:b.resizable,layoutType:b.layoutType,items:b.items}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL,function(){a.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL,arguments)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE,function(){a.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE,arguments)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE,function(b,c){var d=a._getRegionClientPosition(b);a.draw({left:d.left,top:d.top},c,b)}),this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE,function(b,c){a.stopDraw(),a.setRegionSize(b,c)}),this.tags=[]},_isEqual:function(a,b){return this.arrangement._isEqual(a,b)},_getScrollOffset:function(){return this.arrangement._getScrollOffset()},_positionAt:function(a,b){var c=this;b=b||this.getAllRegions();var d=[],e=[],f=[],g=[],h=[],i=[];return BI.each(b,function(b,j){var k=c._getRegionClientPosition(j.id);Math.abs(k.left-a.left)<=3&&d.push(j),Math.abs(k.left+k.width/2-a.left)<=3&&e.push(j),Math.abs(k.left+k.width-a.left)<=3&&f.push(j),Math.abs(k.top-a.top)<=3&&g.push(j),Math.abs(k.top+k.height/2-a.top)<=3&&h.push(j),Math.abs(k.top+k.height-a.top)<=3&&i.push(j)}),{left:d,center:e,right:f,top:g,middle:h,bottom:i}},_getRegionClientPosition:function(a){var b=this.getRegionByName(a),c=this.arrangement._getScrollOffset();return{top:b.top-c.top,left:b.left-c.left,width:b.width,height:b.height,id:b.id}},_vAlign:function(a,b){var c,d=this,e=this._positionAt(a,b),f=[];if(e.left.length>0)c=this._getRegionClientPosition(e.left[0].id).left;else if(e.right.length>0){var g=this._getRegionClientPosition(e.right[0].id);c=g.left+g.width}else if(e.center.length>0){var g=this._getRegionClientPosition(e.center[0].id);c=g.left+g.width/2}var h=e.left.concat(e.right).concat(e.center);return BI.each(h,function(b,e){var g=d._getRegionClientPosition(e.id);if(d._isEqual(g.left,c)||d._isEqual(g.left+g.width,c)||d._isEqual(g.left+g.width/2,c)){var h={top:g.top+g.height/2,left:c};f.push({id:e.id,start:h,end:{left:c,top:a.top}})}}),f},_leftAlign:function(a,b,c){return this._vAlign({left:a.left,top:a.top+b.height/2},c)},_rightAlign:function(a,b,c){return this._vAlign({left:a.left+b.width,top:a.top+b.height/2},c)},_hAlign:function(a,b){var c,d=this,e=this._positionAt(a,b),f=[];if(e.top.length>0){var g=this._getRegionClientPosition(e.top[0].id);c=g.top}else if(e.bottom.length>0){var g=this._getRegionClientPosition(e.bottom[0].id);c=g.top+g.height}else if(e.middle.length>0){var g=this._getRegionClientPosition(e.middle[0].id);c=g.top+g.height/2}var h=e.top.concat(e.bottom).concat(e.middle);return BI.each(h,function(b,e){var g=d._getRegionClientPosition(e.id);if(d._isEqual(g.top,c)||d._isEqual(g.top+g.height,c)||d._isEqual(g.top+g.height/2,c)){var h={top:c,left:g.left+g.width/2};f.push({id:g.id,start:h,end:{left:a.left,top:c}})}}),f},_topAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top},c)},_bottomAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top+b.height},c)},_centerAlign:function(a,b,c){return this._vAlign({left:a.left+b.width/2,top:a.top+b.height/2},c)},_middleAlign:function(a,b,c){return this._hAlign({left:a.left+b.width/2,top:a.top+b.height/2},c)},_drawOneTag:function(a,b){var c=BI.createWidget({type:"bi.icon_button",width:13,height:13,cls:"drag-tag-font interactive-arrangement-dragtag-icon"}),d=BI.createWidget({type:"bi.icon_button",width:13,height:13,cls:"drag-tag-font interactive-arrangement-dragtag-icon"});if(this._isEqual(a.left,b.left))var e=BI.createWidget({type:"bi.layout",cls:"interactive-arrangement-dragtag-line",width:1,height:Math.abs(a.top-b.top)});else var e=BI.createWidget({type:"bi.layout",cls:"interactive-arrangement-dragtag-line",height:1,width:Math.abs(a.left-b.left)});BI.createWidget({type:"bi.absolute",element:this,items:[{el:c,left:a.left-6,top:a.top-7},{el:d,left:b.left-6,top:b.top-7},{el:e,left:Math.min(a.left,b.left),top:Math.min(a.top,b.top)}]}),this.tags.push(c),this.tags.push(d),this.tags.push(e)},stopDraw:function(){BI.each(this.tags,function(a,b){b.destroy()}),this.tags=[]},_getRegionExcept:function(a,b){var c=[];return BI.each(b||this.getAllRegions(),function(b,d){a&&d.id===a||c.push(d)}),c},getClientWidth:function(){return this.arrangement.getClientWidth()},getClientHeight:function(){ +return this.arrangement.getClientHeight()},getPosition:function(a,b,c){var d,e=this.getAllRegions();a&&(d=this._getRegionClientPosition(a));var f=this._getRegionExcept(a,e);b=b||{left:d.left,top:d.top},c=c||{width:d.width,height:d.height};var g=this._leftAlign(b,c,f),h=this._rightAlign(b,c,f),i=this._topAlign(b,c,f,f),j=this._bottomAlign(b,c,f),k=this._centerAlign(b,c,f),l=this._middleAlign(b,c,f);return BI.each(k,function(a,d){b.left=d.end.left-c.width/2}),BI.each(h,function(a,d){b.left=d.end.left-c.width}),BI.each(g,function(a,c){b.left=c.end.left}),BI.each(l,function(a,d){b.top=d.end.top-c.height/2}),BI.each(j,function(a,d){b.top=d.end.top-c.height}),BI.each(i,function(a,c){b.top=c.end.top}),b},getSize:function(a,b,c){var d,e=this.getAllRegions();a&&(d=this._getRegionClientPosition(a));var f=this._getRegionExcept(a,e);b=b||{left:d.left,top:d.top},c=c||{width:d.width,height:d.height};var g=this._leftAlign(b,c,f),h=this._rightAlign(b,c,f),i=this._topAlign(b,c,f,f),j=this._bottomAlign(b,c,f),k=this._centerAlign(b,c,f),l=this._middleAlign(b,c,f);return BI.each(k,function(a,d){c.width=2*(d.end.left-b.left)}),BI.each(h,function(a,d){c.width=d.end.left-b.left}),BI.each(g,function(a,b){}),BI.each(l,function(a,d){c.height=2*(d.end.top-b.top)}),BI.each(j,function(a,d){c.height=d.end.top-b.top}),BI.each(i,function(a,b){}),c},draw:function(a,b,c){var d=this;switch(this.stopDraw(),this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:var e=this._getRegionExcept(c),f=this._leftAlign(a,b,e),g=this._rightAlign(a,b,e),h=this._topAlign(a,b,e),i=this._bottomAlign(a,b,e),j=this._centerAlign(a,b,e),k=this._middleAlign(a,b,e);BI.each(j,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(g,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(f,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(k,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(i,function(a,b){d._drawOneTag(b.start,b.end)}),BI.each(h,function(a,b){d._drawOneTag(b.start,b.end)});break;case BI.Arrangement.LAYOUT_TYPE.GRID:}},addRegion:function(a,b){return this.stopDraw(),this.arrangement.addRegion(a,b)},deleteRegion:function(a){return this.arrangement.deleteRegion(a)},setRegionSize:function(a,b){return b=this.getSize(a,null,b),this.arrangement.setRegionSize(a,b)},setPosition:function(a,b){if(this.stopDraw(),a.left>0&&a.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:a=this.getPosition(null,a,b),this.draw(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}var c=this.arrangement.setPosition(a,b);return c},setRegionPosition:function(a,b){if(b.left>0&&b.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:b=this.getPosition(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}return this.arrangement.setRegionPosition(a,b)},setDropPosition:function(a,b){var c=this;if(this.stopDraw(),a.left>0&&a.top>0)switch(this.getLayoutType()){case BI.Arrangement.LAYOUT_TYPE.FREE:a=this.getPosition(null,a,b),this.draw(a,b);break;case BI.Arrangement.LAYOUT_TYPE.GRID:}var d=c.arrangement.setDropPosition(a,b);return function(){d(),c.stopDraw()}},scrollInterval:function(){this.arrangement.scrollInterval.apply(this.arrangement,arguments)},scrollEnd:function(){this.arrangement.scrollEnd.apply(this.arrangement,arguments)},scrollTo:function(a){this.arrangement.scrollTo(a)},zoom:function(a){this.arrangement.zoom(a)},resize:function(){return this.arrangement.resize()},relayout:function(){return this.arrangement.relayout()},setLayoutType:function(a){this.arrangement.setLayoutType(a)},getLayoutType:function(){return this.arrangement.getLayoutType()},getLayoutRatio:function(){return this.arrangement.getLayoutRatio()},getHelper:function(){return this.arrangement.getHelper()},getRegionByName:function(a){return this.arrangement.getRegionByName(a)},getAllRegions:function(){return this.arrangement.getAllRegions()},revoke:function(){return this.arrangement.revoke()},populate:function(a){this.arrangement.populate(a)}}),BI.InteractiveArrangement.EVENT_RESIZE="InteractiveArrangement.EVENT_RESIZE",BI.InteractiveArrangement.EVENT_SCROLL="InteractiveArrangement.EVENT_SCROLL",BI.shortcut("bi.interactive_arrangement",BI.InteractiveArrangement),BI.MonthCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-month-combo",behaviors:{},height:25})},_init:function(){BI.MonthCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.month_trigger"}),this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM,function(b){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getValue()):this.getKey()||a.setValue(),a.fireEvent(BI.MonthCombo.EVENT_CONFIRM))}),this.trigger.on(BI.MonthTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.MonthTrigger.EVENT_START,function(){a.combo.hideView()}),this.trigger.on(BI.MonthTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.popup=BI.createWidget({type:"bi.month_popup",behaviors:b.behaviors}),this.popup.on(BI.MonthPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MonthCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,el:this.popup}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){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),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 a=this,b=this.options,c=[0,6,1,7,2,8,3,9,4,10,5,11],d=[];d.push(c.slice(0,2)),d.push(c.slice(2,4)),d.push(c.slice(4,6)),d.push(c.slice(6,8)),d.push(c.slice(8,10)),d.push(c.slice(10,12)),d=BI.map(d,function(a,b){return BI.map(b,function(a,b){return{type:"bi.text_item",cls:"bi-list-item-active",textAlign:"center",whiteSpace:"nowrap",once:!1,forceSelected:!0,height:23,width:38,value:b,text:b+1}})}),this.month=BI.createWidget({type:"bi.button_group",element:this,behaviors:b.behaviors,items:BI.createItems(d,{}),layouts:[BI.LogicFactory.createLogic("table",BI.extend({dynamic:!0},{columns:2,rows:6,columnSize:[.5,.5],rowSize:25})),{type:"bi.center_adapt",vgap:1,hgap:2}]}),this.month.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),b===BI.Events.CLICK&&a.fireEvent(BI.MonthPopup.EVENT_CHANGE)})},getValue:function(){return this.month.getValue()[0]},setValue:function(a){this.month.setValue([a])}}),BI.MonthPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.month_popup",BI.MonthPopup),BI.MonthTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:25,errorText:BI.i18nText("BI-Month_Trigger_Error_Text")},_defaultConfig:function(){return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-month-trigger bi-border",height:25})},_init:function(){BI.MonthTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(a){return""===a||BI.isPositiveInteger(a)&&a>=1&&a<=12},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.MonthTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.MonthTrigger.EVENT_CHANGE)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.MonthTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.MonthTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.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:c.triggerWidth},width:c.triggerWidth},{el:{type:"bi.trigger_icon_button",width:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){return BI.isNotNull(a)?(this.editor.setState(a+1),this.editor.setValue(a+1),void this.editor.setTitle(a+1)):(this.editor.setState(""),this.editor.setValue(""),void this.editor.setTitle(""))},getKey:function(){return 0|this.editor.getValue()},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),BI.MultiDateCard=BI.inherit(BI.Widget,{constants:{lgap:80,itemHeight:35,defaultEditorValue:"1"},_defaultConfig:function(){return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this,arguments),{})},dateConfig:function(){},defaultSelectedItem:function(){},_init:function(){BI.MultiDateCard.superclass._init.apply(this,arguments);var a=this;this.options;this.label=BI.createWidget({type:"bi.label",height:this.constants.itemHeight,textAlign:"left",text:BI.i18nText("BI-Multi_Date_Relative_Current_Time"),cls:"bi-multidate-inner-label bi-tips"}),this.radioGroup=BI.createWidget({type:"bi.button_group",chooseType:0,items:BI.createItems(this.dateConfig(),{type:"bi.multidate_segment",height:this.constants.itemHeight}),layouts:[{type:"bi.vertical"}]}),this.radioGroup.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CONFIRM&&a.fireEvent(BI.MultiDateCard.EVENT_CHANGE)}),this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE,function(){a.setValue(a.getValue()),a.fireEvent(BI.MultiDateCard.EVENT_CHANGE)}),BI.createWidget({element:this,type:"bi.center_adapt",lgap:this.constants.lgap,items:[{type:"bi.vertical",items:[this.label,this.radioGroup]}]})},getValue:function(){var a=this.radioGroup.getSelectedButtons()[0],b=a.getValue(),c=a.getInputValue();return{type:b,value:c}},_isTypeAvaliable:function(a){var b=!1;return BI.find(this.dateConfig(),function(c,d){if(d.value===a)return b=!0,!0}),b},setValue:function(a){var b=this;BI.isNotNull(a)&&this._isTypeAvaliable(a.type)?(this.radioGroup.setValue(a.type),BI.each(this.radioGroup.getAllButtons(),function(c,d){d.isEditorExist()===!0&&d.isSelected()?d.setInputValue(a.value):d.setInputValue(b.constants.defaultEditorValue)})):(this.radioGroup.setValue(this.defaultSelectedItem()),BI.each(this.radioGroup.getAllButtons(),function(a,c){c.setInputValue(b.constants.defaultEditorValue)}))},getCalculationValue:function(){var a=this.getValue(),b=a.type,c=a.value;switch(b){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:return(new Date).getOffsetDate(-1*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:return(new Date).getOffsetDate(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:return new Date;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:return(new Date).getBeforeMultiMonth(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:return(new Date).getAfterMultiMonth(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:return new Date((new Date).getFullYear(),(new Date).getMonth(),1);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:return new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getLastDateOfMonth().getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:return(new Date).getBeforeMulQuarter(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:return(new Date).getAfterMulQuarter(c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:return(new Date).getQuarterStartDate();case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:return(new Date).getQuarterEndDate();case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:return(new Date).getOffsetDate(-7*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:return(new Date).getOffsetDate(7*c);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:return new Date((new Date).getFullYear()-1*c,(new Date).getMonth(),(new Date).getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:return new Date((new Date).getFullYear()+1*c,(new Date).getMonth(),(new Date).getDate());case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:return new Date((new Date).getFullYear(),0,1);case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:return new Date((new Date).getFullYear(),11,31)}}}),BI.MultiDateCard.EVENT_CHANGE="EVENT_CHANGE",BI.MultiDateCombo=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"},_defaultConfig:function(){return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-combo bi-border",height:24})},_init:function(){BI.MultiDateCombo.superclass._init.apply(this,arguments);var a=this;this.options;this.storeTriggerValue="";var b=new Date;this.storeValue=null,this.trigger=BI.createWidget({type:"bi.date_trigger",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.DateTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK,function(){a.combo.toggle()}),this.trigger.on(BI.DateTrigger.EVENT_FOCUS,function(){a.storeTriggerValue=a.trigger.getKey(),a.combo.isViewVisible()||a.combo.showView(),a.fireEvent(BI.MultiDateCombo.EVENT_FOCUS)}),this.trigger.on(BI.DateTrigger.EVENT_ERROR,function(){a.storeValue={year:b.getFullYear(),month:b.getMonth()},a.popup.setValue(),a.fireEvent(BI.MultiDateCombo.EVENT_ERROR)}),this.trigger.on(BI.DateTrigger.EVENT_VALID,function(){a.fireEvent(BI.MultiDateCombo.EVENT_VALID)}),this.trigger.on(BI.DateTrigger.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDateCombo.EVENT_CHANGE)}),this.trigger.on(BI.DateTrigger.EVENT_CONFIRM,function(){if(!a.combo.isViewVisible()){var b=a.storeTriggerValue,c=a.trigger.getKey();BI.isNotEmptyString(c)&&!BI.isEqual(c,b)?(a.storeValue=a.trigger.getValue(),a.setValue(a.trigger.getValue())):BI.isEmptyString(c)&&(a.storeValue=null,a.trigger.setValue()),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}}),this.popup=BI.createWidget({type:"bi.multidate_popup",min:this.constants.DATE_MIN_VALUE,max:this.constants.DATE_MAX_VALUE}),this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE,function(){a.setValue(),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE,function(){var b=new Date;a.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,adjustLength:this.constants.comboAdjustHeight,popup:{el:this.popup,maxHeight:this.constants.popupHeight,width:this.constants.popupWidth,stopPropagation:!1}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.popup.setValue(a.storeValue),a.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW)});var c=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-font",width:30,height:23});c.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.combo.isViewVisible()?a.combo.hideView():a.combo.showView()}),this.changeIcon=BI.createWidget({type:"bi.icon_button",cls:"bi-trigger-icon-button date-change-h-font",width:30,height:23});var d=BI.createWidget({type:"bi.absolute",items:[{el:this.combo,top:0,left:0,right:0,bottom:0},{el:c,top:0,left:0}]});BI.createWidget({type:"bi.htape",element:this,items:[d,{el:this.changeIcon,width:30}],ref:function(b){a.comboWrapper=b}})},_checkDynamicValue:function(a){var b=null;switch(BI.isNotNull(a)&&(b=a.type),b){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:this.changeIcon.setVisible(!0),this.comboWrapper.attr("items")[1].width=30,this.comboWrapper.resize();break;default:this.comboWrapper.attr("items")[1].width=0,this.comboWrapper.resize(),this.changeIcon.setVisible(!1)}},setValue:function(a){this.storeValue=a,this.popup.setValue(a),this.trigger.setValue(a),this._checkDynamicValue(a)},getValue:function(){return this.storeValue},getKey:function(){return this.trigger.getKey()},hidePopupView:function(){this.combo.hideView()}}),BI.shortcut("bi.multidate_combo",BI.MultiDateCombo),BI.MultiDateCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.MultiDateCombo.EVENT_FOCUS="EVENT_FOCUS",BI.MultiDateCombo.EVENT_CHANGE="EVENT_CHANGE",BI.MultiDateCombo.EVENT_VALID="EVENT_VALID",BI.MultiDateCombo.EVENT_ERROR="EVENT_ERROR",BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW="BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW",BI.extend(BI.MultiDateCombo,{MULTI_DATE_YMD_CARD:1,MULTI_DATE_YEAR_CARD:2,MULTI_DATE_QUARTER_CARD:3,MULTI_DATE_MONTH_CARD:4,MULTI_DATE_WEEK_CARD:5,MULTI_DATE_DAY_CARD:6}),BI.extend(BI.MultiDateCombo,{DATE_TYPE:{MULTI_DATE_YEAR_PREV:1,MULTI_DATE_YEAR_AFTER:2,MULTI_DATE_YEAR_BEGIN:3,MULTI_DATE_YEAR_END:4,MULTI_DATE_MONTH_PREV:5,MULTI_DATE_MONTH_AFTER:6,MULTI_DATE_MONTH_BEGIN:7,MULTI_DATE_MONTH_END:8,MULTI_DATE_QUARTER_PREV:9,MULTI_DATE_QUARTER_AFTER:10,MULTI_DATE_QUARTER_BEGIN:11,MULTI_DATE_QUARTER_END:12,MULTI_DATE_WEEK_PREV:13,MULTI_DATE_WEEK_AFTER:14,MULTI_DATE_DAY_PREV:15,MULTI_DATE_DAY_AFTER:16,MULTI_DATE_DAY_TODAY:17,MULTI_DATE_PARAM:18,MULTI_DATE_CALENDAR:19,YEAR_QUARTER:20,YEAR_MONTH:21,YEAR_WEEK:22,YEAR_DAY:23,MONTH_WEEK:24,MONTH_DAY:25,YEAR:26,SAME_PERIOD:27,LAST_SAME_PERIOD:28}}),BI.DayCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.DayCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-daycard"})},_init:function(){BI.DayCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{isEditorExist:!0,selected:!0,text:BI.i18nText("BI-Multi_Date_Day_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Day_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY,text:BI.i18nText("BI-Multi_Date_Today")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV}}),BI.DayCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.daycard",BI.DayCard),BI.MonthCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-monthcard"})},_init:function(){BI.MonthCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV,text:BI.i18nText("BI-Multi_Date_Month_Prev")},{isEditorExist:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER,text:BI.i18nText("BI-Multi_Date_Month_Next")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Month_Begin")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Month_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV}}),BI.MonthCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.monthcard",BI.MonthCard),BI.MultiDatePopup=BI.inherit(BI.Widget,{constants:{tabHeight:30,tabWidth:42,titleHeight:27,itemHeight:30,triggerHeight:24,buttonWidth:90,buttonHeight:25,cardHeight:229,cardWidth:270,popupHeight:259,popupWidth:270,comboAdjustHeight:1,ymdWidth:58,lgap:2,border:1},_defaultConfig:function(){return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-popup",width:268,height:260})},_init:function(){BI.MultiDatePopup.superclass._init.apply(this,arguments);var a=this;this.options;this.storeValue="",this.textButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-label bi-border-left bi-border-right bi-border-top",shadow:!0,text:BI.i18nText("BI-Multi_Date_Today")}),this.textButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE)}),this.clearButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_Clear")}),this.clearButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE)}),this.okButton=BI.createWidget({type:"bi.text_button",forceCenter:!0,cls:"bi-multidate-popup-button bi-border-top",shadow:!0,text:BI.i18nText("BI-Basic_OK")}),this.okButton.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE)}),this.dateTab=BI.createWidget({type:"bi.tab",tab:{cls:"bi-multidate-popup-tab bi-border-bottom",height:this.constants.tabHeight,items:BI.createItems([{text:BI.i18nText("BI-Multi_Date_YMD"),value:BI.MultiDateCombo.MULTI_DATE_YMD_CARD,width:this.constants.ymdWidth},{text:BI.i18nText("BI-Multi_Date_Year"),value:BI.MultiDateCombo.MULTI_DATE_YEAR_CARD},{text:BI.i18nText("BI-Multi_Date_Quarter"),value:BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD},{text:BI.i18nText("BI-Multi_Date_Month"),value:BI.MultiDateCombo.MULTI_DATE_MONTH_CARD},{text:BI.i18nText("BI-Multi_Date_Week"),value:BI.MultiDateCombo.MULTI_DATE_WEEK_CARD},{text:BI.i18nText("BI-Multi_Date_Day"),value:BI.MultiDateCombo.MULTI_DATE_DAY_CARD}],{width:this.constants.tabWidth,textAlign:"center",height:this.constants.itemHeight,cls:"bi-multidate-popup-item bi-list-item-active"}),layouts:[{type:"bi.left"}]},cardCreator:function(b){switch(b){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:return a.ymd=BI.createWidget({type:"bi.date_calendar_popup",min:a.options.min,max:a.options.max}),a.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE,function(){a.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE)}),a.ymd;case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:return a.year=BI.createWidget({type:"bi.yearcard"}),a.year.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.year,b)}),a.year;case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:return a.quarter=BI.createWidget({type:"bi.quartercard"}),a.quarter.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.quarter,b)}),a.quarter;case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:return a.month=BI.createWidget({type:"bi.monthcard"}),a.month.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.month,b)}),a.month;case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:return a.week=BI.createWidget({type:"bi.weekcard"}),a.week.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.week,b)}),a.week;case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:return a.day=BI.createWidget({type:"bi.daycard"}),a.day.on(BI.MultiDateCard.EVENT_CHANGE,function(b){a._setInnerValue(a.day,b)}),a.day}}}),this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_YMD_CARD,this.dateTab.on(BI.Tab.EVENT_CHANGE,function(){var b=a.dateTab.getSelect();switch(b){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:var c=this.getTab(a.cur).getCalculationValue();a.ymd.setValue({year:c.getFullYear(),month:c.getMonth(),day:c.getDate()}),a._setInnerValue(a.ymd);break;case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:a.year.setValue(a.storeValue),a._setInnerValue(a.year);break;case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:a.quarter.setValue(a.storeValue),a._setInnerValue(a.quarter);break;case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:a.month.setValue(a.storeValue),a._setInnerValue(a.month);break;case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:a.week.setValue(a.storeValue),a._setInnerValue(a.week);break;case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:a.day.setValue(a.storeValue),a._setInnerValue(a.day)}a.cur=b}),this.dateButton=BI.createWidget({type:"bi.grid",items:[[this.clearButton,this.textButton,this.okButton]]}),BI.createWidget({element:this,type:"bi.vtape",items:[{el:this.dateTab},{el:this.dateButton,height:30}]})},_setInnerValue:function(a){if(this.dateTab.getSelect()===BI.MultiDateCombo.MULTI_DATE_YMD_CARD)this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")),this.textButton.setEnable(!0);else{var b=a.getCalculationValue();b=b.print("%Y-%x-%e"),this.textButton.setValue(b),this.textButton.setEnable(!1)}},setValue:function(a){this.storeValue=a;var b,c,d,e=this;switch(BI.isNotNull(a)&&(c=a.type||BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR,d=a.value,BI.isNull(d)&&(d=a)),c){case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD),this.year.setValue({type:c,value:d}),this.cur=BI.MultiDateCombo.MULTI_DATE_YEAR_CARD,e._setInnerValue(this.year);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD,this.quarter.setValue({type:c,value:d}),e._setInnerValue(this.quarter);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_MONTH_CARD,this.month.setValue({type:c,value:d}),e._setInnerValue(this.month);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_WEEK_CARD,this.week.setValue({type:c,value:d}),e._setInnerValue(this.week);break;case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER:case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY:this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD),this.cur=BI.MultiDateCombo.MULTI_DATE_DAY_CARD,this.day.setValue({type:c,value:d}),e._setInnerValue(this.day);break;default:if(BI.isNull(d)||BI.isEmptyObject(d)){var b=new Date;this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.ymd.setValue({year:b.getFullYear(),month:b.getMonth(),day:b.getDate()}),this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"))}else this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD),this.ymd.setValue(d),this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today"));this.textButton.setEnable(!0)}},getValue:function(){var a=this.dateTab.getSelect();switch(a){case BI.MultiDateCombo.MULTI_DATE_YMD_CARD:return this.ymd.getValue();case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD:return this.year.getValue();case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD:return this.quarter.getValue();case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD:return this.month.getValue();case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD:return this.week.getValue();case BI.MultiDateCombo.MULTI_DATE_DAY_CARD:return this.day.getValue()}}}),BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE="BUTTON_OK_EVENT_CHANGE",BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE="BUTTON_lABEL_EVENT_CHANGE",BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE="BUTTON_CLEAR_EVENT_CHANGE",BI.MultiDatePopup.CALENDAR_EVENT_CHANGE="CALENDAR_EVENT_CHANGE",BI.shortcut("bi.multidate_popup",BI.MultiDatePopup),BI.QuarterCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-quartercard"})},_init:function(){BI.QuarterCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Quarter_Prev")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Quarter_Next")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Quarter_Begin")},{value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END,isEditorExist:!1,text:BI.i18nText("BI-Multi_Date_Quarter_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV}}),BI.QuarterCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.quartercard",BI.QuarterCard),BI.MultiDateSegment=BI.inherit(BI.Single,{constants:{itemHeight:24,maxGap:15,minGap:10,textWidth:30,defaultEditorValue:"1"},_defaultConfig:function(){return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-segment",text:"",width:130,height:30,isEditorExist:!0,selected:!1,defaultEditorValue:"1"})},_init:function(){BI.MultiDateSegment.superclass._init.apply(this,arguments);var a=this,b=this.options;this.radio=BI.createWidget({type:"bi.radio",selected:b.selected}),this.radio.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.textEditor=BI.createWidget({type:"bi.text_editor",value:this.constants.defaultEditorValue,title:function(){return a.textEditor.getValue()},tipType:"success",cls:"bi-multidate-editor",width:this.constants.textWidth,height:this.constants.itemHeight}),this.textEditor.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",cls:"bi-multidate-normal-label",text:b.text,height:this.constants.itemHeight}),this._createSegment()},_createSegment:function(){return this.options.isEditorExist===!0?BI.createWidget({element:this,type:"bi.left",items:[{el:{type:"bi.center_adapt",items:[this.radio],height:this.constants.itemHeight},lgap:0},{el:{type:"bi.center_adapt",items:[this.textEditor],widgetName:"textEditor"},lgap:this.constants.maxGap},{el:this.text,lgap:this.constants.minGap}]}):BI.createWidget({element:this,type:"bi.left",items:[{el:{type:"bi.center_adapt",items:[this.radio],height:this.constants.itemHeight},lgap:0},{el:this.text,lgap:this.constants.maxGap}]})},setSelected:function(a){BI.isNotNull(this.radio)&&(this.radio.setSelected(a),this.textEditor.setEnable(a)); +},isSelected:function(){return this.radio.isSelected()},getValue:function(){return this.options.value},getInputValue:function(){return 0|this.textEditor.getValue()},setInputValue:function(a){this.textEditor.setValue(a)},isEditorExist:function(){return this.options.isEditorExist}}),BI.MultiDateSegment.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multidate_segment",BI.MultiDateSegment),BI.WeekCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-weekcard"})},_init:function(){BI.WeekCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Week_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Week_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV}}),BI.WeekCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.weekcard",BI.WeekCard),BI.YearCard=BI.inherit(BI.MultiDateCard,{_defaultConfig:function(){return $.extend(BI.YearCard.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multidate-yearcard"})},_init:function(){BI.YearCard.superclass._init.apply(this,arguments)},dateConfig:function(){return[{selected:!0,isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Year_Prev"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV},{isEditorExist:!0,text:BI.i18nText("BI-Multi_Date_Year_Next"),value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN,text:BI.i18nText("BI-Multi_Date_Year_Begin")},{isEditorExist:!1,value:BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END,text:BI.i18nText("BI-Multi_Date_Year_End")}]},defaultSelectedItem:function(){return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV}}),BI.YearCard.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.yearcard",BI.YearCard),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:!1,height:30,text:"",items:[]})},_init:function(){BI.MultiLayerSelectTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.multilayer_select_tree_popup",isDefaultInit:b.isDefaultInit,items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE)})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.MultiLayerSelectTreeCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_tree_combo",BI.MultiLayerSelectTreeCombo),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:!1,items:[],itemsCreator:BI.emptyFn})},_init:function(){BI.MultiLayerSelectLevelTree.superclass._init.apply(this,arguments),this.initTree(this.options.items)},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={};if(e.layer=b,BI.isKey(e.id)||(e.id=BI.UUID()),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.multilayer_select_tree_first_plus_group_node";break;case a.length-1:f.type="bi.multilayer_select_tree_last_plus_group_node";break;default:f.type="bi.multilayer_select_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children,b+1)}else{switch(d){case a.length-1:f.type="bi.multilayer_single_tree_last_tree_leaf_item";break;default:f.type="bi.multilayer_single_tree_mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_assertId:function(a){BI.each(a,function(a,b){b.id=b.id||BI.UUID()})},initTree:function(a){var b=this,c=this.options;this.empty(),this._assertId(a),this.tree=BI.createWidget({type:"bi.custom_tree",element:this,expander:{type:"bi.select_tree_expander",isDefaultInit:c.isDefaultInit,el:{},popup:{type:"bi.custom_tree"}},items:this._formatItems(BI.Tree.transformToTreeFormat(a),0),itemsCreator:c.itemsCreator,el:{type:"bi.button_tree",chooseType:BI.Selection.Single,layouts:[{type:"bi.vertical"}]}}),this.tree.on(BI.Controller.EVENT_CHANGE,function(a){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE,arguments)})},populate:function(a){this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(a),0))},setValue:function(a){this.tree.setValue(a)},getValue:function(){return this.tree.getValue()},getAllLeaves:function(){return this.tree.getAllLeaves()},getNodeById:function(a){return this.tree.getNodeById(a)},getNodeByValue:function(a){return this.tree.getNodeByValue(a)}}),BI.MultiLayerSelectLevelTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_level_tree",BI.MultiLayerSelectLevelTree),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:!1,itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSelectTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.multilayer_select_level_tree",isDefaultInit:b.isDefaultInit,items:b.items,itemsCreator:b.itemsCreator}),BI.createWidget({type:"bi.vertical",scrolly:!1,scrollable:!0,element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.MultiLayerSelectTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.MultiLayerSelectTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_select_tree_popup",BI.MultiLayerSelectTreePopup),BI.MultiLayerSelectTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-first-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_first_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},isOnce:function(){return!0},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(a){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.NodeButton.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_first_plus_group_node",BI.MultiLayerSelectTreeFirstPlusGroupNode),BI.MultiLayerSelectTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-last-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_last_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_last_plus_group_node",BI.MultiLayerSelectTreeLastPlusGroupNode),BI.MultiLayerSelectTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active",layer:0,id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.select_tree_mid_plus_group_node",cls:"bi-list-item-none",stopPropagation:!0,logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){a.setSelected(a.isSelected()),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this,arguments),this.node.setSelected(a)},doClick:function(){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this,arguments),this.node.setSelected(this.isSelected())},setOpened:function(a){BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node",BI.MultiLayerSelectTreeMidPlusGroupNode),BI.MultiLayerSingleTreeCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multilayer-singletree-combo",isDefaultInit:!1,height:30,text:"",itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSingleTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.multilayer_single_tree_popup",isDefaultInit:b.isDefaultInit,items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE)})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.MultiLayerSingleTreeCombo.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_tree_combo",BI.MultiLayerSingleTreeCombo),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:!1,items:[],itemsCreator:BI.emptyFn})},_init:function(){BI.MultiLayerSingleLevelTree.superclass._init.apply(this,arguments),this.initTree(this.options.items)},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={};if(e.layer=b,BI.isKey(e.id)||(e.id=BI.UUID()),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.multilayer_single_tree_first_plus_group_node";break;case a.length-1:f.type="bi.multilayer_single_tree_last_plus_group_node";break;default:f.type="bi.multilayer_single_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children,b+1)}else{switch(d){case a.length-1:f.type="bi.multilayer_single_tree_last_tree_leaf_item";break;default:f.type="bi.multilayer_single_tree_mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_assertId:function(a){BI.each(a,function(a,b){b.id=b.id||BI.UUID()})},initTree:function(a){var b=this,c=this.options;this.empty(),this._assertId(a),this.tree=BI.createWidget({type:"bi.custom_tree",element:this,expander:{isDefaultInit:c.isDefaultInit,el:{},popup:{type:"bi.custom_tree"}},items:this._formatItems(BI.Tree.transformToTreeFormat(a),0),itemsCreator:function(a,b){c.itemsCreator(a,function(a){b(BI.Tree.transformToTreeFormat(a),0)})},el:{type:"bi.button_tree",chooseType:BI.Selection.Single,layouts:[{type:"bi.vertical"}]}}),this.tree.on(BI.Controller.EVENT_CHANGE,function(a,c){b.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a===BI.Events.CLICK&&b.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE,c)})},populate:function(a){this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(a),0))},setValue:function(a){this.tree.setValue(a)},getValue:function(){return this.tree.getValue()},getAllLeaves:function(){return this.tree.getAllLeaves()},getNodeById:function(a){return this.tree.getNodeById(a)},getNodeByValue:function(a){return this.tree.getNodeByValue(a)}}),BI.MultiLayerSingleLevelTree.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_level_tree",BI.MultiLayerSingleLevelTree),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:!1,itemsCreator:BI.emptyFn,items:[]})},_init:function(){BI.MultiLayerSingleTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.multilayer_single_level_tree",isDefaultInit:b.isDefaultInit,items:b.items,itemsCreator:b.itemsCreator}),BI.createWidget({type:"bi.vertical",scrolly:!1,scrollable:!0,element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.MultiLayerSingleTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.MultiLayerSingleTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multilayer_single_tree_popup",BI.MultiLayerSingleTreePopup),BI.MultiLayerSingleTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-single-tree-first-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.first_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_first_plus_group_node",BI.MultiLayerSingleTreeFirstPlusGroupNode),BI.MultiLayerSingleTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-single-tree-last-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.last_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_last_plus_group_node",BI.MultiLayerSingleTreeLastPlusGroupNode),BI.MultiLayerSingleTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-multilayer-single-tree-mid-plus-group-node bi-list-item",layer:0,id:"",pId:"",open:!1,height:25})},_init:function(){BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.node=BI.createWidget({type:"bi.mid_plus_group_node",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,open:b.open,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.node.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.node),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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(a){BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.node)&&this.node.setOpened(a)}}),BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node",BI.MultiLayerSingleTreeMidPlusGroupNode),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.first_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item",BI.MultiLayerSingleTreeFirstTreeLeafItem),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.last_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item",BI.MultiLayerSingleTreeLastTreeLeafItem),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:!1},layer:0,id:"",pId:"",height:25})},_init:function(){BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this,arguments);var a=this,b=this.options;this.item=BI.createWidget({type:"bi.mid_tree_leaf_item",cls:"bi-list-item-none",logic:{dynamic:!0},id:b.id,pId:b.pId,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.item.on(BI.Controller.EVENT_CHANGE,function(b){b!==BI.Events.CLICK&&a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)});var c=[];BI.count(0,b.layer,function(){c.push({type:"bi.layout",cls:"base-line-conn-background",width:13,height:b.height})}),c.push(this.item),BI.createWidget({type:"bi.td",element:this,columnSize:BI.makeArray(b.layer,13),items:[c]})},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.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this,arguments),this.item.setSelected(this.isSelected())},setSelected:function(a){BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this,arguments),this.item.setSelected(a)}}),BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item",BI.MultiLayerSingleTreeMidTreeLeafItem),BI.MultiSelectCheckPane=BI.inherit(BI.Widget,{constants:{height:25,lgap:10,tgap: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 a=this,b=this.options;this.storeValue={},this.display=BI.createWidget({type:"bi.display_selected_list",items:b.items,itemsCreator:function(c,d){return c=BI.extend(c||{},{selectedValues:a.storeValue.value}),a.storeValue.type===BI.Selection.Multi?void d({items:BI.map(a.storeValue.value,function(a,c){var d=b.valueFormatter(c)||c;return{text:d,value:c,title:d}})}):void b.itemsCreator(c,d)}}),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(){b.onClickContinueSelect()}),BI.createWidget({type:"bi.vtape",element:this,items:[{height:this.constants.height,el:{type:"bi.left",cls:"multi-select-continue-select",items:[{el:{type:"bi.label",text:BI.i18nText("BI-Selected_Data")},lgap:this.constants.lgap,tgap:this.constants.tgap},{el:this.continueSelect,lgap:this.constants.lgap,tgap:this.constants.tgap}]}},{height:"fill",el:this.display}]})},setValue:function(a){this.storeValue=a||{}},empty:function(){this.display.empty()},populate:function(){this.display.populate.apply(this.display,arguments)}}),BI.shortcut("bi.multi_select_check_pane",BI.MultiSelectCheckPane),BI.DisplaySelectedList=BI.inherit(BI.Pane,{constants:{height:25,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 a=this,b=this.options;this.hasNext=!1,this.button_group=BI.createWidget({type:"bi.list_pane",element:this,el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},items:this._createItems(b.items),chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,layouts:[{type:"bi.vertical",lgap:10}]},itemsCreator:function(c,d){b.itemsCreator(c,function(b){a.hasNext=!!b.hasNext,d(a._createItems(b.items))})},hasNext:function(){return a.hasNext}})},_createItems:function(a){return BI.createItems(a,{type:"bi.icon_text_item",cls:"cursor-default check-font display-list-item bi-tips",once:!0,invalid:!0,selected:!0,height:this.constants.height,logic:{dynamic:!0}})},empty:function(){this.button_group.empty()},populate:function(a){0===arguments.length?this.button_group.populate():this.button_group.populate(this._createItems(a))}}),BI.shortcut("bi.display_selected_list",BI.DisplaySelectedList),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:28})},_init:function(){BI.MultiSelectCombo.superclass._init.apply(this,arguments);var a=this,b=this.options,c=function(){BI.isKey(a._startValue)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](a._startValue),a.trigger.getSearcher().setState(a.storeValue),a.trigger.getCounter().setButtonChecked(a.storeValue)};this.storeValue={},this.requesting=!1,this.trigger=BI.createWidget({type:"bi.multi_select_trigger",height:b.height,masker:{offset:{left:1,top:1,right:2,bottom:33}},valueFormatter:b.valueFormatter,itemsCreator:function(c,d){b.itemsCreator(c,function(b){1===c.times&&BI.isNotNull(c.keywords)&&a.trigger.setValue(BI.deepClone(a.getValue())),d.apply(a,arguments)})}}),this.trigger.on(BI.MultiSelectTrigger.EVENT_START,function(){a._setStartValue(""),this.getSearcher().setValue(a.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP,function(){a._setStartValue("")}),this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE,function(){var b=this.getSearcher().getKeyword();a._join({type:BI.Selection.Multi,value:[b]},function(){a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a.combo.setValue(a.storeValue),a._setStartValue(b),c(),a.populate(),a._setStartValue("")})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING,function(b){var d=BI.last(b);b=BI.initial(b||[]),b.length>0&&a._joinKeywords(b,function(){BI.isEndWithBlank(d)?(a.combo.setValue(a.storeValue),c(),a.combo.populate(),a._setStartValue("")):(a.combo.setValue(a.storeValue),c())})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE,function(b,d){d instanceof BI.MultiSelectBar?a._joinAll(this.getValue(),function(){c()}):a._join(this.getValue(),function(){c()})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,function(){this.getCounter().setValue(a.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK,function(){a.combo.isViewVisible()||a.combo.showView()}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,el:this.trigger,adjustLength:1,popup:{type:"bi.multi_select_popup_view",ref:function(){a.popup=this,a.trigger.setAdapter(this)},listeners:[{eventName:BI.MultiSelectPopupView.EVENT_CHANGE, +action:function(){a.storeValue=this.getValue(),a._adjust(function(){c()})}},{eventName:BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM,action:function(){a._defaultState()}},{eventName:BI.MultiSelectPopupView.EVENT_CLICK_CLEAR,action:function(){a.setValue(),a._defaultState()}}],itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,onLoaded:function(){BI.nextTick(function(){a.combo.adjustWidth(),a.combo.adjustHeight(),a.trigger.getCounter().adjustView(),a.trigger.getSearcher().adjustView()})}},hideChecker:function(a){return 0===d.element.find(a.target).length}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){this.setValue(a.storeValue),BI.nextTick(function(){a.populate()})}),this.wants2Quit=!1,this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW,function(){a.trigger.stopEditing(),a.requesting===!0?a.wants2Quit=!0:a.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM)});var d=BI.createWidget({type:"bi.trigger_icon_button",width:b.height,height:b.height,cls:"multi-select-trigger-icon-button bi-border-left"});d.on(BI.TriggerIconButton.EVENT_CHANGE,function(){a.trigger.getCounter().hideView(),a.combo.isViewVisible()?a.combo.hideView():a.combo.showView()}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.combo,left:0,right:0,top:0,bottom:0},{el:d,right:0,top:0,bottom:0}]})},_defaultState:function(){this.trigger.stopEditing(),this.combo.hideView()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},_makeMap:function(a){return BI.makeObject(a||[])},_joinKeywords:function(a,b){function c(c){var e=d._makeMap(c);BI.each(a,function(a,b){BI.isNotNull(e[b])&&d.storeValue.value[d.storeValue.type===BI.Selection.Multi?"pushDistinct":"remove"](b)}),d._adjust(b)}var d=this,e=this.options;this._assertValue(this.storeValue),this.requesting=!0,e.itemsCreator({type:BI.MultiSelectCombo.REQ_GET_ALL_DATA,keywords:a},function(a){var b=BI.pluck(a.items,"value");c(b)})},_joinAll:function(a,b){var c=this,d=this.options;this._assertValue(a),this.requesting=!0,d.itemsCreator({type:BI.MultiSelectCombo.REQ_GET_ALL_DATA,keywords:[this.trigger.getKey()]},function(d){var e=BI.pluck(d.items,"value");if(c.storeValue.type===a.type){var f=!1,g=c._makeMap(c.storeValue.value);return BI.each(e,function(a,b){BI.isNotNull(g[b])&&(f=!0,delete g[b])}),f&&(c.storeValue.value=BI.values(g)),void c._adjust(b)}var h=c._makeMap(c.storeValue.value),i=c._makeMap(a.value),j=[];BI.each(e,function(a,b){BI.isNotNull(h[e[a]])&&delete h[e[a]],BI.isNull(i[e[a]])&&j.push(b)}),c.storeValue.value=j.concat(BI.values(h)),c._adjust(b)})},_adjust:function(a){function b(){c.wants2Quit===!0&&(c.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM),c.wants2Quit=!1),c.requesting=!1}var c=this;this.options;b(),a()},_join:function(a,b){var c=this;this.options;if(this._assertValue(a),this._assertValue(this.storeValue),this.storeValue.type===a.type){var d=this._makeMap(this.storeValue.value);BI.each(a.value,function(a,b){d[b]||(c.storeValue.value.push(b),d[b]=b)});var e=!1;return BI.each(a.assist,function(a,b){BI.isNotNull(d[b])&&(e=!0,delete d[b])}),e&&(this.storeValue.value=BI.values(d)),void c._adjust(b)}this._joinAll(a,b)},_setStartValue:function(a){this._startValue=a,this.popup.setStartValue(a)},setValue:function(a){this.storeValue=a||{},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:0,REQ_GET_ALL_DATA:-1}),BI.MultiSelectCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.shortcut("bi.multi_select_combo",BI.MultiSelectCombo),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:!0},el:{height:400},valueFormatter:BI.emptyFn,itemsCreator:BI.emptyFn,onLoaded:BI.emptyFn})},_init:function(){BI.MultiSelectLoader.superclass._init.apply(this,arguments);var a=this,b=this.options,c=!1;this.button_group=BI.createWidget({type:"bi.select_list",element:this,logic:b.logic,el:BI.extend({onLoaded:b.onLoaded,el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},el:{chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,behaviors:{redmark:function(){return!0}},layouts:[{type:"bi.vertical"}]}}},b.el),itemsCreator:function(d,e){var f=a._startValue;a.storeValue&&(d=BI.extend(d||{},{selectedValues:BI.isKey(f)&&a.storeValue.type===BI.Selection.Multi?a.storeValue.value.concat(f):a.storeValue.value})),b.itemsCreator(d,function(g){c=g.hasNext;var h=[];if(1===d.times&&a.storeValue){var i=BI.map(a.storeValue.value,function(c,d){var e=b.valueFormatter(d)||d;return{text:e,value:d,title:e,selected:a.storeValue.type===BI.Selection.Multi}});if(BI.isKey(a._startValue)&&!a.storeValue.value.contains(a._startValue)){var j=b.valueFormatter(f)||f;i.unshift({text:j,value:f,title:j,selected:!0})}h=a._createItems(i)}e(h.concat(a._createItems(g.items)),g.keyword||""),1===d.times&&a.storeValue&&(BI.isKey(f)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](f),a.setValue(a.storeValue)),1===d.times&&a._scrollToTop()})},hasNext:function(){return c}}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.SelectList.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE,arguments)})},_createItems:function(a){return BI.createItems(a,{type:"bi.multi_select_item",logic:this.options.logic,height:25,selected:this.isAllSelected()})},_scrollToTop:function(){var a=this;BI.delay(function(){a.button_group.element.scrollTop(0)},30)},isAllSelected:function(){return this.button_group.isAllSelected()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},setStartValue:function(a){this._startValue=a},setValue:function(a){this.storeValue=a||{},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(a){this.button_group.populate.apply(this.button_group,arguments)},resetHeight:function(a){this.button_group.resetHeight(a)},resetWidth:function(a){this.button_group.resetWidth(a)}}),BI.MultiSelectLoader.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_loader",BI.MultiSelectLoader),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 a=this,b=this.options;this.loader=BI.createWidget({type:"bi.multi_select_loader",itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,onLoaded:b.onLoaded}),this.popupView=BI.createWidget({type:"bi.multi_popup_view",stopPropagation:!1,maxWidth:b.maxWidth,minWidth:b.minWidth,maxHeight:b.maxHeight,element:this,buttons:[BI.i18nText("BI-Basic_Clears"),BI.i18nText("BI-Basic_Sure")],el:this.loader}),this.popupView.on(BI.MultiPopupView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE)}),this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON,function(b){switch(b){case 0:a.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR);break;case 1:a.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM)}})},isAllSelected:function(){return this.loader.isAllSelected()},setStartValue:function(a){this.loader.setStartValue(a)},setValue:function(a){this.popupView.setValue(a)},getValue:function(){return this.popupView.getValue()},populate:function(a){this.popupView.populate.apply(this.popupView,arguments)},resetHeight:function(a){this.popupView.resetHeight(a)},resetWidth:function(a){this.popupView.resetWidth(a)}}),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),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 a=this,b=this.options;b.height&&this.setHeight(b.height-2),this.searcher=BI.createWidget(b.searcher,{type:"bi.multi_select_searcher",height:b.height,itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,popup:{},adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.MultiSelectSearcher.EVENT_START,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_START)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING,arguments)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_STOP)}),this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE,arguments)}),this.numberCounter=BI.createWidget(b.switcher,{type:"bi.multi_select_check_selected_switcher",valueFormatter:b.valueFormatter,itemsCreator:b.itemsCreator,adapter:b.adapter,masker:b.masker}),this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK)}),this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW)});var c=BI.createWidget({type:"bi.right_vertical_adapt",hgap:4,items:[{el:this.numberCounter}]}),d=BI.createWidget({type:"bi.htape",element:this,items:[{el:this.searcher,width:"fill"},{el:c,width:0},{el:BI.createWidget(),width:30}]});this.numberCounter.on(BI.Events.VIEW,function(b){BI.nextTick(function(){d.attr("items")[1].width=b===!0?a.numberCounter.element.outerWidth()+8:0,d.resize()})}),this.element.click(function(b){a.element.__isMouseInBounds__(b)&&!a.numberCounter.element.__isMouseInBounds__(b)&&a.numberCounter.hideView()})},getCounter:function(){return this.numberCounter},getSearcher:function(){return this.searcher},stopEditing:function(){this.searcher.stopSearch(),this.numberCounter.hideView()},setAdapter:function(a){this.searcher.setAdapter(a),this.numberCounter.setAdapter(a)},setValue:function(a){this.searcher.setValue(a),this.numberCounter.setValue(a)},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),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 a=this,b=this.options,c=!1;this.button_group=BI.createWidget({type:"bi.select_list",element:this,logic:{dynamic:!1},el:{tipText:BI.i18nText("BI-No_Select"),el:{type:"bi.loader",isDefaultInit:!1,logic:{dynamic:!0,scrolly:!0},el:{chooseType:BI.ButtonGroup.CHOOSE_TYPE_MULTI,behaviors:{redmark:function(){return!0}},layouts:[{type:"bi.vertical"}]}}},itemsCreator:function(d,e){a.storeValue&&(d=BI.extend(d||{},{selectedValues:a.storeValue.value})),b.itemsCreator(d,function(f){var g=f.keyword=b.keywordGetter();c=f.hasNext;var h=[];if(1===d.times&&a.storeValue){var i=a._filterValues(a.storeValue);h=a._createItems(i)}e(h.concat(a._createItems(f.items)),g),1===d.times&&a.storeValue&&a.setValue(a.storeValue)})},hasNext:function(){return c}}),this.button_group.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.button_group.on(BI.SelectList.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE,arguments)})},_createItems:function(a){return BI.createItems(a,{type:"bi.multi_select_item",logic:{dynamic:!1},height:25,selected:this.isAllSelected()})},isAllSelected:function(){return this.button_group.isAllSelected()},_filterValues:function(a){var b=this.options,c=b.keywordGetter(),d=BI.deepClone(a.value)||[],e=BI.map(d,function(a,c){return{text:b.valueFormatter(c)||c,value:c}});if(BI.isKey(c)){var f=BI.Func.getSearchResult(e,c);d=f.matched.concat(f.finded)}return BI.map(d,function(b,c){return{text:c.text,title:c.text,value:c.value,selected:a.type===BI.Selection.All}})},setValue:function(a){this.storeValue=BI.deepClone(a),this.button_group.setValue(a)},getValue:function(){return this.button_group.getValue()},getAllButtons:function(){return this.button_group.getAllButtons()},empty:function(){this.button_group.empty()},populate:function(a){this.button_group.populate.apply(this.button_group,arguments)},resetHeight:function(a){this.button_group.resetHeight(a)},resetWidth:function(a){this.button_group.resetWidth(a)}}),BI.MultiSelectSearchLoader.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_search_loader",BI.MultiSelectSearchLoader),BI.MultiSelectSearchPane=BI.inherit(BI.Widget,{constants:{height:25,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 a=this,b=this.options;this.tooltipClick=BI.createWidget({type:"bi.label",invisible:!0,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:b.keywordGetter,valueFormatter:b.valueFormatter,itemsCreator:function(c,d){b.itemsCreator.apply(a,[c,function(c){d(c),a.setKeyword(b.keywordGetter())}])}}),this.loader.on(BI.Controller.EVENT_CHANGE,function(){a.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(!1)},setKeyword:function(a){var b,c=this.loader.getAllButtons().length>0&&(b=this.loader.getAllButtons()[0])&&a===b.getValue();c!==this.tooltipClick.isVisible()&&(this.tooltipClick.setVisible(c),this.resizer.attr("items")[0].height=c?this.constants.height:0,this.resizer.resize())},isAllSelected:function(){return this.loader.isAllSelected()},hasMatched:function(){return this.tooltipClick.isVisible()},setValue:function(a){this.loader.setValue(a)},getValue:function(){return this.loader.getValue()},empty:function(){this.loader.empty()},populate:function(a){this.loader.populate.apply(this.loader,arguments)}}),BI.MultiSelectSearchPane.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_search_pane",BI.MultiSelectSearchPane),BI.MultiSelectCheckSelectedButton=BI.inherit(BI.Single,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_defaultConfig:function(){return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multi-select-check-selected-button bi-high-light",itemsCreator:BI.emptyFn})},_init:function(){BI.MultiSelectCheckSelectedButton.superclass._init.apply(this,arguments);var a=this;this.numberCounter=BI.createWidget({type:"bi.text_button",element:this,hgap:4,text:"0",textAlign:"center",textHeight:15}),this.numberCounter.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.numberCounter.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE,arguments)}),this.numberCounter.element.hover(function(){a.numberCounter.setTag(a.numberCounter.getText()),a.numberCounter.setText(a._const.checkSelected)},function(){a.numberCounter.setText(a.numberCounter.getTag())}),this.setVisible(!1)},setValue:function(a){var b=this,c=this.options;return a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[]),a.type===BI.Selection.All?void c.itemsCreator({type:BI.MultiSelectCombo.REQ_GET_DATA_LENGTH},function(c){var d=c.count-a.value.length;BI.nextTick(function(){b.numberCounter.setText(d),b.setVisible(d>0)})}):void BI.nextTick(function(){b.numberCounter.setText(a.value.length),b.setVisible(a.value.length>0)})},getValue:function(){}}),BI.MultiSelectCheckSelectedButton.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_select_check_selected_button",BI.MultiSelectCheckSelectedButton),BI.MultiSelectEditor=BI.inherit(BI.Widget,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_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 a=this,b=this.options;this.editor=BI.createWidget(b.el,{type:"bi.state_editor",element:this,height:b.height,watermark:BI.i18nText("BI-Basic_Search"),allowBlank:!0}),this.editor.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.editor.on(BI.StateEditor.EVENT_PAUSE,function(){a.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(a){this.editor.setState(a)},setValue:function(a){this.editor.setValue(a)},getValue:function(){var a=this.editor.getState();return BI.isArray(a)&&a.length>0?a[a.length-1]:""},getKeywords:function(){var a=this.editor.getLastValidValue(),b=a.match(/[\S]+/g);return BI.isEndWithBlank(a)?b.concat([" "]):b},populate:function(a){}}),BI.MultiSelectEditor.EVENT_PAUSE="MultiSelectEditor.EVENT_PAUSE",BI.shortcut("bi.multi_select_editor",BI.MultiSelectEditor),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:{}})},_init:function(){BI.MultiSelectSearcher.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget(b.el,{type:"bi.multi_select_editor",height:b.height}),this.searcher=BI.createWidget({type:"bi.searcher",element:this,height:b.height,isAutoSearch:!1,isAutoSync:!1,onSearch:function(a,b){b()},el:this.editor,popup:BI.extend({type:"bi.multi_select_search_pane",valueFormatter:b.valueFormatter,keywordGetter:function(){return a.editor.getValue()},itemsCreator:function(c,d){c.keyword=a.editor.getValue(),this.setKeyword(c.keyword),b.itemsCreator(c,d)}},b.popup),adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.Searcher.EVENT_START,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_START)}),this.searcher.on(BI.Searcher.EVENT_PAUSE,function(){this.hasMatched(),a.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE)}),this.searcher.on(BI.Searcher.EVENT_STOP,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_STOP)}),this.searcher.on(BI.Searcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE,arguments)}),this.searcher.on(BI.Searcher.EVENT_SEARCHING,function(){var b=this.getKeywords();a.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING,b)})},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(a){this.searcher.setAdapter(a)},setState:function(a){var b=this.options;a||(a={}),a.value||(a.value=[]),a.type===BI.Selection.All?1===BI.size(a.assist)?this.editor.setState(b.valueFormatter(a.assist[0]+"")||a.assist[0]+""):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.All):1===BI.size(a.value)?this.editor.setState(b.valueFormatter(a.value[0]+"")||a.value[0]+""):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.None)},setValue:function(a){this.setState(a),this.searcher.setValue(a)},getKey:function(){return this.editor.getValue()},getValue:function(){return this.searcher.getValue()},populate:function(a){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),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 a=this,b=this.options;this.button=BI.createWidget(b.el,{type:"bi.multi_select_check_selected_button",itemsCreator:b.itemsCreator}),this.button.on(BI.Events.VIEW,function(){a.fireEvent(BI.Events.VIEW,arguments)}),this.switcher=BI.createWidget({type:"bi.switcher",toggle:!1,element:this,el:this.button,popup:BI.extend({type:"bi.multi_select_check_pane",valueFormatter:b.valueFormatter,itemsCreator:b.itemsCreator,onClickContinueSelect:function(){a.switcher.hideView()}},b.popup),adapter:b.adapter,masker:b.masker}),this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE)}),this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW)}),this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW,function(){var a=this;BI.nextTick(function(){a.populate()})}),this.switcher.element.click(function(a){a.stopPropagation()})},adjustView:function(){this.switcher.adjustView()},hideView:function(){this.switcher.empty(),this.switcher.hideView()},setAdapter:function(a){this.switcher.setAdapter(a)},setValue:function(a){this.switcher.setValue(a)},setButtonChecked:function(a){this.button.setValue(a)},getValue:function(){},populate:function(a){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),BI.MultiSelectList=BI.inherit(BI.Widget,{_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 a=this,b=this.options;this.storeValue={};var c=function(){BI.isKey(a._startValue)&&a.storeValue.value[a.storeValue.type===BI.Selection.All?"remove":"pushDistinct"](a._startValue)};this.adapter=BI.createWidget({type:"bi.multi_select_loader",cls:"popup-multi-select-list bi-border-left bi-border-right bi-border-bottom",itemsCreator:b.itemsCreator,valueFormatter:b.valueFormatter,logic:{dynamic:!1},el:{}}),this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE,function(){a.storeValue=this.getValue(),a._adjust(function(){c(),a.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:b.valueFormatter,keywordGetter:function(){return a.trigger.getKeyword()},itemsCreator:function(c,d){c.keyword=a.trigger.getKeyword(),this.setKeyword(c.keyword),b.itemsCreator(c,d)}}),this.searcherPane.setVisible(!1),this.trigger=BI.createWidget({type:"bi.searcher",isAutoSearch:!1,isAutoSync:!1,onSearch:function(a,b){b()},adapter:this.adapter,popup:this.searcherPane,height:200,masker:!1,listeners:[{eventName:BI.Searcher.EVENT_START,action:function(){a._showSearcherPane(),a._setStartValue(""),this.setValue(BI.deepClone(a.storeValue))}},{eventName:BI.Searcher.EVENT_STOP,action:function(){a._showAdapter(),a._setStartValue(""),a.adapter.setValue(a.storeValue),a.adapter.populate()}},{eventName:BI.Searcher.EVENT_PAUSE,action:function(){var b=this.getKeyword();this.hasMatched()?a._join({type:BI.Selection.Multi,value:[b]},function(){a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a._showAdapter(),a.adapter.setValue(a.storeValue),a._setStartValue(b),c(),a.adapter.populate(),a._setStartValue(""),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)}):(a.storeValue.type===BI.Selection.Multi&&a.storeValue.value.pushDistinct(b),a._showAdapter(),a.adapter.setValue(a.storeValue),a.adapter.populate(),a.storeValue.type===BI.Selection.Multi&&a.fireEvent(BI.MultiSelectList.EVENT_CHANGE))}},{eventName:BI.Searcher.EVENT_SEARCHING,action:function(){var b=this.getKeyword(),d=BI.last(b);b=BI.initial(b||[]),b.length>0&&a._joinKeywords(b,function(){BI.isEndWithBlank(d)?(a.adapter.setValue(a.storeValue),c(),a.adapter.populate(),a._setStartValue("")):(a.adapter.setValue(a.storeValue),c())})}},{eventName:BI.Searcher.EVENT_CHANGE,action:function(b,d){d instanceof BI.MultiSelectBar?a._joinAll(this.getValue(),function(){c(),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)}):a._join(this.getValue(),function(){c(),a.fireEvent(BI.MultiSelectList.EVENT_CHANGE)})}}]}),BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.trigger,height:30},{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(!0),this.searcherPane.setVisible(!1)},_showSearcherPane:function(){this.searcherPane.setVisible(!0),this.adapter.setVisible(!1)},_defaultState:function(){this.trigger.stopEditing()},_assertValue:function(a){a||(a={}),a.type||(a.type=BI.Selection.Multi),a.value||(a.value=[])},_makeMap:function(a){return BI.makeObject(a||[])},_joinKeywords:function(a,b){function c(c){var e=d._makeMap(c);BI.each(a,function(a,b){BI.isNotNull(e[b])&&d.storeValue.value[d.storeValue.type===BI.Selection.Multi?"pushDistinct":"remove"](b)}),d._adjust(b)}var d=this,e=this.options;this._assertValue(this.storeValue),this._allData?c(this._allData):e.itemsCreator({type:BI.MultiSelectList.REQ_GET_ALL_DATA},function(a){d._allData=BI.pluck(a.items,"value"),c(d._allData)})},_joinAll:function(a,b){var c=this,d=this.options;this._assertValue(a),d.itemsCreator({type:BI.MultiSelectList.REQ_GET_ALL_DATA,keyword:c.trigger.getKeyword()},function(d){var e=BI.pluck(d.items,"value");if(c.storeValue.type===a.type){var f=!1,g=c._makeMap(c.storeValue.value);return BI.each(e,function(a,b){BI.isNotNull(g[b])&&(f=!0,delete g[b])}),f&&(c.storeValue.value=BI.values(g)),void c._adjust(b)}var h=c._makeMap(c.storeValue.value),i=c._makeMap(a.value),j=[];BI.each(e,function(a,b){BI.isNotNull(h[e[a]])&&delete h[e[a]],BI.isNull(i[e[a]])&&j.push(b)}),c.storeValue.value=j.concat(BI.values(h)),c._adjust(b)})},_adjust:function(a){function b(){}this.options;b(),a()},_join:function(a,b){var c=this;this.options;if(this._assertValue(a),this._assertValue(this.storeValue),this.storeValue.type===a.type){var d=this._makeMap(this.storeValue.value);BI.each(a.value,function(a,b){d[b]||(c.storeValue.value.push(b),d[b]=b)});var e=!1;return BI.each(a.assist,function(a,b){BI.isNotNull(d[b])&&(e=!0,delete d[b])}),e&&(this.storeValue.value=BI.values(d)),void c._adjust(b)}this._joinAll(a,b)},_setStartValue:function(a){this._startValue=a,this.adapter.setStartValue(a)},isAllSelected:function(){return this.adapter.isAllSelected()},resize:function(){},setValue:function(a){this.storeValue=a||{},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:0,REQ_GET_ALL_DATA:-1}),BI.MultiSelectList.EVENT_CHANGE="BI.MultiSelectList.EVENT_CHANGE",BI.shortcut("bi.multi_select_list",BI.MultiSelectList),BI.MultiSelectTree=BI.inherit(BI.Widget,{_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 a=this,b=this.options;this.storeValue={value:{}},this.adapter=BI.createWidget({type:"bi.multi_select_tree_popup",itemsCreator:b.itemsCreator}),this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE,function(){a.searcher.isSearching()?a.storeValue={value:a.searcherPane.getValue()}:a.storeValue={value:a.adapter.getValue()},a.setSelectedValue(a.storeValue.value),a.fireEvent(BI.MultiSelectTree.EVENT_CHANGE)}),this.searcherPane=BI.createWidget({type:"bi.multi_tree_search_pane",cls:"bi-border-left bi-border-right bi-border-bottom",keywordGetter:function(){return a.searcher.getKeyword()},itemsCreator:function(c,d){c.keyword=a.searcher.getKeyword(),b.itemsCreator(c,d)}}),this.searcherPane.setVisible(!1),this.searcher=BI.createWidget({type:"bi.searcher",isAutoSearch:!1,isAutoSync:!1,onSearch:function(b,c){c({keyword:a.searcher.getKeyword()})},adapter:this.adapter,popup:this.searcherPane,masker:!1,listeners:[{eventName:BI.Searcher.EVENT_START,action:function(){a._showSearcherPane()}},{eventName:BI.Searcher.EVENT_STOP,action:function(){a._showAdapter(),BI.nextTick(function(){a.adapter.populate()})}},{eventName:BI.Searcher.EVENT_CHANGE,action:function(){a.searcher.isSearching()?a.storeValue={value:a.searcherPane.getValue()}:a.storeValue={value:a.adapter.getValue()},a.setSelectedValue(a.storeValue.value),a.fireEvent(BI.MultiSelectTree.EVENT_CHANGE)}},{eventName:BI.Searcher.EVENT_PAUSE,action:function(){a._showAdapter()}}]}),BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.searcher,height:30},{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(!0),this.searcherPane.setVisible(!1)},_showSearcherPane:function(){this.searcherPane.setVisible(!0),this.adapter.setVisible(!1)},resize:function(){},setSelectedValue:function(a){this.storeValue.value=a||{},this.adapter.setSelectedValue(a),this.searcherPane.setSelectedValue(a),this.searcher.setValue({value:a||{}})},setValue:function(a){this.adapter.setValue(a)},stopSearch:function(){ +this.searcher.stopSearch()},updateValue:function(a){this.adapter.updateValue(a)},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),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 a=this,b=this.options;this.popup=BI.createWidget({type:"bi.async_tree",element:this,itemsCreator:b.itemsCreator}),this.popup.on(BI.TreeView.EVENT_AFTERINIT,function(){a.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)}),this.popup.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)})},hasChecked:function(){return this.popup.hasChecked()},getValue:function(){return this.popup.getValue()},setValue:function(a){a||(a={}),this.popup.setValue(a)},setSelectedValue:function(a){a||(a={}),this.popup.setSelectedValue(a)},updateValue:function(a){this.popup.updateValue(a),this.popup.refresh()},populate:function(a){this.popup.stroke(a)}}),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),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 a=this,b=this.options;this.selectedValues={};var c=BI.createWidget({type:"bi.text_button",text:BI.i18nText("BI-Continue_Select"),cls:"multi-tree-check-selected"});c.on(BI.TextButton.EVENT_CHANGE,function(){b.onClickContinueSelect(),BI.nextTick(function(){a.empty()})});var d=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:c,lgap:this.constants.lgap,tgap:this.constants.tgap}]});this.display=BI.createWidget({type:"bi.display_tree",cls:"bi-multi-tree-display",itemsCreator:function(a,c){a.type=BI.TreeView.REQ_TYPE_GET_SELECTED_DATA,b.itemsCreator(a,c)}}),this.display.on(BI.Events.AFTERINIT,function(){a.fireEvent(BI.Events.AFTERINIT)}),this.display.on(BI.TreeView.EVENT_INIT,function(){d.setVisible(!1)}),this.display.on(BI.TreeView.EVENT_AFTERINIT,function(){d.setVisible(!0)}),BI.createWidget({type:"bi.vtape",element:this,items:[{height:this.constants.height,el:d},{height:"fill",el:this.display}]})},empty:function(){this.display.empty()},populate:function(a){this.display.stroke(a)},setValue:function(a){a||(a={}),this.display.setSelectedValue(a.value)},getValue:function(){}}),BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK="EVENT_CONTINUE_CLICK",BI.shortcut("bi.multi_tree_check_pane",BI.MultiTreeCheckPane),BI.MultiTreeCombo=BI.inherit(BI.Single,{constants:{offset:{top:1,left:1,right:2,bottom:33}},_defaultConfig:function(){return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-multi-tree-combo",itemsCreator:BI.emptyFn,height:25})},_init:function(){function a(){h()?b.storeValue={value:b.trigger.getValue()}:i()&&(b.storeValue={value:b.combo.getValue()}),b.trigger.setValue(b.storeValue)}BI.MultiTreeCombo.superclass._init.apply(this,arguments);var b=this,c=this.options,d=!1,e=!1;this.trigger=BI.createWidget({type:"bi.multi_select_trigger",height:c.height,masker:{offset:this.constants.offset},searcher:{type:"bi.multi_tree_searcher",itemsCreator:c.itemsCreator},switcher:{el:{type:"bi.multi_tree_check_selected_button"},popup:{type:"bi.multi_tree_check_pane",itemsCreator:c.itemsCreator}}}),this.combo=BI.createWidget({type:"bi.combo",toggle:!1,el:this.trigger,adjustLength:1,popup:{type:"bi.multi_tree_popup_view",ref:function(){b.popup=this,b.trigger.setAdapter(this)},listeners:[{eventName:BI.MultiTreePopup.EVENT_AFTERINIT,action:function(){b.trigger.getCounter().adjustView(),d=!0,e===!0&&a()}},{eventName:BI.MultiTreePopup.EVENT_CHANGE,action:function(){f=!0;var a={type:BI.Selection.Multi,value:this.hasChecked()?{1:1}:{}};b.trigger.getSearcher().setState(a),b.trigger.getCounter().setButtonChecked(a)}},{eventName:BI.MultiTreePopup.EVENT_CLICK_CONFIRM,action:function(){b.combo.hideView()}},{eventName:BI.MultiTreePopup.EVENT_CLICK_CLEAR,action:function(){g=!0,b.setValue(),b._defaultState()}}],itemsCreator:c.itemsCreator,onLoaded:function(){BI.nextTick(function(){b.trigger.getCounter().adjustView(),b.trigger.getSearcher().adjustView()})}},hideChecker:function(a){return 0===j.element.find(a.target).length}}),this.storeValue={value:{}};var f=!1,g=!1,h=function(){return b.trigger.getSearcher().isSearching()},i=function(){return b.combo.isViewVisible()};this.trigger.on(BI.MultiSelectTrigger.EVENT_START,function(){b.storeValue={value:b.combo.getValue()},this.setValue(b.storeValue)}),this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP,function(){b.storeValue={value:this.getValue()},b.combo.setValue(b.storeValue),BI.nextTick(function(){i()&&b.combo.populate()})}),this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW,function(){e===!1&&(e=!0),d===!0&&(e=null,a())}),this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK,function(){b.combo.toggle()}),this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK,function(){b.combo.isViewVisible()||b.combo.showView()}),this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE,function(){var a={type:BI.Selection.Multi,value:this.getSearcher().hasChecked()?{1:1}:{}};this.getSearcher().setState(a),this.getCounter().setButtonChecked(a)}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){h()||(f===!0&&(b.storeValue={value:b.combo.getValue()},f=!1),b.combo.setValue(b.storeValue),b.populate())}),this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW,function(){h()?(b.trigger.stopEditing(),b.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM)):i()&&(b.trigger.stopEditing(),b.storeValue={value:b.combo.getValue()},g===!0&&(b.storeValue={value:{}}),b.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM)),g=!1,f=!1});var j=BI.createWidget({type:"bi.trigger_icon_button",width:c.height,height:c.height,cls:"multi-select-trigger-icon-button bi-border-left"});j.on(BI.TriggerIconButton.EVENT_CHANGE,function(){b.trigger.getCounter().hideView(),b.combo.isViewVisible()?b.combo.hideView():b.combo.showView()}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.combo,left:0,right:0,top:0,bottom:0},{el:j,right:0,top:0,bottom:0}]})},_defaultState:function(){this.trigger.stopEditing(),this.combo.hideView()},setValue:function(a){this.storeValue.value=a||{},this.combo.setValue({value:a||{}})},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),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 a=this,b=this.options;this.selectedValues={},this.tree=BI.createWidget({type:"bi.async_tree",height:400,cls:"popup-view-tree",itemsCreator:b.itemsCreator,onLoaded:b.onLoaded}),this.popupView=BI.createWidget({type:"bi.multi_popup_view",element:this,stopPropagation:!1,maxWidth:b.maxWidth,minWidth:b.minWidth,maxHeight:b.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(b){switch(b){case 0:a.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR);break;case 1:a.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM)}}),this.tree.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreePopup.EVENT_CHANGE)}),this.tree.on(BI.TreeView.EVENT_AFTERINIT,function(){a.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT)})},getValue:function(){return this.tree.getValue()},setValue:function(a){a||(a={}),this.tree.setSelectedValue(a.value)},populate:function(a){this.tree.stroke(a)},hasChecked:function(){return this.tree.hasChecked()},resetHeight:function(a){this.popupView.resetHeight(a)},resetWidth:function(a){this.popupView.resetWidth(a)}}),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),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 a=this,b=this.options;this.partTree=BI.createWidget({type:"bi.part_tree",element:this,tipText:BI.i18nText("BI-No_Select"),itemsCreator:function(a,c){a.keyword=b.keywordGetter(),b.itemsCreator(a,c)}}),this.partTree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.partTree.on(BI.TreeView.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE)})},hasChecked:function(){return this.partTree.hasChecked()},setValue:function(a){this.setSelectedValue(a.value)},setSelectedValue:function(a){a||(a={}),this.partTree.setSelectedValue(a)},getValue:function(){return this.partTree.getValue()},empty:function(){this.partTree.empty()},populate:function(a){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),BI.MultiTreeCheckSelectedButton=BI.inherit(BI.Single,{_const:{checkSelected:BI.i18nText("BI-Check_Selected")},_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 a=this;this.indicator=BI.createWidget({type:"bi.icon_button",cls:"check-font trigger-check-selected",width:15,height:15,stopPropagation:!0}),this.checkSelected=BI.createWidget({type:"bi.text_button",cls:"trigger-check-selected",invisible:!0,hgap:4,text:this._const.checkSelected,textAlign:"center",textHeight:15}),this.checkSelected.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.checkSelected.on(BI.TextButton.EVENT_CHANGE,function(){a.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE,arguments)}),BI.createWidget({type:"bi.horizontal",element:this,items:[this.indicator,this.checkSelected]}),this.element.hover(function(){a.indicator.setVisible(!1),a.checkSelected.setVisible(!0)},function(){a.indicator.setVisible(!0),a.checkSelected.setVisible(!1)}),this.setVisible(!1)},setValue:function(a){a||(a={}),this.setVisible(BI.size(a.value)>0)}}),BI.MultiTreeCheckSelectedButton.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.multi_tree_check_selected_button",BI.MultiTreeCheckSelectedButton),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,popup:{},adapter:null,masker:{}})},_init:function(){BI.MultiTreeSearcher.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.multi_select_editor",height:b.height,el:{type:"bi.simple_state_editor",height:b.height}}),this.searcher=BI.createWidget({type:"bi.searcher",element:this,isAutoSearch:!1,isAutoSync:!1,onSearch:function(b,c){c({keyword:a.editor.getValue()})},el:this.editor,popup:BI.extend({type:"bi.multi_tree_search_pane",keywordGetter:function(){return a.editor.getValue()},itemsCreator:function(c,d){c.keyword=a.editor.getValue(),b.itemsCreator(c,d)}},b.popup),adapter:b.adapter,masker:b.masker}),this.searcher.on(BI.Searcher.EVENT_START,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_START)}),this.searcher.on(BI.Searcher.EVENT_PAUSE,function(){this.hasMatched(),a.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE)}),this.searcher.on(BI.Searcher.EVENT_STOP,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_STOP)}),this.searcher.on(BI.Searcher.EVENT_CHANGE,function(){a.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE,arguments)})},adjustView:function(){this.searcher.adjustView()},setAdapter:function(a){this.searcher.setAdapter(a)},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(a){a||(a={}),a.value||(a.value=[]),a.type===BI.Selection.All?this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.All):this.editor.setState(BI.size(a.value)>0?BI.Selection.Multi:BI.Selection.None)},setValue:function(a){this.setState(a),this.searcher.setValue(a)},getKey:function(){return this.editor.getValue()},getValue:function(){return this.searcher.getValue()},populate:function(a){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),BI.NumberEditor=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-number-editor bi-border",validationChecker:function(){return!0},valueFormatter:function(a){return a},value:0,errorText:"",step:1})},_init:function(){BI.NumberEditor.superclass._init.apply(this,arguments);var a=this,b=this.options;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,value:b.valueFormatter(b.value),validationChecker:b.validationChecker,errorText:b.errorText}),this.editor.on(BI.TextEditor.EVENT_CHANGE,function(){b.value=this.getValue(),a.fireEvent(BI.NumberEditor.EVENT_CHANGE)}),this.editor.on(BI.TextEditor.EVENT_CONFIRM,function(){a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),this.topBtn=BI.createWidget({type:"bi.icon_button",trigger:"lclick,",cls:"column-pre-page-h-font top-button bi-border-left bi-border-bottom"}),this.topBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(b.step),a.fireEvent(BI.NumberEditor.EVENT_CHANGE),a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),this.bottomBtn=BI.createWidget({type:"bi.icon_button",trigger:"lclick,",cls:"column-next-page-h-font bottom-button bi-border-left bi-border-top"}),this.bottomBtn.on(BI.IconButton.EVENT_CHANGE,function(){a._finetuning(-b.step),a.fireEvent(BI.NumberEditor.EVENT_CHANGE),a.fireEvent(BI.NumberEditor.EVENT_CONFIRM)}),BI.createWidget({type:"bi.htape",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}]})},_finetuning:function(a){var b=BI.parseFloat(this.getValue());this.setValue(b.add(a))},setUpEnable:function(a){this.topBtn.setEnable(!!a)},setDownEnable:function(a){this.bottomBtn.setEnable(!!a)},getValue:function(){return this.options.value},setValue:function(a){var b=this.options;b.value=a,this.editor.setValue(b.valueFormatter(a))}}),BI.NumberEditor.EVENT_CONFIRM="EVENT_CONFIRM",BI.NumberEditor.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.number_editor",BI.NumberEditor),BI.NumberInterval=BI.inherit(BI.Single,{constants:{typeError:"typeBubble",numberError:"numberBubble",signalError:"signalBubble",editorWidth:114,columns:5,width:30,rows:1,numberErrorCls:"number-error",border:1,less:0,less_equal:1,numTip:""},_defaultConfig:function(){var a=BI.NumberInterval.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-number-interval",height:25,validation:"valid"})},_init:function(){var a=this,b=this.constants,c=this.options;BI.NumberInterval.superclass._init.apply(this,arguments),this.smallEditor=BI.createWidget({type:"bi.editor",height:c.height-2,watermark:BI.i18nText("BI-Basic_Unrestricted"),allowBlank:!0,value:c.min,level:"warning",tipType:"warning",quitChecker:function(){return!1},validationChecker:function(c){return!!BI.isNumeric(c)||(a.smallEditorBubbleType=b.typeError,!1)},cls:"number-interval-small-editor bi-border-top bi-border-bottom bi-border-left"}),this.smallTip=BI.createWidget({type:"bi.label",text:c.numTip,height:c.height-2,invisible:!0}),BI.createWidget({type:"bi.absolute",element:this.smallEditor.element,items:[{el:this.smallTip,top:0,right:5}]}),this.bigEditor=BI.createWidget({type:"bi.editor",height:c.height-2,watermark:BI.i18nText("BI-Basic_Unrestricted"),allowBlank:!0,value:c.max,level:"warning",tipType:"warning",quitChecker:function(){return!1},validationChecker:function(c){return!!BI.isNumeric(c)||(a.bigEditorBubbleType=b.typeError,!1)},cls:"number-interval-big-editor bi-border-top bi-border-bottom bi-border-right"}),this.bigTip=BI.createWidget({type:"bi.label",text:c.numTip,height:c.height-2,invisible:!0}),BI.createWidget({type:"bi.absolute",element:this.bigEditor.element,items:[{el:this.bigTip,top:0,right:5}]}),this.smallCombo=BI.createWidget({type:"bi.icon_combo",cls:"number-interval-small-combo bi-border",height:c.height-2,items:[{text:"("+BI.i18nText("BI-Less_Than")+")",iconClass:"less-font",value:0},{text:"("+BI.i18nText("BI-Less_And_Equal")+")",value:1,iconClass:"less-equal-font"}]}),c.closemin===!0?this.smallCombo.setValue(1):this.smallCombo.setValue(0),this.bigCombo=BI.createWidget({type:"bi.icon_combo",cls:"number-interval-big-combo bi-border",height:c.height-2,items:[{text:"("+BI.i18nText("BI-Less_Than")+")",iconClass:"less-font",value:0},{text:"("+BI.i18nText("BI-Less_And_Equal")+")",value:1,iconClass:"less-equal-font"}]}),c.closemax===!0?this.bigCombo.setValue(1):this.bigCombo.setValue(0),this.label=BI.createWidget({type:"bi.label",text:BI.i18nText("BI-Basic_Value"),textHeight:c.height-2*b.border,width:b.width-2*b.border,height:c.height-2*b.border,level:"warning",tipType:"warning"}),this.left=BI.createWidget({type:"bi.htape",items:[{el:a.smallEditor},{el:a.smallCombo,width:b.width-2*b.border}]}),this.right=BI.createWidget({type:"bi.htape",items:[{el:a.bigCombo,width:b.width-2*b.border},{el:a.bigEditor}]}),BI.createWidget({element:a,type:"bi.center",hgap:15,height:c.height,items:[{type:"bi.absolute",items:[{el:a.left,left:-15,right:0,top:0,bottom:0}]},{type:"bi.absolute",items:[{el:a.right,left:0,right:-15,top:0,bottom:0}]}]}),BI.createWidget({element:a,type:"bi.horizontal_auto",items:[a.label]}),a._setValidEvent(a.bigEditor,b.bigEditor),a._setValidEvent(a.smallEditor,b.smallEditor),a._setErrorEvent(a.bigEditor,b.bigEditor),a._setErrorEvent(a.smallEditor,b.smallEditor),a._setBlurEvent(a.bigEditor),a._setBlurEvent(a.smallEditor),a._setFocusEvent(a.bigEditor),a._setFocusEvent(a.smallEditor),a._setComboValueChangedEvent(a.bigCombo),a._setComboValueChangedEvent(a.smallCombo),a._setEditorValueChangedEvent(a.bigEditor),a._setEditorValueChangedEvent(a.smallEditor)},_checkValidation:function(){var a=this,b=this.constants,c=this.options;if(a._setTitle(""),BI.Bubbles.hide(b.typeError),BI.Bubbles.hide(b.numberError),BI.Bubbles.hide(b.signalError),a.smallEditor.isValid()&&a.bigEditor.isValid()){if(BI.isEmptyString(a.smallEditor.getValue())||BI.isEmptyString(a.bigEditor.getValue()))return a.element.removeClass("number-error"),c.validation="valid","";var d=parseFloat(a.smallEditor.getValue()),e=parseFloat(a.bigEditor.getValue()),f=a.bigCombo.getValue(),g=a.smallCombo.getValue();return f[0]===b.less_equal&&g[0]===b.less_equal?d>e?(a.element.addClass("number-error"),c.validation="invalid",b.numberError):(a.element.removeClass("number-error"),c.validation="valid",""):d>e?(a.element.addClass("number-error"),c.validation="invalid",b.numberError):d===e?(a.element.addClass("number-error"),c.validation="invalid",b.signalError):(a.element.removeClass("number-error"),c.validation="valid","")}return a.element.removeClass("number-error"),c.validation="invalid",b.typeError},_setTitle:function(a){var b=this;b.bigEditor.setTitle(a),b.smallEditor.setTitle(a),b.label.setTitle(a)},_setFocusEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_FOCUS,function(){switch(b._setTitle(""),b._checkValidation()){case c.typeError:BI.Bubbles.show(c.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),b,{offsetStyle:"center"});break;case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"});break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"});break;default:return}})},_setBlurEvent:function(a){var b=this.constants,c=this;a.on(BI.Editor.EVENT_BLUR,function(){switch(BI.Bubbles.hide(b.typeError),BI.Bubbles.hide(b.numberError),BI.Bubbles.hide(b.signalError),c._checkValidation()){case b.typeError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data"));break;case b.numberError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value"));break;case b.signalError:c._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value"));break;default:c._setTitle("")}})},_setErrorEvent:function(a){var b=this.constants,c=this;a.on(BI.Editor.EVENT_ERROR,function(){c._checkValidation(),BI.Bubbles.show(b.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),c,{offsetStyle:"center"}),c.fireEvent(BI.NumberInterval.EVENT_ERROR)})},_setValidEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_VALID,function(){switch(b._checkValidation()){case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"}),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"}),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;default:b.fireEvent(BI.NumberInterval.EVENT_VALID)}})},_setEditorValueChangedEvent:function(a){var b=this,c=this.constants;a.on(BI.Editor.EVENT_CHANGE,function(){switch(b._checkValidation()){case c.typeError:BI.Bubbles.show(c.typeError,BI.i18nText("BI-Numerical_Interval_Input_Data"),b,{offsetStyle:"center"});break;case c.numberError:BI.Bubbles.show(c.numberError,BI.i18nText("BI-Numerical_Interval_Number_Value"),b,{offsetStyle:"center"});break;case c.signalError:BI.Bubbles.show(c.signalError,BI.i18nText("BI-Numerical_Interval_Signal_Value"),b,{offsetStyle:"center"})}b.fireEvent(BI.NumberInterval.EVENT_CHANGE)})},_setComboValueChangedEvent:function(a){var b=this,c=this.constants;a.on(BI.IconCombo.EVENT_CHANGE,function(){switch(b._checkValidation()){case c.typeError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.numberError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;case c.signalError:b._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")),b.fireEvent(BI.NumberInterval.EVENT_ERROR);break;default:b.fireEvent(BI.NumberInterval.EVENT_CHANGE),b.fireEvent(BI.NumberInterval.EVENT_VALID)}})},isStateValid:function(){return"valid"===this.options.validation},setMinEnable:function(a){this.smallEditor.setEnable(a)},setCloseMinEnable:function(a){this.smallCombo.setEnable(a)},setMaxEnable:function(a){this.bigEditor.setEnable(a)},setCloseMaxEnable:function(a){this.bigCombo.setEnable(a)},showNumTip:function(){this.smallTip.setVisible(!0),this.bigTip.setVisible(!0)},hideNumTip:function(){this.smallTip.setVisible(!1),this.bigTip.setVisible(!1)},setNumTip:function(a){this.smallTip.setText(a),this.bigTip.setText(a)},getNumTip:function(){return this.smallTip.getText()},setValue:function(a){a=a||{};var b,c=this;(BI.isNumeric(a.min)||BI.isEmptyString(a.min))&&c.smallEditor.setValue(a.min),BI.isNotNull(a.min)||c.smallEditor.setValue(""),(BI.isNumeric(a.max)||BI.isEmptyString(a.max))&&c.bigEditor.setValue(a.max),BI.isNotNull(a.max)||c.bigEditor.setValue(""),BI.isNull(a.closemin)||(b=a.closemin===!0?1:0,c.smallCombo.setValue(b)),BI.isNull(a.closemax)||(b=a.closemax===!0?1:0,c.bigCombo.setValue(b))},getValue:function(){var a=this,b={},c=a.smallCombo.getValue(),d=a.bigCombo.getValue();return b.min=a.smallEditor.getValue(),b.max=a.bigEditor.getValue(),0===c[0]?b.closemin=!1:b.closemin=!0,0===d[0]?b.closemax=!1:b.closemax=!0,b}}),BI.NumberInterval.EVENT_CHANGE="EVENT_CHANGE",BI.NumberInterval.EVENT_VALID="EVENT_VALID",BI.NumberInterval.EVENT_ERROR="EVENT_ERROR",BI.shortcut("bi.number_interval",BI.NumberInterval),BI.PageTableCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-page-table-cell",text:"",title:""})},_init:function(){BI.PageTableCell.superclass._init.apply(this,arguments);BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"nowrap",height:this.options.height,text:this.options.text,title:this.options.title,value:this.options.value,lgap:5,rgap:5});BI.isNotNull(this.options.styles)&&BI.isObject(this.options.styles)&&this.element.css(this.options.styles)}}),BI.shortcut("bi.page_table_cell",BI.PageTableCell),BI.PageTable=BI.inherit(BI.Widget,{_const:{scrollWidth:18,minScrollWidth:100},_defaultConfig:function(){return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-page-table",el:{type:"bi.sequence_table"},pager:{horizontal:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn},vertical:{pages:!1,curr:1,hasPrev:BI.emptyFn,hasNext:BI.emptyFn,firstPage:1,lastPage:BI.emptyFn}},itemsCreator:BI.emptyFn,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.PageTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.hCurr=1,this.vCurr=1,this.table=BI.createWidget(b.el,{type:"bi.sequence_table",width:b.width,height:b.height&&b.height-30,isNeedResize:!0,isResizeAdapt:!1,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,minColumnSize:b.minColumnSize,maxColumnSize:b.maxColumnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)}),this.pager=BI.createWidget(b.pager,{type:"bi.direction_pager",height:30}),this.pager.on(BI.Pager.EVENT_CHANGE,function(){var c=this.getVPage&&this.getVPage();BI.isNull(c)&&(c=this.getCurrentPage());var d=this.getHPage&&this.getHPage();b.itemsCreator({vpage:c,hpage:d},function(b,e,f,g){a.table.setVPage?a.table.setVPage(c):a.table.setValue(c),a.table.setHPage&&a.table.setHPage(d),a.populate.apply(a,arguments)})}),BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.table,left:0,top:0},{el:this.pager,left:0,right:0,bottom:0}]})},setHPage:function(a){this.hCurr=a,this.pager.setHPage&&this.pager.setHPage(a),this.table.setHPage&&this.table.setHPage(a)},setVPage:function(a){this.vCurr=a,this.pager.setVPage&&this.pager.setVPage(a),this.table.setVPage&&this.table.setVPage(a)},getHPage:function(){var a=this.pager.getHPage&&this.pager.getHPage();return BI.isNotNull(a)?a:(a=this.pager.getCurrentPage&&this.pager.getCurrentPage(),BI.isNotNull(a)?a:this.hpage)},getVPage:function(){var a=this.pager.getVPage&&this.pager.getVPage();return BI.isNotNull(a)?a:(a=this.pager.getCurrentPage&&this.pager.getCurrentPage(),BI.isNotNull(a)?a:this.vpage)},setWidth:function(a){BI.PageTable.superclass.setWidth.apply(this,arguments),this.table.setWidth(a)},setHeight:function(a){BI.PageTable.superclass.setHeight.apply(this,arguments);var b=!1;this.pager.alwaysShowPager?b=!0:this.pager.hasHNext&&this.pager.hasHNext()?b=!0:this.pager.hasHPrev&&this.pager.hasHPrev()?b=!0:this.pager.hasVNext&&this.pager.hasVNext()?b=!0:this.pager.hasVPrev&&this.pager.hasVPrev()?b=!0:this.pager.hasNext&&this.pager.hasNext()?b=!0:this.pager.hasPrev&&this.pager.hasPrev()&&(b=!0),this.table.setHeight(a-(b?30:0))},setColumnSize:function(a){this.options.columnSize=a,this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.columnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getVerticalScroll:function(){return this.table.getVerticalScroll()},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},restore:function(){this.table.restore()},attr:function(){BI.PageTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments)},populate:function(){this.pager.populate(),this.table.populate.apply(this.table,arguments)},destroy:function(){this.table.destroy(),this.pager&&this.pager.destroy(),BI.PageTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.page_table",BI.PageTable),BI.PathChooser=BI.inherit(BI.Widget,{_const:{lineColor:"#d4dadd",selectLineColor:"#3f8ce8"},_defaultConfig:function(){return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-path-chooser",items:[]})},_init:function(){BI.PathChooser.superclass._init.apply(this,arguments),this.populate(this.options.items)},_createRegions:function(a){var b=this;this.regions=BI.createWidgets(BI.map(a,function(a,c){return{type:"bi.path_region",title:b.texts[c]||c}})),this.regionMap={},BI.each(a,function(a,c){b.regionMap[c]=a}),this.container=BI.createWidget({type:"bi.horizontal",verticalAlign:"top",scrollx:!1,scrolly:!1,hgap:10,items:this.regions}),BI.createWidget({type:"bi.vertical_adapt",element:this,scrollable:!0,hgap:10,items:[this.container]})},getRegionIndexById:function(a){var b=this.store[a],c=b.get("region");return this.regionMap[c]},_drawPath:function(a,b,c){var d=this,e=[];e=BI.contains(this.start,a)?this.start:[a], +BI.each(e,function(a,b){BI.each(d.radios[b],function(a,b){b.setSelected(!1)}),BI.each(d.lines[b],function(a,b){b.attr("stroke",d._const.lineColor)}),BI.each(d.regionIndexes[b],function(a,b){d.regions[b].reset()})}),BI.each(this.routes[a][c],function(a,e){var f=d.getRegionIndexById(e);d.regions[f].setSelect(b+c,e)});for(var f=BI.last(this.routes[a][c]);f&&this.routes[f]&&1===this.routes[f].length;)BI.each(this.routes[f][0],function(a,b){var c=d.getRegionIndexById(b);d.regions[c].setSelect(0,b)}),this.lines[f][0].attr("stroke",d._const.selectLineColor).toFront(),f=BI.last(this.routes[f][0]);this.lines[a][c].attr("stroke",d._const.selectLineColor).toFront(),this.radios[a]&&this.radios[a][c]&&this.radios[a][c].setSelected(!0)},_drawRadio:function(a,b,c,d,e){var f=this,g=BI.createWidget({type:"bi.radio",cls:"path-chooser-radio",selected:b+c===0,start:a,index:c});g.on(BI.Radio.EVENT_CHANGE,function(){f._drawPath(a,b,c),f.fireEvent(BI.PathChooser.EVENT_CHANGE,a,c)}),this.radios[a]||(this.radios[a]=[]),this.radios[a].push(g),BI.createWidget({type:"bi.absolute",element:this.container,items:[{el:g,left:d-6.5,top:e-6.5}]})},_drawLine:function(a,b){var c=this;this.lines[a]||(this.lines[a]=[]),this.pathes[a]||(this.pathes[a]=[]);var d=this.getRegionIndexById(a),e=this.regions[d].getIndexByValue(a);BI.each(b,function(f,g){c.pathes[a][f]=[];var h=f+e,i="",j=47.5+29*h,k=50+100*d,l=k,m=j,n=j,o=c.getRegionIndexById(BI.last(g)),p=c.regions[o].getIndexByValue(BI.last(g)),q=50+100*o;if(BI.contains(c.start,a)?(l=k-50,i+="M"+(k-50)+","+j,c.pathes[a][f].push({x:k-50,y:j})):0===h?(l=k+50,i+="M"+k+","+j,c.pathes[a][f].push({x:k,y:j})):(l=k+50,i+="M"+k+",47.5L"+(k+50)+",47.5L"+(k+50)+","+j,c.pathes[a][f].push({x:k,y:47.5}),c.pathes[a][f].push({x:k+50,y:47.5}),c.pathes[a][f].push({x:k+50,y:j})),h>0){var r=29*p+47.5;i+="L"+(q-50)+","+n+"L"+(q-50)+","+r+"L"+q+","+r,c.pathes[a][f].push({x:q-50,y:n}),c.pathes[a][f].push({x:q-50,y:r}),c.pathes[a][f].push({x:q,y:r})}else i+="L"+q+","+n,c.pathes[a][f].push({x:q,y:n});var s=c.svg.path(i).attr({stroke:0===h?c._const.selectLineColor:c._const.lineColor,"stroke-dasharray":"-"});c.lines[a].push(s),b.length>1&&c.lines[a][0].toFront(),BI.contains(c.start,a)&&c.lines[c.regions[0].getValueByIndex(0)][0].toFront(),(b.length>1||BI.contains(c.start,a))&&c._drawRadio(a,e,f,l,m)})},_drawLines:function(a){var b=this;this.lines={},this.pathes={},this.radios={},this.regionIndexes={},BI.each(a,function(a,c){b.regionIndexes[a]||(b.regionIndexes[a]=[]),BI.each(c,function(c,d){BI.each(d,function(c,d){var e=b.getRegionIndexById(d);BI.contains(b.regionIndexes[a],e)||b.regionIndexes[a].push(e)})})}),BI.each(a,function(a,c){b._drawLine(a,c)})},_pushNodes:function(a){for(var b=this,c=[],d=0;d0||BI.contains(b.start,e))&&g.addItem(e,b.texts[e])}for(var d=BI.first(c);d0&&(h=c[b-1]);var i=a.store[h.value||""],j=a.store[g.value]||new BI.Node(g.value);j.set(g),a.store[g.value]=j,a.texts[g.value]=g.text,a.texts[g.region]=g.regionText,i=BI.isNull(i)?d.getRoot():i,i.getChildIndex(g.value)===-1&&d.addNode(i,j)})}),d.traverse(function(a){BI.each(a.getChildren(),function(b,d){if(BI.contains(c,d.get("region"))){var e=BI.indexOf(c,a.get("region")),f=BI.indexOf(c,d.get("region"));if(e>f){for(var g=c[f],h=f;h0&&(e.push(c),d.push(e),e=[]),e.push(c)}),e.length>0&&d.push(e),BI.each(d,function(a,b){var d=b[0],e=BI.findIndex(c.routes[d],function(a,c){if(BI.isEqual(b,c))return!0});if(e>=0){var f=c.getRegionIndexById(d),g=c.regions[f].getIndexByValue(d);c._drawPath(d,g,e)}})},getValue:function(){var a=[];return BI.each(this.regions,function(b,c){var d=c.getValue();BI.isKey(d)&&a.push(d)}),a}}),BI.PathChooser.EVENT_CHANGE="PathChooser.EVENT_CHANGE",BI.shortcut("bi.path_chooser",BI.PathChooser),BI.PathRegion=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-path-region bi-background",width:80,title:""})},_init:function(){BI.PathRegion.superclass._init.apply(this,arguments);var a=this.options;this.zIndex=100;var b=BI.createWidget({type:"bi.label",text:a.title,title:a.title,height:30});b.element.css("zIndex",this.zIndex--),this.items=[],this.vertical=BI.createWidget({type:"bi.vertical",element:this,bgap:5,hgap:10,items:[b]})},hasItem:function(a){return BI.any(this.items,function(b,c){return a===c.getValue()})},addItem:function(a,b){if(BI.isKey(a))var c=BI.createWidget({type:"bi.label",cls:"path-region-label bi-card bi-border bi-list-item-select",text:b,value:a,title:b||a,height:24});else var c=BI.createWidget({type:"bi.layout",height:24});c.element.css("zIndex",this.zIndex--),this.items.push(c),this.vertical.addItem(c),1===this.items.length&&this.setSelect(0,a)},reset:function(){BI.each(this.items,function(a,b){b.element.removeClass("active")})},setSelect:function(a,b){if(this.reset(),!(this.items.length<=0))return 1===this.items.length?void this.items[0].element.addClass("active"):void(this.items[a].attr("value")===b&&this.items[a].element.addClass("active"))},setValue:function(a){this.setSelect(this.getIndexByValue(a),a)},getValueByIndex:function(a){return this.items[a].attr("value")},getIndexByValue:function(a){return BI.findIndex(this.items,function(b,c){return c.attr("value")===a})},getValue:function(){var a;return BI.any(this.items,function(b,c){if(c.element.hasClass("active"))return a=c.getValue(),!0}),a}}),BI.PathRegion.EVENT_CHANGE="PathRegion.EVENT_CHANGE",BI.shortcut("bi.path_region",BI.PathRegion),BI.PreviewTableCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table-cell",text:""})},_init:function(){BI.PreviewTableCell.superclass._init.apply(this,arguments);this.options;BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"normal",height:this.options.height,text:this.options.text,value:this.options.value})}}),BI.shortcut("bi.preview_table_cell",BI.PreviewTableCell),BI.PreviewTableHeaderCell=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table-header-cell",text:""})},_init:function(){BI.PreviewTableHeaderCell.superclass._init.apply(this,arguments);this.options;BI.createWidget({type:"bi.label",element:this,textAlign:"left",whiteSpace:"normal",height:this.options.height,text:this.options.text,value:this.options.value})}}),BI.shortcut("bi.preview_table_header_cell",BI.PreviewTableHeaderCell),BI.PreviewTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-preview-table",isNeedFreeze:!1,freezeCols:[],rowSize:null,columnSize:[],headerRowSize:30,header:[],items:[]})},_init:function(){BI.PreviewTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.table=BI.createWidget({type:"bi.table_view",element:this,isNeedResize:!1,isResizeAdapt:!1,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,rowSize:b.rowSize,columnSize:b.columnSize,headerRowSize:b.headerRowSize,header:BI.map(b.header,function(a,b){return BI.map(b,function(a,b){return BI.extend({type:"bi.preview_table_header_cell"},b)})}),items:BI.map(b.items,function(a,b){return BI.map(b,function(a,b){return BI.extend({type:"bi.preview_table_cell"},b)})})}),this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT,function(){a._adjustColumns(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT,arguments)}),this.table.on(BI.Table.EVENT_TABLE_RESIZE,function(){a._adjustColumns()})},_hasAdaptCol:function(a){return BI.any(a,function(a,b){return""===b})},_isPercentage:function(a){return a[0]<=1},_adjustColumns:function(){var a=this.options;if(a.isNeedFreeze===!0){if(this._isPercentage(a.columnSize)){if(this._hasAdaptCol(a.columnSize)){var b=[],c=0;BI.each(a.columnSize,function(a,d){""===d?b.push(a):c+=d}),c=1-c;var d=c/b.length;BI.each(b,function(b,c){a.columnSize[c]=d})}var e=0!==BI.first(a.freezeCols),f=[],g=[];BI.each(a.columnSize,function(b,c){a.freezeCols.contains(b)?f.push(c):g.push(c)});var h=BI.sum(f),i=BI.sum(g);BI.each(f,function(a,b){f[a]=b/h}),BI.each(g,function(a,b){g[a]=b/i}),this.table.setRegionColumnSize(e?["fill",h]:[h,"fill"]),this.table.setColumnSize(e?g.concat(f):f.concat(g))}}else(this._hasAdaptCol(a.columnSize)||this._isPercentage(a.columnSize))&&this.table.setRegionColumnSize(["100%"])},setColumnSize:function(a){return this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},getCalculateColumnSize:function(){return this.table.getCalculateColumnSize()},setHeaderColumnSize:function(a){return this.table.setHeaderColumnSize(a)},setRegionColumnSize:function(a){return this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getCalculateRegionColumnSize:function(){return this.table.getCalculateRegionColumnSize()},getCalculateRegionRowSize:function(){return this.table.getCalculateRegionRowSize()},getClientRegionColumnSize:function(){return this.table.getClientRegionColumnSize()},getScrollRegionColumnSize:function(){return this.table.getScrollRegionColumnSize()},getScrollRegionRowSize:function(){return this.table.getScrollRegionRowSize()},hasVerticalScroll:function(){return this.table.hasVerticalScroll()},setVerticalScroll:function(a){return this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){return this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){return this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},getColumns:function(){return this.table.getColumns()},populate:function(a,b){this.table.populate(a,b)}}),BI.PreviewTable.EVENT_CHANGE="PreviewTable.EVENT_CHANGE",BI.shortcut("bi.preview_table",BI.PreviewTable),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 a=this,b=this.options;this.storeValue="",this.trigger=BI.createWidget({type:"bi.quarter_trigger"}),this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.QuarterTrigger.EVENT_START,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.QuarterTrigger.EVENT_STOP,function(){a.combo.isViewVisible()||a.combo.showView()}),this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM,function(){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getKey()):this.getKey()||a.setValue(),a.fireEvent(BI.QuarterCombo.EVENT_CONFIRM))}),this.popup=BI.createWidget({type:"bi.quarter_popup",behaviors:b.behaviors}),this.popup.on(BI.QuarterPopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.QuarterCombo.EVENT_CONFIRM)}),this.combo=BI.createWidget({type:"bi.combo",element:this,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,el:this.popup}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){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),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 a=this,b=this.options,c=[{text:Date._QN[1],value:1},{text:Date._QN[2],value:2},{text:Date._QN[3],value:3},{text:Date._QN[4],value:4}];c=BI.map(c,function(a,b){return BI.extend(b,{type:"bi.text_item",cls:"bi-list-item-active",textAlign:"left",whiteSpace:"nowrap",once:!1,forceSelected:!0,height:25})}),this.quarter=BI.createWidget({type:"bi.button_group",element:this,behaviors:b.behaviors,items:BI.createItems(c,{}),layouts:[{type:"bi.vertical"}]}),this.quarter.on(BI.Controller.EVENT_CHANGE,function(b){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),b===BI.Events.CLICK&&a.fireEvent(BI.MonthPopup.EVENT_CHANGE)})},getValue:function(){return this.quarter.getValue()[0]},setValue:function(a){this.quarter.setValue([a])}}),BI.QuarterPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.quarter_popup",BI.QuarterPopup),BI.QuarterTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:30,textWidth:40,errorText:BI.i18nText("BI-Quarter_Trigger_Error_Text")},_defaultConfig:function(){return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-quarter-trigger bi-border",height:25})},_init:function(){BI.QuarterTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(a){return""===a||BI.isPositiveInteger(a)&&a>=1&&a<=4},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.QuarterTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_CHANGE,function(){a.fireEvent(BI.QuarterTrigger.EVENT_CHANGE)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.QuarterTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.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:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){a=a||"",this.editor.setState(a),this.editor.setValue(a),this.editor.setTitle(a)},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),BI.RelationViewItem=BI.inherit(BI.BasicButton,{_defaultConfig:function(){return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view-item bi-list-item-active",height:25,hoverIn:BI.emptyFn,hoverOut:BI.emptyFn})},_init:function(){BI.RelationViewItem.superclass._init.apply(this,arguments);var a=this.options;this.element.hover(a.hoverIn,a.hoverOut);var b=[];a.isPrimary&&b.push({type:"bi.icon",width:16,height:16,title:BI.i18nText("BI-Primary_Key")}),b.push({type:"bi.label",text:a.text,value:a.value,height:a.height,textAlign:"left",width:a.isPrimary?70:90,lgap:a.isPrimary?0:10}),BI.createWidget({type:"bi.vertical_adapt",element:this,items:b,cls:"primary-key-font",lgap:5})},enableHover:function(a){BI.RelationViewRegion.superclass.enableHover.apply(this,[{container:"body"}])},setSelected:function(a){this.element[a?"addClass":"removeClass"]("active")}}),BI.shortcut("bi.relation_view_item",BI.RelationViewItem),BI.RelationView=BI.inherit(BI.Widget,{_const:{lineColor:"#c4c6c6",selectLineColor:"#009de3"},_defaultConfig:function(){return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view",items:[]})},_init:function(){BI.RelationView.superclass._init.apply(this,arguments),this.populate(this.options.items)},_calculateWidths:function(){var a=[];return BI.each(this.views,function(b,c){BI.each(c,function(b,c){a[b]||(a[b]=BI.MIN),a[b]=Math.max(a[b],c.getWidth())})}),a},_calculateHeights:function(){var a=BI.makeArray(BI.size(this.views),BI.MIN);return BI.each(this.views,function(b,c){BI.each(c,function(c,d){a[b]=Math.max(a[b],d.getHeight())})}),a},_hoverIn:function(a){var b=this,c=this._const;BI.each(this.relations,function(d,e){BI.each(e,function(e,f){f[0].primary.value!==a&&f[0].foreign.value!==a||(b.lines[d][e].attr("stroke",c.selectLineColor).toFront(),b.storeViews[d].setValue(f[0].primary.value),b.storeViews[e].setValue(f[0].foreign.value))})})},_hoverOut:function(a){var b=this,c=this._const;BI.each(this.relations,function(d,e){BI.each(e,function(e,f){f[0].primary.value!==a&&f[0].foreign.value!==a||(b.lines[d][e].attr("stroke",c.lineColor),b.storeViews[d].setValue([]),b.storeViews[e].setValue([]))})})},previewRelationTables:function(a,b){return b?(BI.each(this.storeViews,function(b,c){a.contains(b)?c.setPreviewSelected(!0):c.toggleRegion(!1)}),void BI.each(this.lines,function(b,c){BI.each(c,function(c,d){a.contains(b)&&a.contains(c)||d.hide()})})):(BI.each(this.storeViews,function(a,b){b.toggleRegion(!0),b.setPreviewSelected(!1)}),void BI.each(this.lines,function(a,b){BI.each(b,function(a,b){b.show()})}))},populate:function(a){var b=this,c=this.options,d=this._const;c.items=a||[],this.empty(),this.svg=BI.createWidget({type:"bi.svg"});var e=this.regions={},f=this.relations={};BI.each(a,function(a,b){var c=b.primary.region,d=b.foreign&&b.foreign.region;c&&!f[c]&&(f[c]={}),c&&d&&!f[c][d]&&(f[c][d]=[]),c&&!e[c]&&(e[c]=[]),d&&!e[d]&&(e[d]=[]),c&&!BI.deepContains(e[c],b.primary)&&e[c].push(b.primary),d&&!BI.deepContains(e[d],b.foreign)&&e[d].push(b.foreign),c&&d&&f[c][d].push(b)});for(var g=[],h=BI.clone(e),i={};!BI.isEmpty(h);){var j=BI.clone(h);BI.each(c.items,function(a,b){i[b.primary.region]||delete j[b.foreign&&b.foreign.region]}),g.push(BI.keys(j)),BI.extend(i,j),BI.each(j,function(a,b){delete h[a]})}var k=this.views={},l=this.storeViews={},m=this.indexes={},n=[];BI.each(g,function(a,c){k[a]||(k[a]={});var d=[];BI.each(c,function(c,f){var g=e[f];k[a][c]=l[f]=BI.createWidget({type:"bi.relation_view_region_container",value:f,header:g[0].regionTitle,text:g.length>0?g[0].regionText:"",handler:g.length>0?g[0].regionHandler:BI.emptyFn,items:g,belongPackage:!(g.length>0)||g[0].belongPackage}),BI.isNotNull(g[0])&&BI.isNotNull(g[0].keyword)&&k[a][c].doRedMark(g[0].keyword),k[a][c].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN,function(a){b._hoverIn(a)}),k[a][c].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT,function(a){b._hoverOut(a)}),k[a][c].on(BI.RelationViewRegionContainer.EVENT_PREVIEW,function(a){b.fireEvent(BI.RelationView.EVENT_PREVIEW,f,a)}),m[f]={i:a,j:c},d.push(k[a][c])}),n.push({type:"bi.horizontal",items:d})});var o=this._calculateHeights(),p=this._calculateWidths(),q=[0],r=[0];BI.each(o,function(a,b){0!==a&&(r[a]=r[a-1]+o[a-1])}),BI.each(p,function(a,b){0!==a&&(q[a]=q[a-1]+p[a-1])});var s=this.lines={};BI.each(f,function(a,c){BI.each(c,function(c,e){var f=m[a],g=m[c],h=0,i=1,j=2,n=3,t=j,u=h,v=function(a,b,c,d){var e,f=q[b]+(p[b]-k[a][b].getWidth())/2,g=r[a]+(o[a]-k[a][b].getHeight())/2,l="";switch(c){case h:e=d?k[a][b].getTopRightPosition():k[a][b].getTopLeftPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+f+","+(g-10),g-=10;break;case i:e=k[a][b].getRightPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+(f+10)+","+g,f+=10;break;case j:e=k[a][b].getBottomPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+f+","+(g+10),g+=10;break;case n:e=k[a][b].getLeftPosition(),f+=e.x,g+=e.y,l="M"+f+","+g+"L"+(f-10)+","+g,f-=10}return{x:f,y:g,path:l}},w="",x=v(f.i,f.j,t),y=v(g.i,g.j,u,!0);w+=x.path+y.path,s[a]||(s[a]={}),w+="M"+x.x+","+x.y+"L"+y.x+","+y.y;var z=s[a][c]=b.svg.path(w).attr({stroke:d.lineColor,"stroke-width":"2"}).hover(function(){z.attr("stroke",d.selectLineColor).toFront(),l[a].setValue(e[0].primary.value),l[c].setValue(e[0].foreign.value)},function(){z.attr("stroke",d.lineColor),l[a].setValue([]),l[c].setValue([])})})});var t=BI.createWidget();BI.createWidget({type:"bi.vertical",element:t,items:n}),BI.createWidget({type:"bi.absolute",element:t,items:[{el:this.svg,left:0,right:0,top:0,bottom:0}]}),BI.createWidget({type:"bi.center_adapt",scrollable:!0,element:this,items:[t]})}}),BI.RelationView.EVENT_CHANGE="RelationView.EVENT_CHANGE",BI.RelationView.EVENT_PREVIEW="EVENT_PREVIEW",BI.shortcut("bi.relation_view",BI.RelationView),BI.RelationViewRegionContainer=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view-region-container",width:150})},_init:function(){BI.RelationViewRegionContainer.superclass._init.apply(this,arguments);var a=this,b=this.options;this.region=BI.createWidget({type:"bi.relation_view_region",value:b.value,header:b.header,text:b.text,handler:b.handler,items:b.items,belongPackage:b.belongPackage}),this.region.on(BI.RelationViewRegion.EVENT_PREVIEW,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW,b)}),this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN,b)}),this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT,function(b){a.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT,b)}),BI.createWidget({type:"bi.vertical",element:this,items:[this.region],width:this.region.getWidth(),height:this.region.getHeight()})},doRedMark:function(){this.region.doRedMark.apply(this.region,arguments)},unRedMark:function(){this.region.unRedMark.apply(this.region,arguments)},getWidth:function(){return this.region.getWidth()},getHeight:function(){return this.region.getHeight()},getTopLeftPosition:function(){return this.region.getTopLeftPosition()},getTopRightPosition:function(){return this.region.getTopRightPosition()},getBottomPosition:function(){return this.region.getBottomPosition()},getLeftPosition:function(){return this.region.getLeftPosition()},getRightPosition:function(){return this.region.getRightPosition()},setValue:function(a){this.region.setValue(a)},toggleRegion:function(a){a===!0?this.region.element.fadeIn():this.region.element.fadeOut()},setPreviewSelected:function(a){this.region.setPreviewSelected(a)}}),BI.RelationViewRegionContainer.EVENT_HOVER_IN="RelationViewRegion.EVENT_HOVER_IN",BI.RelationViewRegionContainer.EVENT_HOVER_OUT="RelationViewRegion.EVENT_HOVER_OUT",BI.RelationViewRegionContainer.EVENT_PREVIEW="RelationViewRegion.EVENT_PREVIEW",BI.shortcut("bi.relation_view_region_container",BI.RelationViewRegionContainer),BI.RelationViewRegion=BI.inherit(BI.BasicButton,{_defaultConfig:function(){return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-relation-view-region cursor-pointer",width:150,text:"",value:"",header:"",items:[],belongPackage:!0})},_init:function(){BI.RelationViewRegion.superclass._init.apply(this,arguments);var a=this,b=this.options;this.preview=BI.createWidget({type:"bi.icon_button",cls:"relation-table-preview-font",width:25,height:25,stopPropagation:!0}),this.preview.on(BI.IconButton.EVENT_CHANGE,function(){a.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW,this.isSelected())}),this.title=BI.createWidget({type:"bi.label",height:25,width:70,text:b.text,value:b.value,textAlign:"left"}),BI.isKey(b.header)&&this.title.setTitle(b.header,{container:"body"}),this.button_group=BI.createWidget({type:"bi.button_group",items:this._createItems(b.items),layouts:[{type:"bi.vertical"}]}),BI.createWidget({type:"bi.vertical",element:this,items:[{type:"bi.vertical",cls:"relation-view-region-container bi-card bi-border "+(b.belongPackage?"":"other-package"),items:[{type:"bi.vertical_adapt",cls:"relation-view-region-title bi-border-bottom",items:[this.preview,this.title]},this.button_group]}],hgap:25,vgap:20})},_createItems:function(a){var b=this;return BI.map(a,function(a,c){return BI.extend(c,{type:"bi.relation_view_item",hoverIn:function(){b.setValue(c.value),b.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN,c.value)},hoverOut:function(){b.setValue([]),b.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT,c.value)}})})},doRedMark:function(){this.title.doRedMark.apply(this.title,arguments)},unRedMark:function(){this.title.unRedMark.apply(this.title,arguments)},getWidth:function(){return this.options.width},getHeight:function(){return 25*this.button_group.getAllButtons().length+25+40+3},getTopLeftPosition:function(){return{x:35,y:20}},getTopRightPosition:function(){return{x:this.getWidth()-25-10,y:20}},getBottomPosition:function(){return{x:35,y:this.getHeight()-20}},getLeftPosition:function(){return{x:25,y:30}},getRightPosition:function(){return{x:this.getWidth()-25,y:30}},setValue:function(a){this.button_group.setValue(a)},setPreviewSelected:function(a){this.preview.setSelected(a)}}),BI.RelationViewRegion.EVENT_HOVER_IN="RelationViewRegion.EVENT_HOVER_IN",BI.RelationViewRegion.EVENT_HOVER_OUT="RelationViewRegion.EVENT_HOVER_OUT",BI.RelationViewRegion.EVENT_PREVIEW="RelationViewRegion.EVENT_PREVIEW",BI.shortcut("bi.relation_view_region",BI.RelationViewRegion),BI.ResponisveTable=BI.inherit(BI.Widget,{_const:{perColumnSize:100},_defaultConfig:function(){return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-responsive-table",isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:function(a,b){return BI.isEqual(a,b)},columnSize:[],headerRowSize:25,footerRowSize:25,rowSize:25,regionColumnSize:!1,header:[],footer:!1,items:[],crossHeader:[],crossItems:[]})},_init:function(){BI.ResponisveTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.table=BI.createWidget({type:"bi.table_view",element:this,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,headerRowSize:b.headerRowSize,footerRowSize:b.footerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,header:b.header,footer:b.footer,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT,function(){a._initRegionSize(),a.table.resize(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT,arguments)}),this.table.on(BI.Table.EVENT_TABLE_RESIZE,function(){a._resizeRegion(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(){a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE,function(){a.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE,function(){b.isNeedResize===!0&&a._isAdaptiveColumn()&&a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE,function(){a._resizeBody(),a.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE,function(){a.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){a._resizeRegion(),a._resizeHeader(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)})},_initRegionSize:function(){var a=this.options;if(a.isNeedFreeze===!0){var b=this.table.getRegionColumnSize(),c=this.table.element.width();if(!b[0]||"fill"===b[0]||b[0]>c||b[1]>c){var d=a.freezeCols;if(0===d.length)this.table.setRegionColumnSize([0,"fill"]);else if(d.length>0&&d.lengtha.columnSize.length/2&&(e=2*c/3),this.table.setRegionColumnSize([e,"fill"])}else this.table.setRegionColumnSize(["fill",0])}}},_getBlockSize:function(){var a=this.options,b=this.table.getCalculateColumnSize();if(a.isNeedFreeze===!0){var c=[],d=[];BI.each(b,function(b,e){a.freezeCols.contains(b)?c.push(e):d.push(e)});var e=BI.sum(c)+c.length,f=BI.sum(d)+d.length;return{sumLeft:e,sumRight:f,left:c,right:d}}return{size:b,sum:BI.sum(b)+b.length}},_isAdaptiveColumn:function(a){return!(BI.last(a||this.table.getColumnSize())>1.05)},_resizeHeader:function(){var a=this,b=this.options;if(b.isNeedFreeze===!0)if(this._isAdaptiveColumn()){var c=this.table.getCalculateColumnSize();this.table.setHeaderColumnSize(c)}else{var d=this.table.getClientRegionColumnSize(),e=this._getBlockSize(),f=e.sumLeft,g=e.sumRight,h=e.left,i=e.right;h[h.length-1]+=d[0]-f,i[i.length-1]+=d[1]-g;var j=BI.clone(h),k=BI.clone(i);j[j.length-1]="",k[k.length-1]="",this.table.setColumnSize(j.concat(k)),e=a._getBlockSize(),h[h.length-1]0&&a.freezeCols.length=d+e)&&this.table.setRegionColumnSize([d,"fill"]),this._resizeRegion()}},_resizeRegion:function(){var a=this.options,b=this.table.getCalculateRegionColumnSize();if(a.isNeedFreeze===!0&&a.freezeCols.length>0&&a.freezeCols.lengtha.columnSize.length/2&&(e=2*c/3),this.table.setRegionColumnSize([e,"fill"])}}},resize:function(){this.table.resize(),this._resizeRegion(),this._resizeHeader()},setColumnSize:function(a){this.table.setColumnSize(a),this._adjustRegion(),this._resizeHeader()},getColumnSize:function(){return this.table.getColumnSize()},getCalculateColumnSize:function(){return this.table.getCalculateColumnSize()},setHeaderColumnSize:function(a){this.table.setHeaderColumnSize(a),this._adjustRegion(),this._resizeHeader()},setRegionColumnSize:function(a){this.table.setRegionColumnSize(a),this._resizeHeader()},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},getCalculateRegionColumnSize:function(){return this.table.getCalculateRegionColumnSize()},getCalculateRegionRowSize:function(){return this.table.getCalculateRegionRowSize()},getClientRegionColumnSize:function(){return this.table.getClientRegionColumnSize()},getScrollRegionColumnSize:function(){return this.table.getScrollRegionColumnSize()},getScrollRegionRowSize:function(){return this.table.getScrollRegionRowSize()},hasVerticalScroll:function(){return this.table.hasVerticalScroll()},setVerticalScroll:function(a){this.table.setVerticalScroll(a)},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},getLeftHorizontalScroll:function(){return this.table.getLeftHorizontalScroll()},getRightHorizontalScroll:function(){return this.table.getRightHorizontalScroll()},getColumns:function(){return this.table.getColumns()},attr:function(){BI.ResponisveTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments)},populate:function(a){var b=this,c=this.options;this.table.populate.apply(this.table,arguments),c.isNeedFreeze===!0&&BI.nextTick(function(){b._initRegionSize(),b.table.resize(),b._resizeHeader()})}}),BI.shortcut("bi.responsive_table",BI.ResponisveTable),BI.SelectTreeFirstPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-first-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.first_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_first_plus_group_node",BI.SelectTreeFirstPlusGroupNode),BI.SelectTreeLastPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-last-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.last_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_last_plus_group_node",BI.SelectTreeLastPlusGroupNode),BI.SelectTreeMidPlusGroupNode=BI.inherit(BI.NodeButton,{_defaultConfig:function(){var a=BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{baseCls:(a.baseCls||"")+" bi-select-tree-mid-plus-group-node bi-list-item-active",logic:{dynamic:!1},id:"",pId:"",readonly:!0,open:!1,height:25})},_init:function(){BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this,arguments);var a=this,b=this.options;this.checkbox=BI.createWidget({type:"bi.mid_tree_node_checkbox",stopPropagation:!0}),this.text=BI.createWidget({type:"bi.label",textAlign:"left",whiteSpace:"nowrap",textHeight:b.height,height:b.height,hgap:b.hgap,text:b.text,value:b.value,py:b.py}),this.checkbox.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&(this.isSelected()?a.triggerExpand():a.triggerCollapse())});var c=BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left),d=BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left,{width:25,el:this.checkbox},this.text);BI.createWidget(BI.extend({element:this},BI.LogicFactory.createLogic(c,BI.extend(b.logic,{items:d}))))},isOnce:function(){return!0},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(a){BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this,arguments),BI.isNotNull(this.checkbox)&&this.checkbox.setSelected(a)}}),BI.shortcut("bi.select_tree_mid_plus_group_node",BI.SelectTreeMidPlusGroupNode),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:[]})},_init:function(){BI.SelectTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items}),this.popup=BI.createWidget({type:"bi.select_level_tree",items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.popup.on(BI.SingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView()})},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},getValue:function(){return this.popup.getValue()},populate:function(a){this.combo.populate(a)}}),BI.shortcut("bi.select_tree_combo",BI.SelectTreeCombo),BI.SelectTreeExpander=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-select-tree-expander",trigger:"click",toggle:!0,direction:"bottom",isDefaultInit:!0,el:{},popup:{}})},_init:function(){BI.SelectTreeExpander.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget(BI.extend({stopPropagation:!0},b.el)),this.trigger.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&this.isSelected()&&a.expander.setValue([]),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.expander=BI.createWidget({type:"bi.expander",element:this,trigger:b.trigger,toggle:b.toggle,direction:b.direction,isDefaultInit:b.isDefaultInit,el:this.trigger,popup:b.popup}),this.expander.on(BI.Controller.EVENT_CHANGE,function(b){b===BI.Events.CLICK&&a.trigger.setSelected(!1),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)})},setValue:function(a){BI.contains(a,this.trigger.getValue())?(this.trigger.setSelected(!0),this.expander.setValue([])):(this.trigger.setSelected(!1),this.expander.setValue(a))},getValue:function(){return this.trigger.isSelected()?[this.trigger.getValue()]:this.expander.getValue()},populate:function(a){this.expander.populate(a)}}),BI.shortcut("bi.select_tree_expander",BI.SelectTreeExpander),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:[]})},_formatItems:function(a,b){var c=this;return BI.each(a,function(d,e){var f={layer:b};if(e.id=e.id||BI.UUID(),e.isParent===!0||BI.isNotEmptyArray(e.children)){switch(d){case 0:f.type="bi.select_tree_first_plus_group_node";break;case a.length-1:f.type="bi.select_tree_last_plus_group_node";break;default:f.type="bi.select_tree_mid_plus_group_node"}BI.defaults(e,f),c._formatItems(e.children)}else{switch(d){case a.length-1:f.type="bi.last_tree_leaf_item";break;default:f.type="bi.mid_tree_leaf_item"}BI.defaults(e,f)}}),a},_init:function(){BI.SelectTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.level_tree",expander:{type:"bi.select_tree_expander",isDefaultInit:!0},items:this._formatItems(BI.Tree.transformToTreeFormat(b.items)),chooseType:BI.Selection.Single}),BI.createWidget({type:"bi.vertical",element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.LevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.SelectTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.SelectTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.SelectTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.select_level_tree",BI.SelectTreePopup),BI.SequenceTableDynamicNumber=BI.inherit(BI.SequenceTableTreeNumber,{_defaultConfig:function(){return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-sequence-table-dynamic-number"})},_init:function(){BI.SequenceTableDynamicNumber.superclass._init.apply(this,arguments)},_formatNumber:function(a){function b(a){var c=0;return BI.isNotEmptyArray(a.children)?(BI.each(a.children,function(a,d){c+=b(d)}),a.children.length>1&&BI.isNotEmptyArray(a.values)&&c++):c++,c}var c=this.options,d=[],e=this._getStart(a),f=0,g=0;return BI.each(a,function(a,h){BI.isArray(h.children)&&(BI.each(h.children,function(a,h){var i=b(h);d.push({text:e++,start:f,top:g,cnt:i,index:a,height:i*c.rowSize}),f+=i,g+=i*c.rowSize}),BI.isNotEmptyArray(h.values)&&(d.push({text:BI.i18nText("BI-Summary_Values"),start:f++,top:g,cnt:1,isSummary:!0,height:c.rowSize}),g+=c.rowSize))}),d}}),BI.shortcut("bi.sequence_table_dynamic_number",BI.SequenceTableDynamicNumber),BI.SequenceTableListNumber=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-sequence-table-list-number",isNeedFreeze:!1,scrollTop:0,startSequence:1,headerRowSize:25,rowSize:25,sequenceHeaderCreator:null,header:[],items:[],crossHeader:[],crossItems:[],pageSize:20})},_init:function(){BI.SequenceTableListNumber.superclass._init.apply(this,arguments);var a=this.options;this.start=a.startSequence,this.renderedCells=[],this.renderedKeys=[],this.container=BI.createWidget({type:"bi.absolute",width:60,scrollable:!1}),this.scrollContainer=BI.createWidget({type:"bi.vertical",scrollable:!1,scrolly:!1,items:[this.container]}),this.headerContainer=BI.createWidget({type:"bi.absolute",cls:"bi-border",width:58,scrollable:!1}),this.layout=BI.createWidget({type:"bi.vtape",element:this,items:[{el:this.headerContainer,height:a.headerRowSize*a.header.length-2},{el:{type:"bi.layout"},height:2},{el:this.scrollContainer}]}),this._populate()},_layout:function(){var a=this.options,b=a.headerRowSize*a.header.length-2,c=this.layout.attr("items");a.isNeedFreeze===!1?(c[0].height=0,c[1].height=0):a.isNeedFreeze===!0&&(c[0].height=b,c[1].height=2),this.layout.attr("items",c),this.layout.resize(),this.container.setHeight(a.items.length*a.rowSize);try{this.scrollContainer.element.scrollTop(a.scrollTop)}catch(d){}},_createHeader:function(){var a=this.options;BI.createWidget({type:"bi.absolute",element:this.headerContainer,items:[{el:a.sequenceHeaderCreator||{type:"bi.table_style_cell",cls:"sequence-table-title-cell",styleGetter:a.headerCellStyleGetter,text:BI.i18nText("BI-Number_Index")},left:0,top:0,right:0,bottom:0}]})},_calculateChildrenToRender:function(){for(var a=this,b=this.options,c=BI.clamp(b.scrollTop,0,b.rowSize*b.items.length-(b.height-b.header.length*b.headerRowSize)+BI.DOM.getScrollWidth()),d=Math.floor(c/b.rowSize),e=d+Math.floor((b.height-b.header.length*b.headerRowSize)/b.rowSize),f=[],g=[],h=d,i=0;h<=e&&h-1)b.rowSize!==this.renderedCells[j]._height&&(this.renderedCells[j]._height=b.rowSize,this.renderedCells[j].el.setHeight(b.rowSize)),this.renderedCells[j].top!==k&&(this.renderedCells[j].top=k,this.renderedCells[j].el.element.css("top",k+"px")),f.push(this.renderedCells[j]);else{var l=BI.createWidget(BI.extend({type:"bi.table_style_cell",cls:"sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom",width:60,height:b.rowSize,text:this.start+h,styleGetter:function(c){return function(){return b.sequenceCellStyleGetter(a.start+h-1)}}(i)}));f.push({el:l,left:0,top:k,_height:b.rowSize})}g.push(this.start+h)}var m={},n={},o=[];BI.each(g,function(b,c){BI.deepContains(a.renderedKeys,c)?m[b]=c:n[b]=c}),BI.each(this.renderedKeys,function(a,b){BI.deepContains(m,b)||BI.deepContains(n,b)||o.push(a)}),BI.each(o,function(b,c){a.renderedCells[c].el.destroy()});var p=[];BI.each(n,function(a){p.push(f[a])}),BI.createWidget({type:"bi.absolute",element:this.container,items:p}),this.renderedCells=f,this.renderedKeys=g},_populate:function(){this.headerContainer.empty(),this._createHeader(),this._layout(),this._calculateChildrenToRender()},setVerticalScroll:function(a){if(this.options.scrollTop!==a){this.options.scrollTop=a;try{this.scrollContainer.element.scrollTop(a)}catch(b){}}},getVerticalScroll:function(){return this.options.scrollTop},setVPage:function(a){a=a<1?1:a;var b=this.options;this.start=(a-1)*b.pageSize+1},_restore:function(){this.options;BI.each(this.renderedCells,function(a,b){b.el.destroy()}),this.renderedCells=[],this.renderedKeys=[]},restore:function(){this._restore()},populate:function(a,b){var c=this.options;a&&a!==this.options.items&&(c.items=a,this._restore()),b&&b!==this.options.header&&(c.header=b),this._populate()}}),BI.shortcut("bi.sequence_table_list_number",BI.SequenceTableListNumber),BI.SequenceTable=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-sequence-table",el:{type:"bi.adaptive_table"},sequence:{},isNeedResize:!0,isResizeAdapt:!1,isNeedFreeze:!1,freezeCols:[],isNeedMerge:!1,mergeCols:[],mergeRule:BI.emptyFn,columnSize:[],minColumnSize:[],maxColumnSize:[],headerRowSize:25,rowSize:25,regionColumnSize:[],headerCellStyleGetter:BI.emptyFn,summaryCellStyleGetter:BI.emptyFn,sequenceCellStyleGetter:BI.emptyFn,header:[],items:[],crossHeader:[],crossItems:[],showSequence:!1,startSequence:1})},_init:function(){BI.SequenceTable.superclass._init.apply(this,arguments);var a=this,b=this.options;this.sequence=BI.createWidget(b.sequence,{type:"bi.sequence_table_list_number",invisible:b.showSequence===!1,startSequence:b.startSequence,isNeedFreeze:b.isNeedFreeze,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems,headerRowSize:b.headerRowSize,rowSize:b.rowSize,width:60,height:b.height&&b.height-BI.GridTableScrollbar.SIZE,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter}),this.table=BI.createWidget(b.el,{type:"bi.adaptive_table",width:b.showSequence===!0?b.width-60:b.width,height:b.height,isNeedResize:b.isNeedResize,isResizeAdapt:b.isResizeAdapt,isNeedFreeze:b.isNeedFreeze,freezeCols:b.freezeCols,isNeedMerge:b.isNeedMerge,mergeCols:b.mergeCols,mergeRule:b.mergeRule,columnSize:b.columnSize,minColumnSize:b.minColumnSize,maxColumnSize:b.maxColumnSize,headerRowSize:b.headerRowSize,rowSize:b.rowSize,regionColumnSize:b.regionColumnSize,headerCellStyleGetter:b.headerCellStyleGetter,summaryCellStyleGetter:b.summaryCellStyleGetter,sequenceCellStyleGetter:b.sequenceCellStyleGetter,header:b.header,items:b.items,crossHeader:b.crossHeader,crossItems:b.crossItems}),this.table.on(BI.Table.EVENT_TABLE_SCROLL,function(b){a.sequence.getVerticalScroll()!==this.getVerticalScroll()&&(a.sequence.setVerticalScroll(this.getVerticalScroll()),a.sequence.populate()),a.fireEvent(BI.Table.EVENT_TABLE_SCROLL,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE,arguments)}),this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,function(){b.regionColumnSize=this.getRegionColumnSize(),b.columnSize=this.getColumnSize(),a.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE,arguments)}),this.htape=BI.createWidget({type:"bi.absolute",element:this,items:[{el:this.sequence,left:0,top:0},{el:this.table,top:0,left:b.showSequence===!0?60:0}]}),this._populate()},_populate:function(){var a=this.options;a.showSequence===!0?(this.sequence.setVisible(!0),this.table.element.css("left","60px"),this.table.setWidth(a.width-60)):(this.sequence.setVisible(!1),this.table.element.css("left","0px"),this.table.setWidth(a.width))},setWidth:function(a){BI.PageTable.superclass.setWidth.apply(this,arguments),this.table.setWidth(this.options.showSequence?a-60:a)},setHeight:function(a){BI.PageTable.superclass.setHeight.apply(this,arguments),this.table.setHeight(a),this.sequence.setHeight(a-BI.GridTableScrollbar.SIZE)},setColumnSize:function(a){this.options.columnSize=a,this.table.setColumnSize(a)},getColumnSize:function(){return this.table.getColumnSize()},setRegionColumnSize:function(a){this.options.columnSize=a,this.table.setRegionColumnSize(a)},getRegionColumnSize:function(){return this.table.getRegionColumnSize()},hasLeftHorizontalScroll:function(){return this.table.hasLeftHorizontalScroll()},hasRightHorizontalScroll:function(){return this.table.hasRightHorizontalScroll()},setLeftHorizontalScroll:function(a){this.table.setLeftHorizontalScroll(a)},setRightHorizontalScroll:function(a){this.table.setRightHorizontalScroll(a)},setVerticalScroll:function(a){this.table.setVerticalScroll(a),this.sequence.setVerticalScroll(a)},getVerticalScroll:function(){return this.table.getVerticalScroll()},setVPage:function(a){this.sequence.setVPage&&this.sequence.setVPage(a)},setHPage:function(a){this.sequence.setHPage&&this.sequence.setHPage(a)},attr:function(){BI.SequenceTable.superclass.attr.apply(this,arguments),this.table.attr.apply(this.table,arguments),this.sequence.attr.apply(this.sequence,arguments)},restore:function(){this.table.restore(),this.sequence.restore()},populate:function(a,b,c,d){var e=this.options;a&&(e.items=a),b&&(e.header=b),c&&(e.crossItems=c),d&&(e.crossHeader=d),this._populate(),this.table.populate.apply(this.table,arguments),this.sequence.populate.apply(this.sequence,arguments),this.sequence.setVerticalScroll(this.table.getVerticalScroll())},destroy:function(){this.table.destroy(),BI.SequenceTable.superclass.destroy.apply(this,arguments)}}),BI.shortcut("bi.sequence_table",BI.SequenceTable),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:30,text:"",items:[]})},_init:function(){BI.SingleTreeCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.trigger=BI.createWidget(BI.extend({type:"bi.single_tree_trigger",text:b.text,height:b.height,items:b.items},b.trigger)),this.popup=BI.createWidget({type:"bi.single_level_tree",items:b.items}),this.combo=BI.createWidget({type:"bi.combo",element:this,adjustLength:2,el:this.trigger,popup:{el:this.popup}}),this.combo.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW,arguments)}),this.popup.on(BI.SingleTreePopup.EVENT_CHANGE,function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE)})},populate:function(a){this.combo.populate(a)},setValue:function(a){a=BI.isArray(a)?a:[a],this.trigger.setValue(a),this.popup.setValue(a)},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),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:[]})},_init:function(){BI.SingleTreePopup.superclass._init.apply(this,arguments);var a=this,b=this.options;this.tree=BI.createWidget({type:"bi.level_tree",expander:{isDefaultInit:!0},items:b.items,chooseType:BI.Selection.Single}),BI.createWidget({type:"bi.vertical",element:this,items:[this.tree]}),this.tree.on(BI.Controller.EVENT_CHANGE,function(){a.fireEvent(BI.Controller.EVENT_CHANGE,arguments)}),this.tree.on(BI.LevelTree.EVENT_CHANGE,function(){a.fireEvent(BI.SingleTreePopup.EVENT_CHANGE)}),this.check()},getValue:function(){return this.tree.getValue()},setValue:function(a){a=BI.isArray(a)?a:[a],this.tree.setValue(a)},populate:function(a){BI.SingleTreePopup.superclass.populate.apply(this,arguments),this.tree.populate(a)}}),BI.SingleTreePopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.single_level_tree",BI.SingleTreePopup),BI.SingleTreeTrigger=BI.inherit(BI.Trigger,{_defaultConfig:function(){return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-single-tree-trigger",height:30,text:"",items:[]})},_init:function(){BI.SingleTreeTrigger.superclass._init.apply(this,arguments);var a=this.options;this.trigger=BI.createWidget({type:"bi.select_text_trigger",element:this,text:a.text,items:a.items,height:a.height})},_checkTitle:function(){var a=this,b=this.getValue();BI.any(this.options.items,function(c,d){if(b.contains(d.value))return a.trigger.setTitle(d.text||d.value),!0})},setValue:function(a){a=BI.isArray(a)?a:[a],this.options.value=a,this.trigger.setValue(a),this._checkTitle()},getValue:function(){return this.options.value||[]},populate:function(a){BI.SingleTreeTrigger.superclass.populate.apply(this,arguments),this.trigger.populate(a)}}),BI.shortcut("bi.single_tree_trigger",BI.SingleTreeTrigger),BI.SwitchTree=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-switch-tree",items:[]})},_init:function(){BI.SwitchTree.superclass._init.apply(this,arguments);this.options;this.tab=BI.createWidget({type:"bi.tab",element:this,tab:null,defaultShowIndex:BI.SwitchTree.SelectType.SingleSelect,cardCreator:BI.bind(this._createTree,this)})},_createTree:function(a){var b=this,c=this.options;switch(a){case BI.SwitchTree.SelectType.SingleSelect:return this.levelTree=BI.createWidget({type:"bi.multilayer_single_level_tree",isDefaultInit:!0,items:BI.deepClone(c.items)}),this.levelTree.on(BI.LevelTree.EVENT_CHANGE,function(){b.fireEvent(BI.SwitchTree.EVENT_CHANGE,arguments)}),this.levelTree;case BI.SwitchTree.SelectType.MultiSelect:return this.tree=BI.createWidget({type:"bi.simple_tree",items:this._removeIsParent(BI.deepClone(c.items))}),this.tree.on(BI.SimpleTreeView.EVENT_CHANGE,function(){b.fireEvent(BI.SwitchTree.EVENT_CHANGE,arguments)}),this.tree}},_removeIsParent:function(a){return BI.each(a,function(a,b){BI.isNotNull(b.isParent)&&delete b.isParent}),a},switchSelect:function(){switch(this.getSelect()){case BI.SwitchTree.SelectType.SingleSelect:this.setSelect(BI.SwitchTree.SelectType.MultiSelect);break;case BI.SwitchTree.SelectType.MultiSelect:this.setSelect(BI.SwitchTree.SelectType.SingleSelect)}},setSelect:function(a){this.tab.setSelect(a)},getSelect:function(){return this.tab.getSelect()},setValue:function(a){switch(this.storeValue=a,this.getSelect()){case BI.SwitchTree.SelectType.SingleSelect:this.levelTree.setValue(a);break;case BI.SwitchTree.SelectType.MultiSelect:this.tree.setValue(a)}},getValue:function(){return this.tab.getValue()},populate:function(a){this.options.items=a,BI.isNotNull(this.levelTree)&&this.levelTree.populate(BI.deepClone(a)),BI.isNotNull(this.tree)&&this.tree.populate(this._removeIsParent(BI.deepClone(a)))}}),BI.SwitchTree.EVENT_CHANGE="SwitchTree.EVENT_CHANGE",BI.SwitchTree.SelectType={SingleSelect:BI.Selection.Single,MultiSelect:BI.Selection.Multi},BI.shortcut("bi.switch_tree",BI.SwitchTree),BI.TimeInterval=BI.inherit(BI.Single,{constants:{height:25,width:25,lgap:15,offset:-15,timeErrorCls:"time-error",DATE_MIN_VALUE:"1900-01-01",DATE_MAX_VALUE:"2099-12-31"},_defaultConfig:function(){var a=BI.TimeInterval.superclass._defaultConfig.apply(this,arguments);return BI.extend(a,{extraCls:"bi-time-interval"})},_init:function(){var a=this;BI.TimeInterval.superclass._init.apply(this,arguments),this.left=this._createCombo(),this.right=this._createCombo(),this.label=BI.createWidget({type:"bi.label",height:this.constants.height,width:this.constants.width,text:"-"}),BI.createWidget({element:a,type:"bi.center",hgap:15,height:this.constants.height,items:[{type:"bi.absolute",items:[{el:a.left,left:this.constants.offset,right:0,top:0,bottom:0}]},{type:"bi.absolute",items:[{el:a.right,left:0,right:this.constants.offset,top:0,bottom:0}]}]}),BI.createWidget({type:"bi.horizontal_auto",element:this,items:[a.label]})},_createCombo:function(){var a=this,b=BI.createWidget({type:"bi.multidate_combo"});return b.on(BI.MultiDateCombo.EVENT_ERROR,function(){a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_ERROR)}),b.on(BI.MultiDateCombo.EVENT_VALID,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),BI.Bubbles.show("error",BI.i18nText("BI-Time_Interval_Error_Text"),a,{offsetStyle:"center"}),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls))}),b.on(BI.MultiDateCombo.EVENT_FOCUS,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),BI.Bubbles.show("error",BI.i18nText("BI-Time_Interval_Error_Text"),a,{offsetStyle:"center"}),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls))}),b.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW,function(){a.left.hidePopupView(),a.right.hidePopupView()}),b.on(BI.MultiDateCombo.EVENT_CONFIRM,function(){BI.Bubbles.hide("error");var b=a.left.getKey(),c=a.right.getKey();a._check(b,c)&&a._compare(b,c)?(a._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")),a.element.addClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_ERROR)):(a._clearTitle(),a.element.removeClass(a.constants.timeErrorCls),a.fireEvent(BI.TimeInterval.EVENT_CHANGE))}),b},_dateCheck:function(a){return Date.parseDateTime(a,"%Y-%x-%d").print("%Y-%x-%d")==a||Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d")==a||Date.parseDateTime(a,"%Y-%x-%e").print("%Y-%x-%e")==a||Date.parseDateTime(a,"%Y-%X-%e").print("%Y-%X-%e")==a},_checkVoid:function(a){return!Date.checkVoid(a.year,a.month,a.day,this.constants.DATE_MIN_VALUE,this.constants.DATE_MAX_VALUE)[0]},_check:function(a,b){var c=a.match(/\d+/g),d=b.match(/\d+/g);return this._dateCheck(a)&&Date.checkLegal(a)&&this._checkVoid({year:c[0],month:c[1],day:c[2]})&&this._dateCheck(b)&&Date.checkLegal(b)&&this._checkVoid({year:d[0],month:d[1],day:d[2]})},_compare:function(a,b){return a=Date.parseDateTime(a,"%Y-%X-%d").print("%Y-%X-%d"),b=Date.parseDateTime(b,"%Y-%X-%d").print("%Y-%X-%d"),BI.isNotNull(a)&&BI.isNotNull(b)&&a>b},_setTitle:function(a){this.left.setTitle(a),this.right.setTitle(a),this.label.setTitle(a)},_clearTitle:function(){this.left.setTitle(""),this.right.setTitle(""),this.label.setTitle("")},setValue:function(a){a=a||{},this.left.setValue(a.start),this.right.setValue(a.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),BI.YearCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-combo",behaviors:{},min:"1900-01-01",max:"2099-12-31",height:25})},_init:function(){BI.YearCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.storeValue="",this.trigger=BI.createWidget({type:"bi.year_trigger",min:b.min,max:b.max}),this.trigger.on(BI.YearTrigger.EVENT_FOCUS,function(){a.storeValue=this.getKey()}),this.trigger.on(BI.YearTrigger.EVENT_START,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.YearTrigger.EVENT_STOP,function(){a.combo.showView()}),this.trigger.on(BI.YearTrigger.EVENT_ERROR,function(){a.combo.isViewVisible()&&a.combo.hideView()}),this.trigger.on(BI.YearTrigger.EVENT_CONFIRM,function(){a.combo.isViewVisible()||(this.getKey()&&this.getKey()!==a.storeValue?a.setValue(this.getKey()):this.getKey()||a.setValue(),a.fireEvent(BI.YearCombo.EVENT_CONFIRM))}),this.combo=BI.createWidget({type:"bi.combo",element:this,destroyWhenHide:!0,isNeedAdjustHeight:!1,isNeedAdjustWidth:!1,el:this.trigger,popup:{minWidth:85,stopPropagation:!1,el:{type:"bi.year_popup",ref:function(){a.popup=this},listeners:[{eventName:BI.YearPopup.EVENT_CHANGE,action:function(){a.setValue(a.popup.getValue()),a.combo.hideView(),a.fireEvent(BI.YearCombo.EVENT_CONFIRM)}}],behaviors:b.behaviors,min:b.min,max:b.max}}}),this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW,function(){var b=a.trigger.getKey(); +BI.isNotNull(b)?a.popup.setValue(b):b||b===a.storeValue?a.setValue():a.popup.setValue(a.storeValue),a.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW)})},setValue:function(a){this.combo.setValue(a||"")},getValue:function(){return this.popup.getValue()}}),BI.YearCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_combo",BI.YearCombo),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(a){var b=this.options,c=this._year,d=BI.createWidget({type:"bi.year_calendar",behaviors:b.behaviors,min:b.min,max:b.max,logic:{dynamic:!0},year:c+12*a});return d.setValue(this._year),d},_init:function(){BI.YearPopup.superclass._init.apply(this,arguments);var a=this;this.selectedYear=this._year=(new Date).getFullYear();var b=BI.createWidget({type:"bi.icon_button",cls:"pre-page-h-font",width:25,height:25,value:-1}),c=BI.createWidget({type:"bi.icon_button",cls:"next-page-h-font",width:25,height:25,value:1});this.navigation=BI.createWidget({type:"bi.navigation",element:this,single:!0,logic:{dynamic:!0},tab:{cls:"year-popup-navigation bi-high-light bi-border-top",height:25,items:[b,c]},cardCreator:BI.bind(this._createYearCalendar,this),afterCardShow:function(){this.setValue(a.selectedYear);var d=this.getSelectedCard();b.setEnable(!d.isFrontYear()),c.setEnable(!d.isFinalYear())}}),this.navigation.on(BI.Navigation.EVENT_CHANGE,function(){a.selectedYear=this.getValue(),a.fireEvent(BI.Controller.EVENT_CHANGE,arguments),a.fireEvent(BI.YearPopup.EVENT_CHANGE,a.selectedYear)})},getValue:function(){return this.selectedYear},setValue:function(a){var b=this.options;Date.checkVoid(a,1,1,b.min,b.max)[0]?(a=(new Date).getFullYear(),this.selectedYear="",this.navigation.setSelect(BI.YearCalendar.getPageByYear(a)),this.navigation.setValue("")):(this.selectedYear=a,this.navigation.setSelect(BI.YearCalendar.getPageByYear(a)),this.navigation.setValue(a))}}),BI.YearPopup.EVENT_CHANGE="EVENT_CHANGE",BI.shortcut("bi.year_popup",BI.YearPopup),BI.YearTrigger=BI.inherit(BI.Trigger,{_const:{hgap:4,vgap:2,triggerWidth:25,errorText:BI.i18nText("BI-Please_Input_Positive_Integer"),errorTextInvalid:BI.i18nText("BI-Year_Trigger_Invalid_Text")},_defaultConfig:function(){return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this,arguments),{extraCls:"bi-year-trigger bi-border",min:"1900-01-01",max:"2099-12-31",height:25})},_init:function(){BI.YearTrigger.superclass._init.apply(this,arguments);var a=this,b=this.options,c=this._const;this.editor=BI.createWidget({type:"bi.sign_editor",height:b.height,validationChecker:function(d){return a.editor.setErrorText(BI.isPositiveInteger(d)?c.errorTextInvalid:c.errorText),""===d||BI.isPositiveInteger(d)&&!Date.checkVoid(d,1,1,b.min,b.max)[0]},quitChecker:function(a){return!1},hgap:c.hgap,vgap:c.vgap,allowBlank:!0,errorText:c.errorText}),this.editor.on(BI.SignEditor.EVENT_FOCUS,function(){a.fireEvent(BI.YearTrigger.EVENT_FOCUS)}),this.editor.on(BI.SignEditor.EVENT_STOP,function(){a.fireEvent(BI.YearTrigger.EVENT_STOP)}),this.editor.on(BI.SignEditor.EVENT_CONFIRM,function(){var b=a.editor.getValue();BI.isNotNull(b)&&(a.editor.setValue(b),a.editor.setTitle(b)),a.fireEvent(BI.YearTrigger.EVENT_CONFIRM)}),this.editor.on(BI.SignEditor.EVENT_SPACE,function(){a.editor.isValid()&&a.editor.blur()}),this.editor.on(BI.SignEditor.EVENT_START,function(){a.fireEvent(BI.YearTrigger.EVENT_START)}),this.editor.on(BI.SignEditor.EVENT_ERROR,function(){a.fireEvent(BI.YearTrigger.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:c.triggerWidth},width:c.triggerWidth},{el:{type:"bi.trigger_icon_button",width:c.triggerWidth},width:c.triggerWidth}]})},setValue:function(a){this.editor.setState(a),this.editor.setValue(a),this.editor.setTitle(a)},getKey:function(){return 0|this.editor.getValue()}}),BI.YearTrigger.EVENT_FOCUS="EVENT_FOCUS",BI.YearTrigger.EVENT_ERROR="EVENT_ERROR",BI.YearTrigger.EVENT_START="EVENT_START",BI.YearTrigger.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearTrigger.EVENT_STOP="EVENT_STOP",BI.shortcut("bi.year_trigger",BI.YearTrigger),BI.YearMonthCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-month-combo",yearBehaviors:{},monthBehaviors:{},height:25})},_init:function(){BI.YearMonthCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.year=BI.createWidget({type:"bi.year_combo",behaviors:b.yearBehaviors}),this.month=BI.createWidget({type:"bi.month_combo",behaviors:b.monthBehaviors}),this.year.on(BI.YearCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM)}),this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW)}),this.month.on(BI.MonthCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM)}),this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW)}),BI.createWidget({type:"bi.center",element:this,hgap:5,items:[this.year,this.month]})},setValue:function(a){a=a||{},this.month.setValue(a.month),this.year.setValue(a.year)},getValue:function(){return{year:this.year.getValue(),month:this.month.getValue()}}}),BI.YearMonthCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_month_combo",BI.YearMonthCombo),BI.YearQuarterCombo=BI.inherit(BI.Widget,{_defaultConfig:function(){return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this,arguments),{baseCls:"bi-year-quarter-combo",yearBehaviors:{},quarterBehaviors:{},height:25})},_init:function(){BI.YearQuarterCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;this.year=BI.createWidget({type:"bi.year_combo",behaviors:b.yearBehaviors}),this.quarter=BI.createWidget({type:"bi.quarter_combo",behaviors:b.quarterBehaviors}),this.year.on(BI.YearCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM)}),this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW)}),this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM)}),this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW,function(){a.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW)}),BI.createWidget({type:"bi.center",element:this,hgap:5,items:[this.year,this.quarter]})},setValue:function(a){a=a||{},this.quarter.setValue(a.quarter),this.year.setValue(a.year)},getValue:function(){return{year:this.year.getValue(),quarter:this.quarter.getValue()}}}),BI.YearQuarterCombo.EVENT_CONFIRM="EVENT_CONFIRM",BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW="EVENT_BEFORE_POPUPVIEW",BI.shortcut("bi.year_quarter_combo",BI.YearQuarterCombo),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:!0})},_valueFormatter:function(a){var b=a;return BI.isNotNull(this.items)&&BI.some(this.items,function(c,d){if(d.value===a)return b=d.text,!0}),b},_itemsCreator:function(a,b){function c(c){var d=(a.keywords||[]).slice();if(a.keyword&&d.push(a.keyword),BI.each(d,function(a,b){var d=BI.Func.getSearchResult(c,b);c=d.matched.concat(d.finded)}),a.selectedValues){var e=BI.makeObject(a.selectedValues,!0);c=BI.filter(c,function(a,b){return!e[b.value]})}return a.type===BI.MultiSelectCombo.REQ_GET_ALL_DATA?void b({items:c}):a.type===BI.MultiSelectCombo.REQ_GET_DATA_LENGTH?void b({count:c.length}):void b({items:c,hasNext:!1})}var d=this,e=this.options;e.cache&&this.items?c(this.items):e.itemsCreator({},function(a){d.items=a,c(a)})}}),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:!0})},_init:function(){BI.AllValueChooserCombo.superclass._init.apply(this,arguments);var a=this,b=this.options;BI.isNotNull(b.items)&&(this.items=b.items),this.combo=BI.createWidget({type:"bi.multi_select_combo",element:this,itemsCreator:BI.bind(this._itemsCreator,this),valueFormatter:BI.bind(this._valueFormatter,this),width:b.width,height:b.height}),this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM)})},setValue:function(a){this.combo.setValue({type:BI.Selection.Multi,value:a||[]})},getValue:function(){var a=this.combo.getValue()||{};return a.type===BI.Selection.All?a.assist:a.value||[]},populate:function(){this.combo.populate.apply(this,arguments)}}),BI.AllValueChooserCombo.EVENT_CONFIRM="AllValueChooserCombo.EVENT_CONFIRM",BI.shortcut("bi.all_value_chooser_combo",BI.AllValueChooserCombo),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:!0})},_init:function(){BI.AllValueChooserPane.superclass._init.apply(this,arguments);var a=this,b=this.options;BI.isNotNull(b.items)&&(this.items=b.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:b.width,height:b.height}),this.list.on(BI.MultiSelectList.EVENT_CHANGE,function(){a.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE)})},setValue:function(a){this.list.setValue({type:BI.Selection.Multi,value:a||[]})},getValue:function(){var a=this.list.getValue()||{};return a.type===BI.Selection.All?a.assist:a.value||[]},populate:function(){this.list.populate.apply(this.list,arguments)}}),BI.AllValueChooserPane.EVENT_CHANGE="AllValueChooserPane.EVENT_CHANGE",BI.shortcut("bi.all_value_chooser_pane",BI.AllValueChooserPane),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})},_initData:function(a){this.items=a;var b=BI.Tree.treeFormat(a);this.tree=new BI.Tree,this.tree.initTree(b)},_itemsCreator:function(a,b){function c(){switch(a.type){case BI.TreeView.REQ_TYPE_INIT_DATA:d._reqInitTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_ADJUST_DATA:d._reqAdjustTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_SELECT_DATA:d._reqSelectedTreeNode(a,b);break;case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:d._reqDisplayTreeNode(a,b);break;default:d._reqTreeNode(a,b)}}var d=this,e=this.options;this.items?c():e.itemsCreator({},function(a){d._initData(a),c()})},_reqDisplayTreeNode:function(a,b){function c(a,b,g){return null==g||BI.isEmpty(g)?void BI.each(b.getChildren(),function(d,g){var h=BI.clone(a);h.push(g.value);var i=f._getChildCount(h);e(g,b.id,i),c(h,g,{})}):void BI.each(g,function(b){var h=f._getTreeNode(a,b),i=BI.clone(a);i.push(h.value),e(h,h.parent&&h.parent.id,d(g[b],i)),c(i,h,g[b])})}function d(a,b){return null==a?0:BI.isEmpty(a)?f._getChildCount(b):BI.size(a)}function e(a,b,c){g.push({id:a.id,pId:b,text:a.text+(c>0?"("+BI.i18nText("BI-Basic_Altogether")+c+BI.i18nText("BI-Basic_Count")+")":""),value:a.value,open:!0})}var f=this,g=[],h=a.selectedValues;return null==h||BI.isEmpty(h)?void b({}):(c([],this.tree.getRoot(),h),void b({items:g}))},_reqSelectedTreeNode:function(a,b){function c(a){var b=m.concat(k);if(g(a,b))if(f(b))i._deleteNode(a,b);else{var c=[],j=e(m,k,[],c);j&&BI.isNotEmptyArray(c)&&BI.each(c,function(b,c){var e=i._getNode(a,c);e?i._deleteNode(a,c):d(a,c,BI.last(c))})}if(h(a,b)){var l=[],j=!1;f(b)?j=!0:(j=e(m,k,l),b=m),j===!0&&(d(a,b,k),l.length>0&&BI.each(l,function(b,c){i._buildTree(a,c)}))}}function d(a,b,c){var d=a,e=[],f=[];BI.some(b,function(g,h){var j=d[h];if(null==j){if(0===g)return!0;if(!BI.isEmpty(d))return!0;var k=b.slice(0,g),l=i._getChildren(k);if(f.push(k),e.push(l.length),g===b.length-1&&1===l.length&&l[0]===c)for(var m=e.length-1;m>=0&&1===e[m];m--)i._deleteNode(a,f[m]);else BI.each(l,function(a,e){return g===b.length-1&&e.value===c||void(d[e.value]={})});d=d[h]}else d=j})}function e(a,b,c,d){var f=BI.clone(a);if(f.push(b),i._isMatch(a,b,l))return d&&d.push(f),!0;var g=i._getChildren(f),h=[],j=!1;return BI.each(g,function(a,b){e(f,b.value,c,d)?j=!0:h.push(b.value)}),j===!0&&BI.each(h,function(a,b){var d=BI.clone(f);d.push(b),c.push(d)}),j}function f(a){for(var b=0,c=a.length;bj._const.perPage)break}return f}function d(a,b,c,i,k){if(j._isMatch(b,c,l)){var m=i||h(b,c);return e(b,c,!1,m,!i&&f(b,c),!0,k),[!0,m]}var n=BI.clone(b);n.push(c);var o=j._getChildren(n),p=!1,m=!1,q=i||g(b,c);return BI.each(o,function(b,c){var e=d(a+1,n,c.value,q,k);e[1]===!0&&(m=!0),e[0]===!0&&(p=!0)}),p===!0&&(m=q||h(b,c)&&m,e(b,c,!0,m,!1,!1,k)),[p,m]}function e(a,b,c,d,e,f,g){var h=j._getTreeNode(a,b);g.push({id:h.id,pId:h.pId,text:h.text,value:h.value,title:h.title,isParent:h.getChildrenLength()>0,open:c,checked:d,halfCheck:e,flag:f})}function f(a,b){var c=i(a);return null==c?null:BI.any(c,function(a,c){if(a===b&&null!=c&&!BI.isEmpty(c))return!0})}function g(a,b){var c=i(a);return null==c?null:BI.any(c,function(a,c){if(a===b&&null!=c&&BI.isEmpty(c))return!0})}function h(a,b){var c=i(a);return null!=c&&BI.any(c,function(a){if(a===b)return!0})}function i(a){var b=m;return null==b?null:(BI.every(a,function(a,c){return b=b[c],null!=b}),b)}var j=this,k=[],l=a.keyword||"",m=a.selectedValues,n=a.lastSearchValue||"",o=c();BI.nextTick(function(){b({hasNext:o.length>j._const.perPage,items:k,lastSearchValue:BI.last(o)})})},_reqTreeNode:function(a,b){function c(a,b){var c={};return BI.each(a,function(a,c){b=b[c]||{}}),BI.each(b,function(a,b){if(BI.isNull(b))return void(c[a]=[0,0]);if(BI.isEmpty(b))return void(c[a]=[2,0]);var d={};BI.each(b,function(a,b){(BI.isNull(b)||BI.isEmpty(b))&&(d[a]=!0)}),c[a]=[1,BI.size(d)]}),c}function d(a,b,c,d){var f=d.checked,g=d.half,h=!1,i=!1;if(BI.has(c,a))if(1===c[a][0]){var j=BI.clone(b);j.push(a);var k=e._getChildCount(j);k>0&&k!==c[a][1]&&(i=!0)}else 2===c[a][0]&&(h=!0);var l;return l=f||i||h?(h||f)&&!g||BI.has(c,a):BI.has(c,a),[l,i]}var e=this,f=[],g=a.times,h=a.checkState||{},i=a.parentValues||[],j=a.selectedValues||{},k={};k=c(i,j);for(var l=this._getChildren(i),m=(g-1)*this._const.perPage;l[m]&&m0,checked:n[0],halfCheck:n[1]})}BI.nextTick(function(){b({items:f,hasNext:l.length>g*e._const.perPage})})},_getNode:function(a,b){for(var c=a,d=0,e=b.length;d0&&BI.isEmpty(e);)c=d[d.length-1],d=d.slice(0,d.length-1),e=this._getNode(a,d),null!=e&&delete e[c]},_buildTree:function(a,b){var c=a;BI.each(b,function(a,b){BI.has(c,b)||(c[b]={}),c=c[b]})},_isMatch:function(a,b,c){var d=this._getTreeNode(a,b),e=BI.Func.getSearchResult([d.text||d.value],c);return e.finded.length>0||e.matched.length>0},_getTreeNode:function(a,b){var c,d=this,e=0;return this.tree.traverse(function(f){if(!d.tree.isRoot(f))return!(e>a.length)&&(e===a.length&&f.value===b?(c=f,!1):f.value!==a[e]||void e++)}),c},_getChildren:function(a){if(a.length>0)var b=BI.last(a),c=this._getTreeNode(a.slice(0,a.length-1),b);else var c=this.tree.getRoot();return c.getChildren()},_getChildCount:function(a){return this._getChildren(a).length}}),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 a=this,b=this.options;BI.isNotNull(b.items)&&this._initData(b.items),this.combo=BI.createWidget({type:"bi.multi_tree_combo",element:this,itemsCreator:BI.bind(this._itemsCreator,this),width:b.width,height:b.height}),this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM,function(){a.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM)})},setValue:function(a){this.combo.setValue(a)},getValue:function(){return this.combo.getValue()},populate:function(){this.combo.populate.apply(this.combo,arguments)}}),BI.TreeValueChooserCombo.EVENT_CONFIRM="TreeValueChooserCombo.EVENT_CONFIRM",BI.shortcut("bi.tree_value_chooser_combo",BI.TreeValueChooserCombo),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 a=this,b=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(){a.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE)}),BI.isNotNull(b.items)&&(this._initData(b.items),this.populate())},setSelectedValue:function(a){this.pane.setSelectedValue(a)},setValue:function(a){this.pane.setValue(a)},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),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:!0})},_valueFormatter:function(a){var b=a;return BI.isNotNull(this.items)&&BI.some(this.items,function(c,d){if(d.value===a)return b=d.text,!0}),b},_getItemsByTimes:function(a,b){for(var c=[],d=(b-1)*this._const.perPage;a[d]&&d 11){ - y++; - m -= 12; - } - var calendar = BI.createWidget({ - type: "bi.calendar", - logic: { - dynamic: false - }, - year: y, - month: m, - day: this.DAY - }) - calendar.setValue(this.selectedTime); - return calendar; - }, - - _stringfyTimeObject: function(timeOb){ - return timeOb.year + "-" + (timeOb.month + 1) + "-" + timeOb.day; - }, render: function () { var self = this; var combo1 = BI.createWidget({ type: "bi.bubble_combo", + trigger: "click,hover", el: { type: "bi.button", text: "测试", @@ -3955,7 +3929,364 @@ BI.shortcut("demo.select_text_trigger", Demo.Func);Demo.Func = BI.inherit(BI.Wid }) } }); -BI.shortcut("demo.text_trigger", Demo.Func);/** +BI.shortcut("demo.text_trigger", Demo.Func);Demo.CanvasTable = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-face" + }, + + render: function () { + var self = this; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.sequence_table", + ref: function () { + self.table = this; + }, + isNeedFreeze: null, + isNeedMerge: false, + summaryCellStyleGetter: function (isLast) { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + sequenceCellStyleGetter: function (index) { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + headerCellStyleGetter: function () { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + }, + el: { + type: "bi.adaptive_table", + el: { + type: "bi.resizable_table", + el: { + type: "bi.canvas_table" + } + } + }, + sequence: { + type: "bi.sequence_table_list_number", + pageSize: 100, + sequenceHeaderCreator: { + type: "bi.normal_sequence_header_cell", + styleGetter: function () { + return { + background: "rgb(4, 177, 194)", + color: "#ffffff", + fontWeight: "bold" + }; + } + } + }, + itemsCreator: function (op, populate) { + } + }, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }; + }, + + mounted: function () { + var self = this; + var tableItems = this._expandData(TABLE_ITEMS, 3), + headItems = this._expandHeadData(TABLE_HEADER, 3); + this._resizeHandler = BI.debounce(function () { + var width = self.element.width(), height = self.element.height(); + if (self.table.getWidth() !== width || self.table.getHeight() !== height) { + self.table.setWidth(width); + self.table.setHeight(height); + self.table.populate(); + } + }, 0); + BI.ResizeDetector.addResizeListener(this, function () { + self._resizeHandler(); + }); + this.table.setWidth(this.element.width()); + this.table.setHeight(this.element.height()); + this.table.attr("columnSize", BI.makeArray(headItems[0].length, "")); + this.table.attr("minColumnSize", BI.makeArray(headItems[0].length, 60)); + this.table.attr("isNeedFreeze", true); + this.table.attr("freezeCols", []); + this.table.attr("showSequence", true); + this.table.attr("headerRowSize", 15); + this.table.attr("rowSize", 15); + this.table.populate(tableItems, headItems); + }, + + _expandData: function (items, times) { + var copy = BI.deepClone(items); + for (var m = 0; m < times - 1; m++) { + BI.each(items, function (i, row) { + copy.push(row); + }); + } + + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n % 100], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + }, + + _expandHeadData: function (items, times) { + var copy = BI.deepClone(items); + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + } +}); + +BI.shortcut("demo.canvas_table", Demo.CanvasTable);/** + * canvas绘图 + * + * Created by Shichao on 2017/09/29. + * @class BI.CanvasNew + * @extends BI.Widget + */ +BI.CanvasNew = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.CanvasNew.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-new" + }) + }, + + _init: function () { + BI.CanvasNew.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var canvas = this._createHiDPICanvas(o.width, o.height); + this.element.append(canvas); + this.canvas = canvas; + this._queue = []; + }, + + _getContext: function () { + if (!this.ctx) { + this.ctx = this.canvas.getContext('2d'); + } + return this.ctx; + }, + + getContext: function () { + return this._getContext(); + }, + + _getPixelRatio: function () { + var ctx = document.createElement("canvas").getContext("2d"), + dpr = window.devicePixelRatio || 1, + bsr = ctx.webkitBackingStorePixelRatio || + ctx.mozBackingStorePixelRatio || + ctx.msBackingStorePixelRatio || + ctx.oBackingStorePixelRatio || + ctx.backingStorePixelRatio || 1; + return dpr / bsr; + }, + + getPixelRatio: function () { + return this._getPixelRatio(); + }, + + _createHiDPICanvas: function (w, h, ratio) { + if (!ratio) { + ratio = this._getPixelRatio(); + } + this.ratio = ratio; + var canvas = document.createElement("canvas"); + if (!document.createElement('canvas').getContext) { + canvas = window.G_vmlCanvasManager.initElement(canvas); + } + canvas.width = w * ratio; + canvas.height = h * ratio; + canvas.style.width = w + "px"; + canvas.style.height = h + "px"; + canvas.getContext("2d").setTransform(ratio, 0, 0, ratio, 0, 0); + return canvas; + }, + + _attr: function (key, value) { + var self = this; + if (BI.isNull(key)) { + return; + } + if (BI.isObject(key)) { + BI.each(key, function (k, v) { + self._queue.push({ k: k, v: v }); + }); + return; + } + this._queue.push({ k: key, v: value }); + }, + + _line: function (x0, y0) { + var self = this; + var args = [].slice.call(arguments, 2); + if (BI.isOdd(args.length)) { + this._attr(BI.last(args)); + args = BI.initial(args); + } + this._attr("moveTo", [x0, y0]); + var odd = BI.filter(args, function (i) { + return i % 2 === 0; + }); + var even = BI.filter(args, function (i) { + return i % 2 !== 0; + }); + args = BI.zip(odd, even); + BI.each(args, function (i, point) { + self._attr("lineTo", point); + }); + }, + + line: function (x0, y0, x1, y1) { + this._line.apply(this, arguments); + this._attr("stroke", []); + }, + + rect: function (x, y, w, h, color) { + this._attr("fillStyle", color); + this._attr("fillRect", [x, y, w, h]); + }, + + circle: function (x, y, radius, color) { + this._attr({ + fillStyle: color, + beginPath: [], + arc: [x, y, radius, 0, Math.PI * 2, true], + closePath: [], + fill: [] + }); + }, + + hollow: function () { + this._attr("beginPath", []); + this._line.apply(this, arguments); + this._attr("closePath", []); + this._attr("stroke", []); + }, + + solid: function () { + this.hollow.apply(this, arguments); + this._attr("fill", []); + }, + + text: function (x, y, text, fillStyle) { + this._attr("fillStyle", BI.isNull(fillStyle) ? "rgb(102, 102, 102)" : fillStyle); + this._attr("fillText", [text, x, y]); + }, + + setFontStyle: function (fontStyle) { + this.fontStyle = fontStyle; + }, + + setFontVariant: function (fontVariant) { + this.fontVariant = fontVariant; + }, + + setFontWeight: function (fontWeight) { + this.fontWeight = fontWeight; + }, + + setFontSize: function (fontSize) { + this.fontSize = fontSize; + }, + + setFontFamily: function (fontFamily) { + this.fontFamily = fontFamily; + }, + + setFont: function () { + var fontStyle = this.fontStyle || "", + fontVariant = this.fontVariant || "", + fontWeight = this.fontWeight || "", + fontSize = this.fontSize || "12px", + fontFamily = this.fontFamily || "sans-serif", + font = fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + " " + fontFamily; + this._getContext().font = font; + }, + + gradient: function (x0, y0, x1, y1, start, end) { + var grd = this._getContext().createLinearGradient(x0, y0, x1, y1); + grd.addColorStop(0, start); + grd.addColorStop(1, end); + return grd; + }, + + reset: function (x, y) { + this._getContext().clearRect(x, y, this.canvas.width, this.canvas.height); + }, + + remove: function (x, y, width, height) { + this._getContext().clearRect(x, y, width, height); + }, + + stroke: function (callback) { + var self = this; + BI.nextTick(function () { + var ctx = self._getContext(); + BI.each(self._queue, function (i, q) { + if (BI.isFunction(ctx[q.k])) { + ctx[q.k].apply(ctx, q.v); + } else { + ctx[q.k] = q.v; + } + }); + self._queue = []; + callback && callback(); + }); + }, + + setWidth: function (width) { + BI.CanvasNew.superclass.setWidth.apply(this, arguments); + this.ratio = this._getPixelRatio(); + this.canvas.width = width * this.ratio; + this.canvas.style.width = width + "px"; + this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); + }, + + setHeight: function (height) { + BI.CanvasNew.superclass.setHeight.apply(this, arguments); + this.ratio = this._getPixelRatio(); + this.canvas.height = height * this.ratio; + this.canvas.style.height = height + "px"; + this.canvas.getContext("2d").setTransform(this.ratio, 0, 0, this.ratio, 0, 0); + }, + + setBlock: function () { + this.canvas.style.display = "block"; + }, + + transform: function (a, b, c, d, e, f) { + this._attr("transform", [a, b, c, d, e, f]); + }, + + translate: function (x, y) { + this._attr("translate", [x, y]); + } + }); + BI.shortcut("bi.canvas_new", BI.CanvasNew);/** * guy * 二级树 * @class BI.PlatformLevelTree @@ -4326,6 +4657,8 @@ BI.shortcut("bi.detail_table_header", BI.DetailTableHeader);Demo.Face = BI.inher mounted: function () { var self = this; + var tableItems = this._expandData(TABLE_ITEMS, 3), + headItems = this._expandHeadData(TABLE_HEADER, 3); this._resizeHandler = BI.debounce(function () { var width = self.element.width(), height = self.element.height(); if (self.table.getWidth() !== width || self.table.getHeight() !== height) { @@ -4339,14 +4672,44 @@ BI.shortcut("bi.detail_table_header", BI.DetailTableHeader);Demo.Face = BI.inher }); this.table.setWidth(this.element.width()); this.table.setHeight(this.element.height()); - this.table.attr("columnSize", BI.makeArray(26, "")); - this.table.attr("minColumnSize", BI.makeArray(26, 80)); + this.table.attr("columnSize", BI.makeArray(headItems[0].length, "")); + this.table.attr("minColumnSize", BI.makeArray(headItems[0].length, 60)); this.table.attr("isNeedFreeze", true); this.table.attr("freezeCols", []); this.table.attr("showSequence", true); - this.table.attr("headerRowSize", 25); - this.table.attr("rowSize", 25); - this.table.populate(TABLE_ITEMS, TABLE_HEADER); + this.table.attr("headerRowSize", 15); + this.table.attr("rowSize", 15); + this.table.populate(tableItems, headItems); + }, + + _expandData: function (items, times) { + var copy = BI.deepClone(items); + for (var m = 0; m < times - 1; m++) { + BI.each(items, function (i, row) { + copy.push(row); + }); + } + + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n % 100], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; + }, + + _expandHeadData: function (items, times) { + var copy = BI.deepClone(items); + for (var n = 0; n < copy.length; n++) { + for (var m = 0; m < times - 1; m++) { + BI.each(items[n], function (j, item) { + copy[n].push(item); + }) + } + } + return copy; } }); BI.shortcut("demo.large_table", Demo.Face);/** @@ -5062,6 +5425,10 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.ADDONS_CONFIG pId: 100000, text: "大表格", value: "demo.large_table" +}, { + pId: 100000, + text: "Canvas大表格", + value: "demo.canvas_table" }, { pId: 100000, text: "可以排序的树", diff --git a/dist/sliders.css b/dist/sliders.css index 03f096baf..a8d9688bb 100644 --- a/dist/sliders.css +++ b/dist/sliders.css @@ -1,14 +1,14 @@ .bi-interval-slider-label { min-height: 50px; } - + .bi-interval-slider { min-height: 70px; } .bi-single-slider-label { min-height: 50px; } - + .bi-single-slider-normal { min-height: 30px; } diff --git a/dist/widget.js b/dist/widget.js index a69151301..fb16a787d 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -1,17550 +1,18438 @@ -/** - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTableTreeNumber - * @extends BI.Widget - */ -BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table-tree-number", - isNeedFreeze: false, - startSequence: 1,//开始的序号 - scrollTop: 0, - headerRowSize: 25, - rowSize: 25, - - sequenceHeaderCreator: null, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.vCurr = 1; - this.hCurr = 1; - this.tasks = []; - this.renderedCells = []; - this.renderedKeys = []; - - this.container = BI.createWidget({ - type: "bi.absolute", - width: 60, - scrollable: false - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.vertical", - scrollable: false, - scrolly: false, - items: [this.container] - }); - - this.headerContainer = BI.createWidget({ - type: "bi.absolute", - cls: "bi-border", - width: 58, - scrollable: false - }); - - this.layout = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.headerContainer, - height: this._getHeaderHeight() - 2 - }, {el: {type: "bi.layout"}, height: 2}, { - el: this.scrollContainer - }] - }); - //缓存第一行对应的序号 - this.start = this.options.startSequence; - this.cache = {}; - this._nextState(); - - this._populate(); - }, - - _getNextSequence: function (nodes) { - var self = this; - var start = this.start; - var cnt = this.start; - - function track(node) { - //如果已经有缓存了就不改计数了,复杂表会出现这种情况 - self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); - cnt++; - } - - BI.each(nodes, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - if (index === 0) { - if (self.cache[child.text || child.value]) { - start = cnt = self.cache[child.text || child.value]; - } - } - track(child) - }); - } - }); - this.start = cnt; - return start; - }, - - _getStart: function (nodes) { - var self = this; - var start = this.start; - BI.some(nodes, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - return BI.some(node.children, function (index, child) { - if (index === 0) { - if (self.cache[child.text || child.value]) { - start = self.cache[child.text || child.value]; - return true; - } - } - }); - } - }); - return start; - }, - - _formatNumber: function (nodes) { - var self = this, o = this.options; - var result = []; - var count = this._getStart(nodes); - - function getLeafCount(node) { - var cnt = 0; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - cnt += getLeafCount(child); - }); - if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = this._getHeaderHeight() - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _getHeaderHeight: function () { - var o = this.options; - return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); - }, - - _nextState: function () { - var o = this.options; - this._getNextSequence(o.items); - }, - - _prevState: function () { - var self = this, o = this.options; - var firstChild; - BI.some(o.items, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - return BI.some(node.children, function (j, child) { - firstChild = child; - return true; - }); - } - }); - if (firstChild && BI.isNotEmptyObject(this.cache)) { - this.start = this.cache[firstChild.text || firstChild.value]; - } else { - this.start = 1; - } - this._nextState(); - }, - - _getMaxScrollTop: function (numbers) { - var cnt = 0; - BI.each(numbers, function (i, number) { - cnt += number.cnt; - }); - return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - - var renderedCells = [], renderedKeys = []; - var numbers = this._formatNumber(o.items); - var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); - BI.each(numbers, function (i, number) { - intervalTree.set(i, number.height); - }); - var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); - var index = intervalTree.greatestLowerBound(scrollTop); - var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); - var height = offsetTop; - var bodyHeight = o.height - this._getHeaderHeight(); - while (height < bodyHeight && index < numbers.length) { - renderedKeys.push(index); - offsetTop += numbers[index].height; - height += numbers[index].height; - index++; - } - - BI.each(renderedKeys, function (i, key) { - var index = BI.deepIndexOf(self.renderedKeys, key); - if (index > -1) { - if (numbers[key].height !== self.renderedCells[index]._height) { - self.renderedCells[index]._height = numbers[key].height; - self.renderedCells[index].el.setHeight(numbers[key].height); - } - if (numbers[key].top !== self.renderedCells[index].top) { - self.renderedCells[index].top = numbers[key].top; - self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); - } - renderedCells.push(self.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - styleGetter: numbers[key].isSummary === true ? function () { - return o.summaryCellStyleGetter(true); - } : function (key) { - return function () { - return o.sequenceCellStyleGetter(key); - } - }(numbers[key].index) - }, numbers[key])); - renderedCells.push({ - el: child, - left: 0, - top: numbers[key].top, - _height: numbers[key].height - }); - } - }); - - //已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]) - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - - this.container.setHeight(intervalTree.sumUntil(numbers.length)); - }, - - _restore: function () { - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - _populate: function () { - var self = this; - BI.each(this.tasks, function (i, task) { - task.apply(self); - }); - this.tasks = []; - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - if (v <= 1) { - this.cache = {}; - this.start = this.options.startSequence; - this._restore(); - this.tasks.push(this._nextState); - } else if (v === this.vCurr + 1) { - this.tasks.push(this._nextState); - } else if (v === this.vCurr - 1) { - this.tasks.push(this._prevState); - } - this.vCurr = v; - }, - - setHPage: function (v) { - if (v !== this.hCurr) { - this.tasks.push(this._prevState); - } - this.hCurr = v; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - this.tasks.push(this._prevState); - } - if (header && header !== this.options.header) { - o.header = header; - } - if (crossItems && crossItems !== this.options.crossItems) { - o.crossItems = crossItems; - } - if (crossHeader && crossHeader !== this.options.crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - } -}); -BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** - * 自适应布局 - * - * 1、resize - * 2、吸附 - * 3、当前组件在最上方 - * 4、可以撤销 - * 5、上下之间插入组件 - * - * Created by GUY on 2016/2/23. - * @class BI.AdaptiveArrangement - * @extends BI.Widget - */ -BI.AdaptiveArrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-adaptive-arrangement", - resizable: true, - layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, - items: [] - }); - }, - - _init: function () { - BI.AdaptiveArrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.arrangement", - element: this, - layoutType: o.layoutType, - items: o.items - }); - this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { - self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); - }); - this.zIndex = 0; - BI.each(o.items, function (i, item) { - self._initResizable(item.el); - }); - - $(document).mousedown(function (e) { - BI.each(self.getAllRegions(), function (i, region) { - if (region.el.element.find(e.target).length === 0) { - region.el.element.removeClass("selected"); - } - }); - }); - BI.ResizeDetector.addResizeListener(this, function () { - self.arrangement.resize(); - self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); - }); - }, - - _isEqual: function () { - return this.arrangement._isEqual.apply(this.arrangement, arguments); - }, - - _setSelect: function (item) { - if (!item.element.hasClass("selected")) { - item.element.css("zIndex", ++this.zIndex); - BI.each(this.getAllRegions(), function (i, region) { - region.el.element.removeClass("selected"); - }); - item.element.addClass("selected"); - } - }, - - _initResizable: function (item) { - var self = this, o = this.options; - item.element.css("zIndex", ++this.zIndex); - item.element.mousedown(function () { - self._setSelect(item) - }); - // o.resizable && item.element.resizable({ - // handles: "e, s, se", - // minWidth: 20, - // minHeight: 20, - // autoHide: true, - // helper: "bi-resizer", - // start: function () { - // item.element.css("zIndex", ++self.zIndex); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); - // }, - // resize: function (e, ui) { - // // self._resize(item.attr("id"), ui.size); - // self._resize(item.attr("id"), e, ui.size, ui.position); - // }, - // stop: function (e, ui) { - // self._stopResize(item.attr("id"), ui.size); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); - // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); - // } - // }); - }, - - // _resize: function (name, e, size, position) { - // var self = this; - // this.scrollInterval(e, false, true, function (changedSize) { - // size.width += changedSize.offsetX; - // size.height += changedSize.offsetY; - // var containerWidth = self.arrangement.container.element.width(); - // var containerHeight = self.arrangement.container.element.height(); - // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); - // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); - // switch (self.getLayoutType()) { - // case BI.Arrangement.LAYOUT_TYPE.FREE: - // break; - // case BI.Arrangement.LAYOUT_TYPE.GRID: - // self.setRegionSize(name, size); - // break; - // } - // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); - // }); - // }, - // - // _stopResize: function (name, size) { - // var self = this; - // this.scrollEnd(); - // switch (this.getLayoutType()) { - // case BI.Arrangement.LAYOUT_TYPE.FREE: - // this.setRegionSize(name, size); - // break; - // case BI.Arrangement.LAYOUT_TYPE.GRID: - // this.setRegionSize(name, size); - // break; - // } - // }, - - _getScrollOffset: function () { - return this.arrangement._getScrollOffset(); - }, - - getClientWidth: function () { - return this.arrangement.getClientWidth(); - }, - - getClientHeight: function () { - return this.arrangement.getClientHeight(); - }, - - addRegion: function (region, position) { - this._initResizable(region.el); - this._setSelect(region.el); - var self = this, flag; - var old = this.arrangement.getAllRegions(); - if (flag = this.arrangement.addRegion(region, position)) { - this._old = old; - } - return flag; - }, - - deleteRegion: function (name) { - var flag; - var old = this.getAllRegions(); - if (flag = this.arrangement.deleteRegion(name)) { - this._old = old; - } else { - this._old = this.getAllRegions(); - this.relayout(); - } - return flag; - }, - - setRegionSize: function (name, size) { - var flag; - var old = this.getAllRegions(); - if (flag = this.arrangement.setRegionSize(name, size)) { - this._old = old; - } - return flag; - }, - - setPosition: function (position, size) { - var self = this; - return this.arrangement.setPosition(position, size); - }, - - setRegionPosition: function (name, position) { - var region = this.getRegionByName(name); - return this.arrangement.setRegionPosition(name, position); - }, - - setDropPosition: function (position, size) { - return this.arrangement.setDropPosition(position, size); - }, - - scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { - var self = this; - var map = { - top: [-1, 0], - bottom: [1, 0], - left: [0, -1], - right: [0, 1] - }; - var clientSize = this.element.bounds(); - - function scrollTo(direction, callback) { - if (direction === "") { - self.lastActiveRegion = ""; - if (self._scrollInterval) { - clearInterval(self._scrollInterval); - self._scrollInterval = null; - } - return; - } - if (self.lastActiveRegion !== direction) { - self.lastActiveRegion = direction; - if (self._scrollInterval) { - clearInterval(self._scrollInterval); - self._scrollInterval = null; - } - var count = 0; - self._scrollInterval = setInterval(function () { - count++; - if (count <= 3) { - return; - } - var offset = self._getScrollOffset(); - var t = offset.top + map[direction][0] * 40; - var l = offset.left + map[direction][1] * 40; - if (t < 0 || l < 0) { - return; - } - callback({ - offsetX: map[direction][1] * 40, - offsetY: map[direction][0] * 40 - }); - self.scrollTo({ - top: t, - left: l - }); - }, 300); - } - } - - cb({ - offsetX: 0, - offsetY: 0 - }); - var offset = this.element.offset(); - var p = { - left: e.pageX - offset.left, - top: e.pageY - offset.top - }; - //向上滚 - if (isBorderScroll && p.top >= 0 && p.top <= 30) { - scrollTo("top", cb) - } - //向下滚 - else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { - scrollTo("bottom", cb) - } - //向左滚 - else if (isBorderScroll && p.left >= 0 && p.left <= 30) { - scrollTo("left", cb) - } - //向右滚 - else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { - scrollTo("right", cb) - } else { - if (isOverflowScroll === true) { - if (p.top < 0) { - scrollTo("top", cb); - } - else if (p.top > clientSize.height) { - scrollTo("bottom", cb); - } - else if (p.left < 0) { - scrollTo("left", cb); - } - else if (p.left > clientSize.width) { - scrollTo("right", cb); - } else { - scrollTo("", cb); - } - } else { - scrollTo("", cb); - } - } - }, - - scrollEnd: function () { - this.lastActiveRegion = ""; - if (this._scrollInterval) { - clearInterval(this._scrollInterval); - this._scrollInterval = null; - } - }, - - scrollTo: function (scroll) { - this.arrangement.scrollTo(scroll); - }, - - zoom: function (ratio) { - this.arrangement.zoom(ratio); - }, - - resize: function () { - this.arrangement.resize(); - }, - - relayout: function () { - return this.arrangement.relayout(); - }, - - setLayoutType: function (type) { - var self = this; - this.arrangement.setLayoutType(type); - }, - - getLayoutType: function () { - return this.arrangement.getLayoutType(); - }, - - getLayoutRatio: function () { - return this.arrangement.getLayoutRatio(); - }, - - getHelper: function () { - return this.arrangement.getHelper(); - }, - - getRegionByName: function (name) { - return this.arrangement.getRegionByName(name); - }, - - getAllRegions: function () { - return this.arrangement.getAllRegions(); - }, - - revoke: function () { - if (this._old) { - this.populate(BI.toArray(this._old)); - } - }, - - populate: function (items) { - var self = this; - BI.each(items, function (i, item) { - self._initResizable(item.el); - }); - this.arrangement.populate(items); - } -}); -BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; -BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; -BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; -BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; -BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; -BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** - * Arrangement的block面板 - * - * Created by GUY on 2016/3/1. - * @class BI.ArrangementBlock - * @extends BI.Widget - */ -BI.ArrangementBlock = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement-block bi-mask" - }); - } -}); -BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** - * Arrangement的drop面板 - * - * Created by GUY on 2016/3/1. - * @class BI.ArrangementDroppable - * @extends BI.Widget - */ -BI.ArrangementDroppable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement-droppable bi-resizer" - }); - } -}); -BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** - * 布局 - * - * Created by GUY on 2016/2/23. - * @class BI.Arrangement - * @extends BI.Widget - */ -BI.Arrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-arrangement", - layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, - items: [] - }); - }, - - _init: function () { - BI.Arrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.arrangement_droppable", - cls: "arrangement-block", - invisible: true - }); - this.block = BI.createWidget({ - type: "bi.arrangement_block", - invisible: true - }); - this.container = BI.createWidget({ - type: "bi.absolute", - cls: "arrangement-container", - items: o.items.concat([this.block, this.arrangement]) - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.adaptive", - width: "100%", - height: "100%", - scrollable: true, - items: [this.container] - }); - this.scrollContainer.element.scroll(function () { - self.fireEvent(BI.Arrangement.EVENT_SCROLL, { - scrollLeft: self.scrollContainer.element.scrollLeft(), - scrollTop: self.scrollContainer.element.scrollTop(), - clientWidth: self.scrollContainer.element[0].clientWidth, - clientHeight: self.scrollContainer.element[0].clientHeight - }); - }); - - BI.createWidget({ - type: "bi.adaptive", - element: this, - items: [this.scrollContainer] - }); - this.regions = {}; - if (o.items.length > 0) { - BI.nextTick(function () { - self.populate(o.items); - }); - } - }, - - ////初始化操作//// - _calculateRegions: function (items) { - var self = this, o = this.options; - this.regions = {}; - BI.each(items, function (i, item) { - var region = self._createOneRegion(item); - self.regions[region.id] = region; - }); - }, - - _isEqual: function (num1, num2) { - return Math.abs(num1 - num2) < 2; - }, - - _isLessThan: function (num1, num2) { - return num1 < num2 && !this._isEqual(num1, num2); - }, - - _isMoreThan: function (num1, num2) { - return num1 > num2 && !this._isEqual(num1, num2); - }, - - _isLessThanEqual: function (num1, num2) { - return num1 <= num2 || this._isEqual(num1, num2); - }, - - _isMoreThanEqual: function (num1, num2) { - return num1 >= num2 || this._isEqual(num1, num2); - }, - - //获取占有的最大Region - _getRegionOccupied: function (regions) { - var self = this, o = this.options; - if (BI.size(regions || this.regions) <= 0) { - return { - left: 0, - top: 0, - width: 0, - height: 0 - } - } - var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; - BI.each(regions || this.regions, function (id, region) { - minLeft = Math.min(minLeft, region.left); - maxLeft = Math.max(maxLeft, region.left + region.width); - minTop = Math.min(minTop, region.top); - maxTop = Math.max(maxTop, region.top + region.height); - }); - return { - left: minLeft, - top: minTop, - width: maxLeft - minLeft, - height: maxTop - minTop - } - }, - - //两个区域的交叉面积 - _getCrossArea: function (region1, region2) { - if (region1.left <= region2.left) { - if (region1.top <= region2.top) { - if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { - if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { - return 0; - } - return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); - } - } else { - if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { - if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { - return 0; - } - return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); - } - } - } else { - if (region1.top <= region2.top) { - if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { - if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { - return 0; - } - return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); - } - } else { - if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { - if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { - return 0; - } - return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); - } - } - } - return 0; - }, - - //是否有覆盖的组件 - _isRegionOverlay: function (regions) { - var reg = []; - BI.each(regions || this.regions, function (id, region) { - reg.push(new BI.Region(region.left, region.top, region.width, region.height)); - }); - for (var i = 0, len = reg.length; i < len; i++) { - for (var j = i + 1; j < len; j++) { - var area1 = { - left: reg[i].x, - top: reg[i].y, - width: reg[i].w, - height: reg[i].h - }; - var area2 = { - left: reg[j].x, - top: reg[j].y, - width: reg[j].w, - height: reg[j].h - }; - if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { - return true; - } - } - } - return false; - }, - - //布局是否是优良的 - _isArrangeFine: function (regions) { - switch (this.options.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - return true; - case BI.Arrangement.LAYOUT_TYPE.GRID: - // if (this._isRegionOverlay()) { - // return false; - // } - } - return true; - }, - - _getRegionNames: function (regions) { - var names = []; - BI.each(regions || this.regions, function (i, region) { - names.push(region.id || region.attr("id")); - }); - return names; - }, - - _getRegionsByNames: function (names, regions) { - names = BI.isArray(names) ? names : [names]; - regions = regions || this.regions; - if (BI.isArray(regions)) { - var result = []; - BI.each(regions, function (i, region) { - if (names.contains(region.id || region.attr("id"))) { - result.push(region); - } - }); - } else { - var result = {}; - BI.each(names, function (i, name) { - result[name] = regions[name]; - }); - } - return result; - }, - - _cloneRegion: function (regions) { - var clone = {}; - BI.each(regions || this.regions, function (id, region) { - clone[id] = {}; - clone[id].el = region.el; - clone[id].id = region.id; - clone[id].left = region.left; - clone[id].top = region.top; - clone[id].width = region.width; - clone[id].height = region.height; - }); - return clone; - }, - - //测试合法性 - _test: function (regions) { - var self = this; - return !BI.any(regions || this.regions, function (i, region) { - if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { - return true; - } - }) - }, - - _getScrollOffset: function () { - return { - left: this.scrollContainer.element[0].scrollLeft, - top: this.scrollContainer.element[0].scrollTop - } - }, - - ////操作//// - _createOneRegion: function (item) { - var el = BI.createWidget(item.el); - el.setVisible(true); - return { - id: el.attr("id"), - left: item.left, - top: item.top, - width: item.width, - height: item.height, - el: el - } - }, - - _applyRegion: function (regions) { - var self = this, o = this.options; - BI.each(regions || this.regions, function (i, region) { - region.el.element.css({ - left: region.left, - top: region.top, - width: region.width, - height: region.height - }); - }); - this._applyContainer(); - this.ratio = this.getLayoutRatio(); - }, - - _renderRegion: function () { - var items = BI.toArray(this.regions); - BI.each(items, function (i, item) { - if (BI.isNotNull(item.el)) { - item.el.options.key = item.id; - } else { - item.key = item.id; - } - }); - if (BI.isNull(this.wrapper)) { - this.wrapper = BI.createWidget({ - type: "bi.absolute", - element: this.container - }); - } - this.wrapper.populate(items); - }, - - getClientWidth: function () { - return this.scrollContainer.element[0].clientWidth; - }, - - getClientHeight: function () { - return this.scrollContainer.element[0].clientHeight; - }, - - _applyContainer: function () { - //先掩藏后显示能够明确滚动条是否出现 - this.scrollContainer.element.css("overflow", "hidden"); - var occupied = this._getRegionOccupied(); - this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); - this.scrollContainer.element.css("overflow", "auto"); - return occupied; - }, - - _modifyRegion: function (regions) { - BI.each(this.regions, function (id, region) { - if (regions[id]) { - region.left = regions[id].left; - region.top = regions[id].top; - region.width = regions[id].width; - region.height = regions[id].height; - } - }); - }, - - _addRegion: function (item) { - var region = this._createOneRegion(item); - this.regions[region.id] = region; - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [region] - }); - }, - - _deleteRegionByName: function (name) { - this.regions[name].el.setVisible(false); - delete this.regions[name]; - }, - - _setArrangeSize: function (size) { - this.arrangement.element.css({ - left: size.left, - top: size.top, - width: size.width, - height: size.height - }) - }, - - //Grid - _getOneWidthPortion: function () { - return this.getClientWidth() / BI.Arrangement.PORTION; - }, - _getOneHeightPortion: function () { - return this.getClientHeight() / BI.Arrangement.H_PORTION; - }, - - _getGridPositionAndSize: function (position) { - var perWidth = this._getOneWidthPortion(); - var perHeight = this._getOneHeightPortion(); - var widthPortion = Math.round(position.width / perWidth); - var leftPortion = Math.round(position.left / perWidth); - var topPortion = Math.round(position.top / perHeight); - var heightPortion = Math.round(position.height / perHeight); - // if (leftPortion > BI.Arrangement.PORTION) { - // leftPortion = BI.Arrangement.PORTION; - // } - // if (widthPortion > BI.Arrangement.PORTION) { - // widthPortion = BI.Arrangement.PORTION; - // } - // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { - // leftPortion = BI.Arrangement.PORTION - widthPortion; - // } - if (widthPortion === 0) { - widthPortion = 1; - } - if (heightPortion === 0) { - heightPortion = 1; - } - return { - x: leftPortion, - y: topPortion, - w: widthPortion, - h: heightPortion - } - }, - - _getBlockPositionAndSize: function (position) { - var perWidth = this._getOneWidthPortion(); - var perHeight = this._getOneHeightPortion(); - return { - left: position.x * perWidth, - top: position.y * perHeight, - width: position.w * perWidth, - height: position.h * perHeight - }; - }, - - _getLayoutsByRegions: function (regions) { - var self = this; - var result = []; - BI.each(regions || this.regions, function (id, region) { - result.push(BI.extend(self._getGridPositionAndSize(region), { - i: region.id - })) - }); - return result; - }, - - _getLayoutIndexByName: function (layout, name) { - return BI.findIndex(layout, function (i, l) { - return l.i === name; - }); - }, - - _setBlockPositionAndSize: function (size) { - this.block.element.css({ - left: size.left, - top: size.top, - width: size.width, - height: size.height - }); - }, - - _getRegionsByLayout: function (layout) { - var self = this; - var regions = {}; - BI.each(layout, function (i, ly) { - regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { - id: ly.i - }); - }); - return regions; - }, - - _setRegionsByLayout: function (regions, layout) { - var self = this; - regions || (regions = this.regions); - BI.each(layout, function (i, ly) { - if (regions[ly.i]) { - BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); - } - }); - return regions; - }, - - _moveElement: function (layout, l, x, y, isUserAction) { - var self = this; - if (l._static) { - return layout; - } - - if (l.y === y && l.x === x) { - return layout; - } - - var movingUp = y && l.y > y; - if (typeof x === 'number') { - l.x = x; - } - if (typeof y === 'number') { - l.y = y; - } - l.moved = true; - - var sorted = this._sortLayoutItemsByRowCol(layout); - if (movingUp) { - sorted = sorted.reverse(); - } - var collisions = getAllCollisions(sorted, l); - - for (var i = 0, len = collisions.length; i < len; i++) { - var collision = collisions[i]; - if (collision.moved) { - continue; - } - - if (l.y > collision.y && l.y - collision.y > collision.h / 4) { - continue; - } - - if (collision._static) { - layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); - } else { - layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); - } - } - - return layout; - - function getAllCollisions(layout, layoutItem) { - return BI.filter(layout, function (i, l) { - return self._collides(l, layoutItem); - }); - } - }, - - _sortLayoutItemsByRowCol: function (layout) { - return [].concat(layout).sort(function (a, b) { - if (a.y > b.y || (a.y === b.y && a.x > b.x)) { - return 1; - } - return -1; - }); - }, - - _collides: function (l1, l2) { - if (l1 === l2) { - return false; - } // same element - if (l1.x + l1.w <= l2.x) { - return false; - } // l1 is left of l2 - if (l1.x >= l2.x + l2.w) { - return false; - } // l1 is right of l2 - if (l1.y + l1.h <= l2.y) { - return false; - } // l1 is above l2 - if (l1.y >= l2.y + l2.h) { - return false; - } // l1 is below l2 - return true; // boxes overlap - }, - - _getFirstCollision: function (layout, layoutItem) { - for (var i = 0, len = layout.length; i < len; i++) { - if (this._collides(layout[i], layoutItem)) { - return layout[i]; - } - } - }, - - _moveElementAwayFromCollision: function (layout, collidesWith, - itemToMove, isUserAction) { - if (isUserAction) { - var fakeItem = { - x: itemToMove.x, - y: itemToMove.y, - w: itemToMove.w, - h: itemToMove.h, - i: '-1' - }; - fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); - if (!this._getFirstCollision(layout, fakeItem)) { - return this._moveElement(layout, itemToMove, undefined, fakeItem.y); - } - } - - return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); - }, - - _compactItem: function (compareWith, l, verticalCompact) { - if (verticalCompact) { - while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { - l.y--; - } - } - - var collides; - while ((collides = this._getFirstCollision(compareWith, l))) { - l.y = collides.y + collides.h; - } - return l; - }, - - compact: function (layout, verticalCompact) { - var compareWith = getStatics(layout); - var sorted = this._sortLayoutItemsByRowCol(layout); - var out = []; - - for (var i = 0, len = sorted.length; i < len; i++) { - var l = sorted[i]; - - if (!l._static) { - l = this._compactItem(compareWith, l, verticalCompact); - - compareWith.push(l); - } - - out[layout.indexOf(l)] = l; - - l.moved = false; - } - - return out; - - function getStatics(layout) { - return BI.filter(layout, function (i, l) { - return l._static; - }); - } - }, - - ////公有方法//// - getRegionByName: function (name) { - var obj = {}; - obj[name] = this.regions[name]; - return this._cloneRegion(obj)[name]; - }, - - getAllRegions: function () { - return BI.toArray(this._cloneRegion()); - }, - - getHelper: function () { - var helper = BI.createWidget({ - type: "bi.layout", - width: 18, - height: 18, - cls: "arrangement-helper bi-border" - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [helper] - }); - return helper; - }, - - _start: function () { - if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { - this.block.setVisible(true); - } else { - this.arrangement.setVisible(true); - } - }, - - _stop: function () { - this.arrangement.setVisible(false); - this.block.setVisible(false); - }, - - ////公有操作//// - setLayoutType: function (type) { - var self = this, o = this.options; - if (type !== o.layoutType) { - o.layoutType = type; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.relayout(); - break; - } - } - }, - - getLayoutType: function () { - return this.options.layoutType; - }, - - getLayoutRatio: function () { - var occupied = this._getRegionOccupied(); - var width = this.getClientWidth(), height = this.getClientHeight(); - return { - x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), - y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) - } - }, - - addRegion: function (region, position) { - if (position) { - this.setPosition(position, region); - } - var self = this, o = this.options; - if (!this.position) { - return false; - } - var test = this._cloneRegion(); - BI.each(this.position.regions, function (i, region) { - test[region.id].left = region.left; - test[region.id].top = region.top; - test[region.id].width = region.width; - test[region.id].height = region.height; - - }); - var item = BI.extend({}, region, { - left: this.position.insert.left, - top: this.position.insert.top, - width: this.position.insert.width, - height: this.position.insert.height - }); - var added = this._createOneRegion(item); - test[added.id] = added; - if (this._test(test)) { - delete test[added.id]; - this._modifyRegion(test); - this._addRegion(item); - this._populate(this.getAllRegions()); - return true; - } - return false; - }, - - deleteRegion: function (name) { - if (!this.regions[name]) { - return false; - } - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - this._deleteRegionByName(name); - this._populate(this.getAllRegions()); - return true; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this._deleteRegionByName(name); - this._populate(this.getAllRegions()); - this.resize(); - return true; - } - return false; - }, - - setRegionSize: function (name, size) { - var self = this, o = this.options; - var flag = false; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var clone = this._cloneRegion(); - BI.extend(clone[name], { - width: size.width, - height: size.height - }); - if (this._test(clone)) { - this._modifyRegion(clone); - flag = true; - } - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - var clone = this._cloneRegion(); - BI.extend(clone[name], { - width: size.width, - height: size.height - }); - if (this._test(clone)) { - var layout = this._getLayoutsByRegions(clone); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - flag = true; - } - break; - } - this._applyRegion(); - return flag; - }, - - setPosition: function (position, size) { - var self = this, o = this.options; - var insert, regions = [], cur; - if (position.left < 0 || position.top < 0) { - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.resize(); - break; - } - this._stop(); - this.position = null; - return null; - } - var offset = this._getScrollOffset(); - position = { - left: position.left + offset.left, - top: position.top + offset.top - }; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var insert = { - top: position.top < 0 ? 0 : position.top, - left: position.left < 0 ? 0 : position.left, - width: size.width, - height: size.height - }; - this.position = { - insert: insert - }; - this._setArrangeSize(insert); - this._start(); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - var p = { - top: position.top < 0 ? 0 : position.top, - left: position.left < 0 ? 0 : position.left, - width: size.width, - height: size.height - }; - this._setArrangeSize(p); - var cur = this._getGridPositionAndSize(p); - var layout = [{ - x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i - }].concat(this._getLayoutsByRegions()); - layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); - layout = this.compact(layout, true); - var regions = this._setRegionsByLayout(this._cloneRegion(), layout); - var insert = this._getBlockPositionAndSize(layout[0]); - this.position = { - insert: insert, - regions: regions - }; - this._applyRegion(regions); - this._setBlockPositionAndSize(insert); - this._start(); - break; - } - return this.position; - }, - - setRegionPosition: function (name, position) { - var self = this, o = this.options; - var offset = this._getScrollOffset(); - position = BI.extend(position, { - left: position.left + offset.left, - top: position.top + offset.top - }); - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - this._applyRegion(); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (!position.stop) { - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - var cloned = this._cloneRegion(); - var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - })); - var x = cur.x, y = cur.y; - cur = BI.extend(cur, { - x: 0, y: BI.MAX, i: -1 - }); - delete cloned[name]; - var layout = this._getLayoutsByRegions(cloned); - layout = this._moveElement([cur].concat(layout), cur, x, y, true); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - - this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); - this.block.setVisible(true); - } else { - BI.extend(this.regions[name], { - left: position.left < 0 ? 0 : position.left, - top: position.top < 0 ? 0 : position.top - }); - var cloned = this._cloneRegion(); - var layout = this._getLayoutsByRegions(cloned); - layout = this.compact(layout, true); - var regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - this.block.setVisible(false); - } - break; - } - }, - - setDropPosition: function (position, size) { - var self = this; - this.arrangement.setVisible(true); - var offset = this._getScrollOffset(); - this._setArrangeSize(BI.extend({}, size, { - left: position.left + offset.left, - top: position.top + offset.top - })); - return function () { - self.arrangement.setVisible(false); - } - }, - - scrollTo: function (scroll) { - this.scrollContainer.element.scrollTop(scroll.top); - this.scrollContainer.element.scrollLeft(scroll.left); - }, - - zoom: function (ratio) { - var self = this, o = this.options; - if (!ratio) { - return; - } - var occupied = this._applyContainer(); - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - if (this._isArrangeFine()) { - var width = this.getClientWidth(); - var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); - //var yRatio = ratio.y * height / (occupied.top + occupied.height); - var regions = this._cloneRegion(); - BI.each(regions, function (i, region) { - region.left = region.left * xRatio; - //region.top = region.top * yRatio; - region.width = region.width * xRatio; - //region.height = region.height * yRatio; - }); - if (this._test(regions)) { - this._modifyRegion(regions); - this._applyRegion(); - } - this.resize(); - // } else { - this.relayout(); - } - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (this._isArrangeFine()) { - var width = this.getClientWidth(), height = this.getClientHeight(); - var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); - var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); - var regions = this._cloneRegion(); - BI.each(regions, function (i, region) { - region.left = region.left * xRatio; - region.width = region.width * xRatio; - region.top = region.top * yRatio; - region.height = region.height * yRatio; - //做一下自适应布局到网格布局的兼容 - var perWidth = self._getOneWidthPortion(); - var widthPortion = Math.round(region.width / perWidth); - var leftPortion = Math.round(region.left / perWidth); - var comparePortion = Math.round((region.width + region.left) / perWidth); - if (leftPortion + widthPortion !== comparePortion) { - region.left = leftPortion * perWidth; - region.width = comparePortion * perWidth - region.left; - } - }); - if (this._test(regions)) { - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - } - } else { - this.relayout(); - } - break; - } - }, - - resize: function () { - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - this.zoom(this.ratio); - var regions = this._cloneRegion(); - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._applyRegion(); - break; - } - }, - - relayout: function () { - var self = this, o = this.options; - switch (o.layoutType) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - if (!this._isArrangeFine()) { - var perHeight = this._getOneHeightPortion(); - var width = this.getClientWidth(), height = this.getClientHeight(); - var regions = this._cloneRegion(); - var clone = BI.toArray(regions); - clone.sort(function (r1, r2) { - if (self._isEqual(r1.top, r2.top)) { - return r1.left - r2.left; - } - return r1.top - r2.top; - }); - var count = clone.length; - var cols = 4, rows = Math.floor((count - 1) / 4 + 1); - var w = width / cols, h = height / rows; - var store = {}; - BI.each(clone, function (i, region) { - var row = Math.floor(i / 4), col = i % 4; - BI.extend(region, { - top: row * perHeight * 6, - left: col * w, - width: w, - height: perHeight * 6 - }); - if (!store[row]) { - store[row] = {}; - } - store[row][col] = region; - }); - //非4的倍数 - // if (count % 4 !== 0) { - // var lasts = store[rows - 1]; - // var perWidth = width / (count % 4); - // BI.each(lasts, function (i, region) { - // BI.extend(region, { - // left: BI.parseInt(i) * perWidth, - // width: perWidth - // }); - // }); - // } - if (this._test(clone)) { - var layout = this._getLayoutsByRegions(regions); - layout = this.compact(layout, true); - regions = this._getRegionsByLayout(layout); - this._modifyRegion(regions); - this._populate(clone); - } - } else { - this.resize(); - } - break; - } - }, - - _populate: function (items) { - this._stop(); - this._calculateRegions(items); - this._applyRegion(); - }, - - populate: function (items) { - this.regions = {}; - this._populate(items); - this._renderRegion(); - } -}); -BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; -BI.extend(BI.Arrangement, { - PORTION: 36, - H_PORTION: 18, - LAYOUT_TYPE: { - GRID: 0, - FREE: 1 - } -}); -BI.shortcut('bi.arrangement', BI.Arrangement);/** - * 日期控件中的月份下拉框 - * - * 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: 25 - }); - }, - _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" - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ - self.setValue(self.popup.getValue()); - }) - - - this.combo = BI.createWidget({ - type: "bi.combo", - offsetStyle: "center", - 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); - }); - }, - - setValue: function(v){ - this.trigger.setValue(v + 1); - 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', //最大日期 - height: 25 - }); - }, - _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", - 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, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: this.popup - } - }) - this.combo.on(BI.Combo.EVENT_CHANGE, function(){ - self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); - }) - }, - - 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 bi-background", - height: 25, - 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 = new Date().getFullYear(); - this._month = new Date().getMonth(); - 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 () { - if (self._month === 0) { - self.setValue({ - year: self.year.getValue() - 1, - month: 11 - }) - } 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: 25, - height: 25 - }); - - this.right.on(BI.IconButton.EVENT_CHANGE, function () { - if (self._month === 11) { - self.setValue({ - year: self.year.getValue() + 1, - month: 0 - }) - } 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", - 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" - }); - 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: this.left, - width: 25 - }, { - type: "bi.center_adapt", - items: [{ - type: "bi.horizontal", - width: 100, - items: [this.year, this.month] - }] - }, { - el: this.right, - width: 25 - }] - }) - this.setValue({ - year: this._year, - month: this._month - }) - }, - - _checkLeftValid: function () { - var o = this.options; - var valid = !(this._month === 0 && this._year === Date.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); - this.left.setEnable(valid); - return valid; - }, - - _checkRightValid: function () { - var o = this.options; - var valid = !(this._month === 11 && this._year === Date.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); - this.right.setEnable(valid); - return valid; - }, - - - - setValue: function (ob) { - this._year = ob.year; - this._month = 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.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 = new Date(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); - 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", - min: o.min, - max: o.max - }); - - this.calendar = BI.createWidget({ - direction: "top", - element: this, - 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); - }); - }, - - 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);/** - * 日期控件中的年份或月份trigger - * - * Created by GUY on 2015/9/7. - * @class BI.DateTriangleTrigger - * @extends BI.Trigger - */ -BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { - _const: { - height: 25, - iconWidth: 16, - iconHeight: 13 - }, - - _defaultConfig: function() { - return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", - height: 25 - }); - }, - _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 - }) - this.icon = BI.createWidget({ - type: "bi.icon", - width: c.iconWidth, - height: c.iconHeight - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [{ - type: "bi.center_adapt", - width: 50, - height: c.height, - items: [this.text, this.icon] - }] - }) - }, - - 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 GUY on 2015/9/7. - * @class BI.DateCombo - * @extends BI.Widget - */ -BI.DateCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-combo bi-border", - height: 25 - }); - }, - _init: function () { - BI.DateCombo.superclass._init.apply(this, arguments); - var self = this, - o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.date_trigger" - }); - - this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { - self.combo.toggle(); - }); - - this.popup = BI.createWidget({ - type: "bi.date_calendar_popup" - }); - - this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - width: 270, - el: this.popup, - stopPropagation: false - } - }) - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - triggerWidth: 30, - yearLength: 4, - yearMonthLength: 7 - }, - - _defaultConfig: function () { - return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-date-trigger", - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.DateTrigger.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) { - var date = v.match(/\d+/g); - self._autoAppend(v, date); - return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ - year: date[0], - month: date[1], - day: date[2] - }); - }, - 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"); - } - }); - this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.DateTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DateTrigger.EVENT_STOP); - }); - this.editor.on(BI.SignEditor.EVENT_VALID, function () { - self.fireEvent(BI.DateTrigger.EVENT_VALID); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DateTrigger.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)) { - var date = value.split("-"); - self.store_value = { - type: BI.DateTrigger.MULTI_DATE_CALENDAR, - value:{ - year: date[0] | 0, - month: date[1] - 1, - day: date[2] | 0 - } - }; - } - self.fireEvent(BI.DateTrigger.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.DateTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTrigger.EVENT_CHANGE); - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: BI.createWidget(), - width: 30 - }, { - el: this.editor - }] - }) - }, - _dateCheck: function (date) { - return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; - }, - _checkVoid: function (obj) { - return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; - }, - _autoAppend: function (v, dateObj) { - var self = this; - var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - var yearCheck = function (v) { - return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; - }; - var monthCheck = function (v) { - return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; - }; - if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { - switch (v.length) { - case this._const.yearLength: - if (yearCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - case this._const.yearMonthLength: - if (monthCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - } - } - }, - - setValue: function (v) { - var type, value, self = this; - var date = new Date(); - this.store_value = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; - if(BI.isNull(value)){ - value = v; - } - } - var _setInnerValue = function (date, text) { - var dateStr = date.print("%Y-%x-%e"); - self.editor.setState(dateStr); - self.editor.setValue(dateStr); - self.setTitle(text + ":" + dateStr); - }; - switch (type) { - case BI.DateTrigger.MULTI_DATE_YEAR_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; - date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; - date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; - date = new Date(date.getFullYear(), 0, 1); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_YEAR_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; - date = new Date(date.getFullYear(), 11, 31); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; - date = new Date().getBeforeMulQuarter(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; - date = new Date().getAfterMulQuarter(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; - date = new Date().getQuarterStartDate(); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_QUARTER_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; - date = new Date().getQuarterEndDate(); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; - date = new Date().getBeforeMultiMonth(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; - date = new Date().getAfterMultiMonth(value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; - date = new Date(date.getFullYear(), date.getMonth(), 1); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_MONTH_END: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; - date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_WEEK_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; - date = date.getOffsetDate(-7 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; - date = date.getOffsetDate(7 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_PREV: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; - date = date.getOffsetDate(-1 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_AFTER: - var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; - date = date.getOffsetDate(1 * value); - _setInnerValue(date, text); - break; - case BI.DateTrigger.MULTI_DATE_DAY_TODAY: - var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; - date = new Date(); - _setInnerValue(date, text); - break; - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - this.editor.setState(""); - this.editor.setValue(""); - this.setTitle(""); - } else { - var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - this.setTitle(dateStr); - } - break; - } - }, - - getKey: function () { - return this.editor.getValue(); - }, - getValue: function () { - return this.store_value; - } - -}); - -BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; -BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; -BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; -BI.DateTrigger.MULTI_DATE_YEAR_END = 4; - -BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; -BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; -BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; -BI.DateTrigger.MULTI_DATE_MONTH_END = 8; - -BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; -BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; -BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; -BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; - -BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; -BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; - -BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; -BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; -BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; - -BI.DateTrigger.MULTI_DATE_PARAM = 18; -BI.DateTrigger.MULTI_DATE_CALENDAR = 19; - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); - -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); -BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); - -BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DateTrigger.EVENT_START = "EVENT_START"; -BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; -BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.date_trigger", BI.DateTrigger);/** - * Created by zcf on 2017/2/20. - */ -BI.DatePaneWidget = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.DatePaneWidget.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.DatePaneWidget.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.today = new Date(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); - - this.selectedTime = o.selectedTime || { - year: this._year, - month: this._month - }; - - this.datePicker = BI.createWidget({ - type: "bi.date_picker", - min: o.min, - max: o.max - }); - 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 = BI.createWidget({ - direction: "top", - element: this, - logic: { - dynamic: false - }, - type: "bi.navigation", - tab: this.datePicker, - cardCreator: BI.bind(this._createNav, this) - - // afterCardCreated: function () { - // - // }, - // - // afterCardShow: function () { - // // this.setValue(self.selectedTime); - // } - }); - 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); - }); - - }, - - _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 = new Date(); - return { - year: today.getFullYear(), - month: today.getMonth() - } - }, - - _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.date_pane", BI.DatePaneWidget);/** - * 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', - width: 200, - height: 24 - }); - }, - _init: function () { - BI.DateTimeCombo.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - var date = new Date(); - this.storeValue = { - year: date.getFullYear(), - month: date.getMonth(), - 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 - }); - - this.popup = BI.createWidget({ - type: "bi.date_time_popup", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_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.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () { - self.trigger.setValue(self.popup.getValue()); - self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE); - }); - this.combo = BI.createWidget({ - type: 'bi.combo', - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: this.popup, - maxHeight: this.constants.popupHeight, - width: this.constants.popupWidth, - stopPropagation: false - } - }); - 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 bi-border-right", - width: 30, - height: 24 - }); - triggerBtn.on(BI.TriggerIconButton.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, - left: 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: 290 - }); - }, - _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", - min: self.options.min, - max: self.options.max - }); - self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - }); - - this.dateSelect = BI.createWidget({ - type: "bi.vertical_adapt", - cls: "bi-border-top", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Basic_Time"), - width: 45 - }, { - type: "bi.date_time_select", - max: 23, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.hour = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.minute = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.second = _ref; - } - }] - }); - - var date = new Date(); - this.dateCombo.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.hour.setValue(date.getHours()); - this.minute.setValue(date.getMinutes()); - this.second.setValue(date.getSeconds()); - - this.dateButton = BI.createWidget({ - type: "bi.grid", - items: [[this.cancelButton, this.okButton]] - }); - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this.dateCombo - }, { - el: this.dateSelect, - height: 50 - }, { - el: this.dateButton, - height: 30 - }] - }); - }, - - setValue: function (v) { - var value = v, date; - if (BI.isNull(value)) { - date = new Date(); - this.dateCombo.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.hour.setValue(date.getHours()); - this.minute.setValue(date.getMinutes()); - this.second.setValue(date.getSeconds()); - } else { - this.dateCombo.setValue({ - year: value.year, - month: value.month, - day: value.day - }); - this.hour.setValue(value.hour); - this.minute.setValue(value.minute); - this.second.setValue(value.second); - } - }, - - getValue: function () { - return { - year: this.dateCombo.getValue().year, - month: this.dateCombo.getValue().month, - day: this.dateCombo.getValue().day, - hour: this.hour.getValue(), - minute: this.minute.getValue(), - second: this.second.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.DateTimeSelect = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-time-select bi-border", - max: 23, - min: 0 - }) - }, - - _init: function () { - BI.DateTimeSelect.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - value: this._alertInEditorValue(o.min), - allowBlank: false, - errorText: BI.i18nText("BI-Please_Input_Natural_Number"), - validationChecker: function(v){ - return BI.isNaturalNumber(v); - } - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ - self._finetuning(0); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ - self._finetuning(1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-next-page-h-font bottom-button bi-border-left" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ - self._finetuning(-1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this._finetuning(0); - BI.createWidget({ - type: "bi.htape", - 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: 30 - }] - }); - }, - - _alertOutEditorValue: function(v){ - if (v > this.options.max){ - v = this.options.min; - } - if (v < this.options.min){ - v = this.options.max - } - return BI.parseInt(v); - }, - - _alertInEditorValue: function(v){ - if (v > this.options.max){ - v = this.options.min; - } - if (v < this.options.min){ - v = this.options.max; - } - v = v < 10 ? "0" + v : v; - return v; - }, - - _finetuning: function(add){ - var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); - this.editor.setValue(this._alertInEditorValue(v + add)); - }, - - getValue: function () { - var v = this.editor.getValue(); - return this._alertOutEditorValue(v); - }, - - setValue: function (v) { - this.editor.setValue(this._alertInEditorValue(v)); - this._finetuning(0); - } - -}); -BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimeTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - triggerWidth: 30 - }, - - _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: BI.createWidget(), - width: c.triggerWidth - }, { - el: this.text - }] - }) - }, - - _printTime: function (v) { - return v < 10 ? "0" + v : v; - }, - - setValue: function (v) { - var self = this; - var value = v, dateStr; - if(BI.isNull(value)){ - value = new Date(); - dateStr = value.print("%Y-%X-%d %H:%M:%S"); - } else { - var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second); - dateStr = date.print("%Y-%X-%d %H:%M:%S"); - - } - this.text.setText(dateStr); - this.text.setTitle(dateStr); - } - -}); -BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/** - * 带有方向的pathchooser - * - * Created by GUY on 2016/4/21. - * @class BI.DirectionPathChooser - * @extends BI.Widget - */ -BI.DirectionPathChooser = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#808080", - selectLineColor: "#009de3" - }, - - _defaultConfig: function () { - return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-excel-table", - items: [] - }); - }, - - _init: function () { - BI.DirectionPathChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.pathChooser = BI.createWidget({ - type: "bi.path_chooser", - element: this, - items: o.items - }); - this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { - //self._unselectAllArrows(); - self._setValue(start, index); - self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); - }); - this._drawArrows(); - - }, - - _unselectAllArrows: function () { - var self = this, lineColor = this._const.lineColor; - BI.each(this.arrows, function (region, rs) { - BI.each(rs, function (idx, arrows) { - BI.each(arrows, function (i, arrow) { - arrow.attr({fill: lineColor, stroke: lineColor}); - }); - }); - }); - }, - - _drawOneArrow: function (dot, direction) { - //0,1,2,3 上右下左 - var lineColor = this._const.lineColor; - var selectLineColor = this._const.selectLineColor; - var svg = this.pathChooser.svg; - var path = ""; - switch (direction) { - case 0: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 3) + "," + (dot.y + 5) - + "L" + (dot.x + 3) + "," + (dot.y + 5) - + "L" + dot.x + "," + dot.y; - break; - case 1: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 5) + "," + (dot.y - 3) - + "L" + (dot.x - 5) + "," + (dot.y + 3) - + "L" + dot.x + "," + dot.y; - break; - case 2: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x - 3) + "," + (dot.y - 5) - + "L" + (dot.x + 3) + "," + (dot.y - 5) - + "L" + dot.x + "," + dot.y; - break; - case 3: - path = "M" + dot.x + "," + dot.y - + "L" + (dot.x + 5) + "," + (dot.y - 3) - + "L" + (dot.x + 5) + "," + (dot.y + 3) - + "L" + dot.x + "," + dot.y; - break; - } - return svg.path(path).attr({fill: lineColor, stroke: lineColor}); - }, - - _drawArrows: function () { - var self = this, o = this.options; - var routes = this.pathChooser.routes; - var pathes = this.pathChooser.pathes; - var store = this.pathChooser.store; - this.arrows = {}; - BI.each(routes, function (region, ps) { - self.arrows[region] = []; - BI.each(ps, function (idx, path) { - self.arrows[region][idx] = []; - var dots = pathes[region][idx]; - BI.each(dots, function (i, dot) { - if (i > 0 && i < dots.length - 1) { - var arrow; - if (dot.y === dots[i - 1].y) { - if (dots[i + 1].y != dot.y) { - if (store[path[path.length - 2]].direction === -1) { - if (i - 1 > 0) { - arrow = self._drawOneArrow(dots[i - 1], 3); - } - } else { - arrow = self._drawOneArrow(dots[i], 1); - } - } - } else if (dot.x === dots[i - 1].x) { - if (dot.y > dots[i - 1].y) { - if (store[BI.first(path)].direction === -1) { - arrow = self._drawOneArrow(dots[i - 1], 0); - } else { - arrow = self._drawOneArrow(dot, 2); - } - } else { - if (store[path[path.length - 2]].direction === -1) { - arrow = self._drawOneArrow(dots[i - 1], 2); - } else { - arrow = self._drawOneArrow(dot, 0); - } - } - } - if (arrow) { - self.arrows[region][idx].push(arrow); - } - } - }); - BI.each(path, function (i, node) { - if (i !== 0) { - var arrow; - var from = path[i - 1]; - if (store[from].direction === -1) { - var regionIndex = self.pathChooser.getRegionIndexById(from); - var x = getXoffsetByRegionIndex(regionIndex, -1); - var y = getYByXoffset(dots, x); - arrow = self._drawOneArrow({x: x, y: y}, 3); - } else { - var regionIndex = self.pathChooser.getRegionIndexById(node); - var x = getXoffsetByRegionIndex(regionIndex); - var y = getYByXoffset(dots, x); - arrow = self._drawOneArrow({x: x, y: y}, 1); - } - if (arrow) { - self.arrows[region][idx].push(arrow); - } - } - }); - }) - }); - - function getXoffsetByRegionIndex(regionIndex, diregion) { - if (diregion === -1) { - return 100 * (regionIndex + 1) - 20; - } - return 100 * regionIndex + 20; - } - - function getYByXoffset(dots, xoffset) { - var finded = BI.find(dots, function (i, dot) { - if (i > 0) { - if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { - return true; - } - } - }); - return finded.y; - } - }, - - _setValue: function (start, index) { - var self = this; - var lineColor = this._const.lineColor; - var selectLineColor = this._const.selectLineColor; - var routes = this.pathChooser.routes; - var starts = this.pathChooser.start; - var each = [start]; - if (starts.contains(start)) { - each = starts; - } - BI.each(each, function (i, s) { - BI.each(self.arrows[s], function (j, arrows) { - BI.each(arrows, function (k, arrow) { - arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); - }); - }); - }); - BI.each(this.arrows[start][index], function (i, arrow) { - arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); - }); - var current = BI.last(routes[start][index]); - while (current && routes[current] && routes[current].length === 1) { - BI.each(self.arrows[current][0], function (i, arrow) { - arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); - }); - current = BI.last(routes[current][0]); - } - }, - - setValue: function (v) { - this.pathChooser.setValue(v); - this._unselectAllArrows(); - var routes = this.pathChooser.routes; - var nodes = BI.keys(routes), self = this; - var result = [], array = []; - BI.each(v, function (i, val) { - if (BI.contains(nodes, val)) { - if (array.length > 0) { - array.push(val); - result.push(array); - array = []; - } - } - array.push(val); - }); - if (array.length > 0) { - result.push(array); - } - //画这n条路径 - BI.each(result, function (idx, path) { - var start = path[0]; - var index = BI.findIndex(routes[start], function (idx, p) { - if (BI.isEqual(path, p)) { - return true; - } - }); - if (index >= 0) { - self._setValue(start, index); - } - }); - }, - - getValue: function () { - return this.pathChooser.getValue(); - }, - - populate: function (items) { - this.pathChooser.populate(items); - this._drawArrows(); - } -}); -BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; -BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** - * 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", - invalid: false, - height: 25, - items: [], - adjustLength: 0, - direction: "bottom", - trigger: "click", - 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 - }); - - 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, - adjustLength: o.adjustLength, - direction: o.direction, - 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 () { - this.downlistcombo.showView(); - }, - - 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 - }] - }); - 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.Single, { - _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: 25, - 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.icon_text_item", - element: this, - height: o.height, - text: o.text, - value: o.value, - logic: o.logic, - selected: o.selected, - disabled: o.disabled, - iconHeight: o.iconHeight, - iconWidth: o.iconWidth, - textHgap: o.textHgap, - textVgap: o.textVgap, - textLgap: o.textLgap, - textRgap: o.textRgap, - father: o.father - }); - this.text.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { - self.fireEvent(BI.DownListItem.EVENT_CHANGE); - }); - // this.setSelected(o.selected); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - isSelected: function () { - return this.text.isSelected(); - }, - - setSelected: function (b) { - this.text.setSelected(b); - // if (b === true) { - // this.element.addClass("dot-e-font"); - // } else { - // this.element.removeClass("dot-e-font"); - // } - }, - - setValue: function (v) { - this.text.setValue(v); - }, - - getValue: function () { - return this.text.getValue(); - } -}); -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: 25, - forceNotSelected: true - }); - - this.icon2 = BI.createWidget({ - type: "bi.icon_button", - cls: o.iconCls2, - width: 25, - forceNotSelected: true - }); - - var blank = BI.createWidget({ - type: "bi.layout", - width: 25 - }); - 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() - } - }); - }, - - 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) { - var self = this, o = this.options; - v = BI.isArray(v) ? v : [v]; - BI.find(v, function (idx, value) { - if (BI.contains(o.childValues, value)) { - self.icon1.setSelected(true); - return true; - } else { - self.icon1.setSelected(false); - } - }) - } -}); -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: 25, - 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 = {}; - var self = this, o = this.options, children = this._createChildren(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 - }], - 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 (!self.singleValues.contains(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] - }); - - }, - _createChildren: 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: 4, - el: { - type: "bi.button_tree", - chooseType: 0, - layouts: [{ - type: "bi.vertical" - }] - - } - }; - 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-border-top cursor-pointer", - height: 0 - } - - }], - cls: "bi-down-list-spliter-container cursor-pointer", - lgap: 10, - rgap: 10 - }); - 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 - }, - - populate: function (items) { - BI.DownListPopup.superclass.populate.apply(this, arguments); - var self = this; - self.childValueMap = {}; - self.fatherValueMap = {}; - self.singleValues = []; - var children = self._createChildren(items); - var popupItem = BI.createItems(children, - {}, { - adjustLength: -2 - } - ); - self.popup.populate(popupItem); - }, - - setValue: 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); - } - ); - this.popup.setValue(valueArray); - }, - - getValue: function () { - var self = this, result = []; - var values = this.popup.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 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", - height: 30, - 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, - errorText: o.errorText, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker - }); - 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.SearchEditor.EVENT_CLEAR); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: { - type: "bi.center_adapt", - cls: "search-font", - items: [{ - el: { - type: "bi.icon" - } - }] - }, - width: 25 - }, - { - el: self.editor - }, - { - el: this.clear, - width: 25 - } - ] - }); - 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]; - } - }, - - 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: 24 - }); - }, - - _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", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: false, - watermark: "", - errorText: "", - height: 30 - }) - }, - - _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: 25 - }); - }, - - _init: function () { - BI.SmallTextEditor.superclass._init.apply(this, arguments); - } -}); -BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** - * 文件管理控件组 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerButtonGroup - * @extends BI.Widget - */ -BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-button_group", - items: [] - }) - }, - - _init: function () { - BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.button_group = BI.createWidget({ - type: "bi.button_tree", - element: this, - chooseType: BI.Selection.Multi, - items: this._formatItems(o.items), - layouts: [{ - type: "bi.vertical" - }] - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _formatItems: function (items) { - var self = this, o = this.options; - BI.each(items, function (i, item) { - if (item.children && item.children.length > 0) { - item.type = "bi.file_manager_folder_item"; - } else { - item.type = "bi.file_manager_file_item"; - } - }); - return items; - }, - - setValue: function (v) { - this.button_group.setValue(v); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getNotSelectedValue: function () { - return this.button_group.getNotSelectedValue(); - }, - - getAllLeaves: function () { - return this.button_group.getAllLeaves(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - getSelectedButtons: function () { - return this.button_group.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.button_group.getNotSelectedButtons(); - }, - - populate: function (items) { - this.button_group.populate(this._formatItems(items)); - } -}); -BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManager - * @extends BI.Widget - */ -BI.FileManager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager", - el: {}, - items: [] - }) - }, - - _init: function () { - BI.FileManager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - var items = BI.Tree.transformToTreeFormat(o.items); - this.tree.initTree(items); - this.selectedValues = []; - this.nav = BI.createWidget({ - type: "bi.file_manager_nav", - items: BI.deepClone(items) - }); - this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { - if (value == "-1") {//根节点 - self.populate({children: self.tree.toJSON()}); - } else { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } - self.setValue(self.selectedValues); - }); - this.list = BI.createWidget(o.el, { - type: "bi.file_manager_list", - items: items - }); - this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { - if (type === BI.Events.CHANGE) { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } else if (type === BI.Events.CLICK) { - var values = []; - if (obj instanceof BI.MultiSelectBar) { - var t = self.list.getValue(); - selected = t.type === BI.Selection.All; - values = BI.concat(t.assist, t.value); - } else { - values = obj.getAllLeaves(); - } - BI.each(values, function (i, v) { - if (selected === true) { - self.selectedValues.pushDistinct(v); - } else { - self.selectedValues.remove(v); - } - }); - } - self.setValue(self.selectedValues); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.list, - left: 0, - right: 0, - top: 0, - bottom: 10 - }, { - el: this.nav, - left: 40, - right: 100, - top: 0 - }] - }); - }, - - setValue: function (value) { - this.selectedValues = value || []; - this.list.setValue(this.selectedValues); - }, - - getValue: function () { - var obj = this.list.getValue(); - var res = obj.type === BI.Selection.All ? obj.assist : obj.value; - res.pushDistinctArray(this.selectedValues); - return res; - }, - - _populate: function (items) { - this.list.populate(items); - }, - - getSelectedValue: function () { - return this.nav.getValue()[0]; - }, - - getSelectedId: function () { - return this.nav.getId()[0]; - }, - - populate: function (node) { - var clone = BI.deepClone(node); - this._populate(node.children); - this.nav.populate(clone); - } -}); -BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; -BI.shortcut("bi.file_manager", BI.FileManager);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFileItem - * @extends BI.Single - */ -BI.FileManagerFileItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", - height: 30 - }) - }, - - _init: function () { - BI.FileManagerFileItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-file-font" - }, - width: 20 - }, { - el: { - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - } - }] - }) - }, - - getAllLeaves: function(){ - return [this.options.value]; - }, - - isSelected: function () { - return this.checked.isSelected(); - }, - - setSelected: function (v) { - this.checked.setSelected(v); - } -}); -BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFolderItem - * @extends BI.Single - */ -BI.FileManagerFolderItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", - height: 30 - }) - }, - - _init: function () { - BI.FileManagerFolderItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button = BI.createWidget({ - type: "bi.text_button", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); - }); - - this.tree = new BI.Tree(); - this.tree.initTree([{ - id: o.id, - children: o.children - }]); - this.selectValue = []; - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-folder-font" - }, - width: 20 - }, { - el: this.button - }] - }) - }, - - setAllSelected: function (v) { - this.checked.setSelected(v); - this.selectValue = []; - }, - - setHalfSelected: function (v) { - this.checked.setHalfSelected(v); - if(!v){ - this.selectValue = []; - } - }, - - setValue: function (v) { - var self = this, o = this.options; - var isHalf = false; - var selectValue = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - if (BI.contains(v, node.get("data").value)) { - selectValue.push(node.get("data").value); - } else { - isHalf = true; - } - } - }); - this.setAllSelected(selectValue.length > 0 && !isHalf); - this.setHalfSelected(selectValue.length > 0 && isHalf); - if (this.checked.isHalfSelected()) { - this.selectValue = selectValue; - } - }, - - getAllButtons: function () { - return [this]; - }, - - getAllLeaves: function () { - var o = this.options; - var res = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value) - } - }); - return res; - }, - - getNotSelectedValue: function () { - var self = this, o = this.options; - var res = []; - var isAllSelected = this.checked.isSelected(); - if (isAllSelected === true) { - return res; - } - var isHalfSelected = this.checked.isHalfSelected(); - this.tree.traverse(function (node) { - if (node.isLeaf()) { - var v = node.get("data").value; - if (isHalfSelected === true) { - if (!BI.contains(self.selectValue, node.get("data").value)) { - res.push(v); - } - } else { - res.push(v); - } - } - }); - return res; - }, - - getValue: function () { - var res = []; - if (this.checked.isSelected()) { - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value); - } - }); - return res; - } - if (this.checked.isHalfSelected()) { - return this.selectValue; - } - return []; - } -}); -BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** - * 文件管理控件列表 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerList - * @extends BI.Widget - */ -BI.FileManagerList = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-list", - el: {}, - items: [] - }) - }, - - _init: function () { - BI.FileManagerList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.list = BI.createWidget({ - type: "bi.select_list", - element: this, - items: o.items, - toolbar: { - type: "bi.multi_select_bar", - height: 40, - text: "" - }, - el: { - type: "bi.list_pane", - el: BI.isWidget(o.el) ? o.el : BI.extend({ - type: "bi.file_manager_button_group" - }, o.el) - } - }); - this.list.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - setValue: function (v) { - this.list.setValue({ - value: v - }); - }, - - getValue: function () { - return this.list.getValue(); - }, - - populate: function (items) { - this.list.populate(items); - this.list.setToolBarVisible(true); - } -}); -BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** - * 文件管理导航按钮 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNavButton - * @extends BI.Widget - */ -BI.FileManagerNavButton = BI.inherit(BI.Widget, { - - _const: { - normal_color: "#ffffff", - select_color: "#eff1f4" - }, - _defaultConfig: function () { - return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav-button", - selected: false, - height: 40 - }) - }, - - _init: function () { - BI.FileManagerNavButton.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.button = BI.createWidget({ - type: "bi.text_button", - cls: "file-manager-nav-button-text bi-card", - once: true, - selected: o.selected, - text: o.text, - title: o.text, - value: o.value, - height: o.height, - lgap: 20, - rgap: 10 - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var svg = BI.createWidget({ - type: "bi.svg", - cls: "file-manager-nav-button-triangle", - width: 15, - height: o.height - }); - var path = svg.path("M0,0L15,20L0,40").attr({ - "stroke": c.select_color, - "fill": o.selected ? c.select_color : c.normal_color - }); - this.button.on(BI.TextButton.EVENT_CHANGE, function () { - if (this.isSelected()) { - path.attr("fill", c.select_color); - } else { - path.attr("fill", c.normal_color); - } - }); - BI.createWidget({ - type: "bi.default", - element: this, - items: [this.button] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: svg, - right: -15, - top: 0, - bottom: 0 - }] - }) - }, - - isSelected: function () { - return this.button.isSelected(); - }, - - setValue: function (v) { - this.button.setValue(v); - }, - - getValue: function () { - return this.button.getValue(); - }, - - populate: function (items) { - - } -}); -BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** - * 文件管理导航 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNav - * @extends BI.Widget - */ -BI.FileManagerNav = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav bi-border-left", - height: 40, - items: [] - }) - }, - - _init: function () { - BI.FileManagerNav.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - this.refreshTreeData(o.items); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - this.button_group = BI.createWidget({ - type: "bi.button_group", - element: this, - items: [{ - type: "bi.file_manager_nav_button", - text: BI.i18nText("BI-Created_By_Me"), - selected: true, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME, - value: BI.FileManagerNav.ROOT_CREATE_BY_ME - }], - layouts: [{ - type: "bi.horizontal" - }] - }); - 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.FileManagerNav.EVENT_CHANGE, arguments); - }); - }, - - _getAllParents: function (id) { - var node, res = []; - if (!id) { - node = this.tree.getRoot(); - } else { - node = this.tree.search(id); - } - while (node.parent) { - res.push(node); - node = node.parent; - } - res.push(node); - return res.reverse(); - }, - - _formatNodes: function (nodes) { - var res = []; - BI.each(nodes, function (i, node) { - res.push(BI.extend({ - type: "bi.file_manager_nav_button", - id: node.id - }, node.get("data"))); - }); - BI.last(res).selected = true; - return res; - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getId: function () { - var ids = []; - BI.each(this.button_group.getSelectedButtons(), function (i, btn) { - ids.push(btn.attr("id")); - }); - return ids; - }, - - refreshTreeData: function(items){ - this.tree.initTree(BI.Tree.transformToTreeFormat(items)); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - }, - - populate: function (node) { - var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); - this.button_group.populate(this._formatNodes(parents)); - } -}); -BI.extend(BI.FileManagerNav, { - ROOT_CREATE_BY_ME: "-1" -}); -BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** - * 交互行为布局 - * - * - * Created by GUY on 2016/7/23. - * @class BI.InteractiveArrangement - * @extends BI.Widget - */ -BI.InteractiveArrangement = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-interactive-arrangement", - resizable: true, - layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, - items: [] - }); - }, - - _init: function () { - BI.InteractiveArrangement.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.arrangement = BI.createWidget({ - type: "bi.adaptive_arrangement", - element: this, - resizable: o.resizable, - layoutType: o.layoutType, - items: o.items - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { - self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { - self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); - }); - - this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { - var p = self._getRegionClientPosition(id); - self.draw({ - left: p.left, - top: p.top - }, size, id); - }); - this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { - self.stopDraw(); - self.setRegionSize(id, size); - }); - - this.tags = []; - - }, - - _isEqual: function (num1, num2) { - return this.arrangement._isEqual(num1, num2); - }, - - _getScrollOffset: function () { - return this.arrangement._getScrollOffset(); - }, - - _positionAt: function (position, regions) { - var self = this; - regions = regions || this.getAllRegions(); - var left = [], center = [], right = [], top = [], middle = [], bottom = []; - BI.each(regions, function (i, region) { - var client = self._getRegionClientPosition(region.id); - if (Math.abs(client.left - position.left) <= 3) { - left.push(region); - } - if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { - center.push(region); - } - if (Math.abs(client.left + client.width - position.left) <= 3) { - right.push(region); - } - if (Math.abs(client.top - position.top) <= 3) { - top.push(region); - } - if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { - middle.push(region); - } - if (Math.abs(client.top + client.height - position.top) <= 3) { - bottom.push(region); - } - }); - return { - left: left, - center: center, - right: right, - top: top, - middle: middle, - bottom: bottom - } - }, - - _getRegionClientPosition: function (name) { - var region = this.getRegionByName(name); - var offset = this.arrangement._getScrollOffset(); - return { - top: region.top - offset.top, - left: region.left - offset.left, - width: region.width, - height: region.height, - id: region.id - } - }, - - _vAlign: function (position, regions) { - var self = this; - var vs = this._positionAt(position, regions); - var positions = []; - var l; - if (vs.left.length > 0) { - l = this._getRegionClientPosition(vs.left[0].id).left; - } else if (vs.right.length > 0) { - var temp = this._getRegionClientPosition(vs.right[0].id); - l = temp.left + temp.width; - } else if (vs.center.length > 0) { - var temp = this._getRegionClientPosition(vs.center[0].id); - l = temp.left + temp.width / 2; - } - var rs = vs.left.concat(vs.right).concat(vs.center); - BI.each(rs, function (i, region) { - var p = self._getRegionClientPosition(region.id); - if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l) || self._isEqual(p.left + p.width / 2, l)) { - var topPoint = { - top: p.top + p.height / 2, - left: l - }; - positions.push({ - id: region.id, - start: topPoint, - end: { - left: l, - top: position.top - } - }); - } - }); - return positions; - }, - - _leftAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left, - top: position.top + size.height / 2 - }, regions); - }, - - _rightAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left + size.width, - top: position.top + size.height / 2 - }, regions); - }, - - _hAlign: function (position, regions) { - var self = this; - var hs = this._positionAt(position, regions); - var positions = []; - var t; - if (hs.top.length > 0) { - var temp = this._getRegionClientPosition(hs.top[0].id); - t = temp.top; - } else if (hs.bottom.length > 0) { - var temp = this._getRegionClientPosition(hs.bottom[0].id); - t = temp.top + temp.height; - } else if (hs.middle.length > 0) { - var temp = this._getRegionClientPosition(hs.middle[0].id); - t = temp.top + temp.height / 2; - } - var rs = hs.top.concat(hs.bottom).concat(hs.middle); - BI.each(rs, function (i, region) { - var p = self._getRegionClientPosition(region.id); - if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t) || self._isEqual(p.top + p.height / 2, t)) { - var leftPoint = { - top: t, - left: p.left + p.width / 2 - }; - positions.push({ - id: p.id, - start: leftPoint, - end: { - left: position.left, - top: t - } - }); - } - }); - return positions; - }, - - _topAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top - }, regions); - }, - - _bottomAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top + size.height - }, regions); - }, - - _centerAlign: function (position, size, regions) { - var self = this; - return this._vAlign({ - left: position.left + size.width / 2, - top: position.top + size.height / 2 - }, regions); - }, - - _middleAlign: function (position, size, regions) { - var self = this; - return this._hAlign({ - left: position.left + size.width / 2, - top: position.top + size.height / 2 - }, regions); - }, - - - _drawOneTag: function (start, end) { - var s = BI.createWidget({ - type: "bi.icon_button", - //invisible: true, - width: 13, - height: 13, - cls: "drag-tag-font interactive-arrangement-dragtag-icon" - }); - var e = BI.createWidget({ - type: "bi.icon_button", - //invisible: true, - width: 13, - height: 13, - cls: "drag-tag-font interactive-arrangement-dragtag-icon" - }); - if (this._isEqual(start.left, end.left)) { - var line = BI.createWidget({ - type: "bi.layout", - //invisible: true, - cls: "interactive-arrangement-dragtag-line", - width: 1, - height: Math.abs(start.top - end.top) - }); - } else { - var line = BI.createWidget({ - type: "bi.layout", - //invisible: true, - cls: "interactive-arrangement-dragtag-line", - height: 1, - width: Math.abs(start.left - end.left) - }); - } - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: s, - left: start.left - 6, - top: start.top - 7 - }, { - el: e, - left: end.left - 6, - top: end.top - 7 - }, { - el: line, - left: Math.min(start.left, end.left), - top: Math.min(start.top, end.top) - }] - }); - this.tags.push(s); - this.tags.push(e); - this.tags.push(line); - }, - - stopDraw: function () { - BI.each(this.tags, function (i, w) { - w.destroy(); - }); - this.tags = []; - }, - - _getRegionExcept: function (name, regions) { - var other = []; - BI.each(regions || this.getAllRegions(), function (i, region) { - if (!(name && region.id === name)) { - other.push(region); - } - }); - return other; - }, - - getClientWidth: function () { - return this.arrangement.getClientWidth(); - }, - - getClientHeight: function () { - return this.arrangement.getClientHeight(); - }, - - getPosition: function (name, position, size) { - var regions = this.getAllRegions(); - var me; - if (name) { - me = this._getRegionClientPosition(name); - } - var other = this._getRegionExcept(name, regions); - position = position || { - left: me.left, - top: me.top - }; - size = size || { - width: me.width, - height: me.height - }; - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - position.left = pos.end.left - size.width / 2; - }); - BI.each(right, function (i, pos) { - position.left = pos.end.left - size.width; - }); - BI.each(left, function (i, pos) { - position.left = pos.end.left; - }); - BI.each(middle, function (i, pos) { - position.top = pos.end.top - size.height / 2; - }); - BI.each(bottom, function (i, pos) { - position.top = pos.end.top - size.height; - }); - BI.each(top, function (i, pos) { - position.top = pos.end.top; - }); - return position; - }, - - //position不动 变size - getSize: function (name, position, size) { - var regions = this.getAllRegions(); - var me; - if (name) { - me = this._getRegionClientPosition(name); - } - var other = this._getRegionExcept(name, regions); - position = position || { - left: me.left, - top: me.top - }; - size = size || { - width: me.width, - height: me.height - }; - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - size.width = (pos.end.left - position.left) * 2; - }); - BI.each(right, function (i, pos) { - size.width = pos.end.left - position.left; - }); - BI.each(left, function (i, pos) { - }); - BI.each(middle, function (i, pos) { - size.height = (pos.end.top - position.top) * 2; - }); - BI.each(bottom, function (i, pos) { - size.height = pos.end.top - position.top; - }); - BI.each(top, function (i, pos) { - }); - return size; - }, - - draw: function (position, size, name) { - var self = this; - this.stopDraw(); - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - var other = this._getRegionExcept(name); - var left = this._leftAlign(position, size, other); - var right = this._rightAlign(position, size, other); - var top = this._topAlign(position, size, other); - var bottom = this._bottomAlign(position, size, other); - var center = this._centerAlign(position, size, other); - var middle = this._middleAlign(position, size, other); - - BI.each(center, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(right, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(left, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(middle, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(bottom, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - BI.each(top, function (i, pos) { - self._drawOneTag(pos.start, pos.end); - }); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - }, - - addRegion: function (region, position) { - this.stopDraw(); - return this.arrangement.addRegion(region, position); - }, - - deleteRegion: function (name) { - return this.arrangement.deleteRegion(name); - }, - - setRegionSize: function (name, size) { - size = this.getSize(name, null, size); - return this.arrangement.setRegionSize(name, size); - }, - - setPosition: function (position, size) { - var self = this; - this.stopDraw(); - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(null, position, size); - this.draw(position, size); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - var at = this.arrangement.setPosition(position, size); - return at; - }, - - setRegionPosition: function (name, position) { - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(name, position); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - return this.arrangement.setRegionPosition(name, position); - }, - - setDropPosition: function (position, size) { - var self = this; - this.stopDraw(); - if (position.left > 0 && position.top > 0) { - switch (this.getLayoutType()) { - case BI.Arrangement.LAYOUT_TYPE.FREE: - position = this.getPosition(null, position, size); - this.draw(position, size); - break; - case BI.Arrangement.LAYOUT_TYPE.GRID: - break; - } - } - var callback = self.arrangement.setDropPosition(position, size); - return function () { - callback(); - self.stopDraw(); - } - }, - - scrollInterval: function () { - this.arrangement.scrollInterval.apply(this.arrangement, arguments); - }, - - scrollEnd: function () { - this.arrangement.scrollEnd.apply(this.arrangement, arguments); - }, - - scrollTo: function (scroll) { - this.arrangement.scrollTo(scroll); - }, - - zoom: function (ratio) { - this.arrangement.zoom(ratio); - }, - - resize: function () { - return this.arrangement.resize(); - }, - - relayout: function () { - return this.arrangement.relayout(); - }, - - setLayoutType: function (type) { - this.arrangement.setLayoutType(type); - }, - - getLayoutType: function () { - return this.arrangement.getLayoutType(); - }, - - getLayoutRatio: function () { - return this.arrangement.getLayoutRatio(); - }, - - getHelper: function () { - return this.arrangement.getHelper(); - }, - - getRegionByName: function (name) { - return this.arrangement.getRegionByName(name); - }, - - getAllRegions: function () { - return this.arrangement.getAllRegions(); - }, - - revoke: function () { - return this.arrangement.revoke(); - }, - - populate: function (items) { - var self = this; - this.arrangement.populate(items); - } -}); -BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; -BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; -BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** - * 月份下拉框 - * - * 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: 25 - }); - }, - _init: function () { - BI.MonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.month_trigger" - }); - - 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 - }); - 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", - 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 () { - 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 = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; - 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 + 1 - }; - }); - }); - - 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 - }] - }); - - 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) { - 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, - triggerWidth: 25, - errorText: BI.i18nText("BI-Month_Trigger_Error_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-month-trigger bi-border", - height: 25 - }); - }, - _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: c.errorText - }); - 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: c.triggerWidth - }, - width: c.triggerWidth - }, { - el: { - type: "bi.trigger_icon_button", - width: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - 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);/** - * 普通控件 - * - * @class BI.MultiDateCard - * @extends BI.Widget - * @abstract - */ -BI.MultiDateCard = BI.inherit(BI.Widget, { - - constants: { - lgap: 80, - itemHeight: 35, - defaultEditorValue: "1" - }, - - _defaultConfig: function () { - return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this, arguments), {}); - }, - - dateConfig: function () { - - }, - - defaultSelectedItem: function () { - - }, - - _init: function () { - BI.MultiDateCard.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.label = BI.createWidget({ - type: 'bi.label', - height: this.constants.itemHeight, - textAlign: "left", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - cls: 'bi-multidate-inner-label bi-tips' - }); - this.radioGroup = BI.createWidget({ - type: "bi.button_group", - chooseType: 0, - items: BI.createItems(this.dateConfig(), { - type: 'bi.multidate_segment', - height: this.constants.itemHeight - }), - layouts: [{ - type: "bi.vertical" - }] - }); - - this.radioGroup.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CONFIRM) { - self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); - } - }); - this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE, function () { - self.setValue(self.getValue()); - self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); - }); - BI.createWidget({ - element: this, - type: 'bi.center_adapt', - lgap: this.constants.lgap, - items: [{ - type: 'bi.vertical', - items: [this.label, this.radioGroup] - }] - }); - }, - - getValue: function () { - var button = this.radioGroup.getSelectedButtons()[0]; - var type = button.getValue(), value = button.getInputValue(); - return { - type: type, - value: value - } - }, - - _isTypeAvaliable: function (type) { - var res = false; - BI.find(this.dateConfig(), function (i, item) { - if (item.value === type) { - res = true; - return true; - } - }); - return res; - }, - - setValue: function (v) { - var self = this; - if (BI.isNotNull(v) && this._isTypeAvaliable(v.type)) { - this.radioGroup.setValue(v.type); - BI.each(this.radioGroup.getAllButtons(), function (i, button) { - if (button.isEditorExist() === true && button.isSelected()) { - button.setInputValue(v.value); - } else { - button.setInputValue(self.constants.defaultEditorValue); - } - }); - } else { - this.radioGroup.setValue(this.defaultSelectedItem()); - BI.each(this.radioGroup.getAllButtons(), function (i, button) { - button.setInputValue(self.constants.defaultEditorValue); - }); - } - }, - - getCalculationValue: function () { - var valueObject = this.getValue(); - var type = valueObject.type, value = valueObject.value; - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - return new Date().getOffsetDate(-1 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - return new Date().getOffsetDate(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - return new Date(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - return new Date().getBeforeMultiMonth(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - return new Date().getAfterMultiMonth(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - return new Date(new Date().getFullYear(), new Date().getMonth(), 1); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - return new Date(new Date().getFullYear(), new Date().getMonth(), (new Date().getLastDateOfMonth()).getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - return new Date().getBeforeMulQuarter(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - return new Date().getAfterMulQuarter(value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - return new Date().getQuarterStartDate(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - return new Date().getQuarterEndDate(); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - return new Date().getOffsetDate(-7 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - return new Date().getOffsetDate(7 * value); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - return new Date((new Date().getFullYear() - 1 * value), new Date().getMonth(), new Date().getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - return new Date((new Date().getFullYear() + 1 * value), new Date().getMonth(), new Date().getDate()); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - return new Date(new Date().getFullYear(), 0, 1); - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - return new Date(new Date().getFullYear(), 11, 31); - } - } -}); -BI.MultiDateCard.EVENT_CHANGE = "EVENT_CHANGE"; -/** - * 日期控件 - * @class BI.MultiDateCombo - * @extends BI.Widget - */ -BI.MultiDateCombo = 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" - }, - _defaultConfig: function () { - return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-combo bi-border', - height: 24 - }); - }, - _init: function () { - BI.MultiDateCombo.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.storeTriggerValue = ""; - var date = new Date(); - this.storeValue = null; - this.trigger = BI.createWidget({ - type: 'bi.date_trigger', - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE - }); - this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - }); - this.trigger.on(BI.DateTrigger.EVENT_STOP, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { - self.combo.toggle(); - }); - this.trigger.on(BI.DateTrigger.EVENT_FOCUS, function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.MultiDateCombo.EVENT_FOCUS); - }); - this.trigger.on(BI.DateTrigger.EVENT_ERROR, function () { - self.storeValue = { - year: date.getFullYear(), - month: date.getMonth() - }; - self.popup.setValue(); - self.fireEvent(BI.MultiDateCombo.EVENT_ERROR); - }); - this.trigger.on(BI.DateTrigger.EVENT_VALID, function () { - self.fireEvent(BI.MultiDateCombo.EVENT_VALID); - }); - this.trigger.on(BI.DateTrigger.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); - }); - this.trigger.on(BI.DateTrigger.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()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup = BI.createWidget({ - type: "bi.multidate_popup", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE - }); - this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE, function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE, function () { - var date = new Date(); - self.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - //self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); - self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ - type: 'bi.combo', - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: this.popup, - maxHeight: this.constants.popupHeight, - width: this.constants.popupWidth, - stopPropagation: false - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW); - }); - - var triggerBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: 30, - height: 23 - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.changeIcon = BI.createWidget({ - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 30, - height: 23 - }); - - - var leftPart = BI.createWidget({ - type: "bi.absolute", - items: [{ - el: this.combo, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: triggerBtn, - top: 0, - left: 0 - }] - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [leftPart, { - el: this.changeIcon, - width: 30 - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } - }) - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type - } - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[1].width = 30; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[1].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.popup.setValue(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.shortcut('bi.multidate_combo', BI.MultiDateCombo); - -BI.MultiDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.MultiDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; -BI.MultiDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiDateCombo.EVENT_VALID = "EVENT_VALID"; -BI.MultiDateCombo.EVENT_ERROR = "EVENT_ERROR"; -BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW"; - -BI.extend(BI.MultiDateCombo, { - MULTI_DATE_YMD_CARD: 1, - MULTI_DATE_YEAR_CARD: 2, - MULTI_DATE_QUARTER_CARD: 3, - MULTI_DATE_MONTH_CARD: 4, - MULTI_DATE_WEEK_CARD: 5, - MULTI_DATE_DAY_CARD: 6 -}); - -BI.extend(BI.MultiDateCombo, { - DATE_TYPE: { - MULTI_DATE_YEAR_PREV: 1, - MULTI_DATE_YEAR_AFTER: 2, - MULTI_DATE_YEAR_BEGIN: 3, - MULTI_DATE_YEAR_END: 4, - MULTI_DATE_MONTH_PREV: 5, - MULTI_DATE_MONTH_AFTER: 6, - MULTI_DATE_MONTH_BEGIN: 7, - MULTI_DATE_MONTH_END: 8, - MULTI_DATE_QUARTER_PREV: 9, - MULTI_DATE_QUARTER_AFTER: 10, - MULTI_DATE_QUARTER_BEGIN: 11, - MULTI_DATE_QUARTER_END: 12, - MULTI_DATE_WEEK_PREV: 13, - MULTI_DATE_WEEK_AFTER: 14, - MULTI_DATE_DAY_PREV: 15, - MULTI_DATE_DAY_AFTER: 16, - MULTI_DATE_DAY_TODAY: 17, - MULTI_DATE_PARAM: 18, - MULTI_DATE_CALENDAR: 19, - YEAR_QUARTER: 20, - YEAR_MONTH: 21, - YEAR_WEEK: 22, - YEAR_DAY: 23, - MONTH_WEEK: 24, - MONTH_DAY: 25, - YEAR: 26, - SAME_PERIOD: 27, - LAST_SAME_PERIOD: 28 - } -}); -/** - * 普通控件 - * - * @class BI.DayCard - * @extends BI.MultiDateCard - */ -BI.DayCard = BI.inherit(BI.MultiDateCard, { - - _defaultConfig: function () { - return $.extend(BI.DayCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-daycard' - }); - }, - - _init: function () { - BI.DayCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - isEditorExist: true, - selected: true, - text: BI.i18nText("BI-Multi_Date_Day_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Day_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY, - text: BI.i18nText("BI-Multi_Date_Today") - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV - } -}); -BI.DayCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.daycard', BI.DayCard); -/** - * 普通控件 - * - * @class BI.MonthCard - * @extends BI.MultiDateCard - */ -BI.MonthCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-monthcard' - }); - }, - - _init: function () { - BI.MonthCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV, - text: BI.i18nText("BI-Multi_Date_Month_Prev") - }, - { - isEditorExist: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER, - text: BI.i18nText("BI-Multi_Date_Month_Next") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Month_Begin") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Month_End") - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV; - } -}); -BI.MonthCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.monthcard', BI.MonthCard); -/** - * 日期控件 - * @class BI.MultiDatePopup - * @extends BI.Widget - */ -BI.MultiDatePopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - tabWidth: 42, - titleHeight: 27, - itemHeight: 30, - triggerHeight: 24, - buttonWidth: 90, - buttonHeight: 25, - cardHeight: 229, - cardWidth: 270, - popupHeight: 259, - popupWidth: 270, - comboAdjustHeight: 1, - ymdWidth: 58, - lgap: 2, - border: 1 - }, - _defaultConfig: function () { - return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-popup', - width: 268, - height: 260 - }); - }, - _init: function () { - BI.MultiDatePopup.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.storeValue = ""; - this.textButton = BI.createWidget({ - type: 'bi.text_button', - forceCenter: true, - cls: 'bi-multidate-popup-label bi-border-left bi-border-right bi-border-top', - shadow: true, - text: BI.i18nText("BI-Multi_Date_Today") - }); - this.textButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE); - }); - this.clearButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: 'bi-multidate-popup-button bi-border-top', - shadow: true, - text: BI.i18nText("BI-Basic_Clear") - }); - this.clearButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE); - }); - this.okButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: 'bi-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.MultiDatePopup.BUTTON_OK_EVENT_CHANGE); - }); - this.dateTab = BI.createWidget({ - type: 'bi.tab', - tab: { - cls: "bi-multidate-popup-tab bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.MultiDateCombo.MULTI_DATE_YMD_CARD, - width: this.constants.ymdWidth - }, { - text: BI.i18nText("BI-Multi_Date_Year"), - value: BI.MultiDateCombo.MULTI_DATE_YEAR_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Quarter"), - value: BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Month"), - value: BI.MultiDateCombo.MULTI_DATE_MONTH_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Week"), - value: BI.MultiDateCombo.MULTI_DATE_WEEK_CARD - }, { - text: BI.i18nText("BI-Multi_Date_Day"), - value: BI.MultiDateCombo.MULTI_DATE_DAY_CARD - }], { - width: this.constants.tabWidth, - textAlign: "center", - height: this.constants.itemHeight, - cls: 'bi-multidate-popup-item bi-list-item-active' - }), - layouts: [{ - type: 'bi.left' - }] - }, - cardCreator: function (v) { - switch (v) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - self.ymd = BI.createWidget({ - type: "bi.date_calendar_popup", - min: self.options.min, - max: self.options.max - }); - self.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE); - }); - return self.ymd; - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - self.year = BI.createWidget({ - type: "bi.yearcard" - }); - self.year.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.year, v); - }); - return self.year; - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - self.quarter = BI.createWidget({ - type: 'bi.quartercard' - }); - self.quarter.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.quarter, v); - }); - return self.quarter; - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - self.month = BI.createWidget({ - type: 'bi.monthcard' - }); - self.month.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.month, v); - }); - return self.month; - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - self.week = BI.createWidget({ - type: 'bi.weekcard' - }); - self.week.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.week, v); - }); - return self.week; - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - self.day = BI.createWidget({ - type: 'bi.daycard' - }); - self.day.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { - self._setInnerValue(self.day, v); - }); - return self.day; - } - } - }); - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_YMD_CARD; - this.dateTab.on(BI.Tab.EVENT_CHANGE, function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - var date = this.getTab(self.cur).getCalculationValue(); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - self._setInnerValue(self.ymd); - break; - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - self.year.setValue(self.storeValue); - self._setInnerValue(self.year); - break; - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - self.quarter.setValue(self.storeValue); - self._setInnerValue(self.quarter); - break; - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - self.month.setValue(self.storeValue); - self._setInnerValue(self.month); - break; - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - self.week.setValue(self.storeValue); - self._setInnerValue(self.week); - break; - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - self.day.setValue(self.storeValue); - self._setInnerValue(self.day); - break; - } - self.cur = v; - }); - this.dateButton = BI.createWidget({ - type: "bi.grid", - items: [[this.clearButton, this.textButton, this.okButton]] - }); - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this.dateTab - }, { - el: this.dateButton, - height: 30 - }] - }); - }, - _setInnerValue: function (obj) { - if (this.dateTab.getSelect() === BI.MultiDateCombo.MULTI_DATE_YMD_CARD) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); - } else { - var date = obj.getCalculationValue(); - date = date.print("%Y-%x-%e"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - setValue: function (v) { - this.storeValue = v; - var self = this, date; - var type, value; - if (BI.isNotNull(v)) { - type = v.type || BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR; - value = v.value; - if (BI.isNull(value)) { - value = v; - } - } - switch (type) { - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD); - this.year.setValue({type: type, value: value}); - this.cur = BI.MultiDateCombo.MULTI_DATE_YEAR_CARD; - self._setInnerValue(this.year); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD; - this.quarter.setValue({type: type, value: value}); - self._setInnerValue(this.quarter); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_MONTH_CARD; - this.month.setValue({type: type, value: value}); - self._setInnerValue(this.month); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_WEEK_CARD; - this.week.setValue({type: type, value: value}); - self._setInnerValue(this.week); - break; - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: - case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD); - this.cur = BI.MultiDateCombo.MULTI_DATE_DAY_CARD; - this.day.setValue({type: type, value: value}); - self._setInnerValue(this.day); - break; - default: - if (BI.isNull(value) || BI.isEmptyObject(value)) { - var date = new Date(); - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth(), - day: date.getDate() - }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } else { - this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); - this.ymd.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } - this.textButton.setEnable(true); - break; - } - }, - getValue: function () { - var tab = this.dateTab.getSelect(); - switch (tab) { - case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: - return this.ymd.getValue(); - case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: - return this.year.getValue(); - case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: - return this.quarter.getValue(); - case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: - return this.month.getValue(); - case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: - return this.week.getValue(); - case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: - return this.day.getValue(); - } - } -}); -BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.MultiDatePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; -BI.shortcut('bi.multidate_popup', BI.MultiDatePopup); -/** - * 普通控件 - * - * @class BI.QuarterCard - * @extends BI.MultiDateCard - */ -BI.QuarterCard = BI.inherit(BI.MultiDateCard, { - - _defaultConfig: function () { - return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-quartercard' - }); - }, - - _init: function () { - BI.QuarterCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Quarter_Prev") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Quarter_Next") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Quarter_Begin") - }, - { - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END, - isEditorExist: false, - text: BI.i18nText("BI-Multi_Date_Quarter_End") - }] - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV; - } -}); -BI.QuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.quartercard', BI.QuarterCard); -/** - * 普通控件 - * - * @class BI.MultiDateSegment - * @extends BI.Single - */ -BI.MultiDateSegment = BI.inherit(BI.Single, { - constants: { - itemHeight: 24, - maxGap: 15, - minGap: 10, - textWidth: 30, - defaultEditorValue: "1" - }, - - _defaultConfig: function () { - return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-segment', - text: "", - width: 130, - height: 30, - isEditorExist: true, - selected: false, - defaultEditorValue: "1" - }); - }, - - _init: function () { - BI.MultiDateSegment.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.radio = BI.createWidget({ - type: "bi.radio", - selected: opts.selected - }); - this.radio.on(BI.Controller.EVENT_CHANGE, function (v) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textEditor = BI.createWidget({ - type: 'bi.text_editor', - value: this.constants.defaultEditorValue, - title: function () { - return self.textEditor.getValue(); - }, - tipType: "success", - cls: 'bi-multidate-editor', - width: this.constants.textWidth, - height: this.constants.itemHeight - }); - this.textEditor.on(BI.Controller.EVENT_CHANGE, function (v) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - cls: 'bi-multidate-normal-label', - text: opts.text, - height: this.constants.itemHeight - }); - this._createSegment(); - }, - _createSegment: function () { - if (this.options.isEditorExist === true) { - return BI.createWidget({ - element: this, - type: 'bi.left', - items: [{ - el: { - type: "bi.center_adapt", - items: [this.radio], - height: this.constants.itemHeight - }, - lgap: 0 - }, - { - el: { - type: "bi.center_adapt", - items: [this.textEditor], - widgetName: 'textEditor' - }, - lgap: this.constants.maxGap - }, - { - el: this.text, - lgap: this.constants.minGap - }] - }); - } - return BI.createWidget({ - element: this, - type: 'bi.left', - items: [{ - el: { - type: "bi.center_adapt", - items: [this.radio], - height: this.constants.itemHeight - }, - lgap: 0 - }, - { - el: this.text, - lgap: this.constants.maxGap - }] - }) - }, - setSelected: function (v) { - if (BI.isNotNull(this.radio)) { - this.radio.setSelected(v); - this.textEditor.setEnable(v); - } - }, - isSelected: function () { - return this.radio.isSelected(); - }, - getValue: function () { - return this.options.value; - }, - getInputValue: function () { - return this.textEditor.getValue() | 0; - }, - setInputValue: function (v) { - this.textEditor.setValue(v); - }, - isEditorExist: function () { - return this.options.isEditorExist; - } -}); -BI.MultiDateSegment.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multidate_segment', BI.MultiDateSegment);/** - * 普通控件 - * - * @class BI.WeekCard - * @extends BI.MultiDateCard - */ -BI.WeekCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-weekcard' - }); - }, - - _init: function () { - BI.WeekCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Week_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Week_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER - }]; - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV; - } -}); -BI.WeekCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.weekcard', BI.WeekCard); -/** - * 普通控件 - * - * @class BI.YearCard - * @extends BI.MultiDateCard - */ -BI.YearCard = BI.inherit(BI.MultiDateCard, { - _defaultConfig: function () { - return $.extend(BI.YearCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multidate-yearcard' - }); - }, - - _init: function () { - BI.YearCard.superclass._init.apply(this, arguments); - }, - - dateConfig: function () { - return [{ - selected: true, - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Year_Prev"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV - }, - { - isEditorExist: true, - text: BI.i18nText("BI-Multi_Date_Year_Next"), - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN, - text: BI.i18nText("BI-Multi_Date_Year_Begin") - }, - { - isEditorExist: false, - value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END, - text: BI.i18nText("BI-Multi_Date_Year_End") - }] - }, - - defaultSelectedItem: function () { - return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV; - } -}); -BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.yearcard', BI.YearCard); -/** - * @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: 30, - text: "", - items: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_select_tree_popup", - isDefaultInit: o.isDefaultInit, - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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 - }) - }, - - _init: function () { - BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_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", - element: this, - 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, - - 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); - } - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - 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.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: [] - }); - }, - - _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, - itemsCreator: o.itemsCreator - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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: 25 - }) - }, - _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 items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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/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: 30, - text: "", - itemsCreator: BI.emptyFn, - items: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_single_tree_popup", - isDefaultInit: o.isDefaultInit, - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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 - }) - }, - - _init: function () { - BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_single_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_single_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_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", - element: this, - expander: { - isDefaultInit: o.isDefaultInit, - el: {}, - popup: { - type: "bi.custom_tree" - } - }, - - items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (items) { - callback(BI.Tree.transformToTreeFormat(items), 0) - }) - }, - - el: { - type: "bi.button_tree", - chooseType: BI.Selection.Single, - 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); - } - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - 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.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 - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - 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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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 - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -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: 25 - }) - }, - _init: function () { - BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = 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 - }); - this.node.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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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); - } - } -}); - -BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** - * - * 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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25 - }) - }, - _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 - }); - 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", - cls: "base-line-conn-background", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - 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.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: 25, - lgap: 10, - tgap: 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 = {}; - 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.left', - cls: 'multi-select-continue-select', - items: [ - { - el: { - type: "bi.label", - text: BI.i18nText('BI-Selected_Data') - }, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }, - { - el: this.continueSelect, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }] - } - }, { - height: 'fill', - el: this.display - }] - }); - }, - - 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: 25, - 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 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: 28 - }); - }, - - _init: function () { - BI.MultiSelectCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = {}; - //标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - // adapter: this.popup, - masker: { - offset: { - left: 1, - top: 1, - right: 2, - bottom: 33 - } - }, - 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); - }); - } - }); - - 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 () { - //如果在不选的状态下直接把该值添加进来 - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - 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, - 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(); - }); - } - }, - 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 bi-border-left" - }); - 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.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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.pluck(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.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); - 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.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: 0, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** - * 多选加载数据面板 - * 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.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) && !self.storeValue.value.contains(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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - 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.MultiSelectLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - height: 25, - selected: this.isAllSelected() - }) - }, - - _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) { - 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.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** - * 带加载的多选下拉面板 - * @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 - }); - - 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 - }); - - 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.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, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - popup: {}, - adapter: o.adapter, - masker: o.masker - }); - 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 - }); - 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: 30 - }] - }); - - 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.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { - 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);/** - * 多选加载数据搜索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.button_group = BI.createWidget({ - type: "bi.select_list", - element: this, - logic: { - dynamic: false - }, - 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: 25, - selected: this.isAllSelected() - }) - }, - - 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.matched.concat(search.finded); - } - 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: 25, - 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()); - }]); - } - }); - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-select-check-selected-button bi-high-light', - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); - var self = this; - this.numberCounter = BI.createWidget({ - type: 'bi.text_button', - element: this, - hgap: 4, - text: "0", - textAlign: 'center', - textHeight: 15 - }); - 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(self._const.checkSelected); - }, function () { - self.numberCounter.setText(self.numberCounter.getTag()); - }); - this.setVisible(false); - }, - - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _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 - }); - - 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); - }, - - getValue: function () { - var v = this.editor.getState(); - if (BI.isArray(v) && v.length > 0) { - return v[v.length - 1]; - } else { - 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.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: {} - }); - }, - - _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 - }); - - 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) { - op.keyword = self.editor.getValue(); - this.setKeyword(op.keyword); - o.itemsCreator(op, callback); - } - }, 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); - }); - }, - - 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 (BI.size(ob.assist) === 1) { - this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); - } - } else { - if (BI.size(ob.value) === 1) { - this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); - } - } - }, - - 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 - }); - 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(); - } - }, 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.MultiSelectList = BI.inherit(BI.Widget, { - _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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](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.keyword = self.trigger.getKeyword(); - this.setKeyword(op.keyword); - 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 () { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword) - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }) - } else { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword) - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self.adapter.populate(); - if (self.storeValue.type === BI.Selection.Multi) { - 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: 30 - }, { - 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.MultiSelectList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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, - keyword: self.trigger.getKeyword() - }, function (ob) { - var items = BI.pluck(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: 0, - 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.Widget, { - _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: 30 - }, { - 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); - }, - - 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); - } - }); - - 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: 1, - left: 1, - right: 2, - bottom: 33 - } - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, - height: 25 - }); - }, - - _init: function () { - BI.MultiTreeCombo.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - var isInit = false; - var want2showCounter = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - // adapter: this.popup, - masker: { - offset: this.constants.offset - }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } - } - - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - 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() ? {1: 1} : {} - }; - 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(); - }); - } - }, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.storeValue = {value: {}}; - 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 val = { - type: BI.Selection.Multi, - value: this.getSearcher().hasChecked() ? {1: 1} : {} - }; - this.getSearcher().setState(val); - 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 bi-border-left" - }); - 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 - }); - - 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); - } - }); - - 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, { - - _const: { - checkSelected: BI.i18nText('BI-Check_Selected') - }, - - _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', - width: 15, - height: 15, - stopPropagation: true - }); - - this.checkSelected = BI.createWidget({ - type: 'bi.text_button', - cls: "trigger-check-selected", - invisible: true, - hgap: 4, - text: this._const.checkSelected, - 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, - 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); - } - }, 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); - }); - }, - - 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) { - ob || (ob = {}); - ob.value || (ob.value = []); - if (ob.type === BI.Selection.All) { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); - } else { - this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); - } - }, - - 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", - validationChecker: function () { - return true; - }, - valueFormatter: function (v) { - return v; - }, - value: 0, - 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, - value: o.valueFormatter(o.value), - validationChecker: o.validationChecker, - errorText: o.errorText - }); - this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { - o.value = this.getValue(); - self.fireEvent(BI.NumberEditor.EVENT_CHANGE); - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" - }); - 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,", - cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" - }); - 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", - 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 - }] - }); - }, - - //微调 - _finetuning: function (add) { - var v = BI.parseFloat(this.getValue()); - this.setValue(v.add(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: 30, - rows: 1, - numberErrorCls: "number-error", - border: 1, - less: 0, - less_equal: 1, - numTip: "" - }, - _defaultConfig: function () { - var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments) - return BI.extend(conf, { - extraCls: "bi-number-interval", - height: 25, - validation: "valid" - }) - }, - _init: function () { - var self = this, c = this.constants, o = this.options; - BI.NumberInterval.superclass._init.apply(this, arguments) - this.smallEditor = BI.createWidget({ - type: "bi.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.min, - level: "warning", - tipType: "warning", - 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-top bi-border-bottom bi-border-left" - }); - - 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.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.max, - level: "warning", - tipType: "warning", - 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-top bi-border-bottom bi-border-right" - }); - - 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", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconClass: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconClass: "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", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconClass: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconClass: "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 * 2 - }] - - }); - this.right = BI.createWidget({ - type: "bi.htape", - items: [{ - el: self.bigCombo, - width: c.width - c.border * 2 - }, { - el: self.bigEditor - }] - }); - - - 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); - }, - - _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; - } else { - if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - } else { - 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; - } else { - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - } - } else { - 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; - } else { - 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: "center" - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "center" - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - 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: "center" - }); - 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: "center" - }); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - 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: "center" - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "center" - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "center" - }); - break; - default : - break; - } - self.fireEvent(BI.NumberInterval.EVENT_CHANGE); - }); - }, - - _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_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); - } - }, - - - 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; - } -}); -BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; -BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.shortcut("bi.number_interval", BI.NumberInterval);/** - * - * 表格 - * - * Created by GUY on 2015/9/22. - * @class BI.PageTableCell - * @extends BI.Single - */ -BI.PageTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table-cell", - text: "", - title: "" - }) - }, - - _init: function () { - BI.PageTableCell.superclass._init.apply(this, arguments); - var label = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "nowrap", - height: this.options.height, - text: this.options.text, - title: this.options.title, - value: this.options.value, - lgap: 5, - rgap: 5 - }); - - if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { - this.element.css(this.options.styles); - } - } -}); - -BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** - * 分页表格 - * - * Created by GUY on 2016/2/15. - * @class BI.PageTable - * @extends BI.Widget - */ -BI.PageTable = BI.inherit(BI.Widget, { - - _const: { - scrollWidth: 18, - minScrollWidth: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table", - el: { - type: "bi.sequence_table" - }, - pager: { - 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 - } - }, - - itemsCreator: BI.emptyFn, - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.PageTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.hCurr = 1; - this.vCurr = 1; - - this.table = BI.createWidget(o.el, { - type: "bi.sequence_table", - width: o.width, - height: o.height && o.height - 30, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.pager = BI.createWidget(o.pager, { - type: "bi.direction_pager", - height: 30 - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - var vpage = this.getVPage && this.getVPage(); - if (BI.isNull(vpage)) { - vpage = this.getCurrentPage(); - } - var hpage = this.getHPage && this.getHPage(); - o.itemsCreator({ - vpage: vpage, - hpage: hpage - }, function (items, header, crossItems, crossHeader) { - self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); - self.table.setHPage && self.table.setHPage(hpage); - self.populate.apply(self, arguments); - }); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.table, - left: 0, - top: 0 - }, { - el: this.pager, - left: 0, - right: 0, - bottom: 0 - }] - }) - }, - - setHPage: function (v) { - this.hCurr = v; - this.pager.setHPage && this.pager.setHPage(v); - this.table.setHPage && this.table.setHPage(v); - }, - - setVPage: function (v) { - this.vCurr = v; - this.pager.setVPage && this.pager.setVPage(v); - this.table.setVPage && this.table.setVPage(v); - }, - - getHPage: function () { - var hpage = this.pager.getHPage && this.pager.getHPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - return this.hpage; - }, - - getVPage: function () { - var vpage = this.pager.getVPage && this.pager.getVPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - return this.vpage; - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - var showPager = false; - if (this.pager.alwaysShowPager) { - showPager = true; - } else if (this.pager.hasHNext && this.pager.hasHNext()) { - showPager = true; - } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { - showPager = true; - } else if (this.pager.hasVNext && this.pager.hasVNext()) { - showPager = true; - } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { - showPager = true; - } else if (this.pager.hasNext && this.pager.hasNext()) { - showPager = true; - } else if (this.pager.hasPrev && this.pager.hasPrev()) { - showPager = true; - } - this.table.setHeight(height - (showPager ? 30 : 0)); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - restore: function () { - this.table.restore(); - }, - - attr: function () { - BI.PageTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function () { - this.pager.populate(); - this.table.populate.apply(this.table, arguments); - }, - - destroy: function () { - this.table.destroy(); - this.pager && this.pager.destroy(); - BI.PageTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.page_table', BI.PageTable);/** - * 路径选择 - * - * Created by GUY on 2015/12/4. - * @class BI.PathChooser - * @extends BI.Widget - */ -BI.PathChooser = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#d4dadd", - selectLineColor: "#3f8ce8" - }, - - _defaultConfig: function () { - return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-path-chooser", - items: [] - }) - }, - - _init: function () { - BI.PathChooser.superclass._init.apply(this, arguments); - this.populate(this.options.items); - }, - - _createRegions: function (regions) { - var self = this; - this.regions = BI.createWidgets(BI.map(regions, function (i, region) { - return { - type: "bi.path_region", - title: self.texts[region] || region - } - })); - this.regionMap = {}; - BI.each(regions, function (i, region) { - self.regionMap[region] = i; - }); - this.container = BI.createWidget({ - type: "bi.horizontal", - verticalAlign: "top", - scrollx: false, - scrolly: false, - hgap: 10, - items: this.regions - }); - BI.createWidget({ - type: "bi.vertical_adapt", - element: this, - scrollable: true, - hgap: 10, - items: [this.container] - }); - }, - - getRegionIndexById: function (id) { - var node = this.store[id]; - var regionType = node.get("region"); - return this.regionMap[regionType]; - }, - - _drawPath: function (start, offset, index) { - var self = this; - var starts = []; - if (BI.contains(this.start, start)) { - starts = this.start; - } else { - starts = [start]; - } - - BI.each(starts, function (i, s) { - BI.each(self.radios[s], function (i, rad) { - rad.setSelected(false); - }); - BI.each(self.lines[s], function (i, line) { - line.attr("stroke", self._const.lineColor); - }); - BI.each(self.regionIndexes[s], function (i, idx) { - self.regions[idx].reset(); - }); - }); - - BI.each(this.routes[start][index], function (i, id) { - var regionIndex = self.getRegionIndexById(id); - self.regions[regionIndex].setSelect(offset + index, id); - }); - var current = BI.last(this.routes[start][index]); - - while (current && this.routes[current] && this.routes[current].length === 1) { - BI.each(this.routes[current][0], function (i, id) { - var regionIndex = self.getRegionIndexById(id); - self.regions[regionIndex].setSelect(0, id); - }); - this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); - current = BI.last(this.routes[current][0]); - } - this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); - this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); - }, - - _drawRadio: function (start, offset, index, x, y) { - var self = this; - var radio = BI.createWidget({ - type: "bi.radio", - cls: "path-chooser-radio", - selected: offset + index === 0, - start: start, - index: index - }); - radio.on(BI.Radio.EVENT_CHANGE, function () { - self._drawPath(start, offset, index); - self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); - }); - if (!this.radios[start]) { - this.radios[start] = []; - } - this.radios[start].push(radio); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [{ - el: radio, - left: x - 6.5, - top: y - 6.5 - }] - }) - }, - - _drawLine: function (start, lines) { - var self = this; - if (!this.lines[start]) { - this.lines[start] = []; - } - if (!this.pathes[start]) { - this.pathes[start] = []; - } - var startRegionIndex = this.getRegionIndexById(start); - //start所在的位置,然后接着往下画其他的路径 - var offset = this.regions[startRegionIndex].getIndexByValue(start); - BI.each(lines, function (i, line) { - self.pathes[start][i] = []; - var idx = i + offset; - var path = ""; - var stop = 47.5 + 29 * idx; - var sleft = 50 + 100 * startRegionIndex; - var radioStartX = sleft, radioStartY = stop; - var etop = stop; - var endRegionIndex = self.getRegionIndexById(BI.last(line)); - var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); - var eleft = 50 + 100 * endRegionIndex; - if (BI.contains(self.start, start)) { - radioStartX = sleft - 50; - path += "M" + (sleft - 50) + "," + stop; - self.pathes[start][i].push({ - x: sleft - 50, - y: stop - }) - } else if (idx === 0) { - radioStartX = sleft + 50; - path += "M" + sleft + "," + stop; - self.pathes[start][i].push({ - x: sleft, - y: stop - }) - } else { - radioStartX = sleft + 50; - path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; - self.pathes[start][i].push({ - x: sleft, - y: 47.5 - }); - self.pathes[start][i].push({ - x: sleft + 50, - y: 47.5 - }); - self.pathes[start][i].push({ - x: sleft + 50, - y: stop - }); - } - if (idx > 0) { - var endY = endOffset * 29 + 47.5; - path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; - self.pathes[start][i].push({ - x: eleft - 50, - y: etop - }); - self.pathes[start][i].push({ - x: eleft - 50, - y: endY - }); - self.pathes[start][i].push({ - x: eleft, - y: endY - }); - } else { - path += "L" + eleft + "," + etop; - self.pathes[start][i].push({ - x: eleft, - y: etop - }); - } - - var graph = self.svg.path(path) - .attr({ - stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, - 'stroke-dasharray': '-' - }); - self.lines[start].push(graph); - if (lines.length > 1) { - self.lines[start][0].toFront(); - } - //第一个元素无论有多少个都要显示radio - if (BI.contains(self.start, start)) { - self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); - } - if (lines.length > 1 || BI.contains(self.start, start)) { - self._drawRadio(start, offset, i, radioStartX, radioStartY); - } - }); - }, - - _drawLines: function (routes) { - var self = this; - this.lines = {}; - this.pathes = {}; - this.radios = {}; - this.regionIndexes = {}; - BI.each(routes, function (k, route) { - if (!self.regionIndexes[k]) { - self.regionIndexes[k] = []; - } - BI.each(route, function (i, rs) { - BI.each(rs, function (j, id) { - var regionIndex = self.getRegionIndexById(id); - if (!BI.contains(self.regionIndexes[k], regionIndex)) { - self.regionIndexes[k].push(regionIndex); - } - }); - }) - }); - BI.each(routes, function (k, route) { - self._drawLine(k, route); - }); - }, - - _pushNodes: function (nodes) { - var self = this; - var indexes = []; - for (var i = 0; i < nodes.length; i++) { - var id = nodes[i]; - var index = self.getRegionIndexById(id); - indexes.push(index); - var region = self.regions[index]; - if (i === nodes.length - 1) { - if (!region.hasItem(id)) { - region.addItem(id, self.texts[id]); - } - break; - } - if (i > 0 || BI.contains(self.start, id)) { - region.addItem(id, self.texts[id]); - } - } - for (var i = BI.first(indexes); i < BI.last(indexes); i++) { - if (!BI.contains(indexes, i)) { - self.regions[i].addItem(""); - } - } - }, - - _createNodes: function () { - var self = this, o = this.options; - this.store = {}; - this.texts = {}; - this.start = []; - this.end = []; - BI.each(o.items, function (i, item) { - self.start.push(BI.first(item).value); - self.end.push(BI.last(item).value); - }); - this.start = BI.uniq(this.start); - this.end = BI.uniq(this.end); - var regions = []; - var tree = new BI.Tree(); - var branches = {}, max = 0; - BI.each(o.items, function (i, items) { - BI.each(items, function (j, item) { - if (!BI.has(branches, item.value)) { - branches[item.value] = 0; - } - branches[item.value]++; - max = Math.max(max, branches[item.value]); - var prev = {}; - if (j > 0) { - prev = items[j - 1]; - } - var parent = self.store[prev.value || ""]; - var node = self.store[item.value] || new BI.Node(item.value); - node.set(item); - self.store[item.value] = node; - self.texts[item.value] = item.text; - self.texts[item.region] = item.regionText; - parent = BI.isNull(parent) ? tree.getRoot() : parent; - if (parent.getChildIndex(item.value) === -1) { - tree.addNode(parent, node); - } - }) - }); - - //算出区域列表 - tree.traverse(function (node) { - BI.each(node.getChildren(), function (i, child) { - if (BI.contains(regions, child.get("region"))) { - var index1 = BI.indexOf(regions, node.get("region")); - var index2 = BI.indexOf(regions, child.get("region")); - //交换区域 - if (index1 > index2) { - var t = regions[index2]; - for (var j = index2; j < index1; j++) { - regions[j] = regions[j + 1]; - } - regions[index1] = t; - } - } else { - regions.push(child.get("region")); - } - }); - }); - this._createRegions(regions); - - //算出节点 - BI.each(branches, function (k, branch) { - if (branch < max) { - delete branches[k]; - } - }); - - //过滤节点 - var nodes = []; - var n = tree.getRoot(); - while (n && n.getChildrenLength() === 1) { - if (BI.has(branches, n.getChildren()[0].id)) { - delete branches[n.getChildren()[0].id]; - n = n.getChildren()[0]; - } else { - n = null; - } - } - tree.traverse(function (node) { - if (BI.has(branches, node.id)) { - nodes.push(node.id); - delete branches[node.id]; - } - }); - - //填充节点 - var routes = {}; - var s, e; - for (var i = 0, len = nodes.length; i < len + 1; i++) { - if (len === 0) { - s = []; - BI.each(this.start, function (i, id) { - s.push(tree.search(id)); - }); - e = []; - BI.each(this.end, function (i, id) { - e.push(tree.search(id)); - }); - } else if (i === len) { - s = e; - e = []; - BI.each(this.end, function (i, id) { - e.push(tree.search(id)); - }); - } else if (i === 0) { - s = []; - BI.each(this.start, function (i, id) { - s.push(tree.search(id)); - }); - e = [tree.search(nodes[i])]; - } else { - s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; - e = [tree.search(s[0], nodes[i])]; - } - BI.each(s, function (i, n) { - tree._recursion(n, [n.id], function (node, route) { - if (BI.contains(e, node)) { - if (!routes[n.id]) { - routes[n.id] = []; - } - routes[n.id].push(route); - self._pushNodes(route); - if (e.length <= 1) { - return true; - } - } - }) - }); - } - this.routes = routes; - this._drawLines(routes); - }, - - _unselectAllPath: function () { - var self = this; - BI.each(this.radios, function (idx, rad) { - BI.each(rad, function (i, r) { - r.setSelected(false); - }); - }); - BI.each(this.lines, function (idx, line) { - BI.each(line, function (i, li) { - li.attr("stroke", self._const.lineColor); - }); - }); - BI.each(this.regions, function (idx, region) { - region.reset(); - }); - }, - - populate: function (items) { - this.options.items = items || []; - var self = this; - this.empty(); - if (this.options.items.length <= 0) { - return; - } - this.svg = BI.createWidget({ - type: "bi.svg" - }); - this._createNodes(); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: [{ - el: this.svg, - top: 0, - left: 0, - right: 0, - bottom: 0 - }] - }); - }, - - setValue: function (v) { - this._unselectAllPath(); - var nodes = BI.keys(this.routes), self = this; - var result = [], array = []; - BI.each(v, function (i, val) { - if (BI.contains(nodes, val)) { - if (array.length > 0) { - array.push(val); - result.push(array); - array = []; - } - } - array.push(val); - }); - if (array.length > 0) { - result.push(array); - } - //画这n条路径 - BI.each(result, function (idx, path) { - var start = path[0]; - var index = BI.findIndex(self.routes[start], function (idx, p) { - if (BI.isEqual(path, p)) { - return true; - } - }); - if (index >= 0) { - var startRegionIndex = self.getRegionIndexById(start); - var offset = self.regions[startRegionIndex].getIndexByValue(start); - self._drawPath(start, offset, index); - } - }); - }, - - getValue: function () { - var path = []; - BI.each(this.regions, function (i, region) { - var val = region.getValue(); - if (BI.isKey(val)) { - path.push(val); - } - }); - return path; - } -}); -BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; -BI.shortcut("bi.path_chooser", BI.PathChooser);/** - * 路径选择区域 - * - * Created by GUY on 2015/12/4. - * @class BI.PathRegion - * @extends BI.Widget - */ -BI.PathRegion = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-path-region bi-background", - width: 80, - title: "" - }) - }, - - _init: function () { - BI.PathRegion.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.zIndex = 100; - var title = BI.createWidget({ - type: "bi.label", - text: o.title, - title: o.title, - height: 30 - }); - title.element.css("zIndex", this.zIndex--); - this.items = []; - this.vertical = BI.createWidget({ - type: "bi.vertical", - element: this, - bgap: 5, - hgap: 10, - items: [title] - }) - }, - - hasItem: function (val) { - return BI.any(this.items, function (i, item) { - return val === item.getValue(); - }); - }, - - addItem: function (value, text) { - if (BI.isKey(value)) { - var label = BI.createWidget({ - type: "bi.label", - cls: "path-region-label bi-card bi-border bi-list-item-select", - text: text, - value: value, - title: text || value, - height: 24 - }); - } else { - var label = BI.createWidget({ - type: "bi.layout", - height: 24 - }); - } - label.element.css("zIndex", this.zIndex--); - this.items.push(label); - this.vertical.addItem(label); - if (this.items.length === 1) { - this.setSelect(0, value); - } - }, - - reset: function () { - BI.each(this.items, function (i, item) { - item.element.removeClass("active"); - }); - }, - - setSelect: function (index, value) { - this.reset(); - if (this.items.length <= 0) { - return; - } - if (this.items.length === 1) { - this.items[0].element.addClass("active"); - return; - } - if (this.items[index].attr("value") === value) { - this.items[index].element.addClass("active"); - } - }, - - setValue: function (value) { - this.setSelect(this.getIndexByValue(value), value); - }, - - getValueByIndex: function (idx) { - return this.items[idx].attr("value"); - }, - - getIndexByValue: function (value) { - return BI.findIndex(this.items, function (i, item) { - return item.attr("value") === value; - }); - }, - - getValue: function () { - var res; - BI.any(this.items, function (i, item) { - if (item.element.hasClass("active")) { - res = item.getValue(); - return true; - } - }); - return res; - } -}); -BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; -BI.shortcut("bi.path_region", BI.PathRegion);/** - * 预览表列 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableCell - * @extends BI.Widget - */ -BI.PreviewTableCell = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-cell", - text: "" - }); - }, - - _init: function () { - BI.PreviewTableCell.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value - }) - } -}); -BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableHeaderCell - * @extends BI.Widget - */ -BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-header-cell", - text: "" - }); - }, - - _init: function () { - BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value - }) - } -}); -BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTable - * @extends BI.Widget - */ -BI.PreviewTable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table", - isNeedFreeze: false, - freezeCols: [], - rowSize: null, - columnSize: [], - headerRowSize: 30, - header: [], - items: [] - }); - }, - - _init: function () { - BI.PreviewTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - isNeedResize: false, - - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - rowSize: o.rowSize, - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, - - header: BI.map(o.header, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_header_cell" - }, item); - }); - }), - items: BI.map(o.items, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_cell" - }, item); - }); - }) - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self._adjustColumns(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._adjustColumns(); - }); - }, - - //是否有自适应调节的列,即列宽为"" - _hasAdaptCol: function (columnSize) { - return BI.any(columnSize, function (i, size) { - return size === ""; - }) - }, - - _isPercentage: function (columnSize) { - return columnSize[0] <= 1; - }, - - _adjustColumns: function () { - var self = this, o = this.options; - if (o.isNeedFreeze === true) { - //如果存在百分比的情况 - if (this._isPercentage(o.columnSize)) { - if (this._hasAdaptCol(o.columnSize)) { - var findCols = [], remain = 0; - BI.each(o.columnSize, function (i, size) { - if (size === "") { - findCols.push(i); - } else { - remain += size; - } - }); - remain = 1 - remain; - var average = remain / findCols.length; - BI.each(findCols, function (i, col) { - o.columnSize[col] = average; - }); - } - var isRight = BI.first(o.freezeCols) !== 0; - var freezeSize = [], notFreezeSize = []; - BI.each(o.columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - freezeSize.push(size); - } else { - notFreezeSize.push(size); - } - }); - var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); - BI.each(freezeSize, function (i, size) { - freezeSize[i] = size / sumFreezeSize; - }); - BI.each(notFreezeSize, function (i, size) { - notFreezeSize[i] = size / sumNotFreezeSize; - }); - this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); - this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); - } - } else { - //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% - if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { - this.table.setRegionColumnSize(["100%"]); - } - } - }, - - setColumnSize: function (columnSize) { - return this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); - }, - - setHeaderColumnSize: function (columnSize) { - return this.table.setHeaderColumnSize(columnSize); - }, - - setRegionColumnSize: function (columnSize) { - return this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize() - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize() - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - return this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - return this.table.setLeftHorizontalScroll(scrollLeft) - }, - - setRightHorizontalScroll: function (scrollLeft) { - return this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - getColumns: function () { - return this.table.getColumns(); - }, - - populate: function (items, header) { - this.table.populate(items, header); - } -}); -BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; -BI.shortcut('bi.preview_table', BI.PreviewTable);/** - * 季度下拉框 - * - * 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" - }); - - 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 - }); - - 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", - 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 () { - 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: Date._QN[01], - value: 1 - }, { - text: Date._QN[2], - value: 2 - }, { - text: Date._QN[3], - value: 3 - }, { - text: 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" - }] - }); - - 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, - triggerWidth: 30, - textWidth: 40, - errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-quarter-trigger bi-border", - height: 25 - }); - }, - _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: c.errorText - }); - 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: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - - 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);/** - * 关联视图字段Item - * - * Created by GUY on 2015/12/23. - * @class BI.RelationViewItem - * @extends BI.Widget - */ -BI.RelationViewItem = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-item bi-list-item-active", - height: 25, - hoverIn: BI.emptyFn, - hoverOut: BI.emptyFn - }); - }, - - _init: function () { - BI.RelationViewItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.element.hover(o.hoverIn, o.hoverOut); - var items = []; - if (o.isPrimary) { - items.push({ - type: "bi.icon", - width: 16, - height: 16, - title: BI.i18nText("BI-Primary_Key") - }); - } - items.push({ - type: "bi.label", - text: o.text, - value: o.value, - height: o.height, - textAlign: "left", - width: o.isPrimary ? 70 : 90, - lgap: o.isPrimary ? 0 : 10 - }); - BI.createWidget({ - type: "bi.vertical_adapt", - element: this, - items: items, - cls: "primary-key-font", - lgap: 5 - }); - }, - - enableHover: function (opt) { - BI.RelationViewRegion.superclass.enableHover.apply(this, [{ - container: "body" - }]); - }, - - setSelected: function (b) { - this.element[b ? "addClass" : "removeClass"]("active"); - } -}); -BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** - * 关联视图 - * - * Created by GUY on 2015/12/22. - * @class BI.RelationView - * @extends BI.Widget - */ -BI.RelationView = BI.inherit(BI.Widget, { - - _const: { - lineColor: "#c4c6c6", - selectLineColor: "#009de3" - }, - - _defaultConfig: function () { - return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view", - items: [] - }); - }, - - _init: function () { - BI.RelationView.superclass._init.apply(this, arguments); - this.populate(this.options.items); - }, - - _calculateWidths: function () { - var widths = []; - BI.each(this.views, function (i, items) { - BI.each(items, function (j, obj) { - if (!widths[j]) { - widths[j] = BI.MIN; - } - widths[j] = Math.max(widths[j], obj.getWidth()); - }) - }); - return widths; - }, - - _calculateHeights: function () { - var heights = BI.makeArray(BI.size(this.views), BI.MIN); - BI.each(this.views, function (i, items) { - BI.each(items, function (j, obj) { - heights[i] = Math.max(heights[i], obj.getHeight()); - }) - }); - return heights; - }, - - _hoverIn: function (target) { - var self = this, c = this._const; - BI.each(this.relations, function (start, rs) { - BI.each(rs, function (end, relation) { - if (relation[0].primary.value === target || relation[0].foreign.value === target) { - self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); - self.storeViews[start].setValue(relation[0].primary.value); - self.storeViews[end].setValue(relation[0].foreign.value); - } - }); - }); - }, - - _hoverOut: function (target) { - var self = this, c = this._const; - BI.each(this.relations, function (start, rs) { - BI.each(rs, function (end, relation) { - if (relation[0].primary.value === target || relation[0].foreign.value === target) { - self.lines[start][end].attr("stroke", c.lineColor); - self.storeViews[start].setValue([]); - self.storeViews[end].setValue([]); - } - }); - }); - }, - - previewRelationTables: function(relationTables, show) { - if (!show) { - BI.each(this.storeViews, function (i, view) { - view.toggleRegion(true); - view.setPreviewSelected(false); - }); - BI.each(this.lines, function (i, lines) { - BI.each(lines, function (j, line) { - line.show(); - }); - }); - return; - } - BI.each(this.storeViews, function (id, view) { - if (!relationTables.contains(id)) { - view.toggleRegion(false); - } else { - view.setPreviewSelected(true); - } - }); - BI.each(this.lines, function (id, lines) { - BI.each(lines, function (cId, line) { - if (!relationTables.contains(id) || !relationTables.contains(cId)) { - line.hide(); - } - }); - }); - }, - - populate: function (items) { - var self = this, o = this.options, c = this._const; - o.items = items || []; - this.empty(); - this.svg = BI.createWidget({ - type: "bi.svg" - }); - - //算出所有的区域和关联 - var regions = this.regions = {}, relations = this.relations = {}; - BI.each(items, function (i, item) { - var pr = item.primary.region, fr = item.foreign && item.foreign.region; - if (pr && !relations[pr]) { - relations[pr] = {}; - } - if (pr && fr && !relations[pr][fr]) { - relations[pr][fr] = []; - } - if (pr && !regions[pr]) { - regions[pr] = []; - } - if (fr && !regions[fr]) { - regions[fr] = []; - } - if (pr && !BI.deepContains(regions[pr], item.primary)) { - regions[pr].push(item.primary); - } - if (fr && !BI.deepContains(regions[fr], item.foreign)) { - regions[fr].push(item.foreign); - } - pr && fr && relations[pr][fr].push(item); - }); - //求拓扑 - var topology = []; - var rs = BI.clone(regions), store = {}; - while (!BI.isEmpty(rs)) { - var clone = BI.clone(rs); - BI.each(o.items, function (i, item) { - if (!store[item.primary.region]) { - delete clone[item.foreign && item.foreign.region]; - } - }); - topology.push(BI.keys(clone)); - BI.extend(store, clone); - BI.each(clone, function (k, v) { - delete rs[k]; - }); - } - //构建视图 - var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; - var verticals = []; - BI.each(topology, function (i, items) { - if (!views[i]) { - views[i] = {}; - } - var horizontal = []; - BI.each(items, function (j, region) { - var items = regions[region]; - views[i][j] = storeViews[region] = BI.createWidget({ - type: "bi.relation_view_region_container", - value: region, - header: items[0].regionTitle, - text: items.length > 0 ? items[0].regionText : "", - handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, - items: items, - belongPackage: items.length > 0 ? items[0].belongPackage : true - }); - if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { - views[i][j].doRedMark(items[0].keyword); - } - views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { - self._hoverIn(v); - }); - views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { - self._hoverOut(v); - }); - views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { - self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); - }); - indexes[region] = {i: i, j: j}; - horizontal.push(views[i][j]); - }); - verticals.push({ - type: "bi.horizontal", - items: horizontal - }) - }); - - //求每一行的高度 - var heights = this._calculateHeights(); - - //求每一列的宽度 - var widths = this._calculateWidths(); - - //求相对宽度和高度 - var offsetWidths = [0], offsetHeights = [0]; - BI.each(heights, function (i, h) { - if (i === 0) { - return; - } - offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; - }); - BI.each(widths, function (i, w) { - if (i === 0) { - return; - } - offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; - }); - - //画线 - var lines = this.lines = {};//缓存所有的线 - BI.each(relations, function (start, rs) { - BI.each(rs, function (end, relation) { - var startIndex = indexes[start], endIndex = indexes[end]; - var top = 0, right = 1, bottom = 2, left = 3; - var startDirection = bottom, endDirection = top; - // if (startIndex.j > endIndex.j) { - // startDirection = left; - // endDirection = right; - // } else if (startIndex.j < endIndex.j) { - // startDirection = right; - // endDirection = left; - // } else if (startIndex.i < endIndex.i) { - // startDirection = bottom; - // endDirection = top; - // } else if (startIndex.i > endIndex.i) { - // startDirection = top; - // endDirection = bottom; - // } - var draw = function (i, j, direction, isForeign) { - var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; - var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; - var path = "", position; - switch (direction) { - case top: - position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + x + "," + (y - 10); - y -= 10; - break; - case right: - position = views[i][j].getRightPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + (x + 10) + "," + y; - x += 10; - break; - case bottom: - position = views[i][j].getBottomPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + x + "," + (y + 10); - y += 10; - break; - case left: - position = views[i][j].getLeftPosition(); - x += position.x; - y += position.y; - path = "M" + x + "," + y + "L" + (x - 10) + "," + y; - x -= 10; - break; - } - return {x: x, y: y, path: path}; - }; - var path = ""; - var si = draw(startIndex.i, startIndex.j, startDirection); - var ei = draw(endIndex.i, endIndex.j, endDirection, true); - path += si.path + ei.path; - if (!lines[start]) { - lines[start] = {}; - } - path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; - var line = lines[start][end] = self.svg.path(path) - .attr({"stroke": c.lineColor, "stroke-width": "2"}) - .hover(function () { - line.attr("stroke", c.selectLineColor).toFront(); - storeViews[start].setValue(relation[0].primary.value); - storeViews[end].setValue(relation[0].foreign.value); - }, function () { - line.attr("stroke", c.lineColor); - storeViews[start].setValue([]); - storeViews[end].setValue([]); - }); - }); - }); - var container = BI.createWidget(); - BI.createWidget({ - type: "bi.vertical", - element: container, - items: verticals - }); - BI.createWidget({ - type: "bi.absolute", - element: container, - items: [{ - el: this.svg, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - - BI.createWidget({ - type: "bi.center_adapt", - scrollable: true, - element: this, - items: [container] - }); - } -}); -BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; -BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; -BI.shortcut('bi.relation_view', BI.RelationView);/** - * Created by Young's on 2017/3/10. - */ -BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-region-container", - width: 150 - }); - }, - - _init: function () { - BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.region = BI.createWidget({ - type: "bi.relation_view_region", - value: o.value, - header: o.header, - text: o.text, - handler: o.handler, - items: o.items, - belongPackage: o.belongPackage - }); - this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); - }); - this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); - }); - this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { - self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); - }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.region], - width: this.region.getWidth(), - height: this.region.getHeight() - }); - }, - - doRedMark: function () { - this.region.doRedMark.apply(this.region, arguments); - }, - - unRedMark: function () { - this.region.unRedMark.apply(this.region, arguments); - }, - - getWidth: function () { - return this.region.getWidth(); - }, - - getHeight: function () { - return this.region.getHeight(); - }, - - //获取上方开始划线的位置 - getTopLeftPosition: function () { - return this.region.getTopLeftPosition(); - }, - - getTopRightPosition: function () { - return this.region.getTopRightPosition(); - }, - - getBottomPosition: function () { - return this.region.getBottomPosition(); - }, - - getLeftPosition: function () { - return this.region.getLeftPosition(); - }, - - getRightPosition: function () { - return this.region.getRightPosition(); - }, - - setValue: function (v) { - this.region.setValue(v); - }, - - toggleRegion: function (v) { - v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); - }, - - setPreviewSelected: function(v) { - this.region.setPreviewSelected(v); - } -}); -BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; -BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; -BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; -BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** - * 关联视图 - * - * Created by GUY on 2015/12/23. - * @class BI.RelationViewRegion - * @extends BI.BasicButton - */ -BI.RelationViewRegion = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-relation-view-region cursor-pointer", - width: 150, - text: "", - value: "", - header: "", - items: [], - belongPackage: true - }); - }, - - _init: function () { - BI.RelationViewRegion.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.preview = BI.createWidget({ - type: "bi.icon_button", - cls: "relation-table-preview-font", - width: 25, - height: 25, - stopPropagation: true - }); - this.preview.on(BI.IconButton.EVENT_CHANGE, function () { - self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); - }); - - this.title = BI.createWidget({ - type: "bi.label", - height: 25, - width: 70, - text: o.text, - value: o.value, - textAlign: "left" - }); - //title放body上 - if (BI.isKey(o.header)) { - this.title.setTitle(o.header, { - container: "body" - }) - } - - this.button_group = BI.createWidget({ - type: "bi.button_group", - items: this._createItems(o.items), - layouts: [{ - type: "bi.vertical" - }] - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [{ - type: "bi.vertical", - cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), - items: [{ - type: "bi.vertical_adapt", - cls: "relation-view-region-title bi-border-bottom", - items: [this.preview, this.title] - }, this.button_group] - }], - hgap: 25, - vgap: 20 - }) - }, - - _createItems: function (items) { - var self = this; - return BI.map(items, function (i, item) { - return BI.extend(item, { - type: "bi.relation_view_item", - hoverIn: function () { - self.setValue(item.value); - self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); - }, - hoverOut: function () { - self.setValue([]); - self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); - } - }) - }); - }, - - doRedMark: function () { - this.title.doRedMark.apply(this.title, arguments); - }, - - unRedMark: function () { - this.title.unRedMark.apply(this.title, arguments); - }, - - getWidth: function () { - return this.options.width; - }, - - getHeight: function () { - return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; - }, - - //获取上方开始划线的位置 - getTopLeftPosition: function () { - return { - x: 25 + 10, - y: 20 - } - }, - - getTopRightPosition: function () { - return { - x: this.getWidth() - 25 - 10, - y: 20 - } - }, - - getBottomPosition: function () { - return { - x: 25 + 10, - y: this.getHeight() - 20 - } - }, - - getLeftPosition: function () { - return { - x: 25, - y: 20 + 10 - } - }, - - getRightPosition: function () { - return { - x: this.getWidth() - 25, - y: 20 + 10 - } - }, - - setValue: function (v) { - this.button_group.setValue(v); - }, - - setPreviewSelected: function(v) { - this.preview.setSelected(v); - } -}); -BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; -BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; -BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; -BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** - * 自适应宽度的表格 - * - * Created by GUY on 2016/2/3. - * @class BI.ResponisveTable - * @extends BI.Widget - */ -BI.ResponisveTable = BI.inherit(BI.Widget, { - - _const: { - perColumnSize: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-responsive-table", - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, - - columnSize: [], - headerRowSize: 25, - footerRowSize: 25, - rowSize: 25, - - regionColumnSize: false, - - header: [], - footer: false, - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.ResponisveTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - header: o.header, - footer: o.footer, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - //important:在冻结并自适应列宽的情况下要随时变更表头宽度 - if (o.isNeedResize === true && self._isAdaptiveColumn()) { - self._resizeHeader(); - } - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self._resizeBody(); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _initRegionSize: function () { - var o = this.options; - if (o.isNeedFreeze === true) { - var regionColumnSize = this.table.getRegionColumnSize(); - var maxWidth = this.table.element.width(); - if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { - var freezeCols = o.freezeCols; - if (freezeCols.length === 0) { - this.table.setRegionColumnSize([0, "fill"]); - } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } else { - this.table.setRegionColumnSize(["fill", 0]); - } - } - } - }, - - _getBlockSize: function () { - var o = this.options; - var columnSize = this.table.getCalculateColumnSize(); - if (o.isNeedFreeze === true) { - var columnSizeLeft = [], columnSizeRight = []; - BI.each(columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - columnSizeLeft.push(size); - } else { - columnSizeRight.push(size); - } - }); - //因为有边框,所以加上数组长度的参数调整 - var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, - sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; - return { - sumLeft: sumLeft, - sumRight: sumRight, - left: columnSizeLeft, - right: columnSizeRight - } - } - return { - size: columnSize, - sum: BI.sum(columnSize) + columnSize.length - }; - }, - - _isAdaptiveColumn: function (columnSize) { - return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); - }, - - _resizeHeader: function () { - var self = this, o = this.options; - if (o.isNeedFreeze === true) { - //若是当前处于自适应调节阶段 - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.table.setHeaderColumnSize(columnSize); - } else { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - var columnSizeLeft = block.left, columnSizeRight = block.right; - columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; - columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; - - var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); - newLeft[newLeft.length - 1] = ""; - newRight[newRight.length - 1] = ""; - this.table.setColumnSize(newLeft.concat(newRight)); - - block = self._getBlockSize(); - if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { - columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] - } - if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { - columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] - } - - self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); - } - } else { - if (!this._isAdaptiveColumn()) { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sum = block.sum; - var size = block.size; - - size[size.length - 1] += regionColumnSize[0] - sum; - - var newSize = BI.clone(size); - newSize[newSize.length - 1] = ""; - this.table.setColumnSize(newSize); - block = this._getBlockSize(); - - if (size[size.length - 1] < block.size[block.size.length - 1]) { - size[size.length - 1] = block.size[block.size.length - 1] - } - this.table.setColumnSize(size); - } - } - }, - - _resizeBody: function () { - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.setColumnSize(columnSize); - } - }, - - _adjustRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { - this.table.setRegionColumnSize([sumLeft, "fill"]); - } - this._resizeRegion(); - } - }, - - _resizeRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var maxWidth = this.table.element.width(); - if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { - var freezeCols = o.freezeCols; - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } - } - }, - - - resize: function () { - this.table.resize(); - this._resizeRegion(); - this._resizeHeader(); - }, - - setColumnSize: function (columnSize) { - this.table.setColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); - }, - - setHeaderColumnSize: function (columnSize) { - this.table.setHeaderColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - setRegionColumnSize: function (columnSize) { - this.table.setRegionColumnSize(columnSize); - this._resizeHeader(); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - getColumns: function () { - return this.table.getColumns(); - }, - - attr: function () { - BI.ResponisveTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function (items) { - var self = this, o = this.options; - this.table.populate.apply(this.table, arguments); - if (o.isNeedFreeze === true) { - BI.nextTick(function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - }); - } - } -}); -BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** - * 加号表示的组节点 - * 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: 25 - }) - }, - _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, - 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: 25, - 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: 25 - }) - }, - _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, - 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: 25, - 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: 25 - }) - }, - _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, - 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: 25, - 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);/** - * @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: [] - }); - }, - - _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 - }); - - this.popup = BI.createWidget({ - type: "bi.select_level_tree", - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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: "click", - 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(BI.extend({stopPropagation: true}, 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: [] - }); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {layer: layer}; - node.id = node.id || BI.UUID(); - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - self._formatItems(node.children); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.last_tree_leaf_item"; - break; - default : - extend.type = "bi.mid_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)), - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - 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(items); - } -}); - -BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** - * - * Created by GUY on 2016/8/10. - * @class BI.SequenceTableDynamicNumber - * @extends BI.SequenceTableTreeNumber - */ -BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-sequence-table-dynamic-number" - }); - }, - - _init: function () { - BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); - }, - - _formatNumber: function (nodes) { - var self = this, o = this.options; - var result = []; - var count = this._getStart(nodes); - - function getLeafCount(node) { - var cnt = 0; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - cnt += getLeafCount(child); - }); - if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - } -}); -BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTableListNumber - * @extends BI.Widget - */ -BI.SequenceTableListNumber = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table-list-number", - isNeedFreeze: false, - scrollTop: 0, - startSequence: 1,//开始的序号 - headerRowSize: 25, - rowSize: 25, - - sequenceHeaderCreator: null, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [], - - pageSize: 20 - }); - }, - - _init: function () { - BI.SequenceTableListNumber.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.start = o.startSequence; - this.renderedCells = []; - this.renderedKeys = []; - - this.container = BI.createWidget({ - type: "bi.absolute", - width: 60, - scrollable: false - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.vertical", - scrollable: false, - scrolly: false, - items: [this.container] - }); - - this.headerContainer = BI.createWidget({ - type: "bi.absolute", - cls: "bi-border", - width: 58, - scrollable: false - }); - - this.layout = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.headerContainer, - height: o.headerRowSize * o.header.length - 2 - }, { - el: {type: "bi.layout"}, - height: 2 - }, { - el: this.scrollContainer - }] - }); - this._populate(); - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = o.headerRowSize * o.header.length - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - this.container.setHeight(o.items.length * o.rowSize); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); - var start = Math.floor(scrollTop / o.rowSize); - var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); - var renderedCells = [], renderedKeys = []; - for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { - var index = BI.deepIndexOf(this.renderedKeys, this.start + i); - var top = i * o.rowSize; - if (index > -1) { - if (o.rowSize !== this.renderedCells[index]._height) { - this.renderedCells[index]._height = o.rowSize; - this.renderedCells[index].el.setHeight(o.rowSize); - } - if (this.renderedCells[index].top !== top) { - this.renderedCells[index].top = top; - this.renderedCells[index].el.element.css("top", top + "px"); - } - renderedCells.push(this.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - height: o.rowSize, - text: this.start + i, - styleGetter: function (index) { - return function () { - return o.sequenceCellStyleGetter(self.start + i - 1); - } - }(cnt) - })); - renderedCells.push({ - el: child, - left: 0, - top: top, - _height: o.rowSize - }); - } - renderedKeys.push(this.start + i); - } - - //已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]) - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - }, - - _populate: function () { - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - v = v < 1 ? 1 : v; - var o = this.options; - this.start = (v - 1) * o.pageSize + 1; - }, - - _restore: function () { - var o = this.options; - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - } - if (header && header !== this.options.header) { - o.header = header; - } - this._populate(); - } -}); -BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** - * 带有序号的表格 - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTable - * @extends BI.Widget - */ -BI.SequenceTable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table", - el: { - type: "bi.adaptive_table" - }, - - sequence: {}, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [], - - showSequence: false, - startSequence: 1//开始的序号 - }); - }, - - _init: function () { - BI.SequenceTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.sequence = BI.createWidget(o.sequence, { - type: "bi.sequence_table_list_number", - invisible: o.showSequence === false, - startSequence: o.startSequence, - isNeedFreeze: o.isNeedFreeze, - header: o.header, - items: o.items, - crossHeader: o.crossHeader, - crossItems: o.crossItems, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - width: 60, - height: o.height && o.height - BI.GridTableScrollbar.SIZE, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter - }); - this.table = BI.createWidget(o.el, { - type: "bi.adaptive_table", - width: o.showSequence === true ? o.width - 60 : o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { - if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { - self.sequence.setVerticalScroll(this.getVerticalScroll()); - self.sequence.populate(); - } - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.htape = BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.sequence, - left: 0, - top: 0 - }, { - el: this.table, - top: 0, - left: o.showSequence === true ? 60 : 0 - }] - }); - this._populate(); - }, - - _populate: function () { - var o = this.options; - if (o.showSequence === true) { - this.sequence.setVisible(true); - this.table.element.css("left", "60px"); - this.table.setWidth(o.width - 60); - } else { - this.sequence.setVisible(false); - this.table.element.css("left", "0px"); - this.table.setWidth(o.width); - } - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(this.options.showSequence ? width - 60 : width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - hasLeftHorizontalScroll: function () { - return this.table.hasLeftHorizontalScroll(); - }, - - hasRightHorizontalScroll: function () { - return this.table.hasRightHorizontalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - this.sequence.setVerticalScroll(scrollTop); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setVPage: function (page) { - this.sequence.setVPage && this.sequence.setVPage(page); - }, - - setHPage: function (page) { - this.sequence.setHPage && this.sequence.setHPage(page); - }, - - attr: function () { - BI.SequenceTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - this.sequence.attr.apply(this.sequence, arguments); - }, - - restore: function () { - this.table.restore(); - this.sequence.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - this.table.populate.apply(this.table, arguments); - this.sequence.populate.apply(this.sequence, arguments); - this.sequence.setVerticalScroll(this.table.getVerticalScroll()); - }, - - destroy: function () { - this.table.destroy(); - BI.SequenceTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.sequence_table', BI.SequenceTable);/** - * @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: 30, - text: "", - items: [] - }); - }, - - _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 - }, o.trigger)); - - this.popup = BI.createWidget({ - type: "bi.single_level_tree", - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - 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: [] - }); - }, - - _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, - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - 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: 30, - text: "", - items: [] - }); - }, - - _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 - }); - }, - - _checkTitle: function () { - var self = this, val = this.getValue(); - BI.any(this.options.items, function (i, item) { - if (val.contains(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);/** - * 可以单选多选切换的树 - * - * Created by GUY on 2015/12/21. - * @class BI.SwitchTree - * @extends BI.Widget - */ -BI.SwitchTree = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-switch-tree", - items: [] - }); - }, - - _init: function () { - BI.SwitchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tab = BI.createWidget({ - type: "bi.tab", - element: this, - tab: null, - defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, - cardCreator: BI.bind(this._createTree, this) - }); - }, - - _createTree: function (type) { - var self = this, o = this.options; - switch (type) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree = BI.createWidget({ - type: "bi.multilayer_single_level_tree", - isDefaultInit: true, - items: BI.deepClone(o.items) - }); - this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.levelTree; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree = BI.createWidget({ - type: "bi.simple_tree", - items: this._removeIsParent(BI.deepClone(o.items)) - }); - this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.tree; - } - }, - - _removeIsParent: function(items) { - BI.each(items, function(i, item) { - BI.isNotNull(item.isParent) && delete item.isParent; - }); - return items; - }, - - switchSelect: function () { - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.setSelect(BI.SwitchTree.SelectType.MultiSelect); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.setSelect(BI.SwitchTree.SelectType.SingleSelect); - break; - } - }, - - setSelect: function (v) { - this.tab.setSelect(v); - }, - - getSelect: function () { - return this.tab.getSelect(); - }, - - setValue: function (v) { - this.storeValue = v; - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree.setValue(v); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree.setValue(v); - break; - } - }, - - getValue: function () { - return this.tab.getValue(); - }, - - populate: function (items) { - this.options.items = items; - if (BI.isNotNull(this.levelTree)) { - this.levelTree.populate(BI.deepClone(items)); - } - if (BI.isNotNull(this.tree)) { - this.tree.populate(this._removeIsParent(BI.deepClone(items))); - } - } -}); -BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; -BI.SwitchTree.SelectType = { - SingleSelect: BI.Selection.Single, - MultiSelect: BI.Selection.Multi -}; -BI.shortcut('bi.switch_tree', BI.SwitchTree); -/** - * Created by Baron on 2015/10/19. - */ -BI.TimeInterval = BI.inherit(BI.Single, { - constants: { - height: 25, - width: 25, - lgap: 15, - offset: -15, - 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; - BI.TimeInterval.superclass._init.apply(this, arguments); - - this.left = this._createCombo(); - this.right = this._createCombo(); - 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 () { - var self = this; - var combo = BI.createWidget({ - type: 'bi.multidate_combo' - }); - combo.on(BI.MultiDateCombo.EVENT_ERROR, function () { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - }); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.left.hidePopupView(); - self.right.hidePopupView(); - }); - //combo.on(BI.MultiDateCombo.EVENT_CHANGE, 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.TimeInterval.EVENT_ERROR); - // } else { - // self._clearTitle(); - // self.element.removeClass(self.constants.timeErrorCls); - // } - //}); - - combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); - }else{ - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_CHANGE); - } - }); - return combo; - }, - _dateCheck: function (date) { - return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; - }, - _checkVoid: function (obj) { - return !Date.checkVoid(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) && Date.checkLegal(smallDate) && this._checkVoid({ - year: smallObj[0], - month: smallObj[1], - day: smallObj[2] - }) && this._dateCheck(bigDate) && Date.checkLegal(bigDate) && this._checkVoid({ - year: bigObj[0], - month: bigObj[1], - day: bigObj[2] - }); - }, - _compare: function (smallDate, bigDate) { - smallDate = Date.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); - bigDate = Date.parseDateTime(bigDate, "%Y-%X-%d").print("%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.TimeInterval.EVENT_VALID = "EVENT_VALID"; -BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.time_interval", BI.TimeInterval);/** - * 年份下拉框 - * - * Created by GUY on 2015/8/28. - * @class BI.YearCombo - * @extends BI.Widget - */ -BI.YearCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-combo", - behaviors: {}, - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.YearCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = ""; - this.trigger = BI.createWidget({ - type: "bi.year_trigger", - min: o.min, - max: o.max - }); - this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { - self.storeValue = this.getKey(); - }); - this.trigger.on(BI.YearTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { - self.combo.showView(); - }); - this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.YearTrigger.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.YearCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - destroyWhenHide: true, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: { - type: "bi.year_popup", - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.YearPopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearCombo.EVENT_CONFIRM); - } - }], - behaviors: o.behaviors, - min: o.min, - max: o.max - } - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - var value = self.trigger.getKey(); - if (BI.isNotNull(value)) { - self.popup.setValue(value); - } else if (!value && value !== self.storeValue) { - self.popup.setValue(self.storeValue); - } else { - self.setValue(); - } - self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - setValue: function (v) { - this.combo.setValue(v || ""); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_combo', BI.YearCombo);/** - * 年份展示面板 - * - * 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; - - this.selectedYear = this._year = new Date().getFullYear(); - - var backBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 25, - height: 25, - value: -1 - }); - - var preBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 25, - height: 25, - 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-border-top", - height: 25, - 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); - }); - }, - - getValue: function () { - return this.selectedYear; - }, - - setValue: function (v) { - var o = this.options; - if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { - v = new Date().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/8/21. - * @class BI.YearTrigger - * @extends BI.Trigger - */ -BI.YearTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - triggerWidth: 25, - errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), - errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") - }, - - _defaultConfig: function () { - return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-year-trigger bi-border", - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - height: 25 - }); - }, - _init: function () { - BI.YearTrigger.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) { - self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); - return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); - }, - quitChecker: function (v) { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - errorText: c.errorText - }) - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.YearTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.YearTrigger.EVENT_STOP); - }); - 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.YearTrigger.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.YearTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.YearTrigger.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: c.triggerWidth - }, - width: c.triggerWidth - }, { - el: { - type: "bi.trigger_icon_button", - width: c.triggerWidth - }, - width: c.triggerWidth - } - ] - }); - }, - setValue: function (v) { - this.editor.setState(v); - this.editor.setValue(v); - this.editor.setTitle(v); - }, - getKey: function () { - return this.editor.getValue() | 0; - } -}); -BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.YearTrigger.EVENT_START = "EVENT_START"; -BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; -BI.shortcut("bi.year_trigger", BI.YearTrigger);/** - * 年份 + 月份下拉框 - * - * @class BI.YearMonthCombo - * @extends BI.Widget - */ -BI.YearMonthCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-month-combo", - yearBehaviors: {}, - monthBehaviors: {}, - height: 25 - }); - }, - _init: function () { - BI.YearMonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.year = BI.createWidget({ - type: "bi.year_combo", - behaviors: o.yearBehaviors - }); - - this.month = BI.createWidget({ - type: "bi.month_combo", - behaviors: o.monthBehaviors - }); - - this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); - }); - this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - - this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); - }); - this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.center", - element: this, - hgap: 5, - items: [this.year, this.month] - }); - - }, - - setValue: function (v) { - v = v || {}; - this.month.setValue(v.month); - this.year.setValue(v.year); - }, - - getValue: function () { - return { - year: this.year.getValue(), - month: this.month.getValue() - }; - } -}); -BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** - * 年份 + 月份下拉框 - * - * @class BI.YearQuarterCombo - * @extends BI.Widget - */ -BI.YearQuarterCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-quarter-combo", - yearBehaviors: {}, - quarterBehaviors: {}, - height: 25 - }); - }, - _init: function () { - BI.YearQuarterCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.year = BI.createWidget({ - type: "bi.year_combo", - behaviors: o.yearBehaviors - }); - - this.quarter = BI.createWidget({ - type: "bi.quarter_combo", - behaviors: o.quarterBehaviors - }); - - this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); - }); - this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - - this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); - }); - this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.center", - element: this, - hgap: 5, - items: [this.year, this.quarter] - }); - - }, - - setValue: function (v) { - v = v || {}; - this.quarter.setValue(v.quarter); - this.year.setValue(v.year); - }, - - getValue: function () { - return { - year: this.year.getValue(), - quarter: this.quarter.getValue() - }; - } -}); -BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** - * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { - if (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.matched.concat(search.finded); - }); - 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', - element: this, - 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.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 () { - 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 () { - this.list.populate.apply(this.list, arguments); - } -}); -BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; -BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);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 - }); - }, - - _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 finded = search(parentValues, notSelectedValue, [], searched); - if (finded && 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 = [], finded = false; - //如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(p)) { - finded = true; - } else { - //从当前值开始搜 - finded = search(parentValues, notSelectedValue, result); - p = parentValues; - } - - if (finded === 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, parentValues.length - 1), 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); - var finded = BI.Func.getSearchResult([node.text || node.value], keyword); - return finded.finded.length > 0 || finded.matched.length > 0; - }, - - _getTreeNode: function (parentValues, v) { - var self = this; - var findedParentNode; - 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) { - findedParentNode = node; - return false; - } - if (node.value === parentValues[index]) { - index++; - return; - } - return true; - }); - return findedParentNode; - }, - - _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), - 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 () { - 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) { - 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(); - if (options.keyword) { - keywords.push(options.keyword); - } - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.matched.concat(search.finded); - }); - 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, - 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 () { - 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.populate(); - } - }, - - setValue: function (v) { - this.list.setValue(v); - }, - - getValue: function () { - var val = this.list.getValue() || {}; - return { - type: val.type, - value: val.value - } - }, - - populate: function () { - this.list.populate.apply(this.list, arguments); - } -}); -BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; +/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableTreeNumber + * @extends BI.Widget + */ +BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-tree-number", + isNeedFreeze: false, + startSequence: 1,//开始的序号 + scrollTop: 0, + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.vCurr = 1; + this.hCurr = 1; + this.tasks = []; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: this._getHeaderHeight() - 2 + }, {el: {type: "bi.layout"}, height: 2}, { + el: this.scrollContainer + }] + }); + //缓存第一行对应的序号 + this.start = this.options.startSequence; + this.cache = {}; + this._nextState(); + + this._populate(); + }, + + _getNextSequence: function (nodes) { + var self = this; + var start = this.start; + var cnt = this.start; + + function track(node) { + //如果已经有缓存了就不改计数了,复杂表会出现这种情况 + self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); + cnt++; + } + + BI.each(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = cnt = self.cache[child.text || child.value]; + } + } + track(child) + }); + } + }); + this.start = cnt; + return start; + }, + + _getStart: function (nodes) { + var self = this; + var start = this.start; + BI.some(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = self.cache[child.text || child.value]; + return true; + } + } + }); + } + }); + return start; + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (/**node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = this._getHeaderHeight() - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _getHeaderHeight: function () { + var o = this.options; + return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); + }, + + _nextState: function () { + var o = this.options; + this._getNextSequence(o.items); + }, + + _prevState: function () { + var self = this, o = this.options; + var firstChild; + BI.some(o.items, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (j, child) { + firstChild = child; + return true; + }); + } + }); + if (firstChild && BI.isNotEmptyObject(this.cache)) { + this.start = this.cache[firstChild.text || firstChild.value]; + } else { + this.start = 1; + } + this._nextState(); + }, + + _getMaxScrollTop: function (numbers) { + var cnt = 0; + BI.each(numbers, function (i, number) { + cnt += number.cnt; + }); + return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + + var renderedCells = [], renderedKeys = []; + var numbers = this._formatNumber(o.items); + var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); + BI.each(numbers, function (i, number) { + intervalTree.set(i, number.height); + }); + var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); + var index = intervalTree.greatestLowerBound(scrollTop); + var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); + var height = offsetTop; + var bodyHeight = o.height - this._getHeaderHeight(); + while (height < bodyHeight && index < numbers.length) { + renderedKeys.push(index); + offsetTop += numbers[index].height; + height += numbers[index].height; + index++; + } + + BI.each(renderedKeys, function (i, key) { + var index = BI.deepIndexOf(self.renderedKeys, key); + if (index > -1) { + if (numbers[key].height !== self.renderedCells[index]._height) { + self.renderedCells[index]._height = numbers[key].height; + self.renderedCells[index].el.setHeight(numbers[key].height); + } + if (numbers[key].top !== self.renderedCells[index].top) { + self.renderedCells[index].top = numbers[key].top; + self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); + } + renderedCells.push(self.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + styleGetter: numbers[key].isSummary === true ? function () { + return o.summaryCellStyleGetter(true); + } : function (key) { + return function () { + return o.sequenceCellStyleGetter(key); + } + }(numbers[key].index) + }, numbers[key])); + renderedCells.push({ + el: child, + left: 0, + top: numbers[key].top, + _height: numbers[key].height + }); + } + }); + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + + this.container.setHeight(intervalTree.sumUntil(numbers.length)); + }, + + _restore: function () { + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + _populate: function () { + var self = this; + BI.each(this.tasks, function (i, task) { + task.apply(self); + }); + this.tasks = []; + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + if (v <= 1) { + this.cache = {}; + this.start = this.options.startSequence; + this._restore(); + this.tasks.push(this._nextState); + } else if (v === this.vCurr + 1) { + this.tasks.push(this._nextState); + } else if (v === this.vCurr - 1) { + this.tasks.push(this._prevState); + } + this.vCurr = v; + }, + + setHPage: function (v) { + if (v !== this.hCurr) { + this.tasks.push(this._prevState); + } + this.hCurr = v; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + this.tasks.push(this._prevState); + } + if (header && header !== this.options.header) { + o.header = header; + } + if (crossItems && crossItems !== this.options.crossItems) { + o.crossItems = crossItems; + } + if (crossHeader && crossHeader !== this.options.crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_tree_number', BI.SequenceTableTreeNumber);/** + * 自适应布局 + * + * 1、resize + * 2、吸附 + * 3、当前组件在最上方 + * 4、可以撤销 + * 5、上下之间插入组件 + * + * Created by GUY on 2016/2/23. + * @class BI.AdaptiveArrangement + * @extends BI.Widget + */ +BI.AdaptiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.AdaptiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-adaptive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.FREE, + items: [] + }); + }, + + _init: function () { + BI.AdaptiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement", + element: this, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.Arrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.AdaptiveArrangement.EVENT_SCROLL, arguments); + }); + this.zIndex = 0; + BI.each(o.items, function (i, item) { + self._initResizable(item.el); + }); + + $(document).mousedown(function (e) { + BI.each(self.getAllRegions(), function (i, region) { + if (region.el.element.find(e.target).length === 0) { + region.el.element.removeClass("selected"); + } + }); + }); + BI.ResizeDetector.addResizeListener(this, function () { + self.arrangement.resize(); + self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + }); + }, + + _isEqual: function () { + return this.arrangement._isEqual.apply(this.arrangement, arguments); + }, + + _setSelect: function (item) { + if (!item.element.hasClass("selected")) { + item.element.css("zIndex", ++this.zIndex); + BI.each(this.getAllRegions(), function (i, region) { + region.el.element.removeClass("selected"); + }); + item.element.addClass("selected"); + } + }, + + _initResizable: function (item) { + var self = this, o = this.options; + item.element.css("zIndex", ++this.zIndex); + item.element.mousedown(function () { + self._setSelect(item) + }); + // o.resizable && item.element.resizable({ + // handles: "e, s, se", + // minWidth: 20, + // minHeight: 20, + // autoHide: true, + // helper: "bi-resizer", + // start: function () { + // item.element.css("zIndex", ++self.zIndex); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE); + // }, + // resize: function (e, ui) { + // // self._resize(item.attr("id"), ui.size); + // self._resize(item.attr("id"), e, ui.size, ui.position); + // }, + // stop: function (e, ui) { + // self._stopResize(item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, item.attr("id"), ui.size); + // self.fireEvent(BI.AdaptiveArrangement.EVENT_RESIZE); + // } + // }); + }, + + // _resize: function (name, e, size, position) { + // var self = this; + // this.scrollInterval(e, false, true, function (changedSize) { + // size.width += changedSize.offsetX; + // size.height += changedSize.offsetY; + // var containerWidth = self.arrangement.container.element.width(); + // var containerHeight = self.arrangement.container.element.height(); + // self.arrangement.container.element.width(containerWidth + changedSize.offsetX); + // self.arrangement.container.element.height(containerHeight + changedSize.offsetY); + // switch (self.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // self.setRegionSize(name, size); + // break; + // } + // self.fireEvent(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, name, size); + // }); + // }, + // + // _stopResize: function (name, size) { + // var self = this; + // this.scrollEnd(); + // switch (this.getLayoutType()) { + // case BI.Arrangement.LAYOUT_TYPE.FREE: + // this.setRegionSize(name, size); + // break; + // case BI.Arrangement.LAYOUT_TYPE.GRID: + // this.setRegionSize(name, size); + // break; + // } + // }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + addRegion: function (region, position) { + this._initResizable(region.el); + this._setSelect(region.el); + var self = this, flag; + var old = this.arrangement.getAllRegions(); + if (flag = this.arrangement.addRegion(region, position)) { + this._old = old; + } + return flag; + }, + + deleteRegion: function (name) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.deleteRegion(name)) { + this._old = old; + } else { + this._old = this.getAllRegions(); + this.relayout(); + } + return flag; + }, + + setRegionSize: function (name, size) { + var flag; + var old = this.getAllRegions(); + if (flag = this.arrangement.setRegionSize(name, size)) { + this._old = old; + } + return flag; + }, + + setPosition: function (position, size) { + var self = this; + return this.arrangement.setPosition(position, size); + }, + + setRegionPosition: function (name, position) { + var region = this.getRegionByName(name); + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + return this.arrangement.setDropPosition(position, size); + }, + + scrollInterval: function (e, isBorderScroll, isOverflowScroll, cb) { + var self = this; + var map = { + top: [-1, 0], + bottom: [1, 0], + left: [0, -1], + right: [0, 1] + }; + var clientSize = this.element.bounds(); + + function scrollTo(direction, callback) { + if (direction === "") { + self.lastActiveRegion = ""; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + return; + } + if (self.lastActiveRegion !== direction) { + self.lastActiveRegion = direction; + if (self._scrollInterval) { + clearInterval(self._scrollInterval); + self._scrollInterval = null; + } + var count = 0; + self._scrollInterval = setInterval(function () { + count++; + if (count <= 3) { + return; + } + var offset = self._getScrollOffset(); + var t = offset.top + map[direction][0] * 40; + var l = offset.left + map[direction][1] * 40; + if (t < 0 || l < 0) { + return; + } + callback({ + offsetX: map[direction][1] * 40, + offsetY: map[direction][0] * 40 + }); + self.scrollTo({ + top: t, + left: l + }); + }, 300); + } + } + + cb({ + offsetX: 0, + offsetY: 0 + }); + var offset = this.element.offset(); + var p = { + left: e.pageX - offset.left, + top: e.pageY - offset.top + }; + //向上滚 + if (isBorderScroll && p.top >= 0 && p.top <= 30) { + scrollTo("top", cb) + } + //向下滚 + else if (isBorderScroll && p.top >= clientSize.height - 30 && p.top <= clientSize.height) { + scrollTo("bottom", cb) + } + //向左滚 + else if (isBorderScroll && p.left >= 0 && p.left <= 30) { + scrollTo("left", cb) + } + //向右滚 + else if (isBorderScroll && p.left >= clientSize.width - 30 && p.left <= clientSize.width) { + scrollTo("right", cb) + } else { + if (isOverflowScroll === true) { + if (p.top < 0) { + scrollTo("top", cb); + } + else if (p.top > clientSize.height) { + scrollTo("bottom", cb); + } + else if (p.left < 0) { + scrollTo("left", cb); + } + else if (p.left > clientSize.width) { + scrollTo("right", cb); + } else { + scrollTo("", cb); + } + } else { + scrollTo("", cb); + } + } + }, + + scrollEnd: function () { + this.lastActiveRegion = ""; + if (this._scrollInterval) { + clearInterval(this._scrollInterval); + this._scrollInterval = null; + } + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + var self = this; + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + if (this._old) { + this.populate(BI.toArray(this._old)); + } + }, + + populate: function (items) { + var self = this; + BI.each(items, function (i, item) { + self._initResizable(item.el); + }); + this.arrangement.populate(items); + } +}); +BI.AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_START_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE = "AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE"; +BI.AdaptiveArrangement.EVENT_RESIZE = "AdaptiveArrangement.EVENT_RESIZE"; +BI.AdaptiveArrangement.EVENT_SCROLL = "AdaptiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.adaptive_arrangement', BI.AdaptiveArrangement);/** + * Arrangement的block面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementBlock + * @extends BI.Widget + */ +BI.ArrangementBlock = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementBlock.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-block bi-mask" + }); + } +}); +BI.shortcut('bi.arrangement_block', BI.ArrangementBlock);/** + * Arrangement的drop面板 + * + * Created by GUY on 2016/3/1. + * @class BI.ArrangementDroppable + * @extends BI.Widget + */ +BI.ArrangementDroppable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.ArrangementDroppable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement-droppable bi-resizer" + }); + } +}); +BI.shortcut('bi.arrangement_droppable', BI.ArrangementDroppable);/** + * 布局 + * + * Created by GUY on 2016/2/23. + * @class BI.Arrangement + * @extends BI.Widget + */ +BI.Arrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.Arrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-arrangement", + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.Arrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.arrangement_droppable", + cls: "arrangement-block", + invisible: true + }); + this.block = BI.createWidget({ + type: "bi.arrangement_block", + invisible: true + }); + this.container = BI.createWidget({ + type: "bi.absolute", + cls: "arrangement-container", + items: o.items.concat([this.block, this.arrangement]) + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.adaptive", + width: "100%", + height: "100%", + scrollable: true, + items: [this.container] + }); + this.scrollContainer.element.scroll(function () { + self.fireEvent(BI.Arrangement.EVENT_SCROLL, { + scrollLeft: self.scrollContainer.element.scrollLeft(), + scrollTop: self.scrollContainer.element.scrollTop(), + clientWidth: self.scrollContainer.element[0].clientWidth, + clientHeight: self.scrollContainer.element[0].clientHeight + }); + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + items: [this.scrollContainer] + }); + this.regions = {}; + if (o.items.length > 0) { + BI.nextTick(function () { + self.populate(o.items); + }); + } + }, + + ////初始化操作//// + _calculateRegions: function (items) { + var self = this, o = this.options; + this.regions = {}; + BI.each(items, function (i, item) { + var region = self._createOneRegion(item); + self.regions[region.id] = region; + }); + }, + + _isEqual: function (num1, num2) { + return Math.abs(num1 - num2) < 2; + }, + + _isLessThan: function (num1, num2) { + return num1 < num2 && !this._isEqual(num1, num2); + }, + + _isMoreThan: function (num1, num2) { + return num1 > num2 && !this._isEqual(num1, num2); + }, + + _isLessThanEqual: function (num1, num2) { + return num1 <= num2 || this._isEqual(num1, num2); + }, + + _isMoreThanEqual: function (num1, num2) { + return num1 >= num2 || this._isEqual(num1, num2); + }, + + //获取占有的最大Region + _getRegionOccupied: function (regions) { + var self = this, o = this.options; + if (BI.size(regions || this.regions) <= 0) { + return { + left: 0, + top: 0, + width: 0, + height: 0 + } + } + var minLeft = BI.MAX, maxLeft = BI.MIN, minTop = BI.MAX, maxTop = BI.MIN; + BI.each(regions || this.regions, function (id, region) { + minLeft = Math.min(minLeft, region.left); + maxLeft = Math.max(maxLeft, region.left + region.width); + minTop = Math.min(minTop, region.top); + maxTop = Math.max(maxTop, region.top + region.height); + }); + return { + left: minLeft, + top: minTop, + width: maxLeft - minLeft, + height: maxTop - minTop + } + }, + + //两个区域的交叉面积 + _getCrossArea: function (region1, region2) { + if (region1.left <= region2.left) { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region1.left + region1.width - region2.left); + } + } else { + if (region2.top + region2.height > region1.top && region1.left + region1.width > region2.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region1.left + region1.width, region2.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region1.left + region1.width - region2.left); + } + } + } else { + if (region1.top <= region2.top) { + if (region1.top + region1.height > region2.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region1.top + region1.height, region2.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region1.top + region1.height - region2.top) * (region2.left + region2.width - region1.left); + } + } else { + if (region2.top + region2.height > region1.top && region2.left + region2.width > region1.left) { + if (this._isEqual(region2.top + region2.height, region1.top) || this._isEqual(region2.left + region2.width, region1.left)) { + return 0; + } + return (region2.top + region2.height - region1.top) * (region2.left + region2.width - region1.left); + } + } + } + return 0; + }, + + //是否有覆盖的组件 + _isRegionOverlay: function (regions) { + var reg = []; + BI.each(regions || this.regions, function (id, region) { + reg.push(new BI.Region(region.left, region.top, region.width, region.height)); + }); + for (var i = 0, len = reg.length; i < len; i++) { + for (var j = i + 1; j < len; j++) { + var area1 = { + left: reg[i].x, + top: reg[i].y, + width: reg[i].w, + height: reg[i].h + }; + var area2 = { + left: reg[j].x, + top: reg[j].y, + width: reg[j].w, + height: reg[j].h + }; + if (reg[i].isIntersects(reg[j]) && this._getCrossArea(area1, area2) > 1) { + return true; + } + } + } + return false; + }, + + //布局是否是优良的 + _isArrangeFine: function (regions) { + switch (this.options.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + // if (this._isRegionOverlay()) { + // return false; + // } + } + return true; + }, + + _getRegionNames: function (regions) { + var names = []; + BI.each(regions || this.regions, function (i, region) { + names.push(region.id || region.attr("id")); + }); + return names; + }, + + _getRegionsByNames: function (names, regions) { + names = BI.isArray(names) ? names : [names]; + regions = regions || this.regions; + if (BI.isArray(regions)) { + var result = []; + BI.each(regions, function (i, region) { + if (names.contains(region.id || region.attr("id"))) { + result.push(region); + } + }); + } else { + var result = {}; + BI.each(names, function (i, name) { + result[name] = regions[name]; + }); + } + return result; + }, + + _cloneRegion: function (regions) { + var clone = {}; + BI.each(regions || this.regions, function (id, region) { + clone[id] = {}; + clone[id].el = region.el; + clone[id].id = region.id; + clone[id].left = region.left; + clone[id].top = region.top; + clone[id].width = region.width; + clone[id].height = region.height; + }); + return clone; + }, + + //测试合法性 + _test: function (regions) { + var self = this; + return !BI.any(regions || this.regions, function (i, region) { + if (BI.isNaN(region.width) || BI.isNaN(region.height) || region.width <= 21 || region.height <= 21) { + return true; + } + }) + }, + + _getScrollOffset: function () { + return { + left: this.scrollContainer.element[0].scrollLeft, + top: this.scrollContainer.element[0].scrollTop + } + }, + + ////操作//// + _createOneRegion: function (item) { + var el = BI.createWidget(item.el); + el.setVisible(true); + return { + id: el.attr("id"), + left: item.left, + top: item.top, + width: item.width, + height: item.height, + el: el + } + }, + + _applyRegion: function (regions) { + var self = this, o = this.options; + BI.each(regions || this.regions, function (i, region) { + region.el.element.css({ + left: region.left, + top: region.top, + width: region.width, + height: region.height + }); + }); + this._applyContainer(); + this.ratio = this.getLayoutRatio(); + }, + + _renderRegion: function () { + var items = BI.toArray(this.regions); + BI.each(items, function (i, item) { + if (BI.isNotNull(item.el)) { + item.el.options.key = item.id; + } else { + item.key = item.id; + } + }); + if (BI.isNull(this.wrapper)) { + this.wrapper = BI.createWidget({ + type: "bi.absolute", + element: this.container + }); + } + this.wrapper.populate(items); + }, + + getClientWidth: function () { + return this.scrollContainer.element[0].clientWidth; + }, + + getClientHeight: function () { + return this.scrollContainer.element[0].clientHeight; + }, + + _applyContainer: function () { + //先掩藏后显示能够明确滚动条是否出现 + this.scrollContainer.element.css("overflow", "hidden"); + var occupied = this._getRegionOccupied(); + this.container.element.width(occupied.left + occupied.width).height(occupied.top + occupied.height); + this.scrollContainer.element.css("overflow", "auto"); + return occupied; + }, + + _modifyRegion: function (regions) { + BI.each(this.regions, function (id, region) { + if (regions[id]) { + region.left = regions[id].left; + region.top = regions[id].top; + region.width = regions[id].width; + region.height = regions[id].height; + } + }); + }, + + _addRegion: function (item) { + var region = this._createOneRegion(item); + this.regions[region.id] = region; + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [region] + }); + }, + + _deleteRegionByName: function (name) { + this.regions[name].el.setVisible(false); + delete this.regions[name]; + }, + + _setArrangeSize: function (size) { + this.arrangement.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }) + }, + + //Grid + _getOneWidthPortion: function () { + return this.getClientWidth() / BI.Arrangement.PORTION; + }, + _getOneHeightPortion: function () { + return this.getClientHeight() / BI.Arrangement.H_PORTION; + }, + + _getGridPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + var widthPortion = Math.round(position.width / perWidth); + var leftPortion = Math.round(position.left / perWidth); + var topPortion = Math.round(position.top / perHeight); + var heightPortion = Math.round(position.height / perHeight); + // if (leftPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION; + // } + // if (widthPortion > BI.Arrangement.PORTION) { + // widthPortion = BI.Arrangement.PORTION; + // } + // if (leftPortion + widthPortion > BI.Arrangement.PORTION) { + // leftPortion = BI.Arrangement.PORTION - widthPortion; + // } + if (widthPortion === 0) { + widthPortion = 1; + } + if (heightPortion === 0) { + heightPortion = 1; + } + return { + x: leftPortion, + y: topPortion, + w: widthPortion, + h: heightPortion + } + }, + + _getBlockPositionAndSize: function (position) { + var perWidth = this._getOneWidthPortion(); + var perHeight = this._getOneHeightPortion(); + return { + left: position.x * perWidth, + top: position.y * perHeight, + width: position.w * perWidth, + height: position.h * perHeight + }; + }, + + _getLayoutsByRegions: function (regions) { + var self = this; + var result = []; + BI.each(regions || this.regions, function (id, region) { + result.push(BI.extend(self._getGridPositionAndSize(region), { + i: region.id + })) + }); + return result; + }, + + _getLayoutIndexByName: function (layout, name) { + return BI.findIndex(layout, function (i, l) { + return l.i === name; + }); + }, + + _setBlockPositionAndSize: function (size) { + this.block.element.css({ + left: size.left, + top: size.top, + width: size.width, + height: size.height + }); + }, + + _getRegionsByLayout: function (layout) { + var self = this; + var regions = {}; + BI.each(layout, function (i, ly) { + regions[ly.i] = BI.extend(self._getBlockPositionAndSize(ly), { + id: ly.i + }); + }); + return regions; + }, + + _setRegionsByLayout: function (regions, layout) { + var self = this; + regions || (regions = this.regions); + BI.each(layout, function (i, ly) { + if (regions[ly.i]) { + BI.extend(regions[ly.i], self._getBlockPositionAndSize(ly)); + } + }); + return regions; + }, + + _moveElement: function (layout, l, x, y, isUserAction) { + var self = this; + if (l._static) { + return layout; + } + + if (l.y === y && l.x === x) { + return layout; + } + + var movingUp = y && l.y > y; + if (typeof x === 'number') { + l.x = x; + } + if (typeof y === 'number') { + l.y = y; + } + l.moved = true; + + var sorted = this._sortLayoutItemsByRowCol(layout); + if (movingUp) { + sorted = sorted.reverse(); + } + var collisions = getAllCollisions(sorted, l); + + for (var i = 0, len = collisions.length; i < len; i++) { + var collision = collisions[i]; + if (collision.moved) { + continue; + } + + if (l.y > collision.y && l.y - collision.y > collision.h / 4) { + continue; + } + + if (collision._static) { + layout = this._moveElementAwayFromCollision(layout, collision, l, isUserAction); + } else { + layout = this._moveElementAwayFromCollision(layout, l, collision, isUserAction); + } + } + + return layout; + + function getAllCollisions(layout, layoutItem) { + return BI.filter(layout, function (i, l) { + return self._collides(l, layoutItem); + }); + } + }, + + _sortLayoutItemsByRowCol: function (layout) { + return [].concat(layout).sort(function (a, b) { + if (a.y > b.y || (a.y === b.y && a.x > b.x)) { + return 1; + } + return -1; + }); + }, + + _collides: function (l1, l2) { + if (l1 === l2) { + return false; + } // same element + if (l1.x + l1.w <= l2.x) { + return false; + } // l1 is left of l2 + if (l1.x >= l2.x + l2.w) { + return false; + } // l1 is right of l2 + if (l1.y + l1.h <= l2.y) { + return false; + } // l1 is above l2 + if (l1.y >= l2.y + l2.h) { + return false; + } // l1 is below l2 + return true; // boxes overlap + }, + + _getFirstCollision: function (layout, layoutItem) { + for (var i = 0, len = layout.length; i < len; i++) { + if (this._collides(layout[i], layoutItem)) { + return layout[i]; + } + } + }, + + _moveElementAwayFromCollision: function (layout, collidesWith, + itemToMove, isUserAction) { + if (isUserAction) { + var fakeItem = { + x: itemToMove.x, + y: itemToMove.y, + w: itemToMove.w, + h: itemToMove.h, + i: '-1' + }; + fakeItem.y = Math.max(collidesWith.y - itemToMove.h, 0); + if (!this._getFirstCollision(layout, fakeItem)) { + return this._moveElement(layout, itemToMove, undefined, fakeItem.y); + } + } + + return this._moveElement(layout, itemToMove, undefined, itemToMove.y + 1); + }, + + _compactItem: function (compareWith, l, verticalCompact) { + if (verticalCompact) { + while (l.y > 0 && !this._getFirstCollision(compareWith, l)) { + l.y--; + } + } + + var collides; + while ((collides = this._getFirstCollision(compareWith, l))) { + l.y = collides.y + collides.h; + } + return l; + }, + + compact: function (layout, verticalCompact) { + var compareWith = getStatics(layout); + var sorted = this._sortLayoutItemsByRowCol(layout); + var out = []; + + for (var i = 0, len = sorted.length; i < len; i++) { + var l = sorted[i]; + + if (!l._static) { + l = this._compactItem(compareWith, l, verticalCompact); + + compareWith.push(l); + } + + out[layout.indexOf(l)] = l; + + l.moved = false; + } + + return out; + + function getStatics(layout) { + return BI.filter(layout, function (i, l) { + return l._static; + }); + } + }, + + ////公有方法//// + getRegionByName: function (name) { + var obj = {}; + obj[name] = this.regions[name]; + return this._cloneRegion(obj)[name]; + }, + + getAllRegions: function () { + return BI.toArray(this._cloneRegion()); + }, + + getHelper: function () { + var helper = BI.createWidget({ + type: "bi.layout", + width: 18, + height: 18, + cls: "arrangement-helper bi-border" + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [helper] + }); + return helper; + }, + + _start: function () { + if (this.options.layoutType === BI.Arrangement.LAYOUT_TYPE.GRID) { + this.block.setVisible(true); + } else { + this.arrangement.setVisible(true); + } + }, + + _stop: function () { + this.arrangement.setVisible(false); + this.block.setVisible(false); + }, + + ////公有操作//// + setLayoutType: function (type) { + var self = this, o = this.options; + if (type !== o.layoutType) { + o.layoutType = type; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.relayout(); + break; + } + } + }, + + getLayoutType: function () { + return this.options.layoutType; + }, + + getLayoutRatio: function () { + var occupied = this._getRegionOccupied(); + var width = this.getClientWidth(), height = this.getClientHeight(); + return { + x: BI.parseFloat(BI.contentFormat((occupied.left + occupied.width) / width, "#.##;-#.##")), + y: BI.parseFloat(BI.contentFormat((occupied.top + occupied.height) / height, "#.##;-#.##")) + } + }, + + addRegion: function (region, position) { + if (position) { + this.setPosition(position, region); + } + var self = this, o = this.options; + if (!this.position) { + return false; + } + var test = this._cloneRegion(); + BI.each(this.position.regions, function (i, region) { + test[region.id].left = region.left; + test[region.id].top = region.top; + test[region.id].width = region.width; + test[region.id].height = region.height; + + }); + var item = BI.extend({}, region, { + left: this.position.insert.left, + top: this.position.insert.top, + width: this.position.insert.width, + height: this.position.insert.height + }); + var added = this._createOneRegion(item); + test[added.id] = added; + if (this._test(test)) { + delete test[added.id]; + this._modifyRegion(test); + this._addRegion(item); + this._populate(this.getAllRegions()); + return true; + } + return false; + }, + + deleteRegion: function (name) { + if (!this.regions[name]) { + return false; + } + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + return true; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this._deleteRegionByName(name); + this._populate(this.getAllRegions()); + this.resize(); + return true; + } + return false; + }, + + setRegionSize: function (name, size) { + var self = this, o = this.options; + var flag = false; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + this._modifyRegion(clone); + flag = true; + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var clone = this._cloneRegion(); + BI.extend(clone[name], { + width: size.width, + height: size.height + }); + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(clone); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + flag = true; + } + break; + } + this._applyRegion(); + return flag; + }, + + setPosition: function (position, size) { + var self = this, o = this.options; + var insert, regions = [], cur; + if (position.left < 0 || position.top < 0) { + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.resize(); + break; + } + this._stop(); + this.position = null; + return null; + } + var offset = this._getScrollOffset(); + position = { + left: position.left + offset.left, + top: position.top + offset.top + }; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var insert = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this.position = { + insert: insert + }; + this._setArrangeSize(insert); + this._start(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + var p = { + top: position.top < 0 ? 0 : position.top, + left: position.left < 0 ? 0 : position.left, + width: size.width, + height: size.height + }; + this._setArrangeSize(p); + var cur = this._getGridPositionAndSize(p); + var layout = [{ + x: 0, y: BI.MAX, w: cur.w, h: cur.h, i: cur.i + }].concat(this._getLayoutsByRegions()); + layout = this._moveElement(layout, layout[0], cur.x, cur.y, true); + layout = this.compact(layout, true); + var regions = this._setRegionsByLayout(this._cloneRegion(), layout); + var insert = this._getBlockPositionAndSize(layout[0]); + this.position = { + insert: insert, + regions: regions + }; + this._applyRegion(regions); + this._setBlockPositionAndSize(insert); + this._start(); + break; + } + return this.position; + }, + + setRegionPosition: function (name, position) { + var self = this, o = this.options; + var offset = this._getScrollOffset(); + position = BI.extend(position, { + left: position.left + offset.left, + top: position.top + offset.top + }); + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + this._applyRegion(); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!position.stop) { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var cur = this._getGridPositionAndSize(BI.extend(cloned[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + })); + var x = cur.x, y = cur.y; + cur = BI.extend(cur, { + x: 0, y: BI.MAX, i: -1 + }); + delete cloned[name]; + var layout = this._getLayoutsByRegions(cloned); + layout = this._moveElement([cur].concat(layout), cur, x, y, true); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + + this._setBlockPositionAndSize(this._getBlockPositionAndSize(cur)); + this.block.setVisible(true); + } else { + BI.extend(this.regions[name], { + left: position.left < 0 ? 0 : position.left, + top: position.top < 0 ? 0 : position.top + }); + var cloned = this._cloneRegion(); + var layout = this._getLayoutsByRegions(cloned); + layout = this.compact(layout, true); + var regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + this.block.setVisible(false); + } + break; + } + }, + + setDropPosition: function (position, size) { + var self = this; + this.arrangement.setVisible(true); + var offset = this._getScrollOffset(); + this._setArrangeSize(BI.extend({}, size, { + left: position.left + offset.left, + top: position.top + offset.top + })); + return function () { + self.arrangement.setVisible(false); + } + }, + + scrollTo: function (scroll) { + this.scrollContainer.element.scrollTop(scroll.top); + this.scrollContainer.element.scrollLeft(scroll.left); + }, + + zoom: function (ratio) { + var self = this, o = this.options; + if (!ratio) { + return; + } + var occupied = this._applyContainer(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + if (this._isArrangeFine()) { + var width = this.getClientWidth(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + //var yRatio = ratio.y * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + //region.top = region.top * yRatio; + region.width = region.width * xRatio; + //region.height = region.height * yRatio; + }); + if (this._test(regions)) { + this._modifyRegion(regions); + this._applyRegion(); + } + this.resize(); + // } else { + this.relayout(); + } + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (this._isArrangeFine()) { + var width = this.getClientWidth(), height = this.getClientHeight(); + var xRatio = (ratio.x || 1) * width / (occupied.left + occupied.width); + var yRatio = (ratio.y || 1) * height / (occupied.top + occupied.height); + var regions = this._cloneRegion(); + BI.each(regions, function (i, region) { + region.left = region.left * xRatio; + region.width = region.width * xRatio; + region.top = region.top * yRatio; + region.height = region.height * yRatio; + //做一下自适应布局到网格布局的兼容 + var perWidth = self._getOneWidthPortion(); + var widthPortion = Math.round(region.width / perWidth); + var leftPortion = Math.round(region.left / perWidth); + var comparePortion = Math.round((region.width + region.left) / perWidth); + if (leftPortion + widthPortion !== comparePortion) { + region.left = leftPortion * perWidth; + region.width = comparePortion * perWidth - region.left; + } + }); + if (this._test(regions)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + } + } else { + this.relayout(); + } + break; + } + }, + + resize: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + this.zoom(this.ratio); + var regions = this._cloneRegion(); + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._applyRegion(); + break; + } + }, + + relayout: function () { + var self = this, o = this.options; + switch (o.layoutType) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + if (!this._isArrangeFine()) { + var perHeight = this._getOneHeightPortion(); + var width = this.getClientWidth(), height = this.getClientHeight(); + var regions = this._cloneRegion(); + var clone = BI.toArray(regions); + clone.sort(function (r1, r2) { + if (self._isEqual(r1.top, r2.top)) { + return r1.left - r2.left; + } + return r1.top - r2.top; + }); + var count = clone.length; + var cols = 4, rows = Math.floor((count - 1) / 4 + 1); + var w = width / cols, h = height / rows; + var store = {}; + BI.each(clone, function (i, region) { + var row = Math.floor(i / 4), col = i % 4; + BI.extend(region, { + top: row * perHeight * 6, + left: col * w, + width: w, + height: perHeight * 6 + }); + if (!store[row]) { + store[row] = {}; + } + store[row][col] = region; + }); + //非4的倍数 + // if (count % 4 !== 0) { + // var lasts = store[rows - 1]; + // var perWidth = width / (count % 4); + // BI.each(lasts, function (i, region) { + // BI.extend(region, { + // left: BI.parseInt(i) * perWidth, + // width: perWidth + // }); + // }); + // } + if (this._test(clone)) { + var layout = this._getLayoutsByRegions(regions); + layout = this.compact(layout, true); + regions = this._getRegionsByLayout(layout); + this._modifyRegion(regions); + this._populate(clone); + } + } else { + this.resize(); + } + break; + } + }, + + _populate: function (items) { + this._stop(); + this._calculateRegions(items); + this._applyRegion(); + }, + + populate: function (items) { + this.regions = {}; + this._populate(items); + this._renderRegion(); + } +}); +BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; +BI.extend(BI.Arrangement, { + PORTION: 36, + H_PORTION: 18, + LAYOUT_TYPE: { + GRID: 0, + FREE: 1 + } +}); +BI.shortcut('bi.arrangement', BI.Arrangement);/** + * Created By Shichao on 2017/10/17 + * @class BI.CanvasCollectionView + * @extends BI.Widget + */ +BI.CanvasCollectionView = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasCollectionView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection", + overflowX: true, + overflowY: true, + cellSizeAndPositionGetter: BI.emptyFn, + horizontalOverscanSize: 0, + verticalOverscanSize: 0, + scrollLeft: 0, + scrollTop: 0, + items: [] + }) + }, + + _init: function () { + BI.CanvasCollectionView.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.renderedCells = []; + this.renderedKeys = []; + this._scrollLock = false; + this.scrollTop = this.scrollLeft = 0; + this.summaryScrollTop = this.summaryScrollLeft = 0; + this._debounceRelease = BI.debounce(function () { + self._scrollLock = false; + }, 1000 / 60); + this.canvas = BI.createWidget({ + type: "bi.canvas_new" + }); + $(document).keydown(BI.bind(this._onResize, this)); // 防止在使用ctrl + 滚轮调整窗口大小时触发mousewheel事件 + $(document).keyup(BI.bind(this._onResizeRelease, this)) + this.element.mousewheel(BI.bind(this._onMouseWheel, this)) + BI.createWidget({ + type: "bi.vertical", + element: this, + scrollable: false, + scrolly: false, + scrollx: false, + items: [this.canvas] + }); + if (o.items.length > 0) { + this._calculateSizeAndPositionData(); + this._populate(); + } + if (o.scrollLeft !== 0 || o.scrollTop !== 0) { + BI.nextTick(function () { + self.element.scrollTop(o.scrollTop); + self.element.scrollLeft(o.scrollLeft); + }); + } + }, + + _onMouseWheel: function (e) { + var o = this.options; + if (this._scrollLock) { + return; + } + if (!this._isCtrlPressed) { + o.scrollTop += -e.originalEvent.wheelDelta; + o.scrollTop = BI.clamp(o.scrollTop, 0, this.maxScrollTop); + this._calculateChildrenToRender(); + this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL, { + scrollLeft: o.scrollLeft, + scrollTop: o.scrollTop + }); + } + }, + + _onResize: function (e) { + if (e.ctrlKey) { + this._isCtrlPressed = true; + } else { + this._isCtrlPressed = false; + } + }, + + _onResizeRelease: function (e) { + var Keys = { + CTRL: 17 + }; + var keyCode = e.keyCode; + + if (keyCode === Keys.CTRL) { + this._isCtrlPressed = false; + } + }, + + _getMaxScrollTop: function () { + return this._height - this.options.height + }, + + _calculateSizeAndPositionData: function () { + var o = this.options; + var cellMetadata = []; + var sectionManager = new BI.SectionManager(); + var height = 0; + var width = 0; + + for (var index = 0, len = o.items.length; index < len; index++) { + var cellMetadatum = o.cellSizeAndPositionGetter(index); + + if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || + cellMetadatum.width == null || isNaN(cellMetadatum.width) || + cellMetadatum.x == null || isNaN(cellMetadatum.x) || + cellMetadatum.y == null || isNaN(cellMetadatum.y)) { + throw Error(); + } + + height = Math.max(height, cellMetadatum.y + cellMetadatum.height); + width = Math.max(width, cellMetadatum.x + cellMetadatum.width); + + cellMetadatum.index = index; + cellMetadata[index] = cellMetadatum; + sectionManager.registerCell(cellMetadatum, index); + } + + this._cellMetadata = cellMetadata; + this._sectionManager = sectionManager; + if (this._height === height && this._width === width) { + this._isNeedReset = false; + } else { + this._height = height; + this._width = width; + this._isNeedReset = true; + } + this.maxScrollTop = this._getMaxScrollTop(); + }, + + _cellRenderers: function (height, width, x, y) { + this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); + return this._cellGroupRenderer(); + }, + + _cellGroupRenderer: function () { + var self = this, o = this.options; + var rendered = []; + BI.each(this._lastRenderedCellIndices, function (i, index) { + var cellMetadata = self._sectionManager.getCellMetadata(index); + rendered.push(cellMetadata); + }); + return rendered; + }, + + _calculateChildrenToRender: function () { + var x, y, cellWidth, cellHeight, cellRow, cellCol, value, self = this, o = this.options; + var scrollLeft = o.scrollLeft; + var scrollTop = o.scrollTop; + var left = Math.max(0, scrollLeft - o.horizontalOverscanSize); + var top = Math.max(0, scrollTop - o.verticalOverscanSize); + var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); + var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); + if (right > 0 && bottom > 0) { + var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); + this.canvas.remove(this.scrollLeft, this.scrollTop, o.width, o.height); + for (var i = 0; i < childrenToDisplay.length; i++) { + var datum = childrenToDisplay[i]; + var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; + var rect_tl_x = datum.x, + rect_tl_y = datum.y, + rect_tr_x = rect_tl_x + datum.width, + rect_bl_y = rect_tl_y + datum.height, + cell = o.items[datum.index].cell || o.items[datum.index], + background, color, fontWeight, text; + while (BI.isNull(cell.styles) && !BI.isFunction(cell.styleGetter)) { + cell = cell.cell; + } + if (BI.isNull(cell.styles) && BI.isFunction(cell.styleGetter)) { + background = cell.styleGetter().background; + color = cell.styleGetter().color; + fontWeight = cell.styleGetter().fontWeight; + } else if (!BI.isNull(cell.styles)) { + background = cell.styles.background; + color = cell.styles.color; + fontWeight = cell.styles.fontWeight; + } + if (BI.isNull(cell.text)) { + text = ""; + } else { + text = cell.text; + } + if (!BI.isString(text)) { + text = text.toString(); + } + if (this.scrollLeft !== o.scrollLeft) { + this.canvas.translate(this.scrollLeft - o.scrollLeft, 0); + this.scrollLeft = o.scrollLeft; + } + if (this.scrollTop !== o.scrollTop) { + this.canvas.translate(0, this.scrollTop - o.scrollTop); + this.scrollTop = o.scrollTop; + } + if (datum.x === 0 && datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.x === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tr_x, rect_tl_y, rect_tr_x, rect_bl_y, rect_tl_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else { + this.canvas.solid(rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } + this.canvas.setFontWeight(fontWeight); + this.canvas.setFont(); + var font = this.canvas.getContext().font, + textSize = this._getTextPixel(font), + textHeight = textSize, + textWidth = this.canvas.getContext().measureText(text).width, + dotsWidth = this.canvas.getContext().measureText("...").width; + var offsetX = this._calcOffsetX(textWidth, datum.width, "center"), + offsetY = this._calcOffsetY(textHeight, datum.height, "center"); + if (textHeight > datum.height) { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, "...", color); + } else if (textWidth + 4 > datum.width) { + var sliceIndex = Math.floor((datum.width - dotsWidth - 4) / textWidth * text.length); + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text.slice(0, sliceIndex) + "...", color); + } else { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text, color); + } + this.canvas.stroke(); + } + } + }, + + _getTextPixel: function (font) { + var p = font.split("px")[0], + s = p.split(" "); + for (var c in s) { + var num; + num = BI.parseInt(s[c]); + if (!BI.isNaN(num)) { + return num; + } + } + }, + + _calcOffsetX: function (textWidth, cellWidth, position) { + switch (position) { + case "center": + if (textWidth >= cellWidth) { + return 4; + } else { + return (cellWidth - textWidth) / 2; + } + case "right": + if (textWidth >= cellWidth) { + return 0; + } else { + return cellWidth - textWidth; + } + default: + return 0; + } + }, + + _calcOffsetY: function (textHeight, cellHeight, position) { + switch (position) { + case "center": + if (textHeight >= cellHeight) { + return textHeight; + } else { + return (cellHeight + textHeight) / 2; + } + case "bottom": + if (textHeight >= cellHeight) { + return cellHeight; + } else { + return cellHeight + textHeight; + } + default: + return textHeight; + } + }, + + _populate: function (items) { + var o = this.options; + if (items && items !== this.options.items) { + this.options.items = items; + this._calculateSizeAndPositionData(); + } + if (o.items.length > 0) { + this.canvas.setBlock(); + this.canvas.setWidth(o.width); + this.canvas.setHeight(o.height); + this.restore(); + this._calculateChildrenToRender(); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); + } + }, + + populate: function (items) { + if (items && items !== this.options.items) { + this.restore(); + } + this._populate(items); + }, + + setWidth: function (width) { + BI.CanvasCollectionView.superclass.setWidth.apply(this, arguments); + this.options.width = width; + }, + + setHeight: function (height) { + BI.CanvasCollectionView.superclass.setHeight.apply(this, arguments); + this.options.height = height; + }, + + restore: function () { + this.canvas.remove(this.scrollLeft, this.scrollTop, this.options.width, this.options.height); + this.renderedKeys = []; + this._scrollLock = false; + }, + + setScrollLeft: function (scrollLeft) { + if (this.options.scrollLeft === scrollLeft) { + return; + } + this._scrollLock = true; + this.options.scrollLeft = scrollLeft; + 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 = scrollTop; + this._debounceRelease(); + this._calculateChildrenToRender(); + this.element.scrollTop(this.options.scrollTop); + }, + + getScrollLeft: function () { + return this.options.scrollLeft; + }, + + getScrollTop: function () { + return this.options.scrollTop; + } +}) +BI.CanvasCollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut("bi.canvas_collection_view", BI.CanvasCollectionView);/** + * Created by Shichao on 2017/10/18 + * @class BI.CanvasTable + * @extends BI.Widget + */ +BI.CanvasTable = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection-table", + headerRowSize: 25, + rowSize: 25, + columnSize: [], + isNeedFreeze: false, + freezeCols: [], + isNeedMerge: false, + mergeCols: [], + mergeRule: BI.emptyFn, + header: [], + items: [], + regionColumnSize: [] + }); + }, + + _init: function () { + BI.CanvasTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._scrollBarSize = BI.DOM.getScrollWidth(); + this.topLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topLeftItems[index]; + } + }); + this.topRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topRightItems[index]; + } + }); + this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomLeftItems[index]; + } + }); + this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollTop(scroll.scrollTop); + self.topLeftCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomRightItems[index]; + } + }); + this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomLeftCollection.setScrollTop(scroll.scrollTop); + self.topRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.topLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topLeftCollection] + }); + this.topRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topRightCollection] + }); + this.bottomLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomLeftCollection] + }); + this.bottomRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomRightCollection] + }); + this.contextLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topLeft, + top: 0, + left: 0, + }, { + el: this.topRight, + top: 0 + }, { + el: this.bottomLeft, + left: 0 + }, { + el: this.bottomRight, + }] + }); + + this.topScrollbar = BI.createWidget({ + type: "bi.grid_table_scrollbar", + width: BI.GridTableScrollbar.SIZE + }); + this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollTop) { + self.bottomLeftCollection.setScrollTop(scrollTop); + self.bottomRightCollection.setScrollTop(scrollTop); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.leftScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topLeftCollection.setScrollLeft(scrollLeft); + self.bottomLeftCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.rightScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topRightCollection.setScrollLeft(scrollLeft); + self.bottomRightCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.scrollBarLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topScrollbar, + right: 0, + top: 0 + }, { + el: this.leftScrollbar, + left: 0, + }, { + el: this.rightScrollbar, + }] + }); + this._width = o.width - BI.GridTableScrollbar.SIZE; + this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; + if (o.items.length > 0 || o.header.length > 0) { + this._digest(); + this._populate(); + } + }, + + attr: function () { + BI.CanvasTable.superclass.attr.apply(this, arguments); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; + }, + + getRegionSize: function () { + var o = this.options; + var regionSize = o.regionColumnSize[0] || 0; + if (o.isNeedFreeze === false || o.freezeCols.length === 0) { + return 0; + } + if (!regionSize) { + BI.each(o.freezeCols, function (i, col) { + regionSize += o.columnSize[col]; + }); + } + return regionSize; + }, + + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + + _digest: function () { + var o = this.options; + var freezeColLength = this._getFreezeColLength(); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } + }, + + _populateScrollbar: function () { + var o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + BI.each(o.columnSize, function (i, size) { + if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { + totalLeftColumnSize += size; + } else { + totalRightColumnSize += size; + } + totalColumnSize += size; + if (i === 0) { + summaryColumnSizeArray[i] = size; + } else { + summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; + } + }); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); + this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); + this.topScrollbar.populate(); + + this.leftScrollbar.setContentSize(totalLeftColumnSize); + this.leftScrollbar.setSize(regionSize); + this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft()); + this.leftScrollbar.populate(); + + this.rightScrollbar.setContentSize(totalRightColumnSize); + this.rightScrollbar.setSize(this._width - regionSize); + this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft()); + this.rightScrollbar.populate(); + + var items = this.scrollBarLayout.attr("items"); + items[0].top = this._getFreezeHeaderHeight(); + items[1].top = this._height; + items[2].top = this._height; + items[2].left = regionSize; + this.scrollBarLayout.attr("items", items); + this.scrollBarLayout.resize(); + }, + + _populateTable: function () { + var self = this, o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + var freezeColLength = this._getFreezeColLength(); + var otlw = regionSize; + var otlh = this._getFreezeHeaderHeight(); + var otrw = this._width - regionSize; + var otrh = this._getFreezeHeaderHeight(); + var oblw = regionSize; + var oblh = this._height - otlh; + var obrw = this._width - regionSize; + var obrh = this._height - otrh; + + var tlw = otlw + this._scrollBarSize; + var tlh = otlh + this._scrollBarSize; + var trw = otrw + this._scrollBarSize; + var trh = otrh + this._scrollBarSize; + var blw = oblw + this._scrollBarSize; + var blh = oblh + this._scrollBarSize; + var brw = obrw + this._scrollBarSize; + var brh = obrh + this._scrollBarSize; + + this.topLeft.setWidth(otlw); + this.topLeft.setHeight(otlh); + this.topRight.setWidth(otrw); + this.topRight.setHeight(otrh); + this.bottomLeft.setWidth(oblw); + this.bottomLeft.setHeight(oblh); + this.bottomRight.setWidth(obrw); + this.bottomRight.setHeight(obrh); + + this.topLeftCollection.setWidth(tlw); + this.topLeftCollection.setHeight(tlh); + this.topRightCollection.setWidth(trw); + this.topRightCollection.setHeight(trh); + this.bottomLeftCollection.setWidth(blw); + this.bottomLeftCollection.setHeight(blh); + this.bottomRightCollection.setWidth(brw); + this.bottomRightCollection.setHeight(brh); + + var items = this.contextLayout.attr("items"); + items[1].left = regionSize; + //items[2].top = this._getFreezeHeaderHeight(); + items[2].top = otrh; + items[3].left = regionSize; + //items[3].top = this._getFreezeHeaderHeight(); + items[3].top = otrh; + this.contextLayout.attr("items", items); + this.contextLayout.resize(); + + var leftHeader = [], rightHeader = [], leftItems = [], rightItems = []; + var run = function (positions, items, rendered) { + BI.each(positions, function (i, item) { + if (BI.isNull(items[item.row][item.col])) { + debugger + } + rendered.push(items[item.row][item.col]); + }); + }; + run(this.topLeftItems, o.header, leftHeader); + run(this.topRightItems, o.header, rightHeader); + run(this.bottomLeftItems, o.items, leftItems); + run(this.bottomRightItems, o.items, rightItems); + + this.topLeftCollection._populate(leftHeader); + this.topRightCollection._populate(rightHeader); + this.bottomLeftCollection._populate(leftItems); + this.bottomRightCollection._populate(rightItems); + }, + + _populate: function () { + if (this._width <= 0 || this._height <= 0) { + return; + } + if (this._isNeedDigest === true) { + this._digest(); + } + this._isNeedDigest = false; + this._populateTable(); + this._populateScrollbar(); + }, + + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; + var self = this, o = this.options; + var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; + var summaryColumnSize = []; + for (var i = startCol; i < endCol; i++) { + if (i === startCol) { + summaryColumnSize[i] = columnSize[i]; + } else { + summaryColumnSize[i] = summaryColumnSize[i - 1] + columnSize[i]; + } + } + var mergeRow = function (i, j) { + preCol[j]._height += rowHeight; + preCol[j].__mergeRows.push(i); + }; + + var mergeCol = function (i, j) { + preRow[i]._width += columnSize[j]; + preRow[i].__mergeCols.push(j); + }; + + var createOneEl = function (r, c) { + var width = columnSize[c]; + var height = rowHeight; + map[r][c]._row = r; + map[r][c]._col = c; + map[r][c]._width = width; + map[r][c]._height = height; + preCol[c] = map[r][c]; + preCol[c].__mergeRows = [r]; + preRow[r] = map[r][c]; + preRow[r].__mergeCols = [c]; + + result.push({ + x: summaryColumnSize[c] - columnSize[c], + y: +r * rowHeight, + item: map[r][c] + }); + }; + + BI.each(items, function (i, cols) { + for (var j = startCol; j < endCol; j++) { + if (!cache[i]) { + cache[i] = {}; + } + if (!map[i]) { + map[i] = {}; + } + cache[i][j] = cols[j]; + map[i][j] = {}; + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { + if (i === 0 && j === startCol) { + createOneEl(0, startCol); + } else if (j === startCol && i > 0) { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + if (isNeedMergeRow === true) { + mergeRow(i, j); + preRow[i] = preCol[j]; + } else { + createOneEl(i, j); + } + } else if (i === 0 && j > startCol) { + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol === true) { + mergeCol(i, j); + preCol[j] = preRow[i]; + } else { + createOneEl(i, j); + } + } else { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol && isNeedMergeRow) { + continue; + //mergeRow(i, j);//优先合并列 + } + if (isNeedMergeCol) { + mergeCol(i, j); + } + if (isNeedMergeRow) { + mergeRow(i, j); + } + if (!isNeedMergeCol && !isNeedMergeRow) { + createOneEl(i, j); + } + } + } else { + createOneEl(i, j); + } + } + }); + return BI.map(result, function (i, item) { + return { + x: item.x, + y: item.y, + row: item.item._row, + col: item.item._col, + width: item.item._width, + height: item.item._height + } + }); + }, + + populate: function (items, header) { + if (items && this.options.items !== items) { + this._isNeedDigest = true; + this.options.items = items; + this._restore(); + } + if (header && this.options.header !== header) { + this._isNeedDigest = true; + this.options.header = header; + this._restore(); + } + this._populate(); + }, + + _restore: function () { + this.topLeftCollection.restore(); + this.topRightCollection.restore(); + this.bottomLeftCollection.restore(); + this.bottomRightCollection.restore(); + }, + + restore: function () { + this._restore(); + }, + + setWidth: function (width) { + BI.CanvasTable.superclass.setWidth.apply(this, arguments); + this._width = width - BI.GridTableScrollbar.SIZE; + }, + + setHeight: function (height) { + BI.CanvasTable.superclass.setHeight.apply(this, arguments); + this._height = height - BI.GridTableScrollbar.SIZE; + }, + + setVerticalScroll: function (scrollTop) { + this.bottomLeftCollection.setScrollTop(scrollTop); + this.bottomRightCollection.setScrollTop(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.topLeftCollection.setScrollLeft(scrollLeft); + this.bottomLeftCollection.setScrollLeft(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.topRightCollection.setScrollLeft(scrollLeft); + this.bottomRightCollection.setScrollLeft(scrollLeft); + }, + + getVerticalScroll: function () { + return this.bottomRightCollection.getScrollTop(); + }, + + getLeftHorizontalScroll: function () { + return this.bottomLeftCollection.getScrollLeft(); + }, + + getRightHorizontalScroll: function () { + return this.bottomRightCollection.getScrollLeft(); + }, + + setColumnSize: function (columnSize) { + this._isNeedDigest = true; + this.options.columnSize = columnSize; + }, + + setRegionColumnSize: function (regionColumnSize) { + this._isNeedDigest = true; + this.options.regionColumnSize = regionColumnSize; + }, + + getColumnSize: function () { + return this.options.columnSize; + }, + + getRegionColumnSize: function () { + return this.options.regionColumnSize; + }, +}); + +BI.shortcut("bi.canvas_table", BI.CanvasTable);/** + * 日期控件中的月份下拉框 + * + * 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: 25 + }); + }, + _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" + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function(){ + self.setValue(self.popup.getValue()); + }) + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + 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); + }); + }, + + setValue: function(v){ + this.trigger.setValue(v + 1); + 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', //最大日期 + height: 25 + }); + }, + _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", + 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, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }) + this.combo.on(BI.Combo.EVENT_CHANGE, function(){ + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }) + }, + + 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 bi-background", + height: 25, + 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 = new Date().getFullYear(); + this._month = new Date().getMonth(); + 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 () { + if (self._month === 0) { + self.setValue({ + year: self.year.getValue() - 1, + month: 11 + }) + } 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: 25, + height: 25 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 11) { + self.setValue({ + year: self.year.getValue() + 1, + month: 0 + }) + } 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", + 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" + }); + 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: this.left, + width: 25 + }, { + type: "bi.center_adapt", + items: [{ + type: "bi.horizontal", + width: 100, + items: [this.year, this.month] + }] + }, { + el: this.right, + width: 25 + }] + }) + this.setValue({ + year: this._year, + month: this._month + }) + }, + + _checkLeftValid: function () { + var o = this.options; + var valid = !(this._month === 0 && this._year === Date.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); + this.left.setEnable(valid); + return valid; + }, + + _checkRightValid: function () { + var o = this.options; + var valid = !(this._month === 11 && this._year === Date.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); + this.right.setEnable(valid); + return valid; + }, + + + + setValue: function (ob) { + this._year = ob.year; + this._month = 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.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 = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + 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", + min: o.min, + max: o.max + }); + + this.calendar = BI.createWidget({ + direction: "top", + element: this, + 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); + }); + }, + + 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);/** + * 日期控件中的年份或月份trigger + * + * Created by GUY on 2015/9/7. + * @class BI.DateTriangleTrigger + * @extends BI.Trigger + */ +BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { + _const: { + height: 25, + iconWidth: 16, + iconHeight: 13 + }, + + _defaultConfig: function() { + return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", + height: 25 + }); + }, + _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 + }) + this.icon = BI.createWidget({ + type: "bi.icon", + width: c.iconWidth, + height: c.iconHeight + }); + + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [{ + type: "bi.center_adapt", + width: 50, + height: c.height, + items: [this.text, this.icon] + }] + }) + }, + + 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 GUY on 2015/9/7. + * @class BI.DateCombo + * @extends BI.Widget + */ +BI.DateCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-combo bi-border", + height: 25 + }); + }, + _init: function () { + BI.DateCombo.superclass._init.apply(this, arguments); + var self = this, + o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_trigger" + }); + + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + + this.popup = BI.createWidget({ + type: "bi.date_calendar_popup" + }); + + this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + width: 270, + el: this.popup, + stopPropagation: false + } + }) + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.shortcut('bi.date_combo', BI.DateCombo);BI.DateTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 30, + yearLength: 4, + yearMonthLength: 7 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.DateTrigger.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) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && Date.checkLegal(v) && self._checkVoid({ + year: date[0], + month: date[1], + day: date[2] + }); + }, + 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"); + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DateTrigger.EVENT_KEY_DOWN) + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DateTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DateTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DateTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DateTrigger.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)) { + var date = value.split("-"); + self.store_value = { + type: BI.DateTrigger.MULTI_DATE_CALENDAR, + value:{ + year: date[0] | 0, + month: date[1] - 1, + day: date[2] | 0 + } + }; + } + self.fireEvent(BI.DateTrigger.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.DateTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: 30 + }, { + el: this.editor + }] + }) + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + var self = this; + var date = Date.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + var yearCheck = function (v) { + return Date.parseDateTime(v, "%Y").print("%Y") == v && date >= self.options.min && date <= self.options.max; + }; + var monthCheck = function (v) { + return Date.parseDateTime(v, "%Y-%X").print("%Y-%X") == v && date >= self.options.min && date <= self.options.max; + }; + if (BI.isNotNull(dateObj) && Date.checkLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + if (monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = new Date(); + this.store_value = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DateTrigger.MULTI_DATE_CALENDAR; value = v.value; + if(BI.isNull(value)){ + value = v; + } + } + var _setInnerValue = function (date, text) { + var dateStr = date.print("%Y-%x-%e"); + self.editor.setState(dateStr); + self.editor.setValue(dateStr); + self.setTitle(text + ":" + dateStr); + }; + switch (type) { + case BI.DateTrigger.MULTI_DATE_YEAR_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV]; + date = new Date((date.getFullYear() - 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER]; + date = new Date((date.getFullYear() + 1 * value), date.getMonth(), date.getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN]; + date = new Date(date.getFullYear(), 0, 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_YEAR_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END]; + date = new Date(date.getFullYear(), 11, 31); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV]; + date = new Date().getBeforeMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER]; + date = new Date().getAfterMulQuarter(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN]; + date = new Date().getQuarterStartDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_QUARTER_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END]; + date = new Date().getQuarterEndDate(); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV]; + date = new Date().getBeforeMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER]; + date = new Date().getAfterMultiMonth(value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_BEGIN: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN]; + date = new Date(date.getFullYear(), date.getMonth(), 1); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_MONTH_END: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END]; + date = new Date(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV]; + date = date.getOffsetDate(-7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_WEEK_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER]; + date = date.getOffsetDate(7 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_PREV: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV]; + date = date.getOffsetDate(-1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_AFTER: + var text = value + BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER]; + date = date.getOffsetDate(1 * value); + _setInnerValue(date, text); + break; + case BI.DateTrigger.MULTI_DATE_DAY_TODAY: + var text = BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY]; + date = new Date(); + _setInnerValue(date, text); + break; + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + this.setTitle(""); + } else { + var dateStr = value.year + "-" + (value.month + 1) + "-" + value.day; + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + this.setTitle(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.store_value; + } + +}); + +BI.DateTrigger.MULTI_DATE_YEAR_PREV = 1; +BI.DateTrigger.MULTI_DATE_YEAR_AFTER = 2; +BI.DateTrigger.MULTI_DATE_YEAR_BEGIN = 3; +BI.DateTrigger.MULTI_DATE_YEAR_END = 4; + +BI.DateTrigger.MULTI_DATE_MONTH_PREV = 5; +BI.DateTrigger.MULTI_DATE_MONTH_AFTER = 6; +BI.DateTrigger.MULTI_DATE_MONTH_BEGIN = 7; +BI.DateTrigger.MULTI_DATE_MONTH_END = 8; + +BI.DateTrigger.MULTI_DATE_QUARTER_PREV = 9; +BI.DateTrigger.MULTI_DATE_QUARTER_AFTER = 10; +BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN = 11; +BI.DateTrigger.MULTI_DATE_QUARTER_END = 12; + +BI.DateTrigger.MULTI_DATE_WEEK_PREV = 13; +BI.DateTrigger.MULTI_DATE_WEEK_AFTER = 14; + +BI.DateTrigger.MULTI_DATE_DAY_PREV = 15; +BI.DateTrigger.MULTI_DATE_DAY_AFTER = 16; +BI.DateTrigger.MULTI_DATE_DAY_TODAY = 17; + +BI.DateTrigger.MULTI_DATE_PARAM = 18; +BI.DateTrigger.MULTI_DATE_CALENDAR = 19; + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM = {}; +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_PREV] = BI.i18nText("BI-Multi_Date_Year_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_AFTER] = BI.i18nText("BI-Multi_Date_Year_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_BEGIN] = BI.i18nText("BI-Multi_Date_Year_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_YEAR_END] = BI.i18nText("BI-Multi_Date_Year_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_PREV] = BI.i18nText("BI-Multi_Date_Quarter_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_AFTER] = BI.i18nText("BI-Multi_Date_Quarter_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_BEGIN] = BI.i18nText("BI-Multi_Date_Quarter_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_QUARTER_END] = BI.i18nText("BI-Multi_Date_Quarter_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_PREV] = BI.i18nText("BI-Multi_Date_Month_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_AFTER] = BI.i18nText("BI-Multi_Date_Month_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_BEGIN] = BI.i18nText("BI-Multi_Date_Month_Begin"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_MONTH_END] = BI.i18nText("BI-Multi_Date_Month_End"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_PREV] = BI.i18nText("BI-Multi_Date_Week_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_WEEK_AFTER] = BI.i18nText("BI-Multi_Date_Week_Next"); + +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_PREV] = BI.i18nText("BI-Multi_Date_Day_Prev"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_AFTER] = BI.i18nText("BI-Multi_Date_Day_Next"); +BI.DateTrigger.MULTI_DATE_SEGMENT_NUM[BI.DateTrigger.MULTI_DATE_DAY_TODAY] = BI.i18nText("BI-Multi_Date_Today"); + +BI.DateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DateTrigger.EVENT_START = "EVENT_START"; +BI.DateTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DateTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.date_trigger", BI.DateTrigger);/** + * Created by zcf on 2017/2/20. + */ +BI.DatePaneWidget = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePaneWidget.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.DatePaneWidget.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = new Date(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + min: o.min, + max: o.max + }); + 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 = BI.createWidget({ + direction: "top", + element: this, + logic: { + dynamic: false + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + + // afterCardCreated: function () { + // + // }, + // + // afterCardShow: function () { + // // this.setValue(self.selectedTime); + // } + }); + 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); + }); + + }, + + _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 = new Date(); + return { + year: today.getFullYear(), + month: today.getMonth() + } + }, + + _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.date_pane", BI.DatePaneWidget);/** + * 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', + width: 200, + height: 24 + }); + }, + _init: function () { + BI.DateTimeCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + var date = new Date(); + this.storeValue = { + year: date.getFullYear(), + month: date.getMonth(), + 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 + }); + + this.popup = BI.createWidget({ + type: "bi.date_time_popup", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_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.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () { + self.trigger.setValue(self.popup.getValue()); + self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE); + }); + this.combo = BI.createWidget({ + type: 'bi.combo', + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + maxHeight: this.constants.popupHeight, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + 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 bi-border-right", + width: 30, + height: 24 + }); + triggerBtn.on(BI.TriggerIconButton.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, + left: 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: 290 + }); + }, + _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", + min: self.options.min, + max: self.options.max + }); + self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + }); + + this.dateSelect = BI.createWidget({ + type: "bi.vertical_adapt", + cls: "bi-border-top", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Basic_Time"), + width: 45 + }, { + type: "bi.date_time_select", + max: 23, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.hour = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.minute = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.second = _ref; + } + }] + }); + + var date = new Date(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.cancelButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateCombo + }, { + el: this.dateSelect, + height: 50 + }, { + el: this.dateButton, + height: 30 + }] + }); + }, + + setValue: function (v) { + var value = v, date; + if (BI.isNull(value)) { + date = new Date(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + } else { + this.dateCombo.setValue({ + year: value.year, + month: value.month, + day: value.day + }); + this.hour.setValue(value.hour); + this.minute.setValue(value.minute); + this.second.setValue(value.second); + } + }, + + getValue: function () { + return { + year: this.dateCombo.getValue().year, + month: this.dateCombo.getValue().month, + day: this.dateCombo.getValue().day, + hour: this.hour.getValue(), + minute: this.minute.getValue(), + second: this.second.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.DateTimeSelect = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-time-select bi-border", + max: 23, + min: 0 + }) + }, + + _init: function () { + BI.DateTimeSelect.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.min), + allowBlank: false, + errorText: BI.i18nText("BI-Please_Input_Natural_Number"), + validationChecker: function(v){ + return BI.isNaturalNumber(v); + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){ + self._finetuning(0); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-next-page-h-font bottom-button bi-border-left" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ + self._finetuning(-1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + 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: 30 + }] + }); + }, + + _alertOutEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max + } + return BI.parseInt(v); + }, + + _alertInEditorValue: function(v){ + if (v > this.options.max){ + v = this.options.min; + } + if (v < this.options.min){ + v = this.options.max; + } + v = v < 10 ? "0" + v : v; + return v; + }, + + _finetuning: function(add){ + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + triggerWidth: 30 + }, + + _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: BI.createWidget(), + width: c.triggerWidth + }, { + el: this.text + }] + }) + }, + + _printTime: function (v) { + return v < 10 ? "0" + v : v; + }, + + setValue: function (v) { + var self = this; + var value = v, dateStr; + if(BI.isNull(value)){ + value = new Date(); + dateStr = value.print("%Y-%X-%d %H:%M:%S"); + } else { + var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second); + dateStr = date.print("%Y-%X-%d %H:%M:%S"); + + } + this.text.setText(dateStr); + this.text.setTitle(dateStr); + } + +}); +BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);/** + * 带有方向的pathchooser + * + * Created by GUY on 2016/4/21. + * @class BI.DirectionPathChooser + * @extends BI.Widget + */ +BI.DirectionPathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#808080", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.DirectionPathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-excel-table", + items: [] + }); + }, + + _init: function () { + BI.DirectionPathChooser.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.pathChooser = BI.createWidget({ + type: "bi.path_chooser", + element: this, + items: o.items + }); + this.pathChooser.on(BI.PathChooser.EVENT_CHANGE, function (start, index) { + //self._unselectAllArrows(); + self._setValue(start, index); + self.fireEvent(BI.DirectionPathChooser.EVENT_CHANGE); + }); + this._drawArrows(); + + }, + + _unselectAllArrows: function () { + var self = this, lineColor = this._const.lineColor; + BI.each(this.arrows, function (region, rs) { + BI.each(rs, function (idx, arrows) { + BI.each(arrows, function (i, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}); + }); + }); + }); + }, + + _drawOneArrow: function (dot, direction) { + //0,1,2,3 上右下左 + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var svg = this.pathChooser.svg; + var path = ""; + switch (direction) { + case 0: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y + 5) + + "L" + (dot.x + 3) + "," + (dot.y + 5) + + "L" + dot.x + "," + dot.y; + break; + case 1: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 5) + "," + (dot.y - 3) + + "L" + (dot.x - 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + case 2: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x - 3) + "," + (dot.y - 5) + + "L" + (dot.x + 3) + "," + (dot.y - 5) + + "L" + dot.x + "," + dot.y; + break; + case 3: + path = "M" + dot.x + "," + dot.y + + "L" + (dot.x + 5) + "," + (dot.y - 3) + + "L" + (dot.x + 5) + "," + (dot.y + 3) + + "L" + dot.x + "," + dot.y; + break; + } + return svg.path(path).attr({fill: lineColor, stroke: lineColor}); + }, + + _drawArrows: function () { + var self = this, o = this.options; + var routes = this.pathChooser.routes; + var pathes = this.pathChooser.pathes; + var store = this.pathChooser.store; + this.arrows = {}; + BI.each(routes, function (region, ps) { + self.arrows[region] = []; + BI.each(ps, function (idx, path) { + self.arrows[region][idx] = []; + var dots = pathes[region][idx]; + BI.each(dots, function (i, dot) { + if (i > 0 && i < dots.length - 1) { + var arrow; + if (dot.y === dots[i - 1].y) { + if (dots[i + 1].y != dot.y) { + if (store[path[path.length - 2]].direction === -1) { + if (i - 1 > 0) { + arrow = self._drawOneArrow(dots[i - 1], 3); + } + } else { + arrow = self._drawOneArrow(dots[i], 1); + } + } + } else if (dot.x === dots[i - 1].x) { + if (dot.y > dots[i - 1].y) { + if (store[BI.first(path)].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 0); + } else { + arrow = self._drawOneArrow(dot, 2); + } + } else { + if (store[path[path.length - 2]].direction === -1) { + arrow = self._drawOneArrow(dots[i - 1], 2); + } else { + arrow = self._drawOneArrow(dot, 0); + } + } + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + BI.each(path, function (i, node) { + if (i !== 0) { + var arrow; + var from = path[i - 1]; + if (store[from].direction === -1) { + var regionIndex = self.pathChooser.getRegionIndexById(from); + var x = getXoffsetByRegionIndex(regionIndex, -1); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 3); + } else { + var regionIndex = self.pathChooser.getRegionIndexById(node); + var x = getXoffsetByRegionIndex(regionIndex); + var y = getYByXoffset(dots, x); + arrow = self._drawOneArrow({x: x, y: y}, 1); + } + if (arrow) { + self.arrows[region][idx].push(arrow); + } + } + }); + }) + }); + + function getXoffsetByRegionIndex(regionIndex, diregion) { + if (diregion === -1) { + return 100 * (regionIndex + 1) - 20; + } + return 100 * regionIndex + 20; + } + + function getYByXoffset(dots, xoffset) { + var finded = BI.find(dots, function (i, dot) { + if (i > 0) { + if (dots[i - 1].x < xoffset && dots[i].x > xoffset) { + return true; + } + } + }); + return finded.y; + } + }, + + _setValue: function (start, index) { + var self = this; + var lineColor = this._const.lineColor; + var selectLineColor = this._const.selectLineColor; + var routes = this.pathChooser.routes; + var starts = this.pathChooser.start; + var each = [start]; + if (starts.contains(start)) { + each = starts; + } + BI.each(each, function (i, s) { + BI.each(self.arrows[s], function (j, arrows) { + BI.each(arrows, function (k, arrow) { + arrow.attr({fill: lineColor, stroke: lineColor}).toFront(); + }); + }); + }); + BI.each(this.arrows[start][index], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + var current = BI.last(routes[start][index]); + while (current && routes[current] && routes[current].length === 1) { + BI.each(self.arrows[current][0], function (i, arrow) { + arrow.attr({fill: selectLineColor, stroke: selectLineColor}).toFront(); + }); + current = BI.last(routes[current][0]); + } + }, + + setValue: function (v) { + this.pathChooser.setValue(v); + this._unselectAllArrows(); + var routes = this.pathChooser.routes; + var nodes = BI.keys(routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + self._setValue(start, index); + } + }); + }, + + getValue: function () { + return this.pathChooser.getValue(); + }, + + populate: function (items) { + this.pathChooser.populate(items); + this._drawArrows(); + } +}); +BI.DirectionPathChooser.EVENT_CHANGE = "DirectionPathChooser.EVENT_CHANGE"; +BI.shortcut('bi.direction_path_chooser', BI.DirectionPathChooser);/** + * 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", + invalid: false, + height: 25, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + 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 + }); + + 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, + adjustLength: o.adjustLength, + direction: o.direction, + 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 () { + this.downlistcombo.showView(); + }, + + 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 + }] + }); + 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.Single, { + _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: 25, + 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.icon_text_item", + element: this, + height: o.height, + text: o.text, + value: o.value, + logic: o.logic, + selected: o.selected, + disabled: o.disabled, + iconHeight: o.iconHeight, + iconWidth: o.iconWidth, + textHgap: o.textHgap, + textVgap: o.textVgap, + textLgap: o.textLgap, + textRgap: o.textRgap, + father: o.father + }); + this.text.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text.on(BI.IconTextItem.EVENT_CHANGE, function () { + self.fireEvent(BI.DownListItem.EVENT_CHANGE); + }); + // this.setSelected(o.selected); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + isSelected: function () { + return this.text.isSelected(); + }, + + setSelected: function (b) { + this.text.setSelected(b); + // if (b === true) { + // this.element.addClass("dot-e-font"); + // } else { + // this.element.removeClass("dot-e-font"); + // } + }, + + setValue: function (v) { + this.text.setValue(v); + }, + + getValue: function () { + return this.text.getValue(); + } +}); +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: 25, + forceNotSelected: true + }); + + this.icon2 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls2, + width: 25, + forceNotSelected: true + }); + + var blank = BI.createWidget({ + type: "bi.layout", + width: 25 + }); + 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() + } + }); + }, + + 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) { + var self = this, o = this.options; + v = BI.isArray(v) ? v : [v]; + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { + self.icon1.setSelected(true); + return true; + } else { + self.icon1.setSelected(false); + } + }) + } +}); +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: 25, + 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 = {}; + var self = this, o = this.options, children = this._createChildren(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 + }], + 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 (!self.singleValues.contains(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] + }); + + }, + _createChildren: 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: 4, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + } + }; + 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-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 10 + }); + 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 + }, + + populate: function (items) { + BI.DownListPopup.superclass.populate.apply(this, arguments); + var self = this; + self.childValueMap = {}; + self.fatherValueMap = {}; + self.singleValues = []; + var children = self._createChildren(items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + self.popup.populate(popupItem); + }, + + setValue: 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); + } + ); + this.popup.setValue(valueArray); + }, + + getValue: function () { + var self = this, result = []; + var values = this.popup.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 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", + height: 30, + 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, + errorText: o.errorText, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker + }); + 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.SearchEditor.EVENT_CLEAR); + }); + BI.createWidget({ + element: this, + type: "bi.htape", + items: [ + { + el: { + type: "bi.center_adapt", + cls: "search-font", + items: [{ + el: { + type: "bi.icon" + } + }] + }, + width: 25 + }, + { + el: self.editor + }, + { + el: this.clear, + width: 25 + } + ] + }); + 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]; + } + }, + + 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: 24 + }); + }, + + _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", + hgap: 4, + vgap: 2, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn, + allowBlank: false, + watermark: "", + errorText: "", + height: 30 + }) + }, + + _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: 25 + }); + }, + + _init: function () { + BI.SmallTextEditor.superclass._init.apply(this, arguments); + } +}); +BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** + * 文件管理控件组 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerButtonGroup + * @extends BI.Widget + */ +BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-button_group", + items: [] + }) + }, + + _init: function () { + BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.button_group = BI.createWidget({ + type: "bi.button_tree", + element: this, + chooseType: BI.Selection.Multi, + items: this._formatItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _formatItems: function (items) { + var self = this, o = this.options; + BI.each(items, function (i, item) { + if (item.children && item.children.length > 0) { + item.type = "bi.file_manager_folder_item"; + } else { + item.type = "bi.file_manager_file_item"; + } + }); + return items; + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getNotSelectedValue: function () { + return this.button_group.getNotSelectedValue(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + populate: function (items) { + this.button_group.populate(this._formatItems(items)); + } +}); +BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManager + * @extends BI.Widget + */ +BI.FileManager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + var items = BI.Tree.transformToTreeFormat(o.items); + this.tree.initTree(items); + this.selectedValues = []; + this.nav = BI.createWidget({ + type: "bi.file_manager_nav", + items: BI.deepClone(items) + }); + this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { + if (value == "-1") {//根节点 + self.populate({children: self.tree.toJSON()}); + } else { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } + self.setValue(self.selectedValues); + }); + this.list = BI.createWidget(o.el, { + type: "bi.file_manager_list", + items: items + }); + this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { + if (type === BI.Events.CHANGE) { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } else if (type === BI.Events.CLICK) { + var values = []; + if (obj instanceof BI.MultiSelectBar) { + var t = self.list.getValue(); + selected = t.type === BI.Selection.All; + values = BI.concat(t.assist, t.value); + } else { + values = obj.getAllLeaves(); + } + BI.each(values, function (i, v) { + if (selected === true) { + self.selectedValues.pushDistinct(v); + } else { + self.selectedValues.remove(v); + } + }); + } + self.setValue(self.selectedValues); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.list, + left: 0, + right: 0, + top: 0, + bottom: 10 + }, { + el: this.nav, + left: 40, + right: 100, + top: 0 + }] + }); + }, + + setValue: function (value) { + this.selectedValues = value || []; + this.list.setValue(this.selectedValues); + }, + + getValue: function () { + var obj = this.list.getValue(); + var res = obj.type === BI.Selection.All ? obj.assist : obj.value; + res.pushDistinctArray(this.selectedValues); + return res; + }, + + _populate: function (items) { + this.list.populate(items); + }, + + getSelectedValue: function () { + return this.nav.getValue()[0]; + }, + + getSelectedId: function () { + return this.nav.getId()[0]; + }, + + populate: function (node) { + var clone = BI.deepClone(node); + this._populate(node.children); + this.nav.populate(clone); + } +}); +BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; +BI.shortcut("bi.file_manager", BI.FileManager);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFileItem + * @extends BI.Single + */ +BI.FileManagerFileItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFileItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-file-font" + }, + width: 20 + }, { + el: { + type: "bi.label", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + } + }] + }) + }, + + getAllLeaves: function(){ + return [this.options.value]; + }, + + isSelected: function () { + return this.checked.isSelected(); + }, + + setSelected: function (v) { + this.checked.setSelected(v); + } +}); +BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFolderItem + * @extends BI.Single + */ +BI.FileManagerFolderItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", + height: 30 + }) + }, + + _init: function () { + BI.FileManagerFolderItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button = BI.createWidget({ + type: "bi.text_button", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); + }); + + this.tree = new BI.Tree(); + this.tree.initTree([{ + id: o.id, + children: o.children + }]); + this.selectValue = []; + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-folder-font" + }, + width: 20 + }, { + el: this.button + }] + }) + }, + + setAllSelected: function (v) { + this.checked.setSelected(v); + this.selectValue = []; + }, + + setHalfSelected: function (v) { + this.checked.setHalfSelected(v); + if(!v){ + this.selectValue = []; + } + }, + + setValue: function (v) { + var self = this, o = this.options; + var isHalf = false; + var selectValue = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + if (BI.contains(v, node.get("data").value)) { + selectValue.push(node.get("data").value); + } else { + isHalf = true; + } + } + }); + this.setAllSelected(selectValue.length > 0 && !isHalf); + this.setHalfSelected(selectValue.length > 0 && isHalf); + if (this.checked.isHalfSelected()) { + this.selectValue = selectValue; + } + }, + + getAllButtons: function () { + return [this]; + }, + + getAllLeaves: function () { + var o = this.options; + var res = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value) + } + }); + return res; + }, + + getNotSelectedValue: function () { + var self = this, o = this.options; + var res = []; + var isAllSelected = this.checked.isSelected(); + if (isAllSelected === true) { + return res; + } + var isHalfSelected = this.checked.isHalfSelected(); + this.tree.traverse(function (node) { + if (node.isLeaf()) { + var v = node.get("data").value; + if (isHalfSelected === true) { + if (!BI.contains(self.selectValue, node.get("data").value)) { + res.push(v); + } + } else { + res.push(v); + } + } + }); + return res; + }, + + getValue: function () { + var res = []; + if (this.checked.isSelected()) { + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + } + if (this.checked.isHalfSelected()) { + return this.selectValue; + } + return []; + } +}); +BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** + * 文件管理控件列表 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerList + * @extends BI.Widget + */ +BI.FileManagerList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-list", + el: {}, + items: [] + }) + }, + + _init: function () { + BI.FileManagerList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.select_list", + element: this, + items: o.items, + toolbar: { + type: "bi.multi_select_bar", + height: 40, + text: "" + }, + el: { + type: "bi.list_pane", + el: BI.isWidget(o.el) ? o.el : BI.extend({ + type: "bi.file_manager_button_group" + }, o.el) + } + }); + this.list.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + this.list.setValue({ + value: v + }); + }, + + getValue: function () { + return this.list.getValue(); + }, + + populate: function (items) { + this.list.populate(items); + this.list.setToolBarVisible(true); + } +}); +BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** + * 文件管理导航按钮 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNavButton + * @extends BI.Widget + */ +BI.FileManagerNavButton = BI.inherit(BI.Widget, { + + _const: { + normal_color: "#ffffff", + select_color: "#eff1f4" + }, + _defaultConfig: function () { + return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav-button", + selected: false, + height: 40 + }) + }, + + _init: function () { + BI.FileManagerNavButton.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.button = BI.createWidget({ + type: "bi.text_button", + cls: "file-manager-nav-button-text bi-card", + once: true, + selected: o.selected, + text: o.text, + title: o.text, + value: o.value, + height: o.height, + lgap: 20, + rgap: 10 + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + var svg = BI.createWidget({ + type: "bi.svg", + cls: "file-manager-nav-button-triangle", + width: 15, + height: o.height + }); + var path = svg.path("M0,0L15,20L0,40").attr({ + "stroke": c.select_color, + "fill": o.selected ? c.select_color : c.normal_color + }); + this.button.on(BI.TextButton.EVENT_CHANGE, function () { + if (this.isSelected()) { + path.attr("fill", c.select_color); + } else { + path.attr("fill", c.normal_color); + } + }); + BI.createWidget({ + type: "bi.default", + element: this, + items: [this.button] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: svg, + right: -15, + top: 0, + bottom: 0 + }] + }) + }, + + isSelected: function () { + return this.button.isSelected(); + }, + + setValue: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + return this.button.getValue(); + }, + + populate: function (items) { + + } +}); +BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** + * 文件管理导航 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNav + * @extends BI.Widget + */ +BI.FileManagerNav = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav bi-border-left", + height: 40, + items: [] + }) + }, + + _init: function () { + BI.FileManagerNav.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + this.refreshTreeData(o.items); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: [{ + type: "bi.file_manager_nav_button", + text: BI.i18nText("BI-Created_By_Me"), + selected: true, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME, + value: BI.FileManagerNav.ROOT_CREATE_BY_ME + }], + layouts: [{ + type: "bi.horizontal" + }] + }); + 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.FileManagerNav.EVENT_CHANGE, arguments); + }); + }, + + _getAllParents: function (id) { + var node, res = []; + if (!id) { + node = this.tree.getRoot(); + } else { + node = this.tree.search(id); + } + while (node.parent) { + res.push(node); + node = node.parent; + } + res.push(node); + return res.reverse(); + }, + + _formatNodes: function (nodes) { + var res = []; + BI.each(nodes, function (i, node) { + res.push(BI.extend({ + type: "bi.file_manager_nav_button", + id: node.id + }, node.get("data"))); + }); + BI.last(res).selected = true; + return res; + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getId: function () { + var ids = []; + BI.each(this.button_group.getSelectedButtons(), function (i, btn) { + ids.push(btn.attr("id")); + }); + return ids; + }, + + refreshTreeData: function(items){ + this.tree.initTree(BI.Tree.transformToTreeFormat(items)); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + }, + + populate: function (node) { + var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); + this.button_group.populate(this._formatNodes(parents)); + } +}); +BI.extend(BI.FileManagerNav, { + ROOT_CREATE_BY_ME: "-1" +}); +BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** + * 交互行为布局 + * + * + * Created by GUY on 2016/7/23. + * @class BI.InteractiveArrangement + * @extends BI.Widget + */ +BI.InteractiveArrangement = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.InteractiveArrangement.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-interactive-arrangement", + resizable: true, + layoutType: BI.Arrangement.LAYOUT_TYPE.GRID, + items: [] + }); + }, + + _init: function () { + BI.InteractiveArrangement.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.arrangement = BI.createWidget({ + type: "bi.adaptive_arrangement", + element: this, + resizable: o.resizable, + layoutType: o.layoutType, + items: o.items + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_SCROLL, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_SCROLL, arguments); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_RESIZE, function () { + self.fireEvent(BI.InteractiveArrangement.EVENT_RESIZE, arguments); + }); + + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_RESIZE, function (id, size) { + var p = self._getRegionClientPosition(id); + self.draw({ + left: p.left, + top: p.top + }, size, id); + }); + this.arrangement.on(BI.AdaptiveArrangement.EVENT_ELEMENT_STOP_RESIZE, function (id, size) { + self.stopDraw(); + self.setRegionSize(id, size); + }); + + this.tags = []; + + }, + + _isEqual: function (num1, num2) { + return this.arrangement._isEqual(num1, num2); + }, + + _getScrollOffset: function () { + return this.arrangement._getScrollOffset(); + }, + + _positionAt: function (position, regions) { + var self = this; + regions = regions || this.getAllRegions(); + var left = [], center = [], right = [], top = [], middle = [], bottom = []; + BI.each(regions, function (i, region) { + var client = self._getRegionClientPosition(region.id); + if (Math.abs(client.left - position.left) <= 3) { + left.push(region); + } + if (Math.abs(client.left + client.width / 2 - position.left) <= 3) { + center.push(region); + } + if (Math.abs(client.left + client.width - position.left) <= 3) { + right.push(region); + } + if (Math.abs(client.top - position.top) <= 3) { + top.push(region); + } + if (Math.abs(client.top + client.height / 2 - position.top) <= 3) { + middle.push(region); + } + if (Math.abs(client.top + client.height - position.top) <= 3) { + bottom.push(region); + } + }); + return { + left: left, + center: center, + right: right, + top: top, + middle: middle, + bottom: bottom + } + }, + + _getRegionClientPosition: function (name) { + var region = this.getRegionByName(name); + var offset = this.arrangement._getScrollOffset(); + return { + top: region.top - offset.top, + left: region.left - offset.left, + width: region.width, + height: region.height, + id: region.id + } + }, + + _vAlign: function (position, regions) { + var self = this; + var vs = this._positionAt(position, regions); + var positions = []; + var l; + if (vs.left.length > 0) { + l = this._getRegionClientPosition(vs.left[0].id).left; + } else if (vs.right.length > 0) { + var temp = this._getRegionClientPosition(vs.right[0].id); + l = temp.left + temp.width; + } else if (vs.center.length > 0) { + var temp = this._getRegionClientPosition(vs.center[0].id); + l = temp.left + temp.width / 2; + } + var rs = vs.left.concat(vs.right).concat(vs.center); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.left, l) || self._isEqual(p.left + p.width, l) || self._isEqual(p.left + p.width / 2, l)) { + var topPoint = { + top: p.top + p.height / 2, + left: l + }; + positions.push({ + id: region.id, + start: topPoint, + end: { + left: l, + top: position.top + } + }); + } + }); + return positions; + }, + + _leftAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left, + top: position.top + size.height / 2 + }, regions); + }, + + _rightAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width, + top: position.top + size.height / 2 + }, regions); + }, + + _hAlign: function (position, regions) { + var self = this; + var hs = this._positionAt(position, regions); + var positions = []; + var t; + if (hs.top.length > 0) { + var temp = this._getRegionClientPosition(hs.top[0].id); + t = temp.top; + } else if (hs.bottom.length > 0) { + var temp = this._getRegionClientPosition(hs.bottom[0].id); + t = temp.top + temp.height; + } else if (hs.middle.length > 0) { + var temp = this._getRegionClientPosition(hs.middle[0].id); + t = temp.top + temp.height / 2; + } + var rs = hs.top.concat(hs.bottom).concat(hs.middle); + BI.each(rs, function (i, region) { + var p = self._getRegionClientPosition(region.id); + if (self._isEqual(p.top, t) || self._isEqual(p.top + p.height, t) || self._isEqual(p.top + p.height / 2, t)) { + var leftPoint = { + top: t, + left: p.left + p.width / 2 + }; + positions.push({ + id: p.id, + start: leftPoint, + end: { + left: position.left, + top: t + } + }); + } + }); + return positions; + }, + + _topAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + }, regions); + }, + + _bottomAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height + }, regions); + }, + + _centerAlign: function (position, size, regions) { + var self = this; + return this._vAlign({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + }, + + _middleAlign: function (position, size, regions) { + var self = this; + return this._hAlign({ + left: position.left + size.width / 2, + top: position.top + size.height / 2 + }, regions); + }, + + + _drawOneTag: function (start, end) { + var s = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + var e = BI.createWidget({ + type: "bi.icon_button", + //invisible: true, + width: 13, + height: 13, + cls: "drag-tag-font interactive-arrangement-dragtag-icon" + }); + if (this._isEqual(start.left, end.left)) { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + width: 1, + height: Math.abs(start.top - end.top) + }); + } else { + var line = BI.createWidget({ + type: "bi.layout", + //invisible: true, + cls: "interactive-arrangement-dragtag-line", + height: 1, + width: Math.abs(start.left - end.left) + }); + } + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: s, + left: start.left - 6, + top: start.top - 7 + }, { + el: e, + left: end.left - 6, + top: end.top - 7 + }, { + el: line, + left: Math.min(start.left, end.left), + top: Math.min(start.top, end.top) + }] + }); + this.tags.push(s); + this.tags.push(e); + this.tags.push(line); + }, + + stopDraw: function () { + BI.each(this.tags, function (i, w) { + w.destroy(); + }); + this.tags = []; + }, + + _getRegionExcept: function (name, regions) { + var other = []; + BI.each(regions || this.getAllRegions(), function (i, region) { + if (!(name && region.id === name)) { + other.push(region); + } + }); + return other; + }, + + getClientWidth: function () { + return this.arrangement.getClientWidth(); + }, + + getClientHeight: function () { + return this.arrangement.getClientHeight(); + }, + + getPosition: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + position.left = pos.end.left - size.width / 2; + }); + BI.each(right, function (i, pos) { + position.left = pos.end.left - size.width; + }); + BI.each(left, function (i, pos) { + position.left = pos.end.left; + }); + BI.each(middle, function (i, pos) { + position.top = pos.end.top - size.height / 2; + }); + BI.each(bottom, function (i, pos) { + position.top = pos.end.top - size.height; + }); + BI.each(top, function (i, pos) { + position.top = pos.end.top; + }); + return position; + }, + + //position不动 变size + getSize: function (name, position, size) { + var regions = this.getAllRegions(); + var me; + if (name) { + me = this._getRegionClientPosition(name); + } + var other = this._getRegionExcept(name, regions); + position = position || { + left: me.left, + top: me.top + }; + size = size || { + width: me.width, + height: me.height + }; + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + size.width = (pos.end.left - position.left) * 2; + }); + BI.each(right, function (i, pos) { + size.width = pos.end.left - position.left; + }); + BI.each(left, function (i, pos) { + }); + BI.each(middle, function (i, pos) { + size.height = (pos.end.top - position.top) * 2; + }); + BI.each(bottom, function (i, pos) { + size.height = pos.end.top - position.top; + }); + BI.each(top, function (i, pos) { + }); + return size; + }, + + draw: function (position, size, name) { + var self = this; + this.stopDraw(); + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + var other = this._getRegionExcept(name); + var left = this._leftAlign(position, size, other); + var right = this._rightAlign(position, size, other); + var top = this._topAlign(position, size, other); + var bottom = this._bottomAlign(position, size, other); + var center = this._centerAlign(position, size, other); + var middle = this._middleAlign(position, size, other); + + BI.each(center, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(right, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(left, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(middle, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(bottom, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + BI.each(top, function (i, pos) { + self._drawOneTag(pos.start, pos.end); + }); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + }, + + addRegion: function (region, position) { + this.stopDraw(); + return this.arrangement.addRegion(region, position); + }, + + deleteRegion: function (name) { + return this.arrangement.deleteRegion(name); + }, + + setRegionSize: function (name, size) { + size = this.getSize(name, null, size); + return this.arrangement.setRegionSize(name, size); + }, + + setPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var at = this.arrangement.setPosition(position, size); + return at; + }, + + setRegionPosition: function (name, position) { + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(name, position); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + return this.arrangement.setRegionPosition(name, position); + }, + + setDropPosition: function (position, size) { + var self = this; + this.stopDraw(); + if (position.left > 0 && position.top > 0) { + switch (this.getLayoutType()) { + case BI.Arrangement.LAYOUT_TYPE.FREE: + position = this.getPosition(null, position, size); + this.draw(position, size); + break; + case BI.Arrangement.LAYOUT_TYPE.GRID: + break; + } + } + var callback = self.arrangement.setDropPosition(position, size); + return function () { + callback(); + self.stopDraw(); + } + }, + + scrollInterval: function () { + this.arrangement.scrollInterval.apply(this.arrangement, arguments); + }, + + scrollEnd: function () { + this.arrangement.scrollEnd.apply(this.arrangement, arguments); + }, + + scrollTo: function (scroll) { + this.arrangement.scrollTo(scroll); + }, + + zoom: function (ratio) { + this.arrangement.zoom(ratio); + }, + + resize: function () { + return this.arrangement.resize(); + }, + + relayout: function () { + return this.arrangement.relayout(); + }, + + setLayoutType: function (type) { + this.arrangement.setLayoutType(type); + }, + + getLayoutType: function () { + return this.arrangement.getLayoutType(); + }, + + getLayoutRatio: function () { + return this.arrangement.getLayoutRatio(); + }, + + getHelper: function () { + return this.arrangement.getHelper(); + }, + + getRegionByName: function (name) { + return this.arrangement.getRegionByName(name); + }, + + getAllRegions: function () { + return this.arrangement.getAllRegions(); + }, + + revoke: function () { + return this.arrangement.revoke(); + }, + + populate: function (items) { + var self = this; + this.arrangement.populate(items); + } +}); +BI.InteractiveArrangement.EVENT_RESIZE = "InteractiveArrangement.EVENT_RESIZE"; +BI.InteractiveArrangement.EVENT_SCROLL = "InteractiveArrangement.EVENT_SCROLL"; +BI.shortcut('bi.interactive_arrangement', BI.InteractiveArrangement);/** + * 月份下拉框 + * + * 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: 25 + }); + }, + _init: function () { + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.month_trigger" + }); + + 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 + }); + 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", + 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 () { + 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 = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; + 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 + 1 + }; + }); + }); + + 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 + }] + }); + + 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) { + 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, + triggerWidth: 25, + errorText: BI.i18nText("BI-Month_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-month-trigger bi-border", + height: 25 + }); + }, + _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: c.errorText + }); + 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: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + 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);/** + * 普通控件 + * + * @class BI.MultiDateCard + * @extends BI.Widget + * @abstract + */ +BI.MultiDateCard = BI.inherit(BI.Widget, { + + constants: { + lgap: 80, + itemHeight: 35, + defaultEditorValue: "1" + }, + + _defaultConfig: function () { + return $.extend(BI.MultiDateCard.superclass._defaultConfig.apply(this, arguments), {}); + }, + + dateConfig: function () { + + }, + + defaultSelectedItem: function () { + + }, + + _init: function () { + BI.MultiDateCard.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.label = BI.createWidget({ + type: 'bi.label', + height: this.constants.itemHeight, + textAlign: "left", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + cls: 'bi-multidate-inner-label bi-tips' + }); + this.radioGroup = BI.createWidget({ + type: "bi.button_group", + chooseType: 0, + items: BI.createItems(this.dateConfig(), { + type: 'bi.multidate_segment', + height: this.constants.itemHeight + }), + layouts: [{ + type: "bi.vertical" + }] + }); + + this.radioGroup.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CONFIRM) { + self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); + } + }); + this.radioGroup.on(BI.ButtonGroup.EVENT_CHANGE, function () { + self.setValue(self.getValue()); + self.fireEvent(BI.MultiDateCard.EVENT_CHANGE); + }); + BI.createWidget({ + element: this, + type: 'bi.center_adapt', + lgap: this.constants.lgap, + items: [{ + type: 'bi.vertical', + items: [this.label, this.radioGroup] + }] + }); + }, + + getValue: function () { + var button = this.radioGroup.getSelectedButtons()[0]; + var type = button.getValue(), value = button.getInputValue(); + return { + type: type, + value: value + } + }, + + _isTypeAvaliable: function (type) { + var res = false; + BI.find(this.dateConfig(), function (i, item) { + if (item.value === type) { + res = true; + return true; + } + }); + return res; + }, + + setValue: function (v) { + var self = this; + if (BI.isNotNull(v) && this._isTypeAvaliable(v.type)) { + this.radioGroup.setValue(v.type); + BI.each(this.radioGroup.getAllButtons(), function (i, button) { + if (button.isEditorExist() === true && button.isSelected()) { + button.setInputValue(v.value); + } else { + button.setInputValue(self.constants.defaultEditorValue); + } + }); + } else { + this.radioGroup.setValue(this.defaultSelectedItem()); + BI.each(this.radioGroup.getAllButtons(), function (i, button) { + button.setInputValue(self.constants.defaultEditorValue); + }); + } + }, + + getCalculationValue: function () { + var valueObject = this.getValue(); + var type = valueObject.type, value = valueObject.value; + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + return new Date().getOffsetDate(-1 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + return new Date().getOffsetDate(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + return new Date(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + return new Date().getBeforeMultiMonth(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + return new Date().getAfterMultiMonth(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + return new Date(new Date().getFullYear(), new Date().getMonth(), 1); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + return new Date(new Date().getFullYear(), new Date().getMonth(), (new Date().getLastDateOfMonth()).getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + return new Date().getBeforeMulQuarter(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + return new Date().getAfterMulQuarter(value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + return new Date().getQuarterStartDate(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + return new Date().getQuarterEndDate(); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + return new Date().getOffsetDate(-7 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + return new Date().getOffsetDate(7 * value); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + return new Date((new Date().getFullYear() - 1 * value), new Date().getMonth(), new Date().getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + return new Date((new Date().getFullYear() + 1 * value), new Date().getMonth(), new Date().getDate()); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + return new Date(new Date().getFullYear(), 0, 1); + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + return new Date(new Date().getFullYear(), 11, 31); + } + } +}); +BI.MultiDateCard.EVENT_CHANGE = "EVENT_CHANGE"; +/** + * 日期控件 + * @class BI.MultiDateCombo + * @extends BI.Widget + */ +BI.MultiDateCombo = 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" + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-combo bi-border', + height: 24 + }); + }, + _init: function () { + BI.MultiDateCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.storeTriggerValue = ""; + var date = new Date(); + this.storeValue = null; + this.trigger = BI.createWidget({ + type: 'bi.date_trigger', + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + this.trigger.on(BI.DateTrigger.EVENT_KEY_DOWN, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } + }); + this.trigger.on(BI.DateTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + this.trigger.on(BI.DateTrigger.EVENT_FOCUS, function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.MultiDateCombo.EVENT_FOCUS); + }); + this.trigger.on(BI.DateTrigger.EVENT_ERROR, function () { + self.storeValue = { + year: date.getFullYear(), + month: date.getMonth() + }; + self.popup.setValue(); + self.fireEvent(BI.MultiDateCombo.EVENT_ERROR); + }); + this.trigger.on(BI.DateTrigger.EVENT_VALID, function () { + self.fireEvent(BI.MultiDateCombo.EVENT_VALID); + }); + this.trigger.on(BI.DateTrigger.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); + }); + this.trigger.on(BI.DateTrigger.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()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup = BI.createWidget({ + type: "bi.multidate_popup", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE + }); + this.popup.on(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE, function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE, function () { + var date = new Date(); + self.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.popup.on(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + //self.fireEvent(BI.MultiDateCombo.EVENT_CHANGE); + self.fireEvent(BI.MultiDateCombo.EVENT_CONFIRM); + }); + this.combo = BI.createWidget({ + type: 'bi.combo', + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + maxHeight: this.constants.popupHeight, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW); + }); + + var triggerBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: 30, + height: 23 + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + this.changeIcon = BI.createWidget({ + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 30, + height: 23 + }); + + + var leftPart = BI.createWidget({ + type: "bi.absolute", + items: [{ + el: this.combo, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: triggerBtn, + top: 0, + left: 0 + }] + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [leftPart, { + el: this.changeIcon, + width: 30 + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }) + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type + } + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[1].width = 30; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[1].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.popup.setValue(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.shortcut('bi.multidate_combo', BI.MultiDateCombo); + +BI.MultiDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MultiDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.MultiDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiDateCombo.EVENT_VALID = "EVENT_VALID"; +BI.MultiDateCombo.EVENT_ERROR = "EVENT_ERROR"; +BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW"; + +BI.extend(BI.MultiDateCombo, { + MULTI_DATE_YMD_CARD: 1, + MULTI_DATE_YEAR_CARD: 2, + MULTI_DATE_QUARTER_CARD: 3, + MULTI_DATE_MONTH_CARD: 4, + MULTI_DATE_WEEK_CARD: 5, + MULTI_DATE_DAY_CARD: 6 +}); + +BI.extend(BI.MultiDateCombo, { + DATE_TYPE: { + MULTI_DATE_YEAR_PREV: 1, + MULTI_DATE_YEAR_AFTER: 2, + MULTI_DATE_YEAR_BEGIN: 3, + MULTI_DATE_YEAR_END: 4, + MULTI_DATE_MONTH_PREV: 5, + MULTI_DATE_MONTH_AFTER: 6, + MULTI_DATE_MONTH_BEGIN: 7, + MULTI_DATE_MONTH_END: 8, + MULTI_DATE_QUARTER_PREV: 9, + MULTI_DATE_QUARTER_AFTER: 10, + MULTI_DATE_QUARTER_BEGIN: 11, + MULTI_DATE_QUARTER_END: 12, + MULTI_DATE_WEEK_PREV: 13, + MULTI_DATE_WEEK_AFTER: 14, + MULTI_DATE_DAY_PREV: 15, + MULTI_DATE_DAY_AFTER: 16, + MULTI_DATE_DAY_TODAY: 17, + MULTI_DATE_PARAM: 18, + MULTI_DATE_CALENDAR: 19, + YEAR_QUARTER: 20, + YEAR_MONTH: 21, + YEAR_WEEK: 22, + YEAR_DAY: 23, + MONTH_WEEK: 24, + MONTH_DAY: 25, + YEAR: 26, + SAME_PERIOD: 27, + LAST_SAME_PERIOD: 28 + } +}); +/** + * 普通控件 + * + * @class BI.DayCard + * @extends BI.MultiDateCard + */ +BI.DayCard = BI.inherit(BI.MultiDateCard, { + + _defaultConfig: function () { + return $.extend(BI.DayCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-daycard' + }); + }, + + _init: function () { + BI.DayCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + isEditorExist: true, + selected: true, + text: BI.i18nText("BI-Multi_Date_Day_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Day_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY, + text: BI.i18nText("BI-Multi_Date_Today") + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV + } +}); +BI.DayCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.daycard', BI.DayCard); +/** + * 普通控件 + * + * @class BI.MonthCard + * @extends BI.MultiDateCard + */ +BI.MonthCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.MonthCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-monthcard' + }); + }, + + _init: function () { + BI.MonthCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV, + text: BI.i18nText("BI-Multi_Date_Month_Prev") + }, + { + isEditorExist: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER, + text: BI.i18nText("BI-Multi_Date_Month_Next") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Month_Begin") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Month_End") + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV; + } +}); +BI.MonthCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.monthcard', BI.MonthCard); +/** + * 日期控件 + * @class BI.MultiDatePopup + * @extends BI.Widget + */ +BI.MultiDatePopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + tabWidth: 42, + titleHeight: 27, + itemHeight: 30, + triggerHeight: 24, + buttonWidth: 90, + buttonHeight: 25, + cardHeight: 229, + cardWidth: 270, + popupHeight: 259, + popupWidth: 270, + comboAdjustHeight: 1, + ymdWidth: 58, + lgap: 2, + border: 1 + }, + _defaultConfig: function () { + return BI.extend(BI.MultiDatePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-popup', + width: 268, + height: 260 + }); + }, + _init: function () { + BI.MultiDatePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.storeValue = ""; + this.textButton = BI.createWidget({ + type: 'bi.text_button', + forceCenter: true, + cls: 'bi-multidate-popup-label bi-border-left bi-border-right bi-border-top', + shadow: true, + text: BI.i18nText("BI-Multi_Date_Today") + }); + this.textButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE); + }); + this.clearButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: 'bi-multidate-popup-button bi-border-top', + shadow: true, + text: BI.i18nText("BI-Basic_Clear") + }); + this.clearButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE); + }); + this.okButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: 'bi-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.MultiDatePopup.BUTTON_OK_EVENT_CHANGE); + }); + this.dateTab = BI.createWidget({ + type: 'bi.tab', + tab: { + cls: "bi-multidate-popup-tab bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.MultiDateCombo.MULTI_DATE_YMD_CARD, + width: this.constants.ymdWidth + }, { + text: BI.i18nText("BI-Multi_Date_Year"), + value: BI.MultiDateCombo.MULTI_DATE_YEAR_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Quarter"), + value: BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Month"), + value: BI.MultiDateCombo.MULTI_DATE_MONTH_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Week"), + value: BI.MultiDateCombo.MULTI_DATE_WEEK_CARD + }, { + text: BI.i18nText("BI-Multi_Date_Day"), + value: BI.MultiDateCombo.MULTI_DATE_DAY_CARD + }], { + width: this.constants.tabWidth, + textAlign: "center", + height: this.constants.itemHeight, + cls: 'bi-multidate-popup-item bi-list-item-active' + }), + layouts: [{ + type: 'bi.left' + }] + }, + cardCreator: function (v) { + switch (v) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + self.ymd = BI.createWidget({ + type: "bi.date_calendar_popup", + min: self.options.min, + max: self.options.max + }); + self.ymd.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiDatePopup.CALENDAR_EVENT_CHANGE); + }); + return self.ymd; + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + self.year = BI.createWidget({ + type: "bi.yearcard" + }); + self.year.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.year, v); + }); + return self.year; + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + self.quarter = BI.createWidget({ + type: 'bi.quartercard' + }); + self.quarter.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.quarter, v); + }); + return self.quarter; + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + self.month = BI.createWidget({ + type: 'bi.monthcard' + }); + self.month.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.month, v); + }); + return self.month; + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + self.week = BI.createWidget({ + type: 'bi.weekcard' + }); + self.week.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.week, v); + }); + return self.week; + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + self.day = BI.createWidget({ + type: 'bi.daycard' + }); + self.day.on(BI.MultiDateCard.EVENT_CHANGE, function (v) { + self._setInnerValue(self.day, v); + }); + return self.day; + } + } + }); + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_YMD_CARD; + this.dateTab.on(BI.Tab.EVENT_CHANGE, function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + var date = this.getTab(self.cur).getCalculationValue(); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + self._setInnerValue(self.ymd); + break; + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + self.year.setValue(self.storeValue); + self._setInnerValue(self.year); + break; + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + self.quarter.setValue(self.storeValue); + self._setInnerValue(self.quarter); + break; + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + self.month.setValue(self.storeValue); + self._setInnerValue(self.month); + break; + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + self.week.setValue(self.storeValue); + self._setInnerValue(self.week); + break; + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + self.day.setValue(self.storeValue); + self._setInnerValue(self.day); + break; + } + self.cur = v; + }); + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.clearButton, this.textButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateTab + }, { + el: this.dateButton, + height: 30 + }] + }); + }, + _setInnerValue: function (obj) { + if (this.dateTab.getSelect() === BI.MultiDateCombo.MULTI_DATE_YMD_CARD) { + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.textButton.setEnable(true); + } else { + var date = obj.getCalculationValue(); + date = date.print("%Y-%x-%e"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + setValue: function (v) { + this.storeValue = v; + var self = this, date; + var type, value; + if (BI.isNotNull(v)) { + type = v.type || BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_CALENDAR; + value = v.value; + if (BI.isNull(value)) { + value = v; + } + } + switch (type) { + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YEAR_CARD); + this.year.setValue({type: type, value: value}); + this.cur = BI.MultiDateCombo.MULTI_DATE_YEAR_CARD; + self._setInnerValue(this.year); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD; + this.quarter.setValue({type: type, value: value}); + self._setInnerValue(this.quarter); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_BEGIN: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_MONTH_END: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_MONTH_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_MONTH_CARD; + this.month.setValue({type: type, value: value}); + self._setInnerValue(this.month); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_WEEK_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_WEEK_CARD; + this.week.setValue({type: type, value: value}); + self._setInnerValue(this.week); + break; + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_PREV: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_AFTER: + case BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_DAY_TODAY: + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_DAY_CARD); + this.cur = BI.MultiDateCombo.MULTI_DATE_DAY_CARD; + this.day.setValue({type: type, value: value}); + self._setInnerValue(this.day); + break; + default: + if (BI.isNull(value) || BI.isEmptyObject(value)) { + var date = new Date(); + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth(), + day: date.getDate() + }); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } else { + this.dateTab.setSelect(BI.MultiDateCombo.MULTI_DATE_YMD_CARD); + this.ymd.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } + this.textButton.setEnable(true); + break; + } + }, + getValue: function () { + var tab = this.dateTab.getSelect(); + switch (tab) { + case BI.MultiDateCombo.MULTI_DATE_YMD_CARD: + return this.ymd.getValue(); + case BI.MultiDateCombo.MULTI_DATE_YEAR_CARD: + return this.year.getValue(); + case BI.MultiDateCombo.MULTI_DATE_QUARTER_CARD: + return this.quarter.getValue(); + case BI.MultiDateCombo.MULTI_DATE_MONTH_CARD: + return this.month.getValue(); + case BI.MultiDateCombo.MULTI_DATE_WEEK_CARD: + return this.week.getValue(); + case BI.MultiDateCombo.MULTI_DATE_DAY_CARD: + return this.day.getValue(); + } + } +}); +BI.MultiDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.MultiDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.MultiDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.MultiDatePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; +BI.shortcut('bi.multidate_popup', BI.MultiDatePopup); +/** + * 普通控件 + * + * @class BI.QuarterCard + * @extends BI.MultiDateCard + */ +BI.QuarterCard = BI.inherit(BI.MultiDateCard, { + + _defaultConfig: function () { + return $.extend(BI.QuarterCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-quartercard' + }); + }, + + _init: function () { + BI.QuarterCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Quarter_Prev") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_AFTER, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Quarter_Next") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_BEGIN, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Quarter_Begin") + }, + { + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_END, + isEditorExist: false, + text: BI.i18nText("BI-Multi_Date_Quarter_End") + }] + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_QUARTER_PREV; + } +}); +BI.QuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.quartercard', BI.QuarterCard); +/** + * 普通控件 + * + * @class BI.MultiDateSegment + * @extends BI.Single + */ +BI.MultiDateSegment = BI.inherit(BI.Single, { + constants: { + itemHeight: 24, + maxGap: 15, + minGap: 10, + textWidth: 30, + defaultEditorValue: "1" + }, + + _defaultConfig: function () { + return $.extend(BI.MultiDateSegment.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-segment', + text: "", + width: 130, + height: 30, + isEditorExist: true, + selected: false, + defaultEditorValue: "1" + }); + }, + + _init: function () { + BI.MultiDateSegment.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.radio = BI.createWidget({ + type: "bi.radio", + selected: opts.selected + }); + this.radio.on(BI.Controller.EVENT_CHANGE, function (v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textEditor = BI.createWidget({ + type: 'bi.text_editor', + value: this.constants.defaultEditorValue, + title: function () { + return self.textEditor.getValue(); + }, + tipType: "success", + cls: 'bi-multidate-editor', + width: this.constants.textWidth, + height: this.constants.itemHeight + }); + this.textEditor.on(BI.Controller.EVENT_CHANGE, function (v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + cls: 'bi-multidate-normal-label', + text: opts.text, + height: this.constants.itemHeight + }); + this._createSegment(); + }, + _createSegment: function () { + if (this.options.isEditorExist === true) { + return BI.createWidget({ + element: this, + type: 'bi.left', + items: [{ + el: { + type: "bi.center_adapt", + items: [this.radio], + height: this.constants.itemHeight + }, + lgap: 0 + }, + { + el: { + type: "bi.center_adapt", + items: [this.textEditor], + widgetName: 'textEditor' + }, + lgap: this.constants.maxGap + }, + { + el: this.text, + lgap: this.constants.minGap + }] + }); + } + return BI.createWidget({ + element: this, + type: 'bi.left', + items: [{ + el: { + type: "bi.center_adapt", + items: [this.radio], + height: this.constants.itemHeight + }, + lgap: 0 + }, + { + el: this.text, + lgap: this.constants.maxGap + }] + }) + }, + setSelected: function (v) { + if (BI.isNotNull(this.radio)) { + this.radio.setSelected(v); + this.textEditor.setEnable(v); + } + }, + isSelected: function () { + return this.radio.isSelected(); + }, + getValue: function () { + return this.options.value; + }, + getInputValue: function () { + return this.textEditor.getValue() | 0; + }, + setInputValue: function (v) { + this.textEditor.setValue(v); + }, + isEditorExist: function () { + return this.options.isEditorExist; + } +}); +BI.MultiDateSegment.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multidate_segment', BI.MultiDateSegment);/** + * 普通控件 + * + * @class BI.WeekCard + * @extends BI.MultiDateCard + */ +BI.WeekCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.WeekCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-weekcard' + }); + }, + + _init: function () { + BI.WeekCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Week_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Week_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_AFTER + }]; + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_WEEK_PREV; + } +}); +BI.WeekCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.weekcard', BI.WeekCard); +/** + * 普通控件 + * + * @class BI.YearCard + * @extends BI.MultiDateCard + */ +BI.YearCard = BI.inherit(BI.MultiDateCard, { + _defaultConfig: function () { + return $.extend(BI.YearCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multidate-yearcard' + }); + }, + + _init: function () { + BI.YearCard.superclass._init.apply(this, arguments); + }, + + dateConfig: function () { + return [{ + selected: true, + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Year_Prev"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV + }, + { + isEditorExist: true, + text: BI.i18nText("BI-Multi_Date_Year_Next"), + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_AFTER + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_BEGIN, + text: BI.i18nText("BI-Multi_Date_Year_Begin") + }, + { + isEditorExist: false, + value: BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_END, + text: BI.i18nText("BI-Multi_Date_Year_End") + }] + }, + + defaultSelectedItem: function () { + return BI.MultiDateCombo.DATE_TYPE.MULTI_DATE_YEAR_PREV; + } +}); +BI.YearCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.yearcard', BI.YearCard); +/** + * @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: 30, + text: "", + items: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_select_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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 + }) + }, + + _init: function () { + BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_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", + element: this, + 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, + + 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); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + 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.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: [] + }); + }, + + _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, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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: 25 + }) + }, + _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 items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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/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: 30, + text: "", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_single_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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 + }) + }, + + _init: function () { + BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_single_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_single_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_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", + element: this, + expander: { + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback(BI.Tree.transformToTreeFormat(items), 0) + }) + }, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + 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); + } + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + 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.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 + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + 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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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 + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +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: 25 + }) + }, + _init: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = 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 + }); + this.node.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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** + * + * 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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25 + }) + }, + _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 + }); + 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", + cls: "base-line-conn-background", + width: 13, + height: o.height + }) + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 13), + 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.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: 25, + lgap: 10, + tgap: 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 = {}; + 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.left', + cls: 'multi-select-continue-select', + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText('BI-Selected_Data') + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: this.continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + } + }, { + height: 'fill', + el: this.display + }] + }); + }, + + 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: 25, + 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 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: 28 + }); + }, + + _init: function () { + BI.MultiSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = {}; + //标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: { + left: 1, + top: 1, + right: 2, + bottom: 33 + } + }, + 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); + }); + } + }); + + 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 () { + //如果在不选的状态下直接把该值添加进来 + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + 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, + 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(); + }); + } + }, + 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 bi-border-left" + }); + 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.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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.pluck(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.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); + 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.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: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut('bi.multi_select_combo', BI.MultiSelectCombo);/** + * 多选加载数据面板 + * 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.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) && !self.storeValue.value.contains(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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + 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.MultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 25, + selected: this.isAllSelected() + }) + }, + + _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) { + 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.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut('bi.multi_select_loader', BI.MultiSelectLoader);/** + * 带加载的多选下拉面板 + * @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 + }); + + 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 + }); + + 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.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, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker + }); + 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 + }); + 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: 30 + }] + }); + + 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.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + 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);/** + * 多选加载数据搜索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.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: { + dynamic: false + }, + 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: 25, + selected: this.isAllSelected() + }) + }, + + 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.matched.concat(search.finded); + } + 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: 25, + 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()); + }]); + } + }); + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-check-selected-button bi-high-light', + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.numberCounter = BI.createWidget({ + type: 'bi.text_button', + element: this, + hgap: 4, + text: "0", + textAlign: 'center', + textHeight: 15 + }); + 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(self._const.checkSelected); + }, function () { + self.numberCounter.setText(self.numberCounter.getTag()); + }); + this.setVisible(false); + }, + + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _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 + }); + + 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); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } else { + 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.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: {} + }); + }, + + _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 + }); + + 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) { + op.keyword = self.editor.getValue(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); + } + }, 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); + }); + }, + + 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 (BI.size(ob.assist) === 1) { + this.editor.setState(o.valueFormatter(ob.assist[0] + "") || (ob.assist[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } + } else { + if (BI.size(ob.value) === 1) { + this.editor.setState(o.valueFormatter(ob.value[0] + "") || (ob.value[0] + "")); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + } + }, + + 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 + }); + 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(); + } + }, 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.MultiSelectList = BI.inherit(BI.Widget, { + _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.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](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.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + 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 () { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword) + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }) + } else { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword) + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self.adapter.populate(); + if (self.storeValue.type === BI.Selection.Multi) { + 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: 30 + }, { + 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.MultiSelectList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.pluck(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.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](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, + keyword: self.trigger.getKeyword() + }, function (ob) { + var items = BI.pluck(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: 0, + 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.Widget, { + _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: 30 + }, { + 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); + }, + + 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); + } + }); + + 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: 1, + left: 1, + right: 2, + bottom: 33 + } + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-tree-combo', + itemsCreator: BI.emptyFn, + height: 25 + }); + }, + + _init: function () { + BI.MultiTreeCombo.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + var isInit = false; + var want2showCounter = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + // adapter: this.popup, + masker: { + offset: this.constants.offset + }, + searcher: { + type: "bi.multi_tree_searcher", + itemsCreator: o.itemsCreator + }, + switcher: { + el: { + type: "bi.multi_tree_check_selected_button" + }, + popup: { + type: "bi.multi_tree_check_pane", + itemsCreator: o.itemsCreator + } + } + + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + 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() ? {1: 1} : {} + }; + 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(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.storeValue = {value: {}}; + 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 val = { + type: BI.Selection.Multi, + value: this.getSearcher().hasChecked() ? {1: 1} : {} + }; + this.getSearcher().setState(val); + 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 bi-border-left" + }); + 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 + }); + + 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); + } + }); + + 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, { + + _const: { + checkSelected: BI.i18nText('BI-Check_Selected') + }, + + _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', + width: 15, + height: 15, + stopPropagation: true + }); + + this.checkSelected = BI.createWidget({ + type: 'bi.text_button', + cls: "trigger-check-selected", + invisible: true, + hgap: 4, + text: this._const.checkSelected, + 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, + 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); + } + }, 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); + }); + }, + + 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) { + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.All); + } else { + this.editor.setState(BI.size(ob.value) > 0 ? BI.Selection.Multi : BI.Selection.None); + } + }, + + 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", + validationChecker: function () { + return true; + }, + valueFormatter: function (v) { + return v; + }, + value: 0, + 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, + value: o.valueFormatter(o.value), + validationChecker: o.validationChecker, + errorText: o.errorText + }); + this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { + o.value = this.getValue(); + self.fireEvent(BI.NumberEditor.EVENT_CHANGE); + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + 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,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + 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", + 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 + }] + }); + }, + + //微调 + _finetuning: function (add) { + var v = BI.parseFloat(this.getValue()); + this.setValue(v.add(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: 30, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "" + }, + _defaultConfig: function () { + var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments) + return BI.extend(conf, { + extraCls: "bi-number-interval", + height: 25, + validation: "valid" + }) + }, + _init: function () { + var self = this, c = this.constants, o = this.options; + BI.NumberInterval.superclass._init.apply(this, arguments) + this.smallEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + 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-top bi-border-bottom bi-border-left" + }); + + 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.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + 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-top bi-border-bottom bi-border-right" + }); + + 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", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "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", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconClass: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconClass: "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 * 2 + }] + + }); + this.right = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.bigCombo, + width: c.width - c.border * 2 + }, { + el: self.bigEditor + }] + }); + + + 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); + }, + + _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; + } else { + if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } else { + 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; + } else { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + } else { + 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; + } else { + 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: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + 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: "center" + }); + 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: "center" + }); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + 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: "center" + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "center" + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "center" + }); + break; + default : + break; + } + self.fireEvent(BI.NumberInterval.EVENT_CHANGE); + }); + }, + + _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_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); + } + }, + + + 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; + } +}); +BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; +BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.shortcut("bi.number_interval", BI.NumberInterval);/** + * + * 表格 + * + * Created by GUY on 2015/9/22. + * @class BI.PageTableCell + * @extends BI.Single + */ +BI.PageTableCell = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table-cell", + text: "", + title: "" + }) + }, + + _init: function () { + BI.PageTableCell.superclass._init.apply(this, arguments); + var label = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "nowrap", + height: this.options.height, + text: this.options.text, + title: this.options.title, + value: this.options.value, + lgap: 5, + rgap: 5 + }); + + if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { + this.element.css(this.options.styles); + } + } +}); + +BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** + * 分页表格 + * + * Created by GUY on 2016/2/15. + * @class BI.PageTable + * @extends BI.Widget + */ +BI.PageTable = BI.inherit(BI.Widget, { + + _const: { + scrollWidth: 18, + minScrollWidth: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table", + el: { + type: "bi.sequence_table" + }, + pager: { + 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 + } + }, + + itemsCreator: BI.emptyFn, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.PageTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.hCurr = 1; + this.vCurr = 1; + + this.table = BI.createWidget(o.el, { + type: "bi.sequence_table", + width: o.width, + height: o.height && o.height - 30, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.pager = BI.createWidget(o.pager, { + type: "bi.direction_pager", + height: 30 + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + var vpage = this.getVPage && this.getVPage(); + if (BI.isNull(vpage)) { + vpage = this.getCurrentPage(); + } + var hpage = this.getHPage && this.getHPage(); + o.itemsCreator({ + vpage: vpage, + hpage: hpage + }, function (items, header, crossItems, crossHeader) { + self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); + self.table.setHPage && self.table.setHPage(hpage); + self.populate.apply(self, arguments); + }); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.table, + left: 0, + top: 0 + }, { + el: this.pager, + left: 0, + right: 0, + bottom: 0 + }] + }) + }, + + setHPage: function (v) { + this.hCurr = v; + this.pager.setHPage && this.pager.setHPage(v); + this.table.setHPage && this.table.setHPage(v); + }, + + setVPage: function (v) { + this.vCurr = v; + this.pager.setVPage && this.pager.setVPage(v); + this.table.setVPage && this.table.setVPage(v); + }, + + getHPage: function () { + var hpage = this.pager.getHPage && this.pager.getHPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + return this.hpage; + }, + + getVPage: function () { + var vpage = this.pager.getVPage && this.pager.getVPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + return this.vpage; + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + var showPager = false; + if (this.pager.alwaysShowPager) { + showPager = true; + } else if (this.pager.hasHNext && this.pager.hasHNext()) { + showPager = true; + } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { + showPager = true; + } else if (this.pager.hasVNext && this.pager.hasVNext()) { + showPager = true; + } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { + showPager = true; + } else if (this.pager.hasNext && this.pager.hasNext()) { + showPager = true; + } else if (this.pager.hasPrev && this.pager.hasPrev()) { + showPager = true; + } + this.table.setHeight(height - (showPager ? 30 : 0)); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + restore: function () { + this.table.restore(); + }, + + attr: function () { + BI.PageTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function () { + this.pager.populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + this.pager && this.pager.destroy(); + BI.PageTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.page_table', BI.PageTable);/** + * 路径选择 + * + * Created by GUY on 2015/12/4. + * @class BI.PathChooser + * @extends BI.Widget + */ +BI.PathChooser = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#d4dadd", + selectLineColor: "#3f8ce8" + }, + + _defaultConfig: function () { + return BI.extend(BI.PathChooser.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-chooser", + items: [] + }) + }, + + _init: function () { + BI.PathChooser.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _createRegions: function (regions) { + var self = this; + this.regions = BI.createWidgets(BI.map(regions, function (i, region) { + return { + type: "bi.path_region", + title: self.texts[region] || region + } + })); + this.regionMap = {}; + BI.each(regions, function (i, region) { + self.regionMap[region] = i; + }); + this.container = BI.createWidget({ + type: "bi.horizontal", + verticalAlign: "top", + scrollx: false, + scrolly: false, + hgap: 10, + items: this.regions + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + scrollable: true, + hgap: 10, + items: [this.container] + }); + }, + + getRegionIndexById: function (id) { + var node = this.store[id]; + var regionType = node.get("region"); + return this.regionMap[regionType]; + }, + + _drawPath: function (start, offset, index) { + var self = this; + var starts = []; + if (BI.contains(this.start, start)) { + starts = this.start; + } else { + starts = [start]; + } + + BI.each(starts, function (i, s) { + BI.each(self.radios[s], function (i, rad) { + rad.setSelected(false); + }); + BI.each(self.lines[s], function (i, line) { + line.attr("stroke", self._const.lineColor); + }); + BI.each(self.regionIndexes[s], function (i, idx) { + self.regions[idx].reset(); + }); + }); + + BI.each(this.routes[start][index], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(offset + index, id); + }); + var current = BI.last(this.routes[start][index]); + + while (current && this.routes[current] && this.routes[current].length === 1) { + BI.each(this.routes[current][0], function (i, id) { + var regionIndex = self.getRegionIndexById(id); + self.regions[regionIndex].setSelect(0, id); + }); + this.lines[current][0].attr("stroke", self._const.selectLineColor).toFront(); + current = BI.last(this.routes[current][0]); + } + this.lines[start][index].attr("stroke", self._const.selectLineColor).toFront(); + this.radios[start] && this.radios[start][index] && this.radios[start][index].setSelected(true); + }, + + _drawRadio: function (start, offset, index, x, y) { + var self = this; + var radio = BI.createWidget({ + type: "bi.radio", + cls: "path-chooser-radio", + selected: offset + index === 0, + start: start, + index: index + }); + radio.on(BI.Radio.EVENT_CHANGE, function () { + self._drawPath(start, offset, index); + self.fireEvent(BI.PathChooser.EVENT_CHANGE, start, index); + }); + if (!this.radios[start]) { + this.radios[start] = []; + } + this.radios[start].push(radio); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: radio, + left: x - 6.5, + top: y - 6.5 + }] + }) + }, + + _drawLine: function (start, lines) { + var self = this; + if (!this.lines[start]) { + this.lines[start] = []; + } + if (!this.pathes[start]) { + this.pathes[start] = []; + } + var startRegionIndex = this.getRegionIndexById(start); + //start所在的位置,然后接着往下画其他的路径 + var offset = this.regions[startRegionIndex].getIndexByValue(start); + BI.each(lines, function (i, line) { + self.pathes[start][i] = []; + var idx = i + offset; + var path = ""; + var stop = 47.5 + 29 * idx; + var sleft = 50 + 100 * startRegionIndex; + var radioStartX = sleft, radioStartY = stop; + var etop = stop; + var endRegionIndex = self.getRegionIndexById(BI.last(line)); + var endOffset = self.regions[endRegionIndex].getIndexByValue(BI.last(line)); + var eleft = 50 + 100 * endRegionIndex; + if (BI.contains(self.start, start)) { + radioStartX = sleft - 50; + path += "M" + (sleft - 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft - 50, + y: stop + }) + } else if (idx === 0) { + radioStartX = sleft + 50; + path += "M" + sleft + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: stop + }) + } else { + radioStartX = sleft + 50; + path += "M" + sleft + "," + 47.5 + "L" + (sleft + 50) + "," + 47.5 + "L" + (sleft + 50) + "," + stop; + self.pathes[start][i].push({ + x: sleft, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: 47.5 + }); + self.pathes[start][i].push({ + x: sleft + 50, + y: stop + }); + } + if (idx > 0) { + var endY = endOffset * 29 + 47.5; + path += "L" + (eleft - 50) + "," + etop + "L" + (eleft - 50) + "," + endY + "L" + eleft + "," + endY; + self.pathes[start][i].push({ + x: eleft - 50, + y: etop + }); + self.pathes[start][i].push({ + x: eleft - 50, + y: endY + }); + self.pathes[start][i].push({ + x: eleft, + y: endY + }); + } else { + path += "L" + eleft + "," + etop; + self.pathes[start][i].push({ + x: eleft, + y: etop + }); + } + + var graph = self.svg.path(path) + .attr({ + stroke: idx === 0 ? self._const.selectLineColor : self._const.lineColor, + 'stroke-dasharray': '-' + }); + self.lines[start].push(graph); + if (lines.length > 1) { + self.lines[start][0].toFront(); + } + //第一个元素无论有多少个都要显示radio + if (BI.contains(self.start, start)) { + self.lines[self.regions[0].getValueByIndex(0)][0].toFront(); + } + if (lines.length > 1 || BI.contains(self.start, start)) { + self._drawRadio(start, offset, i, radioStartX, radioStartY); + } + }); + }, + + _drawLines: function (routes) { + var self = this; + this.lines = {}; + this.pathes = {}; + this.radios = {}; + this.regionIndexes = {}; + BI.each(routes, function (k, route) { + if (!self.regionIndexes[k]) { + self.regionIndexes[k] = []; + } + BI.each(route, function (i, rs) { + BI.each(rs, function (j, id) { + var regionIndex = self.getRegionIndexById(id); + if (!BI.contains(self.regionIndexes[k], regionIndex)) { + self.regionIndexes[k].push(regionIndex); + } + }); + }) + }); + BI.each(routes, function (k, route) { + self._drawLine(k, route); + }); + }, + + _pushNodes: function (nodes) { + var self = this; + var indexes = []; + for (var i = 0; i < nodes.length; i++) { + var id = nodes[i]; + var index = self.getRegionIndexById(id); + indexes.push(index); + var region = self.regions[index]; + if (i === nodes.length - 1) { + if (!region.hasItem(id)) { + region.addItem(id, self.texts[id]); + } + break; + } + if (i > 0 || BI.contains(self.start, id)) { + region.addItem(id, self.texts[id]); + } + } + for (var i = BI.first(indexes); i < BI.last(indexes); i++) { + if (!BI.contains(indexes, i)) { + self.regions[i].addItem(""); + } + } + }, + + _createNodes: function () { + var self = this, o = this.options; + this.store = {}; + this.texts = {}; + this.start = []; + this.end = []; + BI.each(o.items, function (i, item) { + self.start.push(BI.first(item).value); + self.end.push(BI.last(item).value); + }); + this.start = BI.uniq(this.start); + this.end = BI.uniq(this.end); + var regions = []; + var tree = new BI.Tree(); + var branches = {}, max = 0; + BI.each(o.items, function (i, items) { + BI.each(items, function (j, item) { + if (!BI.has(branches, item.value)) { + branches[item.value] = 0; + } + branches[item.value]++; + max = Math.max(max, branches[item.value]); + var prev = {}; + if (j > 0) { + prev = items[j - 1]; + } + var parent = self.store[prev.value || ""]; + var node = self.store[item.value] || new BI.Node(item.value); + node.set(item); + self.store[item.value] = node; + self.texts[item.value] = item.text; + self.texts[item.region] = item.regionText; + parent = BI.isNull(parent) ? tree.getRoot() : parent; + if (parent.getChildIndex(item.value) === -1) { + tree.addNode(parent, node); + } + }) + }); + + //算出区域列表 + tree.traverse(function (node) { + BI.each(node.getChildren(), function (i, child) { + if (BI.contains(regions, child.get("region"))) { + var index1 = BI.indexOf(regions, node.get("region")); + var index2 = BI.indexOf(regions, child.get("region")); + //交换区域 + if (index1 > index2) { + var t = regions[index2]; + for (var j = index2; j < index1; j++) { + regions[j] = regions[j + 1]; + } + regions[index1] = t; + } + } else { + regions.push(child.get("region")); + } + }); + }); + this._createRegions(regions); + + //算出节点 + BI.each(branches, function (k, branch) { + if (branch < max) { + delete branches[k]; + } + }); + + //过滤节点 + var nodes = []; + var n = tree.getRoot(); + while (n && n.getChildrenLength() === 1) { + if (BI.has(branches, n.getChildren()[0].id)) { + delete branches[n.getChildren()[0].id]; + n = n.getChildren()[0]; + } else { + n = null; + } + } + tree.traverse(function (node) { + if (BI.has(branches, node.id)) { + nodes.push(node.id); + delete branches[node.id]; + } + }); + + //填充节点 + var routes = {}; + var s, e; + for (var i = 0, len = nodes.length; i < len + 1; i++) { + if (len === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === len) { + s = e; + e = []; + BI.each(this.end, function (i, id) { + e.push(tree.search(id)); + }); + } else if (i === 0) { + s = []; + BI.each(this.start, function (i, id) { + s.push(tree.search(id)); + }); + e = [tree.search(nodes[i])]; + } else { + s = [tree.search(e[0] || tree.getRoot(), nodes[i - 1])]; + e = [tree.search(s[0], nodes[i])]; + } + BI.each(s, function (i, n) { + tree._recursion(n, [n.id], function (node, route) { + if (BI.contains(e, node)) { + if (!routes[n.id]) { + routes[n.id] = []; + } + routes[n.id].push(route); + self._pushNodes(route); + if (e.length <= 1) { + return true; + } + } + }) + }); + } + this.routes = routes; + this._drawLines(routes); + }, + + _unselectAllPath: function () { + var self = this; + BI.each(this.radios, function (idx, rad) { + BI.each(rad, function (i, r) { + r.setSelected(false); + }); + }); + BI.each(this.lines, function (idx, line) { + BI.each(line, function (i, li) { + li.attr("stroke", self._const.lineColor); + }); + }); + BI.each(this.regions, function (idx, region) { + region.reset(); + }); + }, + + populate: function (items) { + this.options.items = items || []; + var self = this; + this.empty(); + if (this.options.items.length <= 0) { + return; + } + this.svg = BI.createWidget({ + type: "bi.svg" + }); + this._createNodes(); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: [{ + el: this.svg, + top: 0, + left: 0, + right: 0, + bottom: 0 + }] + }); + }, + + setValue: function (v) { + this._unselectAllPath(); + var nodes = BI.keys(this.routes), self = this; + var result = [], array = []; + BI.each(v, function (i, val) { + if (BI.contains(nodes, val)) { + if (array.length > 0) { + array.push(val); + result.push(array); + array = []; + } + } + array.push(val); + }); + if (array.length > 0) { + result.push(array); + } + //画这n条路径 + BI.each(result, function (idx, path) { + var start = path[0]; + var index = BI.findIndex(self.routes[start], function (idx, p) { + if (BI.isEqual(path, p)) { + return true; + } + }); + if (index >= 0) { + var startRegionIndex = self.getRegionIndexById(start); + var offset = self.regions[startRegionIndex].getIndexByValue(start); + self._drawPath(start, offset, index); + } + }); + }, + + getValue: function () { + var path = []; + BI.each(this.regions, function (i, region) { + var val = region.getValue(); + if (BI.isKey(val)) { + path.push(val); + } + }); + return path; + } +}); +BI.PathChooser.EVENT_CHANGE = "PathChooser.EVENT_CHANGE"; +BI.shortcut("bi.path_chooser", BI.PathChooser);/** + * 路径选择区域 + * + * Created by GUY on 2015/12/4. + * @class BI.PathRegion + * @extends BI.Widget + */ +BI.PathRegion = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PathRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-path-region bi-background", + width: 80, + title: "" + }) + }, + + _init: function () { + BI.PathRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.zIndex = 100; + var title = BI.createWidget({ + type: "bi.label", + text: o.title, + title: o.title, + height: 30 + }); + title.element.css("zIndex", this.zIndex--); + this.items = []; + this.vertical = BI.createWidget({ + type: "bi.vertical", + element: this, + bgap: 5, + hgap: 10, + items: [title] + }) + }, + + hasItem: function (val) { + return BI.any(this.items, function (i, item) { + return val === item.getValue(); + }); + }, + + addItem: function (value, text) { + if (BI.isKey(value)) { + var label = BI.createWidget({ + type: "bi.label", + cls: "path-region-label bi-card bi-border bi-list-item-select", + text: text, + value: value, + title: text || value, + height: 24 + }); + } else { + var label = BI.createWidget({ + type: "bi.layout", + height: 24 + }); + } + label.element.css("zIndex", this.zIndex--); + this.items.push(label); + this.vertical.addItem(label); + if (this.items.length === 1) { + this.setSelect(0, value); + } + }, + + reset: function () { + BI.each(this.items, function (i, item) { + item.element.removeClass("active"); + }); + }, + + setSelect: function (index, value) { + this.reset(); + if (this.items.length <= 0) { + return; + } + if (this.items.length === 1) { + this.items[0].element.addClass("active"); + return; + } + if (this.items[index].attr("value") === value) { + this.items[index].element.addClass("active"); + } + }, + + setValue: function (value) { + this.setSelect(this.getIndexByValue(value), value); + }, + + getValueByIndex: function (idx) { + return this.items[idx].attr("value"); + }, + + getIndexByValue: function (value) { + return BI.findIndex(this.items, function (i, item) { + return item.attr("value") === value; + }); + }, + + getValue: function () { + var res; + BI.any(this.items, function (i, item) { + if (item.element.hasClass("active")) { + res = item.getValue(); + return true; + } + }); + return res; + } +}); +BI.PathRegion.EVENT_CHANGE = "PathRegion.EVENT_CHANGE"; +BI.shortcut("bi.path_region", BI.PathRegion);/** + * 预览表列 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableCell + * @extends BI.Widget + */ +BI.PreviewTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_cell', BI.PreviewTableCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableHeaderCell + * @extends BI.Widget + */ +BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-header-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value + }) + } +}); +BI.shortcut('bi.preview_table_header_cell', BI.PreviewTableHeaderCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTable + * @extends BI.Widget + */ +BI.PreviewTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table", + isNeedFreeze: false, + freezeCols: [], + rowSize: null, + columnSize: [], + headerRowSize: 30, + header: [], + items: [] + }); + }, + + _init: function () { + BI.PreviewTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + isNeedResize: false, + + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + rowSize: o.rowSize, + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + + header: BI.map(o.header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }), + items: BI.map(o.items, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_cell" + }, item); + }); + }) + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._adjustColumns(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._adjustColumns(); + }); + }, + + //是否有自适应调节的列,即列宽为"" + _hasAdaptCol: function (columnSize) { + return BI.any(columnSize, function (i, size) { + return size === ""; + }) + }, + + _isPercentage: function (columnSize) { + return columnSize[0] <= 1; + }, + + _adjustColumns: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //如果存在百分比的情况 + if (this._isPercentage(o.columnSize)) { + if (this._hasAdaptCol(o.columnSize)) { + var findCols = [], remain = 0; + BI.each(o.columnSize, function (i, size) { + if (size === "") { + findCols.push(i); + } else { + remain += size; + } + }); + remain = 1 - remain; + var average = remain / findCols.length; + BI.each(findCols, function (i, col) { + o.columnSize[col] = average; + }); + } + var isRight = BI.first(o.freezeCols) !== 0; + var freezeSize = [], notFreezeSize = []; + BI.each(o.columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + freezeSize.push(size); + } else { + notFreezeSize.push(size); + } + }); + var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); + BI.each(freezeSize, function (i, size) { + freezeSize[i] = size / sumFreezeSize; + }); + BI.each(notFreezeSize, function (i, size) { + notFreezeSize[i] = size / sumNotFreezeSize; + }); + this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); + this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); + } + } else { + //如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% + if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { + this.table.setRegionColumnSize(["100%"]); + } + } + }, + + setColumnSize: function (columnSize) { + return this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + return this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + return this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize() + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize() + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + return this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + return this.table.setLeftHorizontalScroll(scrollLeft) + }, + + setRightHorizontalScroll: function (scrollLeft) { + return this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + populate: function (items, header) { + this.table.populate(items, header); + } +}); +BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; +BI.shortcut('bi.preview_table', BI.PreviewTable);/** + * 季度下拉框 + * + * 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" + }); + + 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 + }); + + 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", + 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 () { + 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: Date._QN[01], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: 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" + }] + }); + + 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, + triggerWidth: 30, + textWidth: 40, + errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-quarter-trigger bi-border", + height: 25 + }); + }, + _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: c.errorText + }); + 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: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + + 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);/** + * 关联视图字段Item + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewItem + * @extends BI.Widget + */ +BI.RelationViewItem = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-item bi-list-item-active", + height: 25, + hoverIn: BI.emptyFn, + hoverOut: BI.emptyFn + }); + }, + + _init: function () { + BI.RelationViewItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.element.hover(o.hoverIn, o.hoverOut); + var items = []; + if (o.isPrimary) { + items.push({ + type: "bi.icon", + width: 16, + height: 16, + title: BI.i18nText("BI-Primary_Key") + }); + } + items.push({ + type: "bi.label", + text: o.text, + value: o.value, + height: o.height, + textAlign: "left", + width: o.isPrimary ? 70 : 90, + lgap: o.isPrimary ? 0 : 10 + }); + BI.createWidget({ + type: "bi.vertical_adapt", + element: this, + items: items, + cls: "primary-key-font", + lgap: 5 + }); + }, + + enableHover: function (opt) { + BI.RelationViewRegion.superclass.enableHover.apply(this, [{ + container: "body" + }]); + }, + + setSelected: function (b) { + this.element[b ? "addClass" : "removeClass"]("active"); + } +}); +BI.shortcut('bi.relation_view_item', BI.RelationViewItem);/** + * 关联视图 + * + * Created by GUY on 2015/12/22. + * @class BI.RelationView + * @extends BI.Widget + */ +BI.RelationView = BI.inherit(BI.Widget, { + + _const: { + lineColor: "#c4c6c6", + selectLineColor: "#009de3" + }, + + _defaultConfig: function () { + return BI.extend(BI.RelationView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view", + items: [] + }); + }, + + _init: function () { + BI.RelationView.superclass._init.apply(this, arguments); + this.populate(this.options.items); + }, + + _calculateWidths: function () { + var widths = []; + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + if (!widths[j]) { + widths[j] = BI.MIN; + } + widths[j] = Math.max(widths[j], obj.getWidth()); + }) + }); + return widths; + }, + + _calculateHeights: function () { + var heights = BI.makeArray(BI.size(this.views), BI.MIN); + BI.each(this.views, function (i, items) { + BI.each(items, function (j, obj) { + heights[i] = Math.max(heights[i], obj.getHeight()); + }) + }); + return heights; + }, + + _hoverIn: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.selectLineColor).toFront(); + self.storeViews[start].setValue(relation[0].primary.value); + self.storeViews[end].setValue(relation[0].foreign.value); + } + }); + }); + }, + + _hoverOut: function (target) { + var self = this, c = this._const; + BI.each(this.relations, function (start, rs) { + BI.each(rs, function (end, relation) { + if (relation[0].primary.value === target || relation[0].foreign.value === target) { + self.lines[start][end].attr("stroke", c.lineColor); + self.storeViews[start].setValue([]); + self.storeViews[end].setValue([]); + } + }); + }); + }, + + previewRelationTables: function(relationTables, show) { + if (!show) { + BI.each(this.storeViews, function (i, view) { + view.toggleRegion(true); + view.setPreviewSelected(false); + }); + BI.each(this.lines, function (i, lines) { + BI.each(lines, function (j, line) { + line.show(); + }); + }); + return; + } + BI.each(this.storeViews, function (id, view) { + if (!relationTables.contains(id)) { + view.toggleRegion(false); + } else { + view.setPreviewSelected(true); + } + }); + BI.each(this.lines, function (id, lines) { + BI.each(lines, function (cId, line) { + if (!relationTables.contains(id) || !relationTables.contains(cId)) { + line.hide(); + } + }); + }); + }, + + populate: function (items) { + var self = this, o = this.options, c = this._const; + o.items = items || []; + this.empty(); + this.svg = BI.createWidget({ + type: "bi.svg" + }); + + //算出所有的区域和关联 + var regions = this.regions = {}, relations = this.relations = {}; + BI.each(items, function (i, item) { + var pr = item.primary.region, fr = item.foreign && item.foreign.region; + if (pr && !relations[pr]) { + relations[pr] = {}; + } + if (pr && fr && !relations[pr][fr]) { + relations[pr][fr] = []; + } + if (pr && !regions[pr]) { + regions[pr] = []; + } + if (fr && !regions[fr]) { + regions[fr] = []; + } + if (pr && !BI.deepContains(regions[pr], item.primary)) { + regions[pr].push(item.primary); + } + if (fr && !BI.deepContains(regions[fr], item.foreign)) { + regions[fr].push(item.foreign); + } + pr && fr && relations[pr][fr].push(item); + }); + //求拓扑 + var topology = []; + var rs = BI.clone(regions), store = {}; + while (!BI.isEmpty(rs)) { + var clone = BI.clone(rs); + BI.each(o.items, function (i, item) { + if (!store[item.primary.region]) { + delete clone[item.foreign && item.foreign.region]; + } + }); + topology.push(BI.keys(clone)); + BI.extend(store, clone); + BI.each(clone, function (k, v) { + delete rs[k]; + }); + } + //构建视图 + var views = this.views = {}, storeViews = this.storeViews = {}, indexes = this.indexes = {}; + var verticals = []; + BI.each(topology, function (i, items) { + if (!views[i]) { + views[i] = {}; + } + var horizontal = []; + BI.each(items, function (j, region) { + var items = regions[region]; + views[i][j] = storeViews[region] = BI.createWidget({ + type: "bi.relation_view_region_container", + value: region, + header: items[0].regionTitle, + text: items.length > 0 ? items[0].regionText : "", + handler: items.length > 0 ? items[0].regionHandler : BI.emptyFn, + items: items, + belongPackage: items.length > 0 ? items[0].belongPackage : true + }); + if (BI.isNotNull(items[0]) && BI.isNotNull(items[0].keyword)) { + views[i][j].doRedMark(items[0].keyword); + } + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_IN, function (v) { + self._hoverIn(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, function (v) { + self._hoverOut(v); + }); + views[i][j].on(BI.RelationViewRegionContainer.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationView.EVENT_PREVIEW, region, v); + }); + indexes[region] = {i: i, j: j}; + horizontal.push(views[i][j]); + }); + verticals.push({ + type: "bi.horizontal", + items: horizontal + }) + }); + + //求每一行的高度 + var heights = this._calculateHeights(); + + //求每一列的宽度 + var widths = this._calculateWidths(); + + //求相对宽度和高度 + var offsetWidths = [0], offsetHeights = [0]; + BI.each(heights, function (i, h) { + if (i === 0) { + return; + } + offsetHeights[i] = offsetHeights[i - 1] + heights[i - 1]; + }); + BI.each(widths, function (i, w) { + if (i === 0) { + return; + } + offsetWidths[i] = offsetWidths[i - 1] + widths[i - 1]; + }); + + //画线 + var lines = this.lines = {};//缓存所有的线 + BI.each(relations, function (start, rs) { + BI.each(rs, function (end, relation) { + var startIndex = indexes[start], endIndex = indexes[end]; + var top = 0, right = 1, bottom = 2, left = 3; + var startDirection = bottom, endDirection = top; + // if (startIndex.j > endIndex.j) { + // startDirection = left; + // endDirection = right; + // } else if (startIndex.j < endIndex.j) { + // startDirection = right; + // endDirection = left; + // } else if (startIndex.i < endIndex.i) { + // startDirection = bottom; + // endDirection = top; + // } else if (startIndex.i > endIndex.i) { + // startDirection = top; + // endDirection = bottom; + // } + var draw = function (i, j, direction, isForeign) { + var x = offsetWidths[j] + (widths[j] - views[i][j].getWidth()) / 2; + var y = offsetHeights[i] + (heights[i] - views[i][j].getHeight()) / 2; + var path = "", position; + switch (direction) { + case top: + position = isForeign ? views[i][j].getTopRightPosition() : views[i][j].getTopLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y - 10); + y -= 10; + break; + case right: + position = views[i][j].getRightPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x + 10) + "," + y; + x += 10; + break; + case bottom: + position = views[i][j].getBottomPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + x + "," + (y + 10); + y += 10; + break; + case left: + position = views[i][j].getLeftPosition(); + x += position.x; + y += position.y; + path = "M" + x + "," + y + "L" + (x - 10) + "," + y; + x -= 10; + break; + } + return {x: x, y: y, path: path}; + }; + var path = ""; + var si = draw(startIndex.i, startIndex.j, startDirection); + var ei = draw(endIndex.i, endIndex.j, endDirection, true); + path += si.path + ei.path; + if (!lines[start]) { + lines[start] = {}; + } + path += "M" + si.x + "," + si.y + "L" + ei.x + "," + ei.y; + var line = lines[start][end] = self.svg.path(path) + .attr({"stroke": c.lineColor, "stroke-width": "2"}) + .hover(function () { + line.attr("stroke", c.selectLineColor).toFront(); + storeViews[start].setValue(relation[0].primary.value); + storeViews[end].setValue(relation[0].foreign.value); + }, function () { + line.attr("stroke", c.lineColor); + storeViews[start].setValue([]); + storeViews[end].setValue([]); + }); + }); + }); + var container = BI.createWidget(); + BI.createWidget({ + type: "bi.vertical", + element: container, + items: verticals + }); + BI.createWidget({ + type: "bi.absolute", + element: container, + items: [{ + el: this.svg, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + + BI.createWidget({ + type: "bi.center_adapt", + scrollable: true, + element: this, + items: [container] + }); + } +}); +BI.RelationView.EVENT_CHANGE = "RelationView.EVENT_CHANGE"; +BI.RelationView.EVENT_PREVIEW = "EVENT_PREVIEW"; +BI.shortcut('bi.relation_view', BI.RelationView);/** + * Created by Young's on 2017/3/10. + */ +BI.RelationViewRegionContainer = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegionContainer.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region-container", + width: 150 + }); + }, + + _init: function () { + BI.RelationViewRegionContainer.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.region = BI.createWidget({ + type: "bi.relation_view_region", + value: o.value, + header: o.header, + text: o.text, + handler: o.handler, + items: o.items, + belongPackage: o.belongPackage + }); + this.region.on(BI.RelationViewRegion.EVENT_PREVIEW, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_PREVIEW, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_IN, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_IN, v); + }); + this.region.on(BI.RelationViewRegion.EVENT_HOVER_OUT, function (v) { + self.fireEvent(BI.RelationViewRegionContainer.EVENT_HOVER_OUT, v); + }); + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.region], + width: this.region.getWidth(), + height: this.region.getHeight() + }); + }, + + doRedMark: function () { + this.region.doRedMark.apply(this.region, arguments); + }, + + unRedMark: function () { + this.region.unRedMark.apply(this.region, arguments); + }, + + getWidth: function () { + return this.region.getWidth(); + }, + + getHeight: function () { + return this.region.getHeight(); + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return this.region.getTopLeftPosition(); + }, + + getTopRightPosition: function () { + return this.region.getTopRightPosition(); + }, + + getBottomPosition: function () { + return this.region.getBottomPosition(); + }, + + getLeftPosition: function () { + return this.region.getLeftPosition(); + }, + + getRightPosition: function () { + return this.region.getRightPosition(); + }, + + setValue: function (v) { + this.region.setValue(v); + }, + + toggleRegion: function (v) { + v === true ? this.region.element.fadeIn() : this.region.element.fadeOut(); + }, + + setPreviewSelected: function(v) { + this.region.setPreviewSelected(v); + } +}); +BI.RelationViewRegionContainer.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegionContainer.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegionContainer.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut("bi.relation_view_region_container", BI.RelationViewRegionContainer);/** + * 关联视图 + * + * Created by GUY on 2015/12/23. + * @class BI.RelationViewRegion + * @extends BI.BasicButton + */ +BI.RelationViewRegion = BI.inherit(BI.BasicButton, { + + _defaultConfig: function () { + return BI.extend(BI.RelationViewRegion.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-relation-view-region cursor-pointer", + width: 150, + text: "", + value: "", + header: "", + items: [], + belongPackage: true + }); + }, + + _init: function () { + BI.RelationViewRegion.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.preview = BI.createWidget({ + type: "bi.icon_button", + cls: "relation-table-preview-font", + width: 25, + height: 25, + stopPropagation: true + }); + this.preview.on(BI.IconButton.EVENT_CHANGE, function () { + self.fireEvent(BI.RelationViewRegion.EVENT_PREVIEW, this.isSelected()); + }); + + this.title = BI.createWidget({ + type: "bi.label", + height: 25, + width: 70, + text: o.text, + value: o.value, + textAlign: "left" + }); + //title放body上 + if (BI.isKey(o.header)) { + this.title.setTitle(o.header, { + container: "body" + }) + } + + this.button_group = BI.createWidget({ + type: "bi.button_group", + items: this._createItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [{ + type: "bi.vertical", + cls: "relation-view-region-container bi-card bi-border " + (o.belongPackage ? "" : "other-package"), + items: [{ + type: "bi.vertical_adapt", + cls: "relation-view-region-title bi-border-bottom", + items: [this.preview, this.title] + }, this.button_group] + }], + hgap: 25, + vgap: 20 + }) + }, + + _createItems: function (items) { + var self = this; + return BI.map(items, function (i, item) { + return BI.extend(item, { + type: "bi.relation_view_item", + hoverIn: function () { + self.setValue(item.value); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_IN, item.value); + }, + hoverOut: function () { + self.setValue([]); + self.fireEvent(BI.RelationViewRegion.EVENT_HOVER_OUT, item.value); + } + }) + }); + }, + + doRedMark: function () { + this.title.doRedMark.apply(this.title, arguments); + }, + + unRedMark: function () { + this.title.unRedMark.apply(this.title, arguments); + }, + + getWidth: function () { + return this.options.width; + }, + + getHeight: function () { + return this.button_group.getAllButtons().length * 25 + 25 + 2 * 20 + 3; + }, + + //获取上方开始划线的位置 + getTopLeftPosition: function () { + return { + x: 25 + 10, + y: 20 + } + }, + + getTopRightPosition: function () { + return { + x: this.getWidth() - 25 - 10, + y: 20 + } + }, + + getBottomPosition: function () { + return { + x: 25 + 10, + y: this.getHeight() - 20 + } + }, + + getLeftPosition: function () { + return { + x: 25, + y: 20 + 10 + } + }, + + getRightPosition: function () { + return { + x: this.getWidth() - 25, + y: 20 + 10 + } + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + setPreviewSelected: function(v) { + this.preview.setSelected(v); + } +}); +BI.RelationViewRegion.EVENT_HOVER_IN = "RelationViewRegion.EVENT_HOVER_IN"; +BI.RelationViewRegion.EVENT_HOVER_OUT = "RelationViewRegion.EVENT_HOVER_OUT"; +BI.RelationViewRegion.EVENT_PREVIEW = "RelationViewRegion.EVENT_PREVIEW"; +BI.shortcut('bi.relation_view_region', BI.RelationViewRegion);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.ResponisveTable + * @extends BI.Widget + */ +BI.ResponisveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-responsive-table", + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: function (row1, row2) { //合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 25, + footerRowSize: 25, + rowSize: 25, + + regionColumnSize: false, + + header: [], + footer: false, + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.ResponisveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + footerRowSize: o.footerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + header: o.header, + footer: o.footer, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { + //important:在冻结并自适应列宽的情况下要随时变更表头宽度 + if (o.isNeedResize === true && self._isAdaptiveColumn()) { + self._resizeHeader(); + } + self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { + self._resizeBody(); + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _initRegionSize: function () { + var o = this.options; + if (o.isNeedFreeze === true) { + var regionColumnSize = this.table.getRegionColumnSize(); + var maxWidth = this.table.element.width(); + if (!regionColumnSize[0] || (regionColumnSize[0] === 'fill') || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { + var freezeCols = o.freezeCols; + if (freezeCols.length === 0) { + this.table.setRegionColumnSize([0, "fill"]); + } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } else { + this.table.setRegionColumnSize(["fill", 0]); + } + } + } + }, + + _getBlockSize: function () { + var o = this.options; + var columnSize = this.table.getCalculateColumnSize(); + if (o.isNeedFreeze === true) { + var columnSizeLeft = [], columnSizeRight = []; + BI.each(columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + columnSizeLeft.push(size); + } else { + columnSizeRight.push(size); + } + }); + //因为有边框,所以加上数组长度的参数调整 + var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, + sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; + return { + sumLeft: sumLeft, + sumRight: sumRight, + left: columnSizeLeft, + right: columnSizeRight + } + } + return { + size: columnSize, + sum: BI.sum(columnSize) + columnSize.length + }; + }, + + _isAdaptiveColumn: function (columnSize) { + return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); + }, + + _resizeHeader: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + //若是当前处于自适应调节阶段 + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.table.setHeaderColumnSize(columnSize); + } else { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + var columnSizeLeft = block.left, columnSizeRight = block.right; + columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; + columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; + + var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); + newLeft[newLeft.length - 1] = ""; + newRight[newRight.length - 1] = ""; + this.table.setColumnSize(newLeft.concat(newRight)); + + block = self._getBlockSize(); + if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { + columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1] + } + if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { + columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1] + } + + self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); + } + } else { + if (!this._isAdaptiveColumn()) { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sum = block.sum; + var size = block.size; + + size[size.length - 1] += regionColumnSize[0] - sum; + + var newSize = BI.clone(size); + newSize[newSize.length - 1] = ""; + this.table.setColumnSize(newSize); + block = this._getBlockSize(); + + if (size[size.length - 1] < block.size[block.size.length - 1]) { + size[size.length - 1] = block.size[block.size.length - 1] + } + this.table.setColumnSize(size); + } + } + }, + + _resizeBody: function () { + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.setColumnSize(columnSize); + } + }, + + _adjustRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { + this.table.setRegionColumnSize([sumLeft, "fill"]); + } + this._resizeRegion(); + } + }, + + _resizeRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var maxWidth = this.table.element.width(); + if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { + var freezeCols = o.freezeCols; + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } + } + }, + + + resize: function () { + this.table.resize(); + this._resizeRegion(); + this._resizeHeader(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + this._resizeHeader(); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + attr: function () { + BI.ResponisveTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function (items) { + var self = this, o = this.options; + this.table.populate.apply(this.table, arguments); + if (o.isNeedFreeze === true) { + BI.nextTick(function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + }); + } + } +}); +BI.shortcut('bi.responsive_table', BI.ResponisveTable);/** + * 加号表示的组节点 + * 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: 25 + }) + }, + _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, + 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: 25, + 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: 25 + }) + }, + _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, + 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: 25, + 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: 25 + }) + }, + _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, + 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: 25, + 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);/** + * @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: [] + }); + }, + + _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 + }); + + this.popup = BI.createWidget({ + type: "bi.select_level_tree", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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: "click", + 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(BI.extend({stopPropagation: true}, 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: [] + }); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {layer: layer}; + node.id = node.id || BI.UUID(); + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + self._formatItems(node.children); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.last_tree_leaf_item"; + break; + default : + extend.type = "bi.mid_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)), + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + 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(items); + } +}); + +BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** + * + * Created by GUY on 2016/8/10. + * @class BI.SequenceTableDynamicNumber + * @extends BI.SequenceTableTreeNumber + */ +BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-sequence-table-dynamic-number" + }); + }, + + _init: function () { + BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount(node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + } +}); +BI.shortcut('bi.sequence_table_dynamic_number', BI.SequenceTableDynamicNumber);/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableListNumber + * @extends BI.Widget + */ +BI.SequenceTableListNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-list-number", + isNeedFreeze: false, + scrollTop: 0, + startSequence: 1,//开始的序号 + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: null, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + pageSize: 20 + }); + }, + + _init: function () { + BI.SequenceTableListNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.start = o.startSequence; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: o.headerRowSize * o.header.length - 2 + }, { + el: {type: "bi.layout"}, + height: 2 + }, { + el: this.scrollContainer + }] + }); + this._populate(); + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = o.headerRowSize * o.header.length - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + this.container.setHeight(o.items.length * o.rowSize); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); + var start = Math.floor(scrollTop / o.rowSize); + var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); + var renderedCells = [], renderedKeys = []; + for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { + var index = BI.deepIndexOf(this.renderedKeys, this.start + i); + var top = i * o.rowSize; + if (index > -1) { + if (o.rowSize !== this.renderedCells[index]._height) { + this.renderedCells[index]._height = o.rowSize; + this.renderedCells[index].el.setHeight(o.rowSize); + } + if (this.renderedCells[index].top !== top) { + this.renderedCells[index].top = top; + this.renderedCells[index].el.element.css("top", top + "px"); + } + renderedCells.push(this.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + height: o.rowSize, + text: this.start + i, + styleGetter: function (index) { + return function () { + return o.sequenceCellStyleGetter(self.start + i - 1); + } + }(cnt) + })); + renderedCells.push({ + el: child, + left: 0, + top: top, + _height: o.rowSize + }); + } + renderedKeys.push(this.start + i); + } + + //已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]) + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + }, + + _populate: function () { + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + v = v < 1 ? 1 : v; + var o = this.options; + this.start = (v - 1) * o.pageSize + 1; + }, + + _restore: function () { + var o = this.options; + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + } + if (header && header !== this.options.header) { + o.header = header; + } + this._populate(); + } +}); +BI.shortcut('bi.sequence_table_list_number', BI.SequenceTableListNumber);/** + * 带有序号的表格 + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTable + * @extends BI.Widget + */ +BI.SequenceTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table", + el: { + type: "bi.adaptive_table" + }, + + sequence: {}, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: false,//是否需要冻结单元格 + freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false,//是否需要合并单元格 + mergeCols: [], //合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], //二维数组 + + //交叉表头 + crossHeader: [], + crossItems: [], + + showSequence: false, + startSequence: 1//开始的序号 + }); + }, + + _init: function () { + BI.SequenceTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.sequence = BI.createWidget(o.sequence, { + type: "bi.sequence_table_list_number", + invisible: o.showSequence === false, + startSequence: o.startSequence, + isNeedFreeze: o.isNeedFreeze, + header: o.header, + items: o.items, + crossHeader: o.crossHeader, + crossItems: o.crossItems, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + width: 60, + height: o.height && o.height - BI.GridTableScrollbar.SIZE, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter + }); + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + //交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); + } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.htape = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.sequence, + left: 0, + top: 0 + }, { + el: this.table, + top: 0, + left: o.showSequence === true ? 60 : 0 + }] + }); + this._populate(); + }, + + _populate: function () { + var o = this.options; + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); + }, + + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); + }, + + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, + + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, arguments); + }, + + restore: function () { + this.table.restore(); + this.sequence.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); + }, + + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut('bi.sequence_table', BI.SequenceTable);/** + * @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: 30, + text: "", + items: [] + }); + }, + + _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 + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_level_tree", + items: o.items + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + 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: [] + }); + }, + + _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, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + 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: 30, + text: "", + items: [] + }); + }, + + _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 + }); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(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);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", + items: [] + }); + }, + + _init: function () { + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + defaultShowIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); + }, + + _createTree: function (type) { + var self = this, o = this.options; + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items) + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)) + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } + }, + + _removeIsParent: function(items) { + BI.each(items, function(i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; + }); + return items; + }, + + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; + } + }, + + setSelect: function (v) { + this.tab.setSelect(v); + }, + + getSelect: function () { + return this.tab.getSelect(); + }, + + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } + }, + + getValue: function () { + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } + } +}); +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +BI.shortcut('bi.switch_tree', BI.SwitchTree); +/** + * Created by Baron on 2015/10/19. + */ +BI.TimeInterval = BI.inherit(BI.Single, { + constants: { + height: 25, + width: 25, + lgap: 15, + offset: -15, + 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; + BI.TimeInterval.superclass._init.apply(this, arguments); + + this.left = this._createCombo(); + this.right = this._createCombo(); + 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 () { + var self = this; + var combo = BI.createWidget({ + type: 'bi.multidate_combo' + }); + combo.on(BI.MultiDateCombo.EVENT_ERROR, function () { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + }); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.MultiDateCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.left.hidePopupView(); + self.right.hidePopupView(); + }); + //combo.on(BI.MultiDateCombo.EVENT_CHANGE, 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.TimeInterval.EVENT_ERROR); + // } else { + // self._clearTitle(); + // self.element.removeClass(self.constants.timeErrorCls); + // } + //}); + + combo.on(BI.MultiDateCombo.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.TimeInterval.EVENT_ERROR); + }else{ + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_CHANGE); + } + }); + return combo; + }, + _dateCheck: function (date) { + return Date.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") == date || Date.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") == date || Date.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") == date || Date.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") == date; + }, + _checkVoid: function (obj) { + return !Date.checkVoid(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) && Date.checkLegal(smallDate) && this._checkVoid({ + year: smallObj[0], + month: smallObj[1], + day: smallObj[2] + }) && this._dateCheck(bigDate) && Date.checkLegal(bigDate) && this._checkVoid({ + year: bigObj[0], + month: bigObj[1], + day: bigObj[2] + }); + }, + _compare: function (smallDate, bigDate) { + smallDate = Date.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); + bigDate = Date.parseDateTime(bigDate, "%Y-%X-%d").print("%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.TimeInterval.EVENT_VALID = "EVENT_VALID"; +BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.time_interval", BI.TimeInterval);/** + * 年份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.YearCombo + * @extends BI.Widget + */ +BI.YearCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + behaviors: {}, + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.year_trigger", + min: o.min, + max: o.max + }); + this.trigger.on(BI.YearTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.YearTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.YearTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.YearTrigger.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.YearCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + destroyWhenHide: true, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + var value = self.trigger.getKey(); + if (BI.isNotNull(value)) { + self.popup.setValue(value); + } else if (!value && value !== self.storeValue) { + self.popup.setValue(self.storeValue); + } else { + self.setValue(); + } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.combo.setValue(v || ""); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_combo', BI.YearCombo);/** + * 年份展示面板 + * + * 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; + + this.selectedYear = this._year = new Date().getFullYear(); + + var backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25, + value: -1 + }); + + var preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25, + 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-border-top", + height: 25, + 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); + }); + }, + + getValue: function () { + return this.selectedYear; + }, + + setValue: function (v) { + var o = this.options; + if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) { + v = new Date().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/8/21. + * @class BI.YearTrigger + * @extends BI.Trigger + */ +BI.YearTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + triggerWidth: 25, + errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), + errorTextInvalid: BI.i18nText("BI-Year_Trigger_Invalid_Text") + }, + + _defaultConfig: function () { + return BI.extend(BI.YearTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-year-trigger bi-border", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 25 + }); + }, + _init: function () { + BI.YearTrigger.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) { + self.editor.setErrorText(!BI.isPositiveInteger(v) ? c.errorText : c.errorTextInvalid); + return v === "" || (BI.isPositiveInteger(v) && !Date.checkVoid(v, 1, 1, o.min, o.max)[0]); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: c.errorText + }) + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.YearTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.YearTrigger.EVENT_STOP); + }); + 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.YearTrigger.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.YearTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.YearTrigger.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: c.triggerWidth + }, + width: c.triggerWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: c.triggerWidth + }, + width: c.triggerWidth + } + ] + }); + }, + setValue: function (v) { + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + getKey: function () { + return this.editor.getValue() | 0; + } +}); +BI.YearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.YearTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.YearTrigger.EVENT_START = "EVENT_START"; +BI.YearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearTrigger.EVENT_STOP = "EVENT_STOP"; +BI.shortcut("bi.year_trigger", BI.YearTrigger);/** + * 年份 + 月份下拉框 + * + * @class BI.YearMonthCombo + * @extends BI.Widget + */ +BI.YearMonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearMonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.month = BI.createWidget({ + type: "bi.month_combo", + behaviors: o.monthBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); + }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.month] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.month.setValue(v.month); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + }; + } +}); +BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** + * 年份 + 月份下拉框 + * + * @class BI.YearQuarterCombo + * @extends BI.Widget + */ +BI.YearQuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.YearQuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.year = BI.createWidget({ + type: "bi.year_combo", + behaviors: o.yearBehaviors + }); + + this.quarter = BI.createWidget({ + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors + }); + + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); + }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.center", + element: this, + hgap: 5, + items: [this.year, this.quarter] + }); + + }, + + setValue: function (v) { + v = v || {}; + this.quarter.setValue(v.quarter); + this.year.setValue(v.year); + }, + + getValue: function () { + return { + year: this.year.getValue(), + quarter: this.quarter.getValue() + }; + } +}); +BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与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) { + if (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.matched.concat(search.finded); + }); + 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', + element: this, + 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.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 () { + 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 () { + this.list.populate.apply(this.list, arguments); + } +}); +BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; +BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);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 + }); + }, + + _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 finded = search(parentValues, notSelectedValue, [], searched); + if (finded && 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 = [], finded = false; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(p)) { + finded = true; + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + p = parentValues; + } + + if (finded === 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, parentValues.length - 1), 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); + var finded = BI.Func.getSearchResult([node.text || node.value], keyword); + return finded.finded.length > 0 || finded.matched.length > 0; + }, + + _getTreeNode: function (parentValues, v) { + var self = this; + var findedParentNode; + 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) { + findedParentNode = node; + return false; + } + if (node.value === parentValues[index]) { + index++; + return; + } + return true; + }); + return findedParentNode; + }, + + _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), + 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 () { + 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) { + 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(); + if (options.keyword) { + keywords.push(options.keyword); + } + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + items = search.matched.concat(search.finded); + }); + 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, + 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 () { + 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.populate(); + } + }, + + setValue: function (v) { + this.list.setValue(v); + }, + + getValue: function () { + var val = this.list.getValue() || {}; + return { + type: val.type, + value: val.value + } + }, + + populate: function () { + this.list.populate.apply(this.list, arguments); + } +}); +BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane); \ No newline at end of file diff --git a/src/addons/sliders/css/intervalslider/intervalslider.css b/src/addons/sliders/css/intervalslider/intervalslider.css index 18bcc2934..f9388f670 100644 --- a/src/addons/sliders/css/intervalslider/intervalslider.css +++ b/src/addons/sliders/css/intervalslider/intervalslider.css @@ -1,7 +1,7 @@ .bi-interval-slider-label { min-height: 50px; } - + .bi-interval-slider { min-height: 70px; } diff --git a/src/addons/sliders/css/singleslider/singlelider.css b/src/addons/sliders/css/singleslider/singlelider.css index 89c22bab6..b71d5ade1 100644 --- a/src/addons/sliders/css/singleslider/singlelider.css +++ b/src/addons/sliders/css/singleslider/singlelider.css @@ -1,7 +1,7 @@ .bi-single-slider-label { min-height: 50px; } - + .bi-single-slider-normal { min-height: 30px; } diff --git a/src/core/shortcut.js b/src/core/shortcut.js index 16c5510a7..173d428a8 100644 --- a/src/core/shortcut.js +++ b/src/core/shortcut.js @@ -18,7 +18,7 @@ }; BI.createWidget = function (item, options) { - var el; + var el, w; options || (options = {}); if (BI.isEmpty(item) && BI.isEmpty(options)) { return BI.createWidget({ @@ -30,11 +30,13 @@ } if (item && (item.type || options.type)) { el = BI.extend({}, options, item); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && item.el && (item.el.type || options.type)) { el = BI.extend({}, options, item.el); - return BI.Plugin.getObject(el.type, createWidget(BI.Plugin.getWidget(el.type, el))); + w = BI.Plugin.getWidget(el.type, el); + return BI.Plugin.getObject(el.type, w.type === el.type ? createWidget(w) : BI.createWidget(BI.extend({}, item, {type: w.type}, options))); } if (item && BI.isWidget(item.el)) { return item.el; diff --git a/src/widget/canvastable/collection.canvas.js b/src/widget/canvastable/collection.canvas.js new file mode 100644 index 000000000..966b0f6e8 --- /dev/null +++ b/src/widget/canvastable/collection.canvas.js @@ -0,0 +1,361 @@ +/** + * Created By Shichao on 2017/10/17 + * @class BI.CanvasCollectionView + * @extends BI.Widget + */ +BI.CanvasCollectionView = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasCollectionView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection", + overflowX: true, + overflowY: true, + cellSizeAndPositionGetter: BI.emptyFn, + horizontalOverscanSize: 0, + verticalOverscanSize: 0, + scrollLeft: 0, + scrollTop: 0, + items: [] + }) + }, + + _init: function () { + BI.CanvasCollectionView.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.renderedCells = []; + this.renderedKeys = []; + this._scrollLock = false; + this.scrollTop = this.scrollLeft = 0; + this.summaryScrollTop = this.summaryScrollLeft = 0; + this._debounceRelease = BI.debounce(function () { + self._scrollLock = false; + }, 1000 / 60); + this.canvas = BI.createWidget({ + type: "bi.canvas_new" + }); + $(document).keydown(BI.bind(this._onResize, this)); // 防止在使用ctrl + 滚轮调整窗口大小时触发mousewheel事件 + $(document).keyup(BI.bind(this._onResizeRelease, this)) + this.element.mousewheel(BI.bind(this._onMouseWheel, this)) + BI.createWidget({ + type: "bi.vertical", + element: this, + scrollable: false, + scrolly: false, + scrollx: false, + items: [this.canvas] + }); + if (o.items.length > 0) { + this._calculateSizeAndPositionData(); + this._populate(); + } + if (o.scrollLeft !== 0 || o.scrollTop !== 0) { + BI.nextTick(function () { + self.element.scrollTop(o.scrollTop); + self.element.scrollLeft(o.scrollLeft); + }); + } + }, + + _onMouseWheel: function (e) { + var o = this.options; + if (this._scrollLock) { + return; + } + if (!this._isCtrlPressed) { + o.scrollTop += -e.originalEvent.wheelDelta; + o.scrollTop = BI.clamp(o.scrollTop, 0, this.maxScrollTop); + this._calculateChildrenToRender(); + this.fireEvent(BI.CanvasCollectionView.EVENT_SCROLL, { + scrollLeft: o.scrollLeft, + scrollTop: o.scrollTop + }); + } + }, + + _onResize: function (e) { + if (e.ctrlKey) { + this._isCtrlPressed = true; + } else { + this._isCtrlPressed = false; + } + }, + + _onResizeRelease: function (e) { + var Keys = { + CTRL: 17 + }; + var keyCode = e.keyCode; + + if (keyCode === Keys.CTRL) { + this._isCtrlPressed = false; + } + }, + + _getMaxScrollTop: function () { + return this._height - this.options.height + }, + + _calculateSizeAndPositionData: function () { + var o = this.options; + var cellMetadata = []; + var sectionManager = new BI.SectionManager(); + var height = 0; + var width = 0; + + for (var index = 0, len = o.items.length; index < len; index++) { + var cellMetadatum = o.cellSizeAndPositionGetter(index); + + if (cellMetadatum.height == null || isNaN(cellMetadatum.height) || + cellMetadatum.width == null || isNaN(cellMetadatum.width) || + cellMetadatum.x == null || isNaN(cellMetadatum.x) || + cellMetadatum.y == null || isNaN(cellMetadatum.y)) { + throw Error(); + } + + height = Math.max(height, cellMetadatum.y + cellMetadatum.height); + width = Math.max(width, cellMetadatum.x + cellMetadatum.width); + + cellMetadatum.index = index; + cellMetadata[index] = cellMetadatum; + sectionManager.registerCell(cellMetadatum, index); + } + + this._cellMetadata = cellMetadata; + this._sectionManager = sectionManager; + if (this._height === height && this._width === width) { + this._isNeedReset = false; + } else { + this._height = height; + this._width = width; + this._isNeedReset = true; + } + this.maxScrollTop = this._getMaxScrollTop(); + }, + + _cellRenderers: function (height, width, x, y) { + this._lastRenderedCellIndices = this._sectionManager.getCellIndices(height, width, x, y); + return this._cellGroupRenderer(); + }, + + _cellGroupRenderer: function () { + var self = this, o = this.options; + var rendered = []; + BI.each(this._lastRenderedCellIndices, function (i, index) { + var cellMetadata = self._sectionManager.getCellMetadata(index); + rendered.push(cellMetadata); + }); + return rendered; + }, + + _calculateChildrenToRender: function () { + var x, y, cellWidth, cellHeight, cellRow, cellCol, value, self = this, o = this.options; + var scrollLeft = o.scrollLeft; + var scrollTop = o.scrollTop; + var left = Math.max(0, scrollLeft - o.horizontalOverscanSize); + var top = Math.max(0, scrollTop - o.verticalOverscanSize); + var right = Math.min(this._width, scrollLeft + o.width + o.horizontalOverscanSize); + var bottom = Math.min(this._height, scrollTop + o.height + o.verticalOverscanSize); + if (right > 0 && bottom > 0) { + var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); + this.canvas.remove(this.scrollLeft, this.scrollTop, o.width, o.height); + for (var i = 0; i < childrenToDisplay.length; i++) { + var datum = childrenToDisplay[i]; + var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1]; + var rect_tl_x = datum.x, + rect_tl_y = datum.y, + rect_tr_x = rect_tl_x + datum.width, + rect_bl_y = rect_tl_y + datum.height, + cell = o.items[datum.index].cell || o.items[datum.index], + background, color, fontWeight, text; + while (BI.isNull(cell.styles) && !BI.isFunction(cell.styleGetter)) { + cell = cell.cell; + } + if (BI.isNull(cell.styles) && BI.isFunction(cell.styleGetter)) { + background = cell.styleGetter().background; + color = cell.styleGetter().color; + fontWeight = cell.styleGetter().fontWeight; + } else if (!BI.isNull(cell.styles)) { + background = cell.styles.background; + color = cell.styles.color; + fontWeight = cell.styles.fontWeight; + } + if (BI.isNull(cell.text)) { + text = ""; + } else { + text = cell.text; + } + if (!BI.isString(text)) { + text = text.toString(); + } + if (this.scrollLeft !== o.scrollLeft) { + this.canvas.translate(this.scrollLeft - o.scrollLeft, 0); + this.scrollLeft = o.scrollLeft; + } + if (this.scrollTop !== o.scrollTop) { + this.canvas.translate(0, this.scrollTop - o.scrollTop); + this.scrollTop = o.scrollTop; + } + if (datum.x === 0 && datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.x === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, rect_tr_x, rect_tl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else if (datum.y === 0) { + this.canvas.solid(rect_tl_x, rect_tl_y, rect_tr_x, rect_tl_y, rect_tr_x, rect_bl_y, rect_tl_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } else { + this.canvas.solid(rect_tr_x, rect_tl_y, rect_tl_x, rect_tl_y, rect_tl_x, rect_bl_y, rect_tr_x, rect_bl_y, { + strokeStyle: "rgb(212, 218, 221)", + fillStyle: background + }); + } + this.canvas.setFontWeight(fontWeight); + this.canvas.setFont(); + var font = this.canvas.getContext().font, + textSize = this._getTextPixel(font), + textHeight = textSize, + textWidth = this.canvas.getContext().measureText(text).width, + dotsWidth = this.canvas.getContext().measureText("...").width; + var offsetX = this._calcOffsetX(textWidth, datum.width, "center"), + offsetY = this._calcOffsetY(textHeight, datum.height, "center"); + if (textHeight > datum.height) { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, "...", color); + } else if (textWidth + 4 > datum.width) { + var sliceIndex = Math.floor((datum.width - dotsWidth - 4) / textWidth * text.length); + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text.slice(0, sliceIndex) + "...", color); + } else { + this.canvas.text(datum.x + offsetX, datum.y + offsetY, text, color); + } + this.canvas.stroke(); + } + } + }, + + _getTextPixel: function (font) { + var p = font.split("px")[0], + s = p.split(" "); + for (var c in s) { + var num; + num = BI.parseInt(s[c]); + if (!BI.isNaN(num)) { + return num; + } + } + }, + + _calcOffsetX: function (textWidth, cellWidth, position) { + switch (position) { + case "center": + if (textWidth >= cellWidth) { + return 4; + } else { + return (cellWidth - textWidth) / 2; + } + case "right": + if (textWidth >= cellWidth) { + return 0; + } else { + return cellWidth - textWidth; + } + default: + return 0; + } + }, + + _calcOffsetY: function (textHeight, cellHeight, position) { + switch (position) { + case "center": + if (textHeight >= cellHeight) { + return textHeight; + } else { + return (cellHeight + textHeight) / 2; + } + case "bottom": + if (textHeight >= cellHeight) { + return cellHeight; + } else { + return cellHeight + textHeight; + } + default: + return textHeight; + } + }, + + _populate: function (items) { + var o = this.options; + if (items && items !== this.options.items) { + this.options.items = items; + this._calculateSizeAndPositionData(); + } + if (o.items.length > 0) { + this.canvas.setBlock(); + this.canvas.setWidth(o.width); + this.canvas.setHeight(o.height); + this.restore(); + this._calculateChildrenToRender(); + this.element.scrollTop(o.scrollTop); + this.element.scrollLeft(o.scrollLeft); + } + }, + + populate: function (items) { + if (items && items !== this.options.items) { + this.restore(); + } + this._populate(items); + }, + + setWidth: function (width) { + BI.CanvasCollectionView.superclass.setWidth.apply(this, arguments); + this.options.width = width; + }, + + setHeight: function (height) { + BI.CanvasCollectionView.superclass.setHeight.apply(this, arguments); + this.options.height = height; + }, + + restore: function () { + this.canvas.remove(this.scrollLeft, this.scrollTop, this.options.width, this.options.height); + this.renderedKeys = []; + this._scrollLock = false; + }, + + setScrollLeft: function (scrollLeft) { + if (this.options.scrollLeft === scrollLeft) { + return; + } + this._scrollLock = true; + this.options.scrollLeft = scrollLeft; + 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 = scrollTop; + this._debounceRelease(); + this._calculateChildrenToRender(); + this.element.scrollTop(this.options.scrollTop); + }, + + getScrollLeft: function () { + return this.options.scrollLeft; + }, + + getScrollTop: function () { + return this.options.scrollTop; + } +}) +BI.CanvasCollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut("bi.canvas_collection_view", BI.CanvasCollectionView); \ No newline at end of file diff --git a/src/widget/canvastable/table.canvas.js b/src/widget/canvastable/table.canvas.js new file mode 100644 index 000000000..18ba17839 --- /dev/null +++ b/src/widget/canvastable/table.canvas.js @@ -0,0 +1,529 @@ +/** + * Created by Shichao on 2017/10/18 + * @class BI.CanvasTable + * @extends BI.Widget + */ +BI.CanvasTable = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.CanvasTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-canvas-collection-table", + headerRowSize: 25, + rowSize: 25, + columnSize: [], + isNeedFreeze: false, + freezeCols: [], + isNeedMerge: false, + mergeCols: [], + mergeRule: BI.emptyFn, + header: [], + items: [], + regionColumnSize: [] + }); + }, + + _init: function () { + BI.CanvasTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._scrollBarSize = BI.DOM.getScrollWidth(); + this.topLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topLeftItems[index]; + } + }); + this.topRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.topRightItems[index]; + } + }); + this.topRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomLeftCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomLeftItems[index]; + } + }); + this.bottomLeftCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomRightCollection.setScrollTop(scroll.scrollTop); + self.topLeftCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.bottomRightCollection = BI.createWidget({ + type: "bi.canvas_collection_view", + cellSizeAndPositionGetter: function (index) { + return self.bottomRightItems[index]; + } + }); + this.bottomRightCollection.on(BI.CanvasCollectionView.EVENT_SCROLL, function (scroll) { + self.bottomLeftCollection.setScrollTop(scroll.scrollTop); + self.topRightCollection.setScrollLeft(scroll.scrollLeft); + self._populateScrollbar(); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.topLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topLeftCollection] + }); + this.topRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.topRightCollection] + }); + this.bottomLeft = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomLeftCollection] + }); + this.bottomRight = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.bottomRightCollection] + }); + this.contextLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topLeft, + top: 0, + left: 0, + }, { + el: this.topRight, + top: 0 + }, { + el: this.bottomLeft, + left: 0 + }, { + el: this.bottomRight, + }] + }); + + this.topScrollbar = BI.createWidget({ + type: "bi.grid_table_scrollbar", + width: BI.GridTableScrollbar.SIZE + }); + this.topScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollTop) { + self.bottomLeftCollection.setScrollTop(scrollTop); + self.bottomRightCollection.setScrollTop(scrollTop); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.leftScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.leftScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topLeftCollection.setScrollLeft(scrollLeft); + self.bottomLeftCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.rightScrollbar = BI.createWidget({ + type: "bi.grid_table_horizontal_scrollbar", + height: BI.GridTableScrollbar.SIZE + }); + this.rightScrollbar.on(BI.GridTableScrollbar.EVENT_SCROLL, function (scrollLeft) { + self.topRightCollection.setScrollLeft(scrollLeft); + self.bottomRightCollection.setScrollLeft(scrollLeft); + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.scrollBarLayout = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.topScrollbar, + right: 0, + top: 0 + }, { + el: this.leftScrollbar, + left: 0, + }, { + el: this.rightScrollbar, + }] + }); + this._width = o.width - BI.GridTableScrollbar.SIZE; + this._height = o.height - BI.GridTableScrollbar.SIZE; + }, + + mounted: function () { + var o = this.options; + if (o.items.length > 0 || o.header.length > 0) { + this._digest(); + this._populate(); + } + }, + + attr: function () { + BI.CanvasTable.superclass.attr.apply(this, arguments); + }, + + _getFreezeColLength: function () { + return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; + }, + + getRegionSize: function () { + var o = this.options; + var regionSize = o.regionColumnSize[0] || 0; + if (o.isNeedFreeze === false || o.freezeCols.length === 0) { + return 0; + } + if (!regionSize) { + BI.each(o.freezeCols, function (i, col) { + regionSize += o.columnSize[col]; + }); + } + return regionSize; + }, + + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + + _digest: function () { + var o = this.options; + var freezeColLength = this._getFreezeColLength(); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } + }, + + _populateScrollbar: function () { + var o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + BI.each(o.columnSize, function (i, size) { + if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { + totalLeftColumnSize += size; + } else { + totalRightColumnSize += size; + } + totalColumnSize += size; + if (i === 0) { + summaryColumnSizeArray[i] = size; + } else { + summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; + } + }); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); + this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); + this.topScrollbar.populate(); + + this.leftScrollbar.setContentSize(totalLeftColumnSize); + this.leftScrollbar.setSize(regionSize); + this.leftScrollbar.setPosition(this.bottomLeftCollection.getScrollLeft()); + this.leftScrollbar.populate(); + + this.rightScrollbar.setContentSize(totalRightColumnSize); + this.rightScrollbar.setSize(this._width - regionSize); + this.rightScrollbar.setPosition(this.bottomRightCollection.getScrollLeft()); + this.rightScrollbar.populate(); + + var items = this.scrollBarLayout.attr("items"); + items[0].top = this._getFreezeHeaderHeight(); + items[1].top = this._height; + items[2].top = this._height; + items[2].left = regionSize; + this.scrollBarLayout.attr("items", items); + this.scrollBarLayout.resize(); + }, + + _populateTable: function () { + var self = this, o = this.options; + var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, + summaryColumnSizeArray = []; + var freezeColLength = this._getFreezeColLength(); + var otlw = regionSize; + var otlh = this._getFreezeHeaderHeight(); + var otrw = this._width - regionSize; + var otrh = this._getFreezeHeaderHeight(); + var oblw = regionSize; + var oblh = this._height - otlh; + var obrw = this._width - regionSize; + var obrh = this._height - otrh; + + var tlw = otlw + this._scrollBarSize; + var tlh = otlh + this._scrollBarSize; + var trw = otrw + this._scrollBarSize; + var trh = otrh + this._scrollBarSize; + var blw = oblw + this._scrollBarSize; + var blh = oblh + this._scrollBarSize; + var brw = obrw + this._scrollBarSize; + var brh = obrh + this._scrollBarSize; + + this.topLeft.setWidth(otlw); + this.topLeft.setHeight(otlh); + this.topRight.setWidth(otrw); + this.topRight.setHeight(otrh); + this.bottomLeft.setWidth(oblw); + this.bottomLeft.setHeight(oblh); + this.bottomRight.setWidth(obrw); + this.bottomRight.setHeight(obrh); + + this.topLeftCollection.setWidth(tlw); + this.topLeftCollection.setHeight(tlh); + this.topRightCollection.setWidth(trw); + this.topRightCollection.setHeight(trh); + this.bottomLeftCollection.setWidth(blw); + this.bottomLeftCollection.setHeight(blh); + this.bottomRightCollection.setWidth(brw); + this.bottomRightCollection.setHeight(brh); + + var items = this.contextLayout.attr("items"); + items[1].left = regionSize; + //items[2].top = this._getFreezeHeaderHeight(); + items[2].top = otrh; + items[3].left = regionSize; + //items[3].top = this._getFreezeHeaderHeight(); + items[3].top = otrh; + this.contextLayout.attr("items", items); + this.contextLayout.resize(); + + var leftHeader = [], rightHeader = [], leftItems = [], rightItems = []; + var run = function (positions, items, rendered) { + BI.each(positions, function (i, item) { + if (BI.isNull(items[item.row][item.col])) { + debugger + } + rendered.push(items[item.row][item.col]); + }); + }; + run(this.topLeftItems, o.header, leftHeader); + run(this.topRightItems, o.header, rightHeader); + run(this.bottomLeftItems, o.items, leftItems); + run(this.bottomRightItems, o.items, rightItems); + + this.topLeftCollection._populate(leftHeader); + this.topRightCollection._populate(rightHeader); + this.bottomLeftCollection._populate(leftItems); + this.bottomRightCollection._populate(rightItems); + }, + + _populate: function () { + if (this._width <= 0 || this._height <= 0) { + return; + } + if (this._isNeedDigest === true) { + this._digest(); + } + this._isNeedDigest = false; + this._populateTable(); + this._populateScrollbar(); + }, + + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; + var self = this, o = this.options; + var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; + var summaryColumnSize = []; + for (var i = startCol; i < endCol; i++) { + if (i === startCol) { + summaryColumnSize[i] = columnSize[i]; + } else { + summaryColumnSize[i] = summaryColumnSize[i - 1] + columnSize[i]; + } + } + var mergeRow = function (i, j) { + preCol[j]._height += rowHeight; + preCol[j].__mergeRows.push(i); + }; + + var mergeCol = function (i, j) { + preRow[i]._width += columnSize[j]; + preRow[i].__mergeCols.push(j); + }; + + var createOneEl = function (r, c) { + var width = columnSize[c]; + var height = rowHeight; + map[r][c]._row = r; + map[r][c]._col = c; + map[r][c]._width = width; + map[r][c]._height = height; + preCol[c] = map[r][c]; + preCol[c].__mergeRows = [r]; + preRow[r] = map[r][c]; + preRow[r].__mergeCols = [c]; + + result.push({ + x: summaryColumnSize[c] - columnSize[c], + y: +r * rowHeight, + item: map[r][c] + }); + }; + + BI.each(items, function (i, cols) { + for (var j = startCol; j < endCol; j++) { + if (!cache[i]) { + cache[i] = {}; + } + if (!map[i]) { + map[i] = {}; + } + cache[i][j] = cols[j]; + map[i][j] = {}; + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { + if (i === 0 && j === startCol) { + createOneEl(0, startCol); + } else if (j === startCol && i > 0) { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + if (isNeedMergeRow === true) { + mergeRow(i, j); + preRow[i] = preCol[j]; + } else { + createOneEl(i, j); + } + } else if (i === 0 && j > startCol) { + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol === true) { + mergeCol(i, j); + preCol[j] = preRow[i]; + } else { + createOneEl(i, j); + } + } else { + var isNeedMergeRow = o.mergeRule(cache[i][j], cache[i - 1][j]); + var isNeedMergeCol = o.mergeRule(cache[i][j], cache[i][j - 1]); + if (isNeedMergeCol && isNeedMergeRow) { + continue; + //mergeRow(i, j);//优先合并列 + } + if (isNeedMergeCol) { + mergeCol(i, j); + } + if (isNeedMergeRow) { + mergeRow(i, j); + } + if (!isNeedMergeCol && !isNeedMergeRow) { + createOneEl(i, j); + } + } + } else { + createOneEl(i, j); + } + } + }); + return BI.map(result, function (i, item) { + return { + x: item.x, + y: item.y, + row: item.item._row, + col: item.item._col, + width: item.item._width, + height: item.item._height + } + }); + }, + + populate: function (items, header) { + if (items && this.options.items !== items) { + this._isNeedDigest = true; + this.options.items = items; + this._restore(); + } + if (header && this.options.header !== header) { + this._isNeedDigest = true; + this.options.header = header; + this._restore(); + } + this._populate(); + }, + + _restore: function () { + this.topLeftCollection.restore(); + this.topRightCollection.restore(); + this.bottomLeftCollection.restore(); + this.bottomRightCollection.restore(); + }, + + restore: function () { + this._restore(); + }, + + setWidth: function (width) { + BI.CanvasTable.superclass.setWidth.apply(this, arguments); + this._width = width - BI.GridTableScrollbar.SIZE; + }, + + setHeight: function (height) { + BI.CanvasTable.superclass.setHeight.apply(this, arguments); + this._height = height - BI.GridTableScrollbar.SIZE; + }, + + setVerticalScroll: function (scrollTop) { + this.bottomLeftCollection.setScrollTop(scrollTop); + this.bottomRightCollection.setScrollTop(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.topLeftCollection.setScrollLeft(scrollLeft); + this.bottomLeftCollection.setScrollLeft(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.topRightCollection.setScrollLeft(scrollLeft); + this.bottomRightCollection.setScrollLeft(scrollLeft); + }, + + getVerticalScroll: function () { + return this.bottomRightCollection.getScrollTop(); + }, + + getLeftHorizontalScroll: function () { + return this.bottomLeftCollection.getScrollLeft(); + }, + + getRightHorizontalScroll: function () { + return this.bottomRightCollection.getScrollLeft(); + }, + + setColumnSize: function (columnSize) { + this._isNeedDigest = true; + this.options.columnSize = columnSize; + }, + + setRegionColumnSize: function (regionColumnSize) { + this._isNeedDigest = true; + this.options.regionColumnSize = regionColumnSize; + }, + + getColumnSize: function () { + return this.options.columnSize; + }, + + getRegionColumnSize: function () { + return this.options.regionColumnSize; + }, +}); + +BI.shortcut("bi.canvas_table", BI.CanvasTable); \ No newline at end of file