").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
+ } else {
+ n.text = BI.replaceAll((n.text + ""), " ", " ");
+ }
+ });
+ return nodes;
+ },
+
+ _loadMore: function () {
+ var self = this, o = this.options;
+ this.tip.setLoading();
+ var op = BI.extend({}, o.paras, {
+ times: ++this.times
+ });
+ o.itemsCreator(op, function (res) {
+ if (self._stop === true) {
+ return;
+ }
+ var hasNext = !!res.hasNext, nodes = res.items || [];
+
+ if (!hasNext) {
+ self.tip.setEnd();
+ } else {
+ self.tip.setLoaded();
+ }
+ if (nodes.length > 0) {
+ self.nodes.addNodes(null, self._dealWidthNodes(nodes));
+ }
+ });
+ },
+
+ // 生成树内部方法
+ _initTree: function (setting) {
+ var self = this, o = this.options;
+ self.fireEvent(BI.Events.INIT);
+ this.times = 1;
+ var tree = this.tree;
+ tree.empty();
+ this.loading();
+ this.tip.setVisible(false);
+ var callback = function (nodes) {
+ if (self._stop === true) {
+ return;
+ }
+ self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
+ };
+ var op = BI.extend({}, o.paras, {
+ times: 1
+ });
+
+ o.itemsCreator(op, function (res) {
+ if (self._stop === true) {
+ return;
+ }
+ var hasNext = !!res.hasNext, nodes = res.items || [];
+ if (nodes.length > 0) {
+ callback(self._dealWidthNodes(nodes));
+ }
+ self.setTipVisible(nodes.length <= 0);
+ self.loaded();
+ if (!hasNext) {
+ self.tip.invisible();
+ } else {
+ self.tip.setLoaded();
+ }
+ op.times === 1 && self.fireEvent(BI.Events.AFTERINIT);
+ });
+ },
+
+ // 构造树结构,
+ initTree: function (nodes, setting) {
+ var setting = setting || {
+ async: {
+ enable: false
+ },
+ check: {
+ enable: false
+ },
+ data: {
+ key: {
+ title: "title",
+ name: "text"
+ },
+ simpleData: {
+ enable: true
+ }
+ },
+ view: {
+ showIcon: false,
+ expandSpeed: "",
+ nameIsHTML: true
+ },
+ callback: {}
+ };
+ this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes);
+ },
+
+ start: function () {
+ this._stop = false;
+ },
+
+ stop: function () {
+ this._stop = true;
+ },
+
+ // 生成树方法
+ stroke: function (config) {
+ delete this.options.keyword;
+ BI.extend(this.options.paras, config);
+ var setting = this._configSetting();
+ this._createTree();
+ this.start();
+ this._initTree(setting);
+ },
+
+ populate: function () {
+ this.stroke.apply(this, arguments);
+ },
+
+ hasChecked: function () {
+ var treeObj = this.nodes;
+ return treeObj.getCheckedNodes(true).length > 0;
+ },
+
+ checkAll: function (checked) {
+ function setNode (children) {
+ BI.each(children, function (i, child) {
+ child.halfCheck = false;
+ setNode(child.children);
+ });
+ }
+
+ if (!this.nodes) {
+ return;
+ }
+
+ BI.each(this.nodes.getNodes(), function (i, node) {
+ node.halfCheck = false;
+ setNode(node.children);
+ });
+ this.nodes.checkAllNodes(checked);
+ },
+
+ expandAll: function (flag) {
+ this.nodes && this.nodes.expandAll(flag);
+ },
+
+ // 设置树节点的状态
+ setValue: function (value, param) {
+ this.checkAll(false);
+ this.updateValue(value, param);
+ this.refresh();
+ },
+
+ setSelectedValue: function (value) {
+ this.options.paras.selectedValues = BI.deepClone(value || {});
+ },
+
+ updateValue: function (values, param) {
+ if (!this.nodes) {
+ return;
+ }
+ param || (param = "value");
+ var treeObj = this.nodes;
+ BI.each(values, function (v, op) {
+ var nodes = treeObj.getNodesByParam(param, v, null);
+ BI.each(nodes, function (j, node) {
+ BI.extend(node, {checked: true}, op);
+ treeObj.updateNode(node);
+ });
+ });
+ },
+
+ refresh: function () {
+ this.nodes && this.nodes.refresh();
+ },
+
+ getValue: function () {
+ if (!this.nodes) {
+ return null;
+ }
+ return this._getSelectedValues();
+ },
+
+ destroyed: function () {
+ this.stop();
+ this.nodes && this.nodes.destroy();
+ }
+});
+BI.extend(BI.TreeView, {
+ REQ_TYPE_INIT_DATA: 1,
+ REQ_TYPE_ADJUST_DATA: 2,
+ REQ_TYPE_SELECT_DATA: 3,
+ REQ_TYPE_GET_SELECTED_DATA: 4
+});
+
+BI.TreeView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.TreeView.EVENT_INIT = BI.Events.INIT;
+BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT;
+
+BI.shortcut("bi.tree_view", BI.TreeView);/**
+ * guy
+ * 同步树
+ * @class BI.AsyncTree
+ * @extends BI.TreeView
+ */
+BI.AsyncTree = BI.inherit(BI.TreeView, {
+ _defaultConfig: function () {
+ return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {});
+ },
+ _init: function () {
+ BI.AsyncTree.superclass._init.apply(this, arguments);
+ },
+
+ // 配置属性
+ _configSetting: function () {
+ var paras = this.options.paras;
+ var self = this;
+ var setting = {
+ async: {
+ enable: false,
+ otherParam: BI.cjkEncodeDO(paras)
+ },
+ check: {
+ enable: true
+ },
+ data: {
+ key: {
+ title: "title",
+ name: "text"
+ },
+ simpleData: {
+ enable: true
+ }
+ },
+ view: {
+ showIcon: false,
+ expandSpeed: "",
+ nameIsHTML: true,
+ dblClickExpand: false
+ },
+ callback: {
+ beforeCheck: beforeCheck,
+ onCheck: onCheck,
+ beforeExpand: beforeExpand,
+ onExpand: onExpand,
+ onCollapse: onCollapse,
+ onClick: onClick
+ }
+ };
+
+ function onClick (event, treeId, treeNode) {
+ var zTree = $.fn.zTree.getZTreeObj(treeId);
+ zTree.checkNode(treeNode, !treeNode.checked, true, true);
+ }
+
+ function beforeCheck (treeId, treeNode) {
+ treeNode.halfCheck = false;
+ if (treeNode.checked === true) {
+ // 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy
+ // 所有的半选状态都需要取消halfCheck=true的情况
+ function track (children) {
+ BI.each(children, function (i, ch) {
+ if (ch.halfCheck === true) {
+ ch.halfCheck = false;
+ track(ch.children);
+ }
+ });
+ }
+
+ track(treeNode.children);
+
+ var treeObj = $.fn.zTree.getZTreeObj(treeId);
+ var nodes = treeObj.getSelectedNodes();
+ BI.each(nodes, function (index, node) {
+ node.halfCheck = false;
+ });
+ }
+ var status = treeNode.getCheckStatus();
+ // 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选
+ if(status.half === true && status.checked === true) {
+ treeNode.checked = false;
+ }
+ }
+
+ function beforeExpand (treeId, treeNode) {
+ self._beforeExpandNode(treeId, treeNode);
+ }
+
+ function onCheck (event, treeId, treeNode) {
+ self._selectTreeNode(treeId, treeNode);
+ }
+
+ function onExpand (event, treeId, treeNode) {
+ treeNode.halfCheck = false;
+ }
+
+ function onCollapse (event, treeId, treeNode) {
+ treeNode.halfCheck = false;
+ }
+
+ return setting;
+ },
+
+ _selectTreeNode: function (treeId, treeNode) {
+ var self = this, o = this.options;
+ var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode));
+ var name = this._getNodeValue(treeNode);
+ // var values = parentValues.concat([name]);
+ if (treeNode.checked === true) {
+ } else {
+ var tNode = treeNode;
+ var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
+ if (BI.isNotNull(pNode[name])) {
+ delete pNode[name];
+ }
+ while (tNode != null && BI.isEmpty(pNode)) {
+ parentValues = parentValues.slice(0, parentValues.length - 1);
+ tNode = tNode.getParentNode();
+ if (tNode != null) {
+ pNode = this._getTree(this.options.paras.selectedValues, parentValues);
+ name = this._getNodeValue(tNode);
+ delete pNode[name];
+ }
+ }
+ }
+ BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
+ },
+
+ // 展开节点
+ _beforeExpandNode: function (treeId, treeNode) {
+ var self = this, o = this.options;
+ var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
+ var op = BI.extend({}, o.paras, {
+ id: treeNode.id,
+ times: 1,
+ parentValues: parentValues.concat(this._getNodeValue(treeNode)),
+ checkState: treeNode.getCheckStatus()
+ });
+ var complete = function (d) {
+ var nodes = d.items || [];
+ if (nodes.length > 0) {
+ callback(self._dealWidthNodes(nodes), !!d.hasNext);
+ }
+ };
+ var times = 1;
+
+ function callback (nodes, hasNext) {
+ self.nodes.addNodes(treeNode, nodes);
+
+ if (hasNext === true) {
+ BI.delay(function () {
+ times++;
+ op.times = times;
+ o.itemsCreator(op, complete);
+ }, 100);
+ }
+ }
+
+ if (!treeNode.children) {
+ setTimeout(function () {
+ o.itemsCreator(op, complete);
+ }, 17);
+ }
+ },
+
+ _join: function (valueA, valueB) {
+ var self = this;
+ var map = {};
+ track([], valueA, valueB);
+ track([], valueB, valueA);
+ function track (parent, node, compare) {
+ BI.each(node, function (n, item) {
+ if (BI.isNull(compare[n])) {
+ self._addTreeNode(map, parent, n, item);
+ } else if (BI.isEmpty(compare[n])) {
+ self._addTreeNode(map, parent, n, {});
+ } else {
+ track(parent.concat([n]), node[n], compare[n]);
+ }
+ });
+ }
+
+ return map;
+ },
+
+ hasChecked: function () {
+ return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
+ },
+
+ getValue: function () {
+ if (!this.nodes) {
+ return {};
+ }
+ var checkedValues = this._getSelectedValues();
+ if (BI.isEmpty(checkedValues)) {
+ return BI.deepClone(this.options.paras.selectedValues);
+ }
+ if (BI.isEmpty(this.options.paras.selectedValues)) {
+ return checkedValues;
+ }
+ return this._join(checkedValues, this.options.paras.selectedValues);
+ },
+
+ // 生成树方法
+ stroke: function (config) {
+ delete this.options.keyword;
+ BI.extend(this.options.paras, config);
+ var setting = this._configSetting();
+ this._initTree(setting);
+ }
+});
+
+BI.shortcut("bi.async_tree", BI.AsyncTree);/**
+ * guy
+ * 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点
+ * @class BI.PartTree
+ * @extends BI.AsyncTree
+ */
+BI.PartTree = BI.inherit(BI.AsyncTree, {
+ _defaultConfig: function () {
+ return BI.extend(BI.PartTree.superclass._defaultConfig.apply(this, arguments), {});
+ },
+
+ _init: function () {
+ BI.PartTree.superclass._init.apply(this, arguments);
+ },
+
+ _loadMore: function () {
+ var self = this, o = this.options;
+ var op = BI.extend({}, o.paras, {
+ type: BI.TreeView.REQ_TYPE_INIT_DATA,
+ times: ++this.times
+ });
+ this.tip.setLoading();
+ o.itemsCreator(op, function (d) {
+ var hasNext = !!d.hasNext, nodes = d.items || [];
+ o.paras.lastSearchValue = d.lastSearchValue;
+ if (self._stop === true) {
+ return;
+ }
+ if (!hasNext) {
+ self.tip.setEnd();
+ } else {
+ self.tip.setLoaded();
+ }
+ if (nodes.length > 0) {
+ self.nodes.addNodes(null, self._dealWidthNodes(nodes));
+ }
+ });
+ },
+
+ _selectTreeNode: function (treeId, treeNode) {
+ var self = this, o = this.options;
+ var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode));
+ var name = this._getNodeValue(treeNode);
+ if (treeNode.checked === true) {
+ BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
+ } else {
+ // 如果选中的值中不存在该值不处理
+ var t = this.options.paras.selectedValues;
+ var p = parentValues.concat(name);
+ for (var i = 0, len = p.length; i < len; i++) {
+ t = t[p[i]];
+ if (t == null) {
+ return;
+ }
+ if (BI.isEmpty(t)) {
+ break;
+ }
+ }
+ o.itemsCreator(BI.extend({}, o.paras, {
+ type: BI.TreeView.REQ_TYPE_SELECT_DATA,
+ notSelectedValue: name,
+ parentValues: parentValues
+ }), function (new_values) {
+ self.options.paras.selectedValues = new_values;
+ BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
+ });
+ }
+ },
+
+ _getSelectedValues: function () {
+ var self = this;
+ var hashMap = {};
+ var rootNoots = this.nodes.getNodes();
+ track(rootNoots);
+ function track (nodes) {
+ BI.each(nodes, function (i, node) {
+ var checkState = node.getCheckStatus();
+ if (checkState.checked === false) {
+ return true;
+ }
+ var parentValues = node.parentValues || self._getParentValues(node);
+ // 把文字中的html去掉,其实就是把文字颜色去掉
+ var values = parentValues.concat([self._getNodeValue(node)]);
+ self._buildTree(hashMap, values);
+ // if(checkState.checked === true && checkState.half === false && nodes[i].flag === true){
+ // continue;
+ // }
+ if (BI.isNotEmptyArray(node.children)) {
+ track(node.children);
+ return true;
+ }
+ if (checkState.half === true) {
+ self._getHalfSelectedValues(hashMap, node);
+ }
+ });
+ }
+
+ return hashMap;
+ },
+
+ _initTree: function (setting, keyword) {
+ var self = this, o = this.options;
+ this.times = 1;
+ var tree = this.tree;
+ tree.empty();
+ self.tip.setVisible(false);
+ this.loading();
+ var op = BI.extend({}, o.paras, {
+ type: BI.TreeView.REQ_TYPE_INIT_DATA,
+ times: this.times
+ });
+ var complete = function (d) {
+ if (self._stop === true || keyword != o.paras.keyword) {
+ return;
+ }
+ var hasNext = !!d.hasNext, nodes = d.items || [];
+ o.paras.lastSearchValue = d.lastSearchValue;
+ if (nodes.length > 0) {
+ callback(self._dealWidthNodes(nodes));
+ }
+ self.setTipVisible(nodes.length <= 0);
+ self.loaded();
+ if (!hasNext) {
+ self.tip.invisible();
+ } else {
+ self.tip.setLoaded();
+ }
+ self.fireEvent(BI.Events.AFTERINIT);
+ };
+
+ function callback (nodes) {
+ if (self._stop === true) {
+ return;
+ }
+ self.nodes = $.fn.zTree.init(tree.element, setting, nodes);
+ }
+
+ BI.delay(function () {
+ o.itemsCreator(op, complete);
+ }, 100);
+ },
+
+ getValue: function () {
+ var o = this.options;
+ var result = BI.PartTree.superclass.getValue.apply(this, arguments);
+ o.itemsCreator({
+ type: BI.TreeView.REQ_TYPE_ADJUST_DATA,
+ selectedValues: result
+ }, function (res) {
+ result = res;
+ });
+ return result;
+ },
+
+ // 生成树方法
+ stroke: function (config) {
+ var o = this.options;
+ delete o.paras.keyword;
+ BI.extend(o.paras, config);
+ delete o.paras.lastSearchValue;
+ var setting = this._configSetting();
+ this._initTree(setting, o.paras.keyword);
+ }
+});
+
+BI.shortcut("bi.part_tree", BI.PartTree);BI.prepares.push(function () {
+ BI.Resizers = new BI.ResizeController();
+ BI.Layers = new BI.LayerController();
+ BI.Maskers = new BI.MaskersController();
+ BI.Bubbles = new BI.BubblesController();
+ BI.Tooltips = new BI.TooltipsController();
+ BI.Popovers = new BI.PopoverController();
+ BI.Broadcasts = new BI.BroadcastController();
+ BI.StyleLoaders = new BI.StyleLoaderManager();
+});
+/**
+ * CollectionView
+ *
+ * Created by GUY on 2016/1/15.
+ * @class BI.CollectionView
+ * @extends BI.Widget
+ */
+BI.CollectionView = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-collection",
+ // width: 400, //必设
+ // height: 300, //必设
+ overflowX: true,
+ overflowY: true,
+ cellSizeAndPositionGetter: BI.emptyFn,
+ horizontalOverscanSize: 0,
+ verticalOverscanSize: 0,
+ scrollLeft: 0,
+ scrollTop: 0,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.CollectionView.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ this.renderRange = {};
+ this._scrollLock = false;
+ this._debounceRelease = BI.debounce(function () {
+ self._scrollLock = false;
+ }, 1000 / 60);
+ this.container = BI.createWidget({
+ type: "bi.absolute"
+ });
+ this.element.scroll(function () {
+ if (self._scrollLock === true) {
+ return;
+ }
+ o.scrollLeft = self.element.scrollLeft();
+ o.scrollTop = self.element.scrollTop();
+ self._calculateChildrenToRender();
+ self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
+ scrollLeft: o.scrollLeft,
+ scrollTop: o.scrollTop
+ });
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ scrollable: o.overflowX === true && o.overflowY === true,
+ scrolly: o.overflowX === false && o.overflowY === true,
+ scrollx: o.overflowX === true && o.overflowY === false,
+ items: [this.container]
+ });
+ if (o.items.length > 0) {
+ this._calculateSizeAndPositionData();
+ this._populate();
+ }
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
+ this.element.scrollTop(o.scrollTop);
+ this.element.scrollLeft(o.scrollLeft);
+ }
+ },
+
+ _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;
+ this._height = height;
+ this._width = width;
+ },
+
+ _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 self = this, o = this.options;
+ var scrollLeft = BI.clamp(o.scrollLeft, 0, this._getMaxScrollLeft());
+ var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop());
+ 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) {
+ // 如果滚动的区间并没有超出渲染的范围
+ if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) {
+ return;
+ }
+ var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
+ var renderedCells = [], renderedKeys = {}, renderedWidgets = {};
+ // 存储所有的left和top
+ var lefts = {}, tops = {};
+ for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
+ var datum = childrenToDisplay[i];
+ lefts[datum.x] = datum.x;
+ lefts[datum.x + datum.width] = datum.x + datum.width;
+ tops[datum.y] = datum.y;
+ tops[datum.y + datum.height] = datum.y + datum.height;
+ }
+ lefts = BI.toArray(lefts);
+ tops = BI.toArray(tops);
+ var leftMap = BI.invert(lefts);
+ var topMap = BI.invert(tops);
+ // 存储上下左右四个边界
+ var leftBorder = {}, rightBorder = {}, topBorder = {}, bottomBorder = {};
+ var assertMinBorder = function (border, offset) {
+ if (border[offset] == null) {
+ border[offset] = Number.MAX_VALUE;
+ }
+ };
+ var assertMaxBorder = function (border, offset) {
+ if (border[offset] == null) {
+ border[offset] = 0;
+ }
+ };
+ for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
+ var datum = childrenToDisplay[i];
+ var index = this.renderedKeys[datum.index] && this.renderedKeys[datum.index][1];
+ var child;
+ if (index >= 0) {
+ if (datum.width !== this.renderedCells[index]._width) {
+ this.renderedCells[index]._width = datum.width;
+ this.renderedCells[index].el.setWidth(datum.width);
+ }
+ if (datum.height !== this.renderedCells[index]._height) {
+ this.renderedCells[index]._height = datum.height;
+ this.renderedCells[index].el.setHeight(datum.height);
+ }
+ if (this.renderedCells[index]._left !== datum.x) {
+ this.renderedCells[index].el.element.css("left", datum.x + "px");
+ }
+ if (this.renderedCells[index]._top !== datum.y) {
+ this.renderedCells[index].el.element.css("top", datum.y + "px");
+ }
+ renderedCells.push(child = this.renderedCells[index]);
+ } else {
+ child = BI.createWidget(BI.extend({
+ type: "bi.label",
+ width: datum.width,
+ height: datum.height
+ }, o.items[datum.index], {
+ cls: (o.items[datum.index].cls || "") + " container-cell" + (datum.y === 0 ? " first-row" : "") + (datum.x === 0 ? " first-col" : ""),
+ _left: datum.x,
+ _top: datum.y
+ }));
+ renderedCells.push({
+ el: child,
+ left: datum.x,
+ top: datum.y,
+ _left: datum.x,
+ _top: datum.y,
+ _width: datum.width,
+ _height: datum.height
+ });
+ }
+ var startTopIndex = topMap[datum.y] | 0;
+ var endTopIndex = topMap[datum.y + datum.height] | 0;
+ for (var k = startTopIndex; k <= endTopIndex; k++) {
+ var t = tops[k];
+ assertMinBorder(leftBorder, t);
+ assertMaxBorder(rightBorder, t);
+ leftBorder[t] = Math.min(leftBorder[t], datum.x);
+ rightBorder[t] = Math.max(rightBorder[t], datum.x + datum.width);
+ }
+ var startLeftIndex = leftMap[datum.x] | 0;
+ var endLeftIndex = leftMap[datum.x + datum.width] | 0;
+ for (var k = startLeftIndex; k <= endLeftIndex; k++) {
+ var l = lefts[k];
+ assertMinBorder(topBorder, l);
+ assertMaxBorder(bottomBorder, l);
+ topBorder[l] = Math.min(topBorder[l], datum.y);
+ bottomBorder[l] = Math.max(bottomBorder[l], datum.y + datum.height);
+ }
+
+ renderedKeys[datum.index] = [datum.index, i];
+ renderedWidgets[i] = child;
+ }
+ // 已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (self.renderedKeys[i]) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (existSet[i]) {
+ return;
+ }
+ if (addSet[i]) {
+ return;
+ }
+ deleteArray.push(key[1]);
+ });
+ BI.each(deleteArray, function (i, index) {
+ // 性能优化,不调用destroy方法防止触发destroy事件
+ self.renderedCells[index].el._destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index, key) {
+ addedItems.push(renderedCells[key[1]]);
+ });
+ this.container.addItems(addedItems);
+ // 拦截父子级关系
+ this.container._children = renderedWidgets;
+ this.container.attr("items", renderedCells);
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+
+ // Todo 左右比较特殊
+ var minX = BI.min(leftBorder);
+ var maxX = BI.max(rightBorder);
+
+ var minY = BI.max(topBorder);
+ var maxY = BI.min(bottomBorder);
+
+ this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
+ }
+ },
+
+ _getMaxScrollLeft: function () {
+ return Math.max(0, this._width - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0));
+ },
+
+ _getMaxScrollTop: function () {
+ return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
+ },
+
+ _populate: function (items) {
+ var o = this.options;
+ this._reRange();
+ if (items && items !== this.options.items) {
+ this.options.items = items;
+ this._calculateSizeAndPositionData();
+ }
+ if (o.items.length > 0) {
+ this.container.setWidth(this._width);
+ this.container.setHeight(this._height);
+
+ this._calculateChildrenToRender();
+ // 元素未挂载时不能设置scrollTop
+ try {
+ this.element.scrollTop(o.scrollTop);
+ this.element.scrollLeft(o.scrollLeft);
+ } catch (e) {
+ }
+ }
+ },
+
+ setScrollLeft: function (scrollLeft) {
+ if (this.options.scrollLeft === scrollLeft) {
+ return;
+ }
+ this._scrollLock = true;
+ this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getMaxScrollLeft());
+ this._debounceRelease();
+ this._calculateChildrenToRender();
+ this.element.scrollLeft(this.options.scrollLeft);
+ },
+
+ setScrollTop: function (scrollTop) {
+ if (this.options.scrollTop === scrollTop) {
+ return;
+ }
+ this._scrollLock = true;
+ this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop());
+ this._debounceRelease();
+ this._calculateChildrenToRender();
+ this.element.scrollTop(this.options.scrollTop);
+ },
+
+ setOverflowX: function (b) {
+ var self = this;
+ if (this.options.overflowX !== !!b) {
+ this.options.overflowX = !!b;
+ BI.nextTick(function () {
+ self.element.css({overflowX: b ? "auto" : "hidden"});
+ });
+ }
+ },
+
+ setOverflowY: function (b) {
+ var self = this;
+ if (this.options.overflowY !== !!b) {
+ this.options.overflowY = !!b;
+ BI.nextTick(function () {
+ self.element.css({overflowY: b ? "auto" : "hidden"});
+ });
+ }
+ },
+
+ getScrollLeft: function () {
+ return this.options.scrollLeft;
+ },
+
+ getScrollTop: function () {
+ return this.options.scrollTop;
+ },
+
+ getMaxScrollLeft: function () {
+ return this._getMaxScrollLeft();
+ },
+
+ getMaxScrollTop: function () {
+ return this._getMaxScrollTop();
+ },
+
+ // 重新计算children
+ _reRange: function () {
+ this.renderRange = {};
+ },
+
+ _clearChildren: function () {
+ this.container._children = {};
+ this.container.attr("items", []);
+ },
+
+ restore: function () {
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el._destroy();
+ });
+ this._clearChildren();
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ this.renderRange = {};
+ this._scrollLock = false;
+ },
+
+ populate: function (items) {
+ if (items && items !== this.options.items) {
+ this.restore();
+ }
+ this._populate(items);
+ }
+});
+BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
+BI.shortcut("bi.collection_view", BI.CollectionView);/**
+ * @class BI.Combo
+ * @extends BI.Widget
+ */
+BI.Combo = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ var conf = BI.Combo.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-combo",
+ trigger: "click",
+ toggle: true,
+ direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right
+ container: null, // popupview放置的容器,默认为this.element
+ isDefaultInit: false,
+ destroyWhenHide: false,
+ isNeedAdjustHeight: true, // 是否需要高度调整
+ isNeedAdjustWidth: true,
+ stopEvent: false,
+ stopPropagation: false,
+ adjustLength: 0, // 调整的距离
+ adjustXOffset: 0,
+ adjustYOffset: 0,
+ hideChecker: BI.emptyFn,
+ offsetStyle: "left", // left,right,center
+ el: {},
+ popup: {},
+ comboClass: "bi-combo-popup",
+ hoverClass: "bi-combo-hover"
+ });
+ },
+
+ _init: function () {
+ BI.Combo.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._initCombo();
+ this._initPullDownAction();
+ this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (self.isEnabled() && self.isValid()) {
+ if (type === BI.Events.EXPAND) {
+ self._popupView();
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self._hideView();
+ }
+ if (type === BI.Events.EXPAND) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.Combo.EVENT_EXPAND);
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.isViewVisible() && self.fireEvent(BI.Combo.EVENT_COLLAPSE);
+ }
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Combo.EVENT_TRIGGER_CHANGE, obj);
+ }
+ }
+ });
+
+ self.element.on("mouseenter." + self.getName(), function (e) {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
+ self.element.addClass(o.hoverClass);
+ }
+ });
+ self.element.on("mouseleave." + self.getName(), function (e) {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
+ self.element.removeClass(o.hoverClass);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [
+ {el: this.combo}
+ ]
+ });
+ o.isDefaultInit && (this._assertPopupView());
+ BI.Resizers.add(this.getName(), BI.bind(function () {
+ if (this.isViewVisible()) {
+ this._hideView();
+ }
+ }, this));
+ },
+
+ _toggle: function () {
+ this._assertPopupViewRender();
+ if (this.popupView.isVisible()) {
+ this._hideView();
+ } else {
+ if (this.isEnabled()) {
+ this._popupView();
+ }
+ }
+ },
+
+ _initPullDownAction: function () {
+ var self = this, o = this.options;
+ var evs = this.options.trigger.split(",");
+ var st = function (e) {
+ if (o.stopEvent) {
+ e.stopEvent();
+ }
+ if (o.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ var enterPopup = false;
+
+ function hide () {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
+ self._hideView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
+ self.fireEvent(BI.Combo.EVENT_COLLAPSE);
+ }
+ self.popupView && self.popupView.element.off("mouseenter." + self.getName()).off("mouseleave." + self.getName());
+ enterPopup = false;
+ }
+
+ BI.each(evs, function (i, ev) {
+ switch (ev) {
+ case "hover":
+ self.element.on("mouseenter." + self.getName(), function (e) {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
+ self._popupView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
+ self.fireEvent(BI.Combo.EVENT_EXPAND);
+ }
+ });
+ self.element.on("mouseleave." + self.getName(), function (e) {
+ if (self.popupView) {
+ self.popupView.element.on("mouseenter." + self.getName(), function (e) {
+ enterPopup = true;
+ self.popupView.element.on("mouseleave." + self.getName(), function (e) {
+ hide();
+ });
+ self.popupView.element.off("mouseenter." + self.getName());
+ });
+ BI.defer(function () {
+ if (!enterPopup) {
+ hide();
+ }
+ }, 50);
+ }
+ });
+ break;
+ case "click":
+ var debounce = BI.debounce(function (e) {
+ if (self.combo.element.__isMouseInBounds__(e)) {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
+ // if (!o.toggle && self.isViewVisible()) {
+ // return;
+ // }
+ o.toggle ? self._toggle() : self._popupView();
+ if (self.isViewVisible()) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
+ self.fireEvent(BI.Combo.EVENT_EXPAND);
+ } else {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
+ self.fireEvent(BI.Combo.EVENT_COLLAPSE);
+ }
+ }
+ }
+ }, BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ self.element.off(ev + "." + self.getName()).on(ev + "." + self.getName(), function (e) {
+ debounce(e);
+ st(e);
+ });
+ break;
+ case "click-hover":
+ var debounce = BI.debounce(function (e) {
+ if (self.combo.element.__isMouseInBounds__(e)) {
+ if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
+ // if (self.isViewVisible()) {
+ // return;
+ // }
+ self._popupView();
+ if (self.isViewVisible()) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
+ self.fireEvent(BI.Combo.EVENT_EXPAND);
+ }
+ }
+ }
+ }, BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) {
+ debounce(e);
+ st(e);
+ });
+ self.element.on("mouseleave." + self.getName(), function (e) {
+ if (self.popupView) {
+ self.popupView.element.on("mouseenter." + self.getName(), function (e) {
+ enterPopup = true;
+ self.popupView.element.on("mouseleave." + self.getName(), function (e) {
+ hide();
+ });
+ self.popupView.element.off("mouseenter." + self.getName());
+ });
+ BI.defer(function () {
+ if (!enterPopup) {
+ hide();
+ }
+ }, 50);
+ }
+ });
+ break;
+ }
+ });
+ },
+
+ _initCombo: function () {
+ this.combo = BI.createWidget(this.options.el, {
+ value: this.options.value
+ });
+ },
+
+ _assertPopupView: function () {
+ var self = this, o = this.options;
+ if (this.popupView == null) {
+ this.popupView = BI.createWidget(this.options.popup, {
+ type: "bi.popup_view",
+ value: o.value
+ }, this);
+ this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (type === BI.Events.CLICK) {
+ self.combo.setValue(self.getValue());
+ self.fireEvent(BI.Combo.EVENT_CHANGE, value, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.popupView.setVisible(false);
+ BI.nextTick(function () {
+ self.fireEvent(BI.Combo.EVENT_AFTER_INIT);
+ });
+ }
+ },
+
+ _assertPopupViewRender: function () {
+ this._assertPopupView();
+ if (!this._rendered) {
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this.options.container || this,
+ items: [
+ {el: this.popupView}
+ ]
+ });
+ this._rendered = true;
+ }
+ },
+
+ _hideIf: function (e) {
+ // if (this.element.__isMouseInBounds__(e) || (this.popupView && this.popupView.element.__isMouseInBounds__(e))) {
+ // return;
+ // }
+ // BI-10290 公式combo双击公式内容会收起
+ if ((this.element.find(e.target).length > 0)
+ || (this.popupView && this.popupView.element.find(e.target).length > 0)
+ || e.target.className === "CodeMirror-cursor" || BI.Widget._renderEngine.createElement(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下
+ return;
+ }
+ var isHide = this.options.hideChecker.apply(this, [e]);
+ if (isHide === false) {
+ return;
+ }
+ this._hideView();
+ },
+
+ _hideView: function () {
+ this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW);
+ if (this.options.destroyWhenHide === true) {
+ this.popupView && this.popupView.destroy();
+ this.popupView = null;
+ this._rendered = false;
+ } else {
+ this.popupView && this.popupView.invisible();
+ }
+ this.element.removeClass(this.options.comboClass);
+
+ BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
+ this.fireEvent(BI.Combo.EVENT_AFTER_HIDEVIEW);
+ },
+
+ _popupView: function () {
+ this._assertPopupViewRender();
+ this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW);
+
+ this.popupView.visible();
+ this.adjustWidth();
+ this.adjustHeight();
+
+ this.element.addClass(this.options.comboClass);
+ BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName());
+ BI.Widget._renderEngine.createElement(document).bind("mousedown." + this.getName(), BI.bind(this._hideIf, this)).bind("mousewheel." + this.getName(), BI.bind(this._hideIf, this));
+ this.fireEvent(BI.Combo.EVENT_AFTER_POPUPVIEW);
+ },
+
+ adjustWidth: function () {
+ var o = this.options;
+ if (!this.popupView) {
+ return;
+ }
+ if (o.isNeedAdjustWidth === true) {
+ this.resetListWidth("");
+ var width = this.popupView.element.outerWidth();
+ var maxW = this.element.outerWidth() || o.width;
+ if (width > maxW + 80) {
+ maxW = maxW + 80;
+ } else if (width > maxW) {
+ maxW = width;
+ }
+ this.resetListWidth(maxW < 100 ? 100 : maxW);
+ }
+ },
+
+ adjustHeight: function () {
+ var o = this.options, p = {};
+ if (!this.popupView) {
+ return;
+ }
+ var isVisible = this.popupView.isVisible();
+ this.popupView.visible();
+ switch (o.direction) {
+ case "bottom":
+ case "bottom,right":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["bottom", "top", "right", "left"], o.offsetStyle);
+ break;
+ case "top":
+ case "top,right":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["top", "bottom", "right", "left"], o.offsetStyle);
+ break;
+ case "left":
+ case "left,bottom":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "bottom", "top"], o.offsetStyle);
+ break;
+ case "right":
+ case "right,bottom":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "bottom", "top"], o.offsetStyle);
+ break;
+ case "top,left":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["top", "bottom", "left", "right"], o.offsetStyle);
+ break;
+ case "bottom,left":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight, ["bottom", "top", "left", "right"], o.offsetStyle);
+ break;
+ case "left,top":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["left", "right", "top", "bottom"], o.offsetStyle);
+ break;
+ case "right,top":
+ p = $.getComboPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength, o.adjustYOffset, o.isNeedAdjustHeight, ["right", "left", "top", "bottom"], o.offsetStyle);
+ break;
+ case "top,custom":
+ case "custom,top":
+ p = $.getTopAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight);
+ break;
+ case "custom,bottom":
+ case "bottom,custom":
+ p = $.getBottomAdaptPosition(this.combo, this.popupView, o.adjustYOffset || o.adjustLength, o.isNeedAdjustHeight);
+ break;
+ case "left,custom":
+ case "custom,left":
+ p = $.getLeftAdaptPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength);
+ delete p.top;
+ delete p.adaptHeight;
+ break;
+ case "custom,right":
+ case "right,custom":
+ p = $.getRightAdaptPosition(this.combo, this.popupView, o.adjustXOffset || o.adjustLength);
+ delete p.top;
+ delete p.adaptHeight;
+ break;
+ }
+
+ if ("adaptHeight" in p) {
+ this.resetListHeight(p["adaptHeight"]);
+ }
+ if ("left" in p) {
+ this.popupView.element.css({
+ left: p.left
+ });
+ }
+ if ("top" in p) {
+ this.popupView.element.css({
+ top: p.top
+ });
+ }
+ this.position = p;
+ this.popupView.setVisible(isVisible);
+ },
+
+ resetListHeight: function (h) {
+ this._assertPopupView();
+ this.popupView.resetHeight && this.popupView.resetHeight(h);
+ },
+
+ resetListWidth: function (w) {
+ this._assertPopupView();
+ this.popupView.resetWidth && this.popupView.resetWidth(w);
+ },
+
+ populate: function (items) {
+ this._assertPopupView();
+ this.popupView.populate.apply(this.popupView, arguments);
+ this.combo.populate.apply(this.combo, arguments);
+ },
+
+ _setEnable: function (arg) {
+ BI.Combo.superclass._setEnable.apply(this, arguments);
+ if (arg === true) {
+ this.element.removeClass("base-disabled disabled");
+ } else if (arg === false) {
+ this.element.addClass("base-disabled disabled");
+ }
+ !arg && this.element.removeClass(this.options.hoverClass);
+ !arg && this.isViewVisible() && this._hideView();
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ if (BI.isNull(this.popupView)) {
+ this.options.popup.value = v;
+ } else {
+ this.popupView.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (BI.isNull(this.popupView)) {
+ return this.options.popup.value;
+ } else {
+ return this.popupView.getValue();
+ }
+ },
+
+ isViewVisible: function () {
+ return this.isEnabled() && this.combo.isEnabled() && !!this.popupView && this.popupView.isVisible();
+ },
+
+ showView: function () {
+ if (this.isEnabled() && this.combo.isEnabled()) {
+ this._popupView();
+ }
+ },
+
+ hideView: function () {
+ this._hideView();
+ },
+
+ getView: function () {
+ return this.popupView;
+ },
+
+ getPopupPosition: function () {
+ return this.position;
+ },
+
+ toggle: function () {
+ this._toggle();
+ },
+
+ destroy: function () {
+ BI.Widget._renderEngine.createElement(document).unbind("mousedown." + this.getName())
+ .unbind("mousewheel." + this.getName())
+ .unbind("mouseenter." + this.getName())
+ .unbind("mousemove." + this.getName())
+ .unbind("mouseleave." + this.getName());
+ BI.Resizers.remove(this.getName());
+ BI.Combo.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Combo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
+BI.Combo.EVENT_CHANGE = "EVENT_CHANGE";
+BI.Combo.EVENT_EXPAND = "EVENT_EXPAND";
+BI.Combo.EVENT_COLLAPSE = "EVENT_COLLAPSE";
+BI.Combo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
+
+
+BI.Combo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.Combo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
+BI.Combo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
+BI.Combo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
+
+BI.shortcut("bi.combo", BI.Combo);/**
+ *
+ * 某个可以展开的节点
+ *
+ * Created by GUY on 2015/9/10.
+ * @class BI.Expander
+ * @extends BI.Widget
+ */
+BI.Expander = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Expander.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-expander",
+ trigger: "click",
+ toggle: true,
+ // direction: "bottom", //top,bottom四个方向
+ isDefaultInit: false, // 是否默认初始化子节点
+ el: {},
+ popup: {},
+ expanderClass: "bi-expander-popup",
+ hoverClass: "bi-expander-hover"
+ });
+ },
+
+ _init: function () {
+ BI.Expander.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._expanded = !!o.el.open;
+ this._initExpander();
+ this._initPullDownAction();
+ this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (self.isEnabled() && self.isValid()) {
+ if (type === BI.Events.EXPAND) {
+ self._popupView();
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self._hideView();
+ }
+ if (type === BI.Events.EXPAND) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.Expander.EVENT_EXPAND);
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.isViewVisible() && self.fireEvent(BI.Expander.EVENT_COLLAPSE);
+ }
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Expander.EVENT_TRIGGER_CHANGE, value, obj);
+ }
+ }
+ });
+
+ this.element.hover(function () {
+ if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
+ self.element.addClass(o.hoverClass);
+ }
+ }, function () {
+ if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
+ self.element.removeClass(o.hoverClass);
+ }
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [
+ {el: this.expander}
+ ]
+ });
+ o.isDefaultInit && this._assertPopupView();
+ if (this.expander.isOpened() === true) {
+ this._popupView();
+ }
+ },
+
+ _toggle: function () {
+ this._assertPopupViewRender();
+ if (this.popupView.isVisible()) {
+ this._hideView();
+ } else {
+ if (this.isEnabled()) {
+ this._popupView();
+ }
+ }
+ },
+
+ _initPullDownAction: function () {
+ var self = this, o = this.options;
+ var evs = this.options.trigger.split(",");
+ BI.each(evs, function (i, e) {
+ switch (e) {
+ case "hover":
+ self.element[e](function (e) {
+ if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
+ self._popupView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
+ self.fireEvent(BI.Expander.EVENT_EXPAND);
+ }
+ }, function () {
+ if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
+ self._hideView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.expander);
+ self.fireEvent(BI.Expander.EVENT_COLLAPSE);
+ }
+ });
+ break;
+ case "click":
+ if (e) {
+ self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
+ if (self.expander.element.__isMouseInBounds__(e)) {
+ if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
+ o.toggle ? self._toggle() : self._popupView();
+ if (self.isExpanded()) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
+ self.fireEvent(BI.Expander.EVENT_EXPAND);
+ } else {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.expander);
+ self.fireEvent(BI.Expander.EVENT_COLLAPSE);
+ }
+ }
+ }
+ }, BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ }));
+ }
+ break;
+ }
+ });
+ },
+
+ _initExpander: function () {
+ this.expander = BI.createWidget(this.options.el);
+ },
+
+ _assertPopupView: function () {
+ var self = this, o = this.options;
+ if (this.popupView == null) {
+ this.popupView = BI.createWidget(this.options.popup, {
+ type: "bi.button_group",
+ cls: "expander-popup",
+ layouts: [{
+ type: "bi.vertical",
+ hgap: 0,
+ vgap: 0
+ }],
+ value: o.value
+ }, this);
+ this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ // self.setValue(self.getValue());
+ self.fireEvent(BI.Expander.EVENT_CHANGE, value, obj);
+ }
+ });
+ this.popupView.setVisible(this.isExpanded());
+ BI.nextTick(function () {
+ self.fireEvent(BI.Expander.EVENT_AFTER_INIT);
+ });
+ }
+ },
+
+ _assertPopupViewRender: function () {
+ this._assertPopupView();
+ if (!this._rendered) {
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [
+ {el: this.popupView}
+ ]
+ });
+ this._rendered = true;
+ }
+ },
+
+ _hideView: function () {
+ this.fireEvent(BI.Expander.EVENT_BEFORE_HIDEVIEW);
+ this._expanded = false;
+ this.expander.setOpened(false);
+ this.popupView && this.popupView.invisible();
+ this.element.removeClass(this.options.expanderClass);
+
+ this.fireEvent(BI.Expander.EVENT_AFTER_HIDEVIEW);
+ },
+
+ _popupView: function () {
+ this._assertPopupViewRender();
+ this.fireEvent(BI.Expander.EVENT_BEFORE_POPUPVIEW);
+ this._expanded = true;
+ this.expander.setOpened(true);
+ this.popupView.visible();
+ this.element.addClass(this.options.expanderClass);
+ this.fireEvent(BI.Expander.EVENT_AFTER_POPUPVIEW);
+ },
+
+ populate: function (items) {
+ // this._assertPopupView();
+ this.popupView && this.popupView.populate.apply(this.popupView, arguments);
+ this.expander.populate.apply(this.expander, arguments);
+ },
+
+ _setEnable: function (arg) {
+ BI.Expander.superclass._setEnable.apply(this, arguments);
+ !arg && this.element.removeClass(this.options.hoverClass);
+ !arg && this.isViewVisible() && this._hideView();
+ },
+
+ setValue: function (v) {
+ this.expander.setValue(v);
+ if (BI.isNull(this.popupView)) {
+ this.options.popup.value = v;
+ } else {
+ this.popupView.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (BI.isNull(this.popupView)) {
+ return this.options.popup.value;
+ } else {
+ return this.popupView.getValue();
+ }
+ },
+
+ isViewVisible: function () {
+ return this.isEnabled() && this.expander.isEnabled() && !!this.popupView && this.popupView.isVisible();
+ },
+
+ isExpanded: function () {
+ return this._expanded;
+ },
+
+ showView: function () {
+ if (this.isEnabled() && this.expander.isEnabled()) {
+ this._popupView();
+ }
+ },
+
+ hideView: function () {
+ this._hideView();
+ },
+
+ getView: function () {
+ return this.popupView;
+ },
+
+ getAllLeaves: function () {
+ return this.popupView && this.popupView.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ if (this.expander.options.id === id) {
+ return this.expander;
+ }
+ return this.popupView && this.popupView.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ if (this.expander.getValue() === value) {
+ return this.expander;
+ }
+ return this.popupView && this.popupView.getNodeByValue(value);
+ },
+
+ destroy: function () {
+ BI.Expander.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Expander.EVENT_EXPAND = "EVENT_EXPAND";
+BI.Expander.EVENT_COLLAPSE = "EVENT_COLLAPSE";
+BI.Expander.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
+BI.Expander.EVENT_CHANGE = "EVENT_CHANGE";
+BI.Expander.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
+
+
+BI.Expander.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.Expander.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
+BI.Expander.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
+BI.Expander.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
+
+BI.shortcut("bi.expander", BI.Expander);/**
+ * Created by GUY on 2015/8/10.
+ */
+
+BI.ComboGroup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.ComboGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-combo-group bi-list-item",
+
+ // 以下这些属性对每一个combo都是公用的
+ trigger: "click,hover",
+ direction: "right",
+ adjustLength: 0,
+ isDefaultInit: false,
+ isNeedAdjustHeight: false,
+ isNeedAdjustWidth: false,
+
+ el: {type: "bi.text_button", text: "", value: ""},
+ children: [],
+
+ popup: {
+ el: {
+ type: "bi.button_tree",
+ chooseType: 0,
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ }
+ });
+ },
+
+ _init: function () {
+ BI.ComboGroup.superclass._init.apply(this, arguments);
+ this._populate(this.options.el);
+ },
+
+ _populate: function (item) {
+ var self = this, o = this.options;
+ var children = o.children;
+ if (BI.isEmpty(children)) {
+ throw new Error("ComboGroup构造错误");
+ }
+ BI.each(children, function (i, ch) {
+ var son = BI.formatEL(ch).el.children;
+ ch = BI.formatEL(ch).el;
+ if (!BI.isEmpty(son)) {
+ ch.el = BI.clone(ch);
+ ch.children = son;
+ ch.type = "bi.combo_group";
+ ch.action = o.action;
+ ch.height = o.height;
+ ch.direction = o.direction;
+ ch.isDefaultInit = o.isDefaultInit;
+ ch.isNeedAdjustHeight = o.isNeedAdjustHeight;
+ ch.isNeedAdjustWidth = o.isNeedAdjustWidth;
+ ch.adjustLength = o.adjustLength;
+ ch.popup = o.popup;
+ }
+ });
+ this.combo = BI.createWidget({
+ type: "bi.combo",
+ element: this,
+ container: o.container,
+ height: o.height,
+ trigger: o.trigger,
+ direction: o.direction,
+ isDefaultInit: o.isDefaultInit,
+ isNeedAdjustWidth: o.isNeedAdjustWidth,
+ isNeedAdjustHeight: o.isNeedAdjustHeight,
+ adjustLength: o.adjustLength,
+ el: item,
+ popup: BI.extend({}, o.popup, {
+ el: BI.extend({
+ items: children
+ }, o.popup.el)
+ })
+ });
+ this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.ComboGroup.EVENT_CHANGE, obj);
+ }
+ });
+ },
+
+ getValue: function () {
+ return this.combo.getValue();
+ },
+
+ setValue: function (v) {
+ this.combo.setValue(v);
+ }
+});
+BI.ComboGroup.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.combo_group", BI.ComboGroup);BI.VirtualGroup = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.VirtualGroup.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-virtual-group",
+ items: [],
+ layouts: [{
+ type: "bi.center",
+ hgap: 0,
+ vgap: 0
+ }]
+ });
+ },
+
+ render: function () {
+ var o = this.options;
+ this.populate(o.items);
+ if (BI.isKey(o.value)) {
+ this.setValue(o.value);
+ }
+ },
+
+ _packageBtns: function (items) {
+ var o = this.options;
+ var map = this.buttonMap = {};
+ for (var i = o.layouts.length - 1; i > 0; i--) {
+ items = BI.map(items, function (k, it) {
+ var el = BI.stripEL(it);
+ return BI.extend({}, o.layouts[i], {
+ items: [
+ BI.extend({}, o.layouts[i].el, {
+ el: BI.extend({
+ ref: function (_ref) {
+ if (BI.isKey(map[el.value])) {
+ map[el.value] = _ref;
+ }
+ }
+ }, el)
+ })
+ ]
+ });
+ });
+ }
+ return items;
+ },
+
+ _packageLayout: function (items) {
+ var o = this.options, layout = BI.deepClone(o.layouts[0]);
+
+ var lay = BI.formatEL(layout).el;
+ while (lay && lay.items && !BI.isEmpty(lay.items)) {
+ lay = BI.formatEL(lay.items[0]).el;
+ }
+ lay.items = items;
+ return layout;
+ },
+
+ addItems: function (items) {
+ this.layouts.addItems(items);
+ },
+
+ prependItems: function (items) {
+ this.layouts.prependItems(items);
+ },
+
+ setValue: function (v) {
+ v = BI.isArray(v) ? v : [v];
+ BI.each(this.buttonMap, function (key, item) {
+ if (item) {
+ if (v.deepContains(key)) {
+ item.setSelected && item.setSelected(true);
+ } else {
+ item.setSelected && item.setSelected(false);
+ }
+ }
+ });
+ },
+
+ getNotSelectedValue: function () {
+ var v = [];
+ BI.each(this.buttonMap, function (i, item) {
+ if (item) {
+ if (item.isEnabled() && !(item.isSelected && item.isSelected())) {
+ v.push(item.getValue());
+ }
+ }
+ });
+ return v;
+ },
+
+ getValue: function () {
+ var v = [];
+ BI.each(this.buttonMap, function (i, item) {
+ if (item) {
+ if (item.isEnabled() && item.isSelected && item.isSelected()) {
+ v.push(item.getValue());
+ }
+ }
+ });
+ return v;
+ },
+
+ populate: function (items) {
+ var self = this;
+ items = items || [];
+ this.options.items = items;
+ items = this._packageBtns(items);
+ if (!this.layouts) {
+ this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items)));
+ } else {
+ this.layouts.populate(items);
+ }
+ }
+});
+BI.VirtualGroup.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.virtual_group", BI.VirtualGroup);/**
+ * 加载控件
+ *
+ * Created by GUY on 2015/8/31.
+ * @class BI.Loader
+ * @extends BI.Widget
+ */
+BI.Loader = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Loader.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-loader",
+
+ direction: "top",
+ isDefaultInit: true, // 是否默认初始化数据
+ logic: {
+ dynamic: true,
+ scrolly: true
+ },
+
+ // 下面是button_group的属性
+ el: {
+ type: "bi.button_group"
+ },
+
+ items: [],
+ itemsCreator: BI.emptyFn,
+ onLoaded: BI.emptyFn,
+
+ // 下面是分页信息
+ count: false,
+ prev: false,
+ next: {},
+ hasPrev: BI.emptyFn,
+ hasNext: BI.emptyFn
+ });
+ },
+
+ _prevLoad: function () {
+ var self = this, o = this.options;
+ this.prev.setLoading();
+ o.itemsCreator.apply(this, [{times: --this.times}, function () {
+ self.prev.setLoaded();
+ self.prependItems.apply(self, arguments);
+ }]);
+ },
+
+ _nextLoad: function () {
+ var self = this, o = this.options;
+ this.next.setLoading();
+ o.itemsCreator.apply(this, [{times: ++this.times}, function () {
+ self.next.setLoaded();
+ self.addItems.apply(self, arguments);
+ }]);
+ },
+
+ _init: function () {
+ BI.Loader.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ if (o.itemsCreator === false) {
+ o.prev = false;
+ o.next = false;
+ }
+ if (o.prev !== false) {
+ this.prev = BI.createWidget(BI.extend({
+ type: "bi.loading_bar"
+ }, o.prev));
+ this.prev.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self._prevLoad();
+ }
+ });
+ }
+
+ this.button_group = BI.createWidget(o.el, {
+ type: "bi.button_group",
+ chooseType: 0,
+ items: o.items,
+ behaviors: {},
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Loader.EVENT_CHANGE, obj);
+ }
+ });
+
+ if (o.next !== false) {
+ this.next = BI.createWidget(BI.extend({
+ type: "bi.loading_bar"
+ }, o.next));
+ this.next.on(BI.Controller.EVENT_CHANGE, function (type) {
+ if (type === BI.Events.CLICK) {
+ self._nextLoad();
+ }
+ });
+ }
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({
+ scrolly: true
+ }, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.prev, this.button_group, this.next)
+ }))));
+
+ o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () {
+ o.isDefaultInit && BI.isEmpty(o.items) && this.populate();
+ }, this));
+ if (BI.isNotEmptyArray(o.items)) {
+ this.populate(o.items);
+ }
+ },
+
+ hasPrev: function () {
+ var o = this.options;
+ if (BI.isNumber(o.count)) {
+ return this.count < o.count;
+ }
+ return !!o.hasPrev.apply(this, [{
+ times: this.times,
+ count: this.count
+ }]);
+ },
+
+ hasNext: function () {
+ var o = this.options;
+ if (BI.isNumber(o.count)) {
+ return this.count < o.count;
+ }
+ return !!o.hasNext.apply(this, [{
+ times: this.times,
+ count: this.count
+ }]);
+ },
+
+ prependItems: function (items) {
+ this.count += items.length;
+ if (this.next !== false) {
+ if (this.hasPrev()) {
+ this.options.items = this.options.items.concat(items);
+ this.prev.setLoaded();
+ } else {
+ this.prev.setEnd();
+ }
+ }
+ this.button_group.prependItems.apply(this.button_group, arguments);
+ },
+
+ addItems: function (items) {
+ this.count += items.length;
+ if (BI.isObject(this.next)) {
+ if (this.hasNext()) {
+ this.options.items = this.options.items.concat(items);
+ this.next.setLoaded();
+ } else {
+ this.next.setEnd();
+ }
+ }
+ this.button_group.addItems.apply(this.button_group, arguments);
+ },
+
+ populate: function (items) {
+ var self = this, o = this.options;
+ if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) {
+ o.itemsCreator.apply(this, [{times: 1}, function () {
+ if (arguments.length === 0) {
+ throw new Error("arguments can not be null!!!");
+ }
+ self.populate.apply(self, arguments);
+ o.onLoaded();
+ }]);
+ return;
+ }
+ this.options.items = items;
+ this.times = 1;
+ this.count = 0;
+ this.count += items.length;
+ if (BI.isObject(this.next)) {
+ if (this.hasNext()) {
+ this.next.setLoaded();
+ } else {
+ this.next.invisible();
+ }
+ }
+ if (BI.isObject(this.prev)) {
+ if (this.hasPrev()) {
+ this.prev.setLoaded();
+ } else {
+ this.prev.invisible();
+ }
+ }
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ setNotSelectedValue: function () {
+ this.button_group.setNotSelectedValue.apply(this.button_group, arguments);
+ },
+
+ getNotSelectedValue: function () {
+ return this.button_group.getNotSelectedValue();
+ },
+
+ setValue: function () {
+ this.button_group.setValue.apply(this.button_group, arguments);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue.apply(this.button_group, arguments);
+ },
+
+ getAllButtons: function () {
+ return this.button_group.getAllButtons();
+ },
+
+ getAllLeaves: function () {
+ return this.button_group.getAllLeaves();
+ },
+
+ getSelectedButtons: function () {
+ return this.button_group.getSelectedButtons();
+ },
+
+ getNotSelectedButtons: function () {
+ return this.button_group.getNotSelectedButtons();
+ },
+
+ getIndexByValue: function (value) {
+ return this.button_group.getIndexByValue(value);
+ },
+
+ getNodeById: function (id) {
+ return this.button_group.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ return this.button_group.getNodeByValue(value);
+ },
+
+ empty: function () {
+ this.button_group.empty();
+ BI.each([this.prev, this.next], function (i, ob) {
+ ob && ob.setVisible(false);
+ });
+ },
+
+ destroy: function () {
+ BI.Loader.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Loader.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.loader", BI.Loader);/**
+ * Created by GUY on 2015/6/26.
+ */
+
+BI.Navigation = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Navigation.superclass._defaultConfig.apply(this, arguments), {
+ direction: "bottom", // top, bottom, left, right, custom
+ logic: {
+ dynamic: false
+ },
+ single: false,
+ showIndex: false,
+ tab: false,
+ cardCreator: function (v) {
+ return BI.createWidget();
+ },
+
+ afterCardCreated: BI.emptyFn,
+ afterCardShow: BI.emptyFn
+ });
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"});
+ this.cardMap = {};
+ this.showIndex = 0;
+ this.layout = BI.createWidget({
+ type: "bi.card"
+ });
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout)
+ }))));
+
+
+ new BI.ShowListener({
+ eventObj: this.tab,
+ cardLayout: this.layout,
+ cardNameCreator: function (v) {
+ return self.showIndex + v;
+ },
+ cardCreator: function (v) {
+ var card = o.cardCreator(v);
+ self.cardMap[v] = card;
+ return card;
+ },
+ afterCardCreated: BI.bind(this.afterCardCreated, this),
+ afterCardShow: BI.bind(this.afterCardShow, this)
+ });
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (o.showIndex !== false) {
+ this.setSelect(o.showIndex);
+ }
+ },
+
+ _deleteOtherCards: function (currCardName) {
+ var self = this, o = this.options;
+ if (o.single === true) {
+ BI.each(this.cardMap, function (name, card) {
+ if (name !== (currCardName + "")) {
+ self.layout.deleteCardByName(name);
+ delete self.cardMap[name];
+ }
+ });
+ }
+ },
+
+ afterCardCreated: function (v) {
+ var self = this;
+ this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Navigation.EVENT_CHANGE, obj);
+ }
+ });
+ this.options.afterCardCreated.apply(this, arguments);
+ },
+
+ afterCardShow: function (v) {
+ this.showIndex = v;
+ this._deleteOtherCards(v);
+ this.options.afterCardShow.apply(this, arguments);
+ },
+
+ populate: function () {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ return card.populate.apply(card, arguments);
+ }
+ },
+
+ _assertCard: function (v) {
+ if (!this.layout.isCardExisted(v)) {
+ var card = this.options.cardCreator(v);
+ this.cardMap[v] = card;
+ this.layout.addCardByName(v, card);
+ this.afterCardCreated(v);
+ }
+ },
+
+ setSelect: function (v) {
+ this._assertCard(v);
+ this.layout.showCardByName(v);
+ this._deleteOtherCards(v);
+ if (this.showIndex !== v) {
+ this.showIndex = v;
+ BI.nextTick(BI.bind(this.afterCardShow, this, v));
+ }
+ },
+
+ getSelect: function () {
+ return this.showIndex;
+ },
+
+ getSelectedCard: function () {
+ if (BI.isKey(this.showIndex)) {
+ return this.cardMap[this.showIndex];
+ }
+ },
+
+ /**
+ * @override
+ */
+ setValue: function (v) {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ card.setValue(v);
+ }
+ },
+
+ /**
+ * @override
+ */
+ getValue: function () {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ return card.getValue();
+ }
+ },
+
+ empty: function () {
+ this.layout.deleteAllCard();
+ this.cardMap = {};
+ },
+
+ destroy: function () {
+ BI.Navigation.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Navigation.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.navigation", BI.Navigation);/**
+ * 搜索逻辑控件
+ *
+ * Created by GUY on 2015/9/28.
+ * @class BI.Searcher
+ * @extends BI.Widget
+ */
+
+BI.Searcher = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Searcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-searcher",
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ vgap: 0,
+ hgap: 0,
+
+ isDefaultInit: false,
+ isAutoSearch: true, // 是否自动搜索
+ isAutoSync: true, // 是否自动同步数据, 即是否保持搜索面板和adapter面板状态值的统一
+ chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
+
+ // isAutoSearch为false时启用
+ onSearch: function (op, callback) {
+ callback([]);
+ },
+
+ el: {
+ type: "bi.search_editor"
+ },
+
+ popup: {
+ type: "bi.searcher_view"
+ },
+
+ adapter: null,
+ masker: { // masker层
+ offset: {}
+ }
+ });
+ },
+
+ _init: function () {
+ BI.Searcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.editor = BI.createWidget(o.el, {
+ type: "bi.search_editor"
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ vgap: o.vgap,
+ hgap: o.hgap,
+ items: [this.editor]
+ });
+ o.isDefaultInit && (this._assertPopupView());
+
+ var search = BI.debounce(BI.bind(this._search, this), BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ });
+ this.editor.on(BI.Controller.EVENT_CHANGE, function (type) {
+ switch (type) {
+ case BI.Events.STARTEDIT:
+ self._startSearch();
+ break;
+ case BI.Events.EMPTY:
+ self._stopSearch();
+ break;
+ case BI.Events.CHANGE:
+ search();
+ break;
+ case BI.Events.PAUSE:
+ self._pauseSearch();
+ break;
+ }
+ });
+ },
+
+ _assertPopupView: function () {
+ var self = this, o = this.options;
+ if ((o.masker && !BI.Maskers.has(this.getName())) || (o.masker === false && !this.popupView)) {
+ this.popupView = BI.createWidget(o.popup, {
+ type: "bi.searcher_view",
+ chooseType: o.chooseType
+ });
+ this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ if (o.isAutoSync) {
+ var values = o.adapter && o.adapter.getValue();
+ if (!obj.isSelected()) {
+ o.adapter && o.adapter.setValue(BI.deepWithout(values, obj.getValue()));
+ } else {
+ switch (o.chooseType) {
+ case BI.ButtonGroup.CHOOSE_TYPE_SINGLE:
+ o.adapter && o.adapter.setValue([obj.getValue()]);
+ break;
+ case BI.ButtonGroup.CHOOSE_TYPE_MULTI:
+ values.push(obj.getValue());
+ o.adapter && o.adapter.setValue(values);
+ break;
+ }
+ }
+ }
+ self.fireEvent(BI.Searcher.EVENT_CHANGE, value, obj);
+ }
+ });
+ BI.nextTick(function () {
+ self.fireEvent(BI.Searcher.EVENT_AFTER_INIT);
+ });
+ }
+ if (o.masker && !BI.Maskers.has(this.getName())) {
+ BI.Maskers.create(this.getName(), o.adapter, BI.extend({
+ container: this,
+ render: this.popupView
+ }, o.masker), this);
+ }
+ },
+
+ _startSearch: function () {
+ this._assertPopupView();
+ this._stop = false;
+ this._isSearching = true;
+ this.fireEvent(BI.Searcher.EVENT_START);
+ this.popupView.startSearch && this.popupView.startSearch();
+ // 搜索前先清空dom
+ // BI.Maskers.get(this.getName()).empty();
+ BI.nextTick(function (name) {
+ BI.Maskers.show(name);
+ }, this.getName());
+ },
+
+ _pauseSearch: function () {
+ var o = this.options, name = this.getName();
+ this._stop = true;
+ BI.nextTick(function (name) {
+ BI.Maskers.hide(name);
+ }, this.getName());
+ if (this._isSearching === true) {
+ this.popupView && this.popupView.pauseSearch && this.popupView.pauseSearch();
+ this.fireEvent(BI.Searcher.EVENT_PAUSE);
+ }
+ this._isSearching = false;
+ },
+
+ _stopSearch: function () {
+ var o = this.options, name = this.getName();
+ this._stop = true;
+ BI.Maskers.hide(name);
+ if (this._isSearching === true) {
+ this.popupView && this.popupView.stopSearch && this.popupView.stopSearch();
+ this.fireEvent(BI.Searcher.EVENT_STOP);
+ }
+ this._isSearching = false;
+ },
+
+ _search: function () {
+ var self = this, o = this.options, keyword = this.editor.getValue();
+ if (keyword === "" || this._stop) {
+ return;
+ }
+ if (o.isAutoSearch) {
+ var items = (o.adapter && ((o.adapter.getItems && o.adapter.getItems()) || o.adapter.attr("items"))) || [];
+ var finding = BI.Func.getSearchResult(items, keyword);
+ var match = finding.match, find = finding.find;
+ this.popupView.populate(find, match, keyword);
+ o.isAutoSync && o.adapter && o.adapter.getValue && this.popupView.setValue(o.adapter.getValue());
+ self.fireEvent(BI.Searcher.EVENT_SEARCHING);
+ return;
+ }
+ this.popupView.loading && this.popupView.loading();
+ o.onSearch({
+ times: 1,
+ keyword: keyword,
+ selectedValues: o.adapter && o.adapter.getValue()
+ }, function (searchResult, matchResult) {
+ if (!self._stop) {
+ var args = [].slice.call(arguments);
+ if (args.length > 0) {
+ args.push(keyword);
+ }
+ BI.Maskers.show(self.getName());
+ self.popupView.populate.apply(self.popupView, args);
+ o.isAutoSync && o.adapter && o.adapter.getValue && self.popupView.setValue(o.adapter.getValue());
+ self.popupView.loaded && self.popupView.loaded();
+ self.fireEvent(BI.Searcher.EVENT_SEARCHING);
+ }
+ });
+ },
+
+ setAdapter: function (adapter) {
+ this.options.adapter = adapter;
+ BI.Maskers.remove(this.getName());
+ },
+
+ doSearch: function () {
+ if (this.isSearching()) {
+ this._search();
+ }
+ },
+
+ stopSearch: function () {
+ this._stopSearch();// 先停止搜索,然后再去设置editor为空
+ // important:停止搜索必须退出编辑状态,这里必须加上try(input框不显示时blur会抛异常)
+ try {
+ this.editor.blur();
+ } catch (e) {
+ if (!this.editor.blur) {
+ throw new Error("editor没有实现blur方法");
+ }
+ } finally {
+ this.editor.setValue("");
+ }
+ },
+
+ isSearching: function () {
+ return this._isSearching;
+ },
+
+ isViewVisible: function () {
+ return this.editor.isEnabled() && BI.Maskers.isVisible(this.getName());
+ },
+
+ getView: function () {
+ return this.popupView;
+ },
+
+ hasMatched: function () {
+ this._assertPopupView();
+ return this.popupView.hasMatched();
+ },
+
+ adjustHeight: function () {
+ if (BI.Maskers.has(this.getName()) && BI.Maskers.get(this.getName()).isVisible()) {
+ BI.Maskers.show(this.getName());
+ }
+ },
+
+ adjustView: function () {
+ this.isViewVisible() && BI.Maskers.show(this.getName());
+ },
+
+ setValue: function (v) {
+ if (BI.isNull(this.popupView)) {
+ this.options.popup.value = v;
+ } else {
+ this.popupView.setValue(v);
+ }
+ },
+
+ getKeyword: function () {
+ return this.editor.getValue();
+ },
+
+ getKeywords: function () {
+ return this.editor.getKeywords();
+ },
+
+ getValue: function () {
+ var o = this.options;
+ if (o.isAutoSync && o.adapter && o.adapter.getValue) {
+ return o.adapter.getValue();
+ }
+ if (this.isSearching()) {
+ return this.popupView.getValue();
+ } else if (o.adapter && o.adapter.getValue) {
+ return o.adapter.getValue();
+ }
+ if (BI.isNull(this.popupView)) {
+ return o.popup.value;
+ }
+ return this.popupView.getValue();
+
+ },
+
+ populate: function (result, searchResult, keyword) {
+ var o = this.options;
+ this._assertPopupView();
+ this.popupView.populate.apply(this.popupView, arguments);
+ if (o.isAutoSync && o.adapter && o.adapter.getValue) {
+ this.popupView.setValue(o.adapter.getValue());
+ }
+ },
+
+ empty: function () {
+ this.popupView && this.popupView.empty();
+ },
+
+ destroy: function () {
+ BI.Maskers.remove(this.getName());
+ BI.Searcher.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Searcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.Searcher.EVENT_START = "EVENT_START";
+BI.Searcher.EVENT_STOP = "EVENT_STOP";
+BI.Searcher.EVENT_PAUSE = "EVENT_PAUSE";
+BI.Searcher.EVENT_SEARCHING = "EVENT_SEARCHING";
+BI.Searcher.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
+
+BI.shortcut("bi.searcher", BI.Searcher);/**
+ *
+ * 切换显示或隐藏面板
+ *
+ * Created by GUY on 2015/11/2.
+ * @class BI.Switcher
+ * @extends BI.Widget
+ */
+BI.Switcher = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Switcher.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-switcher",
+ direction: BI.Direction.Top,
+ trigger: "click",
+ toggle: true,
+ el: {},
+ popup: {},
+ adapter: null,
+ masker: {},
+ switcherClass: "bi-switcher-popup",
+ hoverClass: "bi-switcher-hover"
+ });
+ },
+
+ _init: function () {
+ BI.Switcher.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this._initSwitcher();
+ this._initPullDownAction();
+ this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ if (self.isEnabled() && self.isValid()) {
+ if (type === BI.Events.EXPAND) {
+ self._popupView();
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self._hideView();
+ }
+ if (type === BI.Events.EXPAND) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.fireEvent(BI.Switcher.EVENT_EXPAND);
+ }
+ if (type === BI.Events.COLLAPSE) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ self.isViewVisible() && self.fireEvent(BI.Switcher.EVENT_COLLAPSE);
+ }
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Switcher.EVENT_TRIGGER_CHANGE, value, obj);
+ }
+ }
+ });
+
+ this.element.hover(function () {
+ if (self.isEnabled() && self.switcher.isEnabled()) {
+ self.element.addClass(o.hoverClass);
+ }
+ }, function () {
+ if (self.isEnabled() && self.switcher.isEnabled()) {
+ self.element.removeClass(o.hoverClass);
+ }
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [
+ {el: this.switcher}
+ ]
+ });
+ o.isDefaultInit && (this._assertPopupView());
+ },
+
+ _toggle: function () {
+ this._assertPopupView();
+ if (this.isExpanded()) {
+ this._hideView();
+ } else {
+ if (this.isEnabled()) {
+ this._popupView();
+ }
+ }
+ },
+
+ _initPullDownAction: function () {
+ var self = this, o = this.options;
+ var evs = this.options.trigger.split(",");
+ BI.each(evs, function (i, e) {
+ switch (e) {
+ case "hover":
+ self.element[e](function (e) {
+ if (self.isEnabled() && self.switcher.isEnabled()) {
+ self._popupView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.switcher);
+ self.fireEvent(BI.Switcher.EVENT_EXPAND);
+ }
+ }, function () {
+ if (self.isEnabled() && self.switcher.isEnabled() && o.toggle) {
+ self._hideView();
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.switcher);
+ self.fireEvent(BI.Switcher.EVENT_COLLAPSE);
+ }
+ });
+ break;
+ default :
+ if (e) {
+ self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
+ if (self.switcher.element.__isMouseInBounds__(e)) {
+ if (self.isEnabled() && self.switcher.isEnabled()) {
+ o.toggle ? self._toggle() : self._popupView();
+ if (self.isExpanded()) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.switcher);
+ self.fireEvent(BI.Switcher.EVENT_EXPAND);
+ } else {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.switcher);
+ self.fireEvent(BI.Switcher.EVENT_COLLAPSE);
+ }
+ }
+ }
+ }, BI.EVENT_RESPONSE_TIME, {
+ "leading": true,
+ "trailing": false
+ }));
+ }
+ break;
+ }
+ });
+ },
+
+ _initSwitcher: function () {
+ this.switcher = BI.createWidget(this.options.el, {
+ value: this.options.value
+ });
+ },
+
+ _assertPopupView: function () {
+ var self = this, o = this.options;
+ if (!this._created) {
+ this.popupView = BI.createWidget(o.popup, {
+ type: "bi.button_group",
+ element: o.adapter && BI.Maskers.create(this.getName(), o.adapter, BI.extend({container: this}, o.masker)),
+ cls: "switcher-popup",
+ layouts: [{
+ type: "bi.vertical",
+ hgap: 0,
+ vgap: 0
+ }],
+ value: o.value
+ }, this);
+ this.popupView.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.Switcher.EVENT_CHANGE, value, obj);
+ }
+ });
+ if (o.direction !== BI.Direction.Custom && !o.adapter) {
+ BI.createWidget({
+ type: "bi.vertical",
+ scrolly: false,
+ element: this,
+ items: [
+ {el: this.popupView}
+ ]
+ });
+ }
+ this._created = true;
+ BI.nextTick(function () {
+ self.fireEvent(BI.Switcher.EVENT_AFTER_INIT);
+ });
+ }
+ },
+
+ _hideView: function () {
+ this.fireEvent(BI.Switcher.EVENT_BEFORE_HIDEVIEW);
+ var self = this, o = this.options;
+ o.adapter ? BI.Maskers.hide(self.getName()) : (self.popupView && self.popupView.setVisible(false));
+ BI.nextTick(function () {
+ o.adapter ? BI.Maskers.hide(self.getName()) : (self.popupView && self.popupView.setVisible(false));
+ self.element.removeClass(o.switcherClass);
+ self.fireEvent(BI.Switcher.EVENT_AFTER_HIDEVIEW);
+ });
+ },
+
+ _popupView: function () {
+ var self = this, o = this.options;
+ this._assertPopupView();
+ this.fireEvent(BI.Switcher.EVENT_BEFORE_POPUPVIEW);
+ o.adapter ? BI.Maskers.show(this.getName()) : self.popupView.setVisible(true);
+ BI.nextTick(function (name) {
+ o.adapter ? BI.Maskers.show(name) : self.popupView.setVisible(true);
+ self.element.addClass(o.switcherClass);
+ self.fireEvent(BI.Switcher.EVENT_AFTER_POPUPVIEW);
+ }, this.getName());
+ },
+
+ populate: function (items) {
+ this._assertPopupView();
+ this.popupView.populate.apply(this.popupView, arguments);
+ this.switcher.populate.apply(this.switcher, arguments);
+ },
+
+ _setEnable: function (arg) {
+ BI.Switcher.superclass._setEnable.apply(this, arguments);
+ !arg && this.isViewVisible() && this._hideView();
+ },
+
+ setValue: function (v) {
+ this.switcher.setValue(v);
+ if (BI.isNull(this.popupView)) {
+ this.options.popup.value = v;
+ } else {
+ this.popupView.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ if (BI.isNull(this.popupView)) {
+ return this.options.popup.value;
+ } else {
+ return this.popupView.getValue();
+ }
+ },
+
+ setAdapter: function (adapter) {
+ this.options.adapter = adapter;
+ BI.Maskers.remove(this.getName());
+ },
+
+ isViewVisible: function () {
+ return this.isEnabled() && this.switcher.isEnabled() &&
+ (this.options.adapter ? BI.Maskers.isVisible(this.getName()) : (this.popupView && this.popupView.isVisible()));
+ },
+
+ isExpanded: function () {
+ return this.isViewVisible();
+ },
+
+ showView: function () {
+ if (this.isEnabled() && this.switcher.isEnabled()) {
+ this._popupView();
+ }
+ },
+
+ hideView: function () {
+ this._hideView();
+ },
+
+ getView: function () {
+ return this.popupView;
+ },
+
+ adjustView: function () {
+ this.isViewVisible() && BI.Maskers.show(this.getName());
+ },
+
+ getAllLeaves: function () {
+ return this.popupView && this.popupView.getAllLeaves();
+ },
+
+ getNodeById: function (id) {
+ if (this.switcher.attr("id") === id) {
+ return this.switcher;
+ }
+ return this.popupView && this.popupView.getNodeById(id);
+ },
+
+ getNodeByValue: function (value) {
+ if (this.switcher.getValue() === value) {
+ return this.switcher;
+ }
+ return this.popupView && this.popupView.getNodeByValue(value);
+ },
+
+ empty: function () {
+ this.popupView && this.popupView.empty();
+ },
+
+ destroy: function () {
+ BI.Switcher.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Switcher.EVENT_EXPAND = "EVENT_EXPAND";
+BI.Switcher.EVENT_COLLAPSE = "EVENT_COLLAPSE";
+BI.Switcher.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE";
+BI.Switcher.EVENT_CHANGE = "EVENT_CHANGE";
+BI.Switcher.EVENT_AFTER_INIT = "EVENT_AFTER_INIT";
+
+
+BI.Switcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
+BI.Switcher.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW";
+BI.Switcher.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW";
+BI.Switcher.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW";
+
+BI.shortcut("bi.switcher", BI.Switcher);/**
+ * Created by GUY on 2015/6/26.
+ */
+
+BI.Tab = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-tab",
+ direction: "top", // top, bottom, left, right, custom
+ single: false, // 是不是单页面
+ logic: {
+ dynamic: false
+ },
+ showIndex: false,
+ tab: false,
+ cardCreator: function (v) {
+ return BI.createWidget();
+ }
+ });
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ if (BI.isObject(o.tab)) {
+ this.tab = BI.createWidget(this.options.tab, {type: "bi.button_group"});
+ this.tab.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ }
+ this.cardMap = {};
+ this.layout = BI.createWidget({
+ type: "bi.card"
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tab, this.layout)
+ }))));
+
+ var listener = new BI.ShowListener({
+ eventObj: this.tab,
+ cardLayout: this.layout,
+ cardCreator: function (v) {
+ var card = o.cardCreator.apply(self, arguments);
+ self.cardMap[v] = card;
+ return card;
+ },
+ afterCardShow: function (v) {
+ self._deleteOtherCards(v);
+ self.curr = v;
+ }
+ });
+ listener.on(BI.ShowListener.EVENT_CHANGE, function (value) {
+ self.fireEvent(BI.Tab.EVENT_CHANGE, value, self);
+ });
+ },
+
+ _deleteOtherCards: function (currCardName) {
+ var self = this, o = this.options;
+ if (o.single === true) {
+ BI.each(this.cardMap, function (name, card) {
+ if (name !== (currCardName + "")) {
+ self.layout.deleteCardByName(name);
+ delete self.cardMap[name];
+ }
+ });
+ }
+ },
+
+ _assertCard: function (v) {
+ if (!this.layout.isCardExisted(v)) {
+ var card = this.options.cardCreator(v);
+ this.cardMap[v] = card;
+ this.layout.addCardByName(v, card);
+ }
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (o.showIndex !== false) {
+ this.setSelect(o.showIndex);
+ }
+ },
+
+ setSelect: function (v) {
+ this.tab && this.tab.setValue(v);
+ this._assertCard(v);
+ this.layout.showCardByName(v);
+ this._deleteOtherCards(v);
+ if (this.curr !== v) {
+ this.curr = v;
+ }
+ },
+
+ removeTab: function (cardname) {
+ var self = this, o = this.options;
+ BI.any(this.cardMap, function (name, card) {
+ if (BI.isEqual(name, (cardname + ""))) {
+ self.layout.deleteCardByName(name);
+ delete self.cardMap[name];
+ return true;
+ }
+ });
+ },
+
+ getSelect: function () {
+ return this.curr;
+ },
+
+ getSelectedTab: function () {
+ return this.layout.getShowingCard();
+ },
+
+ getTab: function (v) {
+ this._assertCard(v);
+ return this.layout.getCardByName(v);
+ },
+
+ setValue: function (v) {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ card.setValue(v);
+ }
+ },
+
+ getValue: function () {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ return card.getValue();
+ }
+ },
+
+ populate: function () {
+ var card = this.layout.getShowingCard();
+ if (card) {
+ return card.populate && card.populate.apply(card, arguments);
+ }
+ },
+
+ empty: function () {
+ this.layout.deleteAllCard();
+ this.cardMap = {};
+ },
+
+ destroy: function () {
+ this.cardMap = {};
+ BI.Tab.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.Tab.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.tab", BI.Tab);/**
+ * 表示当前对象
+ *
+ * Created by GUY on 2015/9/7.
+ * @class BI.EL
+ * @extends BI.Widget
+ */
+BI.EL = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.EL.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-el",
+ el: {},
+ layout: {}
+ });
+ },
+ _init: function () {
+ BI.EL.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.ele = BI.createWidget(o.el);
+ BI.createWidget(o.layout, {
+ type: "bi.adaptive",
+ element: this,
+ items: [this.ele]
+ });
+ this.ele.on(BI.Controller.EVENT_CHANGE, function () {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ },
+
+ setValue: function (v) {
+ this.ele.setValue(v);
+ },
+
+ getValue: function () {
+ return this.ele.getValue();
+ },
+
+ populate: function () {
+ this.ele.populate.apply(this, arguments);
+ }
+});
+BI.shortcut("bi.el", BI.EL);/**
+ * z-index在1亿层级
+ * 弹出提示消息框,用于模拟阻塞操作(通过回调函数实现)
+ * @class BI.Msg
+ */
+BI.Msg = function () {
+
+ var messageShow, $mask, $pop;
+
+ return {
+ alert: function (title, message, callback) {
+ this._show(false, title, message, callback);
+ },
+ confirm: function (title, message, callback) {
+ this._show(true, title, message, callback);
+ },
+ prompt: function (title, message, value, callback, min_width) {
+ // BI.Msg.prompt(title, message, value, callback, min_width);
+ },
+ toast: function (message, options, context) {
+ options = options || {};
+ context = context || BI.Widget._renderEngine.createElement("body");
+ var level = options.level || "normal";
+ var autoClose = BI.isNull(options.autoClose) ? true : options.autoClose;
+ var toast = BI.createWidget({
+ type: "bi.toast",
+ cls: "bi-message-animate bi-message-leave",
+ level: level,
+ autoClose: autoClose,
+ text: message
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: context,
+ items: [{
+ el: toast,
+ left: "50%",
+ top: 10
+ }]
+ });
+ toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
+ toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
+
+ autoClose && BI.delay(function () {
+ toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
+ BI.delay(function () {
+ toast.destroy();
+ }, 1000);
+ }, 5000);
+ },
+ _show: function (hasCancel, title, message, callback) {
+ $mask = BI.Widget._renderEngine.createElement("
").css({
+ position: "absolute",
+ zIndex: BI.zIndex_tip - 2,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ opacity: 0.5
+ }).appendTo("body");
+ $pop = BI.Widget._renderEngine.createElement("
").css({
+ position: "absolute",
+ zIndex: BI.zIndex_tip - 1,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0
+ }).appendTo("body");
+ var close = function () {
+ messageShow.destroy();
+ $mask.remove();
+ };
+ var controlItems = [];
+ if (hasCancel === true) {
+ controlItems.push({
+ el: {
+ type: "bi.button",
+ text: BI.i18nText("BI-Basic_Cancel"),
+ level: "ignore",
+ handler: function () {
+ close();
+ if (BI.isFunction(callback)) {
+ callback.apply(null, [false]);
+ }
+ }
+ }
+ });
+ }
+ controlItems.push({
+ el: {
+ type: "bi.button",
+ text: BI.i18nText("BI-Basic_OK"),
+ handler: function () {
+ close();
+ if (BI.isFunction(callback)) {
+ callback.apply(null, [true]);
+ }
+ }
+ }
+ });
+ var conf = {
+ element: $pop,
+ type: "bi.center_adapt",
+ items: [
+ {
+ type: "bi.border",
+ cls: "bi-message-content bi-card",
+ items: {
+ north: {
+ el: {
+ type: "bi.border",
+ cls: "bi-message-title bi-background",
+ items: {
+ center: {
+ el: {
+ type: "bi.label",
+ text: title || BI.i18nText("BI-Basic_Prompt"),
+ textAlign: "left",
+ hgap: 20,
+ height: 50
+ }
+ },
+ east: {
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-message-close close-font",
+ // height: 50,
+ handler: function () {
+ close();
+ if (BI.isFunction(callback)) {
+ callback.apply(null, [false]);
+ }
+ }
+ },
+ width: 60
+ }
+ }
+ },
+ height: 50
+ },
+ center: {
+ el: {
+ type: "bi.text",
+ cls: "bi-message-text",
+ tgap: 60,
+ hgap: 20,
+ lineHeight: 30,
+ whiteSpace: "normal",
+ text: message
+ }
+ },
+ south: {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: {
+ type: "bi.right_vertical_adapt",
+ hgap: 5,
+ items: controlItems
+ },
+ top: 0,
+ left: 20,
+ right: 20,
+ bottom: 0
+ }]
+
+ },
+ height: 60
+ }
+ },
+ width: 400,
+ height: 300
+ }
+ ]
+ };
+
+ messageShow = BI.createWidget(conf);
+ }
+ };
+}();/**
+ * GridView
+ *
+ * Created by GUY on 2016/1/11.
+ * @class BI.GridView
+ * @extends BI.Widget
+ */
+BI.GridView = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-grid-view",
+ // width: 400, //必设
+ // height: 300, //必设
+ overflowX: true,
+ overflowY: true,
+ overscanColumnCount: 0,
+ overscanRowCount: 0,
+ rowHeightGetter: BI.emptyFn, // number类型或function类型
+ columnWidthGetter: BI.emptyFn, // number类型或function类型
+ // estimatedColumnSize: 100, //columnWidthGetter为function时必设
+ // estimatedRowSize: 30, //rowHeightGetter为function时必设
+ scrollLeft: 0,
+ scrollTop: 0,
+ items: []
+ });
+ },
+
+ _init: function () {
+ BI.GridView.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ this.renderRange = {};
+ this._scrollLock = false;
+ this._debounceRelease = BI.debounce(function () {
+ self._scrollLock = false;
+ }, 1000 / 60);
+ this.container = BI.createWidget({
+ type: "bi.absolute"
+ });
+ this.element.scroll(function () {
+ if (self._scrollLock === true) {
+ return;
+ }
+ o.scrollLeft = self.element.scrollLeft();
+ o.scrollTop = self.element.scrollTop();
+ self._calculateChildrenToRender();
+ self.fireEvent(BI.GridView.EVENT_SCROLL, {
+ scrollLeft: o.scrollLeft,
+ scrollTop: o.scrollTop
+ });
+ });
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ scrollable: o.overflowX === true && o.overflowY === true,
+ scrolly: o.overflowX === false && o.overflowY === true,
+ scrollx: o.overflowX === true && o.overflowY === false,
+ items: [this.container]
+ });
+ if (o.items.length > 0) {
+ this._populate();
+ }
+ },
+
+ mounted: function () {
+ var o = this.options;
+ if (o.scrollLeft !== 0 || o.scrollTop !== 0) {
+ this.element.scrollTop(o.scrollTop);
+ this.element.scrollLeft(o.scrollLeft);
+ }
+ },
+
+ _getOverscanIndices: function (cellCount, overscanCellsCount, startIndex, stopIndex) {
+ return {
+ overscanStartIndex: Math.max(0, startIndex - overscanCellsCount),
+ overscanStopIndex: Math.min(cellCount - 1, stopIndex + overscanCellsCount)
+ };
+ },
+
+ _calculateChildrenToRender: function () {
+ var self = this, o = this.options;
+
+ var width = o.width, height = o.height, scrollLeft = BI.clamp(o.scrollLeft, 0, this._getMaxScrollLeft()),
+ scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop()),
+ overscanColumnCount = o.overscanColumnCount, overscanRowCount = o.overscanRowCount;
+
+ if (height > 0 && width > 0) {
+ var visibleColumnIndices = this._columnSizeAndPositionManager.getVisibleCellRange(width, scrollLeft);
+ var visibleRowIndices = this._rowSizeAndPositionManager.getVisibleCellRange(height, scrollTop);
+
+ if (BI.isEmpty(visibleColumnIndices) || BI.isEmpty(visibleRowIndices)) {
+ return;
+ }
+ var horizontalOffsetAdjustment = this._columnSizeAndPositionManager.getOffsetAdjustment(width, scrollLeft);
+ var verticalOffsetAdjustment = this._rowSizeAndPositionManager.getOffsetAdjustment(height, scrollTop);
+
+ this._renderedColumnStartIndex = visibleColumnIndices.start;
+ this._renderedColumnStopIndex = visibleColumnIndices.stop;
+ this._renderedRowStartIndex = visibleRowIndices.start;
+ this._renderedRowStopIndex = visibleRowIndices.stop;
+
+ var overscanColumnIndices = this._getOverscanIndices(this.columnCount, overscanColumnCount, this._renderedColumnStartIndex, this._renderedColumnStopIndex);
+
+ var overscanRowIndices = this._getOverscanIndices(this.rowCount, overscanRowCount, this._renderedRowStartIndex, this._renderedRowStopIndex);
+
+ var columnStartIndex = overscanColumnIndices.overscanStartIndex;
+ var columnStopIndex = overscanColumnIndices.overscanStopIndex;
+ var rowStartIndex = overscanRowIndices.overscanStartIndex;
+ var rowStopIndex = overscanRowIndices.overscanStopIndex;
+
+ // 算区间size
+ var minRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStartIndex);
+ var minColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStartIndex);
+ var maxRowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowStopIndex);
+ var maxColumnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnStopIndex);
+ var top = minRowDatum.offset + verticalOffsetAdjustment;
+ var left = minColumnDatum.offset + horizontalOffsetAdjustment;
+ var bottom = maxRowDatum.offset + verticalOffsetAdjustment + maxRowDatum.size;
+ var right = maxColumnDatum.offset + horizontalOffsetAdjustment + maxColumnDatum.size;
+ // 如果滚动的区间并没有超出渲染的范围
+ if (top >= this.renderRange.minY && bottom <= this.renderRange.maxY && left >= this.renderRange.minX && right <= this.renderRange.maxX) {
+ return;
+ }
+
+ var renderedCells = [], renderedKeys = {}, renderedWidgets = {};
+ var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
+ var count = 0;
+ for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
+ var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
+
+ for (var columnIndex = columnStartIndex; columnIndex <= columnStopIndex; columnIndex++) {
+ var key = rowIndex + "-" + columnIndex;
+ var columnDatum = this._columnSizeAndPositionManager.getSizeAndPositionOfCell(columnIndex);
+
+ var index = this.renderedKeys[key] && this.renderedKeys[key][2];
+ var child;
+ if (index >= 0) {
+ if (columnDatum.size !== this.renderedCells[index]._width) {
+ this.renderedCells[index]._width = columnDatum.size;
+ this.renderedCells[index].el.setWidth(columnDatum.size);
+ }
+ if (rowDatum.size !== this.renderedCells[index]._height) {
+ this.renderedCells[index]._height = rowDatum.size;
+ this.renderedCells[index].el.setHeight(rowDatum.size);
+ }
+ if (this.renderedCells[index]._left !== columnDatum.offset + horizontalOffsetAdjustment) {
+ this.renderedCells[index].el.element.css("left", (columnDatum.offset + horizontalOffsetAdjustment) + "px");
+ }
+ if (this.renderedCells[index]._top !== rowDatum.offset + verticalOffsetAdjustment) {
+ this.renderedCells[index].el.element.css("top", (rowDatum.offset + verticalOffsetAdjustment) + "px");
+ }
+ renderedCells.push(child = this.renderedCells[index]);
+ } else {
+ child = BI.createWidget(BI.extend({
+ type: "bi.label",
+ width: columnDatum.size,
+ height: rowDatum.size
+ }, o.items[rowIndex][columnIndex], {
+ cls: (o.items[rowIndex][columnIndex].cls || "") + " grid-cell" + (rowIndex === 0 ? " first-row" : "") + (columnIndex === 0 ? " first-col" : ""),
+ _rowIndex: rowIndex,
+ _columnIndex: columnIndex,
+ _left: columnDatum.offset + horizontalOffsetAdjustment,
+ _top: rowDatum.offset + verticalOffsetAdjustment
+ }));
+ renderedCells.push({
+ el: child,
+ left: columnDatum.offset + horizontalOffsetAdjustment,
+ top: rowDatum.offset + verticalOffsetAdjustment,
+ _left: columnDatum.offset + horizontalOffsetAdjustment,
+ _top: rowDatum.offset + verticalOffsetAdjustment,
+ _width: columnDatum.size,
+ _height: rowDatum.size
+ });
+ }
+ minX = Math.min(minX, columnDatum.offset + horizontalOffsetAdjustment);
+ maxX = Math.max(maxX, columnDatum.offset + horizontalOffsetAdjustment + columnDatum.size);
+ minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
+ maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
+ renderedKeys[key] = [rowIndex, columnIndex, count];
+ renderedWidgets[count] = child;
+ count++;
+ }
+ }
+ // 已存在的, 需要添加的和需要删除的
+ var existSet = {}, addSet = {}, deleteArray = [];
+ BI.each(renderedKeys, function (i, key) {
+ if (self.renderedKeys[i]) {
+ existSet[i] = key;
+ } else {
+ addSet[i] = key;
+ }
+ });
+ BI.each(this.renderedKeys, function (i, key) {
+ if (existSet[i]) {
+ return;
+ }
+ if (addSet[i]) {
+ return;
+ }
+ deleteArray.push(key[2]);
+ });
+ BI.each(deleteArray, function (i, index) {
+ // 性能优化,不调用destroy方法防止触发destroy事件
+ self.renderedCells[index].el._destroy();
+ });
+ var addedItems = [];
+ BI.each(addSet, function (index, key) {
+ addedItems.push(renderedCells[key[2]]);
+ });
+ this.container.addItems(addedItems);
+ // 拦截父子级关系
+ this.container._children = renderedWidgets;
+ this.container.attr("items", renderedCells);
+ this.renderedCells = renderedCells;
+ this.renderedKeys = renderedKeys;
+ this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
+ }
+ },
+
+ /**
+ * 获取真实的可滚动的最大宽度
+ * 对于grid_view如果没有全部渲染过,this._columnSizeAndPositionManager.getTotalSize获取的宽度是不准确的
+ * 因此在调用setScrollLeft等函数时会造成没法移动到最右端(预估可移动具体太短)
+ */
+ _getRealMaxScrollLeft: function () {
+ var o = this.options;
+ var totalWidth = 0;
+ BI.count(0, this.columnCount, function (index) {
+ totalWidth += o.columnWidthGetter(index);
+ });
+ return Math.max(0, totalWidth - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0));
+ },
+
+ _getMaxScrollLeft: function () {
+ return Math.max(0, this._columnSizeAndPositionManager.getTotalSize() - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0));
+ },
+
+ _getMaxScrollTop: function () {
+ return Math.max(0, this._rowSizeAndPositionManager.getTotalSize() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0));
+ },
+
+ _populate: function (items) {
+ var self = this, o = this.options;
+ this._reRange();
+ this.columnCount = 0;
+ this.rowCount = 0;
+ if (items && items !== this.options.items) {
+ this.options.items = items;
+ }
+ if (BI.isNumber(o.columnCount)) {
+ this.columnCount = o.columnCount;
+ } else if (o.items.length > 0) {
+ this.columnCount = o.items[0].length;
+ }
+ if (BI.isNumber(o.rowCount)) {
+ this.rowCount = o.rowCount;
+ } else {
+ this.rowCount = o.items.length;
+ }
+ this.container.setWidth(this.columnCount * o.estimatedColumnSize);
+ this.container.setHeight(this.rowCount * o.estimatedRowSize);
+
+ this._columnSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.columnCount, o.columnWidthGetter, o.estimatedColumnSize);
+ this._rowSizeAndPositionManager = new BI.ScalingCellSizeAndPositionManager(this.rowCount, o.rowHeightGetter, o.estimatedRowSize);
+
+ this._calculateChildrenToRender();
+ // 元素未挂载时不能设置scrollTop
+ try {
+ this.element.scrollTop(o.scrollTop);
+ this.element.scrollLeft(o.scrollLeft);
+ } catch (e) {
+ }
+ },
+
+ setScrollLeft: function (scrollLeft) {
+ if (this.options.scrollLeft === scrollLeft) {
+ return;
+ }
+ this._scrollLock = true;
+ this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getRealMaxScrollLeft());
+ this._debounceRelease();
+ this._calculateChildrenToRender();
+ this.element.scrollLeft(this.options.scrollLeft);
+ },
+
+ setScrollTop: function (scrollTop) {
+ if (this.options.scrollTop === scrollTop) {
+ return;
+ }
+ this._scrollLock = true;
+ this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop());
+ this._debounceRelease();
+ this._calculateChildrenToRender();
+ this.element.scrollTop(this.options.scrollTop);
+ },
+
+ setColumnCount: function (columnCount) {
+ this.options.columnCount = columnCount;
+ },
+
+ setRowCount: function (rowCount) {
+ this.options.rowCount = rowCount;
+ },
+
+ setOverflowX: function (b) {
+ var self = this;
+ if (this.options.overflowX !== !!b) {
+ this.options.overflowX = !!b;
+ BI.nextTick(function () {
+ self.element.css({overflowX: b ? "auto" : "hidden"});
+ });
+ }
+ },
+
+ setOverflowY: function (b) {
+ var self = this;
+ if (this.options.overflowY !== !!b) {
+ this.options.overflowY = !!b;
+ BI.nextTick(function () {
+ self.element.css({overflowY: b ? "auto" : "hidden"});
+ });
+ }
+ },
+
+ getScrollLeft: function () {
+ return this.options.scrollLeft;
+ },
+
+ getScrollTop: function () {
+ return this.options.scrollTop;
+ },
+
+ getMaxScrollLeft: function () {
+ return this._getMaxScrollLeft();
+ },
+
+ getMaxScrollTop: function () {
+ return this._getMaxScrollTop();
+ },
+
+ setEstimatedColumnSize: function (width) {
+ this.options.estimatedColumnSize = width;
+ },
+
+ setEstimatedRowSize: function (height) {
+ this.options.estimatedRowSize = height;
+ },
+
+ // 重新计算children
+ _reRange: function () {
+ this.renderRange = {};
+ },
+
+ _clearChildren: function () {
+ this.container._children = {};
+ this.container.attr("items", []);
+ },
+
+ restore: function () {
+ BI.each(this.renderedCells, function (i, cell) {
+ cell.el._destroy();
+ });
+ this._clearChildren();
+ this.renderedCells = [];
+ this.renderedKeys = [];
+ this.renderRange = {};
+ this._scrollLock = false;
+ },
+
+ populate: function (items) {
+ if (items && items !== this.options.items) {
+ this.restore();
+ }
+ this._populate(items);
+ }
+});
+BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
+BI.shortcut("bi.grid_view", BI.GridView);/**
+ * Popover弹出层,
+ * @class BI.Popover
+ * @extends BI.Widget
+ */
+BI.Popover = BI.inherit(BI.Widget, {
+ _constant: {
+ SIZE: {
+ SMALL: "small",
+ NORMAL: "normal",
+ BIG: "big"
+ },
+ HEADER_HEIGHT: 40
+ },
+
+ _defaultConfig: function () {
+ return BI.extend(BI.Popover.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-popover bi-card",
+ // width: 600,
+ // height: 500,
+ size: "normal", // small, normal, big
+ header: null,
+ body: null,
+ footer: null
+ });
+ },
+ render: function () {
+ var self = this, o = this.options;
+ this.startX = 0;
+ this.startY = 0;
+ this.tracker = new BI.MouseMoveTracker(function (deltaX, deltaY) {
+ var size = self._calculateSize();
+ var W = BI.Widget._renderEngine.createElement("body").width(), H = BI.Widget._renderEngine.createElement("body").height();
+ self.startX += deltaX;
+ self.startY += deltaY;
+ self.element.css({
+ left: BI.clamp(self.startX, 0, W - size.width) + "px",
+ top: BI.clamp(self.startY, 0, H - size.height) + "px"
+ });
+ // BI-12134 没有什么特别好的方法
+ BI.Resizers._resize();
+ }, function () {
+ self.tracker.releaseMouseMoves();
+ }, _global);
+ var items = {
+ north: {
+ el: {
+ type: "bi.htape",
+ cls: "bi-message-title bi-header-background",
+ ref: function (_ref) {
+ self.dragger = _ref;
+ },
+ items: [{
+ type: "bi.absolute",
+ items: [{
+ el: BI.isPlainObject(o.header) ? BI.createWidget(o.header, {
+ extraCls: "bi-font-bold"
+ }) : {
+ type: "bi.label",
+ cls: "bi-font-bold",
+ height: this._constant.HEADER_HEIGHT,
+ text: o.header,
+ textAlign: "left"
+ },
+ left: 20,
+ top: 0,
+ right: 0,
+ bottom: 0
+ }]
+ }, {
+ el: {
+ type: "bi.icon_button",
+ cls: "bi-message-close close-font",
+ height: this._constant.HEADER_HEIGHT,
+ handler: function () {
+ self.close();
+ }
+ },
+ width: 56
+ }]
+ },
+ height: this._constant.HEADER_HEIGHT
+ },
+ center: {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: BI.createWidget(o.body),
+ left: 20,
+ top: 10,
+ right: 20,
+ bottom: 0
+ }]
+ }
+ }
+ };
+ if (o.footer) {
+ items.south = {
+ el: {
+ type: "bi.absolute",
+ items: [{
+ el: BI.createWidget(o.footer),
+ left: 20,
+ top: 0,
+ right: 20,
+ bottom: 0
+ }]
+ },
+ height: 44
+ };
+ }
+
+ var size = this._calculateSize();
+
+ return {
+ type: "bi.border",
+ items: items,
+ width: size.width,
+ height: size.height
+ };
+ },
+
+ mounted: function () {
+ var self = this;
+ this.dragger.element.mousedown(function (e) {
+ var pos = self.element.offset();
+ self.startX = pos.left;
+ self.startY = pos.top;
+ self.tracker.captureMouseMoves(e);
+ });
+ },
+
+ _calculateSize: function () {
+ var o = this.options;
+ var size = {};
+ if (BI.isNotNull(o.size)) {
+ switch (o.size) {
+ case this._constant.SIZE.SMALL:
+ size.width = 450;
+ size.height = 220;
+ break;
+ case this._constant.SIZE.BIG:
+ size.width = 900;
+ size.height = 500;
+ break;
+ default:
+ size.width = 550;
+ size.height = 500;
+ }
+ }
+ return {
+ width: o.width || size.width,
+ height: o.height || size.height
+ };
+ },
+
+ hide: function () {
+
+ },
+
+ open: function () {
+ this.show();
+ this.fireEvent(BI.Popover.EVENT_OPEN, arguments);
+ },
+
+ close: function () {
+ this.hide();
+ this.fireEvent(BI.Popover.EVENT_CLOSE, arguments);
+ },
+
+ setZindex: function (zindex) {
+ this.element.css({"z-index": zindex});
+ },
+
+ destroyed: function () {
+ }
+});
+
+BI.shortcut("bi.popover", BI.Popover);
+
+BI.BarPopover = BI.inherit(BI.Popover, {
+ _defaultConfig: function () {
+ return BI.extend(BI.BarPopover.superclass._defaultConfig.apply(this, arguments), {
+ btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))]
+ });
+ },
+
+ beforeCreate: function () {
+ var self = this, o = this.options;
+ o.footer || (o.footer = {
+ type: "bi.right_vertical_adapt",
+ lgap: 10,
+ items: [{
+ type: "bi.button",
+ text: this.options.btns[1],
+ value: 1,
+ level: "ignore",
+ handler: function (v) {
+ self.fireEvent(BI.Popover.EVENT_CANCEL, v);
+ self.close(v);
+ }
+ }, {
+ type: "bi.button",
+ text: this.options.btns[0],
+ warningTitle: o.warningTitle,
+ value: 0,
+ handler: function (v) {
+ self.fireEvent(BI.Popover.EVENT_CONFIRM, v);
+ self.close(v);
+ }
+ }]
+ });
+ }
+});
+
+BI.shortcut("bi.bar_popover", BI.BarPopover);
+
+BI.Popover.EVENT_CLOSE = "EVENT_CLOSE";
+BI.Popover.EVENT_OPEN = "EVENT_OPEN";
+BI.Popover.EVENT_CANCEL = "EVENT_CANCEL";
+BI.Popover.EVENT_CONFIRM = "EVENT_CONFIRM";
+/**
+ * 下拉框弹出层, zIndex在1000w
+ * @class BI.PopupView
+ * @extends BI.Widget
+ */
+BI.PopupView = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-popup-view",
+ maxWidth: "auto",
+ minWidth: 100,
+ // maxHeight: 200,
+ minHeight: 24,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ vgap: 0,
+ hgap: 0,
+ innerVGap: 0,
+ direction: BI.Direction.Top, // 工具栏的方向
+ stopEvent: false, // 是否停止mousedown、mouseup事件
+ stopPropagation: false, // 是否停止mousedown、mouseup向上冒泡
+ logic: {
+ dynamic: true
+ },
+
+ tool: false, // 自定义工具栏
+ tabs: [], // 导航栏
+ buttons: [], // toolbar栏
+
+ el: {
+ type: "bi.button_group",
+ items: [],
+ chooseType: 0,
+ behaviors: {},
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ },
+
+ _init: function () {
+ BI.PopupView.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ var fn = function (e) {
+ e.stopPropagation();
+ }, stop = function (e) {
+ e.stopEvent();
+ return false;
+ };
+ this.element.css({
+ "z-index": BI.zIndex_popup,
+ "min-width": o.minWidth + "px",
+ "max-width": o.maxWidth + "px"
+ }).bind({click: fn});
+
+ this.element.bind("mousewheel", fn);
+
+ o.stopPropagation && this.element.bind({mousedown: fn, mouseup: fn, mouseover: fn});
+ o.stopEvent && this.element.bind({mousedown: stop, mouseup: stop, mouseover: stop});
+ this.tool = this._createTool();
+ this.tab = this._createTab();
+ this.view = this._createView();
+ this.toolbar = this._createToolBar();
+
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.PopupView.EVENT_CHANGE);
+ }
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
+ scrolly: false,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ vgap: o.vgap,
+ hgap: o.hgap,
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction,
+ BI.extend({
+ cls: "list-view-outer bi-card list-view-shadow"
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.tool, this.tab, this.view, this.toolbar)
+ })))
+ )
+ }))));
+ },
+
+ _createView: function () {
+ var o = this.options;
+ this.button_group = BI.createWidget(o.el, {type: "bi.button_group", value: o.value});
+ this.button_group.element.css({"min-height": o.minHeight + "px", "padding-top": o.innerVGap + "px", "padding-bottom": o.innerVGap + "px"});
+ return this.button_group;
+ },
+
+ _createTool: function () {
+ var o = this.options;
+ if (false === o.tool) {
+ return;
+ }
+ return BI.createWidget(o.tool);
+ },
+
+ _createTab: function () {
+ var o = this.options;
+ if (o.tabs.length === 0) {
+ return;
+ }
+ return BI.createWidget({
+ type: "bi.center",
+ cls: "list-view-tab",
+ height: 25,
+ items: o.tabs,
+ value: o.value
+ });
+ },
+
+ _createToolBar: function () {
+ var o = this.options;
+ if (o.buttons.length === 0) {
+ return;
+ }
+
+ return BI.createWidget({
+ type: "bi.center",
+ cls: "list-view-toolbar bi-high-light bi-split-top",
+ height: 24,
+ items: BI.createItems(o.buttons, {
+ once: false,
+ shadow: true,
+ isShadowShowingOnSelected: true
+ })
+ });
+ },
+
+ getView: function () {
+ return this.button_group;
+ },
+
+ populate: function (items) {
+ this.button_group.populate.apply(this.button_group, arguments);
+ },
+
+ resetWidth: function (w) {
+ this.options.width = w;
+ this.element.width(w);
+ },
+
+ resetHeight: function (h) {
+ var tbHeight = this.toolbar ? (this.toolbar.attr("height") || 24) : 0,
+ tabHeight = this.tab ? (this.tab.attr("height") || 24) : 0,
+ toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0);
+ var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVGap - 2;
+ this.view.resetHeight ? this.view.resetHeight(resetHeight) :
+ this.view.element.css({"max-height": resetHeight + "px"});
+ },
+
+ setValue: function (selectedValues) {
+ this.tab && this.tab.setValue(selectedValues);
+ this.button_group.setValue(selectedValues);
+ },
+
+ getValue: function () {
+ return this.button_group.getValue();
+ }
+});
+BI.PopupView.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.popup_view", BI.PopupView);/**
+ * 搜索面板
+ *
+ * Created by GUY on 2015/9/28.
+ * @class BI.SearcherView
+ * @extends BI.Pane
+ */
+
+BI.SearcherView = BI.inherit(BI.Pane, {
+ _defaultConfig: function () {
+ var conf = BI.SearcherView.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-searcher-view bi-card",
+ tipText: BI.i18nText("BI-No_Select"),
+ chooseType: BI.Selection.Single,
+
+ matcher: {// 完全匹配的构造器
+ type: "bi.button_group",
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ items: [],
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ },
+ searcher: {
+ type: "bi.button_group",
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ items: [],
+ layouts: [{
+ type: "bi.vertical"
+ }]
+ }
+ });
+ },
+
+ _init: function () {
+ BI.SearcherView.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+
+ this.matcher = BI.createWidget(o.matcher, {
+ type: "bi.button_group",
+ chooseType: o.chooseType,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+ this.matcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
+ }
+ });
+ this.spliter = BI.createWidget({
+ type: "bi.vertical",
+ height: 1,
+ hgap: 10,
+ items: [{
+ type: "bi.layout",
+ height: 1,
+ cls: "searcher-view-spliter bi-background"
+ }]
+ });
+ this.searcher = BI.createWidget(o.searcher, {
+ type: "bi.button_group",
+ chooseType: o.chooseType,
+ behaviors: {
+ redmark: function () {
+ return true;
+ }
+ },
+ layouts: [{
+ type: "bi.vertical"
+ }],
+ value: o.value
+ });
+ this.searcher.on(BI.Controller.EVENT_CHANGE, function (type, val, ob) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ if (type === BI.Events.CLICK) {
+ self.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
+ }
+ });
+
+ BI.createWidget({
+ type: "bi.vertical",
+ element: this,
+ items: [this.matcher, this.spliter, this.searcher]
+ });
+ },
+
+ startSearch: function () {
+
+ },
+
+ stopSearch: function () {
+
+ },
+
+ setValue: function (v) {
+ this.matcher.setValue(v);
+ this.searcher.setValue(v);
+ },
+
+ getValue: function () {
+ return this.matcher.getValue().concat(this.searcher.getValue());
+ },
+
+ populate: function (searchResult, matchResult, keyword) {
+ searchResult || (searchResult = []);
+ matchResult || (matchResult = []);
+ this.setTipVisible(searchResult.length + matchResult.length === 0);
+ this.spliter.setVisible(BI.isNotEmptyArray(matchResult) && BI.isNotEmptyArray(searchResult));
+ this.matcher.populate(matchResult, keyword);
+ this.searcher.populate(searchResult, keyword);
+ },
+
+ empty: function () {
+ this.searcher.empty();
+ this.matcher.empty();
+ },
+
+ hasMatched: function () {
+ return this.matcher.getAllButtons().length > 0;
+ }
+});
+BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";
+
+BI.shortcut("bi.searcher_view", BI.SearcherView);/**
+ * 表示当前对象
+ *
+ * Created by GUY on 2017/5/23.
+ * @class BI.ListView
+ * @extends BI.Widget
+ */
+BI.ListView = BI.inherit(BI.Widget, {
+ props: function () {
+ return {
+ baseCls: "bi-list-view",
+ overscanHeight: 100,
+ blockSize: 10,
+ scrollTop: 0,
+ el: {},
+ items: []
+ };
+ },
+
+ init: function () {
+ var self = this;
+ this.renderedIndex = -1;
+ this.cache = {};
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vertical",
+ items: [BI.extend({
+ type: "bi.vertical",
+ scrolly: false,
+ ref: function () {
+ self.container = this;
+ }
+ }, o.el)],
+ element: this
+ };
+ },
+
+ mounted: function () {
+ var self = this, o = this.options;
+ this._populate();
+ this.element.scroll(function (e) {
+ o.scrollTop = self.element.scrollTop();
+ self._calculateBlocksToRender();
+ });
+ BI.ResizeDetector.addResizeListener(this, function () {
+ self._calculateBlocksToRender();
+ });
+ },
+
+ _renderMoreIf: function () {
+ var self = this, o = this.options;
+ var height = this.element.height();
+ var minContentHeight = o.scrollTop + height + o.overscanHeight;
+ var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
+ cnt = this.renderedIndex + 1;
+ var lastHeight;
+ var getElementHeight = function () {
+ return self.container.element.height();
+ };
+ while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
+ var items = o.items.slice(index, index + o.blockSize);
+ this.container.addItems(items);
+ var addedHeight = getElementHeight() - lastHeight;
+ this.cache[cnt] = {
+ index: index,
+ scrollTop: lastHeight,
+ height: addedHeight
+ };
+ this.renderedIndex = cnt;
+ cnt++;
+ index += o.blockSize;
+ }
+ },
+
+ _calculateBlocksToRender: function () {
+ var o = this.options;
+ this._renderMoreIf();
+ },
+
+ _populate: function (items) {
+ var o = this.options;
+ if (items && this.options.items !== items) {
+ this.options.items = items;
+ }
+ this._calculateBlocksToRender();
+ this.element.scrollTop(o.scrollTop);
+ },
+
+ restore: function () {
+ this.renderedIndex = -1;
+ this.container.empty();
+ this.cache = {};
+ },
+
+ populate: function (items) {
+ if (items && this.options.items !== items) {
+ this.restore();
+ }
+ this._populate(items);
+ },
+
+ destroyed: function () {
+ this.restore();
+ }
+});
+BI.shortcut("bi.list_view", BI.ListView);
+
+/**
+ * 表示当前对象
+ *
+ * Created by GUY on 2017/5/22.
+ * @class BI.VirtualList
+ * @extends BI.Widget
+ */
+BI.VirtualList = BI.inherit(BI.Widget, {
+ props: function () {
+ return {
+ baseCls: "bi-virtual-list",
+ overscanHeight: 100,
+ blockSize: 10,
+ scrollTop: 0,
+ items: []
+ };
+ },
+
+ init: function () {
+ var self = this;
+ this.renderedIndex = -1;
+ this.cache = {};
+ },
+
+ render: function () {
+ var self = this, o = this.options;
+ return {
+ type: "bi.vertical",
+ items: [{
+ type: "bi.layout",
+ ref: function () {
+ self.topBlank = this;
+ }
+ }, {
+ type: "bi.vertical",
+ scrolly: false,
+ ref: function () {
+ self.container = this;
+ }
+ }, {
+ type: "bi.layout",
+ ref: function () {
+ self.bottomBlank = this;
+ }
+ }],
+ element: this
+ };
+ },
+
+ mounted: function () {
+ var self = this, o = this.options;
+ this._populate();
+ this.element.scroll(function (e) {
+ o.scrollTop = self.element.scrollTop();
+ self._calculateBlocksToRender();
+ });
+ BI.ResizeDetector.addResizeListener(this, function () {
+ self._calculateBlocksToRender();
+ });
+ },
+
+ _renderMoreIf: function () {
+ var self = this, o = this.options;
+ var height = this.element.height();
+ var minContentHeight = o.scrollTop + height + o.overscanHeight;
+ var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
+ cnt = this.renderedIndex + 1;
+ var lastHeight;
+ var getElementHeight = function () {
+ return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
+ };
+ while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
+ var items = o.items.slice(index, index + o.blockSize);
+ this.container.addItems(items);
+ var addedHeight = getElementHeight() - lastHeight;
+ this.cache[cnt] = {
+ index: index,
+ scrollTop: lastHeight,
+ height: addedHeight
+ };
+ this.tree.set(cnt, addedHeight);
+ this.renderedIndex = cnt;
+ cnt++;
+ index += o.blockSize;
+ }
+ },
+
+ _calculateBlocksToRender: function () {
+ var o = this.options;
+ this._renderMoreIf();
+ var height = this.element.height();
+ var minContentHeightFrom = o.scrollTop - o.overscanHeight;
+ var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
+ var start = this.tree.greatestLowerBound(minContentHeightFrom);
+ var end = this.tree.leastUpperBound(minContentHeightTo);
+ var needDestroyed = [];
+ for (var i = 0; i < start; i++) {
+ var index = this.cache[i].index;
+ if (!this.cache[i].destroyed) {
+ for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
+ needDestroyed.push(this.container._children[j]);
+ this.container._children[j] = null;
+ }
+ this.cache[i].destroyed = true;
+ }
+ }
+ for (var i = end + 1; i <= this.renderedIndex; i++) {
+ var index = this.cache[i].index;
+ if (!this.cache[i].destroyed) {
+ for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
+ needDestroyed.push(this.container._children[j]);
+ this.container._children[j] = null;
+ }
+ this.cache[i].destroyed = true;
+ }
+ }
+ var firstFragment = BI.Widget._renderEngine.createFragment(), lastFragment = BI.Widget._renderEngine.createFragment();
+ var currentFragment = firstFragment;
+ for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
+ var index = this.cache[i].index;
+ if (!this.cache[i].destroyed) {
+ currentFragment = lastFragment;
+ }
+ if (this.cache[i].destroyed === true) {
+ for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
+ var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])));
+ currentFragment.appendChild(w.element[0]);
+ }
+ this.cache[i].destroyed = false;
+ }
+ }
+ this.container.element.prepend(firstFragment);
+ this.container.element.append(lastFragment);
+ this.topBlank.setHeight(this.cache[start < 0 ? 0 : start].scrollTop);
+ var lastCache = this.cache[Math.min(end, this.renderedIndex)];
+ this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - lastCache.scrollTop - lastCache.height);
+ BI.each(needDestroyed, function (i, child) {
+ child && child._destroy();
+ });
+ },
+
+ _populate: function (items) {
+ var o = this.options;
+ if (items && this.options.items !== items) {
+ this.options.items = items;
+ }
+ this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
+ this._calculateBlocksToRender();
+ this.element.scrollTop(o.scrollTop);
+ },
+
+ _clearChildren: function () {
+ BI.each(this.container._children, function (i, cell) {
+ cell && cell.el._destroy();
+ });
+ this.container._children = {};
+ this.container.attr("items", []);
+ },
+
+ restore: function () {
+ this.renderedIndex = -1;
+ this._clearChildren();
+ this.cache = {};
+ this.options.scrollTop = 0;
+ },
+
+ populate: function (items) {
+ if (items && this.options.items !== items) {
+ this.restore();
+ }
+ this._populate();
+ },
+
+ destroyed: function () {
+ this.restore();
+ }
+});
+BI.shortcut("bi.virtual_list", BI.VirtualList);
+
+/**
+ * 分页控件
+ *
+ * Created by GUY on 2015/8/31.
+ * @class BI.Pager
+ * @extends BI.Widget
+ */
+BI.Pager = BI.inherit(BI.Widget, {
+ _defaultConfig: function () {
+ return BI.extend(BI.Pager.superclass._defaultConfig.apply(this, arguments), {
+ baseCls: "bi-pager",
+ behaviors: {},
+ layouts: [{
+ type: "bi.horizontal",
+ hgap: 10,
+ vgap: 0
+ }],
+
+ dynamicShow: true, // 是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态
+ // dynamicShow为false时以下两个有用
+ dynamicShowFirstLast: false, // 是否动态显示首页、尾页
+ dynamicShowPrevNext: false, // 是否动态显示上一页、下一页
+ pages: false, // 总页数
+ curr: function () {
+ return 1;
+ }, // 初始化当前页
+ groups: 0, // 连续显示分页数
+ jump: BI.emptyFn, // 分页的回调函数
+
+ first: false, // 是否显示首页
+ last: false, // 是否显示尾页
+ prev: "上一页",
+ next: "下一页",
+
+ firstPage: 1,
+ lastPage: function () { // 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法
+ return 1;
+ },
+ hasPrev: BI.emptyFn, // pages不可用时有效
+ hasNext: BI.emptyFn // pages不可用时有效
+ });
+ },
+ _init: function () {
+ BI.Pager.superclass._init.apply(this, arguments);
+ var self = this;
+ this.currPage = BI.result(this.options, "curr");
+ // 翻页太灵敏
+ // this._lock = false;
+ // this._debouce = BI.debounce(function () {
+ // self._lock = false;
+ // }, 300);
+ this._populate();
+ },
+
+ _populate: function () {
+ var self = this, o = this.options, view = [], dict = {};
+ this.empty();
+ var pages = BI.result(o, "pages");
+ var curr = BI.result(this, "currPage");
+ var groups = BI.result(o, "groups");
+ var first = BI.result(o, "first");
+ var last = BI.result(o, "last");
+ var prev = BI.result(o, "prev");
+ var next = BI.result(o, "next");
+
+ if (pages === false) {
+ groups = 0;
+ first = false;
+ last = false;
+ } else {
+ groups > pages && (groups = pages);
+ }
+
+ // 计算当前组
+ dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups));
+
+ // 当前页非首页,则输出上一页
+ if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) {
+ if (BI.isKey(prev)) {
+ view.push({
+ text: prev,
+ value: "prev",
+ disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
+ });
+ } else {
+ view.push(BI.extend({
+ disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false)
+ }, prev));
+ }
+ }
+
+ // 当前组非首组,则输出首页
+ if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) {
+ view.push({
+ text: first,
+ value: "first",
+ disabled: !(dict.index > 1 && groups !== 0)
+ });
+ if (dict.index > 1 && groups !== 0) {
+ view.push({
+ type: "bi.label",
+ cls: "page-ellipsis",
+ text: "\u2026"
+ });
+ }
+ }
+
+ // 输出当前页组
+ dict.poor = Math.floor((groups - 1) / 2);
+ dict.start = dict.index > 1 ? curr - dict.poor : 1;
+ dict.end = dict.index > 1 ? (function () {
+ var max = curr + (groups - dict.poor - 1);
+ return max > pages ? pages : max;
+ }()) : groups;
+ if (dict.end - dict.start < groups - 1) { // 最后一组状态
+ dict.start = dict.end - groups + 1;
+ }
+ var s = dict.start, e = dict.end;
+ if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) {
+ s++;
+ e--;
+ }
+ for (; s <= e; s++) {
+ if (s === curr) {
+ view.push({
+ text: s,
+ value: s,
+ selected: true
+ });
+ } else {
+ view.push({
+ text: s,
+ value: s
+ });
+ }
+ }
+
+ // 总页数大于连续分页数,且当前组最大页小于总页,输出尾页
+ if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) {
+ if (pages > groups && dict.end < pages && groups !== 0) {
+ view.push({
+ type: "bi.label",
+ cls: "page-ellipsis",
+ text: "\u2026"
+ });
+ }
+ view.push({
+ text: last,
+ value: "last",
+ disabled: !(pages > groups && dict.end < pages && groups !== 0)
+ });
+ }
+
+ // 当前页不为尾页时,输出下一页
+ dict.flow = !prev && groups === 0;
+ if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) {
+ view.push((function () {
+ if (BI.isKey(next)) {
+ if (pages === false) {
+ return {text: next, value: "next", disabled: o.hasNext(curr) === false};
+ }
+ return (dict.flow && curr === pages)
+ ?
+ {text: next, value: "next", disabled: true}
+ :
+ {text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)};
+ }
+ return BI.extend({
+ disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow)
+ }, next);
+
+ }()));
+ }
+
+ this.button_group = BI.createWidget({
+ type: "bi.button_group",
+ element: this,
+ items: BI.createItems(view, {
+ cls: "bi-list-item-select",
+ height: 23,
+ hgap: 10
+ }),
+ behaviors: o.behaviors,
+ layouts: o.layouts
+ });
+ this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
+ // if (self._lock === true) {
+ // return;
+ // }
+ // self._lock = true;
+ // self._debouce();
+ if (type === BI.Events.CLICK) {
+ var v = self.button_group.getValue()[0];
+ switch (v) {
+ case "first":
+ self.currPage = 1;
+ break;
+ case "last":
+ self.currPage = pages;
+ break;
+ case "prev":
+ self.currPage--;
+ break;
+ case "next":
+ self.currPage++;
+ break;
+ default:
+ self.currPage = v;
+ break;
+ }
+ o.jump.apply(self, [{
+ pages: pages,
+ curr: self.currPage
+ }]);
+ self._populate();
+ self.fireEvent(BI.Pager.EVENT_CHANGE, obj);
+ }
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+ this.fireEvent(BI.Pager.EVENT_AFTER_POPULATE);
+ },
+
+ getCurrentPage: function () {
+ return this.currPage;
+ },
+
+ setAllPages: function (pages) {
+ this.options.pages = pages;
+ },
+
+ hasPrev: function (v) {
+ v || (v = 1);
+ var o = this.options;
+ var pages = this.options.pages;
+ return pages === false ? o.hasPrev(v) : v > 1;
+ },
+
+ hasNext: function (v) {
+ v || (v = 1);
+ var o = this.options;
+ var pages = this.options.pages;
+ return pages === false ? o.hasNext(v) : v < pages;
+ },
+
+ setValue: function (v) {
+ var o = this.options;
+ v = v | 0;
+ v = v < 1 ? 1 : v;
+ if (o.pages === false) {
+ var lastPage = BI.result(o, "lastPage"), firstPage = 1;
+ this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v));
+ } else {
+ v = v > o.pages ? o.pages : v;
+ this.currPage = v;
+ }
+ this._populate();
+ },
+
+ getValue: function () {
+ var val = this.button_group.getValue()[0];
+ switch (val) {
+ case "prev":
+ return -1;
+ case "next":
+ return 1;
+ case "first":
+ return BI.MIN;
+ case "last":
+ return BI.MAX;
+ default :
+ return val;
+ }
+ },
+
+ attr: function (key, value) {
+ BI.Pager.superclass.attr.apply(this, arguments);
+ if (key === "curr") {
+ this.currPage = BI.result(this.options, "curr");
+ }
+ },
+
+ populate: function () {
+ this._populate();
+ }
+});
+BI.Pager.EVENT_CHANGE = "EVENT_CHANGE";
+BI.Pager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE";
+BI.shortcut("bi.pager", BI.Pager);/**
+ * 超链接
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.A
+ * @extends BI.Text
+ * @abstract
+ */
+BI.A = BI.inherit(BI.Text, {
+ _defaultConfig: function () {
+ var conf = BI.A.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-a display-block",
+ href: "",
+ target: "_blank",
+ el: null,
+ tagName: "a"
+ });
+ },
+ _init: function () {
+ var o = this.options;
+ BI.A.superclass._init.apply(this, arguments);
+ this.element.attr({href: o.href, target: o.target});
+ if (o.el) {
+ BI.createWidget(o.el, {
+ element: this
+ });
+ }
+ }
+});
+
+BI.shortcut("bi.a", BI.A);/**
+ * guy
+ * 加载条
+ * @type {*|void|Object}
+ */
+BI.LoadingBar = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.LoadingBar.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend( conf, {
+ baseCls: (conf.baseCls || "") + " bi-loading-bar bi-tips",
+ height: 30,
+ handler: BI.emptyFn
+ });
+ },
+ _init: function () {
+ BI.LoadingBar.superclass._init.apply(this, arguments);
+ var self = this;
+ this.loaded = BI.createWidget({
+ type: "bi.text_button",
+ cls: "loading-text bi-list-item-simple",
+ text: BI.i18nText("BI-Load_More"),
+ width: 120,
+ handler: this.options.handler
+ });
+ this.loaded.on(BI.Controller.EVENT_CHANGE, function (type) {
+ self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
+ });
+
+ this.loading = BI.createWidget({
+ type: "bi.layout",
+ width: this.options.height,
+ height: this.options.height,
+ cls: "loading-background cursor-default"
+ });
+ var loaded = BI.createWidget({
+ type: "bi.center_adapt",
+ items: [this.loaded]
+ });
+ var loading = BI.createWidget({
+ type: "bi.center_adapt",
+ items: [this.loading]
+ });
+ this.cardLayout = BI.createWidget({
+ type: "bi.card",
+ element: this,
+ items: [{
+ el: loaded,
+ cardName: "loaded"
+ }, {
+ el: loading,
+ cardName: "loading"
+ }]
+ });
+ this.invisible();
+ },
+
+ _reset: function () {
+ this.visible();
+ this.loaded.setText(BI.i18nText("BI-Load_More"));
+ this.loaded.enable();
+ },
+
+ setLoaded: function () {
+ this._reset();
+ this.cardLayout.showCardByName("loaded");
+ },
+
+ setEnd: function () {
+ this.setLoaded();
+ this.loaded.setText(BI.i18nText("BI-No_More_Data"));
+ this.loaded.disable();
+ },
+
+ setLoading: function () {
+ this._reset();
+ this.cardLayout.showCardByName("loading");
+ }
+});
+
+BI.shortcut("bi.loading_bar", BI.LoadingBar);/**
+ * @class BI.IconButton
+ * @extends BI.BasicButton
+ * 图标的button
+ */
+BI.IconButton = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.IconButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-button horizon-center",
+ iconWidth: null,
+ iconHeight: null
+ });
+ },
+
+ _init: function () {
+ BI.IconButton.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.element.css({
+ textAlign: "center"
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon",
+ width: o.iconWidth,
+ height: o.iconHeight
+ });
+ if (BI.isNumber(o.height) && o.height > 0 && BI.isNull(o.iconWidth) && BI.isNull(o.iconHeight)) {
+ this.element.css("lineHeight", o.height + "px");
+ BI.createWidget({
+ type: "bi.default",
+ element: this,
+ items: [this.icon]
+ });
+ } else {
+ this.element.css("lineHeight", "1");
+ BI.createWidget({
+ element: this,
+ type: "bi.center_adapt",
+ items: [this.icon]
+ });
+ }
+ },
+
+ doClick: function () {
+ BI.IconButton.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.IconButton.EVENT_CHANGE, this);
+ }
+ }
+});
+BI.IconButton.EVENT_CHANGE = "IconButton.EVENT_CHANGE";
+BI.shortcut("bi.icon_button", BI.IconButton);/**
+ * 图片的button
+ *
+ * Created by GUY on 2016/1/27.
+ * @class BI.ImageButton
+ * @extends BI.BasicButton
+ */
+BI.ImageButton = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.ImageButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-image-button",
+ src: "",
+ iconWidth: "100%",
+ iconHeight: "100%"
+ });
+ },
+
+ _init: function () {
+ BI.ImageButton.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.image = BI.createWidget({
+ type: "bi.img",
+ width: o.iconWidth,
+ height: o.iconHeight,
+ src: o.src
+ });
+ if (BI.isNumber(o.iconWidth) || BI.isNumber(o.iconHeight)) {
+ BI.createWidget({
+ type: "bi.center_adapt",
+ element: this,
+ items: [this.image]
+ });
+ } else {
+ BI.createWidget({
+ type: "bi.adaptive",
+ element: this,
+ items: [this.image],
+ scrollable: false
+ });
+ }
+ },
+
+ setWidth: function (w) {
+ BI.ImageButton.superclass.setWidth.apply(this, arguments);
+ this.options.width = w;
+ },
+
+ setHeight: function (h) {
+ BI.ImageButton.superclass.setHeight.apply(this, arguments);
+ this.options.height = h;
+ },
+
+ setImageWidth: function (w) {
+ this.image.setWidth(w);
+ },
+
+ setImageHeight: function (h) {
+ this.image.setHeight(h);
+ },
+
+ getImageWidth: function () {
+ return this.image.element.width();
+ },
+
+ getImageHeight: function () {
+ return this.image.element.height();
+ },
+
+ setSrc: function (src) {
+ this.options.src = src;
+ this.image.setSrc(src);
+ },
+
+ getSrc: function () {
+ return this.image.getSrc();
+ },
+
+ doClick: function () {
+ BI.ImageButton.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.ImageButton.EVENT_CHANGE, this);
+ }
+ }
+});
+BI.ImageButton.EVENT_CHANGE = "ImageButton.EVENT_CHANGE";
+BI.shortcut("bi.image_button", BI.ImageButton);
+/**
+ * 文字类型的按钮
+ * @class BI.Button
+ * @extends BI.BasicButton
+ *
+ * @cfg {JSON} options 配置属性
+ * @cfg {'common'/'success'/'warning'/'ignore'} [options.level='common'] 按钮类型,用不同颜色强调不同的场景
+ */
+BI.Button = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function (props) {
+ var conf = BI.Button.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-button",
+ minWidth: (props.block === true || props.clear === true) ? 0 : 80,
+ height: 24,
+ shadow: props.clear !== true,
+ isShadowShowingOnSelected: true,
+ readonly: true,
+ iconCls: "",
+ level: "common",
+ block: false, // 是否块状显示,即不显示边框,没有最小宽度的限制
+ clear: false, // 是否去掉边框和背景
+ ghost: false, // 是否幽灵显示, 即正常状态无背景
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ forceCenter: false,
+ textWidth: null,
+ textHeight: null,
+ hgap: props.clear ? 0 : 10,
+ vgap: 0,
+ tgap: 0,
+ bgap: 0,
+ lgap: 0,
+ rgap: 0
+ });
+ },
+
+ _init: function () {
+ BI.Button.superclass._init.apply(this, arguments);
+ var o = this.options, self = this;
+ if (BI.isNumber(o.height) && !o.clear && !o.block) {
+ this.element.css({height: o.height + "px", lineHeight: (o.height - 2) + "px"});
+ } else if (o.clear || o.block) {
+ this.element.css({lineHeight: o.height + "px"});
+ } else {
+ this.element.css({lineHeight: (o.height - 2) + "px"});
+ }
+ if (BI.isKey(o.iconCls)) {
+ this.icon = BI.createWidget({
+ type: "bi.icon",
+ width: 18,
+ height: o.height - 2
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ text: o.text,
+ value: o.value,
+ height: o.height - 2
+ });
+ BI.createWidget({
+ type: "bi.horizontal_auto",
+ cls: o.iconCls,
+ element: this,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ items: [{
+ type: "bi.horizontal",
+ items: [this.icon, this.text]
+ }]
+ });
+ } else {
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ forceCenter: o.forceCenter,
+ textWidth: o.textWidth,
+ textHeight: o.textHeight,
+ hgap: o.hgap,
+ vgap: o.vgap,
+ tgap: o.tgap,
+ bgap: o.bgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ element: this,
+ text: o.text,
+ value: o.value
+ });
+ }
+ if (o.block === true) {
+ this.element.addClass("block");
+ }
+ if (o.clear === true) {
+ this.element.addClass("clear");
+ }
+ if (o.ghost === true) {
+ this.element.addClass("ghost");
+ }
+ if (o.minWidth > 0) {
+ this.element.css({"min-width": o.minWidth + "px"});
+ }
+ },
+
+ doClick: function () {
+ BI.Button.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.Button.EVENT_CHANGE, this);
+ }
+ },
+
+ setText: function (text) {
+ BI.Button.superclass.setText.apply(this, arguments);
+ this.text.setText(text);
+ },
+
+ setValue: function (text) {
+ BI.Button.superclass.setValue.apply(this, arguments);
+ if (!this.isReadOnly()) {
+ this.text.setValue(text);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ destroy: function () {
+ BI.Button.superclass.destroy.apply(this, arguments);
+ }
+});
+BI.shortcut("bi.button", BI.Button);
+BI.Button.EVENT_CHANGE = "EVENT_CHANGE";
+/**
+ * guy
+ * 可以点击的一行文字
+ * @class BI.TextButton
+ * @extends BI.BasicButton
+ * 文字button
+ */
+BI.TextButton = BI.inherit(BI.BasicButton, {
+ _defaultConfig: function () {
+ var conf = BI.TextButton.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-button",
+ textAlign: "center",
+ whiteSpace: "nowrap",
+ forceCenter: false,
+ textWidth: null,
+ textHeight: null,
+ hgap: 0,
+ lgap: 0,
+ rgap: 0,
+ text: "",
+ py: ""
+ });
+ },
+
+ _init: function () {
+ BI.TextButton.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ textWidth: o.textWidth,
+ textHeight: o.textHeight,
+ forceCenter: o.forceCenter,
+ width: o.width,
+ height: o.height,
+ hgap: o.hgap,
+ lgap: o.lgap,
+ rgap: o.rgap,
+ text: o.text,
+ value: o.value,
+ py: o.py,
+ keyword: o.keyword
+ });
+ },
+
+ doClick: function () {
+ BI.TextButton.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TextButton.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ setText: function (text) {
+ BI.TextButton.superclass.setText.apply(this, arguments);
+ text = BI.isArray(text) ? text.join(",") : text;
+ this.text.setText(text);
+ },
+
+ setStyle: function (style) {
+ this.text.setStyle(style);
+ },
+
+ setValue: function (text) {
+ BI.TextButton.superclass.setValue.apply(this, arguments);
+ if (!this.isReadOnly()) {
+ text = BI.isArray(text) ? text.join(",") : text;
+ this.text.setValue(text);
+ }
+ }
+});
+BI.TextButton.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_button", BI.TextButton);/**
+ * 带有一个占位
+ *
+ * Created by GUY on 2015/9/11.
+ * @class BI.BlankIconIconTextItem
+ * @extends BI.BasicButton
+ */
+BI.BlankIconIconTextItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.BlankIconIconTextItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item",
+ logic: {
+ dynamic: false
+ },
+ iconCls1: "close-ha-font",
+ iconCls2: "close-ha-font",
+ blankWidth: 0,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.BlankIconIconTextItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: o.blankWidth,
+ height: o.height
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon1 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls1,
+ forceNotSelected: true,
+ width: o.height,
+ height: o.height
+ });
+ this.icon2 = BI.createWidget({
+ type: "bi.icon_button",
+ cls: o.iconCls2,
+ forceNotSelected: true,
+ width: o.height,
+ height: o.height
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon1, this.icon2, this.text)
+ }))));
+ },
+
+ doClick: function () {
+ BI.BlankIconIconTextItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.BlankIconIconTextItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ setSelected: function (b) {
+ BI.BlankIconIconTextItem.superclass.setSelected.apply(this, arguments);
+ this.icon1.setSelected(b);
+ this.icon2.setSelected(b);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ }
+});
+BI.BlankIconIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.blank_icon_icon_text_item", BI.BlankIconIconTextItem);/**
+ * guy
+ * 一个占位符和两个icon和一行数 组成的一行listitem
+ *
+ * Created by GUY on 2015/9/15.
+ * @class BI.BlankIconTextIconItem
+ * @extends BI.BasicButton
+ */
+BI.BlankIconTextIconItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.BlankIconTextIconItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-blank-icon-text-icon-item",
+ logic: {
+ dynamic: false
+ },
+ iconCls1: "close-ha-font",
+ iconCls2: "close-ha-font",
+ blankWidth: 0,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.BlankIconTextIconItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+
+ var icon1 = BI.createWidget({
+ type: "bi.icon_label",
+ cls: o.iconCls1,
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.icon_label",
+ cls: o.iconCls2,
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ },
+ top: 0,
+ bottom: 0,
+ right: 0
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", {
+ type: "bi.layout",
+ width: o.blankWidth
+ }, icon1, this.text, {
+ type: "bi.layout",
+ width: o.height
+ })
+ }))));
+ },
+
+ doClick: function () {
+ BI.BlankIconTextIconItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.BlankIconTextIconItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ }
+});
+BI.BlankIconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.blank_icon_text_icon_item", BI.BlankIconTextIconItem);/**
+ * 带有一个占位
+ *
+ * Created by GUY on 2015/9/11.
+ * @class BI.BlankIconTextItem
+ * @extends BI.BasicButton
+ */
+BI.BlankIconTextItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.BlankIconTextItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-blank-icon-text-item",
+ logic: {
+ dynamic: false
+ },
+ cls: "close-ha-font",
+ blankWidth: 0,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.BlankIconTextItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: o.blankWidth
+ });
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", blank, this.icon, this.text)
+ }))));
+ },
+
+ doClick: function () {
+ BI.BlankIconTextItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.BlankIconTextItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ }
+});
+BI.BlankIconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.blank_icon_text_item", BI.BlankIconTextItem);/**
+ * guy
+ * 两个icon和一行数 组成的一行listitem
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.IconTextIconItem
+ * @extends BI.BasicButton
+ */
+BI.IconTextIconItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.IconTextIconItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-text-icon-item",
+ logic: {
+ dynamic: false
+ },
+ iconCls1: "close-ha-font",
+ iconCls2: "close-ha-font",
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.IconTextIconItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+
+ var icon1 = BI.createWidget({
+ type: "bi.icon_label",
+ cls: o.iconCls1,
+ width: o.leftIconWrapperWidth,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: o.height
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.icon_label",
+ cls: o.iconCls2,
+ width: o.rightIconWrapperWidth,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ },
+ top: 0,
+ bottom: 0,
+ right: 0
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank)
+ }))));
+ },
+
+ doClick: function () {
+ BI.IconTextIconItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.IconTextIconItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ }
+});
+BI.IconTextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_icon_item", BI.IconTextIconItem);/**
+ * guy
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.IconTextItem
+ * @extends BI.BasicButton
+ */
+BI.IconTextItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.IconTextItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-text-item",
+ direction: BI.Direction.Left,
+ logic: {
+ dynamic: false
+ },
+ iconWrapperWidth: null,
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.IconTextItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: o.iconWrapperWidth || o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.icon, this.text)
+ }))));
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doClick: function () {
+ BI.IconTextItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.IconTextItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ }
+});
+BI.IconTextItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_item", BI.IconTextItem);/**
+ *
+ * 图标的button
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.TextIconItem
+ * @extends BI.BasicButton
+ */
+BI.TextIconItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.TextIconItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-icon-item",
+ logic: {
+ dynamic: false
+ },
+ cls: "close-ha-font",
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.TextIconItem.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon)
+ }))));
+ },
+
+ doClick: function () {
+ BI.TextIconItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TextIconItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ }
+});
+BI.TextIconItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_icon_item", BI.TextIconItem);/**
+ * guy
+ * 一个button和一行数 组成的一行listitem
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.TextItem
+ * @extends BI.BasicButton
+ */
+BI.TextItem = BI.inherit(BI.BasicButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.TextItem.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-item",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.TextItem.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight,
+ height: o.height,
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ },
+
+ doClick: function () {
+ BI.TextItem.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TextItem.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ doHighLight: function () {
+ this.text.doHighLight.apply(this.text, arguments);
+ },
+
+ unHighLight: function () {
+ this.text.unHighLight.apply(this.text, arguments);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ }
+});
+BI.TextItem.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_item", BI.TextItem);/**
+ * guy
+ * Created by GUY on 2015/9/9.
+ * @class BI.IconTextIconNode
+ * @extends BI.NodeButton
+ */
+BI.IconTextIconNode = BI.inherit(BI.NodeButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.IconTextIconNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-text-icon-node",
+ logic: {
+ dynamic: false
+ },
+ iconCls1: "close-ha-font",
+ iconCls2: "close-ha-font",
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.IconTextIconNode.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+
+ var icon1 = BI.createWidget({
+ type: "bi.icon_label",
+ cls: o.iconCls1,
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+ var blank = BI.createWidget({
+ type: "bi.layout",
+ width: o.height,
+ height: o.height
+ });
+ BI.createWidget({
+ type: "bi.absolute",
+ element: this,
+ items: [{
+ el: {
+ type: "bi.icon_label",
+ cls: o.iconCls2,
+ width: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ },
+ top: 0,
+ bottom: 0,
+ right: 0
+ }]
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", icon1, this.text, blank)
+ }))));
+ },
+
+ doClick: function () {
+ BI.IconTextIconNode.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.IconTextIconNode.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ }
+});
+BI.IconTextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_icon_node", BI.IconTextIconNode);/**
+ * guy
+ * Created by GUY on 2015/9/9.
+ * @class BI.IconTextNode
+ * @extends BI.NodeButton
+ */
+BI.IconTextNode = BI.inherit(BI.NodeButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.IconTextNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-icon-text-node",
+ logic: {
+ dynamic: false
+ },
+ cls: "close-ha-font",
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.IconTextNode.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon, this.text)
+ }))));
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doClick: function () {
+ BI.IconTextNode.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.IconTextNode.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ }
+});
+BI.IconTextNode.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.icon_text_node", BI.IconTextNode);/**
+ * Created by GUY on 2015/9/9.
+ * @class BI.TextIconNode
+ * @extends BI.NodeButton
+ */
+BI.TextIconNode = BI.inherit(BI.NodeButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.TextIconNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-icon-node",
+ logic: {
+ dynamic: false
+ },
+ cls: "close-ha-font",
+ iconHeight: null,
+ iconWidth: null,
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.TextIconNode.superclass._init.apply(this, arguments);
+ var o = this.options, c = this._const;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ cls: "list-item-text",
+ textAlign: "left",
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ height: o.height
+ });
+ this.icon = BI.createWidget({
+ type: "bi.icon_label",
+ width: o.height,
+ height: o.height,
+ iconWidth: o.iconWidth,
+ iconHeight: o.iconHeight
+ });
+
+ BI.createWidget(BI.extend({
+ element: this
+ }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, {
+ items: BI.LogicFactory.createLogicItemsByDirection("left", this.text, this.icon)
+ }))));
+ },
+
+ doClick: function () {
+ BI.TextIconNode.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TextIconNode.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ }
+});
+BI.TextIconNode.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_icon_node", BI.TextIconNode);/**
+ * guy
+ *
+ * Created by GUY on 2015/9/9.
+ * @class BI.TextNode
+ * @extends BI.NodeButton
+ */
+BI.TextNode = BI.inherit(BI.NodeButton, {
+
+ _defaultConfig: function () {
+ var conf = BI.TextNode.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: (conf.baseCls || "") + " bi-text-node",
+ textAlign: "left",
+ whiteSpace: "nowrap",
+ textHgap: 0,
+ textVgap: 0,
+ textLgap: 0,
+ textRgap: 0
+ });
+ },
+ _init: function () {
+ BI.TextNode.superclass._init.apply(this, arguments);
+ var o = this.options;
+ this.text = BI.createWidget({
+ type: "bi.label",
+ element: this,
+ textAlign: o.textAlign,
+ whiteSpace: o.whiteSpace,
+ textHeight: o.whiteSpace == "nowrap" ? o.height : o.textHeight,
+ height: o.height,
+ hgap: o.textHgap,
+ vgap: o.textVgap,
+ lgap: o.textLgap,
+ rgap: o.textRgap,
+ text: o.text,
+ value: o.value,
+ keyword: o.keyword,
+ py: o.py
+ });
+ },
+
+ doClick: function () {
+ BI.TextNode.superclass.doClick.apply(this, arguments);
+ if (this.isValid()) {
+ this.fireEvent(BI.TextNode.EVENT_CHANGE, this.getValue(), this);
+ }
+ },
+
+ doRedMark: function () {
+ this.text.doRedMark.apply(this.text, arguments);
+ },
+
+ unRedMark: function () {
+ this.text.unRedMark.apply(this.text, arguments);
+ },
+
+ setValue: function () {
+ if (!this.isReadOnly()) {
+ this.text.setValue.apply(this.text, arguments);
+ }
+ },
+
+ getValue: function () {
+ return this.text.getValue();
+ },
+
+ setText: function () {
+ this.text.setText.apply(this.text, arguments);
+ },
+
+ getText: function () {
+ return this.text.getText();
+ }
+});
+BI.TextNode.EVENT_CHANGE = "EVENT_CHANGE";
+BI.shortcut("bi.text_node", BI.TextNode);/**
+ * Created by GUY on 2015/4/15.
+ * @class BI.Editor
+ * @extends BI.Single
+ */
+BI.Editor = BI.inherit(BI.Single, {
+ _defaultConfig: function () {
+ var conf = BI.Editor.superclass._defaultConfig.apply(this, arguments);
+ return BI.extend(conf, {
+ baseCls: "bi-editor bi-focus-shadow",
+ hgap: 4,
+ vgap: 2,
+ lgap: 0,
+ rgap: 0,
+ tgap: 0,
+ bgap: 0,
+ // title,warningTitle这两个属性没用
+ tipType: "warning",
+ inputType: "text",
+ validationChecker: BI.emptyFn,
+ quitChecker: BI.emptyFn,
+ allowBlank: false,
+ watermark: "",
+ errorText: ""
+ });
+ },
+
+ _init: function () {
+ BI.Editor.superclass._init.apply(this, arguments);
+ var self = this, o = this.options;
+ this.editor = this.addWidget(BI.createWidget({
+ type: "bi.input",
+ element: "